michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsITransfer.idl" michael@0: michael@0: interface nsIURI; michael@0: interface nsIFile; michael@0: interface nsIObserver; michael@0: interface nsICancelable; michael@0: interface nsIWebProgressListener; michael@0: interface nsIMIMEInfo; michael@0: michael@0: /** michael@0: * Represents a download object. michael@0: * michael@0: * @note This object is no longer updated once it enters a completed state. michael@0: * Completed states are the following: michael@0: * nsIDownloadManager::DOWNLOAD_FINISHED michael@0: * nsIDownloadManager::DOWNLOAD_FAILED michael@0: * nsIDownloadManager::DOWNLOAD_CANCELED michael@0: * nsIDownloadManager::DOWNLOAD_BLOCKED_PARENTAL michael@0: * nsIDownloadManager::DOWNLOAD_DIRTY michael@0: * nsIDownloadManager::DOWNLOAD_BLOCKED_POLICY michael@0: */ michael@0: [scriptable, uuid(b02be33b-d47c-4bd3-afd9-402a942426b0)] michael@0: interface nsIDownload : nsITransfer { michael@0: michael@0: /** michael@0: * The target of a download is always a file on the local file system. michael@0: */ michael@0: readonly attribute nsIFile targetFile; michael@0: michael@0: /** michael@0: * The percentage of transfer completed. michael@0: * If the file size is unknown it'll be -1 here. michael@0: */ michael@0: readonly attribute long percentComplete; michael@0: michael@0: /** michael@0: * The amount of bytes downloaded so far. michael@0: */ michael@0: readonly attribute long long amountTransferred; michael@0: michael@0: /** michael@0: * The size of file in bytes. michael@0: * Unknown size is represented by -1. michael@0: */ michael@0: readonly attribute long long size; michael@0: michael@0: /** michael@0: * The source of the transfer. michael@0: */ michael@0: readonly attribute nsIURI source; michael@0: michael@0: /** michael@0: * The target of the transfer. michael@0: */ michael@0: readonly attribute nsIURI target; michael@0: michael@0: /** michael@0: * Object that can be used to cancel the download. michael@0: * Will be null after the download is finished. michael@0: */ michael@0: readonly attribute nsICancelable cancelable; michael@0: michael@0: /** michael@0: * The user-readable description of the transfer. michael@0: */ michael@0: readonly attribute AString displayName; michael@0: michael@0: /** michael@0: * The time a transfer was started. michael@0: */ michael@0: readonly attribute long long startTime; michael@0: michael@0: /** michael@0: * The speed of the transfer in bytes/sec. michael@0: */ michael@0: readonly attribute double speed; michael@0: michael@0: /** michael@0: * Optional. If set, it will contain the target's relevant MIME information. michael@0: * This includes its MIME Type, helper app, and whether that helper should be michael@0: * executed. michael@0: */ michael@0: readonly attribute nsIMIMEInfo MIMEInfo; michael@0: michael@0: /** michael@0: * The id of the download that is stored in the database - not globally unique. michael@0: * For example, a private download and a public one might have identical ids. michael@0: * Can only be safely used for direct database manipulation in the database that michael@0: * contains this download. Use the guid property instead for safe, database-agnostic michael@0: * searching and manipulation. michael@0: * michael@0: * @deprecated michael@0: */ michael@0: readonly attribute unsigned long id; michael@0: michael@0: /** michael@0: * The guid of the download that is stored in the database. michael@0: * Has the form of twelve alphanumeric characters. michael@0: */ michael@0: readonly attribute ACString guid; michael@0: michael@0: /** michael@0: * The state of the download. michael@0: * @see nsIDownloadManager and nsIXPInstallManagerUI michael@0: */ michael@0: readonly attribute short state; michael@0: michael@0: /** michael@0: * The referrer uri of the download. This is only valid for HTTP downloads, michael@0: * and can be null. michael@0: */ michael@0: readonly attribute nsIURI referrer; michael@0: michael@0: /** michael@0: * Indicates if the download can be resumed after being paused or not. This michael@0: * is only the case if the download is over HTTP/1.1 or FTP and if the michael@0: * server supports it. michael@0: */ michael@0: readonly attribute boolean resumable; michael@0: michael@0: /** michael@0: * Indicates if the download was initiated from a context marked as private, michael@0: * controlling whether it should be stored in a permanent manner or not. michael@0: */ michael@0: readonly attribute boolean isPrivate; michael@0: michael@0: /** michael@0: * Cancel this download if it's currently in progress. michael@0: */ michael@0: void cancel(); michael@0: michael@0: /** michael@0: * Pause this download if it is in progress. michael@0: * michael@0: * @throws NS_ERROR_UNEXPECTED if it cannot be paused. michael@0: */ michael@0: void pause(); michael@0: michael@0: /** michael@0: * Resume this download if it is paused. michael@0: * michael@0: * @throws NS_ERROR_UNEXPECTED if it cannot be resumed or is not paused. michael@0: */ michael@0: void resume(); michael@0: michael@0: /** michael@0: * Instruct the download manager to remove this download. Whereas michael@0: * cancel simply cancels the transfer, but retains information about it, michael@0: * remove removes all knowledge of it. michael@0: * michael@0: * @see nsIDownloadManager.removeDownload for more detail michael@0: * @throws NS_ERROR_FAILURE if the download is active. michael@0: */ michael@0: void remove(); michael@0: michael@0: /** michael@0: * Instruct the download manager to retry this failed download michael@0: * @throws NS_ERROR_NOT_AVAILABLE if the download is not known. michael@0: * @throws NS_ERROR_FAILURE if the download is not in the following states: michael@0: * nsIDownloadManager::DOWNLOAD_CANCELED michael@0: * nsIDownloadManager::DOWNLOAD_FAILED michael@0: */ michael@0: void retry(); michael@0: }; michael@0: michael@0: %{C++ michael@0: // {b02be33b-d47c-4bd3-afd9-402a942426b0} michael@0: #define NS_DOWNLOAD_CID \ michael@0: { 0xb02be33b, 0xd47c, 0x4bd3, { 0xaf, 0xd9, 0x40, 0x2a, 0x94, 0x24, 0x26, 0xb0 } } michael@0: %}