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

[or-cvs] r10260: [darcs-to-svn @ fix the about box in firefox 1.0] Original a (in torbutton/trunk/src: . chrome/content)



Author: squires
Date: 2007-05-22 01:24:10 -0400 (Tue, 22 May 2007)
New Revision: 10260

Modified:
   torbutton/trunk/src/CHANGELOG
   torbutton/trunk/src/chrome/content/about.xul
   torbutton/trunk/src/chrome/content/torbutton.js
Log:
[darcs-to-svn @ fix the about box in firefox 1.0]

Original author: squires@xxxxxxxxx
Date: 2006-09-23 03:00:34+00:00

Modified: torbutton/trunk/src/CHANGELOG
===================================================================
--- torbutton/trunk/src/CHANGELOG	2007-05-22 05:24:05 UTC (rev 10259)
+++ torbutton/trunk/src/CHANGELOG	2007-05-22 05:24:10 UTC (rev 10260)
@@ -1,3 +1,6 @@
+1.0.5
+  * bugfix: fix the about box in firefox 1.0
+
 1.0.4
   01 Jun 2006
   * bugfix: without-privoxy settings were incorrect

Modified: torbutton/trunk/src/chrome/content/about.xul
===================================================================
--- torbutton/trunk/src/chrome/content/about.xul	2007-05-22 05:24:05 UTC (rev 10259)
+++ torbutton/trunk/src/chrome/content/about.xul	2007-05-22 05:24:10 UTC (rev 10260)
@@ -8,10 +8,18 @@
         xmlns:html="http://www.w3.org/1999/xhtml";
         title="&torbutton.about.title;"
         buttons="accept"
-        persist="screenX screenY">
+        persist="screenX screenY"
+        onload="torbutton_about_init();">
 
     <script type="application/x-javascript" src="torbutton.js" />
+    <stringbundleset id="extensionsSet">
+        <stringbundle id="extensionsStrings" src="chrome://mozapps/locale/extensions/extensions.properties"/>
+    </stringbundleset>
     <label value="Torbutton" style="font-weight: bold;"/>
+    <label id="torbuttonVersion"/>
     <label value="Scott Squires"/>
-    <label value="http://freehaven.net/~squires/torbutton/"/>
+    <label value="http://freehaven.net/~squires/torbutton/";
+          class="url"
+          style="color: blue; text-decoration: underline;"
+          onclick="window.open('http://freehaven.net/~squires/torbutton/');"/>
 </dialog>

Modified: torbutton/trunk/src/chrome/content/torbutton.js
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton.js	2007-05-22 05:24:05 UTC (rev 10259)
+++ torbutton/trunk/src/chrome/content/torbutton.js	2007-05-22 05:24:10 UTC (rev 10260)
@@ -373,22 +373,62 @@
     var extensionManager = Components.classes["@mozilla.org/extensions/manager;1"]
                            .getService(Components.interfaces.nsIExtensionManager);
     var database = '@mozilla.org/rdf/datasource;1?name=composite-datasource';
+    var extension_id = '';
     database = Components.classes[database]
                .getService(Components.interfaces.nsIRDFCompositeDataSource);
     database.AddDataSource(extensionManager.datasource);
 
-    window.openDialog("chrome://mozapps/content/extensions/about.xul","","chrome,modal","urn:mozilla:item:{e0204bd5-9d31-402b-a99d-a6aa8ffebdca}",database);
+    if (geckoVersionCompare("1.8") <= 0)
+    {
+        // Firefox 1.5 -- use built-in about box
+        extension_id = "urn:mozilla:item:{e0204bd5-9d31-402b-a99d-a6aa8ffebdca}";
+        window.openDialog("chrome://mozapps/content/extensions/about.xul","","chrome",extension_id,database);
+    } else {
+        // Firefox 1.0 -- home page link is broken in built-in about box, use our own
+        extension_id = "urn:mozilla:extension:{e0204bd5-9d31-402b-a99d-a6aa8ffebdca}";
+        window.openDialog("chrome://torbutton/content/about.xul","","chrome",extension_id,database);
+    }
+}
 
-// or we could just extract the version the way that about.js and about.xul do it
-// (the below is incomplete)
-/*
-  var rdfs = Components.classes["@mozilla.org/rdf/rdf-service;1"]
-                       .getService(Components.interfaces.nsIRDFService);
-  var extension = rdfs.GetResource("urn:mozilla:item:{e0204bd5-9d31-402b-a99d-a6aa8ffebdca}"); 
-  alert(extension.Value);
-*/
+function torbutton_about_init() {
+    var extensionID = window.arguments[0];
+    var extensionDB = window.arguments[1];
+
+    var oBundle = Components.classes["@mozilla.org/intl/stringbundle;1"]
+                            .getService(Components.interfaces.nsIStringBundleService);
+    var extensionsStrings = document.getElementById("extensionsStrings");
+
+    var rdfs = Components.classes["@mozilla.org/rdf/rdf-service;1"]
+                         .getService(Components.interfaces.nsIRDFService);
+    var extension = rdfs.GetResource(extensionID);
+
+    var versionArc = rdfs.GetResource("http://www.mozilla.org/2004/em-rdf#version";);
+    var version = extensionDB.GetTarget(extension, versionArc, true);
+    version = version.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
+
+    var extensionVersion = document.getElementById("torbuttonVersion");
+
+    extensionVersion.setAttribute("value", extensionsStrings.getFormattedString("aboutWindowVersionString", [version]));
 }
 
+function geckoVersionCompare(aVersion) {
+    var ioService = Components.classes["@mozilla.org/network/io-service;1"]
+                    .getService(Components.interfaces.nsIIOService);
+    var httpProtocolHandler = ioService.getProtocolHandler("http")
+                              .QueryInterface(Components.interfaces.nsIHttpProtocolHandler);
+    var versionComparator = null;
+
+    if ("nsIVersionComparator" in Components.interfaces) {
+        versionComparator = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
+                            .getService(Components.interfaces.nsIVersionComparator);
+    } else {
+        versionComparator = Components.classes["@mozilla.org/updates/version-checker;1"]
+                            .getService(Components.interfaces.nsIVersionChecker);
+    }
+    var geckoVersion = httpProtocolHandler.misc.match(/rv:([0-9.]+)/)[1];
+    return versionComparator.compare(aVersion, geckoVersion);
+}
+
 function torbutton_log(nLevel, sMsg) {
     if (m_tb_logger) {
         var rDate = new Date();