mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
fix updating of folders after imap/moves r=mscott bug 12491
This commit is contained in:
parent
10e0f64b8b
commit
9ba6e2321b
@ -2240,7 +2240,7 @@ nsImapMailFolder::NormalEndMsgWriteStream(nsMsgKey uidOfMessage)
|
||||
nsCOMPtr<nsIMsgDBHdr> msgHdr;
|
||||
|
||||
m_curMsgUid = uidOfMessage;
|
||||
res = GetMessageHeader(getter_AddRefs(msgHdr));
|
||||
res = GetMessageHeader(m_curMsgUid, getter_AddRefs(msgHdr));
|
||||
if (NS_SUCCEEDED(res))
|
||||
msgHdr->MarkRead(PR_TRUE);
|
||||
|
||||
@ -2253,7 +2253,7 @@ nsImapMailFolder::AbortMsgWriteStream()
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult nsImapMailFolder::GetMessageHeader(nsIMsgDBHdr ** aMsgHdr)
|
||||
nsresult nsImapMailFolder::GetMessageHeader(nsMsgKey key, nsIMsgDBHdr ** aMsgHdr)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aMsgHdr)
|
||||
@ -2264,7 +2264,7 @@ nsresult nsImapMailFolder::GetMessageHeader(nsIMsgDBHdr ** aMsgHdr)
|
||||
// recent header we downloaded, and most recent message we've
|
||||
// downloaded. We may want to break this up.
|
||||
if (NS_SUCCEEDED(rv) && mDatabase) // did we get a db back?
|
||||
rv = mDatabase->GetMsgHdrForKey(m_curMsgUid, aMsgHdr);
|
||||
rv = mDatabase->GetMsgHdrForKey(key, aMsgHdr);
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
@ -2508,6 +2508,7 @@ nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
|
||||
NS_PRECONDITION(aUrl, "just a sanity check since this is a test program");
|
||||
nsresult rv = NS_OK;
|
||||
m_urlRunning = PR_FALSE;
|
||||
NS_WITH_SERVICE(nsIMsgMailSession, session, kMsgMailSessionCID, &rv);
|
||||
if (aUrl)
|
||||
{
|
||||
nsCOMPtr<nsIImapUrl> imapUrl = do_QueryInterface(aUrl);
|
||||
@ -2550,7 +2551,15 @@ nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
|
||||
}
|
||||
ClearCopyState(aExitCode);
|
||||
}
|
||||
UpdateFolder();
|
||||
if (session)
|
||||
{
|
||||
PRBool folderOpen = PR_FALSE;
|
||||
session->IsFolderOpenInWindow(this, &folderOpen);
|
||||
if (folderOpen)
|
||||
UpdateFolder();
|
||||
else
|
||||
UpdatePendingCounts(PR_TRUE, PR_FALSE);
|
||||
}
|
||||
break;
|
||||
case nsIImapUrl::nsImapAppendMsgFromFile:
|
||||
case nsIImapUrl::nsImapAppendDraftFromFile:
|
||||
@ -2580,6 +2589,47 @@ nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
|
||||
return rv;
|
||||
}
|
||||
|
||||
void nsImapMailFolder::UpdatePendingCounts(PRBool countUnread, PRBool missingAreRead)
|
||||
{
|
||||
nsresult rv;
|
||||
if (m_copyState)
|
||||
{
|
||||
ChangeNumPendingTotalMessages(m_copyState->m_totalCount);
|
||||
|
||||
if (countUnread)
|
||||
{
|
||||
// count the moves that were unread
|
||||
int numUnread = 0;
|
||||
nsCOMPtr <nsIMsgFolder> srcFolder = do_QueryInterface(m_copyState->m_srcSupport);
|
||||
for (int keyIndex=0; keyIndex < m_copyState->m_totalCount; keyIndex++)
|
||||
{
|
||||
nsCOMPtr<nsIMessage> message;
|
||||
|
||||
nsCOMPtr<nsISupports> aSupport =
|
||||
getter_AddRefs(m_copyState->m_messages->ElementAt(keyIndex));
|
||||
message = do_QueryInterface(aSupport, &rv);
|
||||
// if the key is not there, then assume what the caller tells us to.
|
||||
PRBool isRead = missingAreRead;
|
||||
PRUint32 flags;
|
||||
if (message )
|
||||
{
|
||||
message->GetFlags(&flags);
|
||||
isRead = flags & MSG_FLAG_READ;
|
||||
}
|
||||
|
||||
if (!isRead)
|
||||
numUnread++;
|
||||
}
|
||||
|
||||
if (numUnread)
|
||||
ChangeNumPendingUnread(numUnread);
|
||||
}
|
||||
SummaryChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// nsIImapExtensionSink methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -253,6 +253,8 @@ public:
|
||||
// overriding nsMsgDBFolder::GetMsgDatabase()
|
||||
NS_IMETHOD GetMsgDatabase(nsIMsgDatabase** aMsgDatabase);
|
||||
|
||||
nsresult GetMessageHeader(nsMsgKey key, nsIMsgDBHdr ** aMsgHdr);
|
||||
|
||||
nsresult MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
|
||||
nsIMsgDatabase *sourceDB,
|
||||
char *destFolder,
|
||||
@ -272,6 +274,7 @@ protected:
|
||||
|
||||
nsresult SyncFlags(nsImapFlagAndUidState *flagState);
|
||||
|
||||
void UpdatePendingCounts(PRBool countUnread, PRBool missingAreRead);
|
||||
void SetIMAPDeletedFlag(nsIMsgDatabase *mailDB, const nsMsgKeyArray &msgids, PRBool markDeleted);
|
||||
virtual PRBool ShowDeletedMessages();
|
||||
virtual PRBool DeleteIsMoveToTrash();
|
||||
@ -308,8 +311,6 @@ protected:
|
||||
nsresult BuildIdsAndKeyArray(nsISupportsArray* messages,
|
||||
nsCString& msgIds, nsMsgKeyArray& keyArray);
|
||||
|
||||
nsresult GetMessageHeader(nsIMsgDBHdr ** aMsgHdr);
|
||||
|
||||
nsNativeFileSpec *m_pathName;
|
||||
PRBool m_initialized;
|
||||
PRBool m_haveDiscoveredAllFolders;
|
||||
|
@ -105,18 +105,28 @@ nsresult nsImapMoveCoalescer::PlaybackMoves(nsIEventQueue *eventQueue)
|
||||
nsCOMPtr <nsISupports> sourceSupports = do_QueryInterface((nsIMsgImapMailFolder *) m_sourceFolder, &rv);
|
||||
nsCOMPtr <nsIUrlListener> urlListener(do_QueryInterface(sourceSupports));
|
||||
|
||||
nsCOMPtr<nsISupportsArray> messages;
|
||||
NS_NewISupportsArray(getter_AddRefs(messages));
|
||||
// rv = destFolder->CopyMessages(m_sourceFolder,
|
||||
// nsISupportsArray* messages,
|
||||
// PR_TRUE, nsnull,
|
||||
// nsIMsgCopyServiceListener* listener)
|
||||
|
||||
|
||||
rv = imapService->OnlineMessageCopy(eventQueue,
|
||||
m_sourceFolder, messageIds.GetBuffer(),
|
||||
destFolder, PR_TRUE, PR_TRUE,
|
||||
urlListener, nsnull, nsnull);
|
||||
nsCOMPtr<nsISupportsArray> messages;
|
||||
NS_NewISupportsArray(getter_AddRefs(messages));
|
||||
for (PRUint32 keyIndex = 0; i < keysToAdd->GetSize(); i++)
|
||||
{
|
||||
nsCOMPtr<nsIMessage> message;
|
||||
nsCOMPtr<nsIMsgDBHdr> mailHdr = nsnull;
|
||||
rv = m_sourceFolder->GetMessageHeader(keysToAdd->ElementAt(keyIndex), getter_AddRefs(mailHdr));
|
||||
if (NS_SUCCEEDED(rv) && mailHdr)
|
||||
{
|
||||
nsCOMPtr<nsISupports> iSupports;
|
||||
m_sourceFolder->CreateMessageFromMsgDBHdr(mailHdr, getter_AddRefs(message)) ;
|
||||
iSupports = do_QueryInterface(message);
|
||||
messages->AppendElement(iSupports);
|
||||
}
|
||||
}
|
||||
rv = destFolder->CopyMessages(m_sourceFolder,
|
||||
messages, PR_TRUE, nsnull,
|
||||
/*nsIMsgCopyServiceListener* listener*/ nsnull);
|
||||
// rv = imapService->OnlineMessageCopy(eventQueue,
|
||||
// m_sourceFolder, messageIds.GetBuffer(),
|
||||
// destFolder, PR_TRUE, PR_TRUE,
|
||||
// urlListener, nsnull, nsnull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user