Back to index

lightning-sunbird  0.9+nobinonly
nsImapMailFolder.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
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Lorenzo Colitti <lorenzo@colitti.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 #ifndef nsImapMailFolder_h__
00039 #define nsImapMailFolder_h__
00040 
00041 #include "nsImapCore.h"
00042 #include "nsMsgDBFolder.h"
00043 #include "nsIImapMailFolderSink.h"
00044 #include "nsIImapMessageSink.h"
00045 #include "nsICopyMessageListener.h"
00046 #include "nsIImapService.h"
00047 #include "nsIUrlListener.h"
00048 #include "nsAutoPtr.h"
00049 #include "nsIImapIncomingServer.h" // we need this for its IID
00050 #include "nsIMsgParseMailMsgState.h"
00051 #include "nsITransactionManager.h"
00052 #include "nsMsgTxn.h"
00053 #include "nsIMsgMessageService.h"
00054 #include "nsIMsgFilterHitNotify.h"
00055 #include "nsIMsgFilterList.h"
00056 #include "nsIMsgFilterPlugin.h"
00057 #include "prmon.h"
00058 #include "nsIEventQueue.h"
00059 #include "nsIMsgImapMailFolder.h"
00060 #include "nsIMsgLocalMailFolder.h"
00061 #include "nsIImapMailFolderSink.h"
00062 #include "nsIImapServerSink.h"
00063 #include "nsIMsgFilterPlugin.h"
00064 class nsImapMoveCoalescer;
00065 class nsHashtable;
00066 class nsHashKey;
00067 class nsIMsgIdentity;
00068 
00069 #define COPY_BUFFER_SIZE 16384
00070 
00071 /* b64534f0-3d53-11d3-ac2a-00805f8ac968 */
00072 
00073 #define NS_IMAPMAILCOPYSTATE_IID \
00074 { 0xb64534f0, 0x3d53, 0x11d3, \
00075     { 0xac, 0x2a, 0x00, 0x80, 0x5f, 0x8a, 0xc9, 0x68 } }
00076 
00077 class nsImapMailCopyState: public nsISupports
00078 {
00079 public:
00080     NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMAPMAILCOPYSTATE_IID)
00081     
00082     NS_DECL_ISUPPORTS
00083 
00084     nsImapMailCopyState();
00085     virtual ~nsImapMailCopyState();
00086 
00087     nsCOMPtr<nsISupports> m_srcSupport; // source file spec or folder
00088     nsCOMPtr<nsISupportsArray> m_messages; // array of source messages
00089     nsRefPtr<nsMsgTxn> m_undoMsgTxn; // undo object with this copy operation
00090     nsCOMPtr<nsIMsgDBHdr> m_message; // current message to be copied
00091     nsCOMPtr<nsIMsgCopyServiceListener> m_listener; // listener of this copy
00092                                                     // operation 
00093     nsCOMPtr<nsIFileSpec> m_tmpFileSpec; // temp file spec for copy operation
00094     nsCOMPtr<nsIMsgWindow> m_msgWindow; // msg window for copy operation
00095 
00096     nsCOMPtr<nsIMsgMessageService> m_msgService; // source folder message service; can
00097                                         // be Nntp, Mailbox, or Imap
00098     PRBool m_isMove;             // is a move
00099     PRBool m_selectedState;      // needs to be in selected state; append msg
00100     PRBool m_isCrossServerOp; // are we copying between imap servers?
00101     PRUint32 m_curIndex; // message index to the message array which we are
00102                          // copying 
00103     PRUint32 m_totalCount;// total count of messages we have to do
00104     PRUint32 m_unreadCount; // num unread messages we're moving
00105     PRBool m_streamCopy;
00106     char *m_dataBuffer; // temporary buffer for this copy operation
00107     nsCOMPtr<nsIOutputStream> m_msgFileStream;         // temporary file (processed mail)
00108     PRUint32 m_dataBufferSize;
00109     PRUint32 m_leftOver;
00110     PRBool m_allowUndo;
00111     PRBool m_eatLF;
00112     PRBool m_newMsgFlags; // only used if there's no m_message 
00113 };
00114 
00115 // ACLs for this folder.
00116 // Generally, we will try to always query this class when performing
00117 // an operation on the folder.
00118 // If the server doesn't support ACLs, none of this data will be filled in.
00119 // Therefore, we can assume that if we look up ourselves and don't find
00120 // any info (and also look up "anyone") then we have full rights, that is, ACLs don't exist.
00121 class nsImapMailFolder;
00122 
00123 #define IMAP_ACL_READ_FLAG 0x0000001 /* SELECT, CHECK, FETCH, PARTIAL, SEARCH, COPY from folder */
00124 #define IMAP_ACL_STORE_SEEN_FLAG 0x0000002 /* STORE SEEN flag */
00125 #define IMAP_ACL_WRITE_FLAG 0x0000004 /* STORE flags other than SEEN and DELETED */
00126 #define IMAP_ACL_INSERT_FLAG 0x0000008 /* APPEND, COPY into folder */
00127 #define IMAP_ACL_POST_FLAG 0x0000010 /* Can I send mail to the submission address for folder? */
00128 #define IMAP_ACL_CREATE_SUBFOLDER_FLAG 0x0000020 /* Can I CREATE a subfolder of this folder? */
00129 #define IMAP_ACL_DELETE_FLAG 0x0000040 /* STORE DELETED flag, perform EXPUNGE */
00130 #define IMAP_ACL_ADMINISTER_FLAG 0x0000080 /* perform SETACL */
00131 #define IMAP_ACL_RETRIEVED_FLAG 0x0000100 /* ACL info for this folder has been initialized */
00132 
00133 class nsMsgIMAPFolderACL
00134 {
00135 public:
00136   nsMsgIMAPFolderACL(nsImapMailFolder *folder);
00137   ~nsMsgIMAPFolderACL();
00138   
00139   PRBool SetFolderRightsForUser(const char *userName, const char *rights);
00140   
00141 public:
00142   
00143   // generic for any user, although we might not use them in
00144   // DO NOT use these for looking up information about the currently authenticated user.
00145   // (There are some different checks and defaults we do).
00146   // Instead, use the functions below, GetICan....()
00147   PRBool GetCanUserLookupFolder(const char *userName);         // Is folder visible to LIST/LSUB?
00148   PRBool GetCanUserReadFolder(const char *userName);                  // SELECT, CHECK, FETCH, PARTIAL, SEARCH, COPY from folder?
00149   PRBool GetCanUserStoreSeenInFolder(const char *userName);    // STORE SEEN flag?
00150   PRBool GetCanUserWriteFolder(const char *userName);          // STORE flags other than SEEN and DELETED?
00151   PRBool GetCanUserInsertInFolder(const char *userName);              // APPEND, COPY into folder?
00152   PRBool GetCanUserPostToFolder(const char *userName);         // Can I send mail to the submission address for folder?
00153   PRBool GetCanUserCreateSubfolder(const char *userName);      // Can I CREATE a subfolder of this folder?
00154   PRBool GetCanUserDeleteInFolder(const char *userName);              // STORE DELETED flag, perform EXPUNGE?
00155   PRBool GetCanUserAdministerFolder(const char *userName);     // perform SETACL?
00156   
00157   // Functions to find out rights for the currently authenticated user.
00158   
00159   PRBool GetCanILookupFolder();           // Is folder visible to LIST/LSUB?
00160   PRBool GetCanIReadFolder();             // SELECT, CHECK, FETCH, PARTIAL, SEARCH, COPY from folder?
00161   PRBool GetCanIStoreSeenInFolder();      // STORE SEEN flag?
00162   PRBool GetCanIWriteFolder();            // STORE flags other than SEEN and DELETED?
00163   PRBool GetCanIInsertInFolder();  // APPEND, COPY into folder?
00164   PRBool GetCanIPostToFolder();           // Can I send mail to the submission address for folder?
00165   PRBool GetCanICreateSubfolder(); // Can I CREATE a subfolder of this folder?
00166   PRBool GetCanIDeleteInFolder();  // STORE DELETED flag, perform EXPUNGE?
00167   PRBool GetCanIAdministerFolder();       // perform SETACL?
00168   
00169   PRBool GetDoIHaveFullRightsForFolder(); // Returns TRUE if I have full rights on this folder (all of the above return TRUE)
00170   
00171   PRBool GetIsFolderShared();             // We use this to see if the ACLs think a folder is shared or not.
00172   // We will define "Shared" in 5.0 to mean:
00173   // At least one user other than the currently authenticated user has at least one
00174   // explicitly-listed ACL right on that folder.
00175   
00176   // Returns a newly allocated string describing these rights
00177   nsresult CreateACLRightsString(PRUnichar **rightsString);
00178   
00179 protected:
00180   const char *GetRightsStringForUser(const char *userName);
00181   PRBool GetFlagSetInRightsForUser(const char *userName, char flag, PRBool defaultIfNotFound);
00182   void BuildInitialACLFromCache();
00183   void UpdateACLCache();
00184   static PRBool PR_CALLBACK FreeHashRights(nsHashKey *aKey, void *aData, void *closure);
00185   
00186 protected:
00187   nsHashtable    *m_rightsHash;    // Hash table, mapping username strings to rights strings.
00188   nsImapMailFolder *m_folder;
00189   PRInt32        m_aclCount;
00190   
00191 };
00192 
00193 
00194 
00195 class nsImapMailFolder :  public nsMsgDBFolder, 
00196                           public nsIMsgImapMailFolder,
00197                           public nsIImapMailFolderSink,
00198                           public nsIImapMessageSink,
00199                           public nsICopyMessageListener,
00200                           public nsIMsgFilterHitNotify,
00201                           public nsIJunkMailClassificationListener
00202 {
00203 public:
00204   nsImapMailFolder();
00205   virtual ~nsImapMailFolder();
00206   
00207   NS_DECL_ISUPPORTS_INHERITED
00208     
00209   // nsICollection methods
00210   NS_IMETHOD Enumerate(nsIEnumerator **result);
00211   
00212   // nsIMsgFolder methods:
00213   NS_IMETHOD GetSubFolders(nsIEnumerator* *result);
00214   
00215   NS_IMETHOD GetMessages(nsIMsgWindow *aMsgWindow, nsISimpleEnumerator* *result);
00216   NS_IMETHOD UpdateFolder(nsIMsgWindow *aWindow);
00217   
00218   NS_IMETHOD CreateSubfolder(const PRUnichar *folderName,nsIMsgWindow *msgWindow );
00219   NS_IMETHOD AddSubfolder(const nsAString& aName, nsIMsgFolder** aChild);
00220   NS_IMETHOD AddSubfolderWithPath(nsAString& name, nsIFileSpec *dbPath, nsIMsgFolder **child);
00221   NS_IMETHODIMP CreateStorageIfMissing(nsIUrlListener* urlListener);
00222   
00223   NS_IMETHOD Compact(nsIUrlListener *aListener, nsIMsgWindow *aMsgWindow);
00224   NS_IMETHOD CompactAll(nsIUrlListener *aListener, nsIMsgWindow *aMsgWindow, nsISupportsArray *aFolderArray, PRBool aCompactOfflineAlso, nsISupportsArray *aOfflineFolderArray);
00225   NS_IMETHOD EmptyTrash(nsIMsgWindow *msgWindow, nsIUrlListener *aListener);
00226   NS_IMETHOD CopyDataToOutputStreamForAppend(nsIInputStream *aIStream,
00227                      PRInt32 aLength, nsIOutputStream *outputStream);
00228   NS_IMETHOD CopyDataDone();
00229   NS_IMETHOD Delete ();
00230   NS_IMETHOD Rename (const PRUnichar *newName, nsIMsgWindow *msgWindow);
00231   NS_IMETHOD RenameSubFolders(nsIMsgWindow *msgWindow, nsIMsgFolder *oldFolder);
00232   NS_IMETHOD GetNoSelect(PRBool *aResult);
00233   
00234   NS_IMETHOD GetPrettyName(PRUnichar ** prettyName);    // Override of the base, for top-level mail folder
00235   
00236   NS_IMETHOD GetFolderURL(char **url);
00237   
00238   NS_IMETHOD UpdateSummaryTotals(PRBool force) ;
00239   
00240   NS_IMETHOD GetDeletable (PRBool *deletable); 
00241   NS_IMETHOD GetRequiresCleanup(PRBool *requiresCleanup);
00242   
00243   NS_IMETHOD GetSizeOnDisk(PRUint32 * size);
00244   
00245   NS_IMETHOD GetCanCreateSubfolders(PRBool *aResult);
00246   NS_IMETHOD GetCanSubscribe(PRBool *aResult);   
00247   
00248   NS_IMETHOD AddMessageDispositionState(nsIMsgDBHdr *aMessage, nsMsgDispositionState aDispositionFlag);
00249   NS_IMETHOD MarkMessagesRead(nsISupportsArray *messages, PRBool markRead);
00250   NS_IMETHOD MarkAllMessagesRead(void);
00251   NS_IMETHOD MarkMessagesFlagged(nsISupportsArray *messages, PRBool markFlagged);
00252   NS_IMETHOD MarkThreadRead(nsIMsgThread *thread);
00253   NS_IMETHOD SetLabelForMessages(nsISupportsArray *aMessages, nsMsgLabelValue aLabel);
00254   NS_IMETHOD SetJunkScoreForMessages(nsISupportsArray *aMessages, const char *aJunkScore);
00255   NS_IMETHOD DeleteSubFolders(nsISupportsArray *folders, nsIMsgWindow *msgWindow);
00256   NS_IMETHOD ReadFromFolderCacheElem(nsIMsgFolderCacheElement *element);
00257   NS_IMETHOD WriteToFolderCacheElem(nsIMsgFolderCacheElement *element);
00258   
00259   NS_IMETHOD GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInfo,
00260                                   nsIMsgDatabase **db);
00261   NS_IMETHOD DeleteMessages(nsISupportsArray *messages,
00262                             nsIMsgWindow *msgWindow, PRBool
00263                             deleteStorage, PRBool isMove,
00264                             nsIMsgCopyServiceListener* listener, PRBool allowUndo);
00265   NS_IMETHOD CopyMessages(nsIMsgFolder *srcFolder, 
00266                           nsISupportsArray* messages,
00267                           PRBool isMove, nsIMsgWindow *msgWindow,
00268                           nsIMsgCopyServiceListener* listener, PRBool isFolder, 
00269                           PRBool allowUndo);
00270   NS_IMETHOD CopyFolder(nsIMsgFolder *srcFolder, PRBool isMove, nsIMsgWindow *msgWindow,
00271                         nsIMsgCopyServiceListener* listener);
00272   NS_IMETHOD CopyFileMessage(nsIFileSpec* fileSpec, 
00273                               nsIMsgDBHdr* msgToReplace,
00274                               PRBool isDraftOrTemplate,
00275                               PRUint32 aNewMsgFlags,
00276                               nsIMsgWindow *msgWindow,
00277                               nsIMsgCopyServiceListener* listener);
00278   NS_IMETHOD GetNewMessages(nsIMsgWindow *aWindow, nsIUrlListener *aListener);
00279   
00280   NS_IMETHOD GetPath(nsIFileSpec** aPathName);
00281   NS_IMETHOD SetPath(nsIFileSpec * aPath);
00282   
00283   NS_IMETHOD Shutdown(PRBool shutdownChildren);
00284   
00285   NS_IMETHOD DownloadMessagesForOffline(nsISupportsArray *messages, nsIMsgWindow *msgWindow);
00286   
00287   NS_IMETHOD DownloadAllForOffline(nsIUrlListener *listener, nsIMsgWindow *msgWindow);
00288   NS_IMETHOD GetCanFileMessages(PRBool *aCanFileMessages);
00289   NS_IMETHOD GetCanDeleteMessages(PRBool *aCanDeleteMessages);
00290   NS_IMETHOD FetchMsgPreviewText(nsMsgKey *aKeysToFetch, PRUint32 aNumKeys,
00291                                                  PRBool aLocalOnly, nsIUrlListener *aUrlListener, 
00292                                                  PRBool *aAsyncResults);
00293 
00294   NS_IMETHOD AddKeywordsToMessages(nsISupportsArray *aMessages, const char *aKeywords);
00295   NS_IMETHOD RemoveKeywordsFromMessages(nsISupportsArray *aMessages, const char *aKeywords);
00296 
00297   // nsIMsgImapMailFolder methods
00298   NS_DECL_NSIMSGIMAPMAILFOLDER
00299           
00300   // nsIImapMailFolderSink methods
00301   NS_DECL_NSIIMAPMAILFOLDERSINK
00302   
00303   // nsIImapMessageSink methods
00304   NS_DECL_NSIIMAPMESSAGESINK
00305   
00306   //nsICopyMessageListener
00307   NS_DECL_NSICOPYMESSAGELISTENER
00308   
00309   NS_DECL_NSIREQUESTOBSERVER
00310   
00311   // nsIUrlListener methods
00312   NS_IMETHOD OnStartRunningUrl(nsIURI * aUrl);
00313   NS_IMETHOD OnStopRunningUrl(nsIURI * aUrl, nsresult aExitCode);
00314   
00315   // nsIImapMiscellaneousSink methods
00316   NS_IMETHOD AddSearchResult(nsIImapProtocol* aProtocol, 
00317                               const char* searchHitLine);
00318   NS_IMETHOD MatchName(nsString *name, PRBool *matches);
00319   
00320   NS_DECL_NSIMSGFILTERHITNOTIFY
00321   NS_DECL_NSIJUNKMAILCLASSIFICATIONLISTENER
00322   
00323   NS_IMETHOD IsCommandEnabled(const char *command, PRBool *result);
00324   NS_IMETHOD SetFilterList(nsIMsgFilterList *aMsgFilterList);
00325   NS_IMETHOD GetCustomIdentity(nsIMsgIdentity **aIdentity);
00326         
00327   nsresult MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr, 
00328                                   nsIMsgDatabase *sourceDB, 
00329                                   const nsACString& destFolder,
00330                                   nsIMsgFilter *filter,
00331                                   nsIMsgWindow *msgWindow);
00332   virtual nsresult SpamFilterClassifyMessage(const char *aURI, nsIMsgWindow *aMsgWindow, nsIJunkMailPlugin *aJunkMailPlugin);
00333   virtual nsresult SpamFilterClassifyMessages(const char **aURIArray, PRUint32 aURICount, nsIMsgWindow *aMsgWindow, nsIJunkMailPlugin *aJunkMailPlugin);
00334   
00335   static nsresult  AllocateUidStringFromKeys(nsMsgKey *keys, PRUint32 numKeys, nsCString &msgIds);
00336 
00337   // these might end up as an nsIImapMailFolder attribute.
00338   nsresult SetSupportedUserFlags(PRUint32 userFlags);
00339   nsresult GetSupportedUserFlags(PRUint32 *userFlags);
00340 protected:
00341   // Helper methods
00342   
00343   void FindKeysToAdd(const nsMsgKeyArray &existingKeys, nsMsgKeyArray
00344     &keysToFetch, PRUint32 &numNewUnread, nsIImapFlagAndUidState *flagState);
00345   void FindKeysToDelete(const nsMsgKeyArray &existingKeys, nsMsgKeyArray
00346     &keysToFetch, nsIImapFlagAndUidState *flagState);
00347   void PrepareToAddHeadersToMailDB(nsIImapProtocol* aProtocol, const
00348     nsMsgKeyArray &keysToFetch, 
00349     nsIMailboxSpec *boxSpec);
00350   void TweakHeaderFlags(nsIImapProtocol* aProtocol, nsIMsgDBHdr *tweakMe);
00351   
00352   nsresult SyncFlags(nsIImapFlagAndUidState *flagState);
00353   nsresult HandleCustomFlags(nsMsgKey uidOfMessage, nsIMsgDBHdr *dbHdr, nsXPIDLCString &keywords);
00354   nsresult NotifyMessageFlagsFromHdr(nsIMsgDBHdr *dbHdr, nsMsgKey msgKey, PRUint32 flags);
00355   
00356   nsresult SetupHeaderParseStream(PRUint32 size, const char *content_type, nsIMailboxSpec *boxSpec);
00357   nsresult  ParseAdoptedHeaderLine(const char *messageLine, PRUint32 msgKey);
00358   nsresult  NormalEndHeaderParseStream(nsIImapProtocol *aProtocol, nsIImapUrl *imapUrl);
00359   
00360   void EndOfflineDownload();
00361 
00362   nsresult MarkMessagesImapDeleted(nsMsgKeyArray *keyArray, PRBool deleted, nsIMsgDatabase *db);
00363   
00364   void UpdatePendingCounts();
00365   void SetIMAPDeletedFlag(nsIMsgDatabase *mailDB, const nsMsgKeyArray &msgids, PRBool markDeleted);
00366   virtual PRBool ShowDeletedMessages();
00367   virtual PRBool DeleteIsMoveToTrash();
00368   nsresult GetFolder(const char *name, nsIMsgFolder **pFolder);
00369   nsresult GetTrashFolder(nsIMsgFolder **pTrashFolder);
00370   PRBool TrashOrDescendentOfTrash(nsIMsgFolder* folder);
00371   nsresult GetServerKey(char **serverKey);
00372   nsresult GetImapIncomingServer(nsIImapIncomingServer **aImapIncomingServer);
00373   
00374   nsresult DisplayStatusMsg(nsIImapUrl *aImapUrl, const PRUnichar *msg);
00375   
00376   //nsresult RenameLocal(const char *newName);
00377   nsresult AddDirectorySeparator(nsFileSpec &path);
00378   nsresult CreateSubFolders(nsFileSpec &path);
00379   nsresult GetDatabase(nsIMsgWindow *aMsgWindow);
00380   virtual const char *GetIncomingServerType() {return "imap";}
00381   
00382   nsresult        GetFolderOwnerUserName(char **userName);
00383   nsresult        GetOwnersOnlineFolderName(char **onlineName);
00384   nsIMAPNamespace *GetNamespaceForFolder();
00385   void            SetNamespaceForFolder(nsIMAPNamespace *ns);
00386   
00387   nsresult GetServerAdminUrl(char **aAdminUrl);
00388   nsMsgIMAPFolderACL * GetFolderACL();
00389   nsresult CreateACLRightsStringForFolder(PRUnichar **rightsString);
00390   
00391   nsresult GetBodysToDownload(nsMsgKeyArray *keysOfMessagesToDownload);
00392   // Uber message copy service
00393   nsresult CopyMessagesWithStream(nsIMsgFolder* srcFolder,
00394                                     nsISupportsArray* messages,
00395                                     PRBool isMove,
00396                                     PRBool isCrossServerOp,
00397                                     nsIMsgWindow *msgWindow,
00398                                     nsIMsgCopyServiceListener* listener, PRBool allowUndo);
00399   nsresult CopyStreamMessage(nsIMsgDBHdr* message, nsIMsgFolder* dstFolder,
00400                             nsIMsgWindow *msgWindow, PRBool isMove);
00401   nsresult InitCopyState(nsISupports* srcSupport, 
00402                           nsISupportsArray* messages,
00403                           PRBool isMove,
00404                           PRBool selectedState,
00405                           PRBool acrossServers,
00406                           PRUint32 newMsgFlags,
00407                           nsIMsgCopyServiceListener* listener,
00408                           nsIMsgWindow *msgWindow,
00409                           PRBool allowUndo);
00410   nsresult OnCopyCompleted(nsISupports *srcSupport, nsresult exitCode);
00411   nsresult BuildIdsAndKeyArray(nsISupportsArray* messages,
00412     nsCString& msgIds, nsMsgKeyArray& keyArray);
00413   
00414   nsresult GetMoveCoalescer();
00415   nsresult PlaybackCoalescedOperations();
00416   virtual nsresult CreateBaseMessageURI(const char *aURI);
00417   // offline-ish methods
00418   nsresult GetClearedOriginalOp(nsIMsgOfflineImapOperation *op, nsIMsgOfflineImapOperation **originalOp, 
00419     nsIMsgDatabase **originalDB);
00420   nsresult GetOriginalOp(nsIMsgOfflineImapOperation *op, 
00421     nsIMsgOfflineImapOperation **originalOp, nsIMsgDatabase **originalDB);
00422   nsresult CopyMessagesOffline(nsIMsgFolder* srcFolder,
00423                                 nsISupportsArray* messages,
00424                                 PRBool isMove,
00425                                 nsIMsgWindow *msgWindow,
00426                                 nsIMsgCopyServiceListener* listener);
00427   
00428   nsresult CopyOfflineMsgBody(nsIMsgFolder *srcFolder, nsIMsgDBHdr *destHdr, nsIMsgDBHdr *origHdr);
00429   
00430   void GetTrashFolderName(nsAString &aFolderName);
00431   PRBool ShowPreviewText();
00432   
00433   PRBool m_initialized;
00434   PRBool m_haveDiscoveredAllFolders;
00435   PRBool m_haveReadNameFromDB;
00436   nsCOMPtr<nsIMsgParseMailMsgState> m_msgParser;
00437   nsCOMPtr<nsIMsgFilterList> m_filterList;
00438   nsCOMPtr<nsIMsgFilterPlugin> m_filterPlugin;  // XXX should be a list
00439   // used with filter plugins to know when we've finished classifying and can playback moves
00440   PRInt32 m_numFilterClassifyRequests;
00441   PRBool m_msgMovedByFilter;
00442   nsImapMoveCoalescer *m_moveCoalescer; // strictly owned by the nsImapMailFolder
00443   nsCOMPtr <nsISupportsArray> m_junkMessagesToMarkAsRead;
00444   nsMsgKey m_curMsgUid;
00445   PRUint32 m_uidValidity;
00446   PRInt32 m_numStatusRecentMessages; // used to store counts from Status command
00447   PRInt32 m_numStatusUnseenMessages;
00448   PRInt32  m_nextMessageByteLength;
00449   nsCOMPtr<nsIEventQueue> m_eventQueue;
00450   nsCOMPtr<nsIUrlListener> m_urlListener;
00451   PRBool m_urlRunning;
00452   
00453   // *** jt - undo move/copy trasaction support
00454   nsRefPtr<nsMsgTxn> m_pendingUndoTxn;
00455   nsCOMPtr<nsImapMailCopyState> m_copyState;
00456   PRMonitor *m_appendMsgMonitor;
00457   PRUnichar m_hierarchyDelimiter;
00458   PRInt32 m_boxFlags;
00459   nsCString m_onlineFolderName;
00460   nsFileSpec *m_pathName;
00461   nsCString m_ownerUserName;  // username of the "other user," as in
00462   // "Other Users' Mailboxes"
00463   
00464   nsCString m_adminUrl;   // url to run to set admin privileges for this folder
00465   nsIMAPNamespace  *m_namespace;   
00466   PRPackedBool m_verifiedAsOnlineFolder;
00467   PRPackedBool m_explicitlyVerify; // whether or not we need to explicitly verify this through LIST
00468   PRPackedBool m_folderIsNamespace;
00469   PRPackedBool m_folderNeedsSubscribing;
00470   PRPackedBool m_folderNeedsAdded;
00471   PRPackedBool m_folderNeedsACLListed;
00472   PRPackedBool m_performingBiff;
00473   PRPackedBool m_folderQuotaCommandIssued;
00474   PRPackedBool m_folderQuotaDataIsValid;
00475   PRPackedBool m_updatingFolder;
00476   nsMsgIMAPFolderACL *m_folderACL;
00477   PRUint32     m_aclFlags;
00478   PRUint32     m_supportedUserFlags;
00479 
00480   nsCOMPtr<nsISupports> mSupportsToRelease;
00481   
00482   static nsIAtom* mImapHdrDownloadedAtom;
00483   
00484   // offline imap support
00485   PRBool m_downloadMessageForOfflineUse;
00486   PRBool m_downloadingFolderForOfflineUse;
00487   
00488   // Quota support
00489   nsCString m_folderQuotaRoot;
00490   PRUint32 m_folderQuotaUsedKB;
00491   PRUint32 m_folderQuotaMaxKB;
00492 };
00493 
00494 
00495 
00496 #endif