Meego 1.0 on the Dell Inspiron Mini 1012

While on the topic of Meego, just a quick note for those looking to install on the Dell Inspiron Mini 1012.

Meego itself generally runs quite well on this device, but this machine has a Broadcom BCM4212 wireless chipset (also known as a Dell Wireless 1397) which although supported by the Linux b43 driver is not supported by Meego 1.0. Although Meego 1.0 has a new enough kernel (, it is unfortunately not a simple case of using the firmware cutting tool to extract the firmware, the module itself is compiled out. This is Meego bug #287.

Your other (non-free) option is to use Broadcom’s STA driver. You’re going to need to yum install make gcc diffutils kernel-netbook-devel to build the module.

Finally if you’re looking to buy a netbook, also know that the trackpad is on this device is pretty frustrating under X due to the buttons being under the touch surface (it’s only slightly less frustrating in Windows 7, to be honest). Collabora X Guru Daniel Stone tells me support for trackpads with buttons under the touch surface is getting better so it’s a lot less annoying jumpy, but it still needs more work. I’ve been using an external mouse.

The Meego 1.0 People Panel

So Meego 1.0 for Netbooks shipped last week. Although I miss that tubby cat, Meego 1.0 is very visually attractive and quite nifty.

One of the really neat things about Meego is how it integrates messaging right into the interface. Unsurprisingly, this messaging is powered by Telepathy, the framework that makes communications into a service that you can use throughout your product. Collabora, with its team of Telepathic Ninjas, helped Intel with some of the Telepathy integration for this release.

Meego 1.0 People Panel
Meego 1.0 People Panel

The People Panel shows your available contacts on the left, and a list of your ongoing conversations on the right. Each conversation lists the number of unread messages.

This integration requires no code in Telepathy, and is all done using a Telepathy Observer (I’ve talked about Observers before). This will work with Empathy, or any other well behaved chat client (as it turned out that Empathy originally wasn’t well behaved, that had to be fixed, those fixes are in Empathy 2.30).

Mission Control allows any application to ensure a communications channel exists, and find an appropriate application to handle that channel. This means that double clicking on a user or ongoing conversation in the People Panel causes Mission Control to signal Empathy (the handler) to bring that conversation to the user’s attention (pop it up) or open a new window if required, even though the People Panel and Empathy are completely separate applications and completely unaware of one another. Again this will work with any well behaved chat client.

This same feature could easily be integrated into GNOME Shell or anywhere else. The code to implement this in Meego is free software.

tramtracker in maemo extras-devel [plus some crap about Optus]

Finally got a version of tramtracker (a client for tracking Melbourne trams) and python-suds uploaded to Maemo's extras-devel. There are a couple of issues, the known ones relate to this bug.

In my head I was having a race to see which would be done first: Optus sorting out my phone enough so that I could have data on it; or getting my app into the repository. Turns out, even though I didn't make a lot of effort, I still won.

In fairness, I probably could have gone today to get my phone recontracted (since I think it cut over last night), but the guy told me to come back on Saturday. I'm really hoping this is the end of about 4 hours of dealing with Optus over my phone. It started off by me looking at 3G data plans, and realising that if Stephanie and I both recontracted for 12 months, and put our numbers onto the same account, we could pay for both of our phones for the cost of her phone bill. Unfortunately my phone number was still in my Dad's name, and stuck in some antique account keeping system, so had to be migrated forwards (which took forever), then some nonsense about a credit check. [I'm sorry, but you gave the international student who's been here 4 months, and is not even a resident, a $60/month iPhone plan; why do I need to jump through so many hoops when I have a job and only want a $20/month plan where I bring my own damn phone?] Finally though both phones have been moved onto the same account, so I can go and recontract tomorrow (hopefully; I've been saying this for weeks).

That said, while Optus the company have basically been screwing me around. I do have to give kudos to the peoples at Optus Shop Brunswick, who have spent countless hours on the phone to Optus HQ trying to sort this out for me, even though they've so far earned absolutely no commission from me. I had thought about recontracting my phone at whatever store I happened to pass, but I think I should make sure these guys get the commission.

fixing button theming with GtkBuilder

This is a bit icky. It would be neater if the Python bindings exposed hildon_gtk_widget_set_theme_size(), but not much. So, to fix the button theming if you've created your interface with GtkBuilder, it looks something like this:

# these aren't exported anywhere, copied from Maemo GTK+

# fix theming
for widget in self.ui.get_objects():
    if not isinstance(widget, gtk.Button): continue
    # hildon_gtk_widget_set_theme_size is not bound into Python
    if widget.get_name().startswith('largebutton'):
        widget.set_size_request(-1, HILDON_HEIGHT_THUMB)
    elif widget.get_name().startswith('kpbutton'):
        widget.set_size_request(HILDON_HEIGHT_THUMB, HILDON_HEIGHT_THUMB)

happy new year

Had a pleasant day off eating snacks, watching The Pretender with friends and hacking on my tram tracking app. I added geolocation, which meant needing to test on the device, so I had to package up python-suds for Maemo (git-buildpackage repo, Maemo package).

The app actually runs quite nicely on the device, although each SOAP query is a little slower than in Scratchbox. This makes the Update Database quite a bit slower (also possibly calling COMMIT after each INSERT is a little expensive, I'm not sure). Otherwise things are quite zippy, including searching by location.

I'm not entirely sure I'm using the location API correctly, I don't seem to receive any updates to the location. I think it does some caching to speed up lookups and cut down on signals, so I'll need to try it from another location, but I don't even seem to receive an initial signal when the GPS locks.

I started having a go at packaging the application itself, but ran into some error I don't understand (Debian always seems to throw obscure errors when I try to package things). Regardless, the branch is here. Would love some help here.

It seems like all the fundamentals are now in place; including favourites, status messages and geolocation. Still want to add support for tracking individual trams. Also need to tweak the interfaces, buttons don't look like they have the right texture. Was thinking of using my Google Maps/GtkWebKit experiments to add a “View On Map” option for location based searches.

Melbourne Tram Tracker for the N900

So Collabora's robotic and non-robotic overlords very graciously bought everyone on staff an N900 for Christmas. In my opinion, it's actually a very nice phone (although possibly a little on the large side); but the let down is there just isn't the same host of applications for it. Still, possessing both the tools and the skills, I figured I should do something about this, rather than complain.

One of the most useful iPhone applications in Melbourne is the real-time tram tracker. For stops without a display board, you can type in the stop ID and get the upcoming arrivals at that stop. You can also find nearby stops via GPS and a bunch of other things. It turns out that Yarra Trams offer a SOAP WSDL web service that is reasonably well documented, so I've spent a few days putting together a basic tram tracker for Maemo 5 (even if only two people will ever use it).

It currently can show upcoming trams for a stop by ID or by searching for stops by road names. Could possibly also do things like search for stop by route. There is a lot of information available. It doesn't yet do searching by location; the information is in the database, I've just not yet looked at how the location APIs work yet. Also need to add support for storing favourites.

I also want to add support for tracking a tram by tram ID. I'm wondering if it's possible to use the GPS to detect periods of immobility and check the upcoming tram stop after the tram starts moving again. I habitually miss stops; so what I think would be neat is to dial in a stop number or cross road you're looking for, and have your phone notify you when you're approaching it.

The web service uses python-suds, which is unfortunately not packaged for Debian, so I can't just rebuild it for Maemo (if anyone wants to package this up for me, that would be really awesome). Then I'll find out how well my app actually runs on the device.

In case anyone cares, the source code is here.

a threaded processing queue in PyGTK

I'm currently writing a PyGTK client that needs to make network requests using a library that doesn't integrate with the GLib mainloop (python-suds), so I found myself wanting to be able to make network requests without blocking the mainloop, and getting callbacks in my main thread when operations were done. The pattern to use is clearly having a dedicated network thread. In C I might have used GAsyncQueue, however I've found myself quite liking queue.Queue.

The following is a fairly generic class for queuing asynchronous requests. Calling the add_request() method from the main thread queues a function to be run in the worker thread. If the callback or error keywords are provided, these will then be called from the GLib mainloop in the main thread (queued via g_idle_add).

from threading import Thread
from Queue import Queue

import gobject

class ThreadQueue(object):
    def __init__(self):
        self.q = Queue()

        t = Thread(target=self._thread_worker)

    def add_request(self, func, *args, **kwargs):
        """Add a request to the queue. Pass callback= and/or error= as
           keyword arguments to receive return from functions or exceptions.

        self.q.put((func, args, kwargs))

    def _thread_worker(self):
        while True:
            request = self.q.get()

    def do_request(self, (func, args, kwargs)):
        if 'callback' in kwargs:
            callback = kwargs['callback']
            del kwargs['callback']
            callback = None

        if 'error' in kwargs:
            error = kwargs['error']
            del kwargs['error']
            error = None

            r = func(*args, **kwargs)
            if not isinstance(r, tuple): r = (r,)
            if callback: self.do_callback(callback, *r)
        except Exception, e:
            if error: self.do_callback(error, e)
            else: print "Unhandled error:", e

    def do_callback(self, callback, *args):
        def _callback(callback, args):
            return False

        gobject.idle_add(_callback, callback, args)

We can then inherit this class to provide setup for our specific application:

class WebService(ThreadQueue):
    def __init__(self, guid=None, **kwargs):
        """Initialise the service. If guid is not provided, one will be
           requested (returned in the callback). Pass callback= or error=
           to receive notification of readiness."""

        self.guid = guid
        self.add_request(self._setup_client, **kwargs)

    def _setup_client(self):
        print "Setting up client"


        return self.guid

Which we call from our program like this:

class Client(object):
    def __init__(self):
        self.w = WebService(guid=guid, callback=self.client_ready)

    def client_ready(self, guid):
        print "client ready:", guid




What's really cool though is adding methods to the API that are called asynchronously for you. Python makes this possible through the power of decorators. Add the following decorator to a method, and it instead of it being called directly, it will be added to the processing queue.

def async_method(func):
    """Makes the given method asynchronous, meaning when it is called it
       will be queued with add_request.

    def bound_func(obj, *args, **kwargs):
        obj.add_request(func, obj, *args, **kwargs)

    return bound_func

class WebService(ThreadQueue):

    def GetStopInformation(self, stopNo):
        print "Requesting information for stop", stopNo


And that's it! If you can't follow it, don't worry too much. This is possibly the most Pythonesque bit of code I've ever written, but I've tried to make it generic enough that other people can use it for whatever they need. It's currently part of my app that's beginning to take shape, but the source is here.

Incidently, Maemo people: are there Glade definition files allowing me to use Hildon widgets, GtkBuild and Glade 3? That would be super awesome if there were.