Category Archives: mozilla

Getting your Firefox extension version number

Sometimes you just want to show the version number (or any other meta data) of your own Firefox addon as specified in the install.rdf. You want to display this in your about page for example. In Firefox 2 and 3, you can to use this function:

function getVersion(addonID) {
		var extMan = Components.classes[";1"].getService(Components.interfaces.nsIExtensionManager);
		var ext = extMan.getItemForID(addonID);
		return ext.version;

// usage
var version = getVersion("{my addon id}");

Inputting your addon ID, you will get your version number back. Inside the method, the variable ext (nsIUpdateItem) has a lot more metadata properties you can use as well if you so choose.

However, in the new Firefox version 4, the addon APIs have totally changed. The call to get the addon metadata has changed from synchronous to asynchronous which tends throws a spanner into the works. There seems to be a tendency to migrate all javascript data calls to asynchronous to avoid freezing the UI. Thus, rewriting getVersion means rewriting all the consumers to expect asynchronous operations. Here’s the new version that supports Firefox versions 2 to 4.

function getVersion(addonID, callback) {
	var ascope = { };

	if (typeof(Components.classes[";1"]) != 'undefined') {
		var extMan = Components.classes[";1"].getService(Components.interfaces.nsIExtensionManager);
		var ext = extMan.getItemForID(addonID);

	if (typeof(Components.utils) != 'undefined' && typeof(Components.utils.import) != 'undefined') {
		Components.utils.import("resource://gre/modules/AddonManager.jsm", ascope);

	ascope.AddonManager.getAddonByID(addonID, function (addon) { callback(addon.version); } );


// usage:
var version;
getVersion("{my addon id}", function(ver) { version = ver; });
// you don't know when version will be populated

Generally, in my use cases, I need to get the version and I don’t want to continue on until I have the version. Other than rewriting, the only workaround is to fetch the version number on extension start up and cache it somewhere. Thus all subsequent get version calls will get that cached number synchronously. Such a pain :/

A radical vision for Thunderbird

After hearing about the recent plans of Mozilla Co. spinning off Thunderbird into a new organisation, I can’t help but add my 2c. I see an opportunity for radical change in the direction of Thunderbird. I’ve personally used Thunderbird since the 1.0 days and it’s been an invaluable tool to manage of my email. However, there in lies the problem. With more and more people using online email these days, the role of Thunderbird is diminishing. If we step back and look at the fundamental problem which Thunderbird, which email, solves – It’s the communication between users. We now have many more forms of communication and interaction between users. More and more email is taking a backstage to more contemporary mediums such as IM and even social networking sites like MySpace and Facebook. So why are we still looking at email? There seems to be a general consensus that Thunderbird should grow into a PIM/Email client. A email/personal organiser is good, but why would you want to create something that’s already available? We shouldn’t be chasing the tail lights of Outlook and Evolution.

What I’m suggesting here I guess is to rethink Thinderbird – lose the focus on mail, in favour of more interesting communication mediums like IM, Facebook and MySpace. With the launch of OpenSocial from Google, connecting to social networks should be made much more easily. Thunderbird can utilise these APIs to bring users of social networks what it brought to email users in the past. There is a growing user base of social networks and it’s only getting larger. With many users part of several networks, managing their identities across these networks can become a painful and time-consuming. An application that manages multiple networks, a social network aggregator if you will, is something that we be desired of from these users. Thunderbird can handle multiple email accounts and it doesn’t take much to see that a natural evolution would be handling multiple social network accounts.

The new functionality, like managing social networks can’t be tacked on like an extra arm to the email functionality. There has to be a rethink from ground up. Right now the interface of Thunderbird is that of traditional email clients. You have accounts and folders and emails. This legacy model will be hard and awkward to reconcile with newer social networking models. Classification of messages/emails are no longer done with folders but with tags that allow them to he connected to multiple categories. Instead of the ‘address book’ you now have ‘friends’ and you certainly want to tag them.

Whether this new application, be it Thunderbird or a something brand new, there exists an opportunity to fill an enormous and growing void. Thunderbird is at crossroads and if there is a better time for a new direction, it would be now. In the post, I’ve mainly talked about one facet, which is social networking, but there are many other facets (IM/VoIP/Cal?) I believe should be part of the broader Thunderbird strategy. Aggregating all the different types of communication is surely a role that fits a next generation Thunderbird. This idea is not new and some members of the community share similar views.

Remember, as the /. meme goes, in Korea, only old people use email.

Multiple Cookie Containers for Firefox

A few weeks ago I began work on modifying the cookie system on Firefox to support multiple “containers”. Multiple Containers enables users to log in to many websites as multiple users on the same Firefox session. It is very useful for web developers who require this functionality to test their user account systems. Another use is for people who have multiple web mail accounts with the same provider that they want simultaneously logged on to. This is an oft-requested feature that Internet Explorer partially supports. (See bug #117222)

I’m happy to say that this is now ready for testing. Below is a working build for Windows. It is based on the latest Trunk plus the cookie patch and extension. Unfortunately for Mac and Linux users that wish to try the patch, they will have to manually compile Firefox with the patch below.

Continue reading

Mozilla in Scary Movie 3?

A couple of weeks ago, I went to the theatres with a couple of friends and we incidentally went and watched Scary Movie 3. The movie was mediocre, a few laughs here and there, but what surprised me was that I found traces of Mozilla in it!

I then took the time of compiling this page.

Laptop looks like it’s running Mozilla (Seamonkey), from the layout of the toolbar icons. (was clearer on the big screen :p)

The protagonist using Firebird, identified by the Qute theme icons and layout on what looks like a fusion of redhat’s bluecurve (window frames) and Mac OS X
(menu bar)?

The protagonist forgot to turn on popup-blocking: This was the unfortunate result…

Curious red dino in cody’s room… coincidence?

I might have missed some instances. If so, please tell me.