Exam done. Got cracking on the code today. Slow start, but some progress made. I’ve now got the skeleton code to hook up to DBus and listen for messages. You can even connect to my tool using the Xesam NewSession method, but that’s about it. I’ve started out with GetProperty, but came upon an interesting hitch.
GetProperty is supposed to return a so-called “Variant” type. Depending on the property requested, the method might return a bool, an int, a string, or even an array of strings. Now I’m not sure how the C# bindings for DBus (dbus-sharp) handle this. Intuitively, returning an ‘object’ (the class from which all types are derived) should work, but it doesn’t seem to. Will need to dig deeper, since this might just be a problem with my version of dbus-sharp (0.63, from Gentoo’s gentopia overlay), and speak to the creator of dbus-sharp (Alp Toker) about it.
It feels good to be writing C# code. The focus is purely on solving the problem at hand, rather than small, nagging, ancillary tasks. For example, setting up the Xesam listener is as simple as:
public static int Main(string args)
Connection conn = Bus.GetSessionBus();
Service xesam = new Service(conn, "org.freedesktop.xesam.searcher");
Xesam.Search search = new Xesam.Search();
I’m using the xesam-tools package written by Mikkel Kamstrup Erlandsen for testing this, which makes things a lot simpler for me. The idea now is to continue implementing the Xesam methods by translating to the equivalent implementation using the BeagleClient interface.
Many thanks to jonp and mdx4ever on #mono for their patience with all my n00b questions. :-)
Fun, fun, fun! Good night!