Finally the new update for Maemo 5 is out; it’s good to see that months of bug fixes and new features are finally available to everybody! One of the new features, not directly visible to users, is that developers can now add new buttons to the Contacts application menu. At the beginning we wanted to make the plugin system more powerful, but sadly it required too many changes and we didn’t have enough time to finish and test it properly.
A “Hello World” button added by the example plugin
To add new buttons you have to create a new object that derives from
OssoABookMenuExtension and implements the required methods. For an example of this, see the example on gitorious that Mathias wrote and the API documentation.
Please, don’t go crazy with this new feature and don’t add 2000 different buttons to the menu!
As I said in my previous blog post, some changes in the Facebook XMPP servers lead to the unmerging of the Facebook contacts that were merged with local contacts in the N900 address book. To fix this problem I wrote the small utility Facebook migrator, now available in Maemo extras-testing, that automatically merges back your contacts. Please remember that extras-testing contains unstable software and mine is not an exception! The source code is available on the Collabora git repositories.
If you have any feedback, please let me know in the comments to this post. The only known issue at the moment is that saving your contacts is quite slow, but I didn’t bother making it fast considering that it’s just a one time operation.
In other news, I noticed that I don’t get an email notification anymore when somebody comments on my blog, but a simple PHP script that uses the
mail() function sends emails correctly. In the logs I don’t see anything useful and I’m sure the notifications are not in the spam folder. Does anybody have any suggestion on how to debug this?
The N900 address book can merge multiple contacts into a single entity: if you have a friend that has a phone number, an email address, a Jabber user name, a MSN one and so on, then you can merge all of the different entities into a single meta-contact.
Locally stored details and an IM user name in the same contact
The different IM contacts are tracked through their username and should be immutable, but yesterday Facebook changed all the IDs from something like “email@example.com” to “-firstname.lastname@example.org”. For the address book this means that all the previous contacts were deleted from the IM roster and new contacts were added, so you get duplicate contacts. Moreover, when a contact is removed from the roster we leave the IM user name in the contact details, if you click the button you can add the contact back to one of your rosters. In the Facebook case this means that you end up with all of your meta-contacts with a useless button that cannot do nothing.
The fix for this is to remove the old IDs and merge your contacts again, simple but tedious. A better way to do it is to be patient and wait until I finish a program that will do it for you in a few click
Update: I finished and release the program, see my blog post about Facebook migrator.
 Actually, some changes in the IDs are possible for normalisation purposes; if you add “FooBar@example.COM” it will become “email@example.com” in your roster. (And yes, the normalisation is buggy in PR1.1, but it will be fixed in PR1.2.)
Sometimes the creation of the contact chooser used on the N900 can be slow so, using callgrind and kcachegrind, I tried to understand what is the source of the slowness. This lead me to find some unexpected, and apparently undocumented, differences between upstream GTK and the Maemo version.
The Maemo 5 contact chooser
The widget contains a GtkTreeView that uses a model with just one column for the contact objects. How can its creation be so slow? To my surprise most of the time was spent decompressing the avatar images!
The avatars of the contacts are loaded, scaled and cropped in the cell data function of the GtkTreeViewColumn as, for various reasons, we cannot cache on disk the resulting image or generate it before the creation of the widget. Following calls of the cell data function for the same row won’t need to generate the avatar anymore. Doing non-trivial operations in the cell data function is not the nicest thing to do, but this should not be a problem as the cell data function is called only for the visible rows, right? No, at least not on Maemo!
To verify it just try this example program: on Maemo the
cell_func() function is called once per item in the model plus once per visible item, elsewhere only once per visible item.
After a bit of investigation together with Claudio, we discovered that on Maemo there is a function called
gtk_​tree_​view_​column_​get_​cell_​data_​hint() that returns
GTK_​TREE_​CELL_​DATA_​HINT_​ALL. The hint tells you why the function was called; in the example code the function is called on the hidden rows only to get their sensitivity so there is no need to set the “
pixbuf” property of the cell at this point.
Just this tiny change in the address book code makes the contact chooser open much faster if you have a lot of contacts with big avatars, like the ones that Hermes creates. On the other hand the delayed loading made the scrolling become non-smooth
To fix the scrolling I had to implement some asynchronous loading of the avatars. The contact chooser now tries to load as many avatars as possible in idle moments and also tries to load first the avatars for the contacts that the user is more likely to see. The results seem quite good; now the contact list is fast, scrolling is smooth and the delayed loading of avatars should not be visible in normal cases.