Writing apps for the N900, part 4– the power of DBus

There is a contents page for all these posts.

Matters arising from last time. Several people have been replying to these posts as if I was the embodiment of the Maemo team. Although I worked on some really interesting parts of the desktop as part of a team from Collabora, I didn’t have anything to do with the package format or anything like that, and I’m writing these posts as an individual (and I welcome corrections). If you want to ask about the rationale behind anything here, there might be people who would know more at talk.maemo.org.

It’s a grand life on the buses. One of the many wonderful things to happen to the free desktop in recent years has been the invention of DBus as the glue to stick it all together; it’s gone a long way towards making Unix not suck.  Maemo sticks together with DBus just as much as GNOME or KDE do, which means we can interact with system services fairly painlessly.  And if we don’t know how to do something, we can always run dbus-monitor, use some other program to do what we wanted to do, and see how it managed.  Then we know what to google for when we’re looking for the official documentation.

Sharing is good. So today we’re going to be adding a “share” button to the app, so that we can tell our friends when we find an interesting link on reddit, and we’re going to be doing it using only a DBus client. Adding the entry to the menu is pretty trivial:

Selector with the 'share' item added

Now, let’s consider how we might want to share things with people:

  • Microblogging (twitter, identi.ca…): yes, definitely. You can very simply post a message to an account on one of these systems using DBus services provided by a library called microfeed. We’ll add an optional dependency on that library, and assume that people who are using it will already have set it up (using Mauku or something similar).
  • Email: certainly. We can interact with the email subsystem using DBus services provided by modest.
  • IM: yes, but… We could do this by putting up a dialogue from the address book, waiting for them to choose a contact, and then sending the message using Telepathy. But that’s not what we want; what we want is to start a conversation: we want to put up the IM window with the link as a sent message and allow the recipient to respond. I don’t know a good way of doing that, but maybe you do.
  • “Sharing services” usually means file hosting services like share.ovi.com, and isn’t really the sort of thing that concerns us here– even if the link’s to an image, you probably don’t want to upload a second copy of the image to your Ovi account.
  • Bluetooth: probably overkill (do people really send URLs over bluetooth? Apparently they do, actually, so maybe we’ll add that later.)

But let’s stick with microblogging and email for now. I’ve created a rather rough version of this idea as a separate file, sharing.c, in case it could be separately useful to someone else. This brings us up to raeddit-06 (diff to raeddit-05, git cloneable, and available from maemo-extras). When the user taps “Share”, this part of the program will put up another selector listing “Email” and as many microblogging services as it can find:

Sharing selector

Let’s say we choose Twitter; then the message gets posted, and we can go and check it in Mauku or the web browser:

Successful tweet

Behold the power of DBus!

Next time we’ll be adding the ability to view images in-process rather than launching the web browser, and we’ll be learning about a rather wonderful innovation called “stackable windows”.

Published by

Thomas Thurman

Mostly themes, triaging, and patch review.

4 thoughts on “Writing apps for the N900, part 4– the power of DBus”

  1. Why require two taps when one ought to suffice? There’s a lot of screen space taken up by the ‘Share’ menu item. You could split it into three narrower buttons, say, ‘-> Twitter’, ‘-> identi.ca’ and ‘-> email’.

    My actual question is: would you have to write a custom widget to do that, or can it be done with HildonTouchSelector?

  2. The HildonTouchSelector is one-dimensional, to the best of my knowledge. But your suggestion could still be implemented by allowing the sharing subsystem to add entries to the main menu, so it went

    * View site
    * Read comments
    * Share on Twitter
    * Share on identi.ca
    * Share by email

    I did it in two stages mainly to keep the parts of the program separate.

Leave a Reply

Your email address will not be published. Required fields are marked *