Where Everybody's Crazy

I'm a missionary in Japan. The name of my mission agency is WEC International. That's supposedly Worldwide Evangelisation for Christ, but I think I have a better idea about what it stands for...

2007-03-17

Firefox/Thunderbird Extensions

I used to be thoroughly confused about Mozilla extensions and how you plug in stuff to work with Firefox and Thunderbird. Since my experiments with writing Songbee, I've become much happier with XUL and Javascript and therefore the whole extension concept, and looking back, it's actually very simple. Perhaps one day I'll write a nice easy tutorial about how to do it. Perhaps, though, it's better just to say that it's actually not as scary as it looks.

Anyway, now, whenever I come across something that Firefox or Thunderbird won't do the way I want, I'll just do it myself. For instance, one of the things I liked about mutt is that it would sort my outgoing mail into "sent" folders by month: so, outbox-200703 and so on. The first thing we need to do is translate that concept into Javascript: We want to add the current year and month to a given string, and set that as our main Fcc folder preference. The tricky thing with Mozilla is always knowing how to tie into the rest of the system, but you can usually finding that by reading through code that does something similar to what you want. For instance, I find that other code sets preferences by getting a handle to the "preferences service" and then calling the setCharPref method on that handle. So the JavaScript side of things looks like this:

gPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var now = new Date();
var mon = now.getMonth()+1;
var str = "outbox-"+now.getFullYear()+(mon < 10 ? "0"+mon : mon);
gPrefs.setCharPref("mail.identity.id1.fcc_folder", "imap://simon@alibi.simon-cozens.org/"+str);

Now where do we put this? I had some trouble finding a hook to hang this onto, before realising that Mozilla has a generic hook to run Javascript from: the "hidden window". So we overlay the hidden window with a bit of XUL:

<?xml version="1.0"?>
<overlay id="dated-fcc" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://dated-fcc/content/dated-fcc.js" />
</overlay>

And this is all hooked together in the chrome manifest:

content dated-fcc chrome/content/
overlay chrome://messenger/content/hiddenWindow.xul chrome://dated-fcc/content/dated-fcc.xul

The first line tells the system where to find all the "dated-fcc" files, and the second says that we're putting our XUL file on top of the hidden window. And, well, that's all. I've written a Thunderbird extension. Actually, I've written three in the past couple of weeks: one to control the behaviour of Thunderbird/Firefox when talking to things with bad SSL certificates, one to provide more activity feedback when Thunderbird's doing things, and this one.

So if Mozilla doesn't do what you want, there's no excuse. You have the source, you can hack it, and it's not as scary as it first appears.


Posted at 18:55:34 in technology xul | # | G | P | 3 Comments
Language
Japanese English
Links

Tags and Tools
« 2007-03 »
S M TWTFS
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

RSS


I am...

lathos: Heading down to Oookayama. The おおお joke never gets old.


Photoblog

castle1_filtered.jpg

gosanpai_filtered.jpg

ichibangai2_filtered.jpg

machinaga_filtered.jpg

mizu.jpg


Speedblog

http://daiyainn.gooside.com/ # 京都だいや旅館 京へおこしやす

http://www.e-chords.com/guitartab.asp?idmusica=96629&keyb=true # Where Could I go Tab by Ben Harper - E-Chords

http://www.inmamaskitchen.com/RECIPES/RECIPES/Soups/vegetable_stock.html # Moosewood's Vegetable Stock Recipe

http://www.foodnetwork.com/food/recipes/recipe/0,,FOOD_9936_8389,00.html # Good Eats Roast Turkey Recipe: Recipes: Food Network

http://www.reallivepreacher.com/node/203 # You Ain't Jesus, PreacherPart Two: Losing The Language of Love

http://leiterreports.typepad.com/blog/2005/06/95_theses_on_th.html # Leiter Reports: A Philosophy Blog: 95 Theses on the Religious Right

http://cbae.nmsu.edu/~dboje/teaching/338/traits.htm # TRAITS

http://jweb.kokken.go.jp/gitaigo/index.html # 擬音語・擬態語 - 日本語を楽しもう! -

http://www.nanzan-u.ac.jp/SHUBUNKEN/publications/jjrs/jjrs_cumulative_list.htm # Japanese Journal of Religious Studies: Cumulative list of Essays & Book Reviews

http://www.myspace.com/chloecfrancis # www.myspace.com/chloecfrancis

http://www.solar.ifa.hawaii.edu/cgi-bin/StrikeProb?latitude=+35.38&longitude=-136.26&location=Nagahama,+Japan # Tropical Cyclone Strike Probabilities for Nagahama, Japan

http://www.missionjapan.org/mission/jmissionorg.html # Japan Mission Organization List

http://www.aquasapone.com.au/soapmaking/showergel_soap.html # AquaSapone - How to make shower gel from natural handmade soap

http://www.ultimate-guitar.com/tabs/d/danilo_montero/la_unica_razon_crd.htm # La Unica Razon Chords by Danilo Montero @ Ultimate-Guitar.Com

http://kb.mozillazine.org/Synchronizing_Windows_based_PDAs # Synchronizing Windows based PDAs - MozillaZine Knowledge Base

http://www.provider-navi.jp/campaign/gyao-withflets/ # USENインターネット接続サービス GyaO 光|当サイト限定キャンペーン

http://mytown.asahi.com/shiga/ # asahi.com:マイタウン滋賀 - 朝日新聞地域情報

http://news.bbc.co.uk/2/hi/programmes/from_our_own_correspondent/6506915.stm # BBC NEWS | Programmes | From Our Own Correspondent | Japanese men take marriage lessons

http://wiki.clamwin.com/index.php/Thunderbird_Extension # ClamWin Free Antivirus. GNU GPL Free Software Open Source Virus Scanner and Spyware Detector. Free Windows Antivirus and Anti Spyware. Stay Virus and Spyware Free with Free Software.

http://scan.dalo.us/ # Scandalous Software - Mac XML Tools


Musicblog

Blue States – Diamente

John Martyn – Don't Think Twice It's Alight

The Blind Boys of Alabama – Many Rivers to Cross

Powered by Glob!
Search: