[Fwd: DBus Bindings for Javascript]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Figured I'd forward this over here, as it's pretty interesting stuff...


--- Begin Message ---
Hey everyone,

I've been working on writing DBUS bindings for Mozilla Javscript. The 
goal of this project is to make it possible for XUL and extension 
developers to integrate with the Linux desktop.

The bindings are still in an early state and need lots of cleanup, but 
already supports consuming existing services, creating new services, 
signals, and xml introspection.

The API is very similar to the python bindings, here's an example of how 
to query NetworkManager for interface information:

	const NM_IFACE_INTERFACE = {
		   name: "org.freedesktop.NetworkManager.Devices",
		methods: [ 'getName', 'getIP4Address',
                            'getActiveNetwork' ]
	};
	
	const NM_NETWORK_INTERFACE = {
		   name: "org.freedesktop.NetworkManager.Devices",
		methods: [ 'getName' ]
	};

	var bus = DBUS.getSystemBus();
	
	var nm = bus.getObject("org.freedesktop.NetworkManager",
			       "/org/freedesktop/NetworkManager",
			       NM_INTERFACE);

	var devices = nm.getDevices();

	for (var x = 0; x < devices.length; x++) {
		var device =
			bus.getObject("org.freedesktop.NetworkManager",
			              devices[x], NM_IFACE_INTERFACE);
		var name = device.getName();
		alert('Found interface: ' + name);
         }

Specifying the interface methods is required because NM does not support 
XML introspection. When querying a service that does, you can pass the 
interface name as a string to getObject instead.

One of the goals from the start was to use XPCOM only as a bridge to the 
C DBUS library. Everything else is implemented using Javascript.

Right now I'm looking for both general feedback, as well as someone to 
review my code and suggest ways to clean it up.

The code is available via mercurial at 
http://eric.extremeboredom.net/hg/mozjs_dbus/

A sample program is included that demonstrates network-manager, 
notify-daemon, and avahi. To run, clone the code into top-level
'extensions' folder in an up to date mozilla-central and run from
dist/xpi-stage/mozjs_dbus/ using xulrunner. You'll need to pass 
--enable-dbus to the moz configure script so that the library paths are 
included.

Obligatory screenshots:
http://orion.extremeboredom.net/~eric/DropBox/libnotify-js.png
http://orion.extremeboredom.net/~eric/DropBox/mozjs_dbus_avahi_2.png

There was a project a while back called DBuzilla, which has been 
abandoned. My library is much simpler because in addition to being much 
less reliant on XPCOM, it makes use of glib, rather than re-implementing 
all of the threading/mainloop integration stuff. I was, however, able to 
re-use some of his data marshaling code, so it was not all for nothing.

I look forward to hearing back from people on this list!

Thanks,
Eric

_______________________________________________
dev-platforms-linux mailing list
dev-platforms-linux@xxxxxxxxxxxxxxxxx
https://lists.mozilla.org/listinfo/dev-platforms-linux

--- End Message ---
-- 
Fedora-desktop-list mailing list
Fedora-desktop-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-desktop-list

[Index of Archives]     [Fedora Users]     [Fedora KDE]     [Fedora Announce]     [Fedora Docs]     [Fedora Config]     [PAM]     [Red Hat Development]     [Red Hat 9]     [Gimp]     [Yosemite News]

  Powered by Linux