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

[tor-commits] [torbutton] 02/02: Bug 40933: Moved tor-launcher to tor-browser.git



This is an automated email from the git hooks/post-receive script.

richard pushed a commit to branch main
in repository torbutton.

commit d96a88641bf94ae926bdf326978ce799ddbedb89
Author: Pier Angelo Vendrame <pierov@xxxxxxxxxxxxxx>
AuthorDate: Wed Aug 24 16:00:39 2022 +0200

    Bug 40933: Moved tor-launcher to tor-browser.git
    
    Updated paths to tor-launcher modules and use TorProtocolService,
    instead of referencing the component with
    @torproject.org/torlauncher-protocol-service;1.
---
 chrome/content/torbutton.js    | 26 +++++++++++---------------
 components/startup-observer.js |  9 +++++----
 modules/tor-control-port.js    | 12 ++++++------
 3 files changed, 22 insertions(+), 25 deletions(-)

diff --git a/chrome/content/torbutton.js b/chrome/content/torbutton.js
index ec2680f2..d89e5d55 100644
--- a/chrome/content/torbutton.js
+++ b/chrome/content/torbutton.js
@@ -30,6 +30,10 @@ var torbutton_new_circuit;
     "resource://torbutton/modules/tor-control-port.js"
   );
 
+  const { TorProtocolService } = ChromeUtils.import(
+    "resource://gre/modules/TorProtocolService.jsm"
+  );
+
   const k_tb_tor_check_failed_topic = "Torbutton:TorCheckFailed";
 
   var m_tb_prefs = Services.prefs;
@@ -197,13 +201,6 @@ var torbutton_new_circuit;
     }
     m_tb_wasinited = true;
 
-    let tlps;
-    try {
-      tlps = Cc["@torproject.org/torlauncher-protocol-service;1"].getService(
-        Ci.nsISupports
-      ).wrappedJSObject;
-    } catch (e) {}
-
     // Bug 1506 P4: These vars are very important for New Identity
     var environ = Cc["@mozilla.org/process/environment;1"].getService(
       Ci.nsIEnvironment
@@ -223,7 +220,7 @@ var torbutton_new_circuit;
     } else {
       try {
         // Try to get password from Tor Launcher.
-        m_tb_control_pass = tlps.TorGetPassword(false);
+        m_tb_control_pass = TorProtocolService.torGetPassword(false);
       } catch (e) {}
     }
 
@@ -231,7 +228,7 @@ var torbutton_new_circuit;
     // since Tor Launcher knows how to handle its own preferences and how to
     // resolve relative paths.
     try {
-      m_tb_control_ipc_file = tlps.TorGetControlIPCFile();
+      m_tb_control_ipc_file = TorProtocolService.torGetControlIPCFile();
     } catch (e) {}
 
     if (!m_tb_control_ipc_file) {
@@ -278,12 +275,6 @@ var torbutton_new_circuit;
     torbutton_log(1, "registering Tor check observer");
     torbutton_tor_check_observer.register();
 
-    try {
-      createTorCircuitDisplay("extensions.torbutton.display_circuit");
-    } catch (e) {
-      torbutton_log(4, "Error creating the tor circuit display " + e);
-    }
-
     try {
       torbutton_init_user_manual_links();
     } catch (e) {
@@ -306,6 +297,11 @@ var torbutton_new_circuit;
     async receiveMessage(aMessage) {
       switch (aMessage.name) {
         case "AboutTor:Loaded":
+          try {
+            createTorCircuitDisplay("extensions.torbutton.display_circuit");
+          } catch (e) {
+            torbutton_log(4, "Error creating the tor circuit display " + e);
+          }
           aMessage.target.messageManager.sendAsyncMessage(
             "AboutTor:ChromeData",
             await this.getChromeData(true)
diff --git a/components/startup-observer.js b/components/startup-observer.js
index f89bbe08..090eb7b8 100644
--- a/components/startup-observer.js
+++ b/components/startup-observer.js
@@ -20,6 +20,10 @@ const { XPCOMUtils } = ChromeUtils.import(
   "resource://gre/modules/XPCOMUtils.jsm"
 );
 
+const { TorProtocolService } = ChromeUtils.import(
+  "resource://gre/modules/TorProtocolService.jsm"
+);
+
 XPCOMUtils.defineLazyModuleGetters(this, {
   ComponentUtils: "resource://gre/modules/ComponentUtils.jsm",
 });
@@ -141,10 +145,7 @@ StartupObserver.prototype = {
       // Try to retrieve SOCKS proxy settings from Tor Launcher.
       let socksPortInfo;
       try {
-        let tlps = Cc[
-          "@torproject.org/torlauncher-protocol-service;1"
-        ].getService(Ci.nsISupports).wrappedJSObject;
-        socksPortInfo = tlps.TorGetSOCKSPortInfo();
+        socksPortInfo = TorProtocolService.torGetSOCKSPortInfo();
       } catch (e) {
         this.logger.log(3, "tor launcher failed " + e);
       }
diff --git a/modules/tor-control-port.js b/modules/tor-control-port.js
index dc59c8da..374ff5fd 100644
--- a/modules/tor-control-port.js
+++ b/modules/tor-control-port.js
@@ -26,9 +26,12 @@
 // ### Import Mozilla Services
 const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-const { TorProtocolService, TorProcessStatus } = ChromeUtils.import(
-  "resource:///modules/TorProtocolService.jsm"
+ChromeUtils.defineModuleGetter(
+  this,
+  "TorMonitorService",
+  "resource://gre/modules/TorMonitorService.jsm"
 );
+
 // tor-launcher observer topics
 const TorTopics = Object.freeze({
   ProcessIsReady: "TorProcessIsReady",
@@ -949,10 +952,7 @@ var controller = async function(avoidCache) {
 // tor daemon)
 var wait_for_controller = function(avoidCache) {
   // if tor process is running (either ours or system) immediately return controller
-  if (
-    !TorProtocolService.ownsTorDaemon ||
-    TorProtocolService.torProcessStatus == TorProcessStatus.Running
-  ) {
+  if (!TorMonitorService.ownsTorDaemon || TorMonitorService.isRunning) {
     return controller(avoidCache);
   }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits