Skype and DBus: should my client library act as a server?

Julien JPK julienjpk at email.com
Mon Mar 9 16:31:00 PDT 2015


Hello there,

I began learning about DBus a few weeks ago, and I'm trying to get a
grip of it, through its low-level API. I understand that it would be
easier to start with a higher-level wrapper, or even GLib, but I tend to
understand things better when I study them from their lowest level (and
come on, using a Python or Java binding wouldn't be that much fun...).

I started studying DBus in order to write a small Skype library, which
would then allow me to write Skype-connected programs without bothering
too much with DBus specifics. However, I am getting a little confused as
to whether my library should work as a client, or as a server providing
objects (or maybe both?). Here's why:

Skype provides a single object: /com/Skype. This object has one method:
Invoke(String). In order to send a request to Skype, I need to call this
method, and pass my request as a parameter. These requests are defined
by Skype's protocol. For instance, in order to get a list of my
contacts, I need to send "SEARCH FRIENDS". The Invoke method will then
return my contacts list as a string: "USERS user1, user2, ...".

However, when Skype has too much data to reply, it returns an empty
string instead, and ends the method call. At first, it seemed to me like
Skype was just refusing to reply (too much data), but using
dbus-monitor, I noticed that my request wasn't completely ignored. After
returning "", Skype began building its heavy reply, and when it was
done, tried to contact my program (library) through a completely
different object and interface. Here's an example with "SEARCH
CHATMESSAGES", which returns a complete list of my chat messages:

   method call sender=:1.95 -> dest=:1.659
   path=/com/Skype/Client; interface=com.Skype.API.Client;
   member=Notify
      string "CHATMESSAGES id1, id2, ..."

Here, the sender is Skype, and the destination is a program using my
library. As you can see, while the Invoke(String) call returned nothing,
it seems like Skype did try to reply later on, through a different
method: my chat messages are sent to my program through a Notify(String)
method, and a /com/Skype/Client object... which, as a client, my library
does not provide.

I thought at first that Skype was responding with a signal, but that's
clearly not it... Does this mean that, while it is designed to act as a
client component, my library should register an object to the session
bus, and be ready to receive replies through it, while it sends requests
through Skype's /com/Skype object, in FTP duplex-fashion?

If so, would any of you have some pointers as to how I can register
objects and their methods using the low-level API? I do understand the
concepts themselves (having read "An Introduction to the Basics" [1] and
a few others), but even with the Doxygen documentation (DBusServer,
DBusConnection, ...), I can't seem to find a way to do this...

Thanks in advance for your help,
Regards,
JJPK.

[1] : http://www.freedesktop.org/wiki/IntroductionToDBus/

-- 
Julien JPK (PGP key 0xC3075A58)
julienjpk at email.com


More information about the dbus mailing list