Re: introduction and new DBUS extension

From: Date: Wed, 05 Nov 2008 20:32:45 +0000
Subject: Re: introduction and new DBUS extension
References: 1 2  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-5857@lists.php.net to get a copy of this message
On Sun, 2 Nov 2008, Derick Rethans wrote: > On Sat, 1 Nov 2008, Brad Robel-Forrest wrote: > > > I'd like to introduce myself and get feedback on an extension I've > > written around the D-Bus reference implementation > > (http://www.freedesktop.org/wiki/Software/dbus). This is my first PHP > > extension so I'd be highly appreciative of any input the community > > might offer. The extension itself makes use of the "lower level" API > > (i.e. it does not use or require GLib) and as of the current version > > will only allow calling methods or sending signals from a private bus > > (i.e. registering callable methods or capturing signals is not > > available yet). The extension has seen a fair amount of real-world use > > as it's been incorporated into a commercial network switch and is used > > by the webUI to communicate to various back-end daemons. > > > > At this point, I'd like to know if it is common practice to post the > > extension source to this list or to request for permission to create a > > new project in PECL. > > I've been writing something similar, so yeah, I'd be interested in > seeing something. I've attached the extension as far as I have it ready. It uses an Object Oriented approach to talk to DBUS Objects like a PHP Object and supports at the moment calling methods with support for most datatypes (bool, byte, string, dict, all int types and double) for sending, and single scalar types for return values. It also supports waiting for signals with single scalar return values. I'm planning to use introspection to make marshalling from the one PHP integer type to the 8 different dbus integer types automatic, support for the missing data types, sending signals and receiving method calls, and addressing DBus object properties. The attached .tar.gz file contains a few examples that demonstrate the API in the examples directory. I've also attached those separately. regards, Derick -- HEAD before 5_3!: http://tinyurl.com/6d2esb http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org

<?php $d = new Dbus; $n = new DbusObject( $d, "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications"); $o = $n->Notify( 'Testapp', new DBusUInt32( 0 ), 'iceweasel', 'Testing http://ez.no', 'tEST aPPLICATION', new DBusArray( DBus::STRING, array() ), new DBusDict( DBus::VARIANT, array( 'x' => new DBusVariant( 500 ), 'y' => new DBusVariant( 500 ), 'desktop-entry' => new DBusVariant( 'rhythmbox' ) ) ), new DBusInt32( 9000 ) ); var_dump( $o ); $o = $n->Notify( 'Testapp', new DBusUInt32( 0 ), 'iceweasel', 'Testing http://ez.no', 'Test Application', new DBusArray( DBus::STRING, array() ), new DBusDict( DBus::VARIANT, array( 'x' => new DBusVariant( 500 ), 'y' => new DBusVariant( 500 ), 'desktop-entry' => new DBusVariant( 'rhythmbox' ) ) ), new DBusInt32( 500 ) ); var_dump( $o ); ?> <?php $d = new Dbus; $n = new DbusObject( $d, "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 ); ?> <?php $d = new Dbus; $d->addWatch( 'org.freedesktop.Notifications' ); $d->addWatch( 'org.freedesktop.PowerManagement.Backlight' ); $b = 0; do { $s = $d->waitForSignals( 1000 ); if ( $s ) { echo "signal seen\n"; var_dump( $s->getData() ); } if ( $s && $s->matches( "org.freedesktop.PowerManagement.Backlight", 'BrightnessChanged' ) ) { $b = $s->getData(); } echo "."; } while ( $b < 100 ); ?> <?php $d = new Dbus; $n = new DbusObject( $d, "org.freedesktop.PowerManagement", "/org/freedesktop/PowerManagement/Backlight", "org.freedesktop.DBus.Introspectable"); var_dump( $n->Introspect( false ) ); ?>
« previous php.pecl.dev (#5857) next »