nsIDownload.idl 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. #include "nsITransfer.idl"
  6. interface nsIURI;
  7. interface nsIFile;
  8. interface nsIObserver;
  9. interface nsICancelable;
  10. interface nsIWebProgressListener;
  11. interface nsIMIMEInfo;
  12. /**
  13. * Represents a download object.
  14. *
  15. * @note This object is no longer updated once it enters a completed state.
  16. * Completed states are the following:
  17. * nsIDownloadManager::DOWNLOAD_FINISHED
  18. * nsIDownloadManager::DOWNLOAD_FAILED
  19. * nsIDownloadManager::DOWNLOAD_CANCELED
  20. * nsIDownloadManager::DOWNLOAD_BLOCKED_PARENTAL
  21. * nsIDownloadManager::DOWNLOAD_DIRTY
  22. * nsIDownloadManager::DOWNLOAD_BLOCKED_POLICY
  23. */
  24. [scriptable, uuid(2258f465-656e-4566-87cb-f791dbaf0322)]
  25. interface nsIDownload : nsITransfer {
  26. /**
  27. * The target of a download is always a file on the local file system.
  28. */
  29. readonly attribute nsIFile targetFile;
  30. /**
  31. * The percentage of transfer completed.
  32. * If the file size is unknown it'll be -1 here.
  33. */
  34. readonly attribute long percentComplete;
  35. /**
  36. * The amount of bytes downloaded so far.
  37. */
  38. readonly attribute long long amountTransferred;
  39. /**
  40. * The size of file in bytes.
  41. * Unknown size is represented by -1.
  42. */
  43. readonly attribute long long size;
  44. /**
  45. * The source of the transfer.
  46. */
  47. readonly attribute nsIURI source;
  48. /**
  49. * The target of the transfer.
  50. */
  51. readonly attribute nsIURI target;
  52. /**
  53. * Object that can be used to cancel the download.
  54. * Will be null after the download is finished.
  55. */
  56. readonly attribute nsICancelable cancelable;
  57. /**
  58. * The user-readable description of the transfer.
  59. */
  60. readonly attribute AString displayName;
  61. /**
  62. * The time a transfer was started.
  63. */
  64. readonly attribute long long startTime;
  65. /**
  66. * The speed of the transfer in bytes/sec.
  67. */
  68. readonly attribute double speed;
  69. /**
  70. * Optional. If set, it will contain the target's relevant MIME information.
  71. * This includes its MIME Type, helper app, and whether that helper should be
  72. * executed.
  73. */
  74. readonly attribute nsIMIMEInfo MIMEInfo;
  75. /**
  76. * The id of the download that is stored in the database - not globally unique.
  77. * For example, a private download and a public one might have identical ids.
  78. * Can only be safely used for direct database manipulation in the database that
  79. * contains this download. Use the guid property instead for safe, database-agnostic
  80. * searching and manipulation.
  81. *
  82. * @deprecated
  83. */
  84. readonly attribute unsigned long id;
  85. /**
  86. * The guid of the download that is stored in the database.
  87. * Has the form of twelve alphanumeric characters.
  88. */
  89. readonly attribute ACString guid;
  90. /**
  91. * The state of the download.
  92. * @see nsIDownloadManager and nsIXPInstallManagerUI
  93. */
  94. readonly attribute short state;
  95. /**
  96. * The referrer uri of the download. This is only valid for HTTP downloads,
  97. * and can be null.
  98. */
  99. readonly attribute nsIURI referrer;
  100. /**
  101. * Indicates if the download can be resumed after being paused or not. This
  102. * is only the case if the download is over HTTP/1.1 or FTP and if the
  103. * server supports it.
  104. */
  105. readonly attribute boolean resumable;
  106. /**
  107. * Indicates if the download was initiated from a context marked as private,
  108. * controlling whether it should be stored in a permanent manner or not.
  109. */
  110. readonly attribute boolean isPrivate;
  111. /**
  112. * Cancel this download if it's currently in progress.
  113. */
  114. void cancel();
  115. /**
  116. * Pause this download if it is in progress.
  117. *
  118. * @throws NS_ERROR_UNEXPECTED if it cannot be paused.
  119. */
  120. void pause();
  121. /**
  122. * Resume this download if it is paused.
  123. *
  124. * @throws NS_ERROR_UNEXPECTED if it cannot be resumed or is not paused.
  125. */
  126. void resume();
  127. /**
  128. * Instruct the download manager to remove this download. Whereas
  129. * cancel simply cancels the transfer, but retains information about it,
  130. * remove removes all knowledge of it.
  131. *
  132. * @see nsIDownloadManager.removeDownload for more detail
  133. * @throws NS_ERROR_FAILURE if the download is active.
  134. */
  135. void remove();
  136. /**
  137. * Instruct the download manager to retry this failed download
  138. * @throws NS_ERROR_NOT_AVAILABLE if the download is not known.
  139. * @throws NS_ERROR_FAILURE if the download is not in the following states:
  140. * nsIDownloadManager::DOWNLOAD_CANCELED
  141. * nsIDownloadManager::DOWNLOAD_FAILED
  142. */
  143. void retry();
  144. };
  145. %{C++
  146. // {b02be33b-d47c-4bd3-afd9-402a942426b0}
  147. #define NS_DOWNLOAD_CID \
  148. { 0xb02be33b, 0xd47c, 0x4bd3, { 0xaf, 0xd9, 0x40, 0x2a, 0x94, 0x24, 0x26, 0xb0 } }
  149. %}