Thunderbird 3 – re-implementing the ISP Hook for customized deployments

About two years ago I did some work to customize the Mozilla Thunderbird product to work with the UVM IMAP servers out-of box:
https://sharepoint.uvm.edu/sites/ad/distribution/appconfig/Thunderbird.aspx

This project made use of the so-called “ISP Hook” for Thunderbird, loosely documented here:
https://developer.mozilla.org/en/Thunderbird_ISP_hooks

Unfortunately, it appeared that with the release of Thunderbird 3.0 the ISP Hook was being retired in favor of “autoconfig”:
https://wiki.mozilla.org/Thunderbird:Autoconfiguration

Autoconfig is a promising project, but unfortunately, it lacks the ability to configure all of the settings previously available in the ISP Hook RDF file:
https://bugzilla.mozilla.org/show_bug.cgi?id=475139

I had a long look at using the previous “autoconfig” (called “Mission Control Desktop”), and while this approach is powerful, it really requires too much external scripting to be effective as a deployment mechanism (MCD seems more ideally suited to management of systems in a lab environment):
https://developer.mozilla.org/En/MCD

So what is the solution?  It involves:

  1. One expatriate Windows sys admin and reverse-engineering expert.
  2. A few line of additional shell scripting to our existing build system.
  3. The ability to distinguish capital and lowercase letters.

While explaining the ISP Hook problem to my colleague Ben Coddington, I noticed that the old Account Configuration dialogs (complete with the create “UVM Email Account” option) was still available under TB3, but that the dialog could no longer be activated following a new installation.  Ben said “I’ll bet I can fix that”, and proceeded to unpack every “jar” file in the Thunderbird installation directory. 

He searched around for strings found in the old config dialog, located the XUL call that brings up the dialog, and then traced this call back to the parent function that initiates account creation for new profiles.  In the end we only needed to modify one line of javascript in one JAR to restore the old account dialog.  In “%ProgramFiles%Mozilla Thunderbirdchrome”, we unpack “messenger.jar”, and open “.contentmessengermsgMail3PaneWindow.js”, then replace “NewMailAccount(msgWindow, okCallback);” with “MsgAccountWizard(okCallback);”.  repack the archive, then drop it into the installer, and we are good to go.  Other than that, it is just like using the ISP Hook with TB 2.

There is one other minor change… I also set the following additional default option in the global prefs.js file:

user_pref("mail.winsearch.enable", true);

This defaults Windows Search integration to “on” in the new account setup dialog.  It is a cool new feature that everyone should use (in my opinion).

The following is the modified build script I now use to quickly repackage new Thunderbird releases into customized versions.  Note that we use the free gnuwin32 version of “sed” to do our javascript modifications (be sure to use the –b (—binary) switch to avoid file munging), and we also need 7-zip (7z.exe) to handle file unpacking and packing:

REM Thunderbird customized build script for UVM.
REM Updated December 2009 for Thunderbird 3.0 support.
REM REQUIRES: 7z.exe, 7zr.exe and sed.exe in parallel "..bin" directory
REM     Unmodified Thunderbird installer in .source directory
REM        all required config files in .config directory
REM     (including 7z control file, ISP Hook RDF file, and modified prefs.js)
REM OUTPUT: Fully modified Thunderbird installer in .Installer directory.
@echo off

Echo Cleaning up old builds...
del .Installer*.exe
rmdir /s /q .build
set /P tbver=Enter Thunderbird version number to build (i.e. "3.0.0.0"):

Echo Extracting setup files from OEM Installer...
mkdir .buildtemp
..bin7zr x .source*.exe -o.build

Echo Extracting messenger.jar contents...
REM messenger.jar is a ZIP type archive... need full 7z executable to unpack.
..bin7z x .buildnonlocalizedchromemessenger.jar -o.buildtemp

Echo modifying messenger functions...
..binsed.exe --binary "s/NewMailAccount(msgWindow, okCallback);/MsgAccountWizard(okCallback);/" <.buildtempcontentmessengermsgMail3PaneWindow.js > .buildtempcontentmessengermsgMail3PaneWindow_new.js
MOVE /Y .buildtempcontentmessengermsgMail3PaneWindow_new.js .buildtempcontentmessengermsgMail3PaneWindow.js

Echo Repacking messenger.jar...
REM again, we must use the full 7z executable.  -mx=0 means archive with no compression.
..bin7z a -tzip -mx=0 .buildtempmessenger.jar .buildtemp*

Echo Copying UVM Custom config files to source...

copy /Y .configprefs.js .buildnonlocalizeddefaultsprofileprefs.js
mkdir .buildnonlocalizedispen-US
copy /Y .configUVMMail.rdf .buildnonlocalizedispen-USUVMMail.rdf
copy /Y .buildtempmessenger.jar .buildnonlocalizedchromemessenger.jar

Echo Deleting temporary files...
rmdir /s /q .buildtemp

Echo Repackaging Thunderbird installer...
..bin7zr a .InstallerUVM_Thunderbird_setup_%tbver%.7z .build*
copy /b ..bin7zS.sfx + .configconfig.txt + .InstallerUVM_Thunderbird_setup_%tbver%.7z .InstallerUVM_Thunderbird_setup_%tbver%.exe

Echo Cleaning up installation source...
REM rmdir /s /q .build
del /f /q .InstallerUVM_Thunderbird_setup_%tbver%.7z
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s