diff --git a/mail/base/content/folderPane.js b/mail/base/content/folderPane.js index 8a8c16a4ad..d4924fc54c 100644 --- a/mail/base/content/folderPane.js +++ b/mail/base/content/folderPane.js @@ -2745,12 +2745,9 @@ var gFolderTreeView = { /** * This is our implementation of nsIMsgFolderListener to watch for changes */ - OnItemAdded(aParentItem, aItem) { - // Ignore this item if it's not a folder, or we knew about it. - if ( - !(aItem instanceof Ci.nsIMsgFolder) || - this.getIndexOfFolder(aItem) != null - ) { + onFolderAdded(aParentItem, aItem) { + // Ignore this folder if we already know about it. + if (this.getIndexOfFolder(aItem) != null) { return; } @@ -2778,6 +2775,8 @@ var gFolderTreeView = { } }, + onMessageAdded(parentFolder, msg) {}, + addFolder(aParentItem, aItem) { // This intentionally adds any new folder even if it would not pass the // _filterFunction. The idea is that the user can add new folders even @@ -2825,11 +2824,7 @@ var gFolderTreeView = { this._addChildToView(parent, parentIndex, newChild); }, - OnItemRemoved(aParentItem, aItem) { - if (!(aItem instanceof Ci.nsIMsgFolder)) { - return; - } - + onFolderRemoved(aParentItem, aItem) { let index = this.getIndexOfFolder(aItem); if (index == null) { return; @@ -2859,9 +2854,9 @@ var gFolderTreeView = { gFolderDisplay.show(); } }, - - OnItemPropertyChanged(aItem, aProperty, aOld, aNew) {}, - OnItemIntPropertyChanged(aItem, aProperty, aOld, aNew) { + onMessageRemoved(parentFolder, msg) {}, + onFolderPropertyChanged(aItem, aProperty, aOld, aNew) {}, + onFolderIntPropertyChanged(aItem, aProperty, aOld, aNew) { // First try mode specific handling of the changed property. for (let mode of this.activeModes) { if ( @@ -2892,7 +2887,7 @@ var gFolderTreeView = { } }, - OnItemBoolPropertyChanged(aItem, aProperty, aOld, aNew) { + onFolderBoolPropertyChanged(aItem, aProperty, aOld, aNew) { let index = this.getIndexOfFolder(aItem); if (index != null) { this.clearFolderCacheProperty(aItem, "properties"); @@ -2900,7 +2895,7 @@ var gFolderTreeView = { } }, - OnItemUnicharPropertyChanged(aItem, aProperty, aOld, aNew) { + onFolderUnicharPropertyChanged(aItem, aProperty, aOld, aNew) { let index = this.getIndexOfFolder(aItem); if (index != null) { this.clearFolderCacheProperty(aItem, "properties"); @@ -2908,8 +2903,8 @@ var gFolderTreeView = { } }, - OnItemPropertyFlagChanged(aItem, aProperty, aOld, aNew) {}, - OnItemEvent(aFolder, aEvent) { + onFolderPropertyFlagChanged(aItem, aProperty, aOld, aNew) {}, + onFolderEvent(aFolder, aEvent) { let index = this.getIndexOfFolder(aFolder); if (index != null) { this.clearFolderCacheProperty(aFolder, "properties"); diff --git a/mail/base/content/msgMail3PaneWindow.js b/mail/base/content/msgMail3PaneWindow.js index 3db2f7e8d4..fb06d84f01 100644 --- a/mail/base/content/msgMail3PaneWindow.js +++ b/mail/base/content/msgMail3PaneWindow.js @@ -201,13 +201,14 @@ var gSummaryFrameManager; // the folderListener object var folderListener = { - OnItemAdded(parentItem, item) {}, + onFolderAdded(parentFolder, child) {}, + onMessageAdded(parentFolder, msg) {}, + onFolderRemoved(parentFolder, child) {}, + onMessageRemoved(parentFolder, msg) {}, - OnItemRemoved(parentItem, item) {}, + onFolderPropertyChanged(item, property, oldValue, newValue) {}, - OnItemPropertyChanged(item, property, oldValue, newValue) {}, - - OnItemIntPropertyChanged(item, property, oldValue, newValue) { + onFolderIntPropertyChanged(item, property, oldValue, newValue) { if (item == gFolderDisplay.displayedFolder) { if (property == "TotalMessages" || property == "TotalUnreadMessages") { UpdateStatusMessageCounts(gFolderDisplay.displayedFolder); @@ -215,12 +216,12 @@ var folderListener = { } }, - OnItemBoolPropertyChanged(item, property, oldValue, newValue) {}, + onFolderBoolPropertyChanged(item, property, oldValue, newValue) {}, - OnItemUnicharPropertyChanged(item, property, oldValue, newValue) {}, - OnItemPropertyFlagChanged(item, property, oldFlag, newFlag) {}, + onFolderUnicharPropertyChanged(item, property, oldValue, newValue) {}, + onFolderPropertyFlagChanged(item, property, oldFlag, newFlag) {}, - OnItemEvent(folder, event) { + onFolderEvent(folder, event) { if (event == "ImapHdrDownloaded") { if (folder) { var imapFolder = folder.QueryInterface(Ci.nsIMsgImapMailFolder); diff --git a/mail/components/extensions/parent/ext-folders.js b/mail/components/extensions/parent/ext-folders.js index b67716d1e6..fcb24436ff 100644 --- a/mail/components/extensions/parent/ext-folders.js +++ b/mail/components/extensions/parent/ext-folders.js @@ -71,7 +71,7 @@ var folderTracker = new (class extends EventEmitter { // nsIFolderListener - OnItemIntPropertyChanged(item, property, oldValue, newValue) { + onFolderIntPropertyChanged(item, property, oldValue, newValue) { if (!(item instanceof Ci.nsIMsgFolder)) { return; } diff --git a/mail/components/extensions/parent/ext-mail.js b/mail/components/extensions/parent/ext-mail.js index 97860bcc15..e347d2c72e 100644 --- a/mail/components/extensions/parent/ext-mail.js +++ b/mail/components/extensions/parent/ext-mail.js @@ -1843,7 +1843,7 @@ var messageTracker = new (class extends EventEmitter { // nsIFolderListener - OnItemPropertyFlagChanged(item, property, oldFlag, newFlag) { + onFolderPropertyFlagChanged(item, property, oldFlag, newFlag) { switch (property) { case "Status": if ((oldFlag ^ newFlag) & Ci.nsMsgMessageFlags.Read) { @@ -1865,7 +1865,7 @@ var messageTracker = new (class extends EventEmitter { } } - OnItemIntPropertyChanged(folder, property, oldValue, newValue) { + onFolderIntPropertyChanged(folder, property, oldValue, newValue) { switch (property) { case "BiffState": if (newValue == Ci.nsIMsgFolder.nsMsgBiffState_NewMail) { diff --git a/mail/modules/DBViewWrapper.jsm b/mail/modules/DBViewWrapper.jsm index 7d977e0c6d..22e5cf5103 100644 --- a/mail/modules/DBViewWrapper.jsm +++ b/mail/modules/DBViewWrapper.jsm @@ -201,7 +201,7 @@ var FolderNotificationHelper = { } }, - OnItemEvent(aFolder, aEvent) { + onFolderEvent(aFolder, aEvent) { if (aEvent == "FolderLoaded") { let folderURI = aFolder.URI; let widgets = this._pendingFolderUriToViewWrapperLists[folderURI]; @@ -243,7 +243,7 @@ var FolderNotificationHelper = { } }, - OnItemIntPropertyChanged(aFolder, aProperty, aOldValue, aNewValue) { + onFolderIntPropertyChanged(aFolder, aProperty, aOldValue, aNewValue) { if (aProperty == "TotalMessages" || aProperty == "TotalUnreadMessages") { this._notifyHelper(aFolder, "_messageCountsChanged"); } diff --git a/mail/test/browser/shared-modules/FolderDisplayHelpers.jsm b/mail/test/browser/shared-modules/FolderDisplayHelpers.jsm index e1df86b6a0..5b496a4831 100644 --- a/mail/test/browser/shared-modules/FolderDisplayHelpers.jsm +++ b/mail/test/browser/shared-modules/FolderDisplayHelpers.jsm @@ -2021,7 +2021,7 @@ var FolderListener = { } }, - OnItemEvent(aFolder, aEvent) { + onFolderEvent(aFolder, aEvent) { if (!this.watchingFor) { return; } @@ -2033,7 +2033,7 @@ var FolderListener = { }; /** - * Plan to wait for an nsIFolderListener.OnItemEvent matching one of the + * Plan to wait for an nsIFolderListener.onFolderEvent matching one of the * provided strings. Call this before you do the thing that triggers the * event, then call |wait_for_folder_events| after the event. This ensures * that we see the event, because it might be too late after you initiate diff --git a/mailnews/base/content/folder-menupopup.js b/mailnews/base/content/folder-menupopup.js index 6c0f854ead..746826732e 100644 --- a/mailnews/base/content/folder-menupopup.js +++ b/mailnews/base/content/folder-menupopup.js @@ -265,29 +265,28 @@ } }, - _itemAddedOrRemoved(item) { - if (!(item instanceof Ci.nsIMsgFolder)) { - return; - } - if (this._filterFunction && !this._filterFunction(item)) { + _folderAddedOrRemoved(folder) { + if (this._filterFunction && !this._filterFunction(folder)) { return; } // xxx we can optimize this later this._clearMenu(this._menu); }, - OnItemAdded(ParentItem, item) { - this._itemAddedOrRemoved(item); + onFolderAdded(parentFolder, child) { + this._folderAddedOrRemoved(child); }, - OnItemRemoved(ParentItem, item) { - this._itemAddedOrRemoved(item); + onMessageAdded(parentFolder, msg) {}, + onFolderRemoved(parentFolder, child) { + this._folderAddedOrRemoved(child); }, + onMessageRemoved(parentFolder, msg) {}, // xxx I stole this listener list from nsMsgFolderDatasource.cpp, but // someone should really document what events are fired when, so that // we make sure we're updating at the right times. - OnItemPropertyChanged(item, property, old, newItem) {}, - OnItemIntPropertyChanged(item, property, old, aNew) { + onFolderPropertyChanged(item, property, old, newItem) {}, + onFolderIntPropertyChanged(item, property, old, aNew) { if (item instanceof Ci.nsIMsgFolder) { if (property == "FolderFlag") { if ( @@ -307,15 +306,15 @@ } this._setCssSelectorsForItem(item); }, - OnItemBoolPropertyChanged(item, property, old, newItem) { + onFolderBoolPropertyChanged(item, property, old, newItem) { this._setCssSelectorsForItem(item); }, - OnItemUnicharPropertyChanged(item, property, old, newItem) { + onFolderUnicharPropertyChanged(item, property, old, newItem) { this._setCssSelectorsForItem(item); }, - OnItemPropertyFlagChanged(item, property, old, newItem) {}, + onFolderPropertyFlagChanged(item, property, old, newItem) {}, - OnItemEvent(folder, eventName) { + onFolderEvent(folder, eventName) { if (eventName == "MRMTimeChanged") { if ( this._menu.getAttribute("showRecent") != "true" || diff --git a/mailnews/base/public/nsIFolderListener.idl b/mailnews/base/public/nsIFolderListener.idl index e88be617bb..3906ef2f46 100644 --- a/mailnews/base/public/nsIFolderListener.idl +++ b/mailnews/base/public/nsIFolderListener.idl @@ -21,48 +21,50 @@ typedef unsigned long folderListenerNotifyFlagValue; */ [scriptable, uuid(f60ee1a2-6d81-422c-958f-d408b1b2daa7)] interface nsIFolderListener : nsISupports { + // "added" flag covers adding both messages and child folders. const folderListenerNotifyFlagValue added = 0x1; - void OnItemAdded(in nsIMsgFolder aParentItem, - in nsISupports aItem); + void onFolderAdded(in nsIMsgFolder parent, in nsIMsgFolder child); + void onMessageAdded(in nsIMsgFolder parent, in nsIMsgDBHdr msg); + // "removed" flag covers removing both messages and child folders. const folderListenerNotifyFlagValue removed = 0x2; - void OnItemRemoved(in nsIMsgFolder aParentItem, - in nsISupports aItem); + void onFolderRemoved(in nsIMsgFolder parent, in nsIMsgFolder child); + void onMessageRemoved(in nsIMsgFolder parent, in nsIMsgDBHdr msg); const folderListenerNotifyFlagValue propertyChanged = 0x4; - void OnItemPropertyChanged(in nsIMsgFolder aItem, - in ACString aProperty, - in AUTF8String aOldValue, - in AUTF8String aNewValue); + void onFolderPropertyChanged(in nsIMsgFolder folder, + in ACString property, + in AUTF8String oldValue, + in AUTF8String newValue); const folderListenerNotifyFlagValue intPropertyChanged = 0x8; // While this property handles long long (64bit wide) values, // the Javascript engine will only pass values up to 2^53 to the consumers. - void OnItemIntPropertyChanged(in nsIMsgFolder aItem, - in ACString aProperty, - in long long aOldValue, - in long long aNewValue); + void onFolderIntPropertyChanged(in nsIMsgFolder folder, + in ACString property, + in long long oldValue, + in long long newValue); const folderListenerNotifyFlagValue boolPropertyChanged = 0x10; - void OnItemBoolPropertyChanged(in nsIMsgFolder aItem, - in ACString aProperty, - in boolean aOldValue, - in boolean aNewValue); + void onFolderBoolPropertyChanged(in nsIMsgFolder folder, + in ACString property, + in boolean oldValue, + in boolean newValue); const folderListenerNotifyFlagValue unicharPropertyChanged = 0x20; - void OnItemUnicharPropertyChanged(in nsIMsgFolder aItem, - in ACString aProperty, - in AString aOldValue, - in AString aNewValue); + void onFolderUnicharPropertyChanged(in nsIMsgFolder folder, + in ACString property, + in AString oldValue, + in AString newValue); const folderListenerNotifyFlagValue propertyFlagChanged = 0x40; - void OnItemPropertyFlagChanged(in nsIMsgDBHdr aItem, - in ACString aProperty, - in unsigned long aOldFlag, - in unsigned long aNewFlag); + void onFolderPropertyFlagChanged(in nsIMsgDBHdr msg, + in ACString property, + in unsigned long oldFlag, + in unsigned long newFlag); const folderListenerNotifyFlagValue event = 0x80; - void OnItemEvent(in nsIMsgFolder aItem, in ACString aEvent); + void onFolderEvent(in nsIMsgFolder folder, in ACString event); const folderListenerNotifyFlagValue all = 0xFFFFFFFF; }; diff --git a/mailnews/base/src/MailNotificationManager.jsm b/mailnews/base/src/MailNotificationManager.jsm index edb9e63610..2e1d3c2582 100644 --- a/mailnews/base/src/MailNotificationManager.jsm +++ b/mailnews/base/src/MailNotificationManager.jsm @@ -120,31 +120,22 @@ class MailNotificationManager { /** * Following are nsIFolderListener interfaces. Do nothing about them. */ - OnItemAdded() {} - - OnItemRemoved() {} - - OnItemPropertyChanged() {} - - OnItemBoolPropertyChanged() {} - - OnItemUnicharPropertyChanged() {} - - OnItemPropertyFlagChanged() {} - - OnItemEvent() {} - + onFolderAdded() {} + onMessageAdded() {} + onFolderRemoved() {} + onMessageRemoved() {} + onFolderPropertyChanged() {} /** * The only nsIFolderListener interface we care about. * @see nsIFolderListener */ - OnItemIntPropertyChanged(folder, property, oldValue, newValue) { + onFolderIntPropertyChanged(folder, property, oldValue, newValue) { if (!Services.prefs.getBoolPref("mail.biff.show_alert")) { return; } this._logger.debug( - `OnItemIntPropertyChanged; property=${property}: ${oldValue} => ${newValue}, folder.URI=${folder.URI}` + `onFolderIntPropertyChanged; property=${property}: ${oldValue} => ${newValue}, folder.URI=${folder.URI}` ); switch (property) { @@ -160,6 +151,10 @@ class MailNotificationManager { break; } } + onFolderBoolPropertyChanged() {} + onFolderUnicharPropertyChanged() {} + onFolderPropertyFlagChanged() {} + onFolderEvent() {} /** * @see mozINewMailNotificationService diff --git a/mailnews/base/src/MailNotificationService.jsm b/mailnews/base/src/MailNotificationService.jsm index fdc8fe205d..0ec9ca9c59 100644 --- a/mailnews/base/src/MailNotificationService.jsm +++ b/mailnews/base/src/MailNotificationService.jsm @@ -197,20 +197,13 @@ NewMailNotificationService.prototype = { return shouldCount.data; }, - OnItemIntPropertyChanged(folder, property, oldValue, newValue) { + onFolderIntPropertyChanged(folder, property, oldValue, newValue) { try { if (property == "FolderSize") { return; } this._log.trace( - "NMNS_OnItemIntPropertyChanged: folder " + - folder.URI + - " " + - property + - " " + - oldValue + - " " + - newValue + `Changed int ${property} of ${folder.folderURL}: ${oldValue} -> ${newValue}` ); if (property == "BiffState") { this._biffStateChanged(folder, oldValue, newValue); @@ -220,7 +213,7 @@ NewMailNotificationService.prototype = { this._newMailReceived(folder, oldValue, newValue); } } catch (error) { - this._log.error("NMNS_OnItemIntPropertyChanged: exception " + error); + this._log.error("onFolderIntPropertyChanged: exception " + error); } }, @@ -337,47 +330,39 @@ NewMailNotificationService.prototype = { } }, - OnItemAdded(parentItem, item) { - if (item instanceof Ci.nsIMsgDBHdr) { - if (this.confirmShouldCount(item.folder)) { - this._log.trace( - "NMNS_OnItemAdded: item " + - item.folder.getUriForMsg(item) + - " added to " + - item.folder.folderURL - ); - } + onFolderAdded(parentFolder, child) { + this._log.trace( + `Added child folder ${child.folderURL} to ${parentFolder.folderURL}` + ); + }, + + onMessageAdded(parentFolder, msg) { + if (this.confirmShouldCount(msg.folder)) { + this._log.trace(`Added <${msg.messageId}> to ${msg.folder.folderURL}`); } }, - OnItemPropertyFlagChanged(item, property, oldFlag, newFlag) { - if (item instanceof Ci.nsIMsgDBHdr) { - if ( - oldFlag & Ci.nsMsgMessageFlags.New && - !(newFlag & Ci.nsMsgMessageFlags.New) - ) { - this._log.trace( - "NMNS_OnItemPropertyFlagChanged: item " + - item.folder.getUriForMsg(item) + - " marked read" - ); - } else if (newFlag & Ci.nsMsgMessageFlags.New) { - this._log.trace( - "NMNS_OnItemPropertyFlagChanged: item " + - item.folder.getUriForMsg(item) + - " marked unread" - ); - } + onFolderPropertyFlagChanged(msg, property, oldFlag, newFlag) { + if ( + oldFlag & Ci.nsMsgMessageFlags.New && + !(newFlag & Ci.nsMsgMessageFlags.New) + ) { + this._log.trace(`<${msg.messageId}> marked read`); + } else if (newFlag & Ci.nsMsgMessageFlags.New) { + this._log.trace(`<${msg.messageId}> marked unread`); } }, - OnItemRemoved(parentItem, item) { - if (item instanceof Ci.nsIMsgDBHdr && !item.isRead) { + onFolderRemoved(parentFolder, child) { + this._log.trace( + `Removed child folder ${child.folderURL} from ${parentFolder.folderURL}` + ); + }, + + onMessageRemoved(parentFolder, msg) { + if (!msg.isRead) { this._log.trace( - "NMNS_OnItemRemoved: unread item " + - item.folder.getUriForMsg(item) + - " removed from " + - item.folder.folderURL + `Removed unread <${msg.messageId}> from ${msg.folder.folderURL}` ); } }, diff --git a/mailnews/base/src/nsMessenger.cpp b/mailnews/base/src/nsMessenger.cpp index 36840c27da..2fe7cbed13 100644 --- a/mailnews/base/src/nsMessenger.cpp +++ b/mailnews/base/src/nsMessenger.cpp @@ -2037,32 +2037,39 @@ nsMessenger::FormatFileSize(uint64_t aSize, bool aUseKB, return ::FormatFileSize(aSize, aUseKB, aFormattedSize); } -NS_IMETHODIMP nsMessenger::OnItemAdded(nsIMsgFolder* parentItem, - nsISupports* item) { +NS_IMETHODIMP nsMessenger::OnFolderAdded(nsIMsgFolder* parent, + nsIMsgFolder* child) { return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP nsMessenger::OnItemRemoved(nsIMsgFolder* parentItem, - nsISupports* item) { +NS_IMETHODIMP nsMessenger::OnMessageAdded(nsIMsgFolder* parent, + nsIMsgDBHdr* msg) { + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP nsMessenger::OnFolderRemoved(nsIMsgFolder* parent, + nsIMsgFolder* child) { + return NS_OK; +} + +NS_IMETHODIMP nsMessenger::OnMessageRemoved(nsIMsgFolder* parent, + nsIMsgDBHdr* msgHdr) { // check if this item is a message header that's in our history list. If so, // remove it from the history list. - nsCOMPtr msgHdr = do_QueryInterface(item); - if (msgHdr) { - nsCOMPtr folder; - msgHdr->GetFolder(getter_AddRefs(folder)); - if (folder) { - nsCString msgUri; - nsMsgKey msgKey; - msgHdr->GetMessageKey(&msgKey); - folder->GenerateMessageURI(msgKey, msgUri); - // need to remove the corresponding folder entry, and - // adjust the current history pos. - size_t uriPos = mLoadedMsgHistory.IndexOf(msgUri); - if (uriPos != mLoadedMsgHistory.NoIndex) { - mLoadedMsgHistory.RemoveElementAt(uriPos); - mLoadedMsgHistory.RemoveElementAt(uriPos); // and the folder uri entry - if (mCurHistoryPos >= (int32_t)uriPos) mCurHistoryPos -= 2; - } + nsCOMPtr folder; + msgHdr->GetFolder(getter_AddRefs(folder)); + if (folder) { + nsCString msgUri; + nsMsgKey msgKey; + msgHdr->GetMessageKey(&msgKey); + folder->GenerateMessageURI(msgKey, msgUri); + // need to remove the corresponding folder entry, and + // adjust the current history pos. + size_t uriPos = mLoadedMsgHistory.IndexOf(msgUri); + if (uriPos != mLoadedMsgHistory.NoIndex) { + mLoadedMsgHistory.RemoveElementAt(uriPos); + mLoadedMsgHistory.RemoveElementAt(uriPos); // and the folder uri entry + if (mCurHistoryPos >= (int32_t)uriPos) mCurHistoryPos -= 2; } } return NS_OK; diff --git a/mailnews/base/src/nsMsgAccount.cpp b/mailnews/base/src/nsMsgAccount.cpp index 6b698cfdaa..bd54018e59 100644 --- a/mailnews/base/src/nsMsgAccount.cpp +++ b/mailnews/base/src/nsMsgAccount.cpp @@ -128,7 +128,7 @@ nsMsgAccount::SetIncomingServer(nsIMsgIncomingServer* aIncomingServer) { nsCOMPtr mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); - mailSession->OnItemAdded(nullptr, rootFolder); + mailSession->OnFolderAdded(nullptr, rootFolder); nsCOMPtr notifier( do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID, &rv)); NS_ENSURE_SUCCESS(rv, rv); @@ -145,7 +145,7 @@ nsMsgAccount::SetIncomingServer(nsIMsgIncomingServer* aIncomingServer) { NS_ENSURE_SUCCESS(rv, rv); for (nsIMsgFolder* msgFolder : subFolders) { - mailSession->OnItemAdded(rootFolder, msgFolder); + mailSession->OnFolderAdded(rootFolder, msgFolder); notifier->NotifyFolderAdded(msgFolder); } } diff --git a/mailnews/base/src/nsMsgAccountManager.cpp b/mailnews/base/src/nsMsgAccountManager.cpp index 5c471ae353..13076a4066 100644 --- a/mailnews/base/src/nsMsgAccountManager.cpp +++ b/mailnews/base/src/nsMsgAccountManager.cpp @@ -505,11 +505,11 @@ nsMsgAccountManager::RemoveIncomingServer(nsIMsgIncomingServer* aServer, if (mailSession) { nsCOMPtr parentFolder; folder->GetParent(getter_AddRefs(parentFolder)); - mailSession->OnItemRemoved(parentFolder, folder); + mailSession->OnFolderRemoved(parentFolder, folder); } } if (notifier) notifier->NotifyFolderDeleted(rootFolder); - if (mailSession) mailSession->OnItemRemoved(nullptr, rootFolder); + if (mailSession) mailSession->OnFolderRemoved(nullptr, rootFolder); removeListenersFromFolder(rootFolder); NotifyServerUnloaded(aServer); @@ -2947,12 +2947,8 @@ NS_IMETHODIMP nsMsgAccountManager::GetAllFolders( return NS_OK; } -NS_IMETHODIMP nsMsgAccountManager::OnItemAdded(nsIMsgFolder* parentItem, - nsISupports* item) { - nsCOMPtr folder = do_QueryInterface(item); - // just kick out with a success code if the item in question is not a folder - if (!folder) return NS_OK; - +NS_IMETHODIMP nsMsgAccountManager::OnFolderAdded(nsIMsgFolder* parent, + nsIMsgFolder* folder) { uint32_t folderFlags; folder->GetFlags(&folderFlags); bool addToSmartFolders = false; @@ -3028,10 +3024,10 @@ NS_IMETHODIMP nsMsgAccountManager::OnItemAdded(nsIMsgFolder* parentItem, rv = folder->GetDescendants(allDescendants); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr parent; + nsCOMPtr parentFolder; for (auto subFolder : allDescendants) { - subFolder->GetParent(getter_AddRefs(parent)); - OnItemAdded(parent, subFolder); + subFolder->GetParent(getter_AddRefs(parentFolder)); + OnFolderAdded(parentFolder, subFolder); } } } @@ -3058,11 +3054,13 @@ NS_IMETHODIMP nsMsgAccountManager::OnItemAdded(nsIMsgFolder* parentItem, return rv; } -NS_IMETHODIMP nsMsgAccountManager::OnItemRemoved(nsIMsgFolder* parentItem, - nsISupports* item) { - nsCOMPtr folder = do_QueryInterface(item); - // just kick out with a success code if the item in question is not a folder - if (!folder) return NS_OK; +NS_IMETHODIMP nsMsgAccountManager::OnMessageAdded(nsIMsgFolder* parent, + nsIMsgDBHdr* msg) { + return NS_OK; +} + +NS_IMETHODIMP nsMsgAccountManager::OnFolderRemoved(nsIMsgFolder* parentFolder, + nsIMsgFolder* folder) { nsresult rv = NS_OK; uint32_t folderFlags; folder->GetFlags(&folderFlags); @@ -3135,6 +3133,11 @@ NS_IMETHODIMP nsMsgAccountManager::OnItemRemoved(nsIMsgFolder* parentItem, return rv; } +NS_IMETHODIMP nsMsgAccountManager::OnMessageRemoved(nsIMsgFolder* parent, + nsIMsgDBHdr* msg) { + return NS_OK; +} + NS_IMETHODIMP nsMsgAccountManager::OnItemPropertyChanged( nsIMsgFolder* item, const nsACString& property, const nsACString& oldValue, const nsACString& newValue) { @@ -3152,11 +3155,11 @@ nsMsgAccountManager::OnItemIntPropertyChanged(nsIMsgFolder* aFolder, (nsMsgFolderFlags::SpecialUse & ~nsMsgFolderFlags::Queue); if (smartFlagsChanged) { if (smartFlagsChanged & newValue) { - // if the smart folder flag was set, calling OnItemAdded will + // if the smart folder flag was set, calling OnFolderAdded will // do the right thing. nsCOMPtr parent; aFolder->GetParent(getter_AddRefs(parent)); - return OnItemAdded(parent, aFolder); + return OnFolderAdded(parent, aFolder); } RemoveFolderFromSmartFolder(aFolder, smartFlagsChanged); // sent|archive flag removed, remove sub-folders from smart folder. diff --git a/mailnews/base/src/nsMsgDBFolder.cpp b/mailnews/base/src/nsMsgDBFolder.cpp index 8d69df12f1..b004ed4925 100644 --- a/mailnews/base/src/nsMsgDBFolder.cpp +++ b/mailnews/base/src/nsMsgDBFolder.cpp @@ -4520,50 +4520,50 @@ nsMsgDBFolder::NotifyPropertyFlagChanged(nsIMsgDBHdr* aItem, NS_IMETHODIMP nsMsgDBFolder::NotifyMessageAdded(nsIMsgDBHdr* msg) { // Notify our directly-registered listeners. - NOTIFY_LISTENERS(OnItemAdded, (this, msg)); + NOTIFY_LISTENERS(OnMessageAdded, (this, msg)); // Notify listeners who listen to every folder nsresult rv; nsCOMPtr folderListenerManager = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); - rv = folderListenerManager->OnItemAdded(this, msg); + rv = folderListenerManager->OnMessageAdded(this, msg); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } nsresult nsMsgDBFolder::NotifyMessageRemoved(nsIMsgDBHdr* msg) { // Notify our directly-registered listeners. - NOTIFY_LISTENERS(OnItemRemoved, (this, msg)); + NOTIFY_LISTENERS(OnMessageRemoved, (this, msg)); // Notify listeners who listen to every folder nsresult rv; nsCOMPtr folderListenerManager = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); - rv = folderListenerManager->OnItemRemoved(this, msg); + rv = folderListenerManager->OnMessageRemoved(this, msg); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } NS_IMETHODIMP nsMsgDBFolder::NotifyFolderAdded(nsIMsgFolder* child) { - NOTIFY_LISTENERS(OnItemAdded, (this, child)); + NOTIFY_LISTENERS(OnFolderAdded, (this, child)); // Notify listeners who listen to every folder nsresult rv; nsCOMPtr folderListenerManager = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); - return folderListenerManager->OnItemAdded(this, child); + return folderListenerManager->OnFolderAdded(this, child); } nsresult nsMsgDBFolder::NotifyFolderRemoved(nsIMsgFolder* child) { - NOTIFY_LISTENERS(OnItemRemoved, (this, child)); + NOTIFY_LISTENERS(OnFolderRemoved, (this, child)); // Notify listeners who listen to every folder nsresult rv; nsCOMPtr folderListenerManager = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); - return folderListenerManager->OnItemRemoved(this, child); + return folderListenerManager->OnFolderRemoved(this, child); } nsresult nsMsgDBFolder::NotifyFolderEvent(const nsACString& aEvent) { diff --git a/mailnews/base/src/nsMsgMailSession.cpp b/mailnews/base/src/nsMsgMailSession.cpp index 1eec04a9d8..a53f1c62e7 100644 --- a/mailnews/base/src/nsMsgMailSession.cpp +++ b/mailnews/base/src/nsMsgMailSession.cpp @@ -131,15 +131,26 @@ nsMsgMailSession::OnItemPropertyFlagChanged(nsIMsgDBHdr* aItem, return NS_OK; } -NS_IMETHODIMP nsMsgMailSession::OnItemAdded(nsIMsgFolder* aParentItem, - nsISupports* aItem) { - NOTIFY_FOLDER_LISTENERS(added, OnItemAdded, (aParentItem, aItem)); +NS_IMETHODIMP nsMsgMailSession::OnFolderAdded(nsIMsgFolder* parent, + nsIMsgFolder* child) { + NOTIFY_FOLDER_LISTENERS(added, OnFolderAdded, (parent, child)); + return NS_OK; +} +NS_IMETHODIMP nsMsgMailSession::OnMessageAdded(nsIMsgFolder* parent, + nsIMsgDBHdr* msg) { + NOTIFY_FOLDER_LISTENERS(added, OnMessageAdded, (parent, msg)); return NS_OK; } -NS_IMETHODIMP nsMsgMailSession::OnItemRemoved(nsIMsgFolder* aParentItem, - nsISupports* aItem) { - NOTIFY_FOLDER_LISTENERS(removed, OnItemRemoved, (aParentItem, aItem)); +NS_IMETHODIMP nsMsgMailSession::OnFolderRemoved(nsIMsgFolder* parent, + nsIMsgFolder* child) { + NOTIFY_FOLDER_LISTENERS(removed, OnFolderRemoved, (parent, child)); + return NS_OK; +} + +NS_IMETHODIMP nsMsgMailSession::OnMessageRemoved(nsIMsgFolder* parent, + nsIMsgDBHdr* msg) { + NOTIFY_FOLDER_LISTENERS(removed, OnMessageRemoved, (parent, msg)); return NS_OK; } @@ -174,7 +185,7 @@ NS_IMETHODIMP nsMsgMailSession::AlertUser(const nsAString& aMessage, nsIMsgMailNewsUrl* aUrl) { bool listenersNotified = false; - nsTObserverArray >::ForwardIterator iter( + nsTObserverArray>::ForwardIterator iter( mFeedbackListeners); nsCOMPtr listener; diff --git a/mailnews/base/src/nsStatusBarBiffManager.cpp b/mailnews/base/src/nsStatusBarBiffManager.cpp index a92af17057..9a142e36e8 100644 --- a/mailnews/base/src/nsStatusBarBiffManager.cpp +++ b/mailnews/base/src/nsStatusBarBiffManager.cpp @@ -142,14 +142,25 @@ nsresult nsStatusBarBiffManager::PlayBiffSound(const char* aPrefBranch) { // nsIFolderListener methods.... NS_IMETHODIMP -nsStatusBarBiffManager::OnItemAdded(nsIMsgFolder* parentItem, - nsISupports* item) { +nsStatusBarBiffManager::OnFolderAdded(nsIMsgFolder* parent, + nsIMsgFolder* child) { return NS_OK; } NS_IMETHODIMP -nsStatusBarBiffManager::OnItemRemoved(nsIMsgFolder* parentItem, - nsISupports* item) { +nsStatusBarBiffManager::OnMessageAdded(nsIMsgFolder* parent, nsIMsgDBHdr* msg) { + return NS_OK; +} + +NS_IMETHODIMP +nsStatusBarBiffManager::OnFolderRemoved(nsIMsgFolder* parent, + nsIMsgFolder* child) { + return NS_OK; +} + +NS_IMETHODIMP +nsStatusBarBiffManager::OnMessageRemoved(nsIMsgFolder* parent, + nsIMsgDBHdr* msg) { return NS_OK; } diff --git a/mailnews/base/test/unit/test_bug428427.js b/mailnews/base/test/unit/test_bug428427.js index 2aef27872f..3ee5da7a6a 100644 --- a/mailnews/base/test/unit/test_bug428427.js +++ b/mailnews/base/test/unit/test_bug428427.js @@ -210,7 +210,7 @@ function CreateVirtualFolder( // use acctMgr to setup the virtual folder listener var acctMgr = MailServices.accounts.QueryInterface(Ci.nsIFolderListener); // print(acctMgr); - acctMgr.OnItemAdded(null, newFolder); + acctMgr.onFolderAdded(parentFolder, newFolder); return newFolder; } diff --git a/mailnews/base/test/unit/test_newMailNotification.js b/mailnews/base/test/unit/test_newMailNotification.js index e55fa87a75..00e719df5e 100644 --- a/mailnews/base/test/unit/test_newMailNotification.js +++ b/mailnews/base/test/unit/test_newMailNotification.js @@ -84,7 +84,7 @@ add_test(function testNotifyInbox() { let notif = MailServices.newMailNotification.wrappedJSObject; notif.addListener(mockListener, iNMNS.count); - notif.OnItemIntPropertyChanged(folder, "TotalUnreadMessages", 0, 2); + notif.onFolderIntPropertyChanged(folder, "TotalUnreadMessages", 0, 2); Assert.ok(notified); // Special folders should never count @@ -93,7 +93,7 @@ add_test(function testNotifyInbox() { flags: Ci.nsMsgFolderFlags.Mail | Ci.nsMsgFolderFlags.Junk, }; notified = false; - notif.OnItemIntPropertyChanged(special, "TotalUnreadMessages", 0, 2); + notif.onFolderIntPropertyChanged(special, "TotalUnreadMessages", 0, 2); Assert.ok(!notified); // by default, non-inbox should not count @@ -102,13 +102,13 @@ add_test(function testNotifyInbox() { flags: Ci.nsMsgFolderFlags.Mail, }; notified = false; - notif.OnItemIntPropertyChanged(nonInbox, "TotalUnreadMessages", 0, 2); + notif.onFolderIntPropertyChanged(nonInbox, "TotalUnreadMessages", 0, 2); Assert.ok(!notified); // Try setting the pref to count non-inboxes and notifying a non-inbox Services.prefs.setBoolPref(countInboxesPref, false); notified = false; - notif.OnItemIntPropertyChanged(nonInbox, "TotalUnreadMessages", 0, 2); + notif.onFolderIntPropertyChanged(nonInbox, "TotalUnreadMessages", 0, 2); Assert.ok(notified); run_next_test(); diff --git a/mailnews/base/test/unit/test_nsIFolderListener.js b/mailnews/base/test/unit/test_nsIFolderListener.js index c2f884852e..7b5234739d 100644 --- a/mailnews/base/test/unit/test_nsIFolderListener.js +++ b/mailnews/base/test/unit/test_nsIFolderListener.js @@ -14,14 +14,16 @@ load("../../../resources/MessageGenerator.jsm"); load("../../../resources/messageInjection.js"); var folderListener = { - OnItemAdded() {}, - OnItemRemoved() {}, - OnItemPropertyChanged() {}, - OnItemIntPropertyChanged() {}, - OnItemBoolPropertyChanged() {}, - OnItemUnicharPropertyChanged() {}, - OnItemPropertyFlagChanged() {}, - OnItemEvent() {}, + onFolderAdded() {}, + onMessageAdded() {}, + onFolderRemoved() {}, + onMessageRemoved() {}, + onFolderPropertyChanged() {}, + onFolderIntPropertyChanged() {}, + onFolderBoolPropertyChanged() {}, + onFolderUnicharPropertyChanged() {}, + onFolderPropertyFlagChanged() {}, + onFolderEvent() {}, }; var targetFolder; diff --git a/mailnews/base/test/unit/test_nsMsgMailSession_Listeners.js b/mailnews/base/test/unit/test_nsMsgMailSession_Listeners.js index fdecc91505..e6fa785d79 100644 --- a/mailnews/base/test/unit/test_nsMsgMailSession_Listeners.js +++ b/mailnews/base/test/unit/test_nsMsgMailSession_Listeners.js @@ -24,49 +24,61 @@ fL.prototype = { mReceived: 0, mAutoRemoveItem: false, - OnItemAdded(parentItem, item) { + onFolderAdded(parentFolder, child) { this.mReceived |= Ci.nsIFolderListener.added; if (this.mAutoRemoveItem) { MailServices.mailSession.RemoveFolderListener(this); } }, - OnItemRemoved(parentItem, item) { + onMessageAdded(parentFolder, msg) { + this.mReceived |= Ci.nsIFolderListener.added; + if (this.mAutoRemoveItem) { + MailServices.mailSession.RemoveFolderListener(this); + } + }, + onFolderRemoved(parentFolder, child) { this.mReceived |= Ci.nsIFolderListener.removed; if (this.mAutoRemoveItem) { MailServices.mailSession.RemoveFolderListener(this); } }, - OnItemPropertyChanged(item, property, oldValue, newValue) { + onMessageRemoved(parentFolder, msg) { + this.mReceived |= Ci.nsIFolderListener.removed; + if (this.mAutoRemoveItem) { + MailServices.mailSession.RemoveFolderListener(this); + } + }, + onFolderPropertyChanged(item, property, oldValue, newValue) { this.mReceived |= Ci.nsIFolderListener.propertyChanged; if (this.mAutoRemoveItem) { MailServices.mailSession.RemoveFolderListener(this); } }, - OnItemIntPropertyChanged(item, property, oldValue, newValue) { + onFolderIntPropertyChanged(item, property, oldValue, newValue) { this.mReceived |= Ci.nsIFolderListener.intPropertyChanged; if (this.mAutoRemoveItem) { MailServices.mailSession.RemoveFolderListener(this); } }, - OnItemBoolPropertyChanged(item, property, oldValue, newValue) { + onFolderBoolPropertyChanged(item, property, oldValue, newValue) { this.mReceived |= Ci.nsIFolderListener.boolPropertyChanged; if (this.mAutoRemoveItem) { MailServices.mailSession.RemoveFolderListener(this); } }, - OnItemUnicharPropertyChanged(item, property, oldValue, newValue) { + onFolderUnicharPropertyChanged(item, property, oldValue, newValue) { this.mReceived |= Ci.nsIFolderListener.unicharPropertyChanged; if (this.mAutoRemoveItem) { MailServices.mailSession.RemoveFolderListener(this); } }, - OnItemPropertyFlagChanged(item, property, oldValue, newValue) { + onFolderPropertyFlagChanged(item, property, oldValue, newValue) { this.mReceived |= Ci.nsIFolderListener.propertyFlagChanged; if (this.mAutoRemoveItem) { MailServices.mailSession.RemoveFolderListener(this); } }, - OnItemEvent(parentItem, item) { + onFolderEvent(parentItem, item) { this.mReceived |= Ci.nsIFolderListener.event; if (this.mAutoRemoveItem) { MailServices.mailSession.RemoveFolderListener(this); @@ -75,14 +87,16 @@ fL.prototype = { }; function NotifyMailSession() { - gMailSessionNotifier.OnItemAdded(null, null); - gMailSessionNotifier.OnItemRemoved(null, null); - gMailSessionNotifier.OnItemPropertyChanged(null, null, null, null); - gMailSessionNotifier.OnItemIntPropertyChanged(null, null, null, null); - gMailSessionNotifier.OnItemBoolPropertyChanged(null, null, null, null); - gMailSessionNotifier.OnItemUnicharPropertyChanged(null, null, null, null); - gMailSessionNotifier.OnItemPropertyFlagChanged(null, null, null, null); - gMailSessionNotifier.OnItemEvent(null, null); + gMailSessionNotifier.onFolderAdded(null, null); + gMailSessionNotifier.onMessageAdded(null, null); + gMailSessionNotifier.onFolderRemoved(null, null); + gMailSessionNotifier.onMessageRemoved(null, null); + gMailSessionNotifier.onFolderPropertyChanged(null, null, null, null); + gMailSessionNotifier.onFolderIntPropertyChanged(null, null, null, null); + gMailSessionNotifier.onFolderBoolPropertyChanged(null, null, null, null); + gMailSessionNotifier.onFolderUnicharPropertyChanged(null, null, null, null); + gMailSessionNotifier.onFolderPropertyFlagChanged(null, null, null, null); + gMailSessionNotifier.onFolderEvent(null, null); } function run_test() { diff --git a/mailnews/compose/src/nsMsgSendLater.cpp b/mailnews/compose/src/nsMsgSendLater.cpp index bbf01eae93..73a7b94871 100644 --- a/mailnews/compose/src/nsMsgSendLater.cpp +++ b/mailnews/compose/src/nsMsgSendLater.cpp @@ -1279,8 +1279,7 @@ nsresult nsMsgSendLater::GetIdentityFromKey(const char* aKey, return rv; } -NS_IMETHODIMP -nsMsgSendLater::OnItemAdded(nsIMsgFolder* aParentItem, nsISupports* aItem) { +nsresult nsMsgSendLater::StartTimer() { // No need to trigger if timer is already set if (mTimerSet) return NS_OK; @@ -1304,7 +1303,25 @@ nsMsgSendLater::OnItemAdded(nsIMsgFolder* aParentItem, nsISupports* aItem) { } NS_IMETHODIMP -nsMsgSendLater::OnItemRemoved(nsIMsgFolder* aParentItem, nsISupports* aItem) { +nsMsgSendLater::OnFolderAdded(nsIMsgFolder* /*parent*/, + nsIMsgFolder* /*child*/) { + return StartTimer(); +} + +NS_IMETHODIMP +nsMsgSendLater::OnMessageAdded(nsIMsgFolder* /*parent*/, nsIMsgDBHdr* /*msg*/) { + return StartTimer(); +} + +NS_IMETHODIMP +nsMsgSendLater::OnFolderRemoved(nsIMsgFolder* /*parent*/, + nsIMsgFolder* /*child*/) { + return NS_OK; +} + +NS_IMETHODIMP +nsMsgSendLater::OnMessageRemoved(nsIMsgFolder* /*parent*/, + nsIMsgDBHdr* /*msg*/) { return NS_OK; } diff --git a/mailnews/compose/src/nsMsgSendLater.h b/mailnews/compose/src/nsMsgSendLater.h index 67a2007df2..d335afffd3 100644 --- a/mailnews/compose/src/nsMsgSendLater.h +++ b/mailnews/compose/src/nsMsgSendLater.h @@ -101,6 +101,7 @@ class nsMsgSendLater : public nsIMsgSendLater, nsresult GetIdentityFromKey(const char* aKey, nsIMsgIdentity** aIdentity); nsresult ReparseDBIfNeeded(nsIUrlListener* aListener); nsresult InternalSendMessages(bool aUserInitiated, nsIMsgIdentity* aIdentity); + nsresult StartTimer(); nsTObserverArray > mListenerArray; nsCOMPtr mMessage; diff --git a/mailnews/db/gloda/modules/IndexMsg.jsm b/mailnews/db/gloda/modules/IndexMsg.jsm index 74ffc05d37..181f943ba2 100644 --- a/mailnews/db/gloda/modules/IndexMsg.jsm +++ b/mailnews/db/gloda/modules/IndexMsg.jsm @@ -2917,15 +2917,17 @@ var GlodaMsgIndexer = { this.indexer = aIndexer; }, - OnItemAdded(aParentItem, aItem) {}, - OnItemRemoved(aParentItem, aItem) {}, - OnItemPropertyChanged(aItem, aProperty, aOldValue, aNewValue) {}, + onFolderAdded(parentFolder, child) {}, + onMessageAdded(parentFolder, msg) {}, + onFolderRemoved(parentFolder, child) {}, + onMessageRemoved(parentFolder, msg) {}, + onFolderPropertyChanged(aItem, aProperty, aOldValue, aNewValue) {}, /** * Detect changes to folder flags and reset our indexing priority. This * is important because (all?) folders start out without any flags and * then get their flags added to them. */ - OnItemIntPropertyChanged(aFolderItem, aProperty, aOldValue, aNewValue) { + onFolderIntPropertyChanged(aFolderItem, aProperty, aOldValue, aNewValue) { if (aProperty !== "FolderFlag") { return; } @@ -2941,13 +2943,13 @@ var GlodaMsgIndexer = { } GlodaMsgIndexer.resetFolderIndexingPriority(aFolderItem); }, - OnItemBoolPropertyChanged(aItem, aProperty, aOldValue, aNewValue) {}, - OnItemUnicharPropertyChanged(aItem, aProperty, aOldValue, aNewValue) {}, + onFolderBoolPropertyChanged(aItem, aProperty, aOldValue, aNewValue) {}, + onFolderUnicharPropertyChanged(aItem, aProperty, aOldValue, aNewValue) {}, /** * Notice when user activity adds/removes tags or changes a message's * status. */ - OnItemPropertyFlagChanged(aMsgHdr, aProperty, aOldValue, aNewValue) { + onFolderPropertyFlagChanged(aMsgHdr, aProperty, aOldValue, aNewValue) { if ( aProperty == "Keywords" || // We could care less about the new flag changing. @@ -2966,7 +2968,7 @@ var GlodaMsgIndexer = { * Get folder loaded notifications for folders that had to do some * (asynchronous) processing before they could be opened. */ - OnItemEvent(aFolder, aEvent) { + onFolderEvent(aFolder, aEvent) { if (aEvent == "FolderLoaded") { this.indexer._onFolderLoaded(aFolder); } diff --git a/mailnews/imap/test/unit/test_dontStatNoSelect.js b/mailnews/imap/test/unit/test_dontStatNoSelect.js index ed20a1072a..481f13148e 100644 --- a/mailnews/imap/test/unit/test_dontStatNoSelect.js +++ b/mailnews/imap/test/unit/test_dontStatNoSelect.js @@ -131,7 +131,7 @@ function* endTest() { } var gFolderListener = { - OnItemBoolPropertyChanged(aItem, aProperty, aOldValue, aNewValue) { + onFolderBoolPropertyChanged(aItem, aProperty, aOldValue, aNewValue) { // This means that the STAT on "folder 2" has finished. if (aProperty == "NewMessages" && aNewValue) { async_driver(); diff --git a/mailnews/imap/test/unit/test_imapFilterActions.js b/mailnews/imap/test/unit/test_imapFilterActions.js index 91acfdecf9..77ec257219 100644 --- a/mailnews/imap/test/unit/test_imapFilterActions.js +++ b/mailnews/imap/test/unit/test_imapFilterActions.js @@ -419,7 +419,7 @@ function endTest() { // nsIFolderListener implementation var FolderListener = { - OnItemEvent(aEventFolder, aEvent) { + onFolderEvent(aEventFolder, aEvent) { dump( "received folder event " + aEvent + " folder " + aEventFolder.name + "\n" ); diff --git a/mailnews/imap/test/unit/test_imapFilterActionsPostplugin.js b/mailnews/imap/test/unit/test_imapFilterActionsPostplugin.js index 2fe42cb895..5023153c65 100644 --- a/mailnews/imap/test/unit/test_imapFilterActionsPostplugin.js +++ b/mailnews/imap/test/unit/test_imapFilterActionsPostplugin.js @@ -251,7 +251,7 @@ function endTest() { // nsIFolderListener implementation var FolderListener = { - OnItemEvent(aEventFolder, aEvent) { + onFolderEvent(aEventFolder, aEvent) { dump( "received folder event " + aEvent + " folder " + aEventFolder.name + "\n" ); diff --git a/mailnews/imap/test/unit/test_imapHdrChunking.js b/mailnews/imap/test/unit/test_imapHdrChunking.js index 4c599ea9e7..4bf1f5c929 100644 --- a/mailnews/imap/test/unit/test_imapHdrChunking.js +++ b/mailnews/imap/test/unit/test_imapHdrChunking.js @@ -34,7 +34,7 @@ var dummyMsgWindow = { var gFolderListener = { _gotNewMailBiff: false, - OnItemIntPropertyChanged(aItem, aProperty, aOldValue, aNewValue) { + onFolderIntPropertyChanged(aItem, aProperty, aOldValue, aNewValue) { if ( aProperty == "BiffState" && aNewValue == Ci.nsIMsgFolder.nsMsgBiffState_NewMail diff --git a/mailnews/local/src/nsLocalUndoTxn.cpp b/mailnews/local/src/nsLocalUndoTxn.cpp index c2289e9aa3..54efe6ec38 100644 --- a/mailnews/local/src/nsLocalUndoTxn.cpp +++ b/mailnews/local/src/nsLocalUndoTxn.cpp @@ -359,34 +359,42 @@ nsLocalMoveCopyMsgTxn::RedoTransaction() { return rv; } -NS_IMETHODIMP nsLocalMoveCopyMsgTxn::OnItemAdded(nsIMsgFolder* parentItem, - nsISupports* item) { - nsCOMPtr msgHdr(do_QueryInterface(item)); - if (msgHdr) { - nsresult rv; - nsCOMPtr folder = - do_QueryReferent(m_undoing ? m_srcFolder : m_dstFolder, &rv); - NS_ENSURE_SUCCESS(rv, rv); - nsCString messageId; - msgHdr->GetMessageId(getter_Copies(messageId)); - if (m_copiedMsgIds.Contains(messageId)) { - nsMsgKey msgKey; - msgHdr->GetMessageKey(&msgKey); - if (m_undoing) - m_srcKeyArray.AppendElement(msgKey); - else - m_dstKeyArray.AppendElement(msgKey); - if (++m_numHdrsCopied == m_copiedMsgIds.Length()) { - folder->RemoveFolderListener(this); - m_copiedMsgIds.Clear(); - } +NS_IMETHODIMP nsLocalMoveCopyMsgTxn::OnFolderAdded(nsIMsgFolder* parent, + nsIMsgFolder* child) { + return NS_OK; +} + +NS_IMETHODIMP nsLocalMoveCopyMsgTxn::OnMessageAdded(nsIMsgFolder* parent, + nsIMsgDBHdr + : msgHdr) { + nsresult rv; + nsCOMPtr folder = + do_QueryReferent(m_undoing ? m_srcFolder : m_dstFolder, &rv); + NS_ENSURE_SUCCESS(rv, rv); + nsCString messageId; + msgHdr->GetMessageId(getter_Copies(messageId)); + if (m_copiedMsgIds.Contains(messageId)) { + nsMsgKey msgKey; + msgHdr->GetMessageKey(&msgKey); + if (m_undoing) + m_srcKeyArray.AppendElement(msgKey); + else + m_dstKeyArray.AppendElement(msgKey); + if (++m_numHdrsCopied == m_copiedMsgIds.Length()) { + folder->RemoveFolderListener(this); + m_copiedMsgIds.Clear(); } } return NS_OK; } -NS_IMETHODIMP nsLocalMoveCopyMsgTxn::OnItemRemoved(nsIMsgFolder* parentItem, - nsISupports* item) { +NS_IMETHODIMP nsLocalMoveCopyMsgTxn::OnFolderRemoved(nsIMsgFolder* parent, + nsIMsgFolder* child) { + return NS_OK; +} + +NS_IMETHODIMP nsLocalMoveCopyMsgTxn::OnMessageRemoved(nsIMsgFolder* parent, + nsIMsgDBHdr* msg) { return NS_OK; } @@ -435,13 +443,23 @@ nsLocalUndoFolderListener::nsLocalUndoFolderListener( nsLocalUndoFolderListener::~nsLocalUndoFolderListener() {} -NS_IMETHODIMP nsLocalUndoFolderListener::OnItemAdded(nsIMsgFolder* parentItem, - nsISupports* item) { +NS_IMETHODIMP nsLocalUndoFolderListener::OnFolderAdded(nsIMsgFolder* parent, + nsIMsgFolder* child) { return NS_OK; } -NS_IMETHODIMP nsLocalUndoFolderListener::OnItemRemoved(nsIMsgFolder* parentItem, - nsISupports* item) { +NS_IMETHODIMP nsLocalUndoFolderListener::OnMessageAdded(nsIMsgFolder* parent, + nsIMsgDBHdr* msg) { + return NS_OK; +} + +NS_IMETHODIMP nsLocalUndoFolderListener::OnFolderRemoved(nsIMsgFolder* parent, + nsIMsgFolder* child) { + return NS_OK; +} + +NS_IMETHODIMP nsLocalUndoFolderListener::OnMessageRemoved(nsIMsgFolder* parent, + nsIMsgDBHdr* msg) { return NS_OK; } diff --git a/mailnews/local/test/unit/test_over4GBMailboxes.js b/mailnews/local/test/unit/test_over4GBMailboxes.js index 9d9ad7e1af..230f3a1daa 100644 --- a/mailnews/local/test/unit/test_over4GBMailboxes.js +++ b/mailnews/local/test/unit/test_over4GBMailboxes.js @@ -79,10 +79,13 @@ var FListener = { return this.totalMsgs[this.totalMsgs.length - 1 - aBack]; }, - OnItemAdded: function act_add(aRDFParentItem, aItem) {}, - OnItemRemoved: function act_remove(aRDFParentItem, aItem) {}, - OnItemPropertyChanged(aItem, aProperty, aOld, aNew) {}, - OnItemIntPropertyChanged(aItem, aProperty, aOld, aNew) { + onFolderAdded: function act_add(parentFolder, child) {}, + onMessageAdded: function act_add(parentFolder, msg) {}, + onFolderRemoved: function act_remove(parentFolder, child) {}, + onMessageRemoved: function act_remove(parentFolder, msg) {}, + + onFolderPropertyChanged(aItem, aProperty, aOld, aNew) {}, + onFolderIntPropertyChanged(aItem, aProperty, aOld, aNew) { if (aItem === gInbox) { dump( "Property change on folder Inbox:" + @@ -100,10 +103,10 @@ var FListener = { } } }, - OnItemBoolPropertyChanged(aItem, aProperty, aOld, aNew) {}, - OnItemUnicharPropertyChanged(aItem, aProperty, aOld, aNew) {}, - OnItemPropertyFlagChanged(aItem, aProperty, aOld, aNew) {}, - OnItemEvent(aFolder, aEvent) {}, + onFolderBoolPropertyChanged(aItem, aProperty, aOld, aNew) {}, + onFolderUnicharPropertyChanged(aItem, aProperty, aOld, aNew) {}, + onFolderPropertyFlagChanged(aItem, aProperty, aOld, aNew) {}, + onFolderEvent(aFolder, aEvent) {}, }; /** @@ -365,7 +368,7 @@ function downloadOver4GiB_success_check() { Assert.equal(gInbox.sizeOnDisk, localInboxSize); // Bug 813459 - // Check if the OnItemIntPropertyChanged folder listener hook can return + // Check if the onFolderIntPropertyChanged folder listener hook can return // values above 2^32 for properties where it is relevant. Assert.equal(FListener.sizeHistory(0), gInbox.sizeOnDisk); Assert.ok(FListener.sizeHistory(1) < FListener.sizeHistory(0)); @@ -560,7 +563,7 @@ var ParseListener_run_test = { Assert.notEqual(gInbox.msgDatabase, null); Assert.ok(gInbox.msgDatabase.summaryValid); // Bug 813459 - // Check if the OnItemIntPropertyChanged folder listener hook can return + // Check if the onFolderIntPropertyChanged folder listener hook can return // values below 2^32 for properties which are not 64 bits long. Assert.equal(FListener.msgsHistory(0), gExpectedNewMessages); Assert.equal(FListener.msgsHistory(0), gInbox.getTotalMessages(false)); diff --git a/mailnews/news/test/unit/test_bug695309.js b/mailnews/news/test/unit/test_bug695309.js index 978e7268a9..bffee333d7 100644 --- a/mailnews/news/test/unit/test_bug695309.js +++ b/mailnews/news/test/unit/test_bug695309.js @@ -82,7 +82,7 @@ add_task(async function trigger_bug() { return new Promise((resolve, reject) => { let folderListener = { QueryInterface: ChromeUtils.generateQI(["nsIFolderListener"]), - OnItemEvent(aEventFolder, aEvent) { + onFolderEvent(aEventFolder, aEvent) { if ( aEvent == "FolderLoaded" && aEventFolder.prettyName == "test.subscribe.simple" diff --git a/mailnews/news/test/unit/test_internalUris.js b/mailnews/news/test/unit/test_internalUris.js index 5e320ab529..0b60f5b23a 100644 --- a/mailnews/news/test/unit/test_internalUris.js +++ b/mailnews/news/test/unit/test_internalUris.js @@ -79,7 +79,7 @@ function* test_cancel() { let hdr = db.GetMsgHdrForKey(4); let folderListener = { - OnItemEvent(aEventFolder, aEvent) { + onFolderEvent(aEventFolder, aEvent) { if (aEvent == "DeleteOrMoveMsgCompleted") { MailServices.mailSession.RemoveFolderListener(this); } diff --git a/mailnews/test/resources/MailTestUtils.jsm b/mailnews/test/resources/MailTestUtils.jsm index 20bfb6083b..ba837f3c65 100644 --- a/mailnews/test/resources/MailTestUtils.jsm +++ b/mailnews/test/resources/MailTestUtils.jsm @@ -519,7 +519,7 @@ var mailTestUtils = { // register for the folder loaded notification ahead of time... even though // we may not need it... let folderListener = { - OnItemEvent(aEventFolder, aEvent) { + onFolderEvent(aEventFolder, aEvent) { if (aEvent == "FolderLoaded" && aFolder.URI == aEventFolder.URI) { MailServices.mailSession.RemoveFolderListener(this); aCallback.apply(aCallbackThis, aCallbackArgs); diff --git a/mailnews/test/resources/PromiseTestUtils.jsm b/mailnews/test/resources/PromiseTestUtils.jsm index 5d28293cbd..a4062f972b 100644 --- a/mailnews/test/resources/PromiseTestUtils.jsm +++ b/mailnews/test/resources/PromiseTestUtils.jsm @@ -178,7 +178,7 @@ PromiseTestUtils.promiseFolderEvent = function(folder, event) { return new Promise((resolve, reject) => { let folderListener = { QueryInterface: ChromeUtils.generateQI(["nsIFolderListener"]), - OnItemEvent(aEventFolder, aEvent) { + onFolderEvent(aEventFolder, aEvent) { if (folder === aEventFolder && event == aEvent) { MailServices.mailSession.RemoveFolderListener(folderListener); resolve(); diff --git a/mailnews/test/resources/folderEventLogHelper.js b/mailnews/test/resources/folderEventLogHelper.js index c125d311c0..2e3bb363b4 100644 --- a/mailnews/test/resources/folderEventLogHelper.js +++ b/mailnews/test/resources/folderEventLogHelper.js @@ -144,18 +144,20 @@ var _folderEventLogHelper_msgFolderListener = { * nsIFolderListener implementation to logHelper stuff that gloda cares about. */ var _folderEventLogHelper_folderListener = { - OnItemAdded(aParentItem, aItem) {}, - OnItemRemoved(aParentItem, aItem) {}, - OnItemPropertyChanged(aItem, aProperty, aOldValue, aNewValue) {}, - OnItemIntPropertyChanged(aItem, aProperty, aOldValue, aNewValue) {}, - OnItemBoolPropertyChanged(aItem, aProperty, aOldValue, aNewValue) {}, - OnItemUnicharPropertyChanged(aItem, aProperty, aOldValue, aNewValue) {}, + onFolderAdded(parentFolder, child) {}, + onMessageAdded(parentFolder, msg) {}, + onFolderRemoved(parentFolder, child) {}, + onMessageRemoved(parentFolder, msg) {}, + onFolderPropertyChanged(aItem, aProperty, aOldValue, aNewValue) {}, + onFolderIntPropertyChanged(aItem, aProperty, aOldValue, aNewValue) {}, + onFolderBoolPropertyChanged(aItem, aProperty, aOldValue, aNewValue) {}, + onFolderUnicharPropertyChanged(aItem, aProperty, aOldValue, aNewValue) {}, /** * Notice when user activity adds/removes tags or changes a message's * status. */ - OnItemPropertyFlagChanged(aMsgHdr, aProperty, aOldValue, aNewValue) { - mark_action("msgEvent", "OnItemPropertyFlagChanged", [ + onFolderPropertyFlagChanged(aMsgHdr, aProperty, aOldValue, aNewValue) { + mark_action("msgEvent", "onFolderPropertyFlagChanged", [ "Header", aMsgHdr, "had property " + @@ -170,7 +172,7 @@ var _folderEventLogHelper_folderListener = { * Get folder loaded notifications for folders that had to do some * (asynchronous) processing before they could be opened. */ - OnItemEvent(aFolder, aEvent) { - mark_action("msgEvent", "OnItemEvent", [aFolder, aEvent]); + onFolderEvent(aFolder, aEvent) { + mark_action("msgEvent", "onFolderEvent", [aFolder, aEvent]); }, }; diff --git a/suite/mailnews/content/SearchDialog.js b/suite/mailnews/content/SearchDialog.js index 7d6c5d46e7..20bca4a272 100644 --- a/suite/mailnews/content/SearchDialog.js +++ b/suite/mailnews/content/SearchDialog.js @@ -190,20 +190,21 @@ var gSearchNotificationListener = // the folderListener object var gFolderListener = { - OnItemAdded: function(parentItem, item) {}, + onFolderAdded: function(parentFolder, child) {}, + onMessageAdded: function(parentFolder, msg) {}, + onFolderRemoved: function(parentFolder, child) {}, + onMessageRemoved: function(parentFolder, msg) {}, - OnItemRemoved: function(parentItem, item){}, + onFolderPropertyChanged: function(item, property, oldValue, newValue) {}, - OnItemPropertyChanged: function(item, property, oldValue, newValue) {}, + onFolderIntPropertyChanged: function(item, property, oldValue, newValue) {}, - OnItemIntPropertyChanged: function(item, property, oldValue, newValue) {}, + onFolderBoolPropertyChanged: function(item, property, oldValue, newValue) {}, - OnItemBoolPropertyChanged: function(item, property, oldValue, newValue) {}, + onFolderUnicharPropertyChanged: function(item, property, oldValue, newValue){}, + onFolderPropertyFlagChanged: function(item, property, oldFlag, newFlag) {}, - OnItemUnicharPropertyChanged: function(item, property, oldValue, newValue){}, - OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) {}, - - OnItemEvent: function(folder, event) { + onFolderEvent: function(folder, event) { if (event == "DeleteOrMoveMsgCompleted") { HandleDeleteOrMoveMessageCompleted(folder); } diff --git a/suite/mailnews/content/folderPane.js b/suite/mailnews/content/folderPane.js index 46b0fabb80..f56d3366b1 100644 --- a/suite/mailnews/content/folderPane.js +++ b/suite/mailnews/content/folderPane.js @@ -1391,10 +1391,9 @@ let gFolderTreeView = { /** * This is our implementation of nsIMsgFolderListener to watch for changes */ - OnItemAdded: function ftl_add(aParentItem, aItem) { + onFolderAdded: function ftl_add(aParentItem, aItem) { // Ignore this item if it's not a folder, or we knew about it. - if (!(aItem instanceof Ci.nsIMsgFolder) || - this.getIndexOfFolder(aItem) != null) + if (this.getIndexOfFolder(aItem) != null) return; // If no parent, this is an account, so let's rebuild. @@ -1406,6 +1405,7 @@ let gFolderTreeView = { this._modes[this._mode].onFolderAdded( aParentItem.QueryInterface(Ci.nsIMsgFolder), aItem); }, + onMessageAdded: function(parentFolder, msg) {}, addFolder: function ftl_add_folder(aParentItem, aItem) { // This intentionally adds any new folder even if it would not pass the @@ -1452,10 +1452,7 @@ let gFolderTreeView = { this._addChildToView(parent, parentIndex, newChild); }, - OnItemRemoved: function ftl_remove(aRDFParentItem, aItem) { - if (!(aItem instanceof Ci.nsIMsgFolder)) - return; - + onFolderRemoved: function ftl_remove(aRDFParentItem, aItem) { this._persistItemClosed(aItem.URI); let index = this.getIndexOfFolder(aItem); @@ -1476,8 +1473,10 @@ let gFolderTreeView = { this._tree.invalidateRow(index); }, - OnItemPropertyChanged: function(aItem, aProperty, aOld, aNew) {}, - OnItemIntPropertyChanged: function(aItem, aProperty, aOld, aNew) { + onMessageRemoved: function(parentFolder, msg) {}, + + onFolderPropertyChanged: function(aItem, aProperty, aOld, aNew) {}, + onFolderIntPropertyChanged: function(aItem, aProperty, aOld, aNew) { // First try mode specific handling of the changed property. if (this._modes[this.mode].handleChangedIntProperty(aItem, aProperty, aOld, aNew)) @@ -1499,14 +1498,14 @@ let gFolderTreeView = { } }, - OnItemBoolPropertyChanged: function(aItem, aProperty, aOld, aNew) { + onFolderBoolPropertyChanged: function(aItem, aProperty, aOld, aNew) { let index = this.getIndexOfFolder(aItem); if (index != null) this._tree.invalidateRow(index); }, - OnItemUnicharPropertyChanged: function(aItem, aProperty, aOld, aNew) {}, - OnItemPropertyFlagChanged: function(aItem, aProperty, aOld, aNew) {}, - OnItemEvent: function(aFolder, aEvent) { + onFolderUnicharPropertyChanged: function(aItem, aProperty, aOld, aNew) {}, + onFolderPropertyFlagChanged: function(aItem, aProperty, aOld, aNew) {}, + onFolderEvent: function(aFolder, aEvent) { let index = this.getIndexOfFolder(aFolder); if (index != null) this._tree.invalidateRow(index); diff --git a/suite/mailnews/content/messageWindow.js b/suite/mailnews/content/messageWindow.js index 93495d1e9d..63effe6c3c 100644 --- a/suite/mailnews/content/messageWindow.js +++ b/suite/mailnews/content/messageWindow.js @@ -24,31 +24,30 @@ var gNextMessageAfterLoad = null; // the folderListener object var folderListener = { - OnItemAdded: function(parentItem, item) {}, - - OnItemRemoved: function(parentItem, item) + onFolderAdded: function(parentFolder, child) {}, + onMessageAdded: function(parentFolder, msg) {}, + onFolderRemoved: function(parentFolder, child) {}, + onMessageRemoved: function(parentFolder, msg) { - if (parentItem.URI != gCurrentFolderUri) + if (parentFolder.URI != gCurrentFolderUri) return; - - if (item instanceof Ci.nsIMsgDBHdr && - extractMsgKeyFromURI() == item.messageKey) + if (extractMsgKeyFromURI() == msg.messageKey) gCurrentMessageIsDeleted = true; }, - OnItemPropertyChanged: function(item, property, oldValue, newValue) {}, - OnItemIntPropertyChanged: function(item, property, oldValue, newValue) { + onFolderPropertyChanged: function(item, property, oldValue, newValue) {}, + onFolderIntPropertyChanged: function(item, property, oldValue, newValue) { if (item.URI == gCurrentFolderUri) { if (property == "TotalMessages" || property == "TotalUnreadMessages") { UpdateStandAloneMessageCounts(); } } }, - OnItemBoolPropertyChanged: function(item, property, oldValue, newValue) {}, - OnItemUnicharPropertyChanged: function(item, property, oldValue, newValue){}, - OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) {}, + onFolderBoolPropertyChanged: function(item, property, oldValue, newValue) {}, + onFolderUnicharPropertyChanged: function(item, property, oldValue, newValue){}, + onFolderPropertyFlagChanged: function(item, property, oldFlag, newFlag) {}, - OnItemEvent: function(folder, event) { + onFolderEvent: function(folder, event) { if (event == "DeleteOrMoveMsgCompleted") HandleDeleteOrMoveMsgCompleted(folder); else if (event == "DeleteOrMoveMsgFailed") diff --git a/suite/mailnews/content/msgMail3PaneWindow.js b/suite/mailnews/content/msgMail3PaneWindow.js index 55a71e380b..6dd66ed086 100644 --- a/suite/mailnews/content/msgMail3PaneWindow.js +++ b/suite/mailnews/content/msgMail3PaneWindow.js @@ -113,15 +113,17 @@ function ScrollToMessageAfterFolderLoad(folder) // the folderListener object var folderListener = { - OnItemAdded: function(parentItem, item) {}, - OnItemRemoved: function(parentItem, item) {}, + onFolderAdded: function(parentFolder, child) {}, + onMessageAdded: function(parentFolder, msg) {}, + onFolderRemoved: function(parentFolder, child) {}, + onMessageRemoved: function(parentFolder, msg) {}, - OnItemPropertyChanged: function(item, property, oldValue, newValue) {}, - OnItemBoolPropertyChanged: function(item, property, oldValue, newValue) {}, - OnItemUnicharPropertyChanged: function(item, property, oldValue, newValue) {}, - OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) {}, + onFolderPropertyChanged: function(item, property, oldValue, newValue) {}, + onFolderBoolPropertyChanged: function(item, property, oldValue, newValue) {}, + onFolderUnicharPropertyChanged: function(item, property, oldValue, newValue) {}, + onFolderPropertyFlagChanged: function(item, property, oldFlag, newFlag) {}, - OnItemIntPropertyChanged: function(item, property, oldValue, newValue) + onFolderIntPropertyChanged: function(item, property, oldValue, newValue) { // handle the currently visible folder if (item == gMsgFolderSelected) @@ -151,7 +153,7 @@ var folderListener = } }, - OnItemEvent: function(folder, event) { + onFolderEvent: function(folder, event) { if (event == "FolderLoaded") { if (folder) { var scrolled = false;