зеркало из https://github.com/mozilla/gecko-dev.git
add notifications for filter hits, fix totals for parent folders
This commit is contained in:
Родитель
c7f4c61668
Коммит
e8c3c353cd
|
@ -361,24 +361,7 @@ NS_IMETHODIMP nsImapMailFolder::GetSubFolders(nsIEnumerator* *result)
|
||||||
SetFlag(newFlags);
|
SetFlag(newFlags);
|
||||||
rv = CreateSubFolders(path);
|
rv = CreateSubFolders(path);
|
||||||
}
|
}
|
||||||
else
|
UpdateSummaryTotals(PR_FALSE);
|
||||||
{
|
|
||||||
UpdateSummaryTotals(PR_FALSE);
|
|
||||||
// Look for a directory for this mail folder, and recurse into it.
|
|
||||||
// e.g. if the folder is "inbox", look for "inbox.sbd".
|
|
||||||
#if 0
|
|
||||||
char *folderName = path->GetLeafName();
|
|
||||||
char *newLeafName = (char*)malloc(PL_strlen(folderName) +
|
|
||||||
PL_strlen(kDirExt) + 2);
|
|
||||||
PL_strcpy(newLeafName, folderName);
|
|
||||||
PL_strcat(newLeafName, kDirExt);
|
|
||||||
path->SetLeafName(newLeafName);
|
|
||||||
if(folderName)
|
|
||||||
nsCRT::free(folderName);
|
|
||||||
if(newLeafName)
|
|
||||||
nsCRT::free(newLeafName);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
m_initialized = PR_TRUE; // XXX do this on failure too?
|
m_initialized = PR_TRUE; // XXX do this on failure too?
|
||||||
|
@ -947,7 +930,7 @@ nsImapMailFolder::BuildIdsAndKeyArray(nsISupportsArray* messages,
|
||||||
return AllocateUidStringFromKeyArray(keyArray, msgIds);
|
return AllocateUidStringFromKeyArray(keyArray, msgIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
/* static */ nsresult
|
||||||
nsImapMailFolder::AllocateUidStringFromKeyArray(nsMsgKeyArray &keyArray, nsCString &msgIds)
|
nsImapMailFolder::AllocateUidStringFromKeyArray(nsMsgKeyArray &keyArray, nsCString &msgIds)
|
||||||
{
|
{
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
@ -1435,7 +1418,6 @@ NS_IMETHODIMP nsImapMailFolder::SetupHeaderParseStream(
|
||||||
if (!mDatabase)
|
if (!mDatabase)
|
||||||
GetDatabase();
|
GetDatabase();
|
||||||
|
|
||||||
#ifdef DOING_FILTERS
|
|
||||||
if (mFlags & MSG_FOLDER_FLAG_INBOX && !m_filterList)
|
if (mFlags & MSG_FOLDER_FLAG_INBOX && !m_filterList)
|
||||||
{
|
{
|
||||||
NS_WITH_SERVICE(nsIMsgFilterService, filterService, kMsgFilterServiceCID, &rv);
|
NS_WITH_SERVICE(nsIMsgFilterService, filterService, kMsgFilterServiceCID, &rv);
|
||||||
|
@ -1466,7 +1448,6 @@ NS_IMETHODIMP nsImapMailFolder::SetupHeaderParseStream(
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
m_nextMessageByteLength = aStreamInfo->size;
|
m_nextMessageByteLength = aStreamInfo->size;
|
||||||
if (!m_msgParser)
|
if (!m_msgParser)
|
||||||
{
|
{
|
||||||
|
@ -1535,6 +1516,7 @@ NS_IMETHODIMP nsImapMailFolder::NormalEndHeaderParseStream(nsIImapProtocol*
|
||||||
|
|
||||||
newMsgHdr->SetMessageKey(m_curMsgUid);
|
newMsgHdr->SetMessageKey(m_curMsgUid);
|
||||||
TweakHeaderFlags(aProtocol, newMsgHdr);
|
TweakHeaderFlags(aProtocol, newMsgHdr);
|
||||||
|
m_msgMovedByFilter = PR_FALSE;
|
||||||
// If this is the inbox, try to apply filters.
|
// If this is the inbox, try to apply filters.
|
||||||
if (mFlags & MSG_FOLDER_FLAG_INBOX)
|
if (mFlags & MSG_FOLDER_FLAG_INBOX)
|
||||||
{
|
{
|
||||||
|
@ -1542,15 +1524,14 @@ NS_IMETHODIMP nsImapMailFolder::NormalEndHeaderParseStream(nsIImapProtocol*
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv) && headers)
|
if (NS_SUCCEEDED(rv) && headers)
|
||||||
{
|
{
|
||||||
#ifdef DOING_FILTERS
|
|
||||||
if (m_filterList)
|
if (m_filterList)
|
||||||
m_filterList->ApplyFiltersToHdr(nsMsgFilterType::InboxRule, newMsgHdr, this, mDatabase,
|
m_filterList->ApplyFiltersToHdr(nsMsgFilterType::InboxRule, newMsgHdr, this, mDatabase,
|
||||||
headers, headersSize, this);
|
headers, headersSize, this);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// here we need to tweak flags from uid state..
|
// here we need to tweak flags from uid state..
|
||||||
mDatabase->AddNewHdrToDB(newMsgHdr, PR_TRUE);
|
if (!m_msgMovedByFilter)
|
||||||
|
mDatabase->AddNewHdrToDB(newMsgHdr, PR_TRUE);
|
||||||
m_msgParser->FinishHeader();
|
m_msgParser->FinishHeader();
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -1704,7 +1685,6 @@ NS_IMETHODIMP nsImapMailFolder::EndCopy(PRBool copySucceeded)
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DOING_FILTERS
|
|
||||||
NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter *filter, PRBool *applyMore)
|
NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter *filter, PRBool *applyMore)
|
||||||
{
|
{
|
||||||
nsMsgRuleActionType actionType;
|
nsMsgRuleActionType actionType;
|
||||||
|
@ -2020,8 +2000,6 @@ nsresult nsImapMailFolder::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // DOING_FILTERS
|
|
||||||
|
|
||||||
// both of these algorithms assume that key arrays and flag states are sorted by increasing key.
|
// both of these algorithms assume that key arrays and flag states are sorted by increasing key.
|
||||||
void nsImapMailFolder::FindKeysToDelete(const nsMsgKeyArray &existingKeys, nsMsgKeyArray &keysToDelete, nsImapFlagAndUidState *flagState)
|
void nsImapMailFolder::FindKeysToDelete(const nsMsgKeyArray &existingKeys, nsMsgKeyArray &keysToDelete, nsImapFlagAndUidState *flagState)
|
||||||
{
|
{
|
||||||
|
|
|
@ -314,6 +314,7 @@ public:
|
||||||
char *destFolder,
|
char *destFolder,
|
||||||
nsIMsgFilter *filter);
|
nsIMsgFilter *filter);
|
||||||
nsresult StoreImapFlags(imapMessageFlagsType flags, PRBool addFlags, nsMsgKeyArray &msgKeys);
|
nsresult StoreImapFlags(imapMessageFlagsType flags, PRBool addFlags, nsMsgKeyArray &msgKeys);
|
||||||
|
static nsresult AllocateUidStringFromKeyArray(nsMsgKeyArray &keyArray, nsCString &msgIds);
|
||||||
protected:
|
protected:
|
||||||
// Helper methods
|
// Helper methods
|
||||||
void FindKeysToAdd(const nsMsgKeyArray &existingKeys, nsMsgKeyArray
|
void FindKeysToAdd(const nsMsgKeyArray &existingKeys, nsMsgKeyArray
|
||||||
|
@ -358,7 +359,6 @@ protected:
|
||||||
nsresult BuildIdsAndKeyArray(nsISupportsArray* messages,
|
nsresult BuildIdsAndKeyArray(nsISupportsArray* messages,
|
||||||
nsCString& msgIds, nsMsgKeyArray& keyArray);
|
nsCString& msgIds, nsMsgKeyArray& keyArray);
|
||||||
|
|
||||||
nsresult AllocateUidStringFromKeyArray(nsMsgKeyArray &keyArray, nsCString &msgIds);
|
|
||||||
nsresult GetMessageHeader(nsIMsgDBHdr ** aMsgHdr);
|
nsresult GetMessageHeader(nsIMsgDBHdr ** aMsgHdr);
|
||||||
|
|
||||||
nsNativeFileSpec *m_pathName;
|
nsNativeFileSpec *m_pathName;
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "nsMsgImapCID.h"
|
#include "nsMsgImapCID.h"
|
||||||
#include "nsImapMailFolder.h"
|
#include "nsImapMailFolder.h"
|
||||||
#include "nsImapMoveCoalescer.h"
|
#include "nsImapMoveCoalescer.h"
|
||||||
#include "nsMsgKeySet.h"
|
#include "nsMsgKeyArray.h"
|
||||||
#include "nsImapService.h"
|
#include "nsImapService.h"
|
||||||
|
|
||||||
static NS_DEFINE_CID(kCImapService, NS_IMAPSERVICE_CID);
|
static NS_DEFINE_CID(kCImapService, NS_IMAPSERVICE_CID);
|
||||||
|
@ -35,9 +35,9 @@ nsImapMoveCoalescer::nsImapMoveCoalescer(nsImapMailFolder *sourceFolder)
|
||||||
nsImapMoveCoalescer::~nsImapMoveCoalescer()
|
nsImapMoveCoalescer::~nsImapMoveCoalescer()
|
||||||
{
|
{
|
||||||
NS_IF_RELEASE(m_sourceFolder);
|
NS_IF_RELEASE(m_sourceFolder);
|
||||||
for (PRInt32 i = 0; i < m_sourceKeySets.Count(); i++)
|
for (PRInt32 i = 0; i < m_sourceKeyArrays.Count(); i++)
|
||||||
{
|
{
|
||||||
nsMsgKeySet *keys = (nsMsgKeySet *) m_sourceKeySets.ElementAt(i);
|
nsMsgKeyArray *keys = (nsMsgKeyArray *) m_sourceKeyArrays.ElementAt(i);
|
||||||
delete keys;
|
delete keys;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,10 +49,10 @@ nsresult nsImapMoveCoalescer::AddMove(nsIMsgFolder *folder, nsMsgKey key)
|
||||||
if (m_destFolders)
|
if (m_destFolders)
|
||||||
{
|
{
|
||||||
PRInt32 folderIndex = m_destFolders->IndexOf(folder);
|
PRInt32 folderIndex = m_destFolders->IndexOf(folder);
|
||||||
nsMsgKeySet *keysToAdd;
|
nsMsgKeyArray *keysToAdd;
|
||||||
if (folderIndex >= 0)
|
if (folderIndex >= 0)
|
||||||
{
|
{
|
||||||
keysToAdd = (nsMsgKeySet *) m_sourceKeySets.ElementAt(folderIndex);
|
keysToAdd = (nsMsgKeyArray *) m_sourceKeyArrays.ElementAt(folderIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -60,11 +60,11 @@ nsresult nsImapMoveCoalescer::AddMove(nsIMsgFolder *folder, nsMsgKey key)
|
||||||
if (supports)
|
if (supports)
|
||||||
{
|
{
|
||||||
m_destFolders->AppendElement(supports);
|
m_destFolders->AppendElement(supports);
|
||||||
keysToAdd = nsMsgKeySet::Create();
|
keysToAdd = new nsMsgKeyArray;
|
||||||
if (!keysToAdd)
|
if (!keysToAdd)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
m_sourceKeySets.AppendElement(keysToAdd);
|
m_sourceKeyArrays.AppendElement(keysToAdd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (keysToAdd)
|
if (keysToAdd)
|
||||||
|
@ -92,25 +92,22 @@ nsresult nsImapMoveCoalescer::PlaybackMoves(nsIEventQueue *eventQueue)
|
||||||
NS_WITH_SERVICE(nsIImapService, imapService, kCImapService, &rv);
|
NS_WITH_SERVICE(nsIImapService, imapService, kCImapService, &rv);
|
||||||
if (NS_SUCCEEDED(rv) && imapService)
|
if (NS_SUCCEEDED(rv) && imapService)
|
||||||
{
|
{
|
||||||
nsMsgKeySet *keysToAdd = (nsMsgKeySet *) m_sourceKeySets.ElementAt(i);
|
nsMsgKeyArray *keysToAdd = (nsMsgKeyArray *) m_sourceKeyArrays.ElementAt(i);
|
||||||
if (keysToAdd)
|
if (keysToAdd)
|
||||||
{
|
{
|
||||||
char *messageIds = keysToAdd->Output();
|
nsCString messageIds;
|
||||||
if (messageIds)
|
|
||||||
{
|
nsImapMailFolder::AllocateUidStringFromKeyArray(*keysToAdd, messageIds);
|
||||||
nsCOMPtr <nsISupports> sourceSupports = do_QueryInterface((nsIMsgImapMailFolder *) m_sourceFolder, &rv);
|
|
||||||
nsCOMPtr <nsIUrlListener> urlListener(do_QueryInterface(sourceSupports));
|
destFolder->SetNumNewMessages(keysToAdd->GetSize());
|
||||||
rv = imapService->OnlineMessageCopy(eventQueue,
|
destFolder->SetBiffState(nsMsgBiffState_NewMail);
|
||||||
m_sourceFolder, messageIds,
|
|
||||||
destFolder, PR_TRUE, PR_TRUE,
|
nsCOMPtr <nsISupports> sourceSupports = do_QueryInterface((nsIMsgImapMailFolder *) m_sourceFolder, &rv);
|
||||||
urlListener, nsnull, nsnull);
|
nsCOMPtr <nsIUrlListener> urlListener(do_QueryInterface(sourceSupports));
|
||||||
delete [] messageIds;
|
rv = imapService->OnlineMessageCopy(eventQueue,
|
||||||
}
|
m_sourceFolder, messageIds.GetBuffer(),
|
||||||
else
|
destFolder, PR_TRUE, PR_TRUE,
|
||||||
{
|
urlListener, nsnull, nsnull);
|
||||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
nsresult PlaybackMoves(nsIEventQueue *eventQueue);
|
nsresult PlaybackMoves(nsIEventQueue *eventQueue);
|
||||||
protected:
|
protected:
|
||||||
// m_sourceKeySets and m_destFolders are parallel arrays.
|
// m_sourceKeySets and m_destFolders are parallel arrays.
|
||||||
nsVoidArray m_sourceKeySets;
|
nsVoidArray m_sourceKeyArrays;
|
||||||
nsCOMPtr <nsISupportsArray> m_destFolders;
|
nsCOMPtr <nsISupportsArray> m_destFolders;
|
||||||
nsImapMailFolder *m_sourceFolder;
|
nsImapMailFolder *m_sourceFolder;
|
||||||
};
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче