Exemple #1
0
 public function connect()
 {
     $this->dbus_connection = dbus_bus_get(DBUS_BUS_SESSION);
     if (!$this->dbus_connection) {
         throw new Exception("dbus_bus_get() failed");
     }
     $this->dbus_connection->registerObjectPath(self::dbus_path_notify, array($this, 'callback'));
     list($r, $s) = $this->invoke("NAME " . $this->id, -1);
     if ($r == "CONNSTATUS") {
         $this->handleConnstatus($s);
         return true;
     }
     $this->invokeProtocol(self::default_protocol);
     return true;
 }
Exemple #2
0
    array_shift($argv);
    //skip argv[0] !
    foreach ($argv as $arg) {
        if (preg_match('/--([^=]+)=(.*)/', $arg, $reg)) {
            $_ARG[$reg[1]] = $reg[2];
        } elseif (preg_match('/--([^=]+)/', $arg, $reg)) {
            $_ARG[$reg[1]] = true;
        } elseif (preg_match('/^-([a-zA-Z0-9])/', $arg, $reg)) {
            $_ARG[$reg[1]] = true;
        } else {
            $_ARG['input'][] = $arg;
        }
    }
    return $_ARG;
}
$dbus = dbus_bus_get(DBUS_BUS_SESSION);
$m = new DBusMessage(DBUS_MESSAGE_TYPE_METHOD_CALL);
$m->setDestination("org.kde.VisualNotifications");
$cli_args = arguments($argv);
if (empty($cli_args['input'])) {
    $cli_args['input'] = array();
}
switch ($cli_args['input'][0]) {
    case 'notify':
        $m->setPath("/VisualNotifications");
        $m->setInterface("org.kde.VisualNotifications");
        $m->setAutoStart(true);
        $m->setMember("Notify");
        $m->appendArgs("DBus test app");
        $m->appendArg1(0, 'u');
        $m->appendArgs('', '', "Summary", "Text body", array());