|
1.nsIMsgFolderNotificationService移动复制或删除邮件后通知界面更新- nsresult nsImapMailFolder::CopyMessagesOffline(nsIMsgFolder* srcFolder,
- nsIArray* messages,
- bool isMove,
- nsIMsgWindow *msgWindow,
- nsIMsgCopyServiceListener* listener)
- {
- uint32_t numHdrs;
- msgHdrsCopied->GetLength(&numHdrs);
- if (numHdrs)
- {
- nsCOMPtr<nsIMsgFolderNotificationService> notifier(do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID));
- if (notifier)
- notifier->NotifyMsgsMoveCopyCompleted(isMove, msgHdrsCopied, this, destMsgHdrs);
- }
- }
- NS_IMETHODIMP nsMsgFolderNotificationService::NotifyMsgsMoveCopyCompleted(
- bool aMove, nsIArray *aSrcMsgs, nsIMsgFolder *aDestFolder,
- nsIArray *aDestMsgs)
- {
-
- NOTIFY_MSGFOLDER_LISTENERS(msgsMoveCopyCompleted, MsgsMoveCopyCompleted,
- (isReallyMove, aSrcMsgs, aDestFolder, aDestMsgs));
- return NS_OK;
- }
- //对所有观察都对象中含有指定标记的观察者调用指定方法
- #define NOTIFY_MSGFOLDER_LISTENERS(propertyflag_, propertyfunc_, params_) \
- PR_BEGIN_MACRO \
- nsTObserverArray<MsgFolderListener>::ForwardIterator iter(mListeners); \
- while (iter.HasMore()) { \
- const MsgFolderListener &listener = iter.GetNext(); \
- if (listener.mFlags & propertyflag_) \
- listener.mListener->propertyfunc_ params_; \
- } \
复制代码 邮件列表只要注册上面监听,就可获取到删除邮件的通知- // 监听邮件通知
- var notificationService =
- Components.classes["@mozilla.org/messenger/msgnotificationservice;1"].
- getService(Components.interfaces.nsIMsgFolderNotificationService);
- notificationService.addListener(this,
- Components.interfaces.nsIMsgFolderNotificationService.msgAdded |
- Components.interfaces.nsIMsgFolderNotificationService.msgsClassified |
- Components.interfaces.nsIMsgFolderNotificationService.msgsDeleted |
- Components.interfaces.nsIMsgFolderNotificationService.msgsMoveCopyCompleted |
- Components.interfaces.nsIMsgFolderNotificationService.msgKeyChanged |
- Components.interfaces.nsIMsgFolderNotificationService.folderAdded |
- Components.interfaces.nsIMsgFolderNotificationService.folderDeleted |
- Components.interfaces.nsIMsgFolderNotificationService.folderMoveCopyCompleted |
- Components.interfaces.nsIMsgFolderNotificationService.folderRenamed |
- Components.interfaces.nsIMsgFolderNotificationService.itemEvent);
- },
- msgsMoveCopyCompleted: function(isMove, srcMsgHdrArray, destFolder, destMsgHdrArray) {
- if (isMove) {
- this.removeMsgItemsForMsgHdrArray(srcMsgHdrArray);
- }
- },
复制代码 |
|