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
This commit is contained in:
parent
bc8b21f33b
commit
04ededecb0
@ -79,6 +79,8 @@ XPIDLSRCS = \
|
||||
nsIMsgPurgeService.idl \
|
||||
nsIMsgCopyService.idl \
|
||||
nsIMsgCopyServiceListener.idl \
|
||||
nsIMsgFolderListener.idl \
|
||||
nsIMsgFolderNotificationService.idl \
|
||||
nsIMsgStatusFeedback.idl \
|
||||
nsIMsgMailNewsUrl.idl \
|
||||
nsIMsgWindow.idl \
|
||||
|
||||
65
mozilla/mailnews/base/public/nsIMsgFolderListener.idl
Normal file
65
mozilla/mailnews/base/public/nsIMsgFolderListener.idl
Normal file
@ -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 <bienvenu@mozilla.com>
|
||||
*
|
||||
* 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);
|
||||
};
|
||||
|
||||
@ -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 <bienvenu@mozilla.com>
|
||||
*
|
||||
* 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);
|
||||
};
|
||||
|
||||
@ -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
|
||||
//
|
||||
|
||||
@ -129,6 +129,7 @@ CPPSRCS = \
|
||||
nsCidProtocolHandler.cpp \
|
||||
nsMsgContentPolicy.cpp \
|
||||
nsMsgTagService.cpp\
|
||||
nsMsgFolderNotificationService.cpp\
|
||||
$(NULL)
|
||||
|
||||
# MacOSX requires the MoreFiles module
|
||||
|
||||
@ -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 <nsIMsgFolderNotificationService> notifier = do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID);
|
||||
if (notifier)
|
||||
{
|
||||
PRBool hasListeners;
|
||||
notifier->GetHasListeners(&hasListeners);
|
||||
if (hasListeners)
|
||||
{
|
||||
nsCOMPtr <nsISupportsArray> 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)
|
||||
|
||||
155
mozilla/mailnews/base/src/nsMsgFolderNotificationService.cpp
Normal file
155
mozilla/mailnews/base/src/nsMsgFolderNotificationService.cpp
Normal file
@ -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 <bienvenu@mozilla.org>
|
||||
*
|
||||
* 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<nsIMsgFolderListener> 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<nsIMsgFolderListener> 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<nsIMsgFolderListener> 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<nsIMsgFolderListener> listener = m_listeners[i];
|
||||
NS_ASSERTION(listener, "listener is null");
|
||||
if (!listener)
|
||||
return NS_ERROR_FAILURE;
|
||||
listener->ItemEvent(aItem, aEvent, aData);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
61
mozilla/mailnews/base/src/nsMsgFolderNotificationService.h
Normal file
61
mozilla/mailnews/base/src/nsMsgFolderNotificationService.h
Normal file
@ -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 <bienvenu@mozilla.org>
|
||||
*
|
||||
* 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<nsIMsgFolderListener> m_listeners;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -88,6 +88,7 @@
|
||||
#include "nsIMIMEHeaderParam.h"
|
||||
#include "plbase64.h"
|
||||
#include <time.h>
|
||||
#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 <nsISupports> supports;
|
||||
QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(supports));
|
||||
nsCOMPtr <nsIMsgFolderNotificationService> notifier = do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID);
|
||||
if (notifier)
|
||||
notifier->NotifyItemDeleted(supports);
|
||||
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@ -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 <nsIMsgFolderNotificationService> 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.
|
||||
|
||||
@ -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 <nsIMsgFolderNotificationService> 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 <nsIMsgFolderNotificationService> notifier = do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID);
|
||||
if (notifier)
|
||||
{
|
||||
PRBool hasListeners;
|
||||
notifier->GetHasListeners(&hasListeners);
|
||||
if (hasListeners)
|
||||
{
|
||||
nsCOMPtr <nsISupportsArray> 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 <nsIMsgFolderNotificationService> 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<nsIMsgFolder> srcFolder = do_QueryInterface(mCopyState->m_srcSupport);
|
||||
if(srcFolder)
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 <nsIMsgWindow> m_msgWindow;
|
||||
nsCOMPtr <nsIMsgFolder> m_downloadFolder;
|
||||
nsCOMArray <nsIMsgFolder> m_filterTargetFolders;
|
||||
nsCOMPtr <nsIMsgFolderNotificationService> m_notificationService;
|
||||
|
||||
nsImapMoveCoalescer *m_moveCoalescer; // strictly owned by nsParseNewMailState;
|
||||
|
||||
|
||||
@ -857,6 +857,7 @@ nsPop3Sink::IncorporateComplete(nsIMsgWindow *aMsgWindow, PRInt32 aSize)
|
||||
}
|
||||
}
|
||||
m_newMailParser->m_mailDB->AddNewHdrToDB(hdr, PR_TRUE);
|
||||
m_newMailParser->NotifyGlobalListeners(hdr);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user