From 6d33fec1abbd4ce7f69dff0092cfbc80f1d56bb5 Mon Sep 17 00:00:00 2001 From: "ben%bengoodger.com" Date: Fri, 23 Apr 2004 07:00:57 +0000 Subject: [PATCH] 170006 - more work on mismatch/update checking wizard UI --- .../mozapps/extensions/content/extensions.js | 6 +- .../extensions/public/nsIExtensionManager.idl | 8 +- .../extensions/service/ExtensionItem.java | 90 ------------------- .../extensions/service/VersionCheck.java | 2 + .../extensions/src/nsExtensionManager.js.in | 37 +++++--- toolkit/mozapps/jar.mn | 4 + toolkit/mozapps/update/content/update.css | 5 ++ toolkit/mozapps/update/content/update.js | 88 ++++++++++-------- toolkit/mozapps/update/content/update.xul | 37 +++++--- toolkit/mozapps/update/content/updateItem.xml | 41 +++++++++ toolkit/mozapps/update/locale/update.dtd | 12 ++- .../mozapps/update/locale/update.properties | 5 ++ toolkit/mozapps/update/skin/update.css | 41 +++++++++ .../xpinstall/content/xpinstallConfirm.xul | 2 +- .../xpinstall/skin/xpinstallConfirm.css | 59 ------------ 15 files changed, 222 insertions(+), 215 deletions(-) create mode 100644 toolkit/mozapps/update/content/update.css create mode 100644 toolkit/mozapps/update/content/updateItem.xml create mode 100644 toolkit/mozapps/update/locale/update.properties create mode 100644 toolkit/mozapps/update/skin/update.css diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js index b5d06323690..55b22990ae0 100644 --- a/toolkit/mozapps/extensions/content/extensions.js +++ b/toolkit/mozapps/extensions/content/extensions.js @@ -378,7 +378,8 @@ var gExtensionsViewController = { .createInstance(Components.interfaces.nsIExtensionItem); item.init(aItemID, this.getExtensionProperty(aItemID, "version"), this.getExtensionProperty(aItemID, "name"), - -1, "", Components.interfaces.nsIExtensionItem.TYPE_EXTENSION); // XXXben + -1, "", "", + Components.interfaces.nsIExtensionItem.TYPE_EXTENSION); // XXXben items.push(item); } else { @@ -394,7 +395,8 @@ var gExtensionsViewController = { .createInstance(Components.interfaces.nsIExtensionItem); item.init(id, this.getExtensionProperty(id, "version"), this.getExtensionProperty(id, "name"), - -1, "", Components.interfaces.nsIExtensionItem.TYPE_EXTENSION); // XXXben + -1, "", "", + Components.interfaces.nsIExtensionItem.TYPE_EXTENSION); // XXXben items.push(item); } } diff --git a/toolkit/mozapps/extensions/public/nsIExtensionManager.idl b/toolkit/mozapps/extensions/public/nsIExtensionManager.idl index 12869169de6..46a43c38a3a 100644 --- a/toolkit/mozapps/extensions/public/nsIExtensionManager.idl +++ b/toolkit/mozapps/extensions/public/nsIExtensionManager.idl @@ -60,7 +60,7 @@ interface nsIExtensionItem : nsISupports void init(in string aID, in string aVersion, in wstring aName, in long aRow, in wstring aXPIURL, in long aType); - nsIVariant toObject(); + readonly attribute wstring objectSource; }; [scriptable, uuid(c3515b0f-99f4-453b-805e-1fdf5724d6d9)] @@ -88,3 +88,9 @@ interface nsIExtensionManager : nsISupports readonly attribute nsIRDFDataSource datasource; }; +[scriptable, uuid(c0b7517f-0b3a-41a2-bde8-ba3ac8a5af47)] +interface nsIExtensionItemUpdater : nsISupports +{ + void checkForUpdates(); +}; + diff --git a/toolkit/mozapps/extensions/service/ExtensionItem.java b/toolkit/mozapps/extensions/service/ExtensionItem.java index 1c61462aa31..e69de29bb2d 100644 --- a/toolkit/mozapps/extensions/service/ExtensionItem.java +++ b/toolkit/mozapps/extensions/service/ExtensionItem.java @@ -1,90 +0,0 @@ -package org.mozilla.update.extensions; - -public class ExtensionItem -{ - private int row; - private java.lang.String id; - private java.lang.String version; - private java.lang.String name; - private java.lang.String xpiURL; - private int type; - - public ExtensionItem() - { - } - - public int getRow() - { - return row; - } - - public void setRow(int row) - { - this.row = row; - } - - public java.lang.String getId() - { - return id; - } - - public void setId(java.lang.String id) - { - this.id = id; - } - - public java.lang.String getVersion() - { - return version; - } - - public void setVersion(java.lang.String version) - { - this.version = version; - } - - public java.lang.String getName() - { - return name; - } - - public void setName(java.lang.String name) - { - this.name = name; - } - - public java.lang.String getXpiURL() - { - return xpiURL; - } - - public void setXpiURL(java.lang.String xpiURL) - { - this.xpiURL = xpiURL; - } - - public int getType() - { - return type; - } - - public void setType(int type) - { - this.type = type; - } -} - -//public class ExtensionType -//{ -// public ExtensionType() -// { -// } -// -// public int row; -// public String id; -// public String version; -// public String name; -// public String xpiURL; -// public int type; -//} - diff --git a/toolkit/mozapps/extensions/service/VersionCheck.java b/toolkit/mozapps/extensions/service/VersionCheck.java index dc131f41161..ac514da2d35 100644 --- a/toolkit/mozapps/extensions/service/VersionCheck.java +++ b/toolkit/mozapps/extensions/service/VersionCheck.java @@ -70,6 +70,7 @@ public class VersionCheck e.setName(getProperty(row, "name")); e.setVersion(getProperty(row, "version")); e.setXpiURL(getProperty(row, "xpiurl")); + e.setIconURL(getProperty(row, "iconurl")); results.add(e); } } @@ -94,6 +95,7 @@ public class VersionCheck e.setName(getProperty(row, "name")); e.setVersion(getProperty(row, "version")); e.setXpiURL(getProperty(row, "xpiurl")); + e.setIconURL(getProperty(row, "iconurl")); } return e; } diff --git a/toolkit/mozapps/extensions/src/nsExtensionManager.js.in b/toolkit/mozapps/extensions/src/nsExtensionManager.js.in index f3dd7802378..7d2935a3816 100644 --- a/toolkit/mozapps/extensions/src/nsExtensionManager.js.in +++ b/toolkit/mozapps/extensions/src/nsExtensionManager.js.in @@ -49,13 +49,14 @@ function ExtensionItem () } ExtensionItem.prototype = { - init: function (aID, aVersion, aName, aRow, aXPIURL, aType) + init: function (aID, aVersion, aName, aRow, aXPIURL, aIconURL, aType) { this._id = aID; this._version = aVersion; this._name = aName; this._row = aRow; this._xpiURL = aXPIURL; + this._iconURL = aIconURL; this._type = aType; }, @@ -64,12 +65,14 @@ ExtensionItem.prototype = { get name() { return this._name; }, get row() { return this._row; }, get xpiURL() { return this._xpiURL; }, + get iconURL() { return this._iconURL }, get type() { return this._type; }, - toObject: function () + get objectSource() { return { id: this._id, version: this._version, name: this._name, - row: this._row, xpiURL: this._xpiURL, type: this._type }; + row: this._row, xpiURL: this._xpiURL, iconURL: this._iconURL, + type: this._type }.toSource(); }, ///////////////////////////////////////////////////////////////////////////// @@ -251,7 +254,7 @@ nsExtensionManager.prototype = { var appID = pref.getCharPref(PREF_EM_APP_ID); var appVersion = pref.getCharPref(PREF_EM_APP_VERSION); - var updater = new nsItemUpdater(aItems, appID, appVersion); + var updater = new nsExtensionItemUpdater(aItems, appID, appVersion); switch (aUpdateType) { case Components.interfaces.nsIExtensionManager.UPDATE_TYPE_MISMATCH: @@ -318,7 +321,7 @@ nsExtensionManager.prototype = { } }; -function nsItemUpdater(aItems, aTargetAppID, aTargetAppVersion) +function nsExtensionItemUpdater(aItems, aTargetAppID, aTargetAppVersion) { this._items = aItems; this._count = aItems.length; @@ -329,9 +332,9 @@ function nsItemUpdater(aItems, aTargetAppID, aTargetAppVersion) .getService(Components.interfaces.nsIObserverService); } -nsItemUpdater.prototype = { +nsExtensionItemUpdater.prototype = { ///////////////////////////////////////////////////////////////////////////// - // + // nsIExtensionItemUpdater checkForUpdates: function () { this._os.notifyObservers(null, "update-started", ""); @@ -341,6 +344,8 @@ nsItemUpdater.prototype = { "VersionCheck", "", true, this); }, + ///////////////////////////////////////////////////////////////////////////// + // nsExtensionItemUpdater _proxy: null, _checkForUpdates: function () @@ -348,7 +353,8 @@ nsItemUpdater.prototype = { for (var i = 0; i < this._items.length; ++i) { var e = this._items[i]; this._os.notifyObservers(null, "update-item-started", e.name + " " + e.version); - this._proxy.getNewestExtension(e, this._appID, this._appVersion); + dump("*** obj = " + e.objectSource + "\n"); // goats + this._proxy.getNewestExtension(eval(e.objectSource), this._appID, this._appVersion); } }, @@ -381,7 +387,17 @@ nsItemUpdater.prototype = { if (--this._count == 0) this._os.notifyObservers(null, "update-ended", ""); - } + }, + + ///////////////////////////////////////////////////////////////////////////// + // nsISupports + QueryInterface: function (aIID) + { + if (!aIID.equals(Components.interfaces.nsIExtensionItemUpdater) && + !aIID.equals(Components.interfaces.nsISupports)) + throw Components.results.NS_ERROR_NO_INTERFACE; + return this; + } }; @@ -432,7 +448,8 @@ nsExtensionsDataSource.prototype = { .createInstance(Components.interfaces.nsIExtensionItem); item.init(id, this.getExtensionProperty(id, "version"), this.getExtensionProperty(id, "name"), - -1, "", Components.interfaces.nsIExtensionItem.TYPE_EXTENSION); + -1, "", "", + Components.interfaces.nsIExtensionItem.TYPE_EXTENSION); items.push(item); } } diff --git a/toolkit/mozapps/jar.mn b/toolkit/mozapps/jar.mn index 5ae526bae58..231cd6175d1 100755 --- a/toolkit/mozapps/jar.mn +++ b/toolkit/mozapps/jar.mn @@ -21,6 +21,8 @@ toolkit.jar: * content/mozapps/extensions/about.js (extensions/content/about.js) * content/mozapps/update/update.xul (update/content/update.xul) * content/mozapps/update/update.js (update/content/update.js) +* content/mozapps/update/updateItem.xml (update/content/updateItem.xml) +* content/mozapps/update/update.css (update/content/update.css) * content/mozapps/shared/richview.xml (shared/content/richview.xml) content/mozapps/contents.rdf (contents-content.rdf) @@ -36,6 +38,7 @@ en-US.jar: locale/en-US/mozapps/extensions/extensions.properties (extensions/locale/extensions.properties) locale/en-US/mozapps/extensions/about.dtd (extensions/locale/about.dtd) locale/en-US/mozapps/update/update.dtd (update/locale/update.dtd) + locale/en-US/mozapps/update/update.properties (update/locale/update.properties) locale/en-US/mozapps/contents.rdf (contents-locale.rdf) classic.jar: @@ -43,6 +46,7 @@ classic.jar: skin/classic/mozapps/extensions/about.css (extensions/skin/about.css) skin/classic/mozapps/extensions/placeholder.gif (extensions/skin/placeholder.gif) skin/classic/mozapps/extensions/viewWatermark.png (extensions/skin/viewWatermark.png) + skin/classic/mozapps/update/update.css (update/skin/update.css) skin/classic/mozapps/shared/richview.xml (shared/skin/richview.xml) skin/classic/mozapps/shared/richview.css (shared/skin/richview.css) skin/classic/mozapps/shared/viewFader.png (shared/skin/viewFader.png) diff --git a/toolkit/mozapps/update/content/update.css b/toolkit/mozapps/update/content/update.css new file mode 100644 index 00000000000..76264197c17 --- /dev/null +++ b/toolkit/mozapps/update/content/update.css @@ -0,0 +1,5 @@ +updateitem { + -moz-binding: url("chrome://mozapps/content/update/updateItem.xml#updateItem"); + display: -moz-box; +} + diff --git a/toolkit/mozapps/update/content/update.js b/toolkit/mozapps/update/content/update.js index 46a651c8202..b5fa5c3a346 100644 --- a/toolkit/mozapps/update/content/update.js +++ b/toolkit/mozapps/update/content/update.js @@ -47,12 +47,13 @@ var gUpdater = null; var gUpdateWizard = { _items: [], + _itemsToUpdate: [], init: function () { - gUpdater = window.arguments[0]; - for (var i = 1; i < window.argments.length; ++i) - this._items.push(window.arguments[i].QueryInterface(Components.interfaces.nsIExtensionItem)); + gUpdater = window.arguments[0].QueryInterface(Components.interfaces.nsIExtensionItemUpdater); + for (var i = 1; i < window.arguments.length; ++i) + this._items.push(window.arguments[i].QueryInterface(nsIExtensionItem)); gMismatchPage.init(); }, @@ -76,7 +77,7 @@ var gMismatchPage = { incompatible.appendChild(listitem); } - var strings = document.getElementById("extensionsStrings"); + var strings = document.getElementById("updateStrings"); var next = document.documentElement.getButton("next"); next.label = strings.getString("mismatchCheckNow"); var cancel = document.documentElement.getButton("cancel"); @@ -90,7 +91,7 @@ var gMismatchPage = { }; var gUpdatePage = { - _itemsToUpdate: [], + _completeCount: 0, _messages: ["update-started", "update-ended", "update-item-started", @@ -99,31 +100,22 @@ var gUpdatePage = { onPageShow: function () { + var strings = document.getElementById("updateStrings"); + var next = document.documentElement.getButton("next"); + next.label = strings.getString("nextButtonText"); + next.disabled = true; + var cancel = document.documentElement.getButton("cancel"); + cancel.label = strings.getString("cancelButtonText"); + cancel.disabled = true; + var back = document.documentElement.getButton("back"); + back.disabled = true; + var os = Components.classes["@mozilla.org/observer-service;1"] .getService(Components.interfaces.nsIObserverService); for (var i = 0; i < this._messages.length; ++i) os.addObserver(this, this._messages[i], false); - var extensions = []; - var themes = []; - for (i = 0; i < gExtensionItems.length; ++i) { - switch (gExtensionItems[i].type) { - case nsIExtensionItem.TYPE_EXTENSION: - extensions.push(gExtensionItems[i]); - break; - case nsIExtensionItem.TYPE_THEME: - themes.push(gExtensionItems[i]); - break; - } - } - - var em = Components.classes["@mozilla.org/extensions/manager;1"] - .getService(Components.interfaces.nsIExtensionManager); - if (this._updateType == "extensions") - em.updateExtensions(extensions); - else if (gUpdateType == "themes") - em.updateTheme(this._extensionID); - + gUpdater.checkForUpdates(); }, uninit: function () @@ -142,23 +134,49 @@ var gUpdatePage = { case "update-item-started": break; case "update-item-ended": - this._extensionsToUpdate.push(aSubject); + dump("*** update-item-ended\n"); + gUpdateWizard._itemsToUpdate.push(aSubject); + + ++this._completeCount; + + var progress = document.getElementById("checking.progress"); + progress.value = Math.ceil(this._completeCount / gUpdateWizard._itemsToUpdate.length) * 100; + break; case "update-ended": - var installObj = { }; - for (var i = 0; i < this._extensionsToUpdate.length; ++i) { - var e = this._extensionsToUpdate[i]; - installObj[e.name + " " + e.version] = e.xpiURL; - } - if (InstallTrigger.updateEnabled()) - InstallTrigger.install(installObj); - - document.documentElement.acceptDialog(); + if (gUpdateWizard._itemsToUpdate.length > 0) + document.getElementById("checking").setAttribute("next", "found"); + document.documentElement.advance(); break; } } }; +var gFoundPage = { + + onPageShow: function () + { + var strings = document.getElementById("updateStrings"); + var next = document.documentElement.getButton("next"); + next.label = strings.getString("installButtonText"); + next.disabled = false; + var back = document.documentElement.getButton("back"); + back.disabled = true; + + var list = document.getElementById("foundList"); + for (var i = 0; i < gUpdateWizard._itemsToUpdate.length; ++i) { + var updateitem = document.createElement("updateitem"); + list.appendChild(updateitem); + + var item = gUpdateWizard._itemsToUpdate[i]; + updateitem.name = item.name + " " + item.version; + updateitem.url = item.xpiURL; + if (item.iconURL != "") + updateitem.icon = item.iconURL; + } + }, +}; + # -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- diff --git a/toolkit/mozapps/update/content/update.xul b/toolkit/mozapps/update/content/update.xul index 681c7183e8e..521bf48759f 100644 --- a/toolkit/mozapps/update/content/update.xul +++ b/toolkit/mozapps/update/content/update.xul @@ -37,6 +37,8 @@ # ***** END LICENSE BLOCK ***** + + @@ -57,10 +59,10 @@ - + - @@ -79,29 +81,38 @@ - - + + + - + - + + + + + + + + - diff --git a/toolkit/mozapps/update/content/updateItem.xml b/toolkit/mozapps/update/content/updateItem.xml new file mode 100644 index 00000000000..3972057679c --- /dev/null +++ b/toolkit/mozapps/update/content/updateItem.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + &from.label; + + + + + + + + + + + + + + diff --git a/toolkit/mozapps/update/locale/update.dtd b/toolkit/mozapps/update/locale/update.dtd index 16fcdcd5510..9b902498690 100644 --- a/toolkit/mozapps/update/locale/update.dtd +++ b/toolkit/mozapps/update/locale/update.dtd @@ -2,20 +2,24 @@ + of &brandShortName; you have just installed:"> - + - + + + + + - + \ No newline at end of file diff --git a/toolkit/mozapps/update/locale/update.properties b/toolkit/mozapps/update/locale/update.properties new file mode 100644 index 00000000000..ed77ae66b41 --- /dev/null +++ b/toolkit/mozapps/update/locale/update.properties @@ -0,0 +1,5 @@ +mismatchCheckNow=Check Now +mismatchDontCheck=Don't Check +installButtonText=Install Now +nextButtonText=Next > +cancelButtonText=Cancel diff --git a/toolkit/mozapps/update/skin/update.css b/toolkit/mozapps/update/skin/update.css new file mode 100644 index 00000000000..52d22533127 --- /dev/null +++ b/toolkit/mozapps/update/skin/update.css @@ -0,0 +1,41 @@ +#foundList { + -moz-appearance: listbox; + margin: 10px 4px 10px 4px; +} + +updateitem { + padding: 5px 0px 5px 5px; + border-bottom: 1px dotted #C0C0C0; + margin-bottom: 5px; +} + +.warning { + font-weight: bold; +} + +.updateItemIcon { + width: 32px; + height: 32px; + max-width: 32px !important; + max-height: 32px !important; + margin-right: 5px; +} + +.updateItemName { + font-weight: bold; +} + +.updateItemNameRow { + padding-bottom: 3px; +} + +.updateItemURL { + -moz-appearance: none; + border: none; + background-color: Window; +} + +.updateItemIcon { + list-style-image: url("chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png"); +} + diff --git a/toolkit/mozapps/xpinstall/content/xpinstallConfirm.xul b/toolkit/mozapps/xpinstall/content/xpinstallConfirm.xul index 77e24113582..1bf15aa4aa0 100644 --- a/toolkit/mozapps/xpinstall/content/xpinstallConfirm.xul +++ b/toolkit/mozapps/xpinstall/content/xpinstallConfirm.xul @@ -57,7 +57,7 @@ - + &warningText2.label; &warningText3.label; diff --git a/toolkit/mozapps/xpinstall/skin/xpinstallConfirm.css b/toolkit/mozapps/xpinstall/skin/xpinstallConfirm.css index e2af210d0eb..e69de29bb2d 100644 --- a/toolkit/mozapps/xpinstall/skin/xpinstallConfirm.css +++ b/toolkit/mozapps/xpinstall/skin/xpinstallConfirm.css @@ -1,59 +0,0 @@ -#xpinstallIcon { - list-style-image: url("chrome://mozapps/skin/xpinstall/xpinstallIcon.png"); -} - -#itemList { - -moz-appearance: listbox; - margin: 10px 4px 10px 4px; -} - -#dialogContentBox { - padding: 5px; -} - -installitem { - padding: 5px 0px 5px 5px; - border-bottom: 1px dotted #C0C0C0; - margin-bottom: 5px; -} - -.warning { - font-weight: bold; -} - -.xpinstallItemIcon { - width: 32px; - height: 32px; - max-width: 32px !important; - max-height: 32px !important; - margin-right: 5px; -} - -.xpinstallItemName { - font-weight: bold; -} - -.xpinstallItemSigned { - font-style: italic; -} - -.xpinstallItemSigned[signed=false] { - color: #ED1C24; - font-style: normal; - font-weight: bold; -} - -.xpinstallItemNameRow { - padding-bottom: 3px; -} - -.xpinstallItemURL { - -moz-appearance: none; - border: none; - background-color: Window; -} - -.xpinstallItemIcon { - list-style-image: url("chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png"); -} -