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 "nsIURL.idl"
8
9interface nsIFile;
10interface nsIUrlListener;
11interface nsIMsgStatusFeedback;
12interface nsIMsgIncomingServer;
13interface nsIMsgWindow;
14interface nsILoadGroup;
15interface nsIMsgSearchSession;
16interface nsICacheEntry;
17interface nsIMimeHeaders;
18interface nsIStreamListener;
19interface nsIMsgFolder;
20interface nsIMsgHeaderSink;
21interface nsIMsgDBHdr;
22interface nsIDocShell;
23interface nsITransportSecurityInfo;
24
25[scriptable, builtinclass, uuid(995455ba-5bb4-4643-8d70-2b877a2e1320)]
26interface nsIMsgMailNewsUrl : nsIURL {
27  [noscript,notxpcom,nostdcall]
28  nsresult setFileNameInternal(in ACString aFileName);
29
30  [noscript,notxpcom,nostdcall]
31  nsresult setSpecInternal(in ACString aSpec);
32
33  [noscript,notxpcom,nostdcall]
34  nsresult setPortInternal(in long aPort);
35
36  [noscript,notxpcom,nostdcall]
37  nsresult setQueryInternal(in ACString aQuery);
38
39  [noscript,notxpcom,nostdcall]
40  nsresult setUsernameInternal(in ACString aUsername);
41
42  ///////////////////////////////////////////////////////////////////////////////
43  // Eventually we'd like to push this type of functionality up into nsIURI.
44  // The idea is to allow the "application" (the part of the code which wants to
45  // run a url in order to perform some action) to register itself as a listener
46  // on url. As a url listener, the app will be informed when the url begins to run
47  // and when the url is finished.
48  ////////////////////////////////////////////////////////////////////////////////
49  void RegisterListener(in nsIUrlListener aUrlListener);
50  void UnRegisterListener(in nsIUrlListener aUrlListener);
51
52  readonly attribute nsIURI baseURI;
53
54  // if you really want to know what the current state of the url is (running or not
55  // running) you should look into becoming a urlListener...
56  void SetUrlState(in boolean runningUrl, in nsresult aStatusCode);
57  void GetUrlState(out boolean runningUrl);
58
59  readonly attribute nsIMsgIncomingServer server;
60
61  /**
62   * Transport-level security information (if any), in the case of a security
63   * error having occurred.
64   * This value should be considered undefined if an NSS error has not
65   * occurred. Read it as: "the secInfo that was being used when a failure
66   * occurred", not: "the secInfo that failed".
67   * Seems a bit ugly adding more state here, but the idea is that a
68   * nsIUrlListener.OnStopRunningUrl() needs to be able to access a bad
69   * certificate, so as to have the option of adding an exemption (See
70   * Bug 1590473).
71   */
72  attribute nsITransportSecurityInfo failedSecInfo;
73
74  /**
75   * The folder associated with this url.
76   *
77   * @exception NS_ERROR_FAILURE    May be thrown if the url does not
78   *                                relate to a folder, e.g. standalone
79   *                                .eml messages.
80   */
81  attribute nsIMsgFolder folder;
82
83  attribute nsIMsgStatusFeedback statusFeedback;
84
85  /**
86   * The maximum progress for this URL. This might be a count, or it might
87   * be a number of bytes. A value of -1 indicates that this is unknown.
88   */
89  attribute long long maxProgress;
90
91  attribute nsIMsgWindow msgWindow;
92
93  // current mime headers if reading message
94  attribute nsIMimeHeaders mimeHeaders;
95
96  // the load group is computed from the msgWindow
97  readonly attribute nsILoadGroup loadGroup;
98
99  // search session, if we're running a search.
100  attribute nsIMsgSearchSession searchSession;
101  attribute boolean updatingFolder;
102  attribute boolean msgIsInLocalCache;
103  attribute boolean suppressErrorMsgs; // used to avoid displaying biff error messages
104
105  /**
106   * Set after an error occurred.
107   * It is not translated and contains no parameters.
108   * It is unique to each different kind of error, i.e. the same
109   * error has the same code, but a different error has a different code.
110   * This allows to recover from specific errors programmatically,
111   * or to keep error statistics.
112   * If the error comes from a server, the implementor should make
113   * efforts to pass on comparable server error identifiers and include
114   * them here, e.g. as suffixes. Example: "imap-sasl-S474", where-as "S474"
115   * comes from the server annd "imap-sasl-" is the prefix for where the
116   * server reports appears.
117   */
118  attribute ACString errorCode;
119  /**
120   * Set after an error occurred.
121   * An error message that can be displayed directly
122   * to the end user without further processing.
123   * It must have been translated.
124   * It may contain contain values as part of the message.
125   */
126  attribute AString errorMessage;
127
128  attribute nsICacheEntry memCacheEntry;
129
130  const unsigned long eCopy     = 0;
131  const unsigned long eMove     = 1;
132  const unsigned long eDisplay  = 2;
133  boolean IsUrlType(in unsigned long type);
134  nsIStreamListener getSaveAsListener(in boolean addDummyEnvelope, in nsIFile aFile);
135
136  // typically the header sink is tied to the nsIMsgWindow, but in certain circumstances, a consumer
137  // may chose to provide its own header sink for this url
138  attribute nsIMsgHeaderSink msgHeaderSink;
139
140  /// Returns true if the URI is for a message (e.g., imap-message://)
141  readonly attribute boolean isMessageUri;
142
143  /**
144   * Loads the URI in a docshell. This will give priority to loading the
145   * URI in the passed-in docshell. If it can't be loaded there
146   * however, the URL dispatcher will go through its normal process of content
147   * loading.
148   *
149   * @param docshell     The docshell that will consume the load.
150   *
151   * @param aLoadFlags   Flags to modify load behaviour. Flags are defined in
152   *                     nsIWebNavigation. Normally only LOAD_FLAGS_NONE or
153   *                     LOAD_FLAGS_IS_LINK is needed, but there are eleven
154   *                     other allowed sets of flags. See nsDocShellLoadTypes.h
155   */
156   void loadURI(in nsIDocShell docshell,
157                in unsigned long aLoadFlags);
158
159};
160
161//////////////////////////////////////////////////////////////////////////////////
162// This is a very small interface which I'm grouping with the mailnewsUrl interface.
163// Several url types (mailbox, imap, nntp) have similar properties because they can
164// represent mail messages. For instance, these urls can be have URI
165// equivalents which represent a message.
166// We want to provide the app the ability to get the URI for the
167// url. This URI to URL mapping doesn't exist for all mailnews urls...hence I'm
168// grouping it into a separate interface...
169//////////////////////////////////////////////////////////////////////////////////
170
171[scriptable, uuid(388a37ec-2e1a-4a4f-9d8b-189bedf1bda2)]
172interface nsIMsgMessageUrl : nsISupports {
173  // get and set the RDF URI associated with the url. Note, not all urls have
174  // had uri's set on them so be prepared to handle cases where this string is empty.
175  attribute AUTF8String uri;
176  // used by imap, pop and nntp in order to implement save message to disk
177  attribute nsIFile messageFile;
178  attribute boolean AddDummyEnvelope;
179  attribute boolean canonicalLineEnding;
180  attribute AUTF8String originalSpec;
181
182  // This is used when creating a principal for the URL with a "normalized" spec
183  // that doesn't contain all the bits in the query part that mailnews URLs have.
184  // We need this to implement nsIURIWithSpecialOrigin, since mailnews URLs
185  // have ORIGIN_IS_FULL_SPEC.
186  readonly attribute AUTF8String normalizedSpec;
187
188  /**
189   *  A message db header for that message.
190   *
191   *  @note This attribute is not guaranteed to be set, so callers that
192   *  actually require an nsIMsgDBHdr will need to use the uri attribute
193   *  on this interface to get the  appropriate nsIMsgMessageService and
194   *  then get the header from there.
195   */
196  attribute nsIMsgDBHdr messageHeader;
197};
198
199//////////////////////////////////////////////////////////////////////////////////
200// This is a very small interface which I'm grouping with the mailnewsUrl interface.
201// I want to isolate out all the I18N specific information that may be associated with
202// any given mailnews url. This gives I18N their own "sandbox" of routines they can add
203// and tweak as they see fit. For now it contains mostly charset information.
204//////////////////////////////////////////////////////////////////////////////////
205
206[scriptable, uuid(D71E0785-2862-11d4-98C1-001083010E9B)]
207interface nsIMsgI18NUrl : nsISupports {
208  // when true the user wants us to auto detect the character set.
209  attribute boolean overRideCharset;
210};
211