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 "MailNewsTypes2.idl"
41
42 interface nsIMsgFolder;
43 interface nsIMsgFolderCache;
44 interface nsIMsgWindow;
45 interface nsIMsgFilterList;
46 interface nsIMsgRetentionSettings;
47 interface nsIMsgDownloadSettings;
48 interface nsISpamSettings;
49 interface nsIMsgFilterPlugin;
50 interface nsIUrlListener;
51 interface nsIMsgDBHdr;
52 interface nsILocalFile;
53
54 /*
55 * Interface for incoming mail/news host
56 * this is the base interface for all mail server types (imap, pop, nntp, etc)
57 * often you will want to add extra interfaces that give you server-specific
58 * attributes and methods.
59 */
60 [scriptable, uuid(15087bf7-f63f-42c3-8f60-a0cd11aaca53)]
61 interface nsIMsgIncomingServer : nsISupports {
62
63 /**
64 * internal pref key - guaranteed to be unique across all servers
65 */
66 attribute ACString key;
67
68 /**
69 * pretty name - should be "userid on hostname"
70 * if the pref is not set
71 */
72 attribute AString prettyName;
73
74 /**
75 * helper function to construct the pretty name in a server type
76 * specific way - e.g., mail for foo@test.com, news on news.mozilla.org
77 */
78 readonly attribute AString constructedPrettyName;
79
80 /**
81 * hostname of the server
82 */
83 attribute ACString hostName;
84
85 /**
86 * real hostname of the server (if server name is changed it's stored here)
87 */
88 attribute ACString realHostName;
89
90 /* port of the server */
91 attribute long port;
92
93 /**
94 * userid to log into the server
95 */
96 attribute ACString username;
97
98 /**
99 * real username of the server (if username is changed it's stored here)
100 */
101 attribute ACString realUsername;
102
103 /**
104 * protocol type, i.e. "pop3", "imap", "nntp", "none", etc
105 * used to construct URLs
106 */
107 attribute ACString type;
108
109 readonly attribute AString accountManagerChrome;
110
111 /**
112 * the schema for the local mail store, such
113 * as "mailbox", "imap", or "news"
114 * used to construct URIs
115 */
116 readonly attribute ACString localStoreType;
117
118 // Perform specific tasks (reset flags, remove files, etc) for account user/server name changes.
119 void onUserOrHostNameChanged(in ACString oldName, in ACString newName);
120
121 /* should we remember the password? */
122 attribute boolean rememberPassword;
123
124 /* cleartext version of the password */
125 attribute ACString password;
126
127 /* prompt the user for a password */
128 ACString getPasswordWithUI(in AString aPromptString, in AString aPromptTitle, in nsIMsgWindow aMsgWindow, out boolean okayValue);
129
130 /* forget the password in memory and in single signon database */
131 void forgetPassword();
132
133 /**
134 * logon succeeded - persist password, if user chooses.
135 */
136 void storePassword();
137
138 /* forget the password in memory which is cached for the session */
139 void forgetSessionPassword();
140
141 /* should we download whole messages when biff goes off? */
142 /* in 4.x, this was "mail.pop3_gets_new_mail" for pop */
143 /* "mail.imap.new_mail_get_headers" for imap, and it was global. in 5.x, it is per server */
144 attribute boolean downloadOnBiff;
145
146 /* should we biff the server? */
147 attribute boolean doBiff;
148
149 /* how often to biff */
150 attribute long biffMinutes;
151
152 /* current biff state */
153 attribute unsigned long biffState;
154
155 /* are we running a url as a result of biff going off? (different from user clicking get msg) */
156 attribute boolean performingBiff;
157
158 /* the on-disk path to message storage for this server */
159 attribute nsILocalFile localPath;
160
161 /* the RDF URI for the root mail folder */
162 readonly attribute ACString serverURI;
163
164 /* the root folder for this server, even if server is deferred */
165 attribute nsIMsgFolder rootFolder;
166
167 /* root folder for this account
168 - if account is deferred, root folder of deferred-to account */
169 readonly attribute nsIMsgFolder rootMsgFolder;
170
171 /* are we already getting new Messages on the current server..
172 This is used to help us prevent multiple get new msg commands from
173 going off at the same time. */
174 attribute boolean serverBusy;
175
176 /* should we use a secure channel? */
177 attribute boolean isSecure;
178
179 /* should we use secure authentication? */
180 attribute boolean useSecAuth;
181
182 const long defaultSocket = 0;
183 const long tryTLS = 1;
184 const long alwaysUseTLS = 2;
185 const long useSSL = 3;
186
187 /* use above values */
188 attribute long socketType;
189
190 /* if a logon mechanism fails, should we fallback to a different
191 mechanism?
192 */
193 attribute boolean logonFallback;
194
195 /* can server support a secure channel? */
196 readonly attribute boolean isSecureServer;
197
198 /* empty trash on exit */
199 attribute boolean emptyTrashOnExit;
200
201 /* get filter list */
202 nsIMsgFilterList getFilterList(in nsIMsgWindow aMsgWindow);
203
204 /* set filter list */
205 void setFilterList(in nsIMsgFilterList aFilterList);
206
207 /* we use this to set the default local path. we use this when migrating prefs */
208 void setDefaultLocalPath(in nsILocalFile aDefaultLocalPath);
209
210 /* do a biff */
211 void performBiff(in nsIMsgWindow aMsgWindow);
212
213 /* get new messages */
214 void getNewMessages(in nsIMsgFolder aFolder, in nsIMsgWindow aMsgWindow,
215 in nsIUrlListener aUrlListener);
216 /* this checks if a server needs a password to do biff */
217 readonly attribute boolean serverRequiresPasswordForBiff;
218
219 /* this gets called when the server is expanded in the folder pane */
220 void performExpand(in nsIMsgWindow aMsgWindow);
221
222 /* Write out all known folder data to panacea.dat */
223 void writeToFolderCache(in nsIMsgFolderCache folderCache);
224
225 /* close any server connections */
226 void closeCachedConnections();
227
228 /* ... */
229 void shutdown();
230
231 /* access to generic attributes */
232 boolean getBoolValue(in string attr);
233 void setBoolValue(in string attr, in boolean value);
234
235 ACString getCharValue(in string attr);
236 void setCharValue(in string attr, in ACString value);
237
238 AString getUnicharValue(in string attr);
239 void setUnicharValue(in string attr, in AString value);
240
241 long getIntValue(in string attr);
242 void setIntValue(in string attr, in long value);
243
244 nsILocalFile getFileValue(in string relpref, in string abspref);
245 void setFileValue(in string relpref, in string abspref, in nsILocalFile aValue);
246
247 /**
248 * this is really dangerous. this destroys all pref values
249 * do not call this unless you know what you're doing!
250 */
251 void clearAllValues();
252
253 /**
254 * this is also very dangerous. this will remove the files
255 * associated with this server on disk.
256 */
257 void removeFiles();
258
259 attribute boolean valid;
260
261 AString toString();
262
263 void displayOfflineMsg(in nsIMsgWindow aWindow);
264
265 /* used for comparing nsIMsgIncomingServers */
266 boolean equals(in nsIMsgIncomingServer server);
267
268 /* Get Messages at startup */
269 readonly attribute boolean downloadMessagesAtStartup;
270
271 /* check to this if the server supports filters */
272 readonly attribute boolean canHaveFilters;
273
274 /**
275 * can this server be removed from the account manager? for
276 * instance, local mail is not removable, but an imported folder is
277 */
278 attribute boolean canDelete;
279
280 attribute boolean loginAtStartUp;
281
282 attribute boolean limitOfflineMessageSize;
283 attribute long maxMessageSize;
284
285 attribute nsIMsgRetentionSettings retentionSettings;
286
287 /* check if this server can be a default server */
288 readonly attribute boolean canBeDefaultServer;
289
290 /* check if this server allows search operations */
291 readonly attribute boolean canSearchMessages;
292
293 /* check if this server allows canEmptyTrashOnExit operations */
294 readonly attribute boolean canEmptyTrashOnExit;
295
296 /* display startup page once per account per session */
297 attribute boolean displayStartupPage;
298 attribute nsIMsgDownloadSettings downloadSettings;
299
300 /*
301 * Offline support level. Support level can vary based on abilities
302 * and features each server can offer wrt to offline service.
303 * Here is the legend to determine the each support level details
304 *
305 * supportLevel == 0 --> no offline support (default)
306 * supportLevel == 10 --> regular offline feature support
307 * supportLevel == 20 --> extended offline feature support
308 *
309 * Each server can initialize itself to the support level if needed
310 * to override the default choice i.e., no offline support.
311 *
312 * POP3, None and Movemail will default to 0.
313 * IMAP level 10 and NEWS with level 20.
314 *
315 */
316 attribute long offlineSupportLevel;
317
318 /* create pretty name for migrated accounts */
319 AString generatePrettyNameForMigration();
320
321 /* does this server have disk space settings? */
322 readonly attribute boolean supportsDiskSpace;
323
324 /**
325 * If the server supports Fcc/Sent/etc, default prefs can point to
326 * the server. Otherwise, copies and folders prefs should point to
327 * Local Folders.
328 *
329 * By default this value is set to true via global pref 'allows_specialfolders_usage'
330 * (mailnews.js). For Nntp, the value is overridden to be false.
331 * If ISPs want to modify this value, they should do that in their rdf file
332 * by using this attribute. Please look at mozilla/mailnews/base/ispdata/aol.rdf for
333 * usage example.
334 */
335 attribute boolean defaultCopiesAndFoldersPrefsToServer;
336
337 /* can this server allows sub folder creation */
338 attribute boolean canCreateFoldersOnServer;
339
340 /* can this server allows message filing ? */
341 attribute boolean canFileMessagesOnServer;
342
343 /* can this server allow compacting folders ? */
344 readonly attribute boolean canCompactFoldersOnServer;
345
346 /* can this server allow undo delete ? */
347 readonly attribute boolean canUndoDeleteOnServer;
348
349 /* used for setting up the filter UI */
350 readonly attribute nsMsgSearchScopeValue filterScope;
351
352 /* used for setting up the search UI */
353 readonly attribute nsMsgSearchScopeValue searchScope;
354
355 /**
356 * these generic getter / setters, useful for extending mailnews
357 * note, these attributes persist across sessions
358 */
359 AString getUnicharAttribute(in string name);
360 void setUnicharAttribute(in string name, in AString value);
361
362 ACString getCharAttribute(in string name);
363 void setCharAttribute(in string name, in ACString value);
364
365 boolean getBoolAttribute(in string name);
366 void setBoolAttribute(in string name, in boolean value);
367
368 long getIntAttribute(in string name);
369 void setIntAttribute(in string name, in long value);
370
371 /**
372 * If the password for the server is available either via authentication
373 * in the current session or from password manager stored entries, return
374 * false. Otherwise, return true. If password is obtained from password
375 * manager, set the password member variable.
376 */
377 readonly attribute boolean passwordPromptRequired;
378
379 /**
380 * for mail, this configures both the MDN filter, and the server-side
381 * spam filter filters, if needed.
382 *
383 * If we have set up to filter return receipts into
384 * our Sent folder, this utility method creates
385 * a filter to do that, and adds it to our filterList
386 * if it doesn't exist. If it does, it will enable it.
387 *
388 * this is not used by news filters (yet).
389 */
390 void configureTemporaryFilters(in nsIMsgFilterList filterList);
391
392 /**
393 * If Sent folder pref is changed we need to clear the temporary
394 * return receipt filter so that the new return receipt filter can
395 * be recreated (by ConfigureTemporaryReturnReceiptsFilter()).
396 */
397 void clearTemporaryReturnReceiptsFilter();
398
399 /**
400 * spam settings
401 */
402 readonly attribute nsISpamSettings spamSettings;
403 readonly attribute nsIMsgFilterPlugin spamFilterPlugin;
404
405 nsIMsgFolder getMsgFolderFromURI(in nsIMsgFolder aFolderResource, in ACString aURI);
406
407 readonly attribute boolean isDeferredTo;
408
409 const long keepDups = 0;
410 const long deleteDups = 1;
411 const long moveDupsToTrash = 2;
412 const long markDupsRead = 3;
413
414 attribute long incomingDuplicateAction;
415
416 // check if new hdr is a duplicate of a recently arrived header
417 boolean isNewHdrDuplicate(in nsIMsgDBHdr aNewHdr);
418 };
419
420 %{C++
421 /*
422 * Following values for offline support have been used by
423 * various files. If you are modifying any of the values
424 * below, please do take care of the following files.
425 * - mozilla/mailnews/base/src/nsMsgAccountManagerDS.cpp
426 * - mozilla/mailnews/base/util/nsMsgIncomingServer.cpp
427 * - mozilla/mailnews/imap/src/nsImapIncomingServer.cpp
428 * - mozilla/mailnews/local/src/nsPop3IncomingServer.cpp
429 * - mozilla/mailnews/news/src/nsNntpIncomingServer.cpp
430 * - mozilla/mailnews/base/resources/content/msgAccountCentral.js
431 * - mozilla/modules/libpref/src/init/mailnews.js
432 * - ns/modules/libpref/src/init/mailnews-ns.js
433 * - ns/mailnews/base/ispdata/aol.rdf
434 * - ns/mailnews/base/ispdata/nswebmail.rdf
435 */
436 #define OFFLINE_SUPPORT_LEVEL_NONE 0
437 #define OFFLINE_SUPPORT_LEVEL_REGULAR 10
438 #define OFFLINE_SUPPORT_LEVEL_EXTENDED 20
439 #define OFFLINE_SUPPORT_LEVEL_UNDEFINED -1
440
441 // Value when no port setting is found
442 #define PORT_NOT_SET -1
443
444 /* some useful macros to implement nsIMsgIncomingServer accessors */
445 #define NS_IMPL_SERVERPREF_STR(_class, _postfix, _prefname) \
446 NS_IMETHODIMP \
447 _class::Get##_postfix(nsACString& retval) \
448 { \
449 return GetCharValue(_prefname, retval); \
450 } \
451 NS_IMETHODIMP \
452 _class::Set##_postfix(const nsACString& chvalue) \
453 { \
454 return SetCharValue(_prefname, chvalue); \
455 }
456
457 #define NS_IMPL_SERVERPREF_BOOL(_class, _postfix, _prefname)\
458 NS_IMETHODIMP \
459 _class::Get##_postfix(PRBool *retval) \
460 { \
461 return GetBoolValue(_prefname, retval); \
462 } \
463 NS_IMETHODIMP \
464 _class::Set##_postfix(PRBool bvalue) \
465 { \
466 return SetBoolValue(_prefname, bvalue); \
467 }
468
469 #define NS_IMPL_SERVERPREF_INT(_class, _postfix, _prefname)\
470 NS_IMETHODIMP \
471 _class::Get##_postfix(PRInt32 *retval) \
472 { \
473 return GetIntValue(_prefname, retval); \
474 } \
475 NS_IMETHODIMP \
476 _class::Set##_postfix(PRInt32 ivalue) \
477 { \
478 return SetIntValue(_prefname, ivalue); \
479 }
480
481 %}