DBus, Mono, Rhythmbox, and Beagle, Oh My!

Uncategorized 15 September 2006 | 0 Comments

So I had this idea of writing a quick search plugin for Beagle to search Rhythmbox’s current playlist titles. They would show up in the search GUI and then you’d double-click on one and it’d handle this (probably through a pseudo-URL like playlist://rhythmbox/my-playlist-name which seems to be the de facto standard amongst Beagle plugins) by sending a DBus event to Rhythmbox to start playing this playlist. Sounds simple enough.

Promise

First of all I headed over to the Beagle site. It turns out that if you want to do more than handle a specific file-type (not an option in this case because the playlists are stored as .xml) you create not a “Filter” but a “Queryable”. Unfortunately the Queryable HowTo is still being written. Nevermind, I can always ask on the mailing list, and taking a look through the tutorial for Filters shows that the API for that is nice and clean and should be similar for the Queryables.

Next I try to find a reference for the C# DBus bindings. I install the Monodoc documentation for DBus, only to discover everything marked with “Documentation for this section has not yet been entered”—the default message for undocumented functions, classes, and so on. Nevertheless, I find a short tutorial on how to use Python with DBus to control Rhythmbox. The class names and functions seem to have similar titles in C#, so I figure this will map fairly directly.

Finding the DBus reference for Rhythmbox takes a fair bit more effort, trawling through mailing list archives on Google. Eventually I find the DBus APIs hiding in a couple of .xml files in the CVS repositories; org.gnome.Rhythmbox.PlaylistManager looks promising.

Misfortune

Unfortunately, I find a post by a last-exit hacker in which he states (my emphasis):

As I was told DBus C# bindings are unusable I went on about writing DBus# objects the hard way.

What? This can’t be right, I’ve already written a little test program:

using System;
using DBus;

namespace RhythmboxQuery
{
   class MainClass
   {
      public static void Main(string[] args)
      {
         Connection bus = Bus.GetSessionBus();
         try {
            Service rhythmbox = Service.Get(bus,"org.gnome.Rhythmbox");
         } catch (ApplicationException ex) {
            Console.WriteLine("Rhythmbox not started: " + ex);
            return;
         }
         Console.WriteLine("Found Rhythmbox.");
         /*

         Okay, so all I need to do now is to call `getPlaylists` on:
         /org/gnome/Rhythmbox/PlaylistManager

         */
         Console.WriteLine("Uhoh.");
      }
   }
}

Despite my valiant attempts to stave off the past through trivial C# programs, the DBus site confirms the aforementioned revelation:

They are schedualed to be removed from the core but has yet to find a maintainer. [sic]

Epilogue

As it turns out, what I had been planning to do would have been impossible anyway because the Rhythmbox DBus bindings lack a PlayPlaylist function in any of the three interfaces. Also, it seems that DBus under C# only plays nicely with C# objects that you have access to—but this could be just because I couldn’t find a single example of how to call methods on non-C# DBus applications.

Ah well, that Beagle Filter API did seem quite nice anyway, I wonder if there are any filetypes I could parse out there…

Tagged in , , ,

Leave a Reply