EDBus – EFL D-Bus wrapper
As I have wrote in a previous post, I will talk about the newest EFL library: EDBus.
EDBus is a D-Bus wrapper, that provides easy access to D-Bus for EFL applications.
But what is D-Bus?
It’s a protocol of communication between processes, like CORBA and DCOP. Heavily used in all UNIX graphical toolkits, with Windows port and specified by FreeDesktop.org.
Here is a good source of information about D-DBus: http://dbus.freedesktop.org/doc/dbus-tutorial.html
But what about E_DBus? (the old D-Bus binding for EFL)
E_DBus is a thin layer between libdbus and ecore (library that provides main loop), to use it it’s necessary to use libdbus functions to handle with messages which is not trivial and also does not have support to most of FreeDesktop.org interfaces, leaving this work to applications developers.
So EDBus comes to replace E_DBus, and we not only removed the “_” on name but all libdus functions are encapsulated into a simple and friendly API, here is a sample, reading a message with this signature: “a(sb)”
E_DBus + libdbus:
dbus_message_iter_init_append(msg, &iter); dbus_message_iter_recurse(&iter, &array); while (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_INVALID) { dbus_message_iter_recurse(&array, &st); dbus_message_iter_get_basic(&st, &txt); dbus_message_iter_next(&st); dbus_message_iter_get_basic(&st, &b); printf("%s - %dn", txt, b); dbus_message_iter_next(&array); }
EDBus:
edbus_message_arguments_get(msg, "a(sb)", &array) while (edbus_message_iter_get_and_next(array, '(', &st)) { edbus_message_iter_arguments_get(st, "sb", &txt, &b); printf("%s - %dn", txt, b); }
Most applications when ported to EDBus had 50% fewer lines of D-Bus code.
Here a list with more EDBus advantages:
- High abstraction of method call using Proxies
- Life cycle of objects simplified
- arg0, arg1,…. match rules to signal handlers
- Conversion of Eina_Value to and from EDBus_Message
- ObjectManager interface support
In a future I will write giving more details about all advantages, but now you could download the EDBus code and read examples.
http://svn.enlightenment.org/svn/e/trunk/edbus
EDBus still under development, soon we will have a code generator, you only will need pass the Introspection XML and client and server D-Bus code will come almost free. Another object is remove libdbus dependency and talk directly with D-Bus Daemon through socket.