It starts …

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)
{
    Application.Init();

Connection conn = Bus.GetSessionBus();
Service xesam = new Service(conn, "org.freedesktop.xesam.searcher");
Xesam.Search search = new Xesam.Search();
xesam.RegisterObject(search, "/org/freedesktop/xesam/searcher/main");

Application.Run();

return 0;

}

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!

This entry was posted in Blog and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. ext_44666
    Posted May 7, 2007 at 2:29 pm | Permalink

    Hey Arun,

    You’re using the wrong dbus-sharp library. The one that until recently shipped with D-Bus is the old one based on the C library and doesn’t work well at all. Use Alp’s NDesk DBusSharp from here: http://www.ndesk.org/DBusSharp

    Joe

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>