From 04ededecb03da888ceae4b98de2dc1e520e5bc87 Mon Sep 17 00:00:00 2001 From: "bienvenu%nventure.com" Date: Fri, 26 Jan 2007 01:22:48 +0000 Subject: [PATCH] add new msg+folder notification service geared more to the needs of desktop search indexers, sr=mscott 290057 git-svn-id: svn://10.0.0.236/trunk@218944 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/mailnews/base/public/Makefile.in | 2 + .../base/public/nsIMsgFolderListener.idl | 65 ++++++++ .../nsIMsgFolderNotificationService.idl | 61 +++++++ mozilla/mailnews/base/public/nsMsgBaseCID.h | 11 ++ mozilla/mailnews/base/src/Makefile.in | 1 + .../mailnews/base/src/nsMsgCopyService.cpp | 31 ++++ .../src/nsMsgFolderNotificationService.cpp | 155 ++++++++++++++++++ .../base/src/nsMsgFolderNotificationService.h | 61 +++++++ mozilla/mailnews/base/util/nsMsgDBFolder.cpp | 11 +- .../mailnews/imap/src/nsImapMailFolder.cpp | 9 +- .../mailnews/local/src/nsLocalMailFolder.cpp | 43 ++++- mozilla/mailnews/local/src/nsParseMailbox.cpp | 10 ++ mozilla/mailnews/local/src/nsParseMailbox.h | 3 + mozilla/mailnews/local/src/nsPop3Sink.cpp | 1 + 14 files changed, 459 insertions(+), 5 deletions(-) create mode 100644 mozilla/mailnews/base/public/nsIMsgFolderListener.idl create mode 100644 mozilla/mailnews/base/public/nsIMsgFolderNotificationService.idl create mode 100644 mozilla/mailnews/base/src/nsMsgFolderNotificationService.cpp create mode 100644 mozilla/mailnews/base/src/nsMsgFolderNotificationService.h diff --git a/mozilla/mailnews/base/public/Makefile.in b/mozilla/mailnews/base/public/Makefile.in index a5bf5273016..1622003207e 100644 --- a/mozilla/mailnews/base/public/Makefile.in +++ b/mozilla/mailnews/base/public/Makefile.in @@ -79,6 +79,8 @@ XPIDLSRCS = \ nsIMsgPurgeService.idl \ nsIMsgCopyService.idl \ nsIMsgCopyServiceListener.idl \ + nsIMsgFolderListener.idl \ + nsIMsgFolderNotificationService.idl \ nsIMsgStatusFeedback.idl \ nsIMsgMailNewsUrl.idl \ nsIMsgWindow.idl \ diff --git a/mozilla/mailnews/base/public/nsIMsgFolderListener.idl b/mozilla/mailnews/base/public/nsIMsgFolderListener.idl new file mode 100644 index 00000000000..afa485659ae --- /dev/null +++ b/mozilla/mailnews/base/public/nsIMsgFolderListener.idl @@ -0,0 +1,65 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * The Mozilla Corporation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * David Bienvenu + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +#include "nsISupports.idl" + +interface nsIMsgFolder; +interface nsISupportsArray; + +// This is similar to nsIFolderListener, but with slightly different semantics, +// especially w.r.t. moving messages and folders. Some listeners want to know +// about moves, instead of getting an itemAdded and itemRemoved notification. +// Folder listeners also only tend to get called if a view is open on the folder, +// which is not always the case. I don't want to change nsIFolderListener at this +// point since there are lots of extensions that rely on it. Eventually, +// these two interfaces should be combined somehow. + +[scriptable, uuid(1202F417-4580-4F02-89E5-151BA2C6E3C7)] +interface nsIMsgFolderListener : nsISupports { + // new msg or folder added + void itemAdded(in nsISupports aItem); + // folder or msg deleted (no trash) + void itemDeleted(in nsISupports aItem); + void itemMoveCopyCompleted(in boolean aMove, + in nsISupportsArray aSrcItems, + in nsIMsgFolder aDestFolder); + + void folderRenamed(in nsIMsgFolder aOrigFolder, in nsIMsgFolder aNewFolder); + // extensibility hook + void itemEvent(in nsISupports aItem, in ACString aEvent, in nsISupports aData); +}; + diff --git a/mozilla/mailnews/base/public/nsIMsgFolderNotificationService.idl b/mozilla/mailnews/base/public/nsIMsgFolderNotificationService.idl new file mode 100644 index 00000000000..ac35392961e --- /dev/null +++ b/mozilla/mailnews/base/public/nsIMsgFolderNotificationService.idl @@ -0,0 +1,61 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * The Mozilla Corporation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * David Bienvenu + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +#include "nsISupports.idl" + +interface nsIMsgFolder; +interface nsIMsgFolderListener; +interface nsISupportsArray; + + +[scriptable, uuid(4264C2DC-96AC-48B7-9822-DD4396EBB674)] +interface nsIMsgFolderNotificationService : nsISupports { + readonly attribute boolean hasListeners; + void addListener(in nsIMsgFolderListener aListener); + void removeListener(in nsIMsgFolderListener aListener); + + void notifyItemAdded(in nsISupports aItem); + void notifyItemDeleted(in nsISupports aItem); + void notifyItemMoveCopyCompleted(in boolean aMove, + in nsISupportsArray aSrcItems, + in nsIMsgFolder aDestFolder); + + void notifyFolderRenamed(in nsIMsgFolder aOrigFolder, in nsIMsgFolder aNewFolder); + // extensibility hook + void notifyItemEvent(in nsISupports aItem, in ACString aEvent, in nsISupports aData); +}; + diff --git a/mozilla/mailnews/base/public/nsMsgBaseCID.h b/mozilla/mailnews/base/public/nsMsgBaseCID.h index 5c3de6f50c2..9aa399ca79d 100644 --- a/mozilla/mailnews/base/public/nsMsgBaseCID.h +++ b/mozilla/mailnews/base/public/nsMsgBaseCID.h @@ -527,6 +527,17 @@ 0xb897da55, 0x8256, 0x4cf5, \ { 0x89, 0x2b, 0x32, 0xe7, 0x7b, 0xc7, 0xc5, 0x0b}} +// +// nsMsgNotificationService +// +#define NS_MSGNOTIFICATIONSERVICE_CONTRACTID \ +"@mozilla.org/messenger/msgnotificationservice;1" + +#define NS_MSGNOTIFICATIONSERVICE_CID \ +{ /* F1F7CBCD-D5E3-45A0-AA2D-CECF1A95AB03 */ \ + 0xf1f7cbcd, 0xd5e3, 0x45a0, \ + {0xaa, 0x2d, 0xce, 0xcf, 0x1a, 0x95, 0xab, 0x03}} + // // nsMessengerOSIntegration // diff --git a/mozilla/mailnews/base/src/Makefile.in b/mozilla/mailnews/base/src/Makefile.in index 214f64f37cf..ead7cb57f90 100644 --- a/mozilla/mailnews/base/src/Makefile.in +++ b/mozilla/mailnews/base/src/Makefile.in @@ -129,6 +129,7 @@ CPPSRCS = \ nsCidProtocolHandler.cpp \ nsMsgContentPolicy.cpp \ nsMsgTagService.cpp\ + nsMsgFolderNotificationService.cpp\ $(NULL) # MacOSX requires the MoreFiles module diff --git a/mozilla/mailnews/base/src/nsMsgCopyService.cpp b/mozilla/mailnews/base/src/nsMsgCopyService.cpp index 7c6a8aec893..2fe5cc99d87 100644 --- a/mozilla/mailnews/base/src/nsMsgCopyService.cpp +++ b/mozilla/mailnews/base/src/nsMsgCopyService.cpp @@ -41,6 +41,8 @@ #include "nsCOMArray.h" #include "nspr.h" #include "nsIFileSpec.h" +#include "nsIMsgFolderNotificationService.h" +#include "nsMsgBaseCID.h" // ******************** nsCopySource ****************** // @@ -179,6 +181,35 @@ nsMsgCopyService::ClearRequest(nsCopyRequest* aRequest, nsresult rv) { if (aRequest) { + // Send notifications to nsIGlobalMsgFolderNotificationService + + if (aRequest->m_requestType == nsCopyFoldersType) + { + nsCOMPtr notifier = do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID); + if (notifier) + { + PRBool hasListeners; + notifier->GetHasListeners(&hasListeners); + if (hasListeners) + { + nsCOMPtr supportsArray = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID); + if (supportsArray) + { + // Iterate over the copy sources and append their message arrays to this supports array + // or in the case of folders, the source folder. + PRInt32 cnt, i; + cnt = aRequest->m_copySourceArray.Count(); + for (i=0; i < cnt; i++) + { + nsCopySource *copySource = (nsCopySource*) aRequest->m_copySourceArray.ElementAt(i); + supportsArray->AppendElement(copySource->m_msgFolder); + } + notifier->NotifyItemMoveCopyCompleted(aRequest->m_isMoveOrDraftOrTemplate, supportsArray, aRequest->m_dstFolder); + } + } + } + } + // undo stuff if (aRequest->m_allowUndo && aRequest->m_copySourceArray.Count() > 1 && aRequest->m_txnMgr) diff --git a/mozilla/mailnews/base/src/nsMsgFolderNotificationService.cpp b/mozilla/mailnews/base/src/nsMsgFolderNotificationService.cpp new file mode 100644 index 00000000000..c2c58b97dfd --- /dev/null +++ b/mozilla/mailnews/base/src/nsMsgFolderNotificationService.cpp @@ -0,0 +1,155 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2006 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * David Bienvenu + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "msgCore.h" +#include "nsMsgFolderNotificationService.h" + + +// +// nsMsgFolderNotificationService +// +NS_IMPL_ISUPPORTS1(nsMsgFolderNotificationService, nsIMsgFolderNotificationService) + +nsMsgFolderNotificationService::nsMsgFolderNotificationService() +{ +} + +nsMsgFolderNotificationService::~nsMsgFolderNotificationService() +{ + /* destructor code */ +} + +NS_IMETHODIMP nsMsgFolderNotificationService::GetHasListeners(PRBool *aHasListeners) +{ + NS_ENSURE_ARG_POINTER(aHasListeners); + *aHasListeners = m_listeners.Count() > 0; + return NS_OK; +} + + +/* void addListener (in nsIMsgFolderListener aListener); */ +NS_IMETHODIMP nsMsgFolderNotificationService::AddListener(nsIMsgFolderListener *aListener) +{ + return m_listeners.AppendObject(aListener); +} + +/* void removeListener (in nsIMsgFolderListener aListener); */ +NS_IMETHODIMP nsMsgFolderNotificationService::RemoveListener(nsIMsgFolderListener *aListener) +{ + PRInt32 index = m_listeners.IndexOf(aListener); + NS_ASSERTION(index >= 0, "removing non-existent listener"); + if (index >= 0) + { + m_listeners.RemoveObjectAt(index); + } + return NS_OK; +} + +/* void notifItemAdded (in nsISupports aItem); */ +NS_IMETHODIMP nsMsgFolderNotificationService::NotifyItemAdded(nsISupports *aItem) +{ + PRInt32 count = m_listeners.Count(); + + for(PRInt32 i = 0; i < count; i++) + { + nsCOMPtr listener = m_listeners[i]; + NS_ASSERTION(listener, "listener is null"); + if (!listener) + return NS_ERROR_FAILURE; + listener->ItemAdded(aItem); + } + + return NS_OK; +} + +/* void notifyItemDeleted (in nsISupports aItem); */ +NS_IMETHODIMP nsMsgFolderNotificationService::NotifyItemDeleted(nsISupports *aItem) +{ + PRInt32 count = m_listeners.Count(); + + for(PRInt32 i = 0; i < count; i++) + { + nsCOMPtr listener = m_listeners[i]; + NS_ASSERTION(listener, "listener is null"); + if (!listener) + return NS_ERROR_FAILURE; + listener->ItemDeleted(aItem); + } + + return NS_OK; +} + +/* void notifyItemMoveCopyCompleted (in boolean aMove, in nsISupportsArray aSrcItems, in nsIMsgFolder aDestFolder); */ +NS_IMETHODIMP nsMsgFolderNotificationService::NotifyItemMoveCopyCompleted(PRBool aMove, nsISupportsArray *aSrcItems, nsIMsgFolder *aDestFolder) +{ + PRInt32 count = m_listeners.Count(); + + for(PRInt32 i = 0; i < count; i++) + { + nsCOMPtr listener = m_listeners[i]; + NS_ASSERTION(listener, "listener is null"); + if (!listener) + return NS_ERROR_FAILURE; + listener->ItemMoveCopyCompleted(aMove, aSrcItems, aDestFolder); + } + + return NS_OK; +} + +/* void notifyFolderRenamed (in nsIMsgFolder aOrigFolder, in nsIMsgFolder aNewFolder); */ +NS_IMETHODIMP nsMsgFolderNotificationService::NotifyFolderRenamed(nsIMsgFolder *aOrigFolder, nsIMsgFolder *aNewFolder) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void notifyItemEvent (in nsISupports aItem, in string aEvent, in nsISupports aData); */ +NS_IMETHODIMP nsMsgFolderNotificationService::NotifyItemEvent(nsISupports *aItem, const nsACString &aEvent, nsISupports *aData) +{ + PRInt32 count = m_listeners.Count(); + + for(PRInt32 i = 0; i < count; i++) + { + nsCOMPtr listener = m_listeners[i]; + NS_ASSERTION(listener, "listener is null"); + if (!listener) + return NS_ERROR_FAILURE; + listener->ItemEvent(aItem, aEvent, aData); + } + + return NS_OK; +} diff --git a/mozilla/mailnews/base/src/nsMsgFolderNotificationService.h b/mozilla/mailnews/base/src/nsMsgFolderNotificationService.h new file mode 100644 index 00000000000..b49d74772b5 --- /dev/null +++ b/mozilla/mailnews/base/src/nsMsgFolderNotificationService.h @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2006 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * David Bienvenu + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nsMsgFolderNotificationService_h__ +#define nsMsgFolderNotificationService_h__ + +#include "nsIMsgFolderNotificationService.h" +#include "nsIMsgFolderListener.h" +#include "nsCOMArray.h" + +class nsMsgFolderNotificationService : public nsIMsgFolderNotificationService +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIMSGFOLDERNOTIFICATIONSERVICE + + nsMsgFolderNotificationService(); + +private: + ~nsMsgFolderNotificationService(); + +protected: + nsCOMArray m_listeners; +}; + +#endif diff --git a/mozilla/mailnews/base/util/nsMsgDBFolder.cpp b/mozilla/mailnews/base/util/nsMsgDBFolder.cpp index 9cdb45752c1..9081c235cca 100644 --- a/mozilla/mailnews/base/util/nsMsgDBFolder.cpp +++ b/mozilla/mailnews/base/util/nsMsgDBFolder.cpp @@ -88,6 +88,7 @@ #include "nsIMIMEHeaderParam.h" #include "plbase64.h" #include +#include "nsIMsgFolderNotificationService.h" #define oneHour 3600000000U #include "nsMsgUtils.h" @@ -3130,7 +3131,15 @@ NS_IMETHODIMP nsMsgDBFolder::RecursiveDelete(PRBool deleteStorage, nsIMsgWindow // now delete the disk storage for _this_ if (deleteStorage && (status == NS_OK)) - status = Delete(); + { + status = Delete(); + nsCOMPtr supports; + QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(supports)); + nsCOMPtr notifier = do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID); + if (notifier) + notifier->NotifyItemDeleted(supports); + + } return status; } diff --git a/mozilla/mailnews/imap/src/nsImapMailFolder.cpp b/mozilla/mailnews/imap/src/nsImapMailFolder.cpp index 194c72b69b9..3083d8269fd 100644 --- a/mozilla/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mozilla/mailnews/imap/src/nsImapMailFolder.cpp @@ -115,7 +115,7 @@ #include "nsICacheEntryDescriptor.h" #include "nsDirectoryServiceDefs.h" #include "nsIMsgIdentity.h" - +#include "nsIMsgFolderNotificationService.h" static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); @@ -1536,6 +1536,7 @@ NS_IMETHODIMP nsImapMailFolder::Delete () if (NS_SUCCEEDED(mPath->GetFileSpec(&fileSpec)) && fileSpec.Exists()) fileSpec.Delete(PR_FALSE); } + // should notify nsIMsgFolderListeners about the folder getting deleted... return rv; } @@ -3073,7 +3074,13 @@ nsresult nsImapMailFolder::NormalEndHeaderParseStream(nsIImapProtocol *aProtocol } // here we need to tweak flags from uid state.. if (mDatabase && (!m_msgMovedByFilter || ShowDeletedMessages())) + { mDatabase->AddNewHdrToDB(newMsgHdr, PR_TRUE); + nsCOMPtr notifier = do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID); + if (notifier) + notifier->NotifyItemAdded(newMsgHdr); + + } m_msgParser->Clear(); // clear out parser, because it holds onto a msg hdr. m_msgParser->SetMailDB(nsnull); // tell it to let go of the db too. // I don't think we want to do this - it does bad things like set the size incorrectly. diff --git a/mozilla/mailnews/local/src/nsLocalMailFolder.cpp b/mozilla/mailnews/local/src/nsLocalMailFolder.cpp index a948881c677..46e42c94d8f 100644 --- a/mozilla/mailnews/local/src/nsLocalMailFolder.cpp +++ b/mozilla/mailnews/local/src/nsLocalMailFolder.cpp @@ -109,7 +109,7 @@ #include "nsAutoPtr.h" #include "nsIRssIncomingServer.h" #include "nsNetUtil.h" - +#include "nsIMsgFolderNotificationService.h" static NS_DEFINE_CID(kMailboxServiceCID, NS_MAILBOXSERVICE_CID); static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID); @@ -1514,7 +1514,12 @@ nsMsgLocalMailFolder::DeleteMessages(nsISupportsArray *messages, // shift delete case - (delete to trash is handled in EndMove) // this is also the case when applying retention settings. if (deleteStorage && !isMove) + { MarkMsgsOnPop3Server(messages, POP3_DELETE); + nsCOMPtr notifier = do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID); + if (notifier) + notifier->NotifyItemDeleted(messages); + } PRBool isTrashFolder = mFlags & MSG_FOLDER_FLAG_TRASH; if (!deleteStorage && !isTrashFolder) @@ -2120,7 +2125,24 @@ nsMsgLocalMailFolder::CopyFolderLocal(nsIMsgFolder *srcFolder, } } } - + + nsCOMPtr notifier = do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID); + if (notifier) + { + PRBool hasListeners; + notifier->GetHasListeners(&hasListeners); + if (hasListeners) + { + nsCOMPtr supportsArray = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID); + if (supportsArray) + { + + supportsArray->AppendElement(srcFolder); + notifier->NotifyItemMoveCopyCompleted(isMoveFolder, supportsArray, this); + } + } + } + if (isMoveFolder && NS_SUCCEEDED(copyStatus)) { //notifying the "folder" that was dragged and dropped has been created. @@ -2650,6 +2672,22 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndCopy(PRBool copySucceeded) else { // both CopyMessages() & CopyFileMessage() go here if they have // done copying operation; notify completion to copy service + + // notify the global msg folder listeners + if (multipleCopiesFinished) + { + // we need to send this notification before we delete the source messages, + // because deleting the source messages clears out the src msg db hdr. + nsCOMPtr notifier = do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID); + if (notifier) + { + PRBool hasListeners; + notifier->GetHasListeners(&hasListeners); + if (hasListeners) + notifier->NotifyItemMoveCopyCompleted(mCopyState->m_isMove, mCopyState->m_messages, this); + } + + } if(!mCopyState->m_isMove) { if (multipleCopiesFinished) @@ -2722,7 +2760,6 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndMove(PRBool moveSucceeded) if (mCopyState && mCopyState->m_curCopyIndex >= mCopyState->m_totalMsgCount) { - //Notify that a completion finished. nsCOMPtr srcFolder = do_QueryInterface(mCopyState->m_srcSupport); if(srcFolder) diff --git a/mozilla/mailnews/local/src/nsParseMailbox.cpp b/mozilla/mailnews/local/src/nsParseMailbox.cpp index 706b16f3346..fd4d3c0511f 100644 --- a/mozilla/mailnews/local/src/nsParseMailbox.cpp +++ b/mozilla/mailnews/local/src/nsParseMailbox.cpp @@ -1718,6 +1718,7 @@ PRInt32 nsParseNewMailState::PublishMsgHeader(nsIMsgWindow *msgWindow) m_newMsgHdr->OrFlags(MSG_FLAG_NEW, &newFlags); m_mailDB->AddNewHdrToDB(m_newMsgHdr, PR_TRUE); + NotifyGlobalListeners(m_newMsgHdr); } } // if it was moved by imap filter, m_parseMsgState->m_newMsgHdr == nsnull m_newMsgHdr = nsnull; @@ -1725,6 +1726,14 @@ PRInt32 nsParseNewMailState::PublishMsgHeader(nsIMsgWindow *msgWindow) return 0; } +void nsParseNewMailState::NotifyGlobalListeners(nsIMsgDBHdr *newHdr) +{ + if (!m_notificationService) + m_notificationService = do_GetService("@mozilla.org/messenger/msgnotificationservice;1"); + if (m_notificationService) + m_notificationService->NotifyItemAdded(newHdr); +} + nsresult nsParseNewMailState::GetTrashFolder(nsIMsgFolder **pTrashFolder) { nsresult rv=NS_ERROR_UNEXPECTED; @@ -2327,6 +2336,7 @@ nsresult nsParseNewMailState::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr, } } destMailDB->AddNewHdrToDB(newHdr, PR_TRUE); + NotifyGlobalListeners(newHdr); m_msgToForwardOrReply = newHdr; } } diff --git a/mozilla/mailnews/local/src/nsParseMailbox.h b/mozilla/mailnews/local/src/nsParseMailbox.h index 7b45e0bf700..064db4c945e 100644 --- a/mozilla/mailnews/local/src/nsParseMailbox.h +++ b/mozilla/mailnews/local/src/nsParseMailbox.h @@ -61,6 +61,7 @@ #include "nsIMsgFilterList.h" #include "nsIMsgFilterHitNotify.h" +#include "nsIMsgFolderNotificationService.h" class nsFileSpec; class nsByteArray; @@ -260,6 +261,7 @@ public: virtual void ApplyFilters(PRBool *pMoved, nsIMsgWindow *msgWindow, PRUint32 msgOffset); nsresult ApplyForwardAndReplyFilter(nsIMsgWindow *msgWindow); + void NotifyGlobalListeners(nsIMsgDBHdr *newHdr); protected: virtual nsresult GetTrashFolder(nsIMsgFolder **pTrashFolder); @@ -277,6 +279,7 @@ protected: nsCOMPtr m_msgWindow; nsCOMPtr m_downloadFolder; nsCOMArray m_filterTargetFolders; + nsCOMPtr m_notificationService; nsImapMoveCoalescer *m_moveCoalescer; // strictly owned by nsParseNewMailState; diff --git a/mozilla/mailnews/local/src/nsPop3Sink.cpp b/mozilla/mailnews/local/src/nsPop3Sink.cpp index 8ffb0e7da1b..43c601f1e0e 100644 --- a/mozilla/mailnews/local/src/nsPop3Sink.cpp +++ b/mozilla/mailnews/local/src/nsPop3Sink.cpp @@ -857,6 +857,7 @@ nsPop3Sink::IncorporateComplete(nsIMsgWindow *aMsgWindow, PRInt32 aSize) } } m_newMailParser->m_mailDB->AddNewHdrToDB(hdr, PR_TRUE); + m_newMailParser->NotifyGlobalListeners(hdr); } } else