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

[or-cvs] r10249: [darcs-to-svn @ tagged 1.0] Original author: squires@pobox.c (in torbutton/trunk: . src src/chrome src/chrome/content src/chrome/locale src/chrome/locale/en-US src/chrome/skin src/chrome/skin/classic)



Author: squires
Date: 2007-05-22 01:22:53 -0400 (Tue, 22 May 2007)
New Revision: 10249

Added:
   torbutton/trunk/src/
   torbutton/trunk/src/CREDITS
   torbutton/trunk/src/LICENSE
   torbutton/trunk/src/chrome.manifest
   torbutton/trunk/src/chrome/
   torbutton/trunk/src/chrome/content/
   torbutton/trunk/src/chrome/content/contents.rdf
   torbutton/trunk/src/chrome/content/torbutton.js
   torbutton/trunk/src/chrome/content/torbutton.xul
   torbutton/trunk/src/chrome/locale/
   torbutton/trunk/src/chrome/locale/en-US/
   torbutton/trunk/src/chrome/locale/en-US/contents.rdf
   torbutton/trunk/src/chrome/locale/en-US/torbutton.dtd
   torbutton/trunk/src/chrome/locale/en-US/torbutton.properties
   torbutton/trunk/src/chrome/skin/
   torbutton/trunk/src/chrome/skin/classic/
   torbutton/trunk/src/chrome/skin/classic/bigbutton.png
   torbutton/trunk/src/chrome/skin/classic/bigbutton_gr.png
   torbutton/trunk/src/chrome/skin/classic/contents.rdf
   torbutton/trunk/src/chrome/skin/classic/smallbutton.png
   torbutton/trunk/src/chrome/skin/classic/smallbutton_gr.png
   torbutton/trunk/src/chrome/skin/classic/torbutton.css
   torbutton/trunk/src/install.rdf
Log:
[darcs-to-svn @ tagged 1.0]

Original author: squires@xxxxxxxxx
Date: 2006-06-01 18:57:50+00:00

Added: torbutton/trunk/src/CREDITS
===================================================================
--- torbutton/trunk/src/CREDITS	2007-05-22 02:20:52 UTC (rev 10248)
+++ torbutton/trunk/src/CREDITS	2007-05-22 05:22:53 UTC (rev 10249)
@@ -0,0 +1,2 @@
+TorButton was adapted by Scott Squires from ProxyButton
+(proxybutton.mozdev.com), which was written by Oleg Ivanov.

Added: torbutton/trunk/src/LICENSE
===================================================================
--- torbutton/trunk/src/LICENSE	2007-05-22 02:20:52 UTC (rev 10248)
+++ torbutton/trunk/src/LICENSE	2007-05-22 05:22:53 UTC (rev 10249)
@@ -0,0 +1,7 @@
+Copyright (c) 2006 Scott Squires, Oleg Ivanov
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Added: torbutton/trunk/src/chrome/content/contents.rdf
===================================================================
--- torbutton/trunk/src/chrome/content/contents.rdf	2007-05-22 02:20:52 UTC (rev 10248)
+++ torbutton/trunk/src/chrome/content/contents.rdf	2007-05-22 05:22:53 UTC (rev 10249)
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+
+<RDF:RDF xmlns:chrome="http://www.mozilla.org/rdf/chrome#";
+         xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
+
+    <RDF:Seq about="urn:mozilla:package:root">
+        <RDF:li resource="urn:mozilla:package:torbutton"/>
+    </RDF:Seq>
+    
+    <RDF:Description about="urn:mozilla:package:torbutton"
+                     chrome:extension="true"
+                     chrome:name="torbutton" />
+    </RDF:Description>
+
+    <RDF:Seq about="urn:mozilla:overlays">
+        <RDF:li resource="chrome://browser/content/browser.xul"/>
+    </RDF:Seq>
+    
+    <RDF:Seq about="chrome://browser/content/browser.xul">
+        <RDF:li>chrome://torbutton/content/torbutton.xul</RDF:li>
+    </RDF:Seq>
+
+</RDF:RDF>

