|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
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 "nsIWebProgressListener2.idl" |
|
7 |
|
8 interface nsIArray; |
|
9 interface nsIURI; |
|
10 interface nsICancelable; |
|
11 interface nsIMIMEInfo; |
|
12 interface nsIFile; |
|
13 |
|
14 [scriptable, uuid(0c81b265-34b8-472d-be98-099b2512e3ec)] |
|
15 interface nsITransfer : nsIWebProgressListener2 { |
|
16 |
|
17 /** |
|
18 * Initializes the transfer with certain properties. This function must |
|
19 * be called prior to accessing any properties on this interface. |
|
20 * |
|
21 * @param aSource The source URI of the transfer. Must not be null. |
|
22 * |
|
23 * @param aTarget The target URI of the transfer. Must not be null. |
|
24 * |
|
25 * @param aDisplayName The user-readable description of the transfer. |
|
26 * Can be empty. |
|
27 * |
|
28 * @param aMIMEInfo The MIME info associated with the target, |
|
29 * including MIME type and helper app when appropriate. |
|
30 * This parameter is optional. |
|
31 * |
|
32 * @param startTime Time when the download started (ie, when the first |
|
33 * response from the server was received) |
|
34 * XXX presumably wbp and exthandler do this differently |
|
35 * |
|
36 * @param aTempFile The location of a temporary file; i.e. a file in which |
|
37 * the received data will be stored, but which is not |
|
38 * equal to the target file. (will be moved to the real |
|
39 * target by the caller, when the download is finished) |
|
40 * May be null. |
|
41 * |
|
42 * @param aCancelable An object that can be used to abort the download. |
|
43 * Must not be null. |
|
44 * Implementations are expected to hold a strong |
|
45 * reference to this object until the download is |
|
46 * finished, at which point they should release the |
|
47 * reference. |
|
48 * |
|
49 * @param aIsPrivate Used to determine the privacy status of the new transfer. |
|
50 * If true, indicates that the transfer was initiated from |
|
51 * a source that desires privacy. |
|
52 */ |
|
53 void init(in nsIURI aSource, |
|
54 in nsIURI aTarget, |
|
55 in AString aDisplayName, |
|
56 in nsIMIMEInfo aMIMEInfo, |
|
57 in PRTime startTime, |
|
58 in nsIFile aTempFile, |
|
59 in nsICancelable aCancelable, |
|
60 in boolean aIsPrivate); |
|
61 |
|
62 /* |
|
63 * Used to notify the transfer object of the hash of the downloaded file. |
|
64 * Must be called on the main thread, only after the download has finished |
|
65 * successfully. |
|
66 * @param aHash The SHA-256 hash in raw bytes of the downloaded file. |
|
67 */ |
|
68 void setSha256Hash(in ACString aHash); |
|
69 |
|
70 /* |
|
71 * Used to notify the transfer object of the signature of the downloaded |
|
72 * file. Must be called on the main thread, only after the download has |
|
73 * finished successfully. |
|
74 * @param aSignatureInfo The nsIArray of nsIX509CertList of nsIX509Cert |
|
75 * certificates of the downloaded file. |
|
76 */ |
|
77 void setSignatureInfo(in nsIArray aSignatureInfo); |
|
78 |
|
79 }; |
|
80 |
|
81 %{C++ |
|
82 /** |
|
83 * A component with this contract ID will be created each time a download is |
|
84 * started, and nsITransfer::Init will be called on it and an observer will be set. |
|
85 * |
|
86 * Notifications of the download progress will happen via |
|
87 * nsIWebProgressListener/nsIWebProgressListener2. |
|
88 * |
|
89 * INTERFACES THAT MUST BE IMPLEMENTED: |
|
90 * nsITransfer |
|
91 * nsIWebProgressListener |
|
92 * nsIWebProgressListener2 |
|
93 * |
|
94 * XXX move this to nsEmbedCID.h once the interfaces (and the contract ID) are |
|
95 * frozen. |
|
96 */ |
|
97 #define NS_TRANSFER_CONTRACTID "@mozilla.org/transfer;1" |
|
98 %} |