RSS feed [root] /hack and faq /weblog




login:

password:

title search:




 


Wed Nov 28 19:52:35 GMT 2007

xul



On 9/27/07, Carfield Yim wrote:

How to get instance fo nsIDownloader using javaxpcom?



It's not too difficult. The JavaScript code you pointed to has this line:

var nsIDownloader = Components.classes["@ mozilla.org/network/downloader;1"].createInstance();



The "Components" object is a helper object in Mozilla JavaScript, so we need to do things differently in JavaXPCOM.



We need to use the nsIComponentManager interface ( http://mxr.mozilla.org[..]com/components/nsIComponentManager.idl), which has a createInstance() method. So something like this:



nsIComponentManager compMgr = Mozilla.getInstance().getComponentManager();

nsIDownloader createInstance = (nsIDownloader) compMgr

.createInstance( "@ mozilla.org/network/downloader;1", null,

nsIDownloader.NS_IDOWNLOADER_IID );


(google search) (amazon search)
second
download zip of files only