summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/imap/public/nsIImapServerSink.idl
blob: 736487877ec247c11c86af8985f5fdcd0c52e96b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"
#include "MailNewsTypes2.idl"

interface nsIMsgWindow;
interface nsIMsgMailNewsUrl;
interface nsIImapProtocol;
interface nsIImapUrl;
interface nsIImapMockChannel;

/**
 * nsIImapServerSink is designed to be used as a proxy to the application's UI
 * thread from the running IMAP threads.
 */
[scriptable, uuid(2160c641-e4fa-4bbc-ab8b-d9ba45069027)]
interface nsIImapServerSink : nsISupports {
  /**
   * Check if the given folder path is a possible IMAP mailbox.
   * @param folderPath folder path to check
   * @param hierarchyDelimiter IMAP hierarchy delimiter in canonical format,
   *                           i.e., hierarchy delimiter has been replaced
   *                           with '/'
   * @param boxFlags IMAP folder flags (for subscription, namespaces etc.)
   * @return true if it's a new mailbox
   */
  boolean possibleImapMailbox(in AUTF8String folderPath,
                              in char hierarchyDelimiter, in long boxFlags);
  boolean folderNeedsACLInitialized(in AUTF8String folderPath);
  void addFolderRights(in AUTF8String folderPath, in ACString userName, in ACString rights);
  void refreshFolderRights(in AUTF8String folderPath);
  void discoveryDone();
  void onlineFolderDelete(in AUTF8String folderName);
  void onlineFolderCreateFailed(in AUTF8String aFolderName);
  void onlineFolderRename(in nsIMsgWindow msgWindow, in AUTF8String oldName, in AUTF8String newName);
  boolean folderIsNoSelect(in AUTF8String folderName);
  void setFolderAdminURL(in AUTF8String folderName, in AUTF8String adminUrl);
  boolean folderVerifiedOnline(in AUTF8String folderName);

  void setCapability(in unsigned long long capability);
  /// RFC 2971 ID server response
  void setServerID(in ACString aServerID);
  boolean loadNextQueuedUrl(in nsIImapProtocol protocol);

  /**
   * Prepare to retry the given URL.
   * @param imapUrl the url we're going to retry
   * @return channel to associate with the url. We return this because access
   *         to the channel should only happen on the ui thread.
   */
  nsIImapMockChannel prepareToRetryUrl(in nsIImapUrl imapUrl);

  /**
   * Suspend the url. This puts it at the end of the queue. If the queue is
   * empty, the url will get resumed immediately. Currently, the plan is
   * do this when we have to download a lot of headers in chunks, though we
   * could find other uses for it.
   * @param imapUrl url to suspend
   */
  void suspendUrl(in nsIImapUrl aImapUrl);

  /**
   * Retry the given URL.
   * @param imapUrl url to retry
   * @param channel the channel to associate with the url
   */
  void retryUrl(in nsIImapUrl imapUrl, in nsIImapMockChannel channel);

  /**
   * If previous URL failed, this gives server chance to abort URLs with same
   * mock channel.
   */
  void abortQueuedUrls();
  AString getImapStringByName(in string msgName);
  /**
   * Alerts the user that the login to the IMAP server failed. Asks whether the
   * connection should: retry, cancel, or request a new password.
   *
   * @param aMsgWindow The message window associated with this action (cannot
   *                   be null).
   * @return           The button pressed. 0 for retry, 1 for cancel,
   *                   2 for enter a new password.
   */
  int32_t promptLoginFailed(in nsIMsgWindow aMsgWindow);

  /**
   * Alerts the user with the given string (FE = 'Front End').
   *
   * @param aAlertString The string to alert the user with.
   * @param aUrl         The running url.
   */
  void fEAlert(in AString aAlertString, in nsIMsgMailNewsUrl aUrl);

  /**
   * Alerts the user with a localized string. It will attempt to fill in
   * the hostname into the string if necessary.
   *
   * @param aMsgName  The id of the string to present to the user..
   * @param aUrl    The running url.
   */
  void fEAlertWithName(in string aMsgName, in nsIMsgMailNewsUrl aUrl);
  /**
   * Takes a response from the server and prepends it with IMAP_SERVER_SAID
   *
   * @param aServerString  The string to alert the user with.
   * @param url            The running url.
   */
  void fEAlertFromServer(in ACString aServerString, in nsIMsgMailNewsUrl aUrl);

  void commitNamespaces();

  /**
   * Returns a password via the out param, if we were able to prompt for one,
   * or had one stored.
   * If there is already a password prompt up, we return false, but we
   * ask the async prompt service to notify us when we can put up a prompt.
   * When that notification is received, we prompt the user and set the
   * password on the protocol object, and signal a monitor that the imap
   * thread should be waiting on.
   *
   * rv is NS_MSG_PASSWORD_PROMPT_CANCELLED if the user cancels the
   * password prompt. That's not an exception, however.
   *
   * @param aProtocol imap protocol object requesting the password.
   * @param aNewPasswordRequested Forces password prompt immediately
   * @param aPassword returns the password, unless we had to prompt or use the,
   *                  login manager and there was already a prompt up.
   */
  void asyncGetPassword(in nsIImapProtocol aProtocol,
                        in boolean aNewPasswordRequested,
                        out AString aPassword);

  /**
   * Returns a password via the out param if password is stored in login mgr.
   * If no password is stored, this function returns NS_ERROR_NOT_AVAILABLE.
   * This never triggers a password prompt.
   *
   * @param aPassword returns the stored password or empty string if not stored.
   */
  void syncGetPassword(out AString aPassword);

  attribute boolean userAuthenticated;
  void setMailServerUrls(in AUTF8String manageMailAccount, in AUTF8String manageLists, in AUTF8String manageFilters);

  /** Used by the imap thread when upgrading from the socketType
   * trySTARTTLS.
   * @param aSucceeded whether STARTTLS succeeded. If it did, the server
   * will set the socket type to alwaysSTARTTLS, otherwise plain.
   */
  void UpdateTrySTARTTLSPref(in boolean aSucceeded);

  readonly attribute AUTF8String arbitraryHeaders;
  void forgetPassword();

  readonly attribute boolean showAttachmentsInline;
  string cramMD5Hash(in string decodedChallenge, in string key);
  /// String to send to the imap server as the login user name.
  readonly attribute ACString loginUsername;
  /// String to send to the imap server as the user name.
  readonly attribute ACString originalUsername;
  /// Internal pref key, unique over all servers
  readonly attribute ACString serverKey;
  /// password for server login
  readonly attribute AString serverPassword;
  /// remove a connection to the server
  void removeServerConnection(in nsIImapProtocol aProtocol);
  /// is the imap server shutting down?
  readonly attribute boolean serverShuttingDown;
  /// reset the connection for a particular folder
  void resetServerConnection(in AUTF8String aFolderName);
  /// tell the server if listing using lsub command
  void setServerDoingLsub(in boolean aDoingLsub);
  /// set whether UTF8=ACCEPT enabled or not
  void setServerUtf8AcceptEnabled(in boolean aEnabled);
};