58955. r=sspitzer sr=bienvenu. Copying the msg header when there is a move from pop->imap

so that in case of undo the header can be restored. Eliminating the dependency that
the imap folder is selected.
This commit is contained in:
naving%netscape.com 2001-01-08 01:58:06 +00:00
Родитель 90a5ecbdfc
Коммит 41a031987f
11 изменённых файлов: 75 добавлений и 29 удалений

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

@ -101,7 +101,7 @@ interface nsIMsgDatabase : nsIDBChangeAnnouncer {
void AddNewHdrToDB(in nsIMsgDBHdr newHdr, in boolean notify);
nsIMsgDBHdr CopyHdrFromExistingHdr(in nsMsgKey key, in nsIMsgDBHdr existingHdr);
nsIMsgDBHdr CopyHdrFromExistingHdr(in nsMsgKey key, in nsIMsgDBHdr existingHdr, in boolean addHdrToDB);
[noscript] void ListAllKeys(in nsMsgKeyArrayRef outputKeys);
@ -210,5 +210,7 @@ interface nsIMsgDatabase : nsIDBChangeAnnouncer {
readonly attribute nsMsgKey LowWaterArticleNum;
readonly attribute nsMsgKey HighWaterArticleNum;
attribute nsMsgKey NextPseudoMsgKey; //for undo-redo of move pop->imap
};

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

@ -179,6 +179,7 @@ protected:
nsresult InitMDBInfo();
nsDBFolderInfo *m_dbFolderInfo;
nsMsgKey m_nextPseudoMsgKey;
nsIMdbEnv *m_mdbEnv; // to be used in all the db calls.
nsIMdbStore *m_mdbStore;
nsIMdbTable *m_mdbAllMsgHeadersTable;

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

@ -627,6 +627,7 @@ nsMsgDatabase::nsMsgDatabase()
m_HeaderParser(nsnull),
m_headersInUse(nsnull),
m_cachedHeaders(nsnull),
m_nextPseudoMsgKey(-1),
m_bCacheHeaders(PR_FALSE)
{
@ -2583,7 +2584,7 @@ NS_IMETHODIMP nsMsgDatabase::AddNewHdrToDB(nsIMsgDBHdr *newHdr, PRBool notify)
return err;
}
NS_IMETHODIMP nsMsgDatabase::CopyHdrFromExistingHdr(nsMsgKey key, nsIMsgDBHdr *existingHdr, nsIMsgDBHdr **newHdr)
NS_IMETHODIMP nsMsgDatabase::CopyHdrFromExistingHdr(nsMsgKey key, nsIMsgDBHdr *existingHdr, PRBool addHdrToDB, nsIMsgDBHdr **newHdr)
{
nsresult err = NS_OK;
@ -2597,7 +2598,8 @@ NS_IMETHODIMP nsMsgDatabase::CopyHdrFromExistingHdr(nsMsgKey key, nsIMsgDBHdr *e
err = destRow->SetRow(GetEnv(), sourceRow);
if (NS_SUCCEEDED(err))
{
err = AddNewHdrToDB(destMsgHdr, PR_TRUE);
if(addHdrToDB)
err = AddNewHdrToDB(destMsgHdr, PR_TRUE);
if (NS_SUCCEEDED(err) && newHdr)
*newHdr = destMsgHdr;
}
@ -3336,6 +3338,21 @@ NS_IMETHODIMP nsMsgDatabase::GetLowWaterArticleNum(nsMsgKey *key)
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsMsgKey NextPseudoMsgKey */
NS_IMETHODIMP nsMsgDatabase::GetNextPseudoMsgKey(nsMsgKey *nextPseudoMsgKey)
{
NS_ENSURE_ARG_POINTER(nextPseudoMsgKey);
*nextPseudoMsgKey = m_nextPseudoMsgKey;
return NS_OK;
}
NS_IMETHODIMP nsMsgDatabase::SetNextPseudoMsgKey(nsMsgKey nextPseudoMsgKey)
{
m_nextPseudoMsgKey = nextPseudoMsgKey;
return NS_OK;
}
NS_IMETHODIMP nsMsgDatabase::HasMessagesOfType(PRUint32 viewType, PRBool *hasMessages)
{
nsresult rv;

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

@ -4077,7 +4077,12 @@ nsImapMailFolder::CopyNextStreamMessage(nsIImapProtocol* aProtocol,
{
srcFolder->DeleteMessages(mailCopyState->m_messages, nsnull,
PR_TRUE, PR_TRUE);
}
nsCOMPtr<nsIMsgLocalMailFolder> popFolder = do_QueryInterface(srcFolder);
if (popFolder) //needed if move pop->imap to notify FE
srcFolder->NotifyFolderEvent(mDeleteOrMoveMsgCompletedAtom);
}
}
return rv;
}

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

@ -42,6 +42,7 @@
#include "prmon.h"
#include "nsIEventQueue.h"
#include "nsIMsgImapMailFolder.h"
#include "nsIMsgLocalMailFolder.h"
#include "nsIImapMailFolderSink.h"
#include "nsIImapServerSink.h"
#include "nsIStreamListener.h"

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

@ -4680,8 +4680,8 @@ void nsImapProtocol::UploadMessageFromFile (nsIFileSpec* fileSpec,
nsImapAction imapAction;
m_runningUrl->GetImapAction(&imapAction);
if (GetServerStateParser().LastCommandSuccessful() &&
imapAction == nsIImapUrl::nsImapAppendDraftFromFile)
if (GetServerStateParser().LastCommandSuccessful() && (
imapAction == nsIImapUrl::nsImapAppendDraftFromFile || imapAction == nsIImapUrl::nsImapAppendMsgFromFile ))
{
if (GetServerStateParser().GetCapabilityFlag() &
kUidplusCapability)

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

@ -33,6 +33,7 @@
static NS_DEFINE_CID(kCImapService, NS_IMAPSERVICE_CID);
static NS_DEFINE_CID(kCImapHostSessionList, NS_IIMAPHOSTSESSIONLIST_CID);
nsImapMoveCopyMsgTxn::nsImapMoveCopyMsgTxn() :
m_idsAreUids(PR_FALSE), m_isMove(PR_FALSE), m_srcIsPop3(PR_FALSE)
{
@ -57,6 +58,7 @@ nsImapMoveCopyMsgTxn::Init(
nsIEventQueue* eventQueue, nsIUrlListener* urlListener)
{
nsresult rv;
NS_NewISupportsArray(getter_AddRefs(m_srcHdrs));
m_srcMsgIdString = srcMsgIdString;
m_idsAreUids = idsAreUids;
m_isMove = isMove;
@ -66,6 +68,7 @@ nsImapMoveCopyMsgTxn::Init(
if (urlListener)
m_urlListener = do_QueryInterface(urlListener, &rv);
m_srcKeyArray.CopyArray(srcKeyArray);
m_dupKeyArray.CopyArray(srcKeyArray);
if (srcKeyArray->GetSize() > 1)
{
if (isMove)
@ -116,7 +119,9 @@ nsImapMoveCopyMsgTxn::Init(
rv = m_srcFolder->GetMsgDatabase(nsnull, getter_AddRefs(srcDB));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgDBHdr> srcHdr;
nsCOMPtr<nsIMsgDBHdr> copySrcHdr;
nsMsgKey pseudoKey;
for (i=0; i<count; i++)
{
rv = srcDB->GetMsgHdrForKey(m_srcKeyArray.GetAt(i),
@ -127,6 +132,21 @@ nsImapMoveCopyMsgTxn::Init(
rv = srcHdr->GetMessageSize(&msgSize);
if (NS_SUCCEEDED(rv))
m_srcSizeArray.Add(msgSize);
if (isMove)
{
srcDB->GetNextPseudoMsgKey(&pseudoKey);
pseudoKey--;
srcDB->SetNextPseudoMsgKey(pseudoKey);
m_dupKeyArray.SetAt(i,pseudoKey);
rv = srcDB->CopyHdrFromExistingHdr(pseudoKey,
srcHdr, PR_FALSE,
getter_AddRefs(copySrcHdr));
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsISupports> supports = do_QueryInterface(copySrcHdr);
m_srcHdrs->AppendElement(supports);
}
}
}
}
}
@ -330,25 +350,23 @@ nsImapMoveCopyMsgTxn::UndoMailboxDelete()
PRUint32 i;
nsCOMPtr<nsIMsgDBHdr> oldHdr;
nsCOMPtr<nsIMsgDBHdr> newHdr;
nsCOMPtr<nsISupports> aSupport;
for (i=0; i<count; i++)
{
rv = dstDB->GetMsgHdrForKey(m_dstKeyArray.GetAt(i),
getter_AddRefs(oldHdr));
NS_ASSERTION(oldHdr, "fatal ... cannot get old msg header\n");
if (NS_SUCCEEDED(rv) && oldHdr)
{
rv = srcDB->CopyHdrFromExistingHdr(m_srcKeyArray.GetAt(i),
oldHdr,
getter_AddRefs(newHdr));
NS_ASSERTION(newHdr, "fatal ... cannot create new header\n");
if (NS_SUCCEEDED(rv) && newHdr)
{
if (i < m_srcSizeArray.GetSize())
newHdr->SetMessageSize(m_srcSizeArray.GetAt(i));
srcDB->UndoDelete(newHdr);
}
}
aSupport = getter_AddRefs(m_srcHdrs->ElementAt(i));
oldHdr = do_QueryInterface(aSupport);
NS_ASSERTION(oldHdr, "fatal ... cannot get old msg header\n");
rv = srcDB->CopyHdrFromExistingHdr(m_srcKeyArray.GetAt(i),
oldHdr,PR_TRUE,
getter_AddRefs(newHdr));
NS_ASSERTION(newHdr, "fatal ... cannot create new header\n");
if (NS_SUCCEEDED(rv) && newHdr)
{
if (i < m_srcSizeArray.GetSize())
newHdr->SetMessageSize(m_srcSizeArray.GetAt(i));
srcDB->UndoDelete(newHdr);
}
}
srcDB->SetSummaryValid(PR_TRUE);
srcDB->Commit(nsMsgDBCommitType::kLargeCommit);

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

@ -73,6 +73,8 @@ public:
private:
nsCOMPtr<nsIMsgFolder> m_srcFolder;
nsCOMPtr<nsISupportsArray> m_srcHdrs;
nsMsgKeyArray m_dupKeyArray;
nsMsgKeyArray m_srcKeyArray;
nsCString m_srcMsgIdString;
nsCOMPtr<nsIMsgFolder> m_dstFolder;

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

@ -312,7 +312,7 @@ nsFolderCompactState::OnStopRequest(nsIChannel *channel, nsISupports *ctxt,
// okay done with the current message; copying the existing message header
// to the new database
m_db->CopyHdrFromExistingHdr(m_newKey, msgHdr,
m_db->CopyHdrFromExistingHdr(m_newKey, msgHdr, PR_TRUE,
getter_AddRefs(newMsgHdr));
m_db->Commit(nsMsgDBCommitType::kLargeCommit);
@ -2389,7 +2389,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndCopy(PRBool copySucceeded)
if(NS_SUCCEEDED(rv))
{
rv = mDatabase->CopyHdrFromExistingHdr(mCopyState->m_curDstKey,
msgDBHdr,
msgDBHdr, PR_TRUE,
getter_AddRefs(newHdr));
msgDatabase->SetSummaryValid(PR_TRUE);
msgDatabase->Commit(nsMsgDBCommitType::kLargeCommit);

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

@ -235,7 +235,7 @@ nsLocalMoveCopyMsgTxn::Undo()
if (NS_SUCCEEDED(rv) && oldHdr)
{
rv = srcDB->CopyHdrFromExistingHdr(m_srcKeyArray.GetAt(i),
oldHdr,
oldHdr, PR_TRUE,
getter_AddRefs(newHdr));
NS_ASSERTION(newHdr,
"fatal ... cannot create new msg header\n");
@ -282,7 +282,7 @@ nsLocalMoveCopyMsgTxn::Redo()
if (NS_SUCCEEDED(rv) && oldHdr)
{
rv = dstDB->CopyHdrFromExistingHdr(m_dstKeyArray.GetAt(i),
oldHdr,
oldHdr, PR_TRUE,
getter_AddRefs(newHdr));
NS_ASSERTION(newHdr, "fatal ... cannot get new msg header\n");
if (NS_SUCCEEDED(rv) && newHdr)

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

@ -1932,7 +1932,7 @@ nsresult nsParseNewMailState::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
{
nsIMsgDBHdr *newHdr = nsnull;
nsresult msgErr = destMailDB->CopyHdrFromExistingHdr(newMsgPos, mailHdr, &newHdr);
nsresult msgErr = destMailDB->CopyHdrFromExistingHdr(newMsgPos, mailHdr, PR_TRUE, &newHdr);
if (NS_SUCCEEDED(msgErr) && newHdr)
{
PRUint32 newFlags;