How hard can it be? (Or why you don’t have custom per contact ringtones on Maemo)

Often in blogs, forums or IRC you can find people complaining of missing features in some programs (and some of them are very rude). While they can be right sometimes, other times they just make me angry because they don’t know how difficult writing software can be, and they don’t understand the difference between a semi-working prototype and a proper stable application written by professional developers, designed by professional UI designers and tested by professional testers.

Implementing some features can actually be quite difficult and it could be better to skip those from your product and focus on other things; on the N900 one of these missing features is the ability to set customised ringtones for specific contacts.
Several people wondered how hard it can be, after all a lot of old phones do it. What they don’t consider is that, in many ways, the N900 is not a traditional phone and is more similar to a small computer. On the other hand, the N900 still needs to be reliable to be certified as a phone; for ringtones this means that the ringtone should be played as soon as the phone call is received, or the user could miss it.
Now suppose your N900 is under heavy load due to multitasking (real multitasking, like on a normal computer) and you receive a phone call from a friend; being a close friend that often calls you, you have an MP3 ringtone set just for him. The phone has to look up for the contact corresponding to the phone number, load the file from the (slow) memory card, load the libraries for playing the ringtone, uncompress the file, and finally play it. All of this on a phone under heavy load with most programs swapped out of memory!
To workaround this problem the N900 seems to do some tricks: the ringtone is uncompressed into a (big) WAV file and saved on the faster (but small) internal memory, and the component playing the ringtone is memlocked (i.e. never removed from memory). Of course, you cannot do this for all the possible ringtones or the already small disk space would be used immediately. Choosing not to uncompress the files, on the other hand, would mean keeping loaded in memory all the possible codecs.

Does this mean that it’s impossible to have a different ringtone for a specific contact on Maemo? No, it just means that if you want it you have to be ready to accept that the ringtone could start playing a couple of seconds later in some uncommon heavy load conditions. When you are ready to do that you just have to wait a couple of days, so that I can polish and publish the program I wrote to have custom ringtones :D

In other news, I’m going to GUADEC for the whole week: see you there!

I'm going to GUADEC

Contacts merger 0.1.3 in Maemo extras-testing

Since my previous post about the contacts merger, I fixed a crash, made it handle better broken vcards, improved the partial matching and made the installer quit the address book when the plugin is installed, so no reboot is needed.
The new 0.1.3 merger is now available in Maemo extras-testing, just look for “Merge your duplicate contacts” in the application manager.

What’s next

Suppose I could have some spare time to write some small applications relating to the N900 address book; what would you want me to work on? The application should be small and not require changes to the closed source components. Suggestions are welcome in the comments, but I cannot assure you anything :)

Update: I meant extras-testing of course, not extras

Finding duplicate contacts in your address book

One of the common complaints about the Maemo address book is that it’s easy to get a lot of duplicate contacts as the address book is able to pull your contacts from various IM services. From the beginning there has been a way to merge duplicates, but it meant manually going through all of your contacts hunting down the duplicates.
Today I finished writing the first version of a program that tries to automatically detect duplicates based on the IM names, emails, phone numbers and names. Of course this is just based on heuristics; you still have to go through the list and select the contacts that you want to merge. You can find this utility under the name “Merge your duplicate contacts” in the application manager and it’s available in Maemo extras-devel. Remember that extras-devel contains unstable software: enable it only if you really know what you are doing!
After installing Contacts Merger you have to reboot your phone[1] and then you will get a “Find duplicate contacts” button in the menu of the main address book window.

The window suggesting the possible merges
The window suggesting the possible merges

Update: I released 0.1.1 that fixes a crasher in case of malformed contacts.

Update 2: Forgot to say where to get the code.

[1] Sadly the address book doesn’t automatically load newly installed plugins without a restart; see bug #10542.

Plugins for the N900 address book

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
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!

Merge back your Facebook contacts

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.

WordPress troubles

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?

Facebook and the N900 address book

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
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[1], but yesterday Facebook changed all the IDs from something like “u123456789@chat.facebook.com” to “-123456789@chat.facebook.com”. 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.

[1] Actually, some changes in the IDs are possible for normalisation purposes; if you add “FooBar@example.COM” it will become “foobar@example.com” in your roster. (And yes, the normalisation is buggy in PR1.1, but it will be fixed in PR1.2.)