1/* -*- Mode: IDL; 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#include "nsISupports.idl" 7#include "nsIMsgAccount.idl" 8#include "nsIMsgIdentity.idl" 9#include "nsIMsgIncomingServer.idl" 10#include "nsIIncomingServerListener.idl" 11#include "nsIMsgFolder.idl" 12 13interface nsIMsgFolderCache; 14interface nsIFolderListener; 15 16[scriptable, uuid(d5ab0eea-49c5-42f2-b2e6-8ad306606d8b)] 17interface nsIMsgAccountManager : nsISupports { 18 19 ACString getUniqueAccountKey(); 20 21 nsIMsgAccount createAccount(); 22 /* 23 * Return the account with the provided key, or null if none found. 24 */ 25 nsIMsgAccount getAccount(in ACString key); 26 27 /** 28 * Removes the account from the list of accounts. 29 * 30 * @param aAccount the account to remove 31 * @param aRemoveFiles remove data directory (local directory) of this account 32 */ 33 void removeAccount(in nsIMsgAccount aAccount, [optional] in boolean aRemoveFiles); 34 35 /* 36 * creates a new identity and assigns it a new, unique "key" 37 */ 38 nsIMsgIdentity createIdentity(); 39 40 /** 41 * Scan the preferences to find a unique server key. 42 */ 43 ACString getUniqueServerKey(); 44 45 /* 46 * creates a new server and assigns it a new, unique "key" 47 * the given type will be used to construct a ContractID 48 * 49 * @param type "imap", "pop3", "nntp", "none", "rss", "generic" 50 * (suffix of contract ID @mozilla.org/messenger/server;1?type= ) 51 */ 52 nsIMsgIncomingServer createIncomingServer(in ACString username, 53 in ACString hostname, 54 in ACString type); 55 56 /** 57 * Removes the server from the list of servers 58 * 59 * @param aServer server to remove 60 * @param aRemoveFiles remove directory from profile 61 * 62 * @throws NS_ERROR_FAILURE if server not found 63 */ 64 void removeIncomingServer(in nsIMsgIncomingServer aServer, 65 in boolean aRemoveFiles); 66 /* 67 * get the identity with the given key 68 * if the identity does not exist, it will be created 69 */ 70 nsIMsgIdentity getIdentity(in ACString key); 71 72 /* 73 * Gets the existing incoming server with the given key 74 * if the server's type does not exist in the preference, 75 * an error is returned/thrown 76 */ 77 nsIMsgIncomingServer getIncomingServer(in ACString key); 78 79 /* account list stuff */ 80 81 /** 82 * Returns the account that was marked as the default one. 83 * Only some server types can serve as default account. 84 * If there is no such account, null is returned. 85 * You can only set the defaultAccount to an 86 * account already in the account manager. 87 */ 88 attribute nsIMsgAccount defaultAccount; 89 90 /** 91 * Ordered list of all accounts, by the order they are in the prefs. 92 * Accounts with hidden servers are not returned. 93 * array of nsIMsgAccount 94 */ 95 readonly attribute Array<nsIMsgAccount> accounts; 96 97 /* list of all identities in all accounts 98 * array of nsIMsgIdentity 99 */ 100 readonly attribute Array<nsIMsgIdentity> allIdentities; 101 102 /* list of all servers in all accounts, except for hidden and IM servers 103 * array of nsIMsgIncomingServer 104 */ 105 readonly attribute Array<nsIMsgIncomingServer> allServers; 106 107 /* summary of summary files folder cache */ 108 readonly attribute nsIMsgFolderCache folderCache; 109 110 /* are we shutting down */ 111 readonly attribute boolean shutdownInProgress; 112 113 /** 114 * for preventing unauthenticated users from seeing header information 115 */ 116 attribute boolean userNeedsToAuthenticate; 117 /* 118 * search for the server with the given username, hostname, and type 119 * the type is the same as is specified in the preferences, 120 * i.e. "imap", "pop3", "none", or "nntp" 121 */ 122 nsIMsgIncomingServer 123 FindServer(in ACString userName, in ACString hostname, in ACString type); 124 125 /* 126 * search for the server with the given uri 127 * an analog to FindServer() 128 * The boolean flag selects whether we compare input against the 129 * 'realhostname' and 'realuserName' pref settings. 130 */ 131 nsIMsgIncomingServer 132 findServerByURI(in nsIURI aURI, in boolean aRealFlag); 133 134 /* 135 * Same as FindServer() except it compares the input values against 136 * 'realhostname' and 'realuserName' pref settings. 137 */ 138 nsIMsgIncomingServer 139 findRealServer(in ACString userName, in ACString hostname, in ACString type, in long port ); 140 141 /** 142 * find the index of this server in the (ordered) list of accounts 143 */ 144 long FindServerIndex(in nsIMsgIncomingServer server); 145 146 /** 147 * Finds an account for the given incoming server. 148 * 149 * @param server An incoming server to find the account for. 150 * @return If found, the nsIMsgAccount representing the account found. 151 * Otherwise returns null. 152 */ 153 nsIMsgAccount FindAccountForServer(in nsIMsgIncomingServer server); 154 155 /* given a server, return all identities in accounts that have this server 156 * returns an array of nsIMsgIdentity 157 */ 158 Array<nsIMsgIdentity> getIdentitiesForServer(in nsIMsgIncomingServer server); 159 160 /** 161 * given a server, return the first identity in accounts that have this server 162 */ 163 nsIMsgIdentity getFirstIdentityForServer(in nsIMsgIncomingServer server); 164 165 /* given an identity, return all servers in accounts that have 166 * this identity 167 * returns an array of nsIMsgIncomingServer 168 */ 169 Array<nsIMsgIncomingServer> getServersForIdentity(in nsIMsgIdentity identity); 170 171 /* there is a special server "Local Folders" that is guaranteed to exist. 172 * this will allow you to get */ 173 attribute nsIMsgIncomingServer localFoldersServer; 174 175 // Create the account for that special server. 176 void createLocalMailAccount(); 177 178 /* load accounts kicks off the creation of all accounts. You do not need 179 * to call this and all accounts should be loaded lazily if you use any 180 * of the above. 181 */ 182 void LoadAccounts(); 183 184 /** 185 * When the server for an account could not be loaded, typically because the 186 * extension providing it could not be loaded, it is deactivated for a period 187 * of time as documented in nsIMsgAccount.idl. The server is normally only 188 * rechecked at startup but this function can be used to recheck all servers 189 * at any time to avoid having to restart to reactivate an account. 190 */ 191 void ReactivateAccounts(); 192 193 void setSpecialFolders(); 194 195 void loadVirtualFolders(); 196 197 /* unload accounts frees all the account manager data structures */ 198 void UnloadAccounts(); 199 200 void WriteToFolderCache(in nsIMsgFolderCache folderCache); 201 void saveVirtualFolders(); 202 void closeCachedConnections(); 203 void shutdownServers(); 204 205 void CleanupOnExit(); 206 void SetFolderDoingEmptyTrash(in nsIMsgFolder folder); 207 boolean GetEmptyTrashInProgress(); 208 209 void SetFolderDoingCleanupInbox(in nsIMsgFolder folder); 210 boolean GetCleanupInboxInProgress(); 211 212 void addRootFolderListener(in nsIFolderListener listener); 213 void removeRootFolderListener(in nsIFolderListener listener); 214 215 // these are going away in favor of add/removeRootFolderListener 216 void addIncomingServerListener(in nsIIncomingServerListener serverListener); 217 void removeIncomingServerListener(in nsIIncomingServerListener serverListener); 218 219 // these are going away in favor of nsIMsgFolder::NotifyEvent(in ACString event); 220 // XXX what does this mean? There is no such function yet. 221 void notifyServerLoaded(in nsIMsgIncomingServer server); 222 void notifyServerUnloaded(in nsIMsgIncomingServer server); 223 void notifyServerChanged(in nsIMsgIncomingServer server); 224 225 // force account info out to prefs file 226 void saveAccountInfo(); 227 228 ACString getChromePackageName(in ACString aExtensionName); 229 230 /// Enumerate all incoming servers and their folders and return in an array. 231 readonly attribute Array<nsIMsgFolder> allFolders; 232 233 /** 234 * Iterates over all folders looking for one with the passed in path, 235 * and returns the uri for the matching folder. In the future, 236 * the folder lookup service will provide this functionality. 237 * 238 * @param aLocalPath path of the folder whose uri we want. 239 * @return the URI of the folder that corresponds to aLocalPath 240 */ 241 AUTF8String folderUriForPath(in nsIFile aLocalPath); 242 243 // Used to sort servers (accounts) for e.g. the folder pane 244 long getSortOrder(in nsIMsgIncomingServer server); 245 246 /** 247 * Sets new order of accounts. 248 * 249 * @param accountKeys - Account keys in the new preferred order. 250 */ 251 void reorderAccounts(in Array<ACString> accountKeys); 252}; 253 254%{C++ 255#define MAILNEWS_ACCOUNTMANAGER_EXTENSIONS "mailnews-accountmanager-extensions" 256%} 257 258[scriptable, uuid(70032DE0-CD59-41ba-839D-FC1B65367EE7)] 259interface nsIMsgAccountManagerExtension : nsISupports 260{ 261 readonly attribute ACString name; // examples: mdn 262 boolean showPanel(in nsIMsgIncomingServer server); 263 readonly attribute ACString chromePackageName; // example: messenger, chrome://messenger/content/am-mdn.xhtml and chrome://messenger/locale/am-mdn.properties 264}; 265