From 354abdf32c739cc446e9d0301c6492ab601e1eb5 Mon Sep 17 00:00:00 2001 From: foudfou Date: Sun, 4 Mar 2012 22:19:35 +0100 Subject: [PATCH] * option to include subfolders (notably needed for new messages count) * preference UI fixing --- src/chrome/content/options.js | 49 ++++++++++++++--------------- src/chrome/content/options.xul | 13 ++++++-- src/chrome/locale/en-US/options.dtd | 4 ++- src/defaults/preferences/prefs.js | 1 + src/modules/FiretrayHandler.jsm | 1 + src/modules/FiretrayMessaging.jsm | 20 +++++++++--- 6 files changed, 55 insertions(+), 33 deletions(-) diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js index 862ba55..fc195cd 100644 --- a/src/chrome/content/options.js +++ b/src/chrome/content/options.js @@ -56,13 +56,21 @@ var firetrayUIOptions = { targetNode.hidden = hiddenval; }, - disableGroup: function(group, disableval) { + disableChildren: function(group, disableval) { try { for (let i=0, len=group.childNodes.length; i + @@ -116,7 +117,7 @@ - + + + @@ -204,7 +211,7 @@ - + diff --git a/src/chrome/locale/en-US/options.dtd b/src/chrome/locale/en-US/options.dtd index 681d826..02cb828 100644 --- a/src/chrome/locale/en-US/options.dtd +++ b/src/chrome/locale/en-US/options.dtd @@ -36,6 +36,8 @@ + + @@ -49,7 +51,7 @@ - + diff --git a/src/defaults/preferences/prefs.js b/src/defaults/preferences/prefs.js index e24b252..2a5ea2f 100644 --- a/src/defaults/preferences/prefs.js +++ b/src/defaults/preferences/prefs.js @@ -18,6 +18,7 @@ pref("extensions.firetray.scroll_hides", true); pref("extensions.firetray.scroll_mode", "down_hides"); pref("extensions.firetray.message_count_type", 0); +pref("extensions.firetray.folder_count_recursive", true); pref("extensions.firetray.mail_notification_enabled", true); pref("extensions.firetray.mail_notification_type", 0); pref("extensions.firetray.icon_text_color", "#000000"); diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm index 9dfc4f6..aae3ebb 100644 --- a/src/modules/FiretrayHandler.jsm +++ b/src/modules/FiretrayHandler.jsm @@ -373,6 +373,7 @@ firetray.PrefListener = new PrefListener( firetray.Handler.showHideIcon(); break; case 'message_count_type': + case 'folder_count_recursive': firetray.Messaging.updateMsgCount(); break; default: diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm index 85ed2f6..0cef528 100644 --- a/src/modules/FiretrayMessaging.jsm +++ b/src/modules/FiretrayMessaging.jsm @@ -85,7 +85,6 @@ firetray.Messaging = { updateMsgCount: function(item, property, oldValue, newValue) { let excludedFoldersFlags = firetray.Utils.prefService.getIntPref("excluded_folders_flags"); let msgCountType = firetray.Utils.prefService.getIntPref("message_count_type"); - LOG("msgCountType="+msgCountType); if (!(item.flags & excludedFoldersFlags)) { let prop = property.toString(); @@ -180,11 +179,11 @@ firetray.Messaging = { let rootFolder = accountServer.rootFolder; // nsIMsgFolder if (rootFolder.hasSubFolders) { - let subFolders = rootFolder.subFolders; // nsIMsgFolder + let subFolders = rootFolder.subFolders; while(subFolders.hasMoreElements()) { let folder = subFolders.getNext().QueryInterface(Ci.nsIMsgFolder); if (!(folder.flags & excludedFoldersFlags)) { - newMsgCount = folderCountFunction(folder, newMsgCount); + newMsgCount = this.folderCount(folderCountFunction,folder, newMsgCount); } } } @@ -196,9 +195,22 @@ firetray.Messaging = { return newMsgCount; }, + folderCount: function(folderCountFunction, folder, newMsgCount) { + if (folder.hasSubFolders && firetray.Utils.prefService.getBoolPref("folder_count_recursive")) { + LOG("hasSubFolders"); + let subFolders = folder.subFolders; + while(subFolders.hasMoreElements()) { + let subFolder = subFolders.getNext().QueryInterface(Ci.nsIMsgFolder); + newMsgCount = this.folderCount(folderCountFunction, subFolder, newMsgCount); + } + } + newMsgCount = folderCountFunction(folder, newMsgCount); + return newMsgCount; + }, + unreadMsgCountIterate: function(folder, accumulator) { let folderCountFunctionName = 'getNumUnread'; - let folderUnreadMsgCount = folder[folderCountFunctionName](true); // includes subfolders + let folderUnreadMsgCount = folder[folderCountFunctionName](false); // do not include subfolders LOG(folder.prettyName+" "+folderCountFunctionName+"="+folderUnreadMsgCount); return accumulator + folderUnreadMsgCount; },