Back to index

lightning-sunbird  0.9+nobinonly
nsImapUndoTxn.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998-2001
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef nsImapUndoTxn_h__
00039 #define nsImapUndoTxn_h__
00040 
00041 #include "nsIMsgFolder.h"
00042 #include "nsImapCore.h"
00043 #include "nsIImapService.h"
00044 #include "nsIImapIncomingServer.h"
00045 #include "nsIUrlListener.h"
00046 #include "nsIEventQueue.h"
00047 #include "nsMsgTxn.h"
00048 #include "nsMsgKeyArray.h"
00049 #include "nsIMsgOfflineImapOperation.h"
00050 #include "nsCOMPtr.h"
00051 #include "nsWeakReference.h"
00052 
00053 #define NS_IMAPMOVECOPYMSGTXN_IID \
00054 { /* 51c925b0-208e-11d3-abea-00805f8ac968 */ \
00055        0x51c925b0, 0x208e, 0x11d3, \
00056     { 0xab, 0xea, 0x00, 0x80, 0x5f, 0x8a, 0xc9, 0x68 } }
00057 
00058 class nsImapMoveCopyMsgTxn : public nsMsgTxn
00059 {
00060 public:
00061   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMAPMOVECOPYMSGTXN_IID)
00062 
00063   nsImapMoveCopyMsgTxn();
00064   nsImapMoveCopyMsgTxn(nsIMsgFolder* srcFolder, nsMsgKeyArray* srcKeyArray,
00065                        const char* srcMsgIdString, nsIMsgFolder* dstFolder,
00066                        PRBool idsAreUids, PRBool isMove, 
00067                        nsIEventQueue *eventQueue, 
00068                        nsIUrlListener *urlListener);
00069   virtual ~nsImapMoveCopyMsgTxn();
00070 
00071   NS_DECL_ISUPPORTS_INHERITED 
00072 
00073   NS_IMETHOD UndoTransaction(void);
00074   NS_IMETHOD RedoTransaction(void);
00075 
00076   // helper
00077   nsresult SetCopyResponseUid(const char *msgIdString);
00078   nsresult GetSrcKeyArray(nsMsgKeyArray& srcKeyArray);
00079   nsresult AddDstKey(nsMsgKey aKey);
00080   nsresult UndoMailboxDelete();
00081   nsresult RedoMailboxDelete();
00082   nsresult Init(nsIMsgFolder* srcFolder, nsMsgKeyArray* srcKeyArray,
00083                 const char* srcMsgIdString, nsIMsgFolder* dstFolder,
00084                 PRBool idsAreUids, PRBool isMove, 
00085                 nsIEventQueue *eventQueue, 
00086                 nsIUrlListener *urlListener);
00087 
00088 protected:
00089 
00090   nsWeakPtr m_srcFolder;
00091   nsCOMPtr<nsISupportsArray> m_srcHdrs;
00092   nsMsgKeyArray m_dupKeyArray;
00093   nsMsgKeyArray m_srcKeyArray;
00094   nsCString m_srcMsgIdString;
00095   nsWeakPtr m_dstFolder;
00096   nsCString m_dstMsgIdString;
00097   nsCOMPtr<nsIEventQueue> m_eventQueue;
00098   nsCOMPtr<nsIUrlListener> m_urlListener;
00099   PRBool m_idsAreUids;
00100   PRBool m_isMove;
00101   PRBool m_srcIsPop3;
00102   nsUInt32Array m_srcSizeArray;
00103 
00104   nsresult GetImapDeleteModel(nsIMsgFolder* aFolder, nsMsgImapDeleteModel *aDeleteModel);
00105 };
00106 
00107 class nsImapOfflineTxn : public nsImapMoveCopyMsgTxn
00108 {
00109 public:
00110   nsImapOfflineTxn(nsIMsgFolder* srcFolder, nsMsgKeyArray* srcKeyArray,
00111                        nsIMsgFolder* dstFolder,
00112                        PRBool isMove,
00113                        nsOfflineImapOperationType opType,
00114                        nsIMsgDBHdr *srcHdr,
00115                        nsIEventQueue *eventQueue, 
00116                        nsIUrlListener *urlListener);
00117   virtual ~nsImapOfflineTxn();
00118 
00119   NS_IMETHOD UndoTransaction(void);
00120   NS_IMETHOD RedoTransaction(void);
00121   void SetAddFlags(PRBool addFlags) {m_addFlags = addFlags;}
00122   void SetFlags(PRUint32 flags) {m_flags = flags;}
00123 protected:
00124   nsOfflineImapOperationType m_opType;
00125   nsCOMPtr <nsIMsgDBHdr> m_header;
00126   // these two are used to undo flag changes, which we don't currently do.
00127   PRBool m_addFlags;
00128   PRUint32 m_flags;
00129 };
00130 
00131 
00132 #endif