1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Seth Spitzer <sspitzer@netscape.com>
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38
39 #include "nsISupports.idl"
40 #include "nsIMsgAccount.idl"
41 #include "nsIMsgIdentity.idl"
42 #include "nsIMsgIncomingServer.idl"
43 #include "nsIIncomingServerListener.idl"
44 #include "nsIMsgFolder.idl"
45
46 interface nsISupportsArray;
47 interface nsIMsgFolderCache;
48 interface nsIFolderListener;
49
50 [scriptable, uuid(8129D2AD-6093-479D-884C-D8E79FA29B46)]
51 interface nsIMsgAccountManager : nsISupports {
52
53 nsIMsgAccount createAccount();
54 /*
55 * Return the account with the provided key, or null if none found.
56 */
57 nsIMsgAccount getAccount(in ACString key);
58
59 void removeAccount(in nsIMsgAccount account);
60 void removeIdentity(in nsIMsgIdentity identity);
61 void duplicateAccount(in nsIMsgAccount account);
62
63 /*
64 * creates a new identity and assigns it a new, unique "key"
65 */
66 nsIMsgIdentity createIdentity();
67
68 /*
69 * creates a new server and assigns it a new, unique "key"
70 * the given type will be used to construct a ContractID
71 */
72 nsIMsgIncomingServer createIncomingServer(in ACString username,
73 in ACString hostname,
74 in ACString type);
75
76 /*
77 * get the identity with the given key
78 * if the identity does not exist, it will be created
79 */
80 nsIMsgIdentity getIdentity(in ACString key);
81
82 /*
83 * Gets the existing incoming server with the given key
84 * if the server's type does not exist in the preference,
85 * an error is returned/thrown
86 */
87 nsIMsgIncomingServer getIncomingServer(in ACString key);
88
89 /* account list stuff */
90
91 /* defaultAccount should always be set if there are any accounts
92 * in the account manager. You can only set the defaultAccount to an
93 * account already in the account manager */
94 attribute nsIMsgAccount defaultAccount;
95
96 /**
97 * ordered list of all accounts, by the order they are in the prefs
98 * array of nsIMsgAccount
99 */
100 readonly attribute nsISupportsArray accounts;
101
102 /* list of all identities in all accounts
103 * array of nsIMsgIdentity
104 */
105 readonly attribute nsISupportsArray allIdentities;
106
107 /* list of all servers in all accounts
108 * array of nsIMsgIncomingServer
109 */
110 readonly attribute nsISupportsArray allServers;
111
112 /* summary of summary files folder cache */
113 readonly attribute nsIMsgFolderCache folderCache;
114
115 /* are we shutting down */
116 readonly attribute boolean shutdownInProgress;
117
118 /**
119 * for preventing unauthenticated users from seeing header information
120 */
121 attribute boolean userNeedsToAuthenticate;
122 /*
123 * search for the server with the given username, hostname, and type
124 * the type is the same as is specified in the preferences,
125 * i.e. "imap", "pop3", "none", or "nntp"
126 */
127 nsIMsgIncomingServer
128 FindServer(in ACString userName, in ACString hostname, in ACString type);
129
130 /*
131 * search for the server with the given uri
132 * an analog to FindServer()
133 * The boolean flag selects whether we compare input against the
134 * 'realhostname' and 'realuserName' pref settings.
135 */
136 nsIMsgIncomingServer
137 findServerByURI(in nsIURI aURI, in boolean aRealFlag);
138
139 /*
140 * Same as FindServer() except it compares the input values against
141 * 'realhostname' and 'realuserName' pref settings.
142 */
143 nsIMsgIncomingServer
144 findRealServer(in ACString userName, in ACString hostname, in ACString type, in long port );
145
146 /**
147 * find the index of this server in the (ordered) list of accounts
148 */
149 long FindServerIndex(in nsIMsgIncomingServer server);
150
151 nsIMsgAccount FindAccountForServer(in nsIMsgIncomingServer server);
152
153 /* given a server, return all identities in accounts that have this server
154 * returns an array of nsIMsgIdentity
155 */
156 nsISupportsArray GetIdentitiesForServer(in nsIMsgIncomingServer server);
157
158 /**
159 * given a server, return the first identity in accounts that have this server
160 */
161 nsIMsgIdentity getFirstIdentityForServer(in nsIMsgIncomingServer server);
162
163 /* given an identity, return all servers in accounts that have
164 * this identity
165 * returns an array of nsIMsgIncomingServer
166 */
167 nsISupportsArray GetServersForIdentity(in nsIMsgIdentity identity);
168
169 /* there is a special server "Local Folders" that is guaranteed to exist.
170 * this will allow you to get */
171 attribute nsIMsgIncomingServer localFoldersServer;
172
173 // Create the account for that special server.
174 void createLocalMailAccount();
175
176 /* load accounts kicks off the creation of all accounts. You do not need
177 * to call this and all accounts should be loaded lazily if you use any
178 * of the above.
179 */
180 void LoadAccounts();
181
182 void setSpecialFolders();
183
184 void loadVirtualFolders();
185
186 /* unload accounts frees all the account manager data structures */
187 void UnloadAccounts();
188
189 void WriteToFolderCache(in nsIMsgFolderCache folderCache);
190 void saveVirtualFolders();
191 void closeCachedConnections();
192 void shutdownServers();
193
194 void CleanupOnExit();
195 void SetFolderDoingEmptyTrash(in nsIMsgFolder folder);
196 boolean GetEmptyTrashInProgress();
197
198 void SetFolderDoingCleanupInbox(in nsIMsgFolder folder);
199 boolean GetCleanupInboxInProgress();
200
201 void addRootFolderListener(in nsIFolderListener listener);
202 void removeRootFolderListener(in nsIFolderListener listener);
203
204 // these are going away in favor of add/removeRootFolderListener
205 void addIncomingServerListener(in nsIIncomingServerListener serverListener);
206 void removeIncomingServerListener(in nsIIncomingServerListener serverListener);
207
208 // these are going away in favor of nsIMsgFolder::NotifyEvent(in nsIAtom event);
209 void notifyServerLoaded(in nsIMsgIncomingServer server);
210 void notifyServerUnloaded(in nsIMsgIncomingServer server);
211 void notifyServerChanged(in nsIMsgIncomingServer server);
212
213 // force account info out to prefs file
214 void saveAccountInfo();
215
216 ACString getChromePackageName(in ACString aExtensionName);
217 };
218
219 %{C++
220 #define MAILNEWS_ACCOUNTMANAGER_EXTENSIONS "mailnews-accountmanager-extensions"
221 %}
222
223 [scriptable, uuid(70032DE0-CD59-41ba-839D-FC1B65367EE7)]
224 interface nsIMsgAccountManagerExtension : nsISupports
225 {
226 readonly attribute ACString name; // examples: mdn
227 boolean showPanel(in nsIMsgIncomingServer server);
228 readonly attribute ACString chromePackageName; // example: messenger, chrome://messenger/content/am-mdn.xul and chrome://messenger/locale/am-mdn.properties
229 };