Fix bug 604680 - Remove obsolete preference "general.useragent.extra.lightning". r=nomisvai
authorPhilipp Kewisch <mozilla@kewis.ch>
Wed, 18 May 2011 21:26:56 +0200
changeset 7787 2e0ce86044757ca7e79d11e884ad66a801df6009
parent 7786 ceb7dae0c3118b48320b7cc848a29c4e75b86d3f
child 7788 7a38974444766c365a712deaf18f5b761467345c
push id1
push userbugzilla@standard8.plus.com
push dateFri, 20 May 2011 16:03:29 +0000
treeherdercomm-beta@9f2029d7b5ff [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnomisvai
bugs604680
Fix bug 604680 - Remove obsolete preference "general.useragent.extra.lightning". r=nomisvai
calendar/base/src/calCalendarManager.js
calendar/base/src/calProtocolHandler.js
calendar/lightning/content/lightning.js
calendar/sunbird/app/profile/sunbird.js
--- a/calendar/base/src/calCalendarManager.js
+++ b/calendar/base/src/calCalendarManager.js
@@ -185,28 +185,31 @@ calCalendarManager.prototype = {
         this.setupOfflineObservers();
         if (cal.isSunbird()) {
             this.loginMasterPassword();
         }
         this.mNetworkCalendarCount = 0;
         this.mReadonlyCalendarCount = 0;
         this.mCalendarCount = 0;
 
+        Services.obs.addObserver(this, "http-on-modify-request", false);
+
         aCompleteListener.onResult(null, Components.results.NS_OK);
     },
 
     shutdown: function ccm_shutdown(aCompleteListener) {
         for each (var cal in this.mCache) {
             cal.removeObserver(this.mCalObservers[cal.id]);
         }
 
         this.cleanupOfflineObservers();
 
         Services.obs.removeObserver(this, "profile-after-change");
         Services.obs.removeObserver(this, "profile-before-change");
+        Services.obs.removeObserver(this, "http-on-modify-request");
         AddonManager.removeAddonListener(gCalendarManagerAddonListener);
 
         aCompleteListener.onResult(null, Components.results.NS_OK);
     },
 
 
     setupOfflineObservers: function ccm_setupOfflineObservers() {
         Services.obs.addObserver(this, "network:offline-status-changed", false);
@@ -253,16 +256,36 @@ calCalendarManager.prototype = {
                 break;
             case "network:offline-status-changed":
                 for each (var calendar in this.mCache) {
                     if (calendar instanceof calCachedCalendar) {
                         calendar.onOfflineStatusChanged(aData == "offline");
                     }
                 }
                 break;
+            case "http-on-modify-request":
+                // Unfortunately, the ability to do this with a general pref has
+                // been removed. Calendar servers might still want to know what
+                // client is used for access, so add our UA String to each
+                // request.
+                let httpChannel = aSubject.QueryInterface(Components.interfaces.nsIHttpChannel);
+                try {
+                    // NOTE: For some reason, this observer call doesn't have
+                    // the "cal" namespace defined
+                    let ua = httpChannel.getRequestHeader("User-Agent");
+                    let calUAString = getPrefSafe("calendar.useragent.extra");
+                    if (calUAString && ua.indexOf(calUAString) < 0) {
+                        // Merge in the header value
+                        httpChannel.setRequestHeader("User-Agent", calUAString, true);
+                    }
+                } catch (e if e.result == Components.results.NS_ERROR_NOT_AVAILABLE) {
+                    // We swallow this error since it means the User Agent
+                    // header is not set. We don't want to force it to be set.
+                }
+                break;
         }
     },
 
     //
     // DB migration code begins here
     //
 
     upgradeDB: function(oldVersion, db) {
--- a/calendar/base/src/calProtocolHandler.js
+++ b/calendar/base/src/calProtocolHandler.js
@@ -63,17 +63,17 @@ calProtocolHandler.prototype = {
                             Components.interfaces.nsISupports];
 
         aCount.value = interfaces.length;
         return interfaces;
     },
     getHelperForLanguage: function cP_getHelperForLanguage(aLang) {
         return null;
     },
-    classDescription: "Describes a VALARM",
+    classDescription: "Calendar webcal(s) protocal handler",
     /* classID/contractID is filled in at the end of this file */
     implementationLanguage: Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT,
     flags: 0,
 
     QueryInterface: function cph_QueryInterface(aIID) {
         return cal.doQueryInterface(this, calProtocolHandler.prototype, aIID, null, this);
     },
 
--- a/calendar/lightning/content/lightning.js
+++ b/calendar/lightning/content/lightning.js
@@ -136,9 +136,9 @@ pref("calendar.categories.names", "");
 // Make sure mouse wheel shift and no key actions to scroll lines.
 pref("mousewheel.withnokey.action", 0);
 pref("mousewheel.withshiftkey.action", 0);
 
 // Disable use of worker threads. Restart needed.
 pref("calendar.threading.disabled", false);
 
 // Set up user agent
-#expand pref("general.useragent.extra.lightning","Lightning/__LIGHTNING_VERSION__");
+#expand pref("calendar.useragent.extra", "Lightning/__LIGHTNING_VERSION__");
--- a/calendar/sunbird/app/profile/sunbird.js
+++ b/calendar/sunbird/app/profile/sunbird.js
@@ -208,17 +208,17 @@ pref("extensions.getAddons.search.url", 
 // Extension blocklist preferences
 pref("extensions.blocklist.enabled", true);
 pref("extensions.blocklist.interval", 86400);
 pref("extensions.blocklist.url", "https://addons.mozilla.org/blocklist/2/%APP_ID%/%APP_VERSION%/%PRODUCT%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/");
 pref("extensions.blocklist.detailsURL", "http://%LOCALE%.www.mozilla.com/%LOCALE%/blocklist/");
 
 pref("general.useragent.locale", "@AB_CD@");
 pref("general.skins.selectedSkin", "classic/1.0");
-pref("general.useragent.extra.sunbird", "@APP_UA_NAME@/@APP_VERSION@");
+pref("calendar.useragent.extra", "@APP_UA_NAME@/@APP_VERSION@");
 
 // Scripts & Windows prefs
 pref("dom.disable_open_during_load",        true);
 pref("javascript.options.showInConsole",    true);
 
 // l12n and i18n
 pref("intl.accept_languages", "chrome://global/locale/intl.properties");
 pref("intl.charsetmenu.browser.static", "chrome://global/locale/intl.properties");