214360 - more update notifications work... reorganize some of the apis so they make a bit more sense and are easier to work with

This commit is contained in:
ben%bengoodger.com 2004-04-25 08:52:06 +00:00
parent d7d0a53988
commit e0629f624a
10 changed files with 153 additions and 98 deletions

View File

@ -368,8 +368,10 @@ var gExtensionsViewController = {
{ {
var id = stripPrefix(gExtensionsView.selected.id); var id = stripPrefix(gExtensionsView.selected.id);
var items = gExtensionManager.getItemList(id, nsIUpdateItem.TYPE_EXTENSION, { }); var items = gExtensionManager.getItemList(id, nsIUpdateItem.TYPE_EXTENSION, { });
gExtensionManager.update(items, items.length, var updates = Components.classes["@mozilla.org/updates/update-service;1"]
Components.interfaces.nsIUpdateItem.UPDATE_TYPE_USERINVOKED); .getService(Components.interfaces.nsIUpdateService);
updates.checkForUpdates(items, items.length, nsIUpdateItem.TYPE_EXTENSION,
Components.interfaces.nsIUpdateService.SOURCE_EVENT_USER);
}, },
cmd_uninstall: function () cmd_uninstall: function ()

View File

@ -53,16 +53,13 @@ interface nsIExtensionManager : nsISupports
void installTheme(in string aThemeID); void installTheme(in string aThemeID);
void uninstallTheme(in string aThemeID); void uninstallTheme(in string aThemeID);
const unsigned short UPDATE_TYPE_MISMATCH = 0x01; const unsigned short SOURCE_EVENT_MISMATCH = 0x01;
const unsigned short UPDATE_TYPE_USERINVOKED = 0x02;
const unsigned short UPDATE_TYPE_BACKGROUND = 0x04;
const unsigned short UPDATE_RESULT_OK = 0x00; const unsigned short UPDATE_RESULT_OK = 0x00;
const unsigned short UPDATE_RESULT_RESTART = 0x01; const unsigned short UPDATE_RESULT_RESTART = 0x01;
unsigned short update([array, size_is(aItemCount)] in nsIUpdateItem aItems, unsigned short update([array, size_is(aItemCount)] in nsIUpdateItem aItems,
in unsigned long aItemCount, in unsigned long aItemCount);
in unsigned short aUpdateType);
void getItemList(in string aItemID, void getItemList(in string aItemID,
in unsigned short aType, in unsigned short aType,
@ -77,6 +74,7 @@ interface nsIExtensionItemUpdater : nsISupports
{ {
void checkForUpdates(); void checkForUpdates();
readonly attribute unsigned short updateType; readonly attribute unsigned short sourceEvent;
readonly attribute unsigned short updateTypes;
}; };

View File

@ -203,7 +203,7 @@ nsExtensionManager.prototype = {
this._ds.disableExtension(aExtensionID); this._ds.disableExtension(aExtensionID);
}, },
update: function (aItems, aItemCount, aUpdateType) update: function (aItems, aItemCount)
{ {
var pref = Components.classes["@mozilla.org/preferences-service;1"] var pref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch); .getService(Components.interfaces.nsIPrefBranch);
@ -211,30 +211,11 @@ nsExtensionManager.prototype = {
var appVersion = pref.getCharPref(PREF_EM_APP_VERSION); var appVersion = pref.getCharPref(PREF_EM_APP_VERSION);
if (aItems.length == 0) { if (aItems.length == 0) {
var itemType = Components.interfaces.nsIUpdateItem.TYPE_ANY; var anyType = Components.interfaces.nsIUpdateItem.TYPE_ANY;
aItems = this.getItemList(null, itemType, { }); aItems = this.getItemList(null, anyType, { });
} }
var updater = new nsExtensionItemUpdater(aUpdateType, aItems, appID, appVersion); var updater = new nsExtensionItemUpdater(aItems, appID, appVersion);
switch (aUpdateType) {
case Components.interfaces.nsIExtensionManager.UPDATE_TYPE_MISMATCH:
case Components.interfaces.nsIExtensionManager.UPDATE_TYPE_USERINVOKED:
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher);
var ary = Components.classes["@mozilla.org/supports-array;1"]
.createInstance(Components.interfaces.nsISupportsArray);
ary.AppendElement(updater);
for (var i = 0; i < aItems.length; ++i)
ary.AppendElement(aItems[i]);
ww.openWindow(null, "chrome://mozapps/content/update/update.xul",
"", "chrome,modal,centerscreen", ary);
break;
case Components.interfaces.nsIExtensionManager.UPDATE_TYPE_BACKGROUND:
// The Background Updater Service adds itself as a listener for
// the various kinds of messages that the updater sends out.
updater.checkForUpdates(); updater.checkForUpdates();
break;
}
}, },
getItemList: function (aItemID, aType, aCountRef) getItemList: function (aItemID, aType, aCountRef)
@ -287,9 +268,8 @@ nsExtensionManager.prototype = {
} }
}; };
function nsExtensionItemUpdater(aUpdateType, aItems, aTargetAppID, aTargetAppVersion) function nsExtensionItemUpdater(aItems, aTargetAppID, aTargetAppVersion)
{ {
this._updateType = aUpdateType;
this._items = aItems; this._items = aItems;
this._count = aItems.length; this._count = aItems.length;
this._appID = aTargetAppID; this._appID = aTargetAppID;
@ -314,11 +294,6 @@ nsExtensionItemUpdater.prototype = {
"VersionCheck", "", true, this); "VersionCheck", "", true, this);
}, },
get updateType()
{
return this._updateType;
},
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// nsExtensionItemUpdater // nsExtensionItemUpdater
_proxy: null, _proxy: null,

