Back to index

lightning-sunbird  0.9+nobinonly
nsIMAPHostSessionList.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) 1999
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 _nsIMAPHostSessionList_H_
00039 #define _nsIMAPHostSessionList_H_
00040 
00041 #include "nsImapCore.h"
00042 #include "nsIIMAPHostSessionList.h"
00043 #include "nsIObserver.h"
00044 #include "nsWeakReference.h"
00045 #include "nspr.h"
00046 
00047 class nsIMAPNamespaceList;
00048 class nsIImapIncomingServer;
00049 
00050 class nsIMAPHostInfo
00051 {
00052 public:
00053        friend class nsIMAPHostSessionList;
00054 
00055        nsIMAPHostInfo(const char *serverKey, nsIImapIncomingServer *server);
00056        ~nsIMAPHostInfo();
00057 protected:
00058        char                 *fServerKey;
00059        char                 *fCachedPassword;
00060        char                 *fOnlineDir;
00061        nsIMAPHostInfo       *fNextHost;
00062        PRUint32             fCapabilityFlags;
00063        char                 *fHierarchyDelimiters;      // string of top-level hierarchy delimiters
00064        PRBool               fHaveWeEverDiscoveredFolders;
00065        char                 *fCanonicalOnlineSubDir;
00066        nsIMAPNamespaceList                *fNamespaceList, *fTempNamespaceList;
00067        PRBool               fNamespacesOverridable;
00068        PRBool               fUsingSubscription;
00069        PRBool               fOnlineTrashFolderExists;
00070        PRBool               fShouldAlwaysListInbox;
00071        PRBool               fHaveAdminURL;
00072        PRBool               fPasswordVerifiedOnline;
00073        PRBool               fDeleteIsMoveToTrash;
00074        PRBool               fShowDeletedMessages;
00075        PRBool               fGotNamespaces;
00076        nsIMAPBodyShellCache *fShellCache;
00077 };
00078 
00079 // this is an interface to a linked list of host info's    
00080 class nsIMAPHostSessionList : public nsIImapHostSessionList, public nsIObserver, public nsSupportsWeakReference
00081 {
00082 public:
00083 
00084        NS_DECL_ISUPPORTS
00085   NS_DECL_NSIOBSERVER  
00086 
00087        nsIMAPHostSessionList();
00088        virtual ~nsIMAPHostSessionList();
00089   nsresult Init();
00090        // Host List
00091         NS_IMETHOD   AddHostToList(const char *serverKey, 
00092                               nsIImapIncomingServer *server);
00093         NS_IMETHOD ResetAll();
00094 
00095        // Capabilities
00096         NS_IMETHOD   GetCapabilityForHost(const char *serverKey, PRUint32 &result);
00097         NS_IMETHOD   SetCapabilityForHost(const char *serverKey, PRUint32 capability);
00098         NS_IMETHOD   GetHostHasAdminURL(const char *serverKey, PRBool &result);
00099         NS_IMETHOD   SetHostHasAdminURL(const char *serverKey, PRBool hasAdminUrl);
00100        // Subscription
00101         NS_IMETHOD   GetHostIsUsingSubscription(const char *serverKey, PRBool &result);
00102         NS_IMETHOD   SetHostIsUsingSubscription(const char *serverKey, PRBool usingSubscription);
00103 
00104        // Passwords
00105         NS_IMETHOD   GetPasswordForHost(const char *serverKey, nsString &result);
00106         NS_IMETHOD   SetPasswordForHost(const char *serverKey, const char *password);
00107         NS_IMETHOD GetPasswordVerifiedOnline(const char *serverKey, PRBool &result);
00108         NS_IMETHOD   SetPasswordVerifiedOnline(const char *serverKey);
00109 
00110     // OnlineDir
00111     NS_IMETHOD GetOnlineDirForHost(const char *serverKey,
00112                                    nsString &result);
00113     NS_IMETHOD SetOnlineDirForHost(const char *serverKey,
00114                                    const char *onlineDir);
00115 
00116     // Delete is move to trash folder
00117     NS_IMETHOD GetDeleteIsMoveToTrashForHost(const char *serverKey, PRBool &result);
00118     NS_IMETHOD SetDeleteIsMoveToTrashForHost(const char *serverKey, PRBool isMoveToTrash);
00119        // imap delete model (or not)
00120        NS_IMETHOD GetShowDeletedMessagesForHost(const char *serverKey, PRBool &result);
00121     NS_IMETHOD SetShowDeletedMessagesForHost(const char *serverKey, PRBool showDeletedMessages);
00122 
00123     // Get namespaces
00124     NS_IMETHOD GetGotNamespacesForHost(const char *serverKey, PRBool &result);
00125     NS_IMETHOD SetGotNamespacesForHost(const char *serverKey, PRBool gotNamespaces);
00126        // Folders
00127         NS_IMETHOD   SetHaveWeEverDiscoveredFoldersForHost(const char *serverKey, PRBool discovered);
00128         NS_IMETHOD   GetHaveWeEverDiscoveredFoldersForHost(const char *serverKey, PRBool &result);
00129 
00130        // Trash Folder
00131         NS_IMETHOD   SetOnlineTrashFolderExistsForHost(const char *serverKey, PRBool exists);
00132         NS_IMETHOD   GetOnlineTrashFolderExistsForHost(const char *serverKey, PRBool &result);
00133        
00134        // INBOX
00135         NS_IMETHOD          GetOnlineInboxPathForHost(const char *serverKey, nsString &result);
00136         NS_IMETHOD          GetShouldAlwaysListInboxForHost(const char *serverKey, PRBool &result);
00137         NS_IMETHOD          SetShouldAlwaysListInboxForHost(const char *serverKey, PRBool shouldList);
00138 
00139        // Namespaces
00140         NS_IMETHOD          GetNamespaceForMailboxForHost(const char *serverKey, const char *mailbox_name, nsIMAPNamespace *&result);
00141         NS_IMETHOD          SetNamespaceFromPrefForHost(const char *serverKey, const char *namespacePref, EIMAPNamespaceType type);
00142         NS_IMETHOD          AddNewNamespaceForHost(const char *serverKey, nsIMAPNamespace *ns);
00143         NS_IMETHOD          ClearServerAdvertisedNamespacesForHost(const char *serverKey);
00144         NS_IMETHOD          ClearPrefsNamespacesForHost(const char *serverKey);
00145         NS_IMETHOD          GetDefaultNamespaceOfTypeForHost(const char *serverKey, EIMAPNamespaceType type, nsIMAPNamespace *&result);
00146         NS_IMETHOD          SetNamespacesOverridableForHost(const char *serverKey, PRBool overridable);
00147         NS_IMETHOD          GetNamespacesOverridableForHost(const char *serverKey,PRBool &result);
00148         NS_IMETHOD          GetNumberOfNamespacesForHost(const char *serverKey, PRUint32 &result);
00149         NS_IMETHOD          GetNamespaceNumberForHost(const char *serverKey, PRInt32 n, nsIMAPNamespace * &result);
00150         // ### dmb hoo boy, how are we going to do this?
00151         NS_IMETHOD          CommitNamespacesForHost(nsIImapIncomingServer *host);
00152         NS_IMETHOD          FlushUncommittedNamespacesForHost(const char *serverKey, PRBool &result);
00153 
00154        // Hierarchy Delimiters
00155         NS_IMETHOD          SetNamespaceHierarchyDelimiterFromMailboxForHost(const char *serverKey, const char *boxName, char delimiter);
00156 
00157        // Message Body Shells
00158         NS_IMETHOD          AddShellToCacheForHost(const char *serverKey, nsIMAPBodyShell *shell);
00159         NS_IMETHOD          FindShellInCacheForHost(const char *serverKey, const char *mailboxName, const char *UID, IMAP_ContentModifiedType modType, nsIMAPBodyShell  **result);
00160 
00161        PRMonitor            *gCachedHostInfoMonitor;
00162        nsIMAPHostInfo       *fHostInfoList;
00163 protected:
00164        nsresult SetNamespacesPrefForHost(nsIImapIncomingServer *aHost, EIMAPNamespaceType type, char *pref);
00165 
00166        nsIMAPHostInfo *FindHost(const char *serverKey);
00167 };
00168 
00169 
00170 #endif