Bug 954801 - Suppress errors when running without libpurple, r=florian.
authorBenedikt Pfeifer <benediktp@ymail.com>
Thu, 11 Oct 2012 01:13:46 +0200
changeset 18834 d0b952d42fc4864723ade67c679002f41f2aaaa4
parent 18833 8645b87c557a46f92bd63246cd4a726f0d0e730c
child 18835 3bb78e5ed8e447d5fa67b764ef60dc1647a4e22d
push id1103
push usermbanner@mozilla.com
push dateTue, 18 Mar 2014 07:44:06 +0000
treeherdercomm-beta@50c6279a0af0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs954801
Bug 954801 - Suppress errors when running without libpurple, r=florian.
im/content/aboutDialog.xul
im/content/preferences/advanced.js
im/content/preferences/advanced.xul
im/locales/en-US/chrome/instantbird/preferences/advanced.dtd
im/modules/ibCore.jsm
--- a/im/content/aboutDialog.xul
+++ b/im/content/aboutDialog.xul
@@ -45,20 +45,25 @@
           var versionField = document.getElementById("versionField");
           versionField.value = versionField.value + xai.version
                              + ' (' + xai.appBuildID + ')';
 
           versionField = document.getElementById("geckoVersionField");
           versionField.value = versionField.value + xai.platformVersion
                              + ' (' + xai.platformBuildID + ')';
 
-          var pcs = Components.classes["@instantbird.org/libpurple/core;1"]
-                              .getService(Components.interfaces.purpleICoreService)
           versionField = document.getElementById("libpurpleVersionField");
-          versionField.value = versionField.value + pcs.version;
+          if ("@instantbird.org/libpurple/core;1" in Components.classes) {
+            var pcs = Components.classes["@instantbird.org/libpurple/core;1"]
+                                .getService(Components.interfaces.purpleICoreService);
+            versionField.value = versionField.value + pcs.version;
+          }
+          else {
+            versionField.hidden = true;
+          }
 
           versionField = document.getElementById("userAgentField");
           versionField.value = navigator.userAgent;
 
           var button = document.documentElement.getButton("extra2");
           button.setAttribute("label", document.documentElement.getAttribute("creditslabel"));
           button.setAttribute("accesskey", document.documentElement.getAttribute("creditsaccesskey"));
           gSelectedPage = 0;
--- a/im/content/preferences/advanced.js
+++ b/im/content/preferences/advanced.js
@@ -21,16 +21,17 @@ var gAdvancedPane = {
     if (extraArgs && extraArgs["advancedTab"]){
       advancedPrefs.selectedTab = document.getElementById(extraArgs["advancedTab"]);
     } else {
       var preference = document.getElementById("browser.preferences.advanced.selectedTabIndex");
       if (preference.value !== null)
         advancedPrefs.selectedIndex = preference.value;
     }
 
+    this.updateConnectionGroupbox();
 #ifdef MOZ_UPDATER
     this.updateAppUpdateItems();
     this.updateAutoItems();
     this.updateModeItems();
 #endif
   },
 
   /**
@@ -144,16 +145,32 @@ var gAdvancedPane = {
    * Displays a dialog in which purple proxy settings may be changed.
    */
   showProxies: function ()
   {
     document.documentElement.openSubDialog("chrome://instantbird/content/proxies.xul",
                                            "", null);
   },
 
+  /**
+   * Adapt the content of the connection groupbox depending on libpurple being
+   * there or not.
+   */
+  updateConnectionGroupbox: function ()
+  {
+    let hasLibpurple = "@instantbird.org/libpurple/core;1" in Components.classes;
+    // Hide explanatory header and libpurple section.
+    document.getElementById("connectionGroupHeader").hidden = !hasLibpurple;
+    document.getElementById("connectionGroupSeparator").hidden = !hasLibpurple;
+    document.getElementById("purpleConnectionBox").hidden = !hasLibpurple;
+    // Choose appropriate label for the Mozilla proxy options.
+    document.getElementById("mozConnLabelWithoutLibpurple").hidden = hasLibpurple;
+    document.getElementById("mozConnLabelWithLibpurple").hidden = !hasLibpurple;
+  },
+
   // UPDATE TAB
 
   /*
    * Preferences:
    *
    * app.update.enabled
    * - true if updates to the application are enabled, false otherwise
    * extensions.update.enabled
--- a/im/content/preferences/advanced.xul
+++ b/im/content/preferences/advanced.xul
@@ -179,35 +179,36 @@
 
         <!-- Network -->
         <tabpanel id="networkPanel" orient="vertical">
 
            <!-- Connection -->
            <groupbox id="connectionGroup">
              <caption label="&connection.label;"/>
 
-             <hbox align="center">
+             <hbox id="connectionGroupHeader" align="center">
                <image style="padding-right: 1em;" src="chrome://global/skin/icons/information-32.png"/>
                <vbox>
                  <description flex="1">&connectionInfoDesc.label;</description>
                  <description flex="1">&connectionDesc.label;</description>
                </vbox>
              </hbox>
 
-             <separator class="thin"/>
+             <separator id="connectionGroupSeparator" class="thin"/>
 
              <hbox align="center" id="purpleConnectionBox">
-               <description flex="1" control="connectionSettingsPurple">&connectionAccountsDesc.label;</description>
+               <description flex="1" control="connectionSettingsPurple">&connectionLibpurpleDesc.label;</description>
                <button id="connectionSettingsPurple" icon="network" label="&connectionSettings.label;"
                        accesskey="&connectionSettings.accesskey;"
                        oncommand="gAdvancedPane.showProxies();"/>
              </hbox>
 
              <hbox align="center" id="mozillaConnectionBox">
-               <description flex="1" control="connectionSettings">&connectionOtherDesc.label;</description>
+               <description id="mozConnLabelWithoutLibpurple" flex="1" control="connectionSettings">&connectionDesc.label;</description>
+               <description id="mozConnLabelWithLibpurple" flex="1" control="connectionSettings">&connectionOtherDesc.label;</description>
                <button id="connectionSettings" icon="network" label="&connectionSettings.label;"
                        accesskey="&connectionSettings2.accesskey;"
                        oncommand="gAdvancedPane.showConnections();"/>
              </hbox>
            </groupbox>
         </tabpanel>
 
         <!-- Update -->
--- a/im/locales/en-US/chrome/instantbird/preferences/advanced.dtd
+++ b/im/locales/en-US/chrome/instantbird/preferences/advanced.dtd
@@ -32,17 +32,17 @@
 <!ENTITY configEdit.accesskey            "E">
 
 <!ENTITY networkTab.label                "Network">
 
 <!ENTITY connection.label                "Connection">
 
 <!ENTITY connectionDesc.label            "Configure how &brandShortName; connects to the Internet">
 <!ENTITY connectionInfoDesc.label        "The two following parts will be merged in a later version.">
-<!ENTITY connectionAccountsDesc.label    "To connect accounts">
+<!ENTITY connectionLibpurpleDesc.label   "For libpurple-based accounts">
 <!ENTITY connectionOtherDesc.label       "For everything else (updates, addons, …)">
 <!ENTITY connectionSettings.label        "Settings…">
 <!ENTITY connectionSettings.accesskey    "e">
 <!ENTITY connectionSettings2.accesskey   "i">
 
 <!ENTITY updateTab.label                 "Update">
 
 <!ENTITY autoCheck.label                 "Automatically check for updates to:">
--- a/im/modules/ibCore.jsm
+++ b/im/modules/ibCore.jsm
@@ -25,17 +25,17 @@ var Core = {
                   .getService(Ci.nsICrashReporter)
                   .annotateCrashReport("Vendor", "Instantbird");
       }
     } catch(e) {
       // This can fail if breakpad isn't enabled,
       // don't worry too much about this exception.
     }
 
-    if (!Ci.purpleICoreService) {
+    if (!Ci.imICoreService) {
       this._promptError("startupFailure.purplexpcomFileError");
       return false;
     }
 
     if (!Components.classes["@mozilla.org/chat/core-service;1"]) {
       this._promptError("startupFailure.xpcomRegistrationError");
       return false;
     }