Back to index

lightning-sunbird  0.9+nobinonly
nsImapIncomingServer.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  *   Seth Spitzer <sspitzer@netscape.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 
00039 #ifndef __nsImapIncomingServer_h
00040 #define __nsImapIncomingServer_h
00041 
00042 #include "msgCore.h"
00043 #include "nsIImapIncomingServer.h"
00044 #include "nsISupportsArray.h"
00045 #include "nsMsgIncomingServer.h"
00046 #include "nsIImapServerSink.h"
00047 #include "nsIStringBundle.h"
00048 #include "nsIMsgLogonRedirector.h"
00049 #include "nsISubscribableServer.h"
00050 #include "nsIUrlListener.h"
00051 #include "nsAdapterEnumerator.h"
00052 #include "nsIMsgImapMailFolder.h"
00053 #include "nsCOMArray.h"
00054 /* get some implementation from nsMsgIncomingServer */
00055 class nsImapIncomingServer : public nsMsgIncomingServer,
00056                              public nsIImapIncomingServer,
00057                                                                public nsIImapServerSink,
00058                                                                public nsIMsgLogonRedirectionRequester,
00059                                                                         public nsISubscribableServer,
00060                                                                         public nsIUrlListener
00061                              
00062 {
00063 public:
00064     NS_DECL_ISUPPORTS_INHERITED
00065 
00066     nsImapIncomingServer();
00067     virtual ~nsImapIncomingServer();
00068 
00069     // overriding nsMsgIncomingServer methods
00070        NS_IMETHOD SetKey(const char * aKey);  // override nsMsgIncomingServer's implementation...
00071        NS_IMETHOD GetLocalStoreType(char * *type);
00072 
00073        NS_DECL_NSIIMAPINCOMINGSERVER
00074        NS_DECL_NSIIMAPSERVERSINK
00075        NS_DECL_NSIMSGLOGONREDIRECTIONREQUESTER
00076   NS_DECL_NSISUBSCRIBABLESERVER
00077        NS_DECL_NSIURLLISTENER
00078 
00079        NS_IMETHOD PerformBiff(nsIMsgWindow *aMsgWindow);
00080        NS_IMETHOD PerformExpand(nsIMsgWindow *aMsgWindow);
00081   NS_IMETHOD CloseCachedConnections();
00082   NS_IMETHOD GetConstructedPrettyName(PRUnichar **retval);
00083   NS_IMETHOD GetCanBeDefaultServer(PRBool *canBeDefaultServer);
00084   NS_IMETHOD GetCanCompactFoldersOnServer(PRBool *canCompactFoldersOnServer);
00085   NS_IMETHOD GetCanUndoDeleteOnServer(PRBool *canUndoDeleteOnServer);
00086   NS_IMETHOD GetCanSearchMessages(PRBool *canSearchMessages);
00087   NS_IMETHOD GetCanEmptyTrashOnExit(PRBool *canEmptyTrashOnExit);
00088   NS_IMETHOD GetIsSecureServer(PRBool *isSecureServer);
00089   NS_IMETHOD GetOfflineSupportLevel(PRInt32 *aSupportLevel);
00090   NS_IMETHOD GeneratePrettyNameForMigration(PRUnichar **aPrettyName);
00091   NS_IMETHOD GetSupportsDiskSpace(PRBool *aSupportsDiskSpace);
00092   NS_IMETHOD GetCanCreateFoldersOnServer(PRBool *aCanCreateFoldersOnServer);
00093   NS_IMETHOD GetCanFileMessagesOnServer(PRBool *aCanFileMessagesOnServer);
00094   NS_IMETHOD GetFilterScope(nsMsgSearchScopeValue *filterScope);
00095   NS_IMETHOD GetSearchScope(nsMsgSearchScopeValue *searchScope);
00096   NS_IMETHOD GetServerRequiresPasswordForBiff(PRBool *aServerRequiresPasswordForBiff);
00097   NS_IMETHOD OnUserOrHostNameChanged(const char *oldName, const char *newName);
00098   NS_IMETHOD GetNumIdleConnections(PRInt32 *aNumIdleConnections);
00099   NS_IMETHOD ForgetSessionPassword();
00100   NS_IMETHOD GetMsgFolderFromURI(nsIMsgFolder *aFolderResource, const char *aURI, nsIMsgFolder **aFolder);
00101   NS_IMETHOD SetSocketType(PRInt32 aSocketType);
00102 
00103 protected:
00104        nsresult GetFolder(const char* name, nsIMsgFolder** pFolder);
00105   nsresult ResetFoldersToUnverified(nsIMsgFolder *parentFolder);
00106   nsresult GetUnverifiedSubFolders(nsIMsgFolder *parentFolder, nsISupportsArray *aFoldersArray, PRInt32 *aNumUnverifiedFolders);
00107        nsresult GetUnverifiedFolders(nsISupportsArray *aFolderArray, PRInt32 *aNumUnverifiedFolders);
00108 
00109   nsresult DeleteNonVerifiedFolders(nsIMsgFolder *parentFolder);
00110   PRBool NoDescendentsAreVerified(nsIMsgFolder *parentFolder);
00111   PRBool AllDescendentsAreNoSelect(nsIMsgFolder *parentFolder);
00112 
00113   nsresult GetStringBundle();
00114   const char *GetPFCName();
00115   nsresult GetPFCForStringId(PRBool createIfMissing, PRInt32 stringId, nsIMsgFolder **aFolder);
00116 private:
00117   nsresult SubscribeToFolder(const PRUnichar *aName, PRBool subscribe);
00118   nsresult GetImapConnection (nsIEventQueue* aEventQueue,
00119                                    nsIImapUrl* aImapUrl,
00120                                    nsIImapProtocol** aImapConnection);
00121   nsresult CreateProtocolInstance(nsIEventQueue *aEventQueue, 
00122                                            nsIImapProtocol ** aImapConnection);
00123   nsresult RequestOverrideInfo(nsIMsgWindow *aMsgWindow);
00124   nsresult CreateHostSpecificPrefName(const char *prefPrefix, nsCAutoString &prefName);
00125 
00126   nsresult DoomUrlIfChannelHasError(nsIImapUrl *aImapUrl, PRBool *urlDoomed);
00127   PRBool ConnectionTimeOut(nsIImapProtocol* aImapConnection);
00128   nsresult GetFormattedStringFromID(const PRUnichar *aValue, PRInt32 aID, PRUnichar **aResult);  
00129   nsresult CreatePrefNameWithRedirectorType(const char *prefSuffix, nsCAutoString &prefName);
00130   nsresult GetPrefForServerAttribute(const char *prefSuffix, PRBool *prefValue);
00131 
00132   nsCOMPtr<nsISupportsArray> m_connectionCache;
00133   nsCOMPtr<nsISupportsArray> m_urlQueue;
00134        nsCOMPtr<nsIStringBundle>   m_stringBundle;
00135   nsCOMArray<nsIMsgFolder> m_subscribeFolders; // used to keep folder resources around while subscribe UI is up.
00136   nsCOMArray<nsIMsgImapMailFolder> m_foldersToStat; // folders to check for new mail with Status
00137   nsVoidArray       m_urlConsumers;
00138   PRUint32          m_capability;
00139   nsCString         m_manageMailAccountUrl;
00140   PRPackedBool      m_readPFCName;
00141   PRPackedBool      m_readRedirectorType;
00142   PRPackedBool      m_userAuthenticated;
00143   PRPackedBool           m_waitingForConnectionInfo;
00144   PRPackedBool           mDoingSubscribeDialog;
00145   PRPackedBool           mDoingLsub;
00146   PRPackedBool      m_shuttingDown;
00147   nsCString         m_pfcName;
00148   nsCString         m_redirectorType;
00149   PRInt32                                        m_redirectedLogonRetries;
00150   nsCOMPtr<nsIMsgLogonRedirector> m_logonRedirector;
00151   
00152   // subscribe dialog stuff
00153   nsresult AddFolderToSubscribeDialog(const char *parentUri, const char *uri,const char *folderName);
00154 
00155   nsCOMPtr <nsISubscribableServer> mInner;
00156     nsresult EnsureInner();
00157     nsresult ClearInner();
00158 };
00159 
00160 
00161 #endif