public function invoke($s) { $m = new DBusMessage(DBUS_MESSAGE_TYPE_METHOD_CALL); $m->setDestination(self::dbus_destination); $m->setPath(self::dbus_path_invoke); $m->setInterface(self::dbus_interface); $m->setMember("Invoke"); $m->setAutoStart(true); $m->appendArgs($s); $this->_debug("invoke: %s\n", $s); $r = $this->dbus_connection->sendWithReplyAndBlock($m, $this->timeout); if (!$r) { throw new Exception("dbus_connection_send_with_reply_and_block() failed"); } $tmp = $r->getArgs(); $this->_debug("reply: %s\n", $tmp[0]); if ($tmp[0] == "" || $tmp[0] == "OK") { return array($tmp[0], null); } list($r, $s) = explode(" ", $tmp[0], 2); if ($r == "ERROR") { throw new Skype_Exception(null, intval($s)); } return array($r, $s); }
//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()); $m->appendArg1(array(), 'a{sv}');
//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.freedesktop.Notifications"); $cli_args = arguments($argv); if (empty($cli_args['input'])) { $cli_args['input'] = array(); } switch ($cli_args['input'][0]) { case 'notify': $m->setPath("/org/freedesktop/Notifications"); $m->setInterface("org.freedesktop.Notifications"); $m->setAutoStart(true); $m->setMember("Notify"); // Application Name $m->appendArgs("DBus test app"); // Replaces ID $m->appendArg1(0, 'u');