Added: torbutton/trunk/src/chrome/content/torbutton.js
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton.js	2007-05-22 02:20:52 UTC (rev 10248)
+++ torbutton/trunk/src/chrome/content/torbutton.js	2007-05-22 05:22:53 UTC (rev 10249)
@@ -0,0 +1,194 @@
+var m_toolbutton = false;
+var m_statuspanel = false;
+var m_wasinited = false;
+var m_commonprefs = false;
+var m_stringbundle = false;
+var m_tb_logger = false;
+
+function torbutton_toggle() {
+    torbutton_log(1, 'called toggle()');
+    if (!m_wasinited) {
+        torbutton_init();
+    }
+    if (!m_toolbutton) {
+        torbutton_init_toolbutton();
+    }
+
+    var nCurProxyType = m_commonprefs.getIntPref("network.proxy.type");
+    if (torbutton_check_status()) {
+        torbutton_disable_tor();
+    } else {
+        torbutton_enable_tor();
+    }
+}
+
+function torbutton_init() {
+    if (!m_tb_logger) {
+        try {
+            var logMngr = Components.classes["@mozmonkey.com/debuglogger/manager;1"].getService(Components.interfaces.nsIDebugLoggerManager); 
+            m_tb_logger = logMngr.registerLogger("torbutton");
+        } catch (exErr) {
+            m_tb_logger = false;
+        }
+    }
+    
+    if (!m_stringbundle) {
+        try {
+            var oBundle = Components.classes["@mozilla.org/intl/stringbundle;1"].getService(Components.interfaces.nsIStringBundleService);
+            m_stringbundle = oBundle.createBundle("chrome://torbutton/locale/torbutton.properties");
+        } catch(err) { torbutton_log(1, 'caught exception'); }
+        if (!m_stringbundle) {
+            torbutton_log(1, 'ERROR (init): failed to find torbutton-bundle');
+        }
+    }
+
+    torbutton_log(1, 'called init()');
+    if (!m_commonprefs) {
+    	torbutton_initPrefObjects();
+    }
+
+    if (!m_statuspanel) {
+        torbutton_log(1, 'looking for statusbar element');
+        if (document.getElementById("torbutton-panel")) {
+            m_statuspanel = document.getElementById("torbutton-panel");
+        } else {
+            torbutton_log(1, 'ERROR (init): failed to find torbutton-panel');
+        }
+    } else {
+        torbutton_log(1, 'skipping statusbar panel element search');
+    }
+
+    if (!m_wasinited) {
+        torbutton_log(1, 'initializing observer');
+        var rObserver = {
+            observe : function(subject, topic, data) { torbutton_setButtonFromPreference(); }
+        };
+        torbutton_log(1, 'getting service');
+        var prefService = Components.classes["@mozilla.org/preferences-service;1"].
+            getService(Components.interfaces.nsIPrefService);
+        torbutton_log(1, 'getting branch');
+        var rBranch = prefService.getBranch("network.");
+        torbutton_log(1, 'quering interface');
+        var pbi = rBranch.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
+        torbutton_log(1, 'adding observer');
+        pbi.addObserver("proxy", rObserver, false);
+        
+        m_wasinited = true;
+    } else {
+        torbutton_log(1, 'skipping observers init');
+    }
+    
+    torbutton_log(1, 'setting from prefs');
+    torbutton_setButtonFromPreference();
+    torbutton_log(1, 'init completed');
+}
+
+function torbutton_init_toolbutton() {
+    torbutton_log(1, 'called init_toolbutton()');
+    if (!m_toolbutton) {
+        torbutton_log(1, 'looking for button element');
+        if (document.getElementById("torbutton-button")) {
+            m_toolbutton = document.getElementById("torbutton-button");
+        } else {
+            torbutton_log(1, 'ERROR (init): failed to find torbutton-button');
+        }
+    } else {
+        torbutton_log(1, 'skipping button element search');
+    }
+}
+
+function torbutton_initPrefObjects() {
+    m_commonprefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
+}
+
+function torbutton_check_status() {
+    torbutton_log(1,'checking tor status');
+    if ( (m_commonprefs.getIntPref("network.proxy.type")           == 0)           ||
+         (m_commonprefs.getCharPref("network.proxy.http")          != "localhost") ||
+         (m_commonprefs.getIntPref("network.proxy.http_port")      != 8118)        ||
+         (m_commonprefs.getCharPref("network.proxy.ssl")           != "localhost") ||
+         (m_commonprefs.getIntPref("network.proxy.ssl_port")       != 8118)        ||
+         (m_commonprefs.getCharPref("network.proxy.ftp")           != "localhost") ||
+         (m_commonprefs.getIntPref("network.proxy.ftp_port")       != 8118)        ||
+         (m_commonprefs.getCharPref("network.proxy.gopher")        != "localhost") ||
+         (m_commonprefs.getIntPref("network.proxy.gopher_port")    != 8118)        ||
+         (m_commonprefs.getCharPref("network.proxy.socks")         != "localhost") ||
+         (m_commonprefs.getIntPref("network.proxy.socks_port")     != 8118)        ||
+         (m_commonprefs.getIntPref("network.proxy.socks_version")  != 4)           ||
+         (m_commonprefs.getCharPref("network.proxy.no_proxies_on") != "localhost, 127.0.0.1") ||
+         (m_commonprefs.getIntPref("network.proxy.type")           != 1) )
+    {
+        return false;
+        // torbutton_log(1,'tor is disabled');
+        // torbutton_update_status(0);
+    } else {
+        return true;
+        // torbutton_log(1,'tor is enabled');
+        // torbutton_update_status(1);
+    }
+}
+
+function torbutton_setButtonFromPreference() {
+    if (torbutton_check_status()) {
+        torbutton_log(1,'tor is enabled');
+        torbutton_update_status(1);
+    } else {
+        torbutton_log(1,'tor is disabled');
+        torbutton_update_status(0);
+    }
+}
+
+function torbutton_disable_tor() {
+    torbutton_log(1, 'called disable_tor()');
+    m_commonprefs.setIntPref("network.proxy.type", 0);
+}
+
+function torbutton_enable_tor() {
+    torbutton_log(1, 'called enable_tor()');
+
+    m_commonprefs.setCharPref("network.proxy.http", "localhost");
+    m_commonprefs.setIntPref("network.proxy.http_port", 8118);
+    m_commonprefs.setCharPref("network.proxy.ssl", "localhost");
+    m_commonprefs.setIntPref("network.proxy.ssl_port", 8118);
+    m_commonprefs.setCharPref("network.proxy.ftp", "localhost");
+    m_commonprefs.setIntPref("network.proxy.ftp_port", 8118);
+    m_commonprefs.setCharPref("network.proxy.gopher", "localhost");
+    m_commonprefs.setIntPref("network.proxy.gopher_port", 8118);
+    m_commonprefs.setCharPref("network.proxy.socks", "localhost");
+    m_commonprefs.setIntPref("network.proxy.socks_port", 8118);
+    m_commonprefs.setIntPref("network.proxy.socks_version", 4);
+    m_commonprefs.setCharPref("network.proxy.no_proxies_on", "localhost, 127.0.0.1");
+    m_commonprefs.setIntPref("network.proxy.type", 1);
+}
+
+function torbutton_update_status(nMode) {
+    var sPrefix;
+
+    torbutton_log(1, 'called update_status('+nMode+')');
+    if (nMode == 0) {
+        if (m_toolbutton) {
+            m_toolbutton.setAttribute('tbstatus', 'off');
+            m_toolbutton.setAttribute('tooltiptext', m_stringbundle.GetStringFromName("torbutton.button.tooltip.disabled"));
+        }
+
+        m_statuspanel.style.color = "#F00";
+        m_statuspanel.setAttribute('label', m_stringbundle.GetStringFromName("torbutton.panel.label.disabled"));
+        m_statuspanel.setAttribute('tooltiptext', m_stringbundle.GetStringFromName("torbutton.panel.tooltip.disabled"));
+    } else {
+        if (m_toolbutton) {
+            m_toolbutton.setAttribute('tbstatus', 'on');
+            m_toolbutton.setAttribute('tooltiptext', m_stringbundle.GetStringFromName("torbutton.button.tooltip.disabled"));
+        }
+
+        m_statuspanel.style.color = "#390";
+        m_statuspanel.setAttribute('label', m_stringbundle.GetStringFromName("torbutton.panel.label.enabled"));
+        m_statuspanel.setAttribute('tooltiptext', m_stringbundle.GetStringFromName("torbutton.panel.tooltip.enabled"));
+    }
+}
+
+function torbutton_log(nLevel, sMsg) {
+    if (m_tb_logger) {
+        var rDate = new Date();
+        m_tb_logger.log(nLevel, rDate.getTime()+': '+sMsg);
+    }
+}

