1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 * Blake Ross <blaker@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 "nsITransfer.idl"
40
41 interface nsIURI;
42 interface nsILocalFile;
43 interface nsIObserver;
44 interface nsICancelable;
45 interface nsIWebProgressListener;
46 interface nsIMIMEInfo;
47
48 /**
49 * Represents a download object.
50 *
51 * @note This object is no longer updated once it enters a completed state.
52 * Completed states are the following:
53 * nsIDownloadManager::DOWNLOAD_FINISHED
54 * nsIDownloadManager::DOWNLOAD_FAILED
55 * nsIDownloadManager::DOWNLOAD_CANCELED
56 * nsIDownloadManager::DOWNLOAD_BLOCKED_PARENTAL
57 * nsIDownloadManager::DOWNLOAD_DIRTY
58 * nsIDownloadManager::DOWNLOAD_BLOCKED_POLICY
59 */
60 [scriptable, uuid(c891111e-92a6-47b8-bc46-874ebb61ac9d)]
61 interface nsIDownload : nsITransfer {
62
63 /**
64 * The target of a download is always a file on the local file system.
65 */
66 readonly attribute nsILocalFile targetFile;
67
68 /**
69 * The percentage of transfer completed.
70 * If the file size is unknown it'll be -1 here.
71 */
72 readonly attribute long percentComplete;
73
74 /**
75 * The amount of bytes downloaded so far.
76 */
77 readonly attribute long long amountTransferred;
78
79 /**
80 * The size of file in bytes.
81 * Unknown size is represented by -1.
82 */
83 readonly attribute long long size;
84
85 /**
86 * The source of the transfer.
87 */
88 readonly attribute nsIURI source;
89
90 /**
91 * The target of the transfer.
92 */
93 readonly attribute nsIURI target;
94
95 /**
96 * Object that can be used to cancel the download.
97 * Will be null after the download is finished.
98 */
99 readonly attribute nsICancelable cancelable;
100
101 /**
102 * The user-readable description of the transfer.
103 */
104 readonly attribute AString displayName;
105
106 /**
107 * The time a transfer was started.
108 */
109 readonly attribute long long startTime;
110
111 /**
112 * The speed of the transfer in bytes/sec.
113 */
114 readonly attribute double speed;
115
116 /**
117 * Optional. If set, it will contain the target's relevant MIME information.
118 * This includes it's MIME Type, helper app, and whether that helper should be
119 * executed.
120 */
121 readonly attribute nsIMIMEInfo MIMEInfo;
122
123 /**
124 * The id of the download that is stored in the database.
125 */
126 readonly attribute unsigned long id;
127
128 /**
129 * The state of the download.
130 * @see nsIDownloadManager and nsIXPInstallManagerUI
131 */
132 readonly attribute short state;
133
134 /**
135 * The referrer uri of the download. This is only valid for HTTP downloads,
136 * and can be null.
137 */
138 readonly attribute nsIURI referrer;
139
140 /**
141 * Indicates if the download can be resumed after being paused or not. This
142 * is only the case if the download is over HTTP/1.1 or FTP and if the
143 * server supports it.
144 */
145 readonly attribute boolean resumable;
146 };
147
148 %{C++
149 // {E3FA9D0A-1DD1-11B2-BDEF-8C720B597445}
150 #define NS_DOWNLOAD_CID \
151 { 0xe3fa9d0a, 0x1dd1, 0x11b2, { 0xbd, 0xef, 0x8c, 0x72, 0x0b, 0x59, 0x74, 0x45 } }
152 %}