From ea24d7cee722a4d8f6cbcb2aa42e136b60c87a16 Mon Sep 17 00:00:00 2001 From: "bsmedberg%covad.net" Date: Tue, 7 Dec 2004 04:53:07 +0000 Subject: [PATCH] Bug 273417 - Use the app id/version/buildid from nsXULAppAPI instead of using prefs r=darin a=ben git-svn-id: svn://10.0.0.236/trunk@166377 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/browser/app/nsBrowserApp.cpp | 3 ++- mozilla/browser/app/profile/firefox.js | 3 --- .../calendar/sunbird/app/nsCalendarApp.cpp | 3 ++- .../calendar/sunbird/app/profile/sunbird.js | 10 -------- mozilla/mail/app/nsMailApp.cpp | 2 ++ mozilla/mail/app/profile/all-thunderbird.js | 10 -------- .../mozapps/extensions/content/extensions.js | 5 ++-- .../extensions/src/nsExtensionManager.js.in | 21 +++++++++-------- .../content/pluginInstallerDatasource.js | 12 ++++++---- .../plugins/content/pluginInstallerWizard.js | 7 ++++-- .../toolkit/mozapps/update/content/update.js | 1 - .../mozapps/update/src/nsUpdateService.js.in | 9 ++++---- mozilla/toolkit/xre/nsAppRunner.cpp | 23 ++++++++++++++++++- mozilla/toolkit/xre/nsIXULAppInfo.idl | 5 ++++ mozilla/toolkit/xre/nsXULAppAPI.h | 7 ++++++ .../xulrunner/examples/simple/simple.xulapp | 5 ++++ 16 files changed, 77 insertions(+), 49 deletions(-) diff --git a/mozilla/browser/app/nsBrowserApp.cpp b/mozilla/browser/app/nsBrowserApp.cpp index 404c34d5556..e089d290182 100644 --- a/mozilla/browser/app/nsBrowserApp.cpp +++ b/mozilla/browser/app/nsBrowserApp.cpp @@ -48,11 +48,12 @@ static const nsXREAppData kAppData = { "Firefox", APP_VERSION, BUILD_ID, + // ec8030f7-c20a-464f-9b0e-13a3a9e97384 + { 0xec8030f7, 0xc20a, 0x464f, { 0x9b, 0x0e, 0x13, 0xa3, 0xa9, 0xe9, 0x73, 0x84 } }, "Copyright (c) 2004 mozilla.org", NS_XRE_ENABLE_PROFILE_MIGRATOR | NS_XRE_ENABLE_EXTENSION_MANAGER }; - int main(int argc, char* argv[]) { diff --git a/mozilla/browser/app/profile/firefox.js b/mozilla/browser/app/profile/firefox.js index cc204a29452..ef9ad7327a5 100644 --- a/mozilla/browser/app/profile/firefox.js +++ b/mozilla/browser/app/profile/firefox.js @@ -54,9 +54,6 @@ pref("xpinstall.dialog.progress.type.chrome", "Extension:Manager-extensions"); // This is this application's unique identifier used by the Extension System to identify // this application as an extension target, and by the SmartUpdate system to identify // this application to the Update server. -pref("app.id", "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"); -pref("app.version", @APP_VERSION@); -pref("app.build_id", @BUILD_ID@); pref("app.extensions.version", "1.0"); pref("update.app.enabled", true); // Whether or not app updates are enabled diff --git a/mozilla/calendar/sunbird/app/nsCalendarApp.cpp b/mozilla/calendar/sunbird/app/nsCalendarApp.cpp index 59cec1c5b62..a1d7ce409fc 100644 --- a/mozilla/calendar/sunbird/app/nsCalendarApp.cpp +++ b/mozilla/calendar/sunbird/app/nsCalendarApp.cpp @@ -50,10 +50,11 @@ static const nsXREAppData kAppData = { "Sunbird", APP_VERSION, BUILD_ID, + // {718e30fb-e89b-41dd-9da7-e25a45638b28} + { 0x718e30fb, 0xe89b, 0x41dd, { 0x9d, 0xa7, 0xe2, 0x5a, 0x45, 0x63, 0x8b, 0x28 } }, "Copyright (c) 2004 mozilla.org", NS_XRE_ENABLE_EXTENSION_MANAGER }; - int main(int argc, char* argv[]) { diff --git a/mozilla/calendar/sunbird/app/profile/sunbird.js b/mozilla/calendar/sunbird/app/profile/sunbird.js index 38205f857f6..632ab86ac83 100644 --- a/mozilla/calendar/sunbird/app/profile/sunbird.js +++ b/mozilla/calendar/sunbird/app/profile/sunbird.js @@ -47,16 +47,6 @@ pref("xpinstall.dialog.confirm", "chrome://mozapps/content/xpinstall/xpinstallCo pref("xpinstall.dialog.progress", "chrome://mozapps/content/downloads/downloads.xul"); pref("xpinstall.dialog.progress.type", "Download:Manager"); -// This is this application's unique identifier used by the Extension System to identify -// this application as an extension target, and by the SmartUpdate system to identify -// this application to the Update server. -pref("app.id", "{718e30fb-e89b-41dd-9da7-e25a45638b28}"); -pref("app.version", -#expand __APP_VERSION__ -); -pref("app.build_id", -#expand __BUILD_ID__ -); pref("app.extensions.version", #expand __APP_VERSION__ ); diff --git a/mozilla/mail/app/nsMailApp.cpp b/mozilla/mail/app/nsMailApp.cpp index 34e00325d2c..39b857c855f 100644 --- a/mozilla/mail/app/nsMailApp.cpp +++ b/mozilla/mail/app/nsMailApp.cpp @@ -49,6 +49,8 @@ static const nsXREAppData kAppData = { "Thunderbird", APP_VERSION, BUILD_ID, + // {3550f703-e582-4d05-9a08-453d09bdfdc6} + { 0x3550f703, 0xe582, 0x4d05, { 0x9a, 0x08, 0x45, 0x3d, 0x09, 0xbd, 0xfd, 0xc6 } }, "Copyright (c) 2004 mozilla.org", NS_XRE_ENABLE_PROFILE_MIGRATOR | NS_XRE_ENABLE_EXTENSION_MANAGER diff --git a/mozilla/mail/app/profile/all-thunderbird.js b/mozilla/mail/app/profile/all-thunderbird.js index b05a73a6f75..cae029a4e79 100644 --- a/mozilla/mail/app/profile/all-thunderbird.js +++ b/mozilla/mail/app/profile/all-thunderbird.js @@ -42,16 +42,6 @@ pref("general.useragent.vendorSub", pref("general.useragent.locale", "en-US"); pref("general.skins.selectedSkin", "classic/1.0"); -// This is this application's unique identifier used by the Extension System to identify -// this application as an extension target, and by the SmartUpdate system to identify -// this application to the Update server. -pref("app.id", "{3550f703-e582-4d05-9a08-453d09bdfdc6}"); -pref("app.version", -#expand __APP_VERSION__ -); -pref("app.build_id", -#expand __BUILD_ID__ -); pref("app.extensions.version", "0.6"); #ifdef XP_MACOSX diff --git a/mozilla/toolkit/mozapps/extensions/content/extensions.js b/mozilla/toolkit/mozapps/extensions/content/extensions.js index 35c3bad6a50..d575034b101 100644 --- a/mozilla/toolkit/mozapps/extensions/content/extensions.js +++ b/mozilla/toolkit/mozapps/extensions/content/extensions.js @@ -15,7 +15,6 @@ var gDownloadManager = null; var gObserverIndex = -1; var gItemType = -1; -const PREF_APP_ID = "app.id"; const PREF_EXTENSIONS_GETMORETHEMESURL = "extensions.getMoreThemesURL"; const PREF_EXTENSIONS_GETMOREEXTENSIONSURL = "extensions.getMoreExtensionsURL"; const PREF_EXTENSIONS_DSS_ENABLED = "extensions.dss.enabled"; @@ -178,7 +177,9 @@ function Startup() gGetMoreURL = pref.getComplexValue(isExtensions ? PREF_EXTENSIONS_GETMOREEXTENSIONSURL : PREF_EXTENSIONS_GETMORETHEMESURL, Components.interfaces.nsIPrefLocalizedString).data; - gGetMoreURL = gGetMoreURL.replace(/%APPID%/g, pref.getCharPref(PREF_APP_ID)); + var app = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULAppInfo); + gGetMoreURL = gGetMoreURL.replace(/%APPID%/g, app.ID); // Update various pieces of state-dependant UI var getMore = document.getElementById("getMore"); getMore.setAttribute("value", getMore.getAttribute(isExtensions ? "valueextensions" : "valuethemes")); diff --git a/mozilla/toolkit/mozapps/extensions/src/nsExtensionManager.js.in b/mozilla/toolkit/mozapps/extensions/src/nsExtensionManager.js.in index 6b6784d99a7..c249616df46 100644 --- a/mozilla/toolkit/mozapps/extensions/src/nsExtensionManager.js.in +++ b/mozilla/toolkit/mozapps/extensions/src/nsExtensionManager.js.in @@ -20,6 +20,7 @@ * * Contributor(s): * Ben Goodger + * Benjamin Smedberg * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -39,10 +40,7 @@ const nsIExtensionManager = Components.interfaces.nsIExtensionManage const nsIUpdateService = Components.interfaces.nsIUpdateService; const nsIUpdateItem = Components.interfaces.nsIUpdateItem; -const PREF_EM_APP_ID = "app.id"; -const PREF_EM_APP_VERSION = "app.version"; const PREF_EM_APP_EXTENSIONS_VERSION = "app.extensions.version"; -const PREF_EM_APP_BUILDID = "app.build_id"; const PREF_EM_LAST_APP_VERSION = "extensions.lastAppVersion"; const PREF_UPDATE_COUNT = "extensions.update.count"; const PREF_UPDATE_DEFAULT_URL = "extensions.update.url"; @@ -87,6 +85,7 @@ const ERROR_INVALID_VERSION = -1; const ERROR_PHONED_HOME = -2; const ERROR_EXTENSION_IS_THEME = -3; +var gApp = null; var gPref = null; var gRDF = null; var gOS = null; @@ -528,7 +527,7 @@ function getItemMetadata(aDS, aResult) } // Target App Name and Version - var appID = gPref.getCharPref(PREF_EM_APP_ID); + var appID = gApp.ID; var targets = aDS.GetTargets(manifestRoot, gRDF.GetResource(EM_NS("targetApplication")), true); var idRes = gRDF.GetResource(EM_NS("id")); @@ -1522,6 +1521,8 @@ nsThemeUninstaller.prototype = { // function nsExtensionManager() { + gApp = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULAppInfo); gPref = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch); gRDF = Components.classes["@mozilla.org/rdf/rdf-service;1"] @@ -2022,7 +2023,7 @@ nsExtensionManager.prototype = { // and do version checking. Time hit here doesn't matter since this // doesn't happen all that often. this._ensureDS(); - var currAppID = gPref.getCharPref(PREF_EM_APP_ID); + var currAppID = gApp.ID; var items = this._ds.getIncompatibleItemList(currAppID, currAppVersion, nsIUpdateItem.TYPE_ADDON); if (items.length > 0) { @@ -2186,7 +2187,7 @@ nsExtensionManager.prototype = { var compat = getFile(KEY_PROFILEDIR, [FILE_COMPAT_MANIFEST]); fos.init(compat, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, 0644, 0); - var currAppBuildID = gPref.getCharPref(PREF_EM_APP_BUILDID); + var currAppBuildID = gApp.appBuildID; var val = aComponentListUpdated ? 1 : 0; var lines = ["[Compatibility]\r\n", @@ -2633,7 +2634,7 @@ nsExtensionManager.prototype = { update: function nsExtensionManager_update (aItems, aItemCount, aVersionUpdateOnly) { - var appID = gPref.getCharPref(PREF_EM_APP_ID); + var appID = gApp.ID; var appVersion = gPref.getCharPref(PREF_EM_APP_EXTENSIONS_VERSION); if (aItems.length == 0) { @@ -3429,7 +3430,7 @@ nsExtensionsDataSource.prototype = { return true; var appVersion = gPref.getCharPref(PREF_EM_APP_EXTENSIONS_VERSION); - var appID = gPref.getCharPref(PREF_EM_APP_ID); + var appID = gApp.ID; var targets = aDS.GetTargets(aSource, this._emR("targetApplication"), true); var idRes = this._emR("id"); @@ -3606,7 +3607,7 @@ nsExtensionsDataSource.prototype = { return { minVersion: ver, maxVersion: ver }; } - var appID = gPref.getCharPref(PREF_EM_APP_ID); + var appID = gApp.ID; var r = gRDF.GetResource(getItemPrefix(aType) + aExtensionID); var targetApps = aDataSource.GetTargets(r, this._emR("targetApplication"), true); if (!targetApps.hasMoreElements()) { @@ -3639,7 +3640,7 @@ nsExtensionsDataSource.prototype = { if (!targetDataSource) targetDataSource = this; - var appID = gPref.getCharPref(PREF_EM_APP_ID); + var appID = gApp.ID; var r = gRDF.GetResource(getItemPrefix(aType) + aExtensionID); var targetApps = targetDataSource.GetTargets(r, this._emR("targetApplication"), true); if (!targetApps.hasMoreElements()) { diff --git a/mozilla/toolkit/mozapps/plugins/content/pluginInstallerDatasource.js b/mozilla/toolkit/mozapps/plugins/content/pluginInstallerDatasource.js index bf2a3dc9c49..ab1b8fab5d7 100644 --- a/mozilla/toolkit/mozapps/plugins/content/pluginInstallerDatasource.js +++ b/mozilla/toolkit/mozapps/plugins/content/pluginInstallerDatasource.js @@ -7,12 +7,16 @@ function nsRDFItemUpdater(aClientOS, aChromeLocale){ this._os = Components.classes["@mozilla.org/observer-service;1"] .getService(Components.interfaces.nsIObserverService); - var prefBranch = Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefBranch); - this.appID = prefBranch.getCharPref("app.id"); - this.buildID = prefBranch.getCharPref("app.build_id"); + var app = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULAppInfo); + this.appID = app.ID; + this.buildID = app.geckoBuildID; + this.clientOS = aClientOS; this.chromeLocale = aChromeLocale; + + var prefBranch = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefBranch); this.dsURI = prefBranch.getComplexValue("pfs.datasource.url", Components.interfaces.nsIPrefLocalizedString).data; } diff --git a/mozilla/toolkit/mozapps/plugins/content/pluginInstallerWizard.js b/mozilla/toolkit/mozapps/plugins/content/pluginInstallerWizard.js index 81596b546cf..248ac1c2f53 100644 --- a/mozilla/toolkit/mozapps/plugins/content/pluginInstallerWizard.js +++ b/mozilla/toolkit/mozapps/plugins/content/pluginInstallerWizard.js @@ -478,10 +478,13 @@ nsPluginInstallerWizard.prototype.showPluginResults = function (){ document.getElementById("pluginSummaryRestartNeeded").hidden = !needsRestart; + var app = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULAppInfo); + // set the get more info link to contain the mimetypes we couldn't install. notInstalledList += - "&appID=" + this.getPrefBranch().getCharPref("app.id") + - "&appVersion=" + this.getPrefBranch().getCharPref("app.build_id") + + "&appID=" + app.ID + + "&appVersion=" + app.geckoBuildID + "&clientOS=" + this.getOS() + "&chromeLocale=" + this.getChromeLocale(); diff --git a/mozilla/toolkit/mozapps/update/content/update.js b/mozilla/toolkit/mozapps/update/content/update.js index eb12e7a9b0b..848b27e125b 100644 --- a/mozilla/toolkit/mozapps/update/content/update.js +++ b/mozilla/toolkit/mozapps/update/content/update.js @@ -43,7 +43,6 @@ const nsIUpdateItem = Components.interfaces.nsIUpdateItem; const nsIUpdateService = Components.interfaces.nsIUpdateService; const nsIExtensionManager = Components.interfaces.nsIExtensionManager; -const PREF_APP_ID = "app.id"; const PREF_UPDATE_APP_UPDATESAVAILABLE = "app.update.updatesAvailable"; const PREF_UPDATE_APP_PERFORMED = "app.update.performed"; diff --git a/mozilla/toolkit/mozapps/update/src/nsUpdateService.js.in b/mozilla/toolkit/mozapps/update/src/nsUpdateService.js.in index 037f2171287..500f4333ad2 100644 --- a/mozilla/toolkit/mozapps/update/src/nsUpdateService.js.in +++ b/mozilla/toolkit/mozapps/update/src/nsUpdateService.js.in @@ -35,8 +35,6 @@ * * ***** END LICENSE BLOCK ***** */ -const PREF_APP_ID = "app.id"; -const PREF_APP_VERSION = "app.version"; const PREF_UPDATE_APP_ENABLED = "app.update.enabled"; const PREF_UPDATE_APP_AUTOUPDATEENABLED = "app.update.autoUpdateEnabled"; const PREF_UPDATE_APP_URI = "app.update.url"; @@ -109,12 +107,15 @@ function stackTrace(aArguments, aMaxCount) dump("==================================================================\n"); } +var gApp = null; var gPref = null; var gOS = null; var gRDF = null; function nsUpdateService() { + gApp = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULAppInfo); gPref = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch); gOS = Components.classes["@mozilla.org/observer-service;1"] @@ -755,8 +756,8 @@ nsAppUpdater.prototype = { // onDatasourceLoaded: function nsAppUpdater_onDatasourceLoaded (aDataSource) { - var appID = gPref.getCharPref(PREF_APP_ID); - var appVersion = gPref.getCharPref(PREF_APP_VERSION); + var appID = gApp.ID; + var appVersion = gApp.version; var appResource = gRDF.GetResource("urn:mozilla:app:" + appID); var updatesArc = gRDF.GetResource(APP_NS("updates")); diff --git a/mozilla/toolkit/xre/nsAppRunner.cpp b/mozilla/toolkit/xre/nsAppRunner.cpp index 644354d10ab..95ee6a37e07 100644 --- a/mozilla/toolkit/xre/nsAppRunner.cpp +++ b/mozilla/toolkit/xre/nsAppRunner.cpp @@ -382,7 +382,7 @@ CheckArg(const char* aArg, const char **aParam = nsnull) static const nsXREAppData* LoadAppData(const char* appDataFile) { static char vendor[256], name[256], version[32], buildID[32], copyright[512]; - static nsXREAppData data = { vendor, name, version, buildID, copyright, 0 }; + static nsXREAppData data = { vendor, name, version, buildID, {0,0,0,{0,0,0,0,0,0,0,0}}, copyright, 0 }; nsCOMPtr lf; NS_GetFileFromPath(appDataFile, getter_AddRefs(lf)); @@ -401,6 +401,15 @@ static const nsXREAppData* LoadAppData(const char* appDataFile) return nsnull; } + // Read the app ID, if specified + char id[38] = ""; + rv = parser.GetString("App", "ID", id, sizeof(id)); + if (NS_SUCCEEDED(rv)) { + if(!data.id.Parse(id)) { + memset(&data.id, 0, sizeof(data.id)); + } + } + PRUint32 i; // Read string-valued fields @@ -886,6 +895,18 @@ nsXULAppInfo::GetName(nsACString& aResult) return NS_OK; } +NS_IMETHODIMP +nsXULAppInfo::GetID(nsID** aResult) +{ + *aResult = (nsID*) NS_Alloc(sizeof(nsID)); + if (!*aResult) + return NS_ERROR_OUT_OF_MEMORY; + + **aResult = gAppData->id; + + return NS_OK; +} + NS_IMETHODIMP nsXULAppInfo::GetVersion(nsACString& aResult) { diff --git a/mozilla/toolkit/xre/nsIXULAppInfo.idl b/mozilla/toolkit/xre/nsIXULAppInfo.idl index a09b4579374..5bd44d57df4 100644 --- a/mozilla/toolkit/xre/nsIXULAppInfo.idl +++ b/mozilla/toolkit/xre/nsIXULAppInfo.idl @@ -65,6 +65,11 @@ interface nsIXULAppInfo : nsISupports */ readonly attribute ACString version; + /** + * The application GUID. + */ + readonly attribute nsIDPtr ID; + /** * The build ID/date of the application. For xulrunner applications, * this will be different than the build ID of gecko. Be careful diff --git a/mozilla/toolkit/xre/nsXULAppAPI.h b/mozilla/toolkit/xre/nsXULAppAPI.h index f411b6b05a1..992320ebf10 100644 --- a/mozilla/toolkit/xre/nsXULAppAPI.h +++ b/mozilla/toolkit/xre/nsXULAppAPI.h @@ -41,6 +41,7 @@ #define _nsXULAppAPI_h__ #include "prtypes.h" +#include "nsID.h" /** * This API is "not even kinda frozen yet" @@ -91,6 +92,12 @@ struct nsXREAppData */ const char *appBuildID; + /** + * The application's UUID. Used by the extension manager to determine + * compatible extensions. + */ + nsID id; + /** * The copyright information to print for the -h commandline flag, * e.g. "Copyright (c) 2003 mozilla.org". diff --git a/mozilla/xulrunner/examples/simple/simple.xulapp b/mozilla/xulrunner/examples/simple/simple.xulapp index aa0050a9ed0..cc574da5734 100644 --- a/mozilla/xulrunner/examples/simple/simple.xulapp +++ b/mozilla/xulrunner/examples/simple/simple.xulapp @@ -4,6 +4,11 @@ Name=Simple Version=0.1.0 BuildID=BUILD_ID Copyright=Copyright (c) 2004 Mozilla.org +# This ID is just an example. Every XUL app ought to have +# it's own unique ID. You can use the microsoft "guidgen" +# or "uuidgen" tools, or go on irc.mozilla.org and +# /msg botbot uuid +ID={3aea3f07-ffe3-4060-bb03-bff3a5365e90} [XRE] Version=0.1