38 Components.utils.import(
"resource://app/jsmodules/StringUtils.jsm");
64 label = document.getElementById(
"setupprogress_label");
65 progressmeter = document.getElementById(
"setupprogress_progress");
66 cancelButton = document.getElementById(
"setupprogress_cancel");
67 bundle =
window.arguments[0];
68 pbundle = bundle.QueryInterface(Components.interfaces.sbPIBundle);
69 pbundle.setNeedRestart(
false);
70 bundle = bundle.QueryInterface(Components.interfaces.sbIBundle);
71 n_ext = bundle.bundleExtensionCount;
83 if (cur_ext + 1 > n_ext) {
84 var
sbIBundle = Components.interfaces.sbIBundle;
85 pbundle.setInstallResult(afailure ? sbIBundle.BUNDLE_INSTALL_ERROR : sbIBundle.BUNDLE_INSTALL_SUCCESS);
86 for (var
i = 0;
i < pbundle.installListenerCount;
i++)
87 pbundle.getInstallListener(
i).onComplete(bundle);
93 if (!bundle.getExtensionInstallFlag(cur_ext)) {
98 var downloading =
SBString(
"setupprogress.downloading",
"Downloading");
99 label.setAttribute(
"value", downloading +
" " + bundle.getExtensionAttribute(cur_ext,
"name"));
100 cancelButton.removeAttribute(
"disabled");
102 progressmeter.setAttribute(
"value", 0);
104 for (var
i = 0;
i < pbundle.installListenerCount;
i++)
105 pbundle.getInstallListener(
i).onExtensionDownloadProgress(bundle, cur_ext, 0, 1);
107 destFile =
downloadFile(bundle.getExtensionAttribute(cur_ext,
"url"));
115 progressmeter.setAttribute(
"value", aCurrentProgress / aMaxProgress * 100);
116 for (var
i=0;
i < pbundle.installListenerCount;
i++)
117 pbundle.getInstallListener(
i).onExtensionDownloadProgress(pbundle, cur_ext, aCurrentProgress, aMaxProgress);
125 for (var
i = 0;
i < pbundle.installListenerCount;
i++)
126 pbundle.getInstallListener(
i).onDownloadComplete(pbundle, cur_ext);
130 SBString(
"setupprogress.couldnotinstall",
"Could not install" ) +
" " +
131 bundle.getExtensionAttribute(cur_ext,
"name") );
132 for (var
i = 0;
i < pbundle.installListenerCount;
i++)
133 pbundle.getInstallListener(
i).onInstallError(pbundle, cur_ext);
135 pbundle.setNeedRestart(
true);
138 for (var
i = 0;
i < pbundle.installListenerCount;
i++)
139 pbundle.getInstallListener(
i).onInstallComplete(pbundle, cur_ext);
149 SBString(
"setupprogress.couldnotdownload",
"Downloading" ) +
" " +
150 bundle.getExtensionAttribute(cur_ext,
"name") );
153 for (var
i=0;
i<pbundle.installListenerCount;
i++)
154 pbundle.getInstallListener(
i).onDownloadError(pbundle, cur_ext);
167 event.preventDefault();
178 onLocationChange:
function(aWebProgress, aRequest, aLocation)
182 onProgressChange:
function(aWebProgress, aRequest, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress)
187 onSecurityChange:
function(aWebProgress, aRequest, aStateFlags)
191 onStateChange:
function(aWebProgress, aRequest, aStateFlags, aStatus)
193 if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP)
204 if (aRequest instanceof Components.interfaces.nsIHttpChannel) {
205 if (!aRequest.requestSucceeded) {
209 var
file = Components.classes[
"@mozilla.org/file/local;1"]
210 .createInstance(Components.interfaces.nsILocalFile);
212 if (!file.exists()) {
227 onStatusChange:
function(aWebProgress, aRequest, aStateFlags, strStateMessage)
232 if (!iid.equals(Components.interfaces.nsIWebProgressListener) &&
233 !iid.equals(Components.interfaces.nsISupportsWeakReference) &&
234 !iid.equals(Components.interfaces.nsISupports))
235 throw Components.results.NS_ERROR_NO_INTERFACE;
257 _browser = (Components.classes[
"@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]).
createInstance(Components.interfaces.nsIWebBrowserPersist);
259 if (!_browser)
return null;
262 var aLocalFile = (Components.classes[
"@mozilla.org/file/local;1"]).
createInstance(Components.interfaces.nsILocalFile);
263 aLocalFile.initWithPath(destFile);
266 var aLocalURI = Components.classes[
"@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).newURI(
url +
getRandomParameter(),
null,
null);
268 const nsIWBP = Components.interfaces.nsIWebBrowserPersist;
269 var
flags = nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES |
270 nsIWBP.PERSIST_FLAGS_BYPASS_CACHE;
271 _browser.persistFlags =
flags;
273 _browser.saveURI(aLocalURI,
null,
null,
null,
"", aLocalFile);
280 if (!_browser)
return;
282 var sbs = Components.classes[
"@mozilla.org/intl/stringbundle;1"]
283 .getService(Components.interfaces.nsIStringBundleService);
284 var songbirdStrings = sbs.createBundle(
"chrome://songbird/locale/songbird.properties");
285 var cancelling =
"Cancelling" +
" " + bundle.getExtensionAttribute(cur_ext,
"name");
287 var params = [ bundle.getExtensionAttribute(cur_ext,
"name") ];
288 cancelling = songbirdStrings.formatStringFromName(
"setupprogress.cancelling",
289 params, params.length);
291 label.setAttribute(
"value", cancelling);
292 cancelButton.disabled =
true;
293 progressmeter.setAttribute(
"value", 0);
298 _browser.cancelSave();
320 var strTempFile =
"";
322 var aDirectoryService = Components.classes[
"@mozilla.org/file/directory_service;1"].createInstance();
323 aDirectoryService = aDirectoryService.QueryInterface(Components.interfaces.nsIProperties);
327 var bResult =
new Object;
328 var aTempFolder = aDirectoryService.get(
"DefProfLRt", Components.interfaces.nsIFile, bResult);
330 aTempFolder.append(aUUID);
332 return aTempFolder.path;
341 var aUUIDGenerator = (Components.classes[
"@mozilla.org/uuid-generator;1"]).
createInstance();
342 aUUIDGenerator = aUUIDGenerator.QueryInterface(Components.interfaces.nsIUUIDGenerator);
343 return aUUIDGenerator.generateUUID();
365 var
file = Components.classes[
"@mozilla.org/file/local;1"]
366 .createInstance(Components.interfaces.nsILocalFile);
367 file.initWithPath(localFilename);
369 var em = Components.classes[
"@mozilla.org/extensions/manager;1"]
370 .getService(Components.interfaces.nsIExtensionManager);
372 em.installItemFromFile(file,
"app-profile");
const BUNDLE_ERROR_XPIINSTALLFAILED
function installNextXPI()
Install the next XPI in the list of XPIs to install.
function getTempFilename()
Get a temporary file name.
function succeeded(ch, cx, status, data)
sbDeviceFirmwareAutoCheckForUpdate prototype flags
function handleKeyDown(event)
Handler function used to prevent bubbling of escape and enter key events while the progressSetup dial...
sbOSDControlService prototype QueryInterface
function getRandomParameter()
Generate a random URL parameter.
function generateUUID()
Generate a UUID.
function init()
Initialize the setupProgress dialog.
function SBString(aKey, aDefault, aStringBundle)
function onExtensionDownloadError()
Listener function used to recover from any errors that occur during the download of an XPI...
function downloadFile(url)
Download an XPI file from a URL. Downloads an XPI file from a URL to a temporary file on disk...
aWindow setTimeout(function(){_this.restoreHistory(aWindow, aTabs, aTabData, aIdMap);}, 0)
function deleteLastDownloadedFile()
Delete the last downloaded XPI file.
function forceInstallXPI(localFilename)
Force installation of an XPI. This method will install the XPI without asking the user's permission...
const BUNDLE_ERROR_DOWNLOADFAILED
Songbird Bundle Interface This is the main bundle management interface, used to get the bundle data...
ContinuingWebProgressListener prototype onStateChange
function cancelDownload()
function onExtensionDownloadProgress(aCurrentProgress, aMaxProgress)
Listener function used to track progress of XPIs being downloaded.
var _downloadListener
Download listener object used to track progress of XPI downloads.
_getSelectedPageStyle s i
function onExtensionDownloadComplete()
Listener function used to trigger installation of XPI when download is complete.