Exemple #1
0
 /**
  * Create the dbus-object & -proxy
  */
 public function __construct()
 {
     if (extension_loaded('dbus') === true) {
         $oDbus = new \Dbus(\Dbus::BUS_SESSION, true);
         $this->_oProxy = $oDbus->createProxy('org.freedesktop.Notifications', '/org/freedesktop/Notifications', 'org.freedesktop.Notifications');
     }
 }
Exemple #2
0
 protected function notify($title, $message)
 {
     if (!class_exists('Dbus', false)) {
         return;
     }
     $d = new \Dbus(\Dbus::BUS_SESSION);
     $n = $d->createProxy('org.freedesktop.Notifications', '/org/freedesktop/Notifications', 'org.freedesktop.Notifications');
     $n->Notify('Twircd_Util_DbusLog', new \DBusUInt32(0), 'twircd', "TwIRCd: " . $title, $message, new \DBusArray(\DBus::STRING, array()), new \DBusDict(\DBus::VARIANT, array()), 1500);
 }
 /**
  * @return bool
  * @see http://derickrethans.nl/talks/dbus-ipc10s.pdf
  * @throws \BadFunctionCallException
  */
 public function send()
 {
     if (!extension_loaded('dbus')) {
         throw new \BadFunctionCallException('dbus extension is not available');
     }
     $dbus = new \Dbus(\Dbus::BUS_SESSION);
     $notification = $dbus->createProxy("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications");
     $id = $notification->Notify($this->appName, new \DBusUInt32(0), $this->icon, $this->summary, $this->body, new \DBusArray(\DBus::STRING, array()), new \DBusDict(\DBus::VARIANT, array()), 1000);
     return $id > 0;
 }
$ctl = new control_modules();
if (!Defined('SETTINGS_SKYPE_CYCLE') || SETTINGS_SKYPE_CYCLE == 0) {
    exit;
}
include_once DIR_MODULES . 'patterns/patterns.class.php';
$pt = new patterns();
Define('DEVIDER', 'и');
$last_day = date('d-M-y');
$last_minute = date('H:i');
$old_message = $latest_message = '';
$tmp = SQLSelectOne("SELECT * FROM shouts WHERE MEMBER_ID = 0 ORDER BY ADDED DESC");
$latest_message = $tmp['MESSAGE'];
$old_message = $latest_message;
//проверяем, запущен ли Скайп. Если нет - пока вываливаемся
//Инициализируем Dbus
$dbus = new Dbus(Dbus::BUS_SESSION, true);
//Попытка вызова методов. Если ошибка - значит нам не удалось к скайпу подключиться
for ($i = 0; $i < 5; $i++) {
    try {
        //Подключаемся к скайпу
        $n = $dbus->createProxy('com.Skype.API', '/com/Skype', 'com.Skype.API');
        //Имя нашей программы, авторизация в скайпе
        $n->Invoke('NAME MajorDoMo');
        //Используем последний протокол
        $n->Invoke('PROTOCOL 8');
        break;
    } catch (Exception $e) {
        DebMes('Skype error : ' . $e->getCode() . '. Error message: ' . $e->getMessage());
        $n = null;
    }
    sleep(5);
Exemple #5
0
<?php

$dbus = new Dbus(Dbus::BUS_SESSION);
$interface = "im.pidgin.purple.PurpleInterface";
$method = "ReceivedImMsg";
$dbus->addWatch($interface, $method);
$proxy = $dbus->createProxy("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject", "im.pidgin.purple.PurpleInterface");
$kill = false;
do {
    $signal = $dbus->waitLoop(1000);
    if ($signal instanceof DbusSignal) {
        if ($signal->matches($interface, $method)) {
            /**
             * Contents of the recieved data, see:
             * http://developer.pidgin.im/doxygen/dev/html/pages.html
             * http://developer.pidgin.im/doxygen/dev/html/conversation-signals.html
             * data:
             *  0 => the reciever account
             *  1 => the user sending the message
             *  2 => the message
             *  3 => the IM conversation
             *  4 => flags
             */
            $data = $signal->getData()->getData();
            $receiver = $data[0];
            $sender = $data[1];
            $message = $data[2];
            $conversation = $data[3];
            $responseMessage = "I'm sorry Dave. I'm affraid I can't do that.";
            // 2034 is *my* account's number, yours will be different
            // 3681 is the account number from which *I* accept messages
Exemple #6
0
<?php

$content = implode(file("ui.html"), "");
//tell astrologic to start streaming
$dbus = new Dbus(Dbus::BUS_SYSTEM);
$proxy = $dbus->createProxy("info.echord.Astromobile.AstroLogic", "/AstroLogic", "info.echord.Astromobile.AstroLogic");
$proxy->startWebVideo();
//display locations for navigation requests
$locations = $proxy->getLocations();
$locationSelector = '<select name="location" id="locationSelector">';
foreach ($locations->getData() as $loc) {
    $locationSelector .= '<option value="' . $loc . '" >' . $loc . '</option>';
}
$locationSelector .= '<option value="User">User</option>';
$locationSelector .= '</select>';
$content = preg_replace("/{{locationselector}}/i", $locationSelector, $content);
echo $content;
Exemple #7
0
<?php

$d = new Dbus();
$n = $d->createProxy("org.gnome.ScreenSaver", "/org/gnome/ScreenSaver", "org.gnome.ScreenSaver");
var_dump($n->GetActive());
$n->SetActive(true);
var_dump($n->GetActive());
sleep(5);
$n->SetActive(false);
?>

Exemple #8
0
# 2014 (C) Mariano Reingart <*****@*****.**>
# En Windows habilitar COM en php.ini: extension=c:\PHP\ext\php_com_dotnet.dll
# Para Linux instalar: sudo pecl install dbus-0.1.1
# Registrar/iniciar python controlador.py --register (Windows), --dbus (Linux)
error_reporting(-1);
try {
    # Crear objeto interface con el componente del controlador fiscal:
    if (@class_exists('COM')) {
        echo "creando interface ...";
        $ctrl = new COM('PyFiscalPrinter') or die("No se puede crear el objeto");
        echo "interface creada version {$ctrl->Version}\n";
        # habilitar excecpciones (capturarlas con un bloque try/except), ver abajo:
        $ctrl->LanzarExcepciones = true;
    } else {
        if (@class_exists('Dbus')) {
            $dbus = new Dbus(Dbus::BUS_SESSION, true);
            $ctrl = $dbus->createProxy("ar.com.pyfiscalprinter.Service", "/ar/com/pyfiscalprinter/Object", "ar.com.pyfiscalprinter.Interface");
        } else {
            echo "No existe soporte para COM (Windows) o DBus (Linux) \n";
            exit(1);
        }
    }
    # Iniciar conexión con el controlador fiscal:
    $marca = "epson";
    // configurar "hasar" o "epson"
    $modelo = "epsonlx300+";
    // "tickeadoras", "epsonlx300+", "tm-220-af"
    // "615", "715v1", "715v2", "320"
    $puerto = "dummy";
    // "COM1", "COM2", etc. o "/dev/ttyS0" en linux
    $equipo = "";
<?php

$dbus = new Dbus();
$proxy = $dbus->createProxy("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject", "org.freedesktop.DBus.Introspectable");
$data = $proxy->Introspect();
file_put_contents('introspect.xml', $data);
<?php

$dbus = new Dbus(Dbus::BUS_SESSION);
$interface = "im.pidgin.purple.PurpleInterface";
$method = "ReceivedImMsg";
// watching only for this particular signal on this particular interface
$dbus->addWatch($interface, $method);
$kill = false;
do {
    $signal = $dbus->waitLoop(1000);
    if ($signal instanceof DbusSignal) {
        // even if we watch only for one signal on one interface
        // we still can get rubbish, so making sure this is what we need
        if ($signal->matches($interface, $method)) {
            $data = $signal->getData()->getData();
            // if we received "kill" as a message, then kill it.
            if ($data[2] == 'kill') {
                $kill = true;
                echo "Goodbye, cruel world!\n";
            } else {
                echo "Got stuff!\n";
            }
        }
    }
} while (!$kill);
 private function _notify()
 {
     if (extension_loaded('dbus') === false) {
         return;
     }
     $d = new Dbus(Dbus::BUS_SESSION);
     $n = $d->createProxy("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications");
     $n->Notify('Whitewashing_PHPUnit', new DBusUInt32(0), 'phpunit', 'PHPUnit Test-Run Report', sprintf("Suite: %s\n%d tests run in %s minutes.\n%d errors, %d failures...", $this->_suiteName, $this->_tests, date('i:s', time() - $this->_startTime), $this->_errors, $this->_failures), new DBusArray(DBus::STRING, array()), new DBusDict(DBus::VARIANT, array()), 1000);
 }
Exemple #12
0
<?php

define('NM', "org.freedesktop.NetworkManager");
$d = new Dbus(Dbus::BUS_SYSTEM, true);
$n = $d->createProxy(NM, "/org/freedesktop/NetworkManager", NM);
$wifi = array();
foreach ($n->GetDevices()->getData() as $device) {
    $device = $device->getData();
    $dev = $d->createProxy(NM, $device, "org.freedesktop.DBus.Properties");
    $type = $dev->Get(NM . ".Device", "DeviceType")->getData();
    if ($type == 2) {
        $wifiDev = $d->createProxy(NM, $device, NM . ".Device.Wireless");
        foreach ($wifiDev->GetAccessPoints()->getData() as $ap) {
            $apDev = $d->createProxy(NM, $ap->getData(), "org.freedesktop.DBus.Properties");
            $props = $apDev->GetAll(NM . ".AccessPoint")->getData();
            $ssid = '';
            foreach ($props['Ssid']->getData()->getData() as $n) {
                $ssid .= chr($n);
            }
            $wifi[] = array('ssid' => $ssid, "mac_address" => $props['HwAddress']->getData());
        }
    }
}
$request = array('version' => '1.1.0', 'host' => 'example.com', 'wifi_towers' => $wifi);
$c = curl_init();
curl_setopt($c, CURLOPT_URL, 'https://www.google.com/loc/json');
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, json_encode($request));
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$result = json_decode(curl_exec($c))->location;
echo "<a href='http://openstreetmap.org/?lat={$result->latitude}&amp;lon={$result->longitude}&amp;zoom=18'>here</a>\n";
Exemple #13
0
 /**
  * Test simple notify call
  */
 public function testNotify()
 {
     $sText = sprintf('%s: %s', 'dbus', md5(time()));
     $this->assertInstanceOf('\\notifyy\\AbstractAdapter', $this->_object->notify(\notifyy\Notifyable::SUCCESS, $sText));
 }
Exemple #14
0
<?php

$d = new Dbus(Dbus::BUS_SESSION);
$n = $d->createProxy("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications");
$id = $n->Notify('Testapp', new DBusUInt32(0), 'iceweasel', 'Testing http://ez.no', 'Test Notification', new DBusArray(DBus::STRING, array()), new DBusDict(DBus::VARIANT, array('x' => new DBusVariant(500), 'y' => new DBusVariant(500), 'desktop-entry' => new DBusVariant('rhythmbox'))), 1000);
echo $id[0], "\n";
Exemple #15
0
 /**
  *
  */
 protected function notify()
 {
     $d = new Dbus(Dbus::BUS_SESSION);
     $n = $d->createProxy('org.freedesktop.Notifications', '/org/freedesktop/Notifications', 'org.freedesktop.Notifications');
     $n->Notify('PHPUnit_Util_Log_DBUS', new DBusUInt32(0), 'phpunit', 'PHPUnit Test Report', sprintf("Suite: %s\n%d tests run in %s minutes.\n%d errors, %d failures", $this->suiteName, $this->tests, date('i:s', time() - $this->startTime), $this->errors, $this->failures), new DBusArray(DBus::STRING, array()), new DBusDict(DBus::VARIANT, array()), 1000);
 }
Exemple #16
0
<?php

require_once 'vendor/autoload.php';
class SkypeBot
{
    static function notify($a)
    {
        global $n;
        $engine = new \Inviqa\SkypeEngine($n);
        try {
            $engine->parse($a);
        } catch (Exception $e) {
            echo $e->getMessage() . PHP_EOL;
        }
    }
}
$d = new Dbus(Dbus::BUS_SESSION, true);
$n = $d->createProxy("com.Skype.API", "/com/Skype", "com.Skype.API");
$n->Invoke("NAME PHP");
$n->Invoke("PROTOCOL 7");
$d->registerObject('/com/Skype/Client', 'com.Skype.API.Client', 'SkypeBot');
do {
    $s = $d->waitLoop(1000);
} while (true);
<?php

$dbus = new Dbus();
$proxy = $dbus->createProxy("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject", "im.pidgin.purple.PurpleInterface");
$accounts = $proxy->PurpleAccountsGetAllActive();
foreach ($accounts->getData() as $account) {
    if ($proxy->PurpleAccountIsConnected($account)) {
        $username = $proxy->PurpleAccountGetUsername($account);
        $protocolId = $proxy->PurpleAccountGetProtocolId($account);
        $protocolName = $proxy->PurpleAccountGetProtocolName($account);
        echo $username . " is connected on the " . $protocolName . " (" . $protocolId . ") protocol.\n";
    }
}
 /**
  * Is called when PDepend has finished the logging process.
  *
  * @return void
  */
 public function endLogProcess()
 {
     if (extension_loaded('dbus') === false) {
         return;
     }
     $dbus = new Dbus(Dbus::BUS_SESSION);
     $proxy = $dbus->createProxy("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications");
     $proxy->Notify('PDepend', new DBusUInt32(0), 'pdepend', 'PDepend', sprintf('%d files analyzed in %s minutes...', $this->parsedFiles, date('i:s', time() - $this->startTime)), new DBusArray(DBus::STRING, array()), new DBusDict(DBus::VARIANT, array()), 1000);
 }
Exemple #19
0
#!/usr/local/bin/php
<?php 
include "Skype.php";
include "Bot.php";
$dbus = new Dbus(Dbus::BUS_SESSION, true);
$proxy = $dbus->createProxy('com.Skype.API', '/com/Skype', 'com.Skype.API');
//Connect to skype
$proxy->Invoke("NAME PHP");
$proxy->Invoke('PROTOCOL 8');
Skype::$bot = new Bot($proxy);
$dbus->registerObject('/com/Skype/Client', 'com.Skype.API.Client', 'Skype');
// Register message listener
while (1) {
    $votes = Skype::$bot->getVotes();
    if (isset($votes)) {
        foreach ($votes as $chat => $vot) {
            if ($vot['time'] < time() - 10 * 60) {
                echo "Clear: " . $chat, "\n";
                Skype::$bot->clearVoting($chat);
            }
        }
    }
    $s = $dbus->waitLoop(1);
}