Added: torbutton/trunk/src/chrome/content/torbutton.xul
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton.xul	2007-05-22 02:20:52 UTC (rev 10248)
+++ torbutton/trunk/src/chrome/content/torbutton.xul	2007-05-22 05:22:53 UTC (rev 10249)
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://torbutton/skin/torbutton.css" type="text/css"?> 
+
+<!DOCTYPE overlay SYSTEM "chrome://torbutton/locale/torbutton.dtd">
+
+<overlay id="torbutton-overlay"
+         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";>
+    <script type="application/x-javascript" src="chrome://torbutton/content/torbutton.js" />
+    <script language="JavaScript">
+        //onLoad Hander
+        try{window.addEventListener("load", torbutton_init, false);}catch(e){}
+    </script>
+
+    <stringbundleset id="torbutton-stringbundleset">
+        <stringbundle id="torbutton-bundle" src="chrome://torbutton/locale/torbutton.properties"/>
+    </stringbundleset>
+
+    <toolbarpalette id="BrowserToolbarPalette">
+        <toolbarbutton 
+            id="torbutton-button" 
+            class="toolbarbutton-1" 
+            tooltiptext="&torbuttonTooltip;" 
+            label="&torbuttonButton.label;"
+            oncommand="torbutton_toggle();" />
+    </toolbarpalette>
+
+    <statusbar id="status-bar">
+        <statusbarpanel	id="torbutton-panel"
+			label="torbutton"
+			insertbefore="statusbar-updates"
+			onclick="torbutton_toggle()" />
+    </statusbar>
+
+</overlay>

