Otaqui.com Blog

Enable Google Gears and Offline Gmail for Mozilla Prism

[Warning : this post suggests stuff that may not work now, or may break in the future. Use at your own risk!]

I’m really happy to hear that, as the official google blog points out, Gmail now has support for Google Gears allowing you to view your mail offline.

This has caused quite a stir in the blogging community – TechCrunch invites you to throw off your chains, GoogleWatch speculates that it might be the tipping point for Gears adoption, Colin Charles mentioning SSBs such as Fluid and Prism (which this article is about), Google Operating System giving a basic overview and also the GadgetWise NYT blog giving it a spread .

So far, so good. Now what if we want to use a Site Specific Browser, such as those created by Fluid and Mozilla Prism ? These “SSBs” are essentially entire browsers, but used only for a single web app – which is quite handy really. I think that Google’s paradigm of basically making each tab / window in your browser it’s own application instance may well remove the need for things like this eventually, but for the time being it would be great to use Gmail’s new offline capability in an SSB.

Well – we can’t do much about enabling Gears in Fluid, since it’s based on WebKit. Check back if you here that Google releases some frm of plugin for WebKit (although actually WK already has HTML5 style “local storage” using SQLite so it could be native support).

We can however do some hacking to get Gears installed in a Prism browser, so let’s go through the process. By the way – I am using Mac OS X 10.5, but I think this should work for any platform that can get Firefox and Google Gears.

I’m using a Google Apps For Your Domain account, it’s worked fine there, although your account will have to have Offline access enabled by google (patience, young grasshopper!).

Step 1: Split a Beam

Go and install Mozilla Prism . I did this by installing it as an extension to my current Firefox.

Once it’s installed and you have restarted the browser, login to your Gmail and from the Tools menu choose “Convert Website To Application.”

Choose whatever options you like in terms of where to put the shortcut. Personally I grabbed Chris Ivarson’s awesome Fluid Gmail Icons and used Preview.app to convert the 128×128 version into a PNG file.

I *also* had a slight issue with not being able to create the app inside the Applications folder, because it needed to Authenticate but just failed silently – YMMV.

Assuming that’s done you should have a nice new Gmail SSB, which you can start and log in to Gmail with. Funky.

Step 2: Start The Fans, Please!

[Note: you have to be older than young, from the UK and to know who Richard O’Brien is to get that “start the fans” bit]

So now we need to get Google Gears installed. You can try doing this from Gmail’s own interface but it will fail complaining that “Gears is not compatiable with XYZ” (where XYZ is the name you gave it and a version number). This is because, even though your Gmail webapp *is( Firefox under the hood, it doesn’t report itself as such to the extension. What we need to do is convince the extension that it is in fact compatible with it.

[Note: it might be more efficient if you want to install several extensions to make your SSB report itself as really being Firefox, but I’m happy with a one-at-a-time approach].

The next thing to do is actually download Google Gears manually. I suggest that you really do try (and fail) to install it from inside the Prism app, because you will be told the current, valid URL for the XPI in the process. If you’re super lazy, here’s where I got mine from (not a link so that you’re encouraged to FIND THE RIGHT URL FOR YOURSELF!):


You might want to use Safari / Opera / wget / IE to actually download it.

Step 3: Unpack, Tweak, Repack

An XPI file is in fact just a ZIP file with delusions of grandeur. Rename the file to “gears-osx-opt.zip” and unpack it.

Now open up “install.rdf” and find the bit that looks like this:


The big long string in curly brackets is the Firefox GUID.  We will need to change this, and also the version numbers.

I found the GUID and version numbers inside my (OS X-specific) “Gmail.app” that Prism created.  Control+Click on it and choose “Show Package Contents” then navigate to “Contents/Resources/application.ini” and open this in a text editor.  It is the “Version” and “ID” values that you want from the “[App]” section.

Applying these to the original install.rdf file we get this (I’ve extended the version numbers just for the hell of it):

Save the edited “install.rdf” file and now you need to repack the zip / xpi.  Take note – you should compress the *files* and not the *directory* or it won’t work.

Change your newly created zip file’s extension back to XPI – and we’re ready to install!

Step 4: Install

This may vary across platforms, I’m not sure.

From the *status bar* (an unusual place to get to the Add Ons / Extensions list) of your Prism app, click the cog and choose “Tools”, “Addons”.  This should pop open the Add Ons panel.

Drag and drop the XPI onto the Add Ons panel and, hopefully, bingo!

If you get an error about “version support” then you might have got the ID or version number wrong somewhere.  If you get one about “cannot find install script” then your XPI / zip is badly formed.  Leave a comment if you need more help here.

Step 5: Enable Gears for Gmail

You’ll need to restart your browser and log back in to GMail.  Then you should be able to click the “Offline” icon at the top of the interface and go through the normal Gears “I trust this application” process.

That’s it! You should now be able to access your mail offline. It’s worth noting that the shortcut that gears can create for you to open your email while offline seems to work fine too.

[Update 31st Jan 2009: It looks like Fluid may support Gears sometime soon !]