Bug 468364 Shouldn't be necessary for nsLocalMoveCopyMsgTxn to implement QueryInterface r+sr=bienvenu

This commit is contained in:
Neil Rashbrook 2008-12-08 10:42:45 +00:00
Родитель 6862cda484
Коммит 20187b2a59
4 изменённых файлов: 8 добавлений и 67 удалений

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

@ -81,7 +81,6 @@
#include "nsMsgUtils.h"
#include "nsICopyMsgStreamListener.h"
#include "nsIMsgCopyService.h"
#include "nsLocalUndoTxn.h"
#include "nsMsgTxn.h"
#include "nsIMessenger.h"
#include "nsMsgBaseCID.h"
@ -1745,19 +1744,8 @@ nsMsgLocalMailFolder::CopyMessages(nsIMsgFolder* srcFolder, nsIArray*
// undo stuff
if (allowUndo) //no undo for folder move/copy or or move/copy from search window
{
nsLocalMoveCopyMsgTxn* msgTxn = nsnull;
msgTxn = new nsLocalMoveCopyMsgTxn;
nsRefPtr<nsLocalMoveCopyMsgTxn> msgTxn = new nsLocalMoveCopyMsgTxn;
if (msgTxn && NS_SUCCEEDED(msgTxn->Init(srcFolder, this, isMove)))
rv = msgTxn->QueryInterface(NS_GET_IID(nsLocalMoveCopyMsgTxn),
getter_AddRefs(mCopyState->m_undoMsgTxn));
else
{
delete msgTxn;
rv = NS_ERROR_OUT_OF_MEMORY;
}
if (NS_FAILED(rv))
(void) OnCopyCompleted(srcSupport, PR_FALSE);
else
{
msgTxn->SetMsgWindow(msgWindow);
if (isMove)
@ -1769,6 +1757,7 @@ nsMsgLocalMailFolder::CopyMessages(nsIMsgFolder* srcFolder, nsIArray*
}
else
msgTxn->SetTransactionType(nsIMessenger::eCopyMsg);
msgTxn.swap(mCopyState->m_undoMsgTxn);
}
}
@ -2465,11 +2454,9 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndCopy(PRBool copySucceeded)
return NS_OK;
}
nsRefPtr<nsLocalMoveCopyMsgTxn> localUndoTxn;
PRBool multipleCopiesFinished = (mCopyState->m_curCopyIndex >= mCopyState->m_totalMsgCount);
if (mCopyState->m_undoMsgTxn)
mCopyState->m_undoMsgTxn->QueryInterface(NS_GET_IID(nsLocalMoveCopyMsgTxn), getter_AddRefs(localUndoTxn));
nsRefPtr<nsLocalMoveCopyMsgTxn> localUndoTxn = mCopyState->m_undoMsgTxn;
nsCOMPtr <nsISeekableStream> seekableStream;
if (mCopyState)
@ -2762,19 +2749,13 @@ NS_IMETHODIMP nsMsgLocalMailFolder::StartMessage()
// just finished the current message.
NS_IMETHODIMP nsMsgLocalMailFolder::EndMessage(nsMsgKey key)
{
nsRefPtr<nsLocalMoveCopyMsgTxn> localUndoTxn;
nsRefPtr<nsLocalMoveCopyMsgTxn> localUndoTxn = mCopyState->m_undoMsgTxn;
nsCOMPtr<nsIMsgWindow> msgWindow;
nsresult rv;
if (mCopyState->m_undoMsgTxn)
{
rv = mCopyState->m_undoMsgTxn->QueryInterface(NS_GET_IID(nsLocalMoveCopyMsgTxn), getter_AddRefs(localUndoTxn));
if (localUndoTxn)
localUndoTxn->GetMsgWindow(getter_AddRefs(msgWindow));
}
if (localUndoTxn)
{
localUndoTxn->GetMsgWindow(getter_AddRefs(msgWindow));
localUndoTxn->AddSrcKey(key);
localUndoTxn->AddDstKey(mCopyState->m_curDstKey);
}
@ -3332,12 +3313,7 @@ nsresult nsMsgLocalMailFolder::DisplayMoveCopyStatusMsg()
// get msgWindow from undo txn
nsCOMPtr<nsIMsgWindow> msgWindow;
if (mCopyState->m_undoMsgTxn)
{
nsRefPtr<nsLocalMoveCopyMsgTxn> localUndoTxn;
rv = mCopyState->m_undoMsgTxn->QueryInterface(NS_GET_IID(nsLocalMoveCopyMsgTxn), getter_AddRefs(localUndoTxn));
if (NS_SUCCEEDED(rv))
localUndoTxn->GetMsgWindow(getter_AddRefs(msgWindow));
}
mCopyState->m_undoMsgTxn->GetMsgWindow(getter_AddRefs(msgWindow));
if (!msgWindow)
return NS_OK; // not a fatal error.
msgWindow->GetStatusFeedback(getter_AddRefs(mCopyState->m_statusFeedback));

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

@ -55,6 +55,7 @@
#include "nsIMsgFilterPlugin.h"
#include "nsISeekableStream.h"
#include "nsIMutableArray.h"
#include "nsLocalUndoTxn.h"
#define COPY_BUFFER_SIZE 16384
@ -66,7 +67,7 @@ struct nsLocalMailCopyState
nsCOMPtr <nsIOutputStream> m_fileStream;
nsCOMPtr<nsISupports> m_srcSupport;
nsCOMPtr<nsIArray> m_messages;
nsRefPtr<nsMsgTxn> m_undoMsgTxn;
nsRefPtr<nsLocalMoveCopyMsgTxn> m_undoMsgTxn;
nsCOMPtr<nsIMsgDBHdr> m_message; // current copy message
nsCOMPtr<nsIMsgParseMailMsgState> m_parseMsgState;
nsCOMPtr<nsIMsgCopyServiceListener> m_listener;

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

@ -57,30 +57,6 @@ nsLocalMoveCopyMsgTxn::~nsLocalMoveCopyMsgTxn()
{
}
NS_IMPL_ADDREF_INHERITED(nsLocalMoveCopyMsgTxn, nsMsgTxn)
NS_IMPL_RELEASE_INHERITED(nsLocalMoveCopyMsgTxn, nsMsgTxn)
NS_IMETHODIMP
nsLocalMoveCopyMsgTxn::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (!aInstancePtr) return NS_ERROR_NULL_POINTER;
*aInstancePtr = nsnull;
if (aIID.Equals(NS_GET_IID(nsLocalMoveCopyMsgTxn)))
{
*aInstancePtr = static_cast<nsLocalMoveCopyMsgTxn*>(this);
}
if (*aInstancePtr)
{
NS_ADDREF_THIS();
return NS_OK;
}
return nsMsgTxn::QueryInterface(aIID, aInstancePtr);
}
nsresult
nsLocalMoveCopyMsgTxn::Init(nsIMsgFolder* srcFolder, nsIMsgFolder* dstFolder,
PRBool isMove)

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

@ -48,23 +48,14 @@
#include "nsIUrlListener.h"
#include "nsIWeakReference.h"
#define NS_LOCALMOVECOPYMSGTXN_IID \
{ /* 874363b4-242e-11d3-afad-001083002da8 */ \
0x874363b4, 0x242e, 0x11d3, \
{ 0xaf, 0xad, 0x00, 0x10, 0x83, 0x00, 0x2d, 0xa8 } }
class nsLocalUndoFolderListener;
class nsLocalMoveCopyMsgTxn : public nsMsgTxn
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_LOCALMOVECOPYMSGTXN_IID)
nsLocalMoveCopyMsgTxn();
virtual ~nsLocalMoveCopyMsgTxn();
NS_DECL_ISUPPORTS_INHERITED
// overloading nsITransaction methods
NS_IMETHOD UndoTransaction(void);
NS_IMETHOD RedoTransaction(void);
@ -97,9 +88,6 @@ private:
nsLocalUndoFolderListener *mUndoFolderListener;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsLocalMoveCopyMsgTxn,
NS_LOCALMOVECOPYMSGTXN_IID)
class nsLocalUndoFolderListener : public nsIFolderListener
{
public: