From a6550f8a4079021c656c1780c3522d071d939546 Mon Sep 17 00:00:00 2001 From: "darin%meer.net" Date: Tue, 14 Jun 2005 01:54:18 +0000 Subject: [PATCH] Construct update URL using RegExps per suggestion from Ben. Include "0" in baseURL per Chase. --- browser/app/profile/firefox.js | 2 +- .../chrome/mozapps/update/updates.properties | 12 ++++++--- .../mozapps/update/src/nsUpdateService.js.in | 25 +++++++++++-------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 8d2c6fa2a6c6..48e6efcafe55 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -80,7 +80,7 @@ pref("app.update.autoInstallMode", 0); // XXX these prefs and others like them are distribution specific and should move // into chrome://browser -pref("app.update.url.base", "https://aus.mozilla.org/update/"); +pref("app.update.url", "chrome://mozapps/locale/update/updates.properties"); pref("app.update.url.manual", "chrome://mozapps/locale/update/updates.properties"); pref("app.update.url.override", "chrome://mozapps/locale/update/updates.properties"); pref("app.update.updatesAvailable", false); diff --git a/toolkit/locales/en-US/chrome/mozapps/update/updates.properties b/toolkit/locales/en-US/chrome/mozapps/update/updates.properties index c425f294b3fd..96d12a1f82c1 100755 --- a/toolkit/locales/en-US/chrome/mozapps/update/updates.properties +++ b/toolkit/locales/en-US/chrome/mozapps/update/updates.properties @@ -4,11 +4,15 @@ updateType_minor=Security Update introType_minor=An important Security Update for %S is available: introType_major=A new version of %S is available: verificationError=%S could not confirm the integrity of the update package. -app.update.url.manual=http://www.mozilla.org/update -# This should be empty unless you wish to override the URL used to discover -# available updates. -app.update.url.override= errorsPageHeader=Update Failed IAgreeLabel=I Agree license404Error=The license file could not be found. Please contact the distributor. downloadingLicense=Downloading license text... +# The prefix /update2/0/ uniquely identifies the format of this URL. If you +# change the format of this URL, then you MUST change the prefix (i.e., +# increment 0 to 1). +app.update.url=https://aus.mozilla.org/update2/0/%PRODUCT%/%VERSION%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/update.xml +# When updating fails, we present the user with this web page: +app.update.url.manual=http://www.mozilla.org/update +# This value should be empty unless you wish to override app.update.url +app.update.url.override= diff --git a/toolkit/mozapps/update/src/nsUpdateService.js.in b/toolkit/mozapps/update/src/nsUpdateService.js.in index 98ec47fd73fb..e9a3668b902b 100644 --- a/toolkit/mozapps/update/src/nsUpdateService.js.in +++ b/toolkit/mozapps/update/src/nsUpdateService.js.in @@ -49,7 +49,7 @@ const PREF_APP_UPDATE_INTERVAL = "app.update.interval"; const PREF_APP_UPDATE_TIMER = "app.update.timer"; const PREF_APP_UPDATE_LOG_ENABLED = "app.update.logEnabled"; -const PREF_APP_UPDATE_URL_BASE = "app.update.url.base"; +const PREF_APP_UPDATE_URL = "app.update.url"; const PREF_APP_UPDATE_URL_OVERRIDE = "app.update.url.override"; const PREF_UPDATE_LASTUPDATETIME_FMT = "app.update.lastUpdateTime.%ID%"; @@ -974,19 +974,22 @@ Checker.prototype = { } catch (e) {} // Otherwise, construct the update URL from component parts. - var baseURL = getPref("getCharPref", PREF_APP_UPDATE_URL_BASE, null); - if (!baseURL) { - LOG(PREF_APP_UPDATE_URL_BASE + " not defined"); + try { + url = gPref.getComplexValue(PREF_APP_UPDATE_URL, + nsIPrefLocalizedString).data; + } catch (e) { + LOG(PREF_APP_UPDATE_URL + " not defined"); return null; } - // /////update.xml - url = baseURL + - gApp.name + "/" + - gApp.version + "/" + - gApp.appBuildID + "/" + - gApp.OS + "_" + gApp.XPCOMABI + "/" + - gPref.getCharPref("general.useragent.locale") + "/update.xml"; + var locale = gPref.getCharPref("general.useragent.locale"); + + url = url.replace(/%PRODUCT%/g, gApp.name); + url = url.replace(/%VERSION%/g, gApp.version); + url = url.replace(/%BUILD_ID%/g, gApp.appBuildID); + url = url.replace(/%BUILD_TARGET%/g, gApp.OS + "_" + gApp.XPCOMABI); + url = url.replace(/%LOCALE%/g, locale); + LOG("update url: " + url); return url; },