Back to index

lightning-sunbird  0.9+nobinonly
nsMsgCopy.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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
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 _nsMsgCopy_H_
00039 #define _nsMsgCopy_H_
00040 
00041 #include "nscore.h"
00042 #include "nsIFileSpec.h"
00043 #include "nsMsgSend.h"
00044 #include "nsIMsgFolder.h"
00045 #include "nsITransactionManager.h"
00046 #include "nsIMsgCopyServiceListener.h"
00047 #include "nsIMsgCopyService.h"
00048 
00049 // {0874C3B5-317D-11d3-8EFB-00A024A7D144}
00050 #define NS_IMSGCOPY_IID           \
00051 { 0x874c3b5, 0x317d, 0x11d3,      \
00052 { 0x8e, 0xfb, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } };
00053 
00054 // Forward declarations...
00055 class   nsMsgCopy;
00056 
00058 // This is the listener class for the copy operation. We have to create this class 
00059 // to listen for message copy completion and eventually notify the caller
00061 class CopyListener : public nsIMsgCopyServiceListener
00062 {
00063 public:
00064   CopyListener(void);
00065   virtual ~CopyListener(void);
00066 
00067   // nsISupports interface
00068   NS_DECL_ISUPPORTS
00069 
00070   NS_IMETHOD OnStartCopy();
00071   
00072   NS_IMETHOD OnProgress(PRUint32 aProgress, PRUint32 aProgressMax);
00073 
00074   NS_IMETHOD SetMessageKey(PRUint32 aMessageKey);
00075   
00076   NS_IMETHOD GetMessageId(nsCString* aMessageId);
00077   
00078   NS_IMETHOD OnStopCopy(nsresult aStatus);
00079 
00080   NS_IMETHOD SetMsgComposeAndSendObject(nsIMsgSend *obj);
00081   
00082   nsCOMPtr<nsISupports> mCopyObject;
00083   PRBool                          mCopyInProgress;
00084 
00085 private:
00086   nsCOMPtr<nsIMsgSend>       mComposeAndSend;
00087 };
00088 
00089 //
00090 // This is a class that deals with processing remote attachments. It implements
00091 // an nsIStreamListener interface to deal with incoming data
00092 //
00093 class nsMsgCopy : public nsIUrlListener
00094 {
00095 public:
00096   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMSGCOPY_IID)
00097 
00098   nsMsgCopy();
00099   virtual ~nsMsgCopy();
00100 
00101   // nsISupports interface
00102   NS_DECL_ISUPPORTS
00103   NS_DECL_NSIURLLISTENER
00104 
00105 
00107   // Object methods...
00109   //
00110   nsresult              StartCopyOperation(nsIMsgIdentity       *aUserIdentity,
00111                                            nsIFileSpec          *aFileSpec, 
00112                                            nsMsgDeliverMode     aMode,
00113                                            nsIMsgSend           *aMsgSendObj,
00114                                            const char           *aSavePref,
00115                                            nsIMsgDBHdr          *aMsgToReplace);
00116 
00117   nsresult              DoCopy(nsIFileSpec *aDiskFile, nsIMsgFolder *dstFolder,
00118                                nsIMsgDBHdr *aMsgToReplace, PRBool aIsDraft,
00119                                nsIMsgWindow *msgWindow,
00120                                nsIMsgSend   *aMsgSendObj);
00121 
00122   nsresult    GetUnsentMessagesFolder(nsIMsgIdentity *userIdentity, nsIMsgFolder **msgFolder, PRBool *waitForUrl);
00123   nsresult    GetDraftsFolder(nsIMsgIdentity *userIdentity, nsIMsgFolder **msgFolder, PRBool *waitForUrl);
00124   nsresult    GetTemplatesFolder(nsIMsgIdentity *userIdentity, nsIMsgFolder **msgFolder, PRBool *waitForUrl);
00125   nsresult    GetSentFolder(nsIMsgIdentity *userIdentity,  nsIMsgFolder **msgFolder, PRBool *waitForUrl);
00126   nsresult   CreateIfMissing(nsIMsgFolder **folder, PRBool *waitForUrl);
00127 
00128   
00129   //
00130   // Vars for implementation...
00131   //
00132   nsIFileSpec                     *mFileSpec;     // the file we are sending...
00133   nsMsgDeliverMode                mMode;
00134   nsCOMPtr<CopyListener>          mCopyListener;
00135   nsCOMPtr<nsIMsgFolder>          mDstFolder;
00136   nsCOMPtr<nsIMsgDBHdr>           mMsgToReplace;
00137   PRBool                          mIsDraft;
00138   nsCOMPtr<nsIMsgSend>            mMsgSendObj;
00139   char                            *mSavePref;
00140 };
00141 
00142 // Useful function for the back end...
00143 nsresult      LocateMessageFolder(nsIMsgIdentity   *userIdentity, 
00144                                        nsMsgDeliverMode aFolderType,
00145                                        const char       *aSaveURI,
00146                                    nsIMsgFolder **msgFolder);
00147 
00148 nsresult      MessageFolderIsLocal(nsIMsgIdentity   *userIdentity, 
00149                                        nsMsgDeliverMode aFolderType,
00150                                        const char       *aSaveURI,
00151                                    PRBool        *aResult);
00152 
00153 #endif /* _nsMsgCopy_H_ */