I am building an installer which needs to download files from remote http:// or ftp:// sites. I have been using the saveURI method to get the files, and it works great. Except in some cases where it simply stops and doesn't return an error.
In the specific example I am thinking of, Firefox cannot get the link by clicking, nor can I use the saveURI method successfully. However, using wget, I can get the link without a problem everytime. It *is* there and intact. (If you're interested, the specific problem link is: ftp://ftp.ibiblio.org/pub/linux/distributions/vectorlinux/development/veclinux-soho-4.0-dev/stable/games/SDL_perl-1.19.2-i586-1.tgz ) The questions are: 1) Does anyone know why I can't get this in Firefox by any method I try, but the neighboring files from the same server save without an issue using Firefox? 2) Is there a way to set a listener to issue a pre-set timeout on the download? There is no state change or progress change triggered by this download, so the usual callback functions don't seem to be working. My code snippet is below: function saveURI(url,file) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); uri = Components.classes["@mozilla.org/network/standard-url;1"]. createInstance(Components.interfaces.nsIURI); uri.spec = url; localFile = Components.classes["@mozilla.org/file/local;1"]. createInstance(Components.interfaces.nsILocalFile) localFile.initWithPath(file) persistListener = new PersistProgressListener; persist = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]. createInstance(Components.interfaces.nsIWebBrowserPersist); persist.progressListener = persistListener; persist.persistFlags = persist.PERSIST_FLAGS_FAIL_ON_BROKEN_LINKS; // persist.saveURI(uri, null, localFile); // <-Outdated form // // Code seems to stop at following line, but without getting to callbacks // persist.saveURI(uri,null,null,null,null,localFile); //persist.cancelSave(); } catch(e) { alert("Exception: " + e); } } function PersistProgressListener() { this.init(); } PersistProgressListener.prototype = { QueryInterface : function(aIID) { if(aIID.equals(Components.interfaces.nsIWebProgressListener)) return this; throw Components.results.NS_NOINTERFACE; }, init : function() { }, destroy : function() { }, // nsIWebProgressListener onProgressChange : function (aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress) { setProgress(aCurTotalProgress, aMaxTotalProgress, aCurSelfProgress, aMaxSelfProgress); }, onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); if(persist.currentState == persist.PERSIST_STATE_READY) { persiststate = persiststate + "Persister is ready to save data." + "<br>"; } else if(persist.currentState == persist.PERSIST_STATE_SAVING) { persiststate = persiststate + "Persister is saving data." + "<br>"; } else if(persist.currentState == persist.PERSIST_STATE_FINISHED) { persiststate = persiststate + "Persister has finished saving data." + "<br>"; } } catch(e) { alert("Exception: " + e); } }, onLocationChange : function(aWebProgress, aRequest, aLocation) { }, onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) { setStatus(aMessage); }, onSecurityChange : function(aWebProgress, aRequest, aState) { } } Thanks! Tim ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. _______________________________________________ Mozilla-xpcom mailing list [email protected] http://mail.mozilla.org/listinfo/mozilla-xpcom