Added: torbutton/trunk/src/chrome/locale/en-US/contents.rdf
===================================================================
--- torbutton/trunk/src/chrome/locale/en-US/contents.rdf	2007-05-22 02:20:52 UTC (rev 10248)
+++ torbutton/trunk/src/chrome/locale/en-US/contents.rdf	2007-05-22 05:22:53 UTC (rev 10249)
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+         xmlns:chrome="http://www.mozilla.org/rdf/chrome#";>
+
+  <!-- skins supplied by this package -->
+  <RDF:Seq about="urn:mozilla:locale:root">
+    <RDF:li resource="urn:mozilla:locale:en-US"/>
+  </RDF:Seq>
+
+  <!-- locale information -->
+  <RDF:Description about="urn:mozilla:locale:en-US">
+    <chrome:packages>
+      <RDF:Seq about="urn:mozilla:locale:en-US:packages">
+        <RDF:li resource="urn:mozilla:locale:en-US:torbutton"/>
+      </RDF:Seq>
+    </chrome:packages>
+  </RDF:Description>
+
+</RDF:RDF>

Added: torbutton/trunk/src/chrome/locale/en-US/torbutton.dtd
===================================================================
--- torbutton/trunk/src/chrome/locale/en-US/torbutton.dtd	2007-05-22 02:20:52 UTC (rev 10248)
+++ torbutton/trunk/src/chrome/locale/en-US/torbutton.dtd	2007-05-22 05:22:53 UTC (rev 10249)
@@ -0,0 +1,2 @@
+<!ENTITY torbuttonButton.label "TorButton">
+<!ENTITY torbuttonTooltip "Turn Tor on/off">

Added: torbutton/trunk/src/chrome/locale/en-US/torbutton.properties
===================================================================
--- torbutton/trunk/src/chrome/locale/en-US/torbutton.properties	2007-05-22 02:20:52 UTC (rev 10248)
+++ torbutton/trunk/src/chrome/locale/en-US/torbutton.properties	2007-05-22 05:22:53 UTC (rev 10249)
@@ -0,0 +1,6 @@
+torbutton.button.tooltip.disabled = Enable Tor
+torbutton.button.tooltip.enabled = Disable Tor
+torbutton.panel.tooltip.disabled = Click to enable Tor
+torbutton.panel.tooltip.enabled = Click to disable Tor
+torbutton.panel.label.disabled = Tor Disabled
+torbutton.panel.label.enabled = Tor Enabled

Added: torbutton/trunk/src/chrome/skin/classic/bigbutton.png
===================================================================
(Binary files differ)


Property changes on: torbutton/trunk/src/chrome/skin/classic/bigbutton.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: torbutton/trunk/src/chrome/skin/classic/bigbutton_gr.png
===================================================================
(Binary files differ)


Property changes on: torbutton/trunk/src/chrome/skin/classic/bigbutton_gr.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: torbutton/trunk/src/chrome/skin/classic/contents.rdf
===================================================================
--- torbutton/trunk/src/chrome/skin/classic/contents.rdf	2007-05-22 02:20:52 UTC (rev 10248)
+++ torbutton/trunk/src/chrome/skin/classic/contents.rdf	2007-05-22 05:22:53 UTC (rev 10249)
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+     xmlns:chrome="http://www.mozilla.org/rdf/chrome#";>
+
+    <Seq about="urn:mozilla:skin:root">
+        <li resource="urn:mozilla:skin:classic/1.0"/>
+    </Seq>
+  
+    <Description about="urn:mozilla:skin:classic/1.0">
+        <chrome:packages>
+            <Seq about="urn:mozilla:skin:classic/1.0:packages">
+                <li resource="urn:mozilla:skin:classic/1.0:torbutton"/>
+            </Seq>
+        </chrome:packages>
+    </Description>
+
+    <Seq about="urn:mozilla:stylesheets">
+        <li resource="chrome://browser/content/browser.xul"/>
+        <li resource="chrome://global/content/customizeToolbar.xul"/>
+    </Seq>
+
+    <!-- FireFox -->  
+    <Seq about="chrome://browser/content/browser.xul">
+        <li>chrome://torbutton/skin/torbutton.css</li>
+    </Seq>
+
+    <Seq about="chrome://global/content/customizeToolbar.xul">
+        <li>chrome://torbutton/skin/torbutton.css</li>
+    </Seq>
+</RDF>