View File

@ -48,6 +48,7 @@ classic.jar:
skin/classic/mozapps/extensions/viewWatermark.png (extensions/skin/viewWatermark.png) skin/classic/mozapps/extensions/viewWatermark.png (extensions/skin/viewWatermark.png)
skin/classic/mozapps/update/update.css (update/skin/update.css) skin/classic/mozapps/update/update.css (update/skin/update.css)
skin/classic/mozapps/update/warning.gif (update/skin/warning.gif) skin/classic/mozapps/update/warning.gif (update/skin/warning.gif)
+ skin/classic/mozapps/update/icon32.png (update/skin/icon32.png)
skin/classic/mozapps/shared/richview.xml (shared/skin/richview.xml) skin/classic/mozapps/shared/richview.xml (shared/skin/richview.xml)
skin/classic/mozapps/shared/richview.css (shared/skin/richview.css) skin/classic/mozapps/shared/richview.css (shared/skin/richview.css)
skin/classic/mozapps/shared/viewFader.png (shared/skin/viewFader.png) skin/classic/mozapps/shared/viewFader.png (shared/skin/viewFader.png)

View File

@ -1,6 +1,4 @@
// //
// window.arguments[0] is the nsIExtensionItemUpdater object
//
// window.arguments[1...] is an array of nsIUpdateItem implementing objects // window.arguments[1...] is an array of nsIUpdateItem implementing objects
// that are to be updated. // that are to be updated.
// * if the array is empty, all items are updated (like a background update // * if the array is empty, all items are updated (like a background update
@ -42,10 +40,13 @@
// //
const nsIUpdateItem = Components.interfaces.nsIUpdateItem; const nsIUpdateItem = Components.interfaces.nsIUpdateItem;
const MISMATCH = Components.interfaces.nsIExtensionManager.UPDATE_TYPE_MISMATCH; const nsIUpdateService = Components.interfaces.nsIUpdateService;
const USERINVOKED = Components.interfaces.nsIExtensionManager.UPDATE_TYPE_USERINVOKED;
var gUpdater = null; const PREF_APP_ID = "app.id";
const PREF_UPDATE_APP_UPDATESAVAILABLE = "update.app.updatesAvailable";
var gSourceEvent = null;
var gUpdateTypes = null;
var gUpdateWizard = { var gUpdateWizard = {
// The items to check for updates for (e.g. an extension, some subset of extensions, // The items to check for updates for (e.g. an extension, some subset of extensions,
@ -62,16 +63,17 @@ var gUpdateWizard = {
init: function () init: function ()
{ {
gUpdater = window.arguments[0].QueryInterface(Components.interfaces.nsIExtensionItemUpdater); gUpdateTypes = window.arguments[0];
for (var i = 1; i < window.arguments.length; ++i) gSourceEvent = window.arguments[1];
for (var i = 2; i < window.arguments.length; ++i)
this.items.push(window.arguments[i].QueryInterface(nsIUpdateItem)); this.items.push(window.arguments[i].QueryInterface(nsIUpdateItem));
var pref = Components.classes["@mozilla.org/preferences-service;1"] var pref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch); .getService(Components.interfaces.nsIPrefBranch);
this.shouldSuggestAutoChecking = (gUpdater.updateType == MISMATCH) && this.shouldSuggestAutoChecking = (gSourceEvent == nsIUpdateService.SOURCE_EVENT_MISMATCH) &&
!pref.getBoolPref("update.extensions.enabled"); !pref.getBoolPref("update.extensions.enabled");
if (gUpdater.updateType == USERINVOKED) { if (gSourceEvent == nsIUpdateService.SOURCE_EVENT_USER) {
document.getElementById("mismatch").setAttribute("next", "checking"); document.getElementById("mismatch").setAttribute("next", "checking");
document.documentElement.advance(); document.documentElement.advance();
} }
@ -138,7 +140,6 @@ var gMismatchPage = {
} }
}; };
const nsIBUS = Components.interfaces.nsIBackgroundUpdateService;
var gUpdatePage = { var gUpdatePage = {
_completeCount: 0, _completeCount: 0,
_updateState: 0, _updateState: 0,
@ -146,7 +147,9 @@ var gUpdatePage = {
"Update:Extension:Ended", "Update:Extension:Ended",
"Update:Extension:Item-Started", "Update:Extension:Item-Started",
"Update:Extension:Item-Ended", "Update:Extension:Item-Ended",
"Update:Extension:Item-Error"], "Update:Extension:Item-Error",
"Update:App:Ended",
"Update:Ended"],
onPageShow: function () onPageShow: function ()
{ {
@ -160,9 +163,11 @@ var gUpdatePage = {
for (var i = 0; i < this._messages.length; ++i) for (var i = 0; i < this._messages.length; ++i)
os.addObserver(this, this._messages[i], false); os.addObserver(this, this._messages[i], false);
gUpdater.checkForUpdates(); var updates = Components.classes["@mozilla.org/updates/update-service;1"]
.getService(Components.interfaces.nsIUpdateService);
updates.checkForUpdatesInternal(gUpdateWizard.items, gUpdateWizard.items.length, gUpdateTypes);
this._updateState = nsIBUS.UPDATED_NONE; this._updateState = nsIUpdateService.UPDATED_NONE;
}, },
uninit: function () uninit: function ()
@ -194,7 +199,8 @@ var gUpdatePage = {
// If we were passed a set of extensions/themes/other to update, this // If we were passed a set of extensions/themes/other to update, this
// means we're not checking for app updates, so don't wait for the app // means we're not checking for app updates, so don't wait for the app
// update to complete before advancing (because there is none). // update to complete before advancing (because there is none).
canFinish = gUpdateWizard.items.length > 0; // canFinish = gUpdateWizard.items.length > 0;
// XXXben
break; break;
case "Update:Ended": case "Update:Ended":
// If we're doing a general update check, (that is, no specific extensions/themes // If we're doing a general update check, (that is, no specific extensions/themes
@ -207,7 +213,23 @@ var gUpdatePage = {
// updates so it can list them first. // updates so it can list them first.
var pref = Components.classes["@mozilla.org/preferences-service;1"] var pref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch); .getService(Components.interfaces.nsIPrefBranch);
gUpdateWizard.appUpdatesAvailable = pref.getBoolPref(PREF_UPDATE_APPUPDATESAVAILABLE); gUpdateWizard.appUpdatesAvailable = pref.getBoolPref(PREF_UPDATE_APP_UPDATESAVAILABLE);
if (gUpdateWizard.appUpdatesAvailable) {
var appID = pref.getCharPref(PREF_APP_ID);
var updates = Components.classes["@mozilla.org/updates/update-service;1"]
.getService(Components.interfaces.nsIUpdateService);
var brandShortName = document.getElementById("brandStrings").getString("brandShortName");
var item = Components.classes["@mozilla.org/updates/item;1"]
.createInstance(Components.interfaces.nsIUpdateItem);
item.init(appID, updates.appUpdateVersion,
brandShortName, -1, updates.appUpdateURL,
"chrome://mozapps/skin/update/icon32.png",
Components.interfaces.nsIUpdateItem.TYPE_APP);
gUpdateWizard.itemsToUpdate.splice(0, 0, item);
}
break; break;
} }
@ -285,7 +307,7 @@ var gFinishedPage = {
fEC.hidden = true; fEC.hidden = true;
} }
if (gUpdater.updateType == MISMATCH) { if (gUpdater.updateType == nsIUpdateService.SOURCE_EVENT_MISMATCH) {
document.getElementById("finishedMismatch").hidden = false; document.getElementById("finishedMismatch").hidden = false;
document.getElementById("incompatibleAlert").hidden = false; document.getElementById("incompatibleAlert").hidden = false;
} }

View File

@ -51,8 +51,8 @@
<body> <body>
<![CDATA[ <![CDATA[
if (aTopic == "Update:Ended") { if (aTopic == "Update:Ended") {
var updates = Components.classes["@mozilla.org/updates/background-update-service;1"] var updates = Components.classes["@mozilla.org/updates/update-service;1"]
.getService(Components.interfaces.nsIBackgroundUpdateService); .getService(Components.interfaces.nsIUpdateService);
this.severity = updates.updateSeverity; this.severity = updates.updateSeverity;
this.updateCount = updates.updateCount; this.updateCount = updates.updateCount;
@ -105,9 +105,10 @@
<method name="showUpdates"> <method name="showUpdates">
<body> <body>
<![CDATA[ <![CDATA[
var em = Components.classes["@mozilla.org/extensions/manager;1"] var updates = Components.classes["@mozilla.org/updates/update-service;1"]
.getService(Components.interfaces.nsIExtensionManager); .getService(Components.interfaces.nsIUpdateService);
em.update([], 0, Components.interfaces.nsIExtensionManager.UPDATE_TYPE_USERINVOKED); updates.checkForUpdates([], 0, Components.interfaces.nsIUpdateItem.TYPE_ANY,
Components.interfaces.nsIUpdateService.SOURCE_EVENT_USER);
]]> ]]>
</body> </body>
</method> </method>

View File

@ -44,7 +44,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = update MODULE = update
XPIDL_MODULE = update XPIDL_MODULE = update
XPIDLSRCS = nsIBackgroundUpdateService.idl XPIDLSRCS = nsIUpdateService.idl
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk

View File

@ -38,20 +38,6 @@
#include "nsISupports.idl" #include "nsISupports.idl"
[scriptable, uuid(c8a2339e-770a-417d-ab9c-efde1f23ba24)]
interface nsIBackgroundUpdateService : nsISupports
{
void checkForUpdates();
void checkForUpdatesNow();
readonly attribute long updateCount;
readonly attribute unsigned short updateSeverity;
readonly attribute wstring appUpdateDescription;
readonly attribute wstring appUpdateURL;
};
[scriptable, uuid(37648f86-0f77-4007-929e-673a75d5438f)] [scriptable, uuid(37648f86-0f77-4007-929e-673a75d5438f)]
interface nsIUpdateItem : nsISupports interface nsIUpdateItem : nsISupports
{ {
@ -62,11 +48,11 @@ interface nsIUpdateItem : nsISupports
readonly attribute wstring updateURL; readonly attribute wstring updateURL;
readonly attribute wstring iconURL; readonly attribute wstring iconURL;
const unsigned short TYPE_ANY = 0x00; const unsigned short TYPE_ANY = 0x01;
const unsigned short TYPE_APP = 0x01; const unsigned short TYPE_APP = 0x02;
const unsigned short TYPE_EXTENSION = 0x02; const unsigned short TYPE_EXTENSION = 0x04;
const unsigned short TYPE_THEME = 0x04; const unsigned short TYPE_THEME = 0x08;
const unsigned short TYPE_LOCALE = 0x08; const unsigned short TYPE_LOCALE = 0x10;
readonly attribute long type; readonly attribute long type;
@ -77,3 +63,27 @@ interface nsIUpdateItem : nsISupports
readonly attribute wstring objectSource; readonly attribute wstring objectSource;
}; };
[scriptable, uuid(c8a2339e-770a-417d-ab9c-efde1f23ba24)]
interface nsIUpdateService : nsISupports
{
void watchForUpdates();
const unsigned short SOURCE_EVENT_USER = 0x01;
const unsigned short SOURCE_EVENT_BACKGROUND = 0x02;
void checkForUpdates([array, size_is(aItemCount)] in nsIUpdateItem aItems,
in unsigned long aItemCount,
in unsigned short aUpdateTypes,
in unsigned short aSourceEvent);
void checkForUpdatesInternal([array, size_is(aItemCount)] in nsIUpdateItem aItems,
in unsigned long aItemCount,
in unsigned short aUpdateTypes);
readonly attribute long updateCount;
readonly attribute unsigned short updateSeverity;
readonly attribute string appUpdateVersion;
readonly attribute wstring appUpdateDescription;
readonly attribute wstring appUpdateURL;
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -40,6 +40,7 @@ const PREF_APP_VERSION = "app.version";
const PREF_UPDATE_APP_ENABLED = "update.app.enabled"; const PREF_UPDATE_APP_ENABLED = "update.app.enabled";
const PREF_UPDATE_APP_URI = "update.app.url"; const PREF_UPDATE_APP_URI = "update.app.url";
const PREF_UPDATE_APP_UPDATESAVAILABLE = "update.app.updatesAvailable"; const PREF_UPDATE_APP_UPDATESAVAILABLE = "update.app.updatesAvailable";
const PREF_UPDATE_APP_UPDATEVERSION = "update.app.updateVersion";
const PREF_UPDATE_APP_UPDATEDESCRIPTION = "update.app.updateDescription"; const PREF_UPDATE_APP_UPDATEDESCRIPTION = "update.app.updateDescription";
const PREF_UPDATE_APP_UPDATEURL = "update.app.updateURL"; const PREF_UPDATE_APP_UPDATEURL = "update.app.updateURL";
@ -51,7 +52,8 @@ const PREF_UPDATE_INTERVAL = "update.interval";
const PREF_UPDATE_LASTUPDATEDATE = "update.lastUpdateDate"; const PREF_UPDATE_LASTUPDATEDATE = "update.lastUpdateDate";
const PREF_UPDATE_SEVERITY = "update.severity"; const PREF_UPDATE_SEVERITY = "update.severity";
const nsIBUS = Components.interfaces.nsIBackgroundUpdateService; const nsIUpdateService = Components.interfaces.nsIUpdateService;
const nsIUpdateItem = Components.interfaces.nsIUpdateItem;
const UPDATED_EXTENSIONS = 0x01; const UPDATED_EXTENSIONS = 0x01;
const UPDATED_APP = 0x02; const UPDATED_APP = 0x02;
@ -67,8 +69,8 @@ nsBackgroundUpdateService.prototype = {
_pref: null, _pref: null,
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// nsIBackgroundUpdateService // nsIUpdateService
checkForUpdates: function () watchForUpdates: function ()
{ {
// This is called when the app starts, so check to see if the time interval // This is called when the app starts, so check to see if the time interval
// expired between now and the last time an automated update was performed. // expired between now and the last time an automated update was performed.
@ -81,15 +83,51 @@ nsBackgroundUpdateService.prototype = {
var interval = this._pref.getIntPref(PREF_UPDATE_INTERVAL); var interval = this._pref.getIntPref(PREF_UPDATE_INTERVAL);
var lastUpdateTime = this._pref.getIntPref(PREF_UPDATE_LASTUPDATEDATE); var lastUpdateTime = this._pref.getIntPref(PREF_UPDATE_LASTUPDATEDATE);
var timeSinceLastCheck = Date.UTC() - lastUpdateTime; var timeSinceLastCheck = Date.UTC() - lastUpdateTime;
this.checkForUpdatesNow(); /// XXXben this.checkForUpdatesInternal([], 0, nsIUpdateItem.TYPE_ANY); /// XXXben
if (timeSinceLastCheck > interval) if (timeSinceLastCheck > interval)
this.checkForUpdatesNow(); this.checkForUpdatesInternal([], 0, nsIUpdateItem.TYPE_ANY);
else else
this._makeTimer(interval - timeSinceLastCheck); this._makeTimer(interval - timeSinceLastCheck);
}, },
checkForUpdatesNow: function () checkForUpdates: function (aItems, aItemCount, aUpdateTypes, aSourceEvent)
{
switch (aSourceEvent) {
case Components.interfaces.nsIExtensionManager.SOURCE_EVENT_MISMATCH:
case nsIUpdateService.SOURCE_EVENT_USER:
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher);
var ary = Components.classes["@mozilla.org/supports-array;1"]
.createInstance(Components.interfaces.nsISupportsArray);
var updateTypes = Components.classes["@mozilla.org/supports-PRUint8;1"]
.createInstance(Components.interfaces.nsISupportsPRUint8);
updateTypes.data = aUpdateTypes;
ary.AppendElement(updateTypes);
var sourceEvent = Components.classes["@mozilla.org/supports-PRUint8;1"]
.createInstance(Components.interfaces.nsISupportsPRUint8);
sourceEvent.data = aSourceEvent;
ary.AppendElement(sourceEvent);
for (var i = 0; i < aItems.length; ++i)
ary.AppendElement(aItems[i]);
ww.openWindow(null, "chrome://mozapps/content/update/update.xul",
"", "chrome,modal,centerscreen", ary);
break;
case nsIUpdateService.SOURCE_EVENT_BACKGROUND:
// Rather than show a UI, call the checkForUpdates function directly here.
// The Browser's inline front end update notification system listens for the
// updates that this function broadcasts.
this.checkForUpdatesInternal([], 0, aUpdateTypes, aSourceEvent);
// If this was a background update, reset timer.
this._makeTimer(this._pref.getIntPref(PREF_UPDATE_INTERVAL));
this._pref.setIntPref(PREF_UPDATE_LASTUPDATEDATE, Date.UTC());
break;
}
},
checkForUpdatesInternal: function (aItems, aItemCount, aUpdateTypes)
{ {
// Listen for notifications sent out by the app updater (implemented here) and the // Listen for notifications sent out by the app updater (implemented here) and the
// extension updater (implemented in nsExtensionItemUpdater) // extension updater (implemented in nsExtensionItemUpdater)
@ -99,10 +137,13 @@ nsBackgroundUpdateService.prototype = {
os.addObserver(this, "Update:Extension:Ended", false); os.addObserver(this, "Update:Extension:Ended", false);
os.addObserver(this, "Update:App:Ended", false); os.addObserver(this, "Update:App:Ended", false);
this._updateState = 0;
var appUpdatesEnabled = this._pref.getBoolPref(PREF_UPDATE_APP_ENABLED); var appUpdatesEnabled = this._pref.getBoolPref(PREF_UPDATE_APP_ENABLED);
var extUpdatesEnabled = this._pref.getBoolPref(PREF_UPDATE_EXTENSIONS_ENABLED); var extUpdatesEnabled = this._pref.getBoolPref(PREF_UPDATE_EXTENSIONS_ENABLED);
if (appUpdatesEnabled) { if (appUpdatesEnabled && ((aUpdateTypes == nsIUpdateItem.TYPE_ANY) ||
(aUpdateTypes == nsIUpdateItem.TYPE_APP))) {
var dsURI = this._pref.getComplexValue(PREF_UPDATE_APP_URI, var dsURI = this._pref.getComplexValue(PREF_UPDATE_APP_URI,
Components.interfaces.nsIPrefLocalizedString).data; Components.interfaces.nsIPrefLocalizedString).data;
var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"] var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"]
@ -111,13 +152,11 @@ nsBackgroundUpdateService.prototype = {
ds = ds.QueryInterface(Components.interfaces.nsIRDFXMLSink); ds = ds.QueryInterface(Components.interfaces.nsIRDFXMLSink);
ds.addXMLSinkObserver(new nsAppUpdateXMLRDFDSObserver(this)); ds.addXMLSinkObserver(new nsAppUpdateXMLRDFDSObserver(this));
} }
if (extUpdatesEnabled) { if (extUpdatesEnabled && (aUpdateTypes != nsIUpdateItem.TYPE_APP)) {
var em = Components.classes["@mozilla.org/extensions/manager;1"] var em = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(Components.interfaces.nsIExtensionManager); .getService(Components.interfaces.nsIExtensionManager);
em.update([], 0, Components.interfaces.nsIExtensionManager.UPDATE_TYPE_BACKGROUND); em.update(aItems, aItems.length);
} }
this._makeTimer(this._pref.getIntPref(PREF_UPDATE_INTERVAL));
}, },
get updateCount() get updateCount()
@ -135,6 +174,11 @@ nsBackgroundUpdateService.prototype = {
return this._pref.getIntPref(PREF_UPDATE_SEVERITY); return this._pref.getIntPref(PREF_UPDATE_SEVERITY);
}, },
get appUpdateVersion()
{
return this._pref.getComplexValue(PREF_UPDATE_APP_UPDATEVERSION, Components.interfaces.nsISupportsString).data;
},
get appUpdateDescription() get appUpdateDescription()
{ {
return this._pref.getComplexValue(PREF_UPDATE_APP_UPDATEDESCRIPTION, Components.interfaces.nsISupportsString).data; return this._pref.getComplexValue(PREF_UPDATE_APP_UPDATEDESCRIPTION, Components.interfaces.nsISupportsString).data;
@ -210,7 +254,7 @@ nsBackgroundUpdateService.prototype = {
// nsISupports // nsISupports
QueryInterface: function (aIID) QueryInterface: function (aIID)
{ {
if (!aIID.equals(Components.interfaces.nsIBackgroundUpdateService) && if (!aIID.equals(Components.interfaces.nsIUpdateService) &&
!aIID.equals(Components.interfaces.nsISupports)) !aIID.equals(Components.interfaces.nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE; throw Components.results.NS_ERROR_NO_INTERFACE;
return this; return this;
@ -281,6 +325,8 @@ nsAppUpdateXMLRDFDSObserver.prototype =
var version = this._getProperty(ds, appID, "version"); var version = this._getProperty(ds, appID, "version");
var checker = new VersionChecker(appVersion, version); var checker = new VersionChecker(appVersion, version);
if (checker.isNewer) { if (checker.isNewer) {
pref.setCharPref(PREF_UPDATE_APP_UPDATEVERSION, version);
var severity = this._getProperty(ds, appID, "severity"); var severity = this._getProperty(ds, appID, "severity");
// Synthesize the real severity value using the hint from the web site // Synthesize the real severity value using the hint from the web site
// and the version. // and the version.
@ -452,7 +498,7 @@ var gModule = {
_objects: { _objects: {
manager: { CID: Components.ID("{B3C290A6-3943-4B89-8BBE-C01EB7B3B311}"), manager: { CID: Components.ID("{B3C290A6-3943-4B89-8BBE-C01EB7B3B311}"),
contractID: "@mozilla.org/updates/background-update-service;1", contractID: "@mozilla.org/updates/update-service;1",
className: "Background Update Service", className: "Background Update Service",
factory: { factory: {
createInstance: function (aOuter, aIID) createInstance: function (aOuter, aIID)