IMAP4 NOTIFY addon for Thunderbird! (Thunderbird 60 compatible!)

Warning: I publish this addon as is. It is a Proof Of Concept. It works well enough for my needs, and I don't have the time neither the Javascript and Thunderbird internals expertise to create a real addon usable by regular users.

Sorry for that. I already invested too much time on this. I am a consultant, btw, so you could just pay me :-).

This code is BSD licensed.

In IMAP4 NOTIFY addon for Thunderbird! I proposed an ugly addon to add IMAP4 notify to Mozilla Thunderbird. I have been enjoying that addon for four years (since late 2014) and I forgot about it. Cool.

In november 2018 Mozilla published Thunderbird 60 and my addon was disabled as "incompatible".

OK, I thought, I will check it out when I have a spare cycle.

So I used Thunderbird 60 for like two weeks without my notify addon.

My friend, what a hell.

I am not going to explain the rational or the details for this Thunderbird addon. You can find them in IMAP4 NOTIFY addon for Thunderbird!. I am going to explain only the source code changes. They are actually quite minor.

File bootstrap.js:

--- bootstrap.js        2014-10-11 17:56:36.000000000 +0200
+++ /home/jcea/.thunderbird/XXXX/extensions/extension-notify-thunderbird@jcea.es/bootstrap.js       2018-11-15 03:27:31.113372680 +0100
@@ -4,9 +4,9 @@
 * https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules
 */
 Components.utils.import("resource://gre/modules/Timer.jsm");
-Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource://gre/modules/osfile.jsm");
 Components.utils.import("resource://gre/modules/NetUtil.jsm");
+Components.utils.import("resource://gre/modules/Console.jsm");

 var incomingServer = null;
 var rootFolder = null;
@@ -45,7 +45,8 @@
                        if (folder == "")
                                continue; // El \n final, si lo hay
                        folder = incomingServer.getMsgFolderFromURI(rootFolder, folder);
-                       Services.console.logStringMessage(folder.prettiestName+" "+folder.URI);
+                       // https://developer.mozilla.org/en-US/docs/Web/API/console
+                       console.info(folder.prettyName+" "+folder.URI);

                        // Costly, and running in the main thread.
                        // Would be wonderful if we could do this in a worker thread

Here we simply change the way we do the logging. You can find some details in https://developer.mozilla.org/en-US/docs/Web/API/console. We also change the name pretty printing, from the deprecated folder.prettiestName() to folder.prettyName().

Even without those changes, my addon should work in Thunderbird 60. Nevertheless Mozilla deprecated plenty of APIs so they decided that addons should be explicitly declared compatible. This is done in file install.rdf:

--- install.rdf 2014-10-11 17:56:36.000000000 +0200
+++ /home/jcea/.thunderbird/XXXX/extensions/extension-notify-thunderbird@jcea.es/install.rdf        2018-11-15 01:32:07.938443225 +0100
@@ -6,7 +6,7 @@
   <Description about="urn:mozilla:install-manifest">
     <em:id>extension-notify-thunderbird@jcea.es</em:id>
     <em:name>NOTIFY IMAP</em:name>
-    <em:version>0.0.14</em:version>
+    <em:version>0.0.16</em:version>
     <em:creator>jcea@jcea.es</em:creator>
     <em:unpack>true</em:unpack>

@@ -16,7 +16,7 @@
       <Description>
         <em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
         <em:minVersion>31.0</em:minVersion>
-        <em:maxVersion>31.*</em:maxVersion>
+        <em:maxVersion>60.*</em:maxVersion>
       </Description>
     </em:targetApplication>

And that is all it's needed. We only need to declare the addon as compatible with Thunderbird 60. That is. The addon should be still compatible with previous Thunderbird versions.

Download version 0.0.16.

Bibliography