A Perl API for dbus
Daniel P. Berrange
dan at berrange.com
Mon Aug 9 16:01:42 PDT 2004
Last week I was looking around for a messaging system to
let multiple Test::AutoBuild (www.autobuild.org) instances
co-ordinate their operation, and to notify applications
of build results/status. After considering XML::RPC,
and plain old HTTP, I decided on dbus. Unfortunately
there was no Perl API in evidence, so having wanted an
opportunity to learn Perl-XS programming I wrote one...
It is by no means complete, but I've done enough that it
is potentially useful to people besides myself, hence
this mail
It is a minimal Perl+XS wrapper around the plain old C
APIs for dbus, written in a object-oriented perl style.
It provides the following objects mapping onto the
corresponding dbus APIs:
DBus::Server - dbus_server_XXX
DBus::Connection - dbus_connection_XXX
DBus::Timeout - dbus_timeout_XXX
DBus::Watch - dbus_watch_XXX
DBus::Message - dbus_message_XXX
DBus::Iterator - dbus_message_iter_XXX
For ease of construction, there are three trivial
subclasses of Message:
DBus::Message::Signal
DBus::Message::MethodCall
DBus::Message::MethodReturn
DBus::Message::Error
And likewise a trivial connection subclass for
connecting to well known message buses:
DBus::Bus
With the exception of the Iterator object, these
modules have pretty near complete coverage of the
C APIs. For Iterators, I still need to add support
for the array & dictionary datatypes.
In keeping with the style of the basic C API, there
are no external dependancies in this module, bar
Perl >= 5.8.0 (earlier Perl versions should work if
you grab Time::HiRes from CPAN). Aside from the
basic API wrappers I've written
* Unit tests for as much of the perl code as I
can test without having to run a test server.
* API documentation for core perl APIs
* A pure perl event loop using select system
call, with full support for timers & syntactic
sugar for hooking up connection watch & timeout
handlers
This is still very much work in progress, with things
I want to do:
* More unit tests - its really rather hard testing
multiplexed I/O in a single process!
* Better error handling (mostly the out of memory
return codes, and connection/server connect
failure)
* Finish Iterator API to support arrays & dictionaries
* Finish off documentation
* Change the Perl namespace to be Net::DBus
Once i do those bits & test its operation within my
original scenario (Test-AutoBuild) I'll consider it
ready for general use, but if anyone wants to take a
look at it in the meanwhile, then my ViewCVS pages are
http://cvs.berrange.com/cgi-bin/viewcvs.cgi/freeware/DBus/
BTW, thanks to all those concerned for the good job on
the plain C APIs - they were very easy to write a Perl
wrapper to!
Regards,
Dan.
--
|=- GPG key: http://www.berrange.com/~dan/gpgkey.txt -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- berrange at redhat.com - Daniel Berrange - dan at berrange.com -=|
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://freedesktop.org/pipermail/dbus/attachments/20040810/41d88643/attachment-0001.pgp
More information about the dbus
mailing list