09 Oct 12
Thunderbird Extension Development
Recently, i have been working on an productizing an product of my working company. It involves developing an extension for Thunderbird. During the development process, i have discovered there has been inadequate resources out there for Thunderbird Extension, especially when most developers are interested in working on another Mozilla’s flagship product — FireFox. So, i would like to share my experience on this
To begin, we have to prepare the appropriate directory.
sample.xpi
/install.rdf
/components/
/defaults/
/plugins/
/chrome.manifest
/chrome/icons/default/
/chrome/
/chrome/content
/chrome/skin
Then, we have to work on the install.rdf. It’s an RDF file to document about the extension’s information.
<?xml version="1.0"?> <RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#"> <Description about="urn:mozilla:install-manifest"> <em:id>sample@steve.chan</em:id> <em:name>Sample Plugin</em:name> <em:version>1.0</em:version> <em:creator>Steve Chan</em:creator> <em:description>First Plugin on Mozilla Thunderbird</em:description> <em:homepageURL>http://www.codetter.com/</em:homepageURL> <em:targetApplication> <Description> <em:id>GUID</em:id> <em:minVersion>1.5</em:minVersion> <em:maxVersion>2.0.0.*</em:maxVersion> </Description> </em:targetApplication> </Description> </RDF>
Note that,
- <em:id> shall be filled in with string formatted as “string”@”string” like an email.
- under “targetApplication”, the <em:id> shall be a proper GUID, it could be easily gen with tools (Google it)
- For minVersion and maxVersion, they determine which version of Thunderbird could install your plugin. View Valid Application Versions.
After finishing install.rdf, there’s another manifest to prepare. It’s chrome.manifest which describe the extension file structure of yours.
content sample chrome/content overlay chrome://messenger/content/messenger.xul chrome://sample/content/message-overlay.xul skin sample classic/1.0 chrome/skin/classic/ style chrome://messenger/content/messenger.xul chrome://sample/skin/style.css
- content describes the location where content’s file and folder are located
- overlay describes which UI of Thunderbird is to be worked on / Override. (Do read about XUL to get your familiar with this idea)
- skin describes the location where the skin’s file and folder are located
- style describes what stylesheet to apply on various UI.
Next step is to create an message-overlay.xul
<?xml version="1.0">
<overlay id="sample" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<statusbar id="status-bar">
<statusbarpanel id="my-panel" label="Hello, World!" onclick="alert('Hello World!')"/>
</statusbar>
</overlay>
- statusbar with id=”status-bar” states the merge point of the extension, the while xul describe the addition of an “Hello, World!” label on the bottom right corner of Thunderbird (status bar).
- The onclick is given a javascript function to create an alert box when the “Hello, World!” label is being clicked. (XUL works with javascript!)
Last but not least, we have to package the extension
Zip all the Content of the extension (without the root folder), and rename .zip into .xpi, and it’s DONE! Congratulation.
Thanks, it’s very useful!
There’s not much info around.
Comment by Jumbo Cheung — March 22, 2010 @ 3:39 pm