зеркало из https://github.com/mozilla/pjs.git
more on unod work - added SetCopyResponseUid() method; nsImapMoveCopyMsgTxn class; fix set message flags not working problem
This commit is contained in:
Родитель
022d8c0b72
Коммит
23d62e28a4
|
@ -60,6 +60,7 @@ CPPSRCS = \
|
|||
nsImapService.cpp \
|
||||
nsImapUrl.cpp \
|
||||
nsImapFlagAndUidState.cpp \
|
||||
nsImapUndoTxn.cpp \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
|
|
@ -59,6 +59,7 @@ CPP_OBJS= .\$(OBJDIR)\nsImapUrl.obj \
|
|||
.\$(OBJDIR)\nsImapMailFolder.obj \
|
||||
.\$(OBJDIR)\nsImapMessage.obj \
|
||||
.\$(OBJDIR)\nsImapUtils.obj \
|
||||
.\$(OBJDIR)\nsImapUndoTxn.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "nsIWebShell.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
#include "nsMsgLocalCID.h"
|
||||
#include "nsImapUndoTxn.h"
|
||||
|
||||
#ifdef DOING_FILTERS
|
||||
#include "nsIMsgFilter.h"
|
||||
|
@ -867,6 +868,12 @@ NS_IMETHODIMP nsImapMailFolder::DeleteMessages(nsISupportsArray *messages,
|
|||
uri.Append(hostName);
|
||||
PR_FREEIF(hostName);
|
||||
|
||||
if (!m_transactionManager || m_transactionManager != txnMgr)
|
||||
{
|
||||
m_transactionManager = null_nsCOMPtr();
|
||||
m_transactionManager = do_QueryInterface(txnMgr, &rv);
|
||||
}
|
||||
|
||||
NS_WITH_SERVICE(nsIRDFService, rdf, kRDFServiceCID, &rv);
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -909,6 +916,7 @@ NS_IMETHODIMP nsImapMailFolder::DeleteMessages(nsISupportsArray *messages,
|
|||
rv = messages->Count(&count);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Count failed");
|
||||
nsString2 messageIds("", eOneByte);
|
||||
nsMsgKeyArray srcKeyArray;
|
||||
PRUint32 i;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
|
@ -924,6 +932,7 @@ NS_IMETHODIMP nsImapMailFolder::DeleteMessages(nsISupportsArray *messages,
|
|||
if (messageIds.Length() > 0)
|
||||
messageIds.Append(',');
|
||||
messageIds.Append((PRInt32)key);
|
||||
srcKeyArray.Add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -935,6 +944,24 @@ NS_IMETHODIMP nsImapMailFolder::DeleteMessages(nsISupportsArray *messages,
|
|||
this, nsnull);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
m_pendingUndoTxn = null_nsCOMPtr();
|
||||
m_pendingUndoTxn = do_QueryInterface(new nsImapMoveCopyMsgTxn(
|
||||
this, &srcKeyArray, messageIds.GetBuffer(), trashFolder,
|
||||
PR_TRUE, PR_TRUE, m_eventQueue, this), &rv);
|
||||
if (m_pendingUndoTxn)
|
||||
{
|
||||
nsString undoString = count > 1 ? "Undo Delete Messages" :
|
||||
"Undo Delete Message";
|
||||
nsString redoString = count > 1 ? "Redo Delete Messages" :
|
||||
"Redo Delete Message";
|
||||
nsCOMPtr<nsImapMoveCopyMsgTxn>
|
||||
msgTxn(do_QueryInterface(m_pendingUndoTxn, &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = msgTxn->SetUndoString(&undoString);
|
||||
rv = msgTxn->SetRedoString(&redoString);
|
||||
}
|
||||
}
|
||||
if (mDatabase) // *** jt - do we really need to do this?
|
||||
// especially if using imap delete model
|
||||
{
|
||||
|
@ -960,6 +987,7 @@ NS_IMETHODIMP nsImapMailFolder::DeleteMessages(nsISupportsArray *messages,
|
|||
}
|
||||
}
|
||||
}
|
||||
mDatabase->Commit(kLargeCommit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2177,6 +2205,26 @@ nsImapMailFolder::OnStopRunningUrl(nsIURL *aUrl, nsresult aExitCode)
|
|||
m_urlRunning = PR_FALSE;
|
||||
if (aUrl)
|
||||
{
|
||||
nsCOMPtr<nsIImapUrl> imapUrl = do_QueryInterface(aUrl);
|
||||
if (imapUrl)
|
||||
{
|
||||
nsIImapUrl::nsImapAction imapAction = nsIImapUrl::nsImapTest;
|
||||
imapUrl->GetImapAction(&imapAction);
|
||||
switch(imapAction)
|
||||
{
|
||||
case nsIImapUrl::nsImapDeleteMsg:
|
||||
case nsIImapUrl::nsImapOnlineMove:
|
||||
case nsIImapUrl::nsImapOnlineCopy:
|
||||
#ifdef NOT_YET
|
||||
if (m_transactionManager)
|
||||
m_transactionManager->Do(m_pendingUndoTxn);
|
||||
#endif
|
||||
m_pendingUndoTxn = null_nsCOMPtr();
|
||||
break;
|
||||
default:
|
||||
m_pendingUndoTxn = null_nsCOMPtr();
|
||||
}
|
||||
}
|
||||
// query it for a mailnews interface for now....
|
||||
nsCOMPtr<nsIMsgMailNewsUrl> mailUrl = do_QueryInterface(aUrl);
|
||||
if (mailUrl)
|
||||
|
@ -2186,6 +2234,7 @@ nsImapMailFolder::OnStopRunningUrl(nsIURL *aUrl, nsresult aExitCode)
|
|||
}
|
||||
|
||||
// nsIImapExtensionSink methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMailFolder::SetUserAuthenticated(nsIImapProtocol* aProtocol,
|
||||
PRBool aBool)
|
||||
|
@ -2242,7 +2291,21 @@ nsImapMailFolder::SetFolderAdminURL(nsIImapProtocol* aProtocol,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMailFolder::SetCopyResponseUid(nsIImapProtocol* aProtocol,
|
||||
nsMsgKeyArray* aKeyArray,
|
||||
const char* msgIdString)
|
||||
{
|
||||
if (m_pendingUndoTxn)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsImapMoveCopyMsgTxn> msgTxn =
|
||||
do_QueryInterface(m_pendingUndoTxn, &rv);
|
||||
if (msgTxn)
|
||||
msgTxn->SetCopyResponseUid(aKeyArray, msgIdString);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
// nsIImapMiscellaneousSink methods
|
||||
NS_IMETHODIMP
|
||||
nsImapMailFolder::AddSearchResult(nsIImapProtocol* aProtocol,
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include "nsIUrlListener.h"
|
||||
#include "nsIImapIncomingServer.h" // we need this for its IID
|
||||
#include "nsIMsgParseMailMsgState.h"
|
||||
#include "nsITransactionManager.h"
|
||||
#include "nsMsgTxn.h"
|
||||
#ifdef DEBUG_bienvenu
|
||||
//#define DOING_FILTERS
|
||||
#endif
|
||||
|
@ -199,6 +201,9 @@ public:
|
|||
nsIMAPACLRightsInfo* aclRights);
|
||||
NS_IMETHOD SetFolderAdminURL(nsIImapProtocol* aProtocol,
|
||||
FolderQueryInfo* aInfo);
|
||||
NS_IMETHOD SetCopyResponseUid(nsIImapProtocol* aProtocol,
|
||||
nsMsgKeyArray* keyArray,
|
||||
const char* msgIdString);
|
||||
|
||||
// nsIImapMiscellaneousSink methods
|
||||
NS_IMETHOD AddSearchResult(nsIImapProtocol* aProtocol,
|
||||
|
@ -296,6 +301,10 @@ protected:
|
|||
// converter interface...
|
||||
nsCOMPtr<nsIOutputStream> m_tempMessageStream;
|
||||
nsFileSpec m_tempMessageFile;
|
||||
|
||||
// *** jt - undo move/copy trasaction support
|
||||
nsCOMPtr<nsITransactionManager> m_transactionManager;
|
||||
nsCOMPtr<nsMsgTxn> m_pendingUndoTxn;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3290,6 +3290,12 @@ void nsImapProtocol::AddFolderRightsForUser(const char *mailboxName, const char
|
|||
HandleMemoryFailure();
|
||||
}
|
||||
|
||||
void nsImapProtocol::SetCopyResponseUid(nsMsgKeyArray* aKeyArray,
|
||||
const char *msgIdString)
|
||||
{
|
||||
if (m_imapExtensionSink)
|
||||
m_imapExtensionSink->SetCopyResponseUid(this,aKeyArray, msgIdString);
|
||||
}
|
||||
|
||||
void nsImapProtocol::CommitNamespacesForHostEvent()
|
||||
{
|
||||
|
@ -5068,7 +5074,7 @@ void nsImapProtocol::ProcessStoreFlags(nsString2 &messageIdsString,
|
|||
flagString .Append("$MDNSent "); // if supported
|
||||
|
||||
// replace the final space with ')'
|
||||
flagString.SetCharAt(flagString.Length() - 1, ')');;
|
||||
flagString.SetCharAt(')',flagString.Length() - 1);;
|
||||
|
||||
Store(messageIdsString, flagString.GetBuffer(), idsAreUids);
|
||||
}
|
||||
|
|
|
@ -260,6 +260,10 @@ public:
|
|||
void HandleMemoryFailure();
|
||||
void HandleCurrentUrlError();
|
||||
|
||||
// UIDPLUS extension
|
||||
void SetCopyResponseUid(nsMsgKeyArray* aKeyArray,
|
||||
const char* msgIdString);
|
||||
|
||||
private:
|
||||
// the following flag is used to determine when a url is currently being run. It is cleared on calls
|
||||
// to ::StopBinding and it is set whenever we call Load on a url
|
||||
|
|
|
@ -46,7 +46,7 @@ nsImapEvent::~nsImapEvent()
|
|||
void
|
||||
nsImapEvent::SetNotifyCompletion(PRBool notifyCompletion)
|
||||
{
|
||||
m_notifyCompletion = PR_TRUE;
|
||||
m_notifyCompletion = notifyCompletion;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1106,6 +1106,35 @@ nsImapExtensionSinkProxy::SetFolderAdminURL(nsIImapProtocol* aProtocol,
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapExtensionSinkProxy::SetCopyResponseUid(nsIImapProtocol* aProtocol,
|
||||
nsMsgKeyArray* aKeyArray,
|
||||
const char* msgIdString)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
NS_PRECONDITION (aKeyArray, "Oops... null aKeyArray");
|
||||
if(!aKeyArray)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
NS_ASSERTION (m_protocol == aProtocol, "Ooh ooh, wrong protocol");
|
||||
|
||||
if (PR_GetCurrentThread() == m_thread)
|
||||
{
|
||||
SetCopyResponseUidProxyEvent *ev =
|
||||
new SetCopyResponseUidProxyEvent(this, aKeyArray, msgIdString);
|
||||
if(nsnull == ev)
|
||||
res = NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
ev->PostEvent(m_eventQueue);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = m_realImapExtensionSink->SetCopyResponseUid(aProtocol,
|
||||
aKeyArray,
|
||||
msgIdString);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
nsImapMiscellaneousSinkProxy::nsImapMiscellaneousSinkProxy(
|
||||
nsIImapMiscellaneousSink* aImapMiscellaneousSink,
|
||||
nsIImapProtocol* aProtocol,
|
||||
|
@ -2824,6 +2853,32 @@ SetFolderAdminURLProxyEvent::HandleEvent()
|
|||
return res;
|
||||
}
|
||||
|
||||
SetCopyResponseUidProxyEvent::SetCopyResponseUidProxyEvent(
|
||||
nsImapExtensionSinkProxy* aProxy, nsMsgKeyArray* aKeyArray,
|
||||
const char* msgIdString) :
|
||||
nsImapExtensionSinkProxyEvent(aProxy), m_msgIdString(msgIdString, eOneByte)
|
||||
{
|
||||
NS_ASSERTION (aKeyArray, "Oops... a null key array");
|
||||
if (aKeyArray)
|
||||
{
|
||||
m_copyKeyArray.CopyArray(aKeyArray);
|
||||
}
|
||||
}
|
||||
|
||||
SetCopyResponseUidProxyEvent::~SetCopyResponseUidProxyEvent()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SetCopyResponseUidProxyEvent::HandleEvent()
|
||||
{
|
||||
nsresult res = m_proxy->m_realImapExtensionSink->SetCopyResponseUid(
|
||||
m_proxy->m_protocol, &m_copyKeyArray, m_msgIdString.GetBuffer());
|
||||
if (m_notifyCompletion)
|
||||
m_proxy->m_protocol->NotifyFEEventCompletion();
|
||||
return res;
|
||||
}
|
||||
|
||||
nsImapMiscellaneousSinkProxyEvent::nsImapMiscellaneousSinkProxyEvent(
|
||||
nsImapMiscellaneousSinkProxy* aProxy)
|
||||
{
|
||||
|
|
|
@ -178,6 +178,9 @@ public:
|
|||
nsIMAPACLRightsInfo* aclRights);
|
||||
NS_IMETHOD SetFolderAdminURL(nsIImapProtocol* aProtocol,
|
||||
FolderQueryInfo* aInfo);
|
||||
NS_IMETHOD SetCopyResponseUid(nsIImapProtocol* aProtocol,
|
||||
nsMsgKeyArray* aKeyArray,
|
||||
const char* msgIdString);
|
||||
|
||||
nsIImapExtensionSink* m_realImapExtensionSink;
|
||||
};
|
||||
|
@ -570,6 +573,17 @@ struct SetFolderAdminURLProxyEvent : nsImapExtensionSinkProxyEvent
|
|||
FolderQueryInfo m_folderQueryInfo;
|
||||
};
|
||||
|
||||
struct SetCopyResponseUidProxyEvent : nsImapExtensionSinkProxyEvent
|
||||
{
|
||||
SetCopyResponseUidProxyEvent(nsImapExtensionSinkProxy* aProxy,
|
||||
nsMsgKeyArray* aKeyArray,
|
||||
const char* msgIdString);
|
||||
virtual ~SetCopyResponseUidProxyEvent();
|
||||
NS_IMETHOD HandleEvent();
|
||||
nsMsgKeyArray m_copyKeyArray;
|
||||
nsString2 m_msgIdString;
|
||||
};
|
||||
|
||||
struct nsImapMiscellaneousSinkProxyEvent : public nsImapEvent
|
||||
{
|
||||
nsImapMiscellaneousSinkProxyEvent(nsImapMiscellaneousSinkProxy* aProxy);
|
||||
|
|
|
@ -81,6 +81,7 @@ nsImapServerResponseParser::~nsImapServerResponseParser()
|
|||
PR_FREEIF( fSelectedMailboxName );
|
||||
|
||||
NS_IF_RELEASE (fHostSessionList);
|
||||
fCopyResponseKeyArray.RemoveAll();
|
||||
}
|
||||
|
||||
PRBool nsImapServerResponseParser::LastCommandSuccessful()
|
||||
|
@ -1444,6 +1445,42 @@ void nsImapServerResponseParser::resp_text_code()
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (!PL_strcasecmp(fNextToken, "COPYUID"))
|
||||
{
|
||||
fNextToken = GetNextToken();
|
||||
if (ContinueParse())
|
||||
{
|
||||
fFolderUIDValidity = atoi(fNextToken);
|
||||
fHighestRecordedUID = 0;
|
||||
// original message set; ignore it
|
||||
fNextToken = GetNextToken();
|
||||
if (ContinueParse())
|
||||
{
|
||||
// the resulting message set; should be in the form of
|
||||
// either uid or uid1:uid2
|
||||
fNextToken = GetNextToken();
|
||||
// clear copy response uid
|
||||
fCopyResponseKeyArray.RemoveAll();
|
||||
PRUint32 startKey = atoi(fNextToken);
|
||||
fCopyResponseKeyArray.Add(startKey);
|
||||
char *colon = PL_strchr(fNextToken, ':');
|
||||
if (colon)
|
||||
{
|
||||
PRUint32 endKey= atoi(colon+1);
|
||||
NS_ASSERTION (endKey > startKey,
|
||||
"Oops ... invalid message set");
|
||||
for (startKey++; startKey <= endKey; startKey++)
|
||||
fCopyResponseKeyArray.Add(startKey);
|
||||
}
|
||||
fServerConnection.SetCopyResponseUid(
|
||||
&fCopyResponseKeyArray, fNextToken);
|
||||
}
|
||||
if (ContinueParse())
|
||||
{
|
||||
fNextToken = GetNextToken();
|
||||
}
|
||||
}
|
||||
}
|
||||
else // just text
|
||||
{
|
||||
// do nothing but eat tokens until we see the ] or CRLF
|
||||
|
@ -2304,3 +2341,15 @@ nsImapServerResponseParser::GetHostSessionList()
|
|||
return fHostSessionList;
|
||||
}
|
||||
|
||||
void
|
||||
nsImapServerResponseParser::CopyResponseUID(nsMsgKeyArray& keyArray)
|
||||
{
|
||||
keyArray.CopyArray(fCopyResponseKeyArray);
|
||||
}
|
||||
|
||||
void
|
||||
nsImapServerResponseParser::ClearCopyResponseUID()
|
||||
{
|
||||
fCopyResponseKeyArray.RemoveAll();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "nsIMAPHostSessionList.h"
|
||||
#include "nsImapSearchResults.h"
|
||||
#include "nsString.h"
|
||||
#include "nsMsgKeyArray.h"
|
||||
|
||||
class nsIMAPNamespace;
|
||||
class nsIMAPNamespaceList;
|
||||
|
@ -76,6 +77,8 @@ public:
|
|||
PRInt32 FolderUID();
|
||||
PRUint32 CurrentResponseUID();
|
||||
PRUint32 HighestRecordedUID();
|
||||
void CopyResponseUID(nsMsgKeyArray& keyArray);
|
||||
void ClearCopyResponseUID();
|
||||
PRBool IsNumericString(const char *string);
|
||||
PRInt32 SizeOfMostRecentMessage();
|
||||
void SetTotalDownloadSize(PRInt32 newSize) { fTotalDownloadSize = newSize; }
|
||||
|
@ -244,6 +247,7 @@ private:
|
|||
nsImapProtocol &fServerConnection;
|
||||
|
||||
nsIImapHostSessionList *fHostSessionList;
|
||||
nsMsgKeyArray fCopyResponseKeyArray;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,162 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998, 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsImapUndoTxn.h"
|
||||
|
||||
static NS_DEFINE_CID(kCImapService, NS_IMAPSERVICE_CID);
|
||||
|
||||
nsImapMoveCopyMsgTxn::nsImapMoveCopyMsgTxn(
|
||||
nsIMsgFolder* srcFolder, nsMsgKeyArray* srcKeyArray,
|
||||
const char* srcMsgIdString, nsIMsgFolder* dstFolder,
|
||||
PRBool idsAreUids, PRBool isMove,
|
||||
nsIEventQueue* eventQueue, nsIUrlListener* urlListener) :
|
||||
m_srcMsgIdString(srcMsgIdString, eOneByte),
|
||||
m_dstMsgIdString("", eOneByte), m_idsAreUids(idsAreUids), m_isMove(isMove)
|
||||
{
|
||||
nsresult rv;
|
||||
m_srcFolder = do_QueryInterface(srcFolder, &rv);
|
||||
m_dstFolder = do_QueryInterface(dstFolder, &rv);
|
||||
m_eventQueue = do_QueryInterface(eventQueue, &rv);
|
||||
if (urlListener)
|
||||
m_urlListener = do_QueryInterface(urlListener, &rv);
|
||||
m_srcKeyArray.CopyArray(srcKeyArray);
|
||||
if (srcKeyArray->GetSize() > 1)
|
||||
{
|
||||
if (isMove)
|
||||
{
|
||||
m_undoString = "Undo Move Messages";
|
||||
m_redoString = "Redo Move Messages";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_undoString = "Undo Copy Messages";
|
||||
m_redoString = "Redo Copy Messages";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isMove)
|
||||
{
|
||||
m_undoString = "Undo Move Message";
|
||||
m_redoString = "Redo Move Message";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_undoString = "Undo Copy Message";
|
||||
m_redoString = "Redo Copy Message";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsImapMoveCopyMsgTxn::~nsImapMoveCopyMsgTxn()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsImapMoveCopyMsgTxn, nsMsgTxn, nsImapMoveCopyMsgTxn)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMoveCopyMsgTxn::Undo(void)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
NS_WITH_SERVICE(nsIImapService, imapService, kCImapService, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (m_isMove)
|
||||
rv = imapService->SubtractMessageFlags(m_eventQueue, m_srcFolder,
|
||||
m_urlListener, nsnull,
|
||||
m_srcMsgIdString.GetBuffer(),
|
||||
kImapMsgDeletedFlag,
|
||||
m_idsAreUids);
|
||||
if (m_dstKeyArray.GetSize() > 0)
|
||||
rv = imapService->AddMessageFlags(m_eventQueue, m_dstFolder,
|
||||
m_urlListener, nsnull,
|
||||
m_dstMsgIdString.GetBuffer(),
|
||||
kImapMsgDeletedFlag,
|
||||
m_idsAreUids);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMoveCopyMsgTxn::Redo(void)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
NS_WITH_SERVICE(nsIImapService, imapService, kCImapService, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (m_isMove)
|
||||
rv = imapService->AddMessageFlags(m_eventQueue, m_srcFolder,
|
||||
m_urlListener, nsnull,
|
||||
m_srcMsgIdString.GetBuffer(),
|
||||
kImapMsgDeletedFlag,
|
||||
m_idsAreUids);
|
||||
if (m_dstKeyArray.GetSize() > 0)
|
||||
rv = imapService->SubtractMessageFlags(m_eventQueue, m_dstFolder,
|
||||
m_urlListener, nsnull,
|
||||
m_dstMsgIdString.GetBuffer(),
|
||||
kImapMsgDeletedFlag,
|
||||
m_idsAreUids);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMoveCopyMsgTxn::GetUndoString(nsString* aString)
|
||||
{
|
||||
if (!aString)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aString = m_undoString;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMoveCopyMsgTxn::GetRedoString(nsString* aString)
|
||||
{
|
||||
if (!aString)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aString = m_redoString;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsImapMoveCopyMsgTxn::SetUndoString(nsString *aString)
|
||||
{
|
||||
if (!aString)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
m_undoString = *aString;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsImapMoveCopyMsgTxn::SetRedoString(nsString* aString)
|
||||
{
|
||||
if (!aString) return NS_ERROR_NULL_POINTER;
|
||||
m_redoString = *aString;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsImapMoveCopyMsgTxn::SetCopyResponseUid(nsMsgKeyArray* aKeyArray,
|
||||
const char* aMsgIdString)
|
||||
{
|
||||
if (!aKeyArray || !aMsgIdString) return NS_ERROR_NULL_POINTER;
|
||||
m_dstKeyArray.CopyArray(aKeyArray);
|
||||
m_dstMsgIdString = aMsgIdString;
|
||||
if (m_dstMsgIdString.Last() == ']')
|
||||
{
|
||||
PRInt32 len = m_dstMsgIdString.Length();
|
||||
m_dstMsgIdString.SetLength(len - 1);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998, 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsImapUndoTxn_h__
|
||||
#define nsImapUndoTxn_h__
|
||||
|
||||
#include "nsIMsgFolder.h"
|
||||
#include "nsImapCore.h"
|
||||
#include "nsIImapService.h"
|
||||
#include "nsIUrlListener.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsMsgTxn.h"
|
||||
#include "nsMsgKeyArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define NS_IMAPMOVECOPYMSGTXN_IID \
|
||||
{ /* 51c925b0-208e-11d3-abea-00805f8ac968 */ \
|
||||
0x51c925b0, 0x208e, 0x11d3, \
|
||||
{ 0xab, 0xea, 0x00, 0x80, 0x5f, 0x8a, 0xc9, 0x68 } }
|
||||
|
||||
class nsImapMoveCopyMsgTxn : public nsMsgTxn
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMAPMOVECOPYMSGTXN_IID)
|
||||
|
||||
nsImapMoveCopyMsgTxn(nsIMsgFolder* srcFolder, nsMsgKeyArray* srcKeyArray,
|
||||
const char* srcMsgIdString, nsIMsgFolder* dstFolder,
|
||||
PRBool idsAreUids, PRBool isMove,
|
||||
nsIEventQueue *eventQueue,
|
||||
nsIUrlListener *urlListener);
|
||||
virtual ~nsImapMoveCopyMsgTxn();
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_IMETHOD Undo(void);
|
||||
NS_IMETHOD Redo(void);
|
||||
NS_IMETHOD GetUndoString(nsString *aString);
|
||||
NS_IMETHOD GetRedoString(nsString *aString);
|
||||
|
||||
// helper
|
||||
nsresult SetUndoString(nsString *aString);
|
||||
nsresult SetRedoString(nsString *aString);
|
||||
nsresult SetCopyResponseUid(nsMsgKeyArray* keyArray,
|
||||
const char *msgIdString);
|
||||
|
||||
private:
|
||||
|
||||
nsCOMPtr<nsIMsgFolder> m_srcFolder;
|
||||
nsMsgKeyArray m_srcKeyArray;
|
||||
nsString m_srcMsgIdString;
|
||||
nsCOMPtr<nsIMsgFolder> m_dstFolder;
|
||||
nsMsgKeyArray m_dstKeyArray;
|
||||
nsString m_dstMsgIdString;
|
||||
nsCOMPtr<nsIEventQueue> m_eventQueue;
|
||||
nsCOMPtr<nsIUrlListener> m_urlListener;
|
||||
nsString m_undoString;
|
||||
nsString m_redoString;
|
||||
PRBool m_idsAreUids;
|
||||
PRBool m_isMove;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -959,6 +959,13 @@ void nsImapUrl::ParseImapPart(char *imapPartOfUrl)
|
|||
ParseFolderPath(&m_sourceCanonicalFolderPathSubString);
|
||||
ParseListofMessageIds();
|
||||
}
|
||||
else if (!PL_strcasecmp(m_urlidSubString, "uidexpunge"))
|
||||
{
|
||||
m_imapAction = nsImapUidExpunge;
|
||||
ParseUidChoice();
|
||||
ParseFolderPath(&m_sourceCanonicalFolderPathSubString);
|
||||
ParseListofMessageIds();
|
||||
}
|
||||
else if (!PL_strcasecmp(m_urlidSubString, "deleteallmsgs"))
|
||||
{
|
||||
m_imapAction = nsImapDeleteAllMsgs;
|
||||
|
|
Загрузка…
Ссылка в новой задаче