Commit 3daaee7e authored by Kathleen Brade's avatar Kathleen Brade
Browse files

Added hidden pref. to control whether Tor Launcher starts the tor process.

parent d44dfc5d
......@@ -15,8 +15,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "TorLauncherUtil",
XPCOMUtils.defineLazyModuleGetter(this, "TorLauncherLogger",
"resource://torlauncher/modules/tl-logger.jsm");
const kPrefPromptAtStartup = "extensions.torlauncher.prompt_at_startup";
const kUseProxyCheckbox = "useProxy";
const kProxyTypeMenulist = "proxyType";
const kProxyAddr = "proxyAddr";
......@@ -48,7 +46,7 @@ var gIsBootstrapComplete = false;
function initDialog()
{
var okBtn = document.documentElement.getButton("accept");
gIsInitialBootstrap = TorLauncherUtil.getBoolPref(kPrefPromptAtStartup);
gIsInitialBootstrap = window.arguments[0];
if (gIsInitialBootstrap)
{
document.documentElement.setAttribute("class", "initialBootstrap");
......
......@@ -30,6 +30,7 @@ TorProcessService.prototype =
kServiceName : "Tor Launcher Process Service",
kClassID: Components.ID("{FE7B4CAF-BCF4-4848-8BFF-EFA66C9AFDA1}"),
kPrefStartTor: "extensions.torlauncher.start_tor",
kPrefPromptAtStartup: "extensions.torlauncher.prompt_at_startup",
kInitialMonitorDelayMS: 1000, // TODO: how can we avoid this delay?
kMonitorDelayMS: 200,
......@@ -76,7 +77,9 @@ TorProcessService.prototype =
this.mObsSvc.addObserver(this, "quit-application-granted", false);
this.mObsSvc.addObserver(this, kOpenNetworkSettingsTopic, false);
this.mObsSvc.addObserver(this, kUserQuitTopic, false);
this._startTor();
if (TorLauncherUtil.getBoolPref(this.kPrefStartTor))
this._startTor();
}
else if ("quit-application-granted" == aTopic)
{
......@@ -118,7 +121,7 @@ TorProcessService.prototype =
this.mTimer.init(this, this.kMonitorDelayMS, this.mTimer.TYPE_ONE_SHOT);
}
else if (kOpenNetworkSettingsTopic == aTopic)
this._openNetworkSettings();
this._openNetworkSettings(false);
else if (kUserQuitTopic == aTopic)
this.mQuitSoon = true;
},
......@@ -267,7 +270,7 @@ TorProcessService.prototype =
// to delay before retry inside TorSendCommand()... which is
// difficult b/c that is a synchronous API.
if (this.mProtocolSvc)
this._openNetworkSettings(); // Blocks until dialog is closed.
this._openNetworkSettings(true); // Blocks until dialog is closed.
}
else
{
......@@ -332,13 +335,22 @@ TorProcessService.prototype =
}, // _checkBootstrapStatus()
// Blocks until network settings dialog is closed.
_openNetworkSettings: function()
_openNetworkSettings: function(aIsInitialBootstrap)
{
var chromeURL = "chrome://torlauncher/content/network-settings.xul";
const kChromeURL = "chrome://torlauncher/content/network-settings.xul";
var wwSvc = Cc["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Ci.nsIWindowWatcher);
var winFeatures = "chrome,dialog=yes,modal,all";
wwSvc.openWindow(null, chromeURL, "_blank", winFeatures, null);
var argsArray = Cc["@mozilla.org/array;1"]
.createInstance(Ci.nsIMutableArray);
var variant = Cc["@mozilla.org/variant;1"]
.createInstance(Ci.nsIWritableVariant);
variant.setFromVariant(aIsInitialBootstrap);
argsArray.appendElement(variant, false);
wwSvc.openWindow(null, kChromeURL, "_blank", winFeatures, argsArray);
},
_openProgressDialog: function()
......
......@@ -71,6 +71,8 @@ TorProtocolService.prototype =
kServiceName : "Tor Launcher Protocol Service",
kClassID: Components.ID("{4F476361-23FB-43EF-A427-B36A14D3208E}"),
kPrefStartTor: "extensions.torlauncher.start_tor",
// nsISupports implementation.
QueryInterface: function(aIID)
{
......@@ -429,16 +431,19 @@ TorProtocolService.prototype =
return null;
}
// Try to become the primary controller (TAKEOWNERSHIP).
reply = this._sendCommand(conn, "TAKEOWNERSHIP", null);
if (!this.TorCommandSucceeded(reply))
TorLauncherLogger.log(4, "take ownership failed");
else
if (TorLauncherUtil.getBoolPref(this.kPrefStartTor))
{
reply = this._sendCommand(conn, "RESETCONF",
"__OwningControllerProcess");
// Try to become the primary controller (TAKEOWNERSHIP).
reply = this._sendCommand(conn, "TAKEOWNERSHIP", null);
if (!this.TorCommandSucceeded(reply))
TorLauncherLogger.log(4, "clear owning controller process failed");
TorLauncherLogger.log(4, "take ownership failed");
else
{
reply = this._sendCommand(conn, "RESETCONF",
"__OwningControllerProcess");
if (!this.TorCommandSucceeded(reply))
TorLauncherLogger.log(4, "clear owning controller process failed");
}
}
}
catch(e)
......
......@@ -4,6 +4,7 @@ pref("extensions.torlauncher.logmethod", 1); // 0=stdout, 1=errorconsole, 2=deb
pref("extensions.torlauncher.control_host", "127.0.0.1");
pref("extensions.torlauncher.control_port", 9151);
pref("extensions.torlauncher.start_tor", true);
pref("extensions.torlauncher.prompt_at_startup", true);
// All path prefs. are relative to the firefox executable's directory
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment