fix move of local messages to imap delete source local message 131595 r=sspitzer, sr=mscott, a=asa

This commit is contained in:
bienvenu%netscape.com 2002-03-23 23:01:50 +00:00
Родитель 2407cfe7f8
Коммит e63eb965e4
4 изменённых файлов: 42 добавлений и 30 удалений

Просмотреть файл

@ -91,12 +91,12 @@ interface nsIImapMailFolderSink : nsISupports {
void NotifySearchHit(in nsIMsgMailNewsUrl aUrl, in string hitLine); void NotifySearchHit(in nsIMsgMailNewsUrl aUrl, in string hitLine);
void copyNextStreamMessage(in boolean copySucceeded); void copyNextStreamMessage(in boolean copySucceeded, in nsISupports copyState);
// these two hokey methods are needed so we can try to make sure the imap url is released // these two hokey methods are needed so we can try to make sure the imap objects are released
// on the UI thread. This in turn ensures that the objects the imap url holds on to // on the UI thread. This in turn ensures that the objects the imap object holds on to
// are only released / destroyed from the UI thread. // are only released / destroyed from the UI thread. This is used for urls and copy state objects now.
void prepareToReleaseUrl(in nsIMsgMailNewsUrl aUrl); void prepareToReleaseObject(in nsISupports aISupports);
void releaseUrl(); void releaseObject();
void closeMockChannel(in nsIImapMockChannel aChannel); void closeMockChannel(in nsIImapMockChannel aChannel);
void setUrlState(in nsIImapProtocol aProtocol, in nsIMsgMailNewsUrl aUrl, in boolean isRunning, in nsresult status); void setUrlState(in nsIImapProtocol aProtocol, in nsIMsgMailNewsUrl aUrl, in boolean isRunning, in nsresult status);
void releaseUrlCacheEntry(in nsIMsgMailNewsUrl aUrl); void releaseUrlCacheEntry(in nsIMsgMailNewsUrl aUrl);

Просмотреть файл

@ -3751,16 +3751,17 @@ nsImapMailFolder::OnlineCopyCompleted(nsIImapProtocol *aProtocol, ImapOnlineCopy
} }
NS_IMETHODIMP NS_IMETHODIMP
nsImapMailFolder::PrepareToReleaseUrl(nsIMsgMailNewsUrl * aUrl) nsImapMailFolder::PrepareToReleaseObject(nsISupports * aSupports)
{ {
mUrlToRelease = aUrl; NS_ASSERTION(!mSupportsToRelease, "can't prepare to release w/o releasing prev object");
mSupportsToRelease = aSupports;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsImapMailFolder::ReleaseUrl() nsImapMailFolder::ReleaseObject()
{ {
mUrlToRelease = nsnull; mSupportsToRelease = nsnull;
return NS_OK; return NS_OK;
} }
@ -5382,38 +5383,44 @@ nsImapMailFolder::ProcessTunnel(nsIImapProtocol* aProtocol,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsImapMailFolder::CopyNextStreamMessage(PRBool copySucceeded) nsImapMailFolder::CopyNextStreamMessage(PRBool copySucceeded, nsISupports *copyState)
{ {
//if copy has failed it could be either user interrupted it or for some other reason //if copy has failed it could be either user interrupted it or for some other reason
//don't do any subsequent copies or delete src messages if it is move //don't do any subsequent copies or delete src messages if it is move
if (!copySucceeded || !m_copyState)
if (!copySucceeded)
return NS_OK; return NS_OK;
nsresult rv; nsresult rv;
if (!m_copyState->m_streamCopy) nsCOMPtr<nsImapMailCopyState> mailCopyState = do_QueryInterface(copyState,
&rv);
if (NS_FAILED(rv)) return rv;
if (!mailCopyState->m_streamCopy)
return NS_OK; return NS_OK;
if (m_copyState->m_curIndex < m_copyState->m_totalCount)
if (mailCopyState->m_curIndex < mailCopyState->m_totalCount)
{ {
nsCOMPtr<nsISupports> aSupport = nsCOMPtr<nsISupports> aSupport =
getter_AddRefs(m_copyState->m_messages->ElementAt getter_AddRefs(mailCopyState->m_messages->ElementAt
(m_copyState->m_curIndex)); (mailCopyState->m_curIndex));
m_copyState->m_message = do_QueryInterface(aSupport, mailCopyState->m_message = do_QueryInterface(aSupport,
&rv); &rv);
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
rv = CopyStreamMessage(m_copyState->m_message, rv = CopyStreamMessage(mailCopyState->m_message,
this, m_copyState->m_msgWindow, m_copyState->m_isMove); this, mailCopyState->m_msgWindow, mailCopyState->m_isMove);
} }
} }
else if (m_copyState->m_isMove) else if (mailCopyState->m_isMove)
{ {
nsCOMPtr<nsIMsgFolder> srcFolder = nsCOMPtr<nsIMsgFolder> srcFolder =
do_QueryInterface(m_copyState->m_srcSupport, &rv); do_QueryInterface(mailCopyState->m_srcSupport, &rv);
if (NS_SUCCEEDED(rv) && srcFolder) if (NS_SUCCEEDED(rv) && srcFolder)
{ {
srcFolder->DeleteMessages(m_copyState->m_messages, nsnull, srcFolder->DeleteMessages(mailCopyState->m_messages, nsnull,
PR_TRUE, PR_TRUE, nsnull, PR_FALSE); PR_TRUE, PR_TRUE, nsnull, PR_FALSE);
// we want to send this notification after the source messages have // we want to send this notification after the source messages have
// been deleted. // been deleted.

Просмотреть файл

@ -468,7 +468,7 @@ protected:
nsMsgIMAPFolderACL *m_folderACL; nsMsgIMAPFolderACL *m_folderACL;
nsCOMPtr<nsIMsgMailNewsUrl> mUrlToRelease; nsCOMPtr<nsISupports> mSupportsToRelease;
// offline imap support // offline imap support
PRBool m_downloadMessageForOfflineUse; PRBool m_downloadMessageForOfflineUse;

Просмотреть файл

@ -715,11 +715,13 @@ void nsImapProtocol::ReleaseUrlState()
// for real. // for real.
if (m_imapMailFolderSink) if (m_imapMailFolderSink)
{ {
m_imapMailFolderSink->PrepareToReleaseUrl(mailnewsurl); nsCOMPtr <nsISupports> supports = do_QueryInterface(mailnewsurl);
m_imapMailFolderSink->PrepareToReleaseObject(supports);
supports = nsnull;
mailnewsurl = nsnull; mailnewsurl = nsnull;
// at this point in time, we MUST have released all of our references to // at this point in time, we MUST have released all of our references to
// the url from the imap protocol. otherwise this whole exercise is moot. // the url from the imap protocol. otherwise this whole exercise is moot.
m_imapMailFolderSink->ReleaseUrl(); m_imapMailFolderSink->ReleaseObject();
} }
} }
@ -1211,10 +1213,9 @@ PRBool nsImapProtocol::ProcessCurrentURL()
m_lastActiveTime = PR_Now(); // ** jt -- is this the best place for time stamp m_lastActiveTime = PR_Now(); // ** jt -- is this the best place for time stamp
SetFlag(IMAP_CLEAN_UP_URL_STATE); SetFlag(IMAP_CLEAN_UP_URL_STATE);
#ifdef DEBUG_bienvenu1 nsCOMPtr <nsISupports> copyState;
mailnewsurl->GetSpec(getter_Copies(urlSpec)); if (m_runningUrl)
printf("end processing url %s\n", (const char *) urlSpec); m_runningUrl->GetCopyState(getter_AddRefs(copyState));
#endif
// this is so hokey...we MUST clear any local references to the url // this is so hokey...we MUST clear any local references to the url
// BEFORE calling ReleaseUrlState // BEFORE calling ReleaseUrlState
mailnewsurl = nsnull; mailnewsurl = nsnull;
@ -1229,7 +1230,10 @@ PRBool nsImapProtocol::ProcessCurrentURL()
if (GetConnectionStatus() >= 0 && imapMailFolderSink) if (GetConnectionStatus() >= 0 && imapMailFolderSink)
{ {
imapMailFolderSink->CopyNextStreamMessage(GetServerStateParser().LastCommandSuccessful()); imapMailFolderSink->PrepareToReleaseObject(copyState);
imapMailFolderSink->CopyNextStreamMessage(GetServerStateParser().LastCommandSuccessful(), copyState);
copyState = nsnull;
imapMailFolderSink->ReleaseObject();
imapMailFolderSink = nsnull; imapMailFolderSink = nsnull;
} }
@ -4775,6 +4779,7 @@ void nsImapProtocol::UploadMessageFromFile (nsIFileSpec* fileSpec,
rv = fileInputStream->Read(dataBuffer, COPY_BUFFER_SIZE, &readCount); rv = fileInputStream->Read(dataBuffer, COPY_BUFFER_SIZE, &readCount);
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
NS_ASSERTION(readCount <= (PRUint32) totalSize, "got more bytes than there should be");
dataBuffer[readCount] = 0; dataBuffer[readCount] = 0;
rv = SendData(dataBuffer); rv = SendData(dataBuffer);
totalSize -= readCount; totalSize -= readCount;