foudfou/FireTray — Issue #13: RFE: New Messages Indicator (aka Biff)
Author: vineyard
Created: 2012-02-04 02:06:33+00:00
State: open

I routinely have accounts with thousands of unread messages. Thus, triggering icon changes and displaying tooltips based on unread message counts is useless to me.

Essentially I want to exactly replicate the behavior of the old and now-defunct MozTrayBiff extension.

I did some poking around, and I found that Thunderbird offers an internal "biff" mechanism. It appears that a similar method to what I am proposing existed in the XPCOM version of this extension, but I don't see any such references in the js-ctypes version even in the latest git master. I also discovered that Thunderbird exposes a function for grabbing the number of *new* messages in addition to the usual unread message count.

Here's a bit of duct-tape code that modifies FireTrayMessaging.jsm to do more or less what I want...

In the OnItemIntPropertyChanged() function, I added:

```js
if (property.toString() === "BiffState") {
firetray.Messaging.updateBiff(oldValue, newValue);
}
```

I then created a new function to change the icon appropriately upon biff state changes:

```js
updateBiff: function(oldValue, newValue) {
if ( ( (oldValue === 2) || (oldValue === 1) ) && (newValue === 0) ) {
firetray.Handler.setIconImage(firetray.Handler.FILENAME_NEWMAIL);
} else {
firetray.Handler.setIconImageDefault();
}
}
```

Finally, within the updateUnreadMsgCount() function, I altered the polling mechanism to calculate the number of *new* unread messages, not the total of *all* unread messages:

```js
//this._unreadMsgCount += folder.getNumUnread(true); // includes subfolders
this._unreadMsgCount += folder.getNumNewMessages(true); // includes subfolders
```