Back to index

lightning-sunbird  0.9+nobinonly
nsMsgIncomingServer.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; 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  *   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 nsMsgIncomingServer_h__
00040 #define nsMsgIncomingServer_h__
00041 
00042 #include "nsIMsgIncomingServer.h"
00043 #include "nsIPrefBranch.h"
00044 #include "nsIMsgFilterList.h"
00045 #include "msgCore.h"
00046 #include "nsIMsgFolder.h"
00047 #include "nsCOMPtr.h"
00048 #include "nsWeakReference.h"
00049 #include "nsIMsgDatabase.h"
00050 #include "nsIFileSpec.h"
00051 #include "nsISpamSettings.h"
00052 #include "nsIMsgFilterPlugin.h"
00053 #include "nsHashtable.h"
00054 
00055 class nsIMsgFolderCache;
00056 class nsIMsgProtocolInfo;
00057 
00058 /*
00059  * base class for nsIMsgIncomingServer - derive your class from here
00060  * if you want to get some free implementation
00061  * 
00062  * this particular implementation is not meant to be used directly.
00063  */
00064 
00065 #undef  IMETHOD_VISIBILITY
00066 #define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT
00067 
00068 class NS_MSG_BASE nsMsgIncomingServer : public nsIMsgIncomingServer,
00069                                         public nsSupportsWeakReference
00070 {
00071  public:
00072   nsMsgIncomingServer();
00073   virtual ~nsMsgIncomingServer();
00074 
00075   NS_DECL_ISUPPORTS
00076   NS_DECL_NSIMSGINCOMINGSERVER
00077 
00078 protected:
00079   nsCString m_serverKey;
00080   void getPrefName(const char *serverKey, const char *pref, nsCString& fullPrefName);
00081   void getDefaultPrefName(const char *pref, nsCString& fullPrefName);
00082 
00083   nsresult ConfigureTemporaryReturnReceiptsFilter(nsIMsgFilterList *filterList);
00084   nsresult ConfigureTemporaryServerSpamFilters(nsIMsgFilterList *filterList);
00085 
00086   // these are private pref getters and setters for the password
00087   // field. Callers should be using Get/Set Password
00088   NS_IMETHOD GetPrefPassword(char * *aPassword);
00089   NS_IMETHOD SetPrefPassword(const char * aPassword);
00090   PRBool     PasswordProtectLocalCache();
00091   
00092   nsCOMPtr <nsIMsgFolder> m_rootFolder;
00093   nsCOMPtr <nsIMsgRetentionSettings> m_retentionSettings;
00094   nsCOMPtr <nsIMsgDownloadSettings> m_downloadSettings;
00095   nsresult getDefaultCharPref(const char *pref, char **);
00096   nsresult getDefaultUnicharPref(const char *pref, PRUnichar **);
00097   nsresult getDefaultBoolPref(const char *pref, PRBool *);
00098   nsresult getDefaultIntPref(const char *pref, PRInt32 *);
00099   
00100   nsresult CreateLocalFolder(nsIFileSpec *path, const char *folderName);
00101   nsresult GetDeferredServers(nsIMsgIncomingServer *server, nsISupportsArray **_retval);
00102 
00103   nsresult CreateRootFolder();
00104 
00105   nsresult InternalSetHostName(const char *aHostname, const char *prefName);
00106 
00107   nsresult getProtocolInfo(nsIMsgProtocolInfo **aResult);
00108   nsCOMPtr <nsIFileSpec> mFilterFile;
00109   nsCOMPtr <nsIMsgFilterList> mFilterList;
00110   // these allow us to handle duplicate incoming messages, e.g. delete them.
00111   nsHashtable m_downloadedHdrs;
00112   PRInt32  m_numMsgsDownloaded;
00113   nsIPrefBranch *m_prefBranch;
00114 static PRBool evictOldEntries(nsHashKey *aKey, void *element, void *aData);
00115 private:
00116   nsCString m_password;
00117   PRUint32 m_biffState;
00118   PRPackedBool m_serverBusy;
00119   nsCOMPtr <nsISpamSettings> mSpamSettings;
00120   nsCOMPtr<nsIMsgFilterPlugin> mFilterPlugin;  // XXX should be a list
00121 
00122 protected:
00123   PRPackedBool m_canHaveFilters;
00124   PRPackedBool m_displayStartupPage;
00125   PRPackedBool mPerformingBiff;
00126 };
00127 
00128 #undef  IMETHOD_VISIBILITY
00129 #define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
00130 
00131 #endif // nsMsgIncomingServer_h__