Added: torbutton/trunk/src/chrome/skin/classic/smallbutton.png
===================================================================
(Binary files differ)


Property changes on: torbutton/trunk/src/chrome/skin/classic/smallbutton.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: torbutton/trunk/src/chrome/skin/classic/smallbutton_gr.png
===================================================================
(Binary files differ)


Property changes on: torbutton/trunk/src/chrome/skin/classic/smallbutton_gr.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: torbutton/trunk/src/chrome/skin/classic/torbutton.css
===================================================================
--- torbutton/trunk/src/chrome/skin/classic/torbutton.css	2007-05-22 02:20:52 UTC (rev 10248)
+++ torbutton/trunk/src/chrome/skin/classic/torbutton.css	2007-05-22 05:22:53 UTC (rev 10249)
@@ -0,0 +1,18 @@
+#torbutton-button {
+  list-style-image: url("chrome://torbutton/skin/bigbutton.png");
+}
+#torbutton-button[tbstatus="on"] {
+  list-style-image: url("chrome://torbutton/skin/bigbutton_gr.png");
+}
+#torbutton-button[tbstatus="off"] {
+  list-style-image: url("chrome://torbutton/skin/bigbutton.png");
+}
+toolbar[iconsize="small"] #torbutton-button {
+  list-style-image: url("chrome://torbutton/skin/smallbutton.png");
+}
+toolbar[iconsize="small"] #torbutton-button[tbstatus="on"] {
+  list-style-image: url("chrome://torbutton/skin/smallbutton_gr.png");
+}
+toolbar[iconsize="small"] #torbutton-button[tbstatus="off"] {
+  list-style-image: url("chrome://torbutton/skin/smallbutton.png");
+}

Added: torbutton/trunk/src/chrome.manifest
===================================================================
--- torbutton/trunk/src/chrome.manifest	2007-05-22 02:20:52 UTC (rev 10248)
+++ torbutton/trunk/src/chrome.manifest	2007-05-22 05:22:53 UTC (rev 10249)
@@ -0,0 +1,7 @@
+content torbutton chrome/content/
+overlay chrome://browser/content/browser.xul chrome://torbutton/content/torbutton.xul
+
+locale torbutton en-US chrome/locale/en-US/
+
+skin torbutton classic/1.0 chrome/skin/classic/
+style chrome://global/content/customizeToolbar.xul chrome://torbutton/skin/torbutton.css

Added: torbutton/trunk/src/install.rdf
===================================================================
--- torbutton/trunk/src/install.rdf	2007-05-22 02:20:52 UTC (rev 10248)
+++ torbutton/trunk/src/install.rdf	2007-05-22 05:22:53 UTC (rev 10249)
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#";>
+
+    <Description about="urn:mozilla:install-manifest">
+        <em:creator>Scott Squires</em:creator>
+        <em:description>TorButton provides a button to easily enable or disable the tor proxy</em:description>
+        <em:id>{e0204bd5-9d31-402b-a99d-a6aa8ffebdca}</em:id>
+        <em:name>TorButton</em:name>
+        <em:version>1.0</em:version>
+
+        <em:targetApplication>
+            <Description>
+                <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+                <em:minVersion>0.9</em:minVersion>
+                <em:maxVersion>1.5.0.1</em:maxVersion>
+            </Description>
+        </em:targetApplication>
+
+        <em:file>
+            <Description about="urn:mozilla:extension:file:torbutton.jar">
+                <em:package>content/</em:package>
+                <em:locale>locale/en-US/</em:locale>
+                <em:skin>skin/classic/</em:skin>
+            </Description>
+        </em:file>
+
+        <em:file>
+            <Description resource="urn:mozilla:extension:file:torbutton.jar"/>
+        </em:file>
+    </Description>
+
+</RDF>