On 03/09/2013 18.08, teramako wrote:
> I want to notify to the user when the download is finished.
> 
> on nsIDownloadManager, I write like following:
> 
> Services.downloads.addListener({
>  onDownloadStateChange: function (state, download) {
>    if (download.state === Services.downloads.DOWNLOAD_FINISHED) {
>       openPopup(.....);
>    }
>  },
>  ...
> });
> 
> on Download.jsm, how to register a observer if can do ?
> I read Download.jsm and related files, but couldn't find.

You need to add a view on the public (and private, if needed) download
lists (getPublicDownloadList, getPrivateDownloadList).

If you're just interested on completion, in the onDownloadAdded
callback of the object you provided to addView, you can register a
whenSucceeded callback on the download:

aDownload.whenSucceeded().then(function () { ... });

For other states, you need to handle them in the onDownloadChanged
callback. You should track your own previous state for the changes
you're interested into, if applicable.

Cheers,
Paolo
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to