1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #ifndef _nsImapHostSessionList_H_ 7 #define _nsImapHostSessionList_H_ 8 9 #include "mozilla/Attributes.h" 10 #include "nsImapCore.h" 11 #include "nsIImapHostSessionList.h" 12 #include "nsImapBodyShell.h" 13 #include "nsIObserver.h" 14 #include "nsWeakReference.h" 15 #include "nspr.h" 16 17 class nsImapNamespaceList; 18 class nsIImapIncomingServer; 19 20 class nsIMAPHostInfo { 21 public: 22 friend class nsImapHostSessionList; 23 24 nsIMAPHostInfo(const char* serverKey, nsIImapIncomingServer* server); 25 ~nsIMAPHostInfo(); 26 27 protected: 28 nsCString fServerKey; 29 nsString fCachedPassword; 30 nsCString fOnlineDir; 31 nsIMAPHostInfo* fNextHost; 32 eIMAPCapabilityFlags fCapabilityFlags; 33 char* fHierarchyDelimiters; // string of top-level hierarchy delimiters 34 bool fHaveWeEverDiscoveredFolders; 35 bool fDiscoveryForHostInProgress; 36 char* fCanonicalOnlineSubDir; 37 nsImapNamespaceList *fNamespaceList, *fTempNamespaceList; 38 bool fNamespacesOverridable; 39 bool fUsingSubscription; 40 bool fOnlineTrashFolderExists; 41 bool fShouldAlwaysListInbox; 42 bool fHaveAdminURL; 43 bool fPasswordVerifiedOnline; 44 bool fDeleteIsMoveToTrash; 45 bool fShowDeletedMessages; 46 bool fGotNamespaces; 47 nsImapBodyShellCache* fShellCache; 48 }; 49 50 // this is an interface to a linked list of host info's 51 class nsImapHostSessionList : public nsIImapHostSessionList, 52 public nsIObserver, 53 public nsSupportsWeakReference { 54 public: 55 NS_DECL_THREADSAFE_ISUPPORTS 56 NS_DECL_NSIOBSERVER 57 58 nsImapHostSessionList(); 59 nsresult Init(); 60 // Host List 61 NS_IMETHOD AddHostToList(const char* serverKey, 62 nsIImapIncomingServer* server) override; 63 NS_IMETHOD ResetAll() override; 64 65 // Capabilities 66 NS_IMETHOD GetHostHasAdminURL(const char* serverKey, bool& result) override; 67 NS_IMETHOD SetHostHasAdminURL(const char* serverKey, 68 bool hasAdminUrl) override; 69 // Subscription 70 NS_IMETHOD GetHostIsUsingSubscription(const char* serverKey, 71 bool& result) override; 72 NS_IMETHOD SetHostIsUsingSubscription(const char* serverKey, 73 bool usingSubscription) override; 74 75 // Passwords 76 NS_IMETHOD GetPasswordForHost(const char* serverKey, 77 nsString& result) override; 78 NS_IMETHOD SetPasswordForHost(const char* serverKey, 79 const nsAString& password) override; 80 NS_IMETHOD GetPasswordVerifiedOnline(const char* serverKey, 81 bool& result) override; 82 NS_IMETHOD SetPasswordVerifiedOnline(const char* serverKey) override; 83 84 // OnlineDir 85 NS_IMETHOD GetOnlineDirForHost(const char* serverKey, 86 nsString& result) override; 87 NS_IMETHOD SetOnlineDirForHost(const char* serverKey, 88 const char* onlineDir) override; 89 90 // Delete is move to trash folder 91 NS_IMETHOD GetDeleteIsMoveToTrashForHost(const char* serverKey, 92 bool& result) override; 93 NS_IMETHOD SetDeleteIsMoveToTrashForHost(const char* serverKey, 94 bool isMoveToTrash) override; 95 // imap delete model (or not) 96 NS_IMETHOD GetShowDeletedMessagesForHost(const char* serverKey, 97 bool& result) override; 98 NS_IMETHOD SetShowDeletedMessagesForHost(const char* serverKey, 99 bool showDeletedMessages) override; 100 101 // Get namespaces 102 NS_IMETHOD GetGotNamespacesForHost(const char* serverKey, 103 bool& result) override; 104 NS_IMETHOD SetGotNamespacesForHost(const char* serverKey, 105 bool gotNamespaces) override; 106 // Folders 107 NS_IMETHOD SetHaveWeEverDiscoveredFoldersForHost(const char* serverKey, 108 bool discovered) override; 109 NS_IMETHOD GetHaveWeEverDiscoveredFoldersForHost(const char* serverKey, 110 bool& result) override; 111 NS_IMETHOD SetDiscoveryForHostInProgress(const char* serverKey, 112 bool inProgress) override; 113 NS_IMETHOD GetDiscoveryForHostInProgress(const char* serverKey, 114 bool& result) override; 115 116 // Trash Folder 117 NS_IMETHOD SetOnlineTrashFolderExistsForHost(const char* serverKey, 118 bool exists) override; 119 NS_IMETHOD GetOnlineTrashFolderExistsForHost(const char* serverKey, 120 bool& result) override; 121 122 // INBOX 123 NS_IMETHOD GetOnlineInboxPathForHost(const char* serverKey, 124 nsString& result) override; 125 NS_IMETHOD GetShouldAlwaysListInboxForHost(const char* serverKey, 126 bool& result) override; 127 NS_IMETHOD SetShouldAlwaysListInboxForHost(const char* serverKey, 128 bool shouldList) override; 129 130 // Namespaces 131 NS_IMETHOD GetNamespaceForMailboxForHost(const char* serverKey, 132 const char* mailbox_name, 133 nsImapNamespace*& result) override; 134 NS_IMETHOD SetNamespaceFromPrefForHost(const char* serverKey, 135 const char* namespacePref, 136 EIMAPNamespaceType type) override; 137 NS_IMETHOD AddNewNamespaceForHost(const char* serverKey, 138 nsImapNamespace* ns) override; 139 NS_IMETHOD ClearServerAdvertisedNamespacesForHost( 140 const char* serverKey) override; 141 NS_IMETHOD ClearPrefsNamespacesForHost(const char* serverKey) override; 142 NS_IMETHOD GetDefaultNamespaceOfTypeForHost( 143 const char* serverKey, EIMAPNamespaceType type, 144 nsImapNamespace*& result) override; 145 NS_IMETHOD SetNamespacesOverridableForHost(const char* serverKey, 146 bool overridable) override; 147 NS_IMETHOD GetNamespacesOverridableForHost(const char* serverKey, 148 bool& result) override; 149 NS_IMETHOD GetNumberOfNamespacesForHost(const char* serverKey, 150 uint32_t& result) override; 151 NS_IMETHOD GetNamespaceNumberForHost(const char* serverKey, int32_t n, 152 nsImapNamespace*& result) override; 153 // ### dmb hoo boy, how are we going to do this? 154 NS_IMETHOD CommitNamespacesForHost(nsIImapIncomingServer* host) override; 155 NS_IMETHOD FlushUncommittedNamespacesForHost(const char* serverKey, 156 bool& result) override; 157 158 // Hierarchy Delimiters 159 NS_IMETHOD SetNamespaceHierarchyDelimiterFromMailboxForHost( 160 const char* serverKey, const char* boxName, char delimiter) override; 161 162 // Message Body Shells 163 NS_IMETHOD AddShellToCacheForHost(const char* serverKey, 164 nsImapBodyShell* shell) override; 165 NS_IMETHOD FindShellInCacheForHost(const char* serverKey, 166 const char* mailboxName, const char* UID, 167 IMAP_ContentModifiedType modType, 168 nsImapBodyShell** result) override; 169 NS_IMETHOD ClearShellCacheForHost(const char* serverKey) override; 170 PRMonitor* gCachedHostInfoMonitor; 171 nsIMAPHostInfo* fHostInfoList; 172 173 protected: 174 virtual ~nsImapHostSessionList(); 175 nsresult SetNamespacesPrefForHost(nsIImapIncomingServer* aHost, 176 EIMAPNamespaceType type, const char* pref); 177 nsIMAPHostInfo* FindHost(const char* serverKey); 178 }; 179 #endif 180