26 Components.utils.import(
"resource://gre/modules/XPCOMUtils.jsm");
30 const Cc = Components.classes;
31 const Ci = Components.interfaces;
32 const Cr = Components.results
33 const Cu = Components.utils
36 this._datalisteners =
new Array();
37 this._installlisteners =
new Array();
39 var obs = Components.classes[
"@mozilla.org/observer-service;1"]
40 .getService(Components.interfaces.nsIObserverService);
41 obs.addObserver(
this,
"quit-application",
false);
44 Bundle.prototype.constructor = Bundle;
48 classID: Components.ID(
"{ff29ec35-1294-42ae-a341-63d0303df969}"),
49 contractID:
"@songbirdnest.com/Songbird/Bundle;1",
55 _installlisteners:
null,
65 _simulate_lots_of_entries:
false,
73 var consoleService = Components.classes[
'@mozilla.org/consoleservice;1']
74 .getService(Components.interfaces.nsIConsoleService);
75 consoleService.logStringMessage(
str);
80 return this._bundleid;
83 set bundleId(aStringValue) {
85 if (aStringValue ==
null)
87 this._bundleid = aStringValue;
90 set bundleURL(aBundleURL) {
92 if (aBundleURL ==
null)
94 this._bundleURL = aBundleURL;
98 return this._bundleURL;
101 retrieveBundleData:
function(aTimeout) {
103 var
url = this.formatBundleURL();
104 url += this._getRandomParameter();
107 this.retrieveBundleDataCommon(url,
true);
111 this.
_timer = Components.classes[
"@mozilla.org/timer;1"]
112 .createInstance(Components.interfaces.nsITimer);
113 this.
_timer.initWithCallback(
this, aTimeout,
114 Components.interfaces.nsITimer.TYPE_ONE_SHOT);
118 retrieveLocalBundleData:
function() {
119 this.retrieveBundleDataCommon(this._bundleURL,
false);
122 retrieveBundleDataCommon:
function(aBundleURL, aAsync) {
123 if (this._init && this._req) {
125 var httpReq = this._req.QueryInterface(Components.interfaces.nsIJSXMLHttpRequest);
126 httpReq.removeEventListener(
"load", this._onload,
false);
127 httpReq.removeEventListener(
"error", this._onerror,
false);
134 handleEvent:
function(
event ) { this._that.onLoad(); }
135 }; this._onload._that =
this;
139 handleEvent:
function(
event ) { this._that.onError(); }
140 }; this._onerror._that =
this;
142 this._req = Components.classes[
"@mozilla.org/xmlextras/xmlhttprequest;1"]
143 .createInstance(Components.interfaces.nsIXMLHttpRequest);
145 this._req.mozBackgroundRequest =
true;
146 var httpReq = this._req.QueryInterface(Components.interfaces.nsIJSXMLHttpRequest);
147 httpReq.addEventListener(
"load", this._onload,
false);
148 httpReq.addEventListener(
"error", this._onerror,
false);
151 var
url = this.formatBundleURL();
153 this._req.open(
'GET', aBundleURL, aAsync);
154 this._req.send(
null);
158 formatBundleURL:
function() {
162 var urlFormatter =
Cc[
"@songbirdnest.com/moz/sburlformatter;1"]
163 .getService(
Ci.sbIURLFormatter);
164 var pbag =
Cc[
"@mozilla.org/hash-property-bag;1"]
165 .createInstance(
Ci.nsIWritablePropertyBag2);
166 var
url = urlFormatter.formatURL(this._bundleURL, pbag);
171 get bundleDataDocument() {
172 return this._req ? this._req.responseXML :
null;
175 get bundleDataText() {
176 return this._req ? this._req.responseText :
"";
179 addBundleDataListener:
function(aListener) {
180 this._datalisteners.push(aListener);
183 removeBundleDataListener:
function (aListener) {
184 var r = this.getDataListenerIndex(aListener);
185 if (r != -1) this._datalisteners.splice(r, 1);
188 getNumDataListeners:
function() {
189 return this._datalisteners.length;
192 getDataListener:
function(aIndex) {
193 return this._datalisteners[aIndex];
196 getDataListenerIndex:
function(aListener) {
197 return this._datalisteners.indexOf(aListener);
200 addBundleInstallListener:
function(aListener) {
201 this._installlisteners.push(aListener);
204 removeBundleInstallListener:
function (aListener) {
205 var r = this.getInstallListenerIndex(aListener);
206 if (r != -1) this._installlisteners.splice(r, 1);
209 get installListenerCount() {
210 return this._installlisteners.length;
213 getInstallListener:
function(aIndex) {
214 return this._installlisteners[aIndex];
217 getInstallaListenerIndex:
function(aListener) {
218 for (var
i = 0;
i < this._installlisteners.length;
i++)
if (this._datalisteners[
i] == aListener)
return i;
222 get bundleDataStatus() {
228 this.getExtensionList();
229 for (var
i = 0;
i < this._datalisteners.length;
i++) this._datalisteners[
i].onDownloadComplete(
this);
232 onError:
function() {
234 for (var
i = 0;
i < this._datalisteners.length;
i++) this._datalisteners[
i].onError(
this);
237 getDataNodes:
function(bundledocument) {
238 if (!bundledocument)
return null;
239 var datablocknodes = bundledocument.childNodes;
241 for (var
i = 0;
i < datablocknodes.length;
i++) {
242 if (datablocknodes[
i].nodeType ==
Ci.nsIDOMNode.ELEMENT_NODE &&
243 datablocknodes[
i].tagName ==
"SongbirdInstallBundle") {
244 this._bundleversion = datablocknodes[
i].getAttribute(
"version")
254 return datablocknodes[
i].childNodes;
260 installFlaggedExtensions:
function(aWindow) {
261 var windowWatcherService = Components.classes[
'@mozilla.org/embedcomp/window-watcher;1']
262 .getService(Components.interfaces.nsIWindowWatcher);
264 this._installresult = Components.interfaces.sbIBundle.BUNDLE_INSTALL_ERROR;
265 windowWatcherService.openWindow(aWindow,
266 "chrome://songbird/content/xul/setupProgress.xul",
268 "chrome,dialog=yes,centerscreen,alwaysRaised,close=no,modal",
270 return this._installresult;
273 setInstallResult:
function(aResult) {
274 this._installresult = aResult;
277 getExtensionList:
function() {
278 this._extlist =
new Array();
280 var bundledocument = this.bundleDataDocument;
281 if (bundledocument) {
282 var nodes = this.getDataNodes(bundledocument);
284 for (var
i = 0;
i < nodes.length;
i++) {
285 if (nodes[
i].nodeType ==
Ci.nsIDOMNode.ELEMENT_NODE &&
286 nodes[
i].tagName ==
"XPI") {
287 var
inst = nodes[
i].getAttribute(
"default");
288 this._extlist.push(
Array(nodes[
i], (inst==
"true" || inst==
"1")));
296 get bundleExtensionCount() {
298 if (this._simulate_lots_of_entries)
return this._extlist.length * 20;
299 return this._extlist.length;
304 removeExtension:
function(aIndex) {
305 if (!this._extlist)
return;
306 if (this._extlist.length != 0 &&
this._simulate_lots_of_entries)
307 aIndex = aIndex % this._extlist.length;
308 if (this._status ==
SONGBIRD_BUNDLE_IID.BUNDLE_DATA_STATUS_SUCCESS && aIndex <
this.bundleExtensionCount)
309 this._extlist.splice(aIndex, 1);
312 getExtensionAttribute:
function(aIndex, aAttributeName) {
313 if (!this._extlist)
return "";
314 if (this._extlist.length != 0 &&
this._simulate_lots_of_entries)
315 aIndex = aIndex % this._extlist.length;
316 if (this._status ==
SONGBIRD_BUNDLE_IID.BUNDLE_DATA_STATUS_SUCCESS && aIndex <
this.bundleExtensionCount)
317 return this._extlist[aIndex][0].getAttribute(aAttributeName);
321 getExtensionInstallFlag:
function(aIndex) {
322 if (!this._extlist)
return false;
323 if (this._extlist.length != 0 &&
this._simulate_lots_of_entries)
324 aIndex = aIndex % this._extlist.length;
325 if (this._status ==
SONGBIRD_BUNDLE_IID.BUNDLE_DATA_STATUS_SUCCESS && aIndex <
this.bundleExtensionCount)
326 return this._extlist[aIndex][1];
330 setExtensionInstallFlag:
function(aIndex, aInstallFlag) {
331 if (!this._extlist)
return;
332 if (this._extlist.length != 0 &&
this._simulate_lots_of_entries)
333 aIndex = aIndex % this._extlist.length;
334 if (this._status ==
SONGBIRD_BUNDLE_IID.BUNDLE_DATA_STATUS_SUCCESS && aIndex <
this.bundleExtensionCount)
335 this._extlist[aIndex][1] = aInstallFlag;
338 _getRandomParameter:
function() {
339 var aUUIDGenerator = (Components.classes[
"@mozilla.org/uuid-generator;1"]).
createInstance();
340 aUUIDGenerator = aUUIDGenerator.QueryInterface(Components.interfaces.nsIUUIDGenerator);
341 var aUUID = aUUIDGenerator.generateUUID();
342 return "?randomguid=" + escape(aUUID);
345 setNeedRestart:
function(aRequired) {
346 this._needrestart = aRequired;
349 get restartRequired() {
350 return this._needrestart;
353 get bundleDataVersion() {
354 return this._bundleversion;
360 if(this._req.readyState != 4) {
372 if (aTopic ==
"quit-application") {
385 Components.interfaces.sbPIBundle,
386 Components.interfaces.nsIWebProgressListener,
387 Components.interfaces.nsISupportsWeakReference,
388 Components.interfaces.nsIObserver])
392 return XPCOMUtils.generateModule([Bundle]);
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
sbDeviceFirmwareAutoCheckForUpdate prototype _timer
TimerLoop prototype notify
function NSGetModule(compMgr, fileSpec)
sbDeviceFirmwareAutoCheckForUpdate prototype classID
const SONGBIRD_BUNDLE_IID
var _downloadListener
Download listener object used to track progress of XPI downloads.
_getSelectedPageStyle s i
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe