Monitoring downloads - MDC. Firefox 3 makes it easier than ever to monitor the status of downloads. Although it was possible to do so in previous versions of Firefox, it was previously only possible for one observer to do so at a time. Firefox 3 introduces new API that allows any number of listeners to observe downloads. This article demonstrates how to monitor downloads in Firefox 3, using the Download Manager. As a nice bonus, it also demonstrates how to use the Storage API to issue sqlite commands on a database. The result is a window you can open by choosing "Download log" in the Tools menu, which lists all downloads that have been started since you installed the extension.
Download the full sample. Setting up When the extension loads, it will do some housekeeping chores. This is fairly simple stuff. Finally, the database is closed. Note: The mozIStorageConnection method close() is being added to Firefox 3 alpha 8; in prior versions of Firefox, there is no way to explicitly close the database. See also. NsIDownloadProgressListener - MDC. This interface gives applications and extensions a way to monitor the status of downloads being processed by the Download Manager. Inherits from: nsISupportsLast changed in Gecko 1.9.1 (Firefox 3.5 / Thunderbird 3.0 / SeaMonkey 2.0) As the states of downloads change, the methods described here are called by the Download Manager so your code can take whatever steps it needs to.
This interface works very similarly to the nsIWebProgress interface. It is important to note that there is no service for this listener. Rather, the developer must create an object with the methods provided below to implement it. Method overview Attributes Methods Requires Gecko 1.9.1 (Firefox 3.5 / Thunderbird 3.0 / SeaMonkey 2.0) onDownloadStateChange() Called when the status of a particular download changes. void onDownloadStateChange( in short aState, in nsIDownload aDownload ); Parameters aState The previous state of the download.
aDownload The nsIDownload object representing the file whose download status has changed. NsIDownloadManager - MDC. This interface lets applications and extensions communicate with the Download Manager, adding and removing files to be downloaded, fetching information about downloads, and being notified when downloads are completed. Inherits from: nsISupportsLast changed in Gecko 1.9.1 (Firefox 3.5 / Thunderbird 3.0 / SeaMonkey 2.0) Implemented by: @mozilla.org/download-manager;1. To get the service, use: var downloadManager = Components.classes["@mozilla.org/download-manager;1"] .getService(Components.interfaces.nsIDownloadManager); Method overview Attributes Constants Methods addDownload() Creates an nsIDownload and adds it to the list of activities being managed by the Download Manager.
Note: Prior to Gecko 12.0, this was a synchronous operation; that is, once this method returned, you knew that the download was in the Download Manager's list. Parameters aDownloadType The download type for the transfer. aSource The source URI of the transfer. aTarget aDisplayName A user-readable description of the transfer. aID. NsIDownload - MDC. Download onStateChange question. File types and download actions. From MozillaZine Knowledge Base This article describes how Mozilla browsers handle downloads for different file types and how to change that behavior. It applies to Firefox, Mozilla Suite/SeaMonkey 1.x and SeaMonkey 2. For help with embedded media or a "missing plugin" alert, see Video or audio does not play. For help with Thunderbird mail attachments, see Actions for attachment file types. Opening dialog When you click a link to download a file, the MIME type determines what action is taken.
The "Open with" option can show a "Choose" or "Browse" button, if no application is associated with the file type (shown here on Windows), or it may show a default application for the file type. Setting an automatic action Warning! Unable to set an automatic action In some cases, you may not be able to set an automatic download action. Resetting download actions This section applies to all versions of Firefox and Mozilla Suite/SeaMonkey Type about:config into the address bar.
Audio and video content <!