Bug 526987 - getItemList, getIncompatibleItemList, getDependentItemListForID and updateAndGetNewBlocklistedItems itemCount out params should be optional. r=dtownsend

This commit is contained in:
Dão Gottwald 2009-11-07 09:21:07 +01:00
parent 1f2cb76806
commit c982ab9fc0
10 changed files with 30 additions and 27 deletions

View File

@ -83,7 +83,7 @@ function disableAddons() {
var em = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(Components.interfaces.nsIExtensionManager);
var type = nsIUpdateItem.TYPE_EXTENSION + nsIUpdateItem.TYPE_LOCALE;
var items = em.getItemList(type, { });
var items = em.getItemList(type);
for (var i = 0; i < items.length; ++i)
em.disableItem(items[i].id);

View File

@ -531,7 +531,7 @@ Extensions.prototype = {
// maxVersion: "2.0"
find : function exts_find(aOptions) {
var retVal = [];
var items = this._extmgr.getItemList(Ci.nsIUpdateItem.TYPE_EXTENSION, {});
var items = this._extmgr.getItemList(Ci.nsIUpdateItem.TYPE_EXTENSION);
for (var i = 0; i < items.length; i++) {
retVal.push(this._get(items[i].id));

View File

@ -2923,7 +2923,7 @@ var gExtensionsViewController = {
var dependentItems = [];
if (!aSelectedItem.hasAttribute("lwtheme")) {
var id = getIDFromResourceURI(aSelectedItem.id);
dependentItems = gExtensionManager.getDependentItemListForID(id, true, { });
dependentItems = gExtensionManager.getDependentItemListForID(id, true);
}
var result = confirmOperation(name, "uninstallTitle", "uninstallQueryMessage",
"uninstallButton", "cancelButton",
@ -3055,7 +3055,7 @@ var gExtensionsViewController = {
}
var id = getIDFromResourceURI(aSelectedItem.id);
var dependentItems = gExtensionManager.getDependentItemListForID(id, false, { });
var dependentItems = gExtensionManager.getDependentItemListForID(id, false);
if (dependentItems.length > 0) {
name = aSelectedItem.getAttribute("name");

View File

@ -65,7 +65,7 @@ var gUpdateWizard = {
var em = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(nsIExtensionManager);
// Retrieve all items in order to sync their app compatibility information
this.items = em.getItemList(nsIUpdateItem.TYPE_ANY, { });
this.items = em.getItemList(nsIUpdateItem.TYPE_ANY);
this.inactiveItemIDs = window.arguments[0];
var pref =
Components.classes["@mozilla.org/preferences-service;1"].
@ -207,7 +207,7 @@ var gVersionInfoPage = {
// Retrieve the remaining incompatible items.
gUpdateWizard.items = em.getIncompatibleItemList(null, null,
nsIUpdateItem.TYPE_ANY,
true, { });
true);
gUpdateWizard.items = gUpdateWizard.items.filter(function(item) {
return gUpdateWizard.inactiveItemIDs.indexOf(item.id) < 0;
});

View File

@ -362,7 +362,8 @@ interface nsIExtensionManager : nsISupports
* XXXben - it would be good if this function took an optional
* install location.
*/
void getItemList(in unsigned long type, out unsigned long itemCount,
void getItemList(in unsigned long type,
[optional] out unsigned long itemCount,
[retval, array, size_is(itemCount)] out nsIUpdateItem items);
/**
@ -385,7 +386,7 @@ interface nsIExtensionManager : nsISupports
in AString platformVersion,
in unsigned long type,
in boolean includeDisabled,
out unsigned long itemCount,
[optional] out unsigned long itemCount,
[retval, array, size_is(itemCount)] out nsIUpdateItem items);
/**
@ -463,7 +464,7 @@ interface nsIExtensionManager : nsISupports
*/
void getDependentItemListForID(in AString id,
in boolean includeDisabled,
out unsigned long itemCount,
[optional] out unsigned long itemCount,
[retval, array, size_is(itemCount)] out nsIUpdateItem items);
/**
@ -479,7 +480,7 @@ interface nsIExtensionManager : nsISupports
* @returns An array of nsIUpdateItems that are blocklisted or the user should
* be warned about but are currently enabled.
*/
void updateAndGetNewBlocklistedItems(out unsigned long itemCount,
void updateAndGetNewBlocklistedItems([optional] out unsigned long itemCount,
[retval, array, size_is(itemCount)] out nsIUpdateItem items);
};

View File

@ -780,7 +780,7 @@ Blocklist.prototype = {
var em = Cc["@mozilla.org/extensions/manager;1"].
getService(Ci.nsIExtensionManager);
var addons = em.updateAndGetNewBlocklistedItems({});
var addons = em.updateAndGetNewBlocklistedItems();
for (let i = 0; i < addons.length; i++) {
let oldState = -1;

View File

@ -2525,7 +2525,7 @@ ExtensionManager.prototype = {
if (!getPref("getBoolPref", PREF_EM_UPDATE_ENABLED, true))
return;
var items = this.getItemList(Ci.nsIUpdateItem.TYPE_ANY, { });
var items = this.getItemList(Ci.nsIUpdateItem.TYPE_ANY);
var updater = new ExtensionItemUpdater(this);
updater.checkForUpdates(items, items.length,
@ -3405,7 +3405,7 @@ ExtensionManager.prototype = {
* @returns An array of active items of the specified type.
*/
_getActiveItems: function EM__getActiveItems(type) {
var allItems = this.getItemList(type, { });
var allItems = this.getItemList(type);
var activeItems = [];
var ds = this.datasource;
for (var i = 0; i < allItems.length; ++i) {
@ -4863,7 +4863,7 @@ ExtensionManager.prototype = {
*/
_updateDependentItemsForID: function EM__updateDependentItemsForID(id) {
var ds = this.datasource;
var dependentItems = this.getDependentItemListForID(id, true, { });
var dependentItems = this.getDependentItemListForID(id, true);
for (var i = 0; i < dependentItems.length; ++i) {
var dependentID = dependentItems[i].id;
ds.updateProperty(dependentID, "satisfiesDependencies");
@ -4901,7 +4901,7 @@ ExtensionManager.prototype = {
}
if (items.length == 0)
items = this.getItemList(Ci.nsIUpdateItem.TYPE_ANY, { });
items = this.getItemList(Ci.nsIUpdateItem.TYPE_ANY);
var updater = new ExtensionItemUpdater(this);
updater.checkForUpdates(items, items.length, updateCheckType, listener,
@ -4918,7 +4918,7 @@ ExtensionManager.prototype = {
var list = [];
var ds = this.datasource;
var items = this.getItemList(Ci.nsIUpdateItem.TYPE_ANY, { });
var items = this.getItemList(Ci.nsIUpdateItem.TYPE_ANY);
for (var i = 0; i < items.length; ++i) {
var id = items[i].id;
@ -4952,7 +4952,8 @@ ExtensionManager.prototype = {
ds.updateProperty(id, "blocklistedsoft");
}
itemCount.value = list.length;
if (itemCount)
itemCount.value = list.length;
return list;
},
@ -5016,7 +5017,8 @@ ExtensionManager.prototype = {
var items = this.datasource.getIncompatibleItemList(appVersion ? appVersion : undefined,
platformVersion ? platformVersion : undefined,
type, includeDisabled);
countRef.value = items.length;
if (countRef)
countRef.value = items.length;
return items;
},
@ -6732,7 +6734,8 @@ ExtensionsDataSource.prototype = {
if (type != -1 && type & desiredType)
items.push(this.getItemForID(eID));
}
countRef.value = items.length;
if (countRef)
countRef.value = items.length;
return items;
},
@ -6771,7 +6774,8 @@ ExtensionsDataSource.prototype = {
}
}
}
countRef.value = items.length;
if (countRef)
countRef.value = items.length;
return items;
},

View File

@ -161,7 +161,7 @@ function run_test() {
restartEM();
var items = gEM.getIncompatibleItemList("3", "3", Ci.nsIUpdateItem.TYPE_ANY,
false, { });
false);
// Verify only items incompatible with the next app version are returned
for (var k in ADDONS) {

View File

@ -659,14 +659,12 @@ var gIncompatibleCheckPage = {
getService(CoI.nsIExtensionManager);
this.addons = em.getIncompatibleItemList(gUpdates.update.extensionVersion,
gUpdates.update.platformVersion,
CoI.nsIUpdateItem.TYPE_ANY, false,
{ });
CoI.nsIUpdateItem.TYPE_ANY, false);
if (this.addons.length > 0) {
// Don't include add-ons that are already incompatible with the current
// version of the application
var addons = em.getIncompatibleItemList(null, null,
CoI.nsIUpdateItem.TYPE_ANY, false,
{ });
CoI.nsIUpdateItem.TYPE_ANY, false);
for (var i = 0; i < addons.length; ++i) {
for (var j = 0; j < this.addons.length; ++j) {
if (addons[i].id == this.addons[j].id) {

View File

@ -1392,13 +1392,13 @@ UpdateService.prototype = {
var currentAddons = em.getIncompatibleItemList(this._update.extensionVersion,
this._update.platformVersion,
Ci.nsIUpdateItem.TYPE_ANY,
false, { });
false);
if (currentAddons.length > 0) {
// Get the add-ons that are incompatible with the current application
// version and toolkit version.
var previousAddons = em.getIncompatibleItemList(null, null,
Ci.nsIUpdateItem.TYPE_ANY,
false, { });
false);
// Don't include add-ons that are already incompatible with the current
// application version and toolkit version.
for (var i = 0; i < previousAddons.length; ++i) {