[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [torbutton/master 08/31] Fix toggle codepath for Firefox 4.



Author: Mike Perry <mikeperry-git@xxxxxxxxxx>
Date: Wed, 1 Dec 2010 03:38:10 -0800
Subject: Fix toggle codepath for Firefox 4.
Commit: 513700cc742b98a24dc6d716dcb7a671f3d95c95

Don't touch gopher settings for FF4. gopher support has finally been removed.
RIP, archie. No one will miss you.
---
 src/chrome/content/torbutton.js      |   31 +++++++++++++++++++++++--------
 src/chrome/content/torbutton_util.js |   23 +++++++++++++++++------
 2 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 14c9d66..f5080c5 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -17,6 +17,7 @@ var m_tb_window_width = window.outerWidth;
 var m_tb_ff3 = false;
 var m_tb_ff35 = false;
 var m_tb_ff36 = false;
+var m_tb_ff4 = false;
 
 var torbutton_window_pref_observer =
 {
@@ -404,6 +405,12 @@ function torbutton_init() {
     var versionChecker = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
         .getService(Components.interfaces.nsIVersionComparator);
 
+    if(versionChecker.compare(appInfo.version, "4.0a1") >= 0) {
+        m_tb_ff4 = true;
+    } else {
+        m_tb_ff4 = false;
+    }
+
     if(versionChecker.compare(appInfo.version, "3.0a1") >= 0) {
         m_tb_ff3 = true;
     } else {
@@ -563,20 +570,24 @@ function torbutton_init_prefs() {
             torprefs.setCharPref('http_proxy', proxy_host);
             torprefs.setCharPref('https_proxy', proxy_host);
             torprefs.setCharPref('ftp_proxy', '');
-            torprefs.setCharPref('gopher_proxy', '');
             torprefs.setIntPref('http_port', proxy_port);
             torprefs.setIntPref('https_port', proxy_port);
             torprefs.setIntPref('ftp_port', 0);
-            torprefs.setIntPref('gopher_port', 0);
+            if (!m_tb_ff4) {
+                torprefs.setCharPref('gopher_proxy', '');
+                torprefs.setIntPref('gopher_port', 0);
+            }
         } else {
             torprefs.setCharPref('http_proxy', proxy_host);
             torprefs.setCharPref('https_proxy', proxy_host);
             torprefs.setCharPref('ftp_proxy', proxy_host);
-            torprefs.setCharPref('gopher_proxy', proxy_host);
+            if (!m_tb_ff4) {
+                torprefs.setCharPref('gopher_proxy', proxy_host);
+                torprefs.setIntPref('gopher_port', proxy_port);
+            }
             torprefs.setIntPref('http_port', proxy_port);
             torprefs.setIntPref('https_port', proxy_port);
             torprefs.setIntPref('ftp_port', proxy_port);
-            torprefs.setIntPref('gopher_port', proxy_port);
         }
         torprefs.setCharPref('socks_host', '127.0.0.1');
         torprefs.setIntPref('socks_port', 9050);
@@ -646,12 +657,14 @@ function torbutton_save_nontor_settings()
   savprefs.setCharPref('ftp_proxy',    liveprefs.getCharPref('ftp'));
   torbutton_log(1, 'half-way');
   savprefs.setIntPref('ftp_port',      liveprefs.getIntPref('ftp_port'));
-  savprefs.setCharPref('gopher_proxy', liveprefs.getCharPref('gopher'));
-  savprefs.setIntPref('gopher_port',   liveprefs.getIntPref('gopher_port'));
   savprefs.setCharPref('socks_host',   liveprefs.getCharPref('socks'));
   savprefs.setIntPref('socks_port',    liveprefs.getIntPref('socks_port'));
   savprefs.setIntPref('socks_version', liveprefs.getIntPref('socks_version'));
   savprefs.setCharPref('no_proxies_on', liveprefs.getCharPref('no_proxies_on'));
+  if (!m_tb_ff4) {
+    savprefs.setCharPref('gopher_proxy', liveprefs.getCharPref('gopher'));
+    savprefs.setIntPref('gopher_port',   liveprefs.getIntPref('gopher_port'));
+  }
   try { // ff-0.9 doesn't have share_proxy_settings
     savprefs.setBoolPref('share_proxy_settings', liveprefs.getBoolPref('share_proxy_settings'));
   } catch(e) {}
@@ -685,8 +698,10 @@ function torbutton_restore_nontor_settings()
   liveprefs.setCharPref('ftp',          savprefs.getCharPref('ftp_proxy'));
   torbutton_log(1, 'half-way there');
   liveprefs.setIntPref('ftp_port',      savprefs.getIntPref('ftp_port'));
-  liveprefs.setCharPref('gopher',       savprefs.getCharPref('gopher_proxy'));
-  liveprefs.setIntPref('gopher_port',   savprefs.getIntPref('gopher_port'));
+  if (!m_tb_ff4) {
+      liveprefs.setCharPref('gopher',       savprefs.getCharPref('gopher_proxy'));
+      liveprefs.setIntPref('gopher_port',   savprefs.getIntPref('gopher_port'));
+  }
   liveprefs.setCharPref('socks',        savprefs.getCharPref('socks_host'));
   liveprefs.setIntPref('socks_port',    savprefs.getIntPref('socks_port'));
   liveprefs.setIntPref('socks_version', savprefs.getIntPref('socks_version'));
diff --git a/src/chrome/content/torbutton_util.js b/src/chrome/content/torbutton_util.js
index 86509da..fb17932 100644
--- a/src/chrome/content/torbutton_util.js
+++ b/src/chrome/content/torbutton_util.js
@@ -1,6 +1,19 @@
 var m_tb_torlog = Components.classes["@torproject.org/torbutton-logger;1"]
 .getService(Components.interfaces.nsISupports).wrappedJSObject;
 
+// This is sort of hacky and random..
+var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
+    .getService(Components.interfaces.nsIXULAppInfo);
+var versionChecker = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
+    .getService(Components.interfaces.nsIVersionComparator);
+var m_tb_ff4 = false;
+
+if(versionChecker.compare(appInfo.version, "4.0a1") >= 0) {
+    m_tb_ff4 = true;
+} else {
+    m_tb_ff4 = false;
+}
+
 
 function torbutton_eclog(nLevel, sMsg) {
     m_tb_torlog.eclog(nLevel, sMsg);
@@ -122,10 +135,6 @@ function torbutton_check_status() {
          torbutton_log(1, "ftp proxy") &&
          (liveprefs.getIntPref("ftp_port")      == torprefs.getIntPref('ftp_port'))      &&
          torbutton_log(1, "ftp port") &&
-         (liveprefs.getCharPref("gopher")       == torprefs.getCharPref('gopher_proxy')) &&
-         torbutton_log(1, "gopher proxy") &&
-         (liveprefs.getIntPref("gopher_port")   == torprefs.getIntPref('gopher_port'))   &&
-         torbutton_log(1, "gopher port") &&
          (liveprefs.getCharPref("socks")        == torprefs.getCharPref('socks_host'))   &&
          torbutton_log(1, "socks proxy") &&
          (liveprefs.getIntPref("socks_port")    == torprefs.getIntPref('socks_port'))    &&
@@ -159,8 +168,10 @@ function torbutton_activate_tor_settings()
   liveprefs.setCharPref('ftp',          torprefs.getCharPref('ftp_proxy'));
   liveprefs.setIntPref('ftp_port',      torprefs.getIntPref('ftp_port'));
   torbutton_log(1, 'Half-way there');
-  liveprefs.setCharPref('gopher',       torprefs.getCharPref('gopher_proxy'));
-  liveprefs.setIntPref('gopher_port',   torprefs.getIntPref('gopher_port'));
+  if (!m_tb_ff4) {
+      liveprefs.setCharPref('gopher',       torprefs.getCharPref('gopher_proxy'));
+      liveprefs.setIntPref('gopher_port',   torprefs.getIntPref('gopher_port'));
+  }
   liveprefs.setCharPref('socks',        torprefs.getCharPref('socks_host'));
   liveprefs.setIntPref('socks_port',    torprefs.getIntPref('socks_port'));
   liveprefs.setIntPref('socks_version', torprefs.getIntPref('socks_version'));
-- 
1.7.1