Commit b152a6ed authored by Kathleen Brade's avatar Kathleen Brade
Browse files

Bug 11199: Improve behavior if tor exits.

If Tor Launcher started the tor process and it exits, display
a prompt that allows the user to restart tor.
parent 6cf204d6
...@@ -155,13 +155,7 @@ ...@@ -155,13 +155,7 @@
<spring flex="1" /> <spring flex="1" />
<hbox> <hbox>
<spring flex="1" /> <spring flex="1" />
<description id="startingTorMessage">&torsettings.startingTor;</description> <description>&torsettings.startingTor;</description>
<spring flex="1" />
</hbox>
<hbox>
<spring flex="1" />
<button id="restartButton" label="&torsettings.restart;" hidden="true"
oncommand="onRestartApp()" />
<spring flex="1" /> <spring flex="1" />
</hbox> </hbox>
<spring flex="1" /> <spring flex="1" />
...@@ -173,7 +167,14 @@ ...@@ -173,7 +167,14 @@
<spring flex="1" /> <spring flex="1" />
<hbox> <hbox>
<spring flex="1" /> <spring flex="1" />
<description id="errorPanelMessage" flex="1"/> <description id="errorPanelMessage" />
<spring flex="1" />
</hbox>
<separator/>
<hbox>
<spring flex="1" />
<button id="restartTorButton" label="&torsettings.restartTor;" hidden="true"
oncommand="onRestartTor()" />
<spring flex="1" /> <spring flex="1" />
</hbox> </hbox>
<spring flex="1" /> <spring flex="1" />
......
...@@ -24,6 +24,7 @@ const kSupportAddr = "help@rt.torproject.org"; ...@@ -24,6 +24,7 @@ const kSupportAddr = "help@rt.torproject.org";
const kTorProcessReadyTopic = "TorProcessIsReady"; const kTorProcessReadyTopic = "TorProcessIsReady";
const kTorProcessExitedTopic = "TorProcessExited"; const kTorProcessExitedTopic = "TorProcessExited";
const kTorProcessDidNotStartTopic = "TorProcessDidNotStart"; const kTorProcessDidNotStartTopic = "TorProcessDidNotStart";
const kTorOpenProgressTopic = "TorOpenProgressDialog";
const kTorBootstrapErrorTopic = "TorBootstrapError"; const kTorBootstrapErrorTopic = "TorBootstrapError";
const kTorLogHasWarnOrErrTopic = "TorLogHasWarnOrErr"; const kTorLogHasWarnOrErrTopic = "TorLogHasWarnOrErr";
...@@ -158,12 +159,16 @@ function initDialog() ...@@ -158,12 +159,16 @@ function initDialog()
gObsService.addObserver(gObserver, kTorBootstrapErrorTopic, false); gObsService.addObserver(gObserver, kTorBootstrapErrorTopic, false);
gObsService.addObserver(gObserver, kTorLogHasWarnOrErrTopic, false); gObsService.addObserver(gObserver, kTorLogHasWarnOrErrTopic, false);
gObsService.addObserver(gObserver, kTorProcessExitedTopic, false); gObsService.addObserver(gObserver, kTorProcessExitedTopic, false);
gObsService.addObserver(gObserver, kTorOpenProgressTopic, false);
var status = gTorProcessService.TorProcessStatus; var status = gTorProcessService.TorProcessStatus;
if (TorLauncherUtil.shouldStartAndOwnTor && if (TorLauncherUtil.shouldStartAndOwnTor &&
(status != gTorProcessService.kStatusRunning)) (status != gTorProcessService.kStatusRunning))
{ {
showStartingTorPanel(status == gTorProcessService.kStatusExited); if (status == gTorProcessService.kStatusExited)
showErrorMessage(true, null);
else
showStartingTorPanel();
gObsService.addObserver(gObserver, kTorProcessReadyTopic, false); gObsService.addObserver(gObserver, kTorProcessReadyTopic, false);
gObsService.addObserver(gObserver, kTorProcessDidNotStartTopic, false); gObsService.addObserver(gObserver, kTorProcessDidNotStartTopic, false);
} }
...@@ -337,12 +342,16 @@ var gObserver = { ...@@ -337,12 +342,16 @@ var gObserver = {
else if (kTorProcessDidNotStartTopic == aTopic) else if (kTorProcessDidNotStartTopic == aTopic)
{ {
gObsService.removeObserver(gObserver, kTorProcessDidNotStartTopic); gObsService.removeObserver(gObserver, kTorProcessDidNotStartTopic);
showErrorPanel(aData); showErrorMessage(false, aData);
} }
else if (kTorProcessExitedTopic == aTopic) else if (kTorProcessExitedTopic == aTopic)
{ {
gObsService.removeObserver(gObserver, kTorProcessExitedTopic); gObsService.removeObserver(gObserver, kTorProcessExitedTopic);
showStartingTorPanel(true); showErrorMessage(true, null);
}
else if (kTorOpenProgressTopic == aTopic)
{
openProgressDialog();
} }
} }
}; };
...@@ -365,7 +374,7 @@ function readTorSettings() ...@@ -365,7 +374,7 @@ function readTorSettings()
if (!didSucceed) if (!didSucceed)
{ {
// Unable to communicate with tor. Hide settings and display an error. // Unable to communicate with tor. Hide settings and display an error.
showErrorPanel(); showErrorMessage(false, null);
setTimeout(function() setTimeout(function()
{ {
...@@ -422,34 +431,49 @@ function advanceToWizardPanel(aPanelID) ...@@ -422,34 +431,49 @@ function advanceToWizardPanel(aPanelID)
} }
function showStartingTorPanel(aTorExited) function showStartingTorPanel()
{ {
if (aTorExited) var haveWizard = (getWizard() != null);
if (haveWizard)
{ {
// Show "Tor exited; please restart" message and Restart button. showOrHideButton("back", false, false);
var elem = document.getElementById("startingTorMessage"); showOrHideButton("next", false, false);
if (elem)
{
var s1 = TorLauncherUtil.getLocalizedString("tor_exited");
var s2 = TorLauncherUtil.getLocalizedString("please_restart_app");
elem.textContent = s1 + "\n\n" + s2;
}
var btn = document.getElementById("restartButton");
if (btn)
btn.removeAttribute("hidden");
} }
showPanel("startingTor"); showPanel("startingTor");
} }
function showErrorPanel(aErrorMsg) function showErrorMessage(aTorExited, aErrorMsg)
{ {
showPanel("errorPanel");
var elem = document.getElementById("errorPanelMessage"); var elem = document.getElementById("errorPanelMessage");
var btn = document.getElementById("restartTorButton");
if (aTorExited)
{
// Show "Tor exited" message and "Restart Tor" button.
aErrorMsg = TorLauncherUtil.getLocalizedString("tor_exited");
if (btn)
btn.removeAttribute("hidden");
}
else
{
if (btn)
btn.setAttribute("hidden", true);
}
if (elem) if (elem)
elem.textContent = (aErrorMsg) ? aErrorMsg : ""; elem.textContent = (aErrorMsg) ? aErrorMsg : "";
showPanel("errorPanel");
var haveWizard = (getWizard() != null);
if (haveWizard)
{
showOrHideButton("back", false, false);
showOrHideButton("next", false, false);
}
var haveErrorOrWarning = (gTorProcessService.TorBootstrapErrorOccurred || var haveErrorOrWarning = (gTorProcessService.TorBootstrapErrorOccurred ||
gProtocolSvc.TorLogHasWarnOrErr) gProtocolSvc.TorLogHasWarnOrErr)
showCopyLogButton(haveErrorOrWarning); showCopyLogButton(haveErrorOrWarning);
...@@ -613,28 +637,16 @@ function onProxyTypeChange() ...@@ -613,28 +637,16 @@ function onProxyTypeChange()
} }
function onRestartApp() // Called when user clicks "Restart Tor" button after tor unexpectedly quits.
function onRestartTor()
{ {
if (gIsInitialBootstrap) // Re-add these observers in case they have been removed.
{ gObsService.addObserver(gObserver, kTorProcessReadyTopic, false);
// If the browser has not fully started yet, we cannot use the app startup gObsService.addObserver(gObserver, kTorProcessDidNotStartTopic, false);
// service to restart it... so we use a delayed approach. gObsService.addObserver(gObserver, kTorProcessExitedTopic, false);
try
{
var obsSvc = Cc["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService);
obsSvc.notifyObservers(null, "TorUserRequestedQuit", "restart");
window.close(); gTorProcessService._startTor();
} catch (e) {} gTorProcessService._controlTor();
}
else
{
// Restart now.
var asSvc = Cc["@mozilla.org/toolkit/app-startup;1"]
.getService(Ci.nsIAppStartup);
asSvc.quit(asSvc.eAttemptQuit | asSvc.eRestart);
}
} }
......
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- <!--
- Copyright (c) 2013, The Tor Project, Inc. - Copyright (c) 2014, The Tor Project, Inc.
- See LICENSE for licensing information. - See LICENSE for licensing information.
- vim: set sw=2 sts=2 ts=8 et syntax=xml: - vim: set sw=2 sts=2 ts=8 et syntax=xml:
--> -->
...@@ -57,18 +57,27 @@ ...@@ -57,18 +57,27 @@
<spring flex="1" /> <spring flex="1" />
<hbox> <hbox>
<spring flex="1" /> <spring flex="1" />
<description id="startingTorMessage">&torsettings.startingTor;</description> <description>&torsettings.startingTor;</description>
<spring flex="1" /> <spring flex="1" />
</hbox> </hbox>
<spring flex="1" />
</vbox>
<vbox id="errorPanel">
<spring flex="1" />
<hbox>
<spring flex="1" />
<description id="errorPanelMessage" />
<spring flex="1" />
</hbox>
<separator/>
<hbox> <hbox>
<spring flex="1" /> <spring flex="1" />
<button id="restartButton" label="&torsettings.restart;" hidden="true" <button id="restartTorButton" label="&torsettings.restartTor;" hidden="true"
oncommand="onRestartApp()" /> oncommand="onRestartTor()" />
<spring flex="1" /> <spring flex="1" />
</hbox> </hbox>
<spring flex="1" /> <spring flex="1" />
</vbox> </vbox>
<vbox id="errorPanel"/>
<vbox id="bridgeHelp" class="help"> <vbox id="bridgeHelp" class="help">
<vbox id="bridgeHelpContent" /> <vbox id="bridgeHelpContent" />
</vbox> </vbox>
......
...@@ -136,7 +136,7 @@ var gObserver = { ...@@ -136,7 +136,7 @@ var gObserver = {
{ {
// TODO: provide a way to access tor log e.g., leave this dialog open // TODO: provide a way to access tor log e.g., leave this dialog open
// and display the open settings button. // and display the open settings button.
onCancel(); cleanup();
window.close(); window.close();
} }
else if (kBootstrapStatusTopic == aTopic) else if (kBootstrapStatusTopic == aTopic)
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<!-- Other: --> <!-- Other: -->
<!ENTITY torsettings.startingTor "Waiting for Tor to start…"> <!ENTITY torsettings.startingTor "Waiting for Tor to start…">
<!ENTITY torsettings.restart "Restart"> <!ENTITY torsettings.restartTor "Restart Tor">
<!ENTITY torsettings.optional "Optional"> <!ENTITY torsettings.optional "Optional">
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
torlauncher.error_title=Tor Launcher torlauncher.error_title=Tor Launcher
torlauncher.tor_exited=Tor unexpectedly exited. torlauncher.tor_exited=Tor unexpectedly exited.
torlauncher.please_restart_app=Please restart this application.
torlauncher.tor_controlconn_failed=Could not connect to Tor control port. torlauncher.tor_controlconn_failed=Could not connect to Tor control port.
torlauncher.tor_failed_to_start=Tor failed to start. torlauncher.tor_failed_to_start=Tor failed to start.
torlauncher.tor_control_failed=Failed to take control of Tor. torlauncher.tor_control_failed=Failed to take control of Tor.
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<!-- Other: --> <!-- Other: -->
<!ENTITY torsettings.startingTor "Waiting for Tor to start…"> <!ENTITY torsettings.startingTor "Waiting for Tor to start…">
<!ENTITY torsettings.restart "Restart"> <!ENTITY torsettings.restartTor "Restart Tor">
<!ENTITY torsettings.optional "Optional"> <!ENTITY torsettings.optional "Optional">
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
torlauncher.error_title=Tor Launcher torlauncher.error_title=Tor Launcher
torlauncher.tor_exited=Tor unexpectedly exited. torlauncher.tor_exited=Tor unexpectedly exited.
torlauncher.please_restart_app=Please restart this application.
torlauncher.tor_controlconn_failed=Could not connect to Tor control port. torlauncher.tor_controlconn_failed=Could not connect to Tor control port.
torlauncher.tor_failed_to_start=Tor failed to start. torlauncher.tor_failed_to_start=Tor failed to start.
torlauncher.tor_control_failed=Failed to take control of Tor. torlauncher.tor_control_failed=Failed to take control of Tor.
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
torlauncher.error_title=Tor Launcher torlauncher.error_title=Tor Launcher
torlauncher.tor_exited=Tor unexpectedly exited. torlauncher.tor_exited=Tor unexpectedly exited.
torlauncher.please_restart_app=Please restart this application.
torlauncher.tor_controlconn_failed=Could not connect to Tor control port. torlauncher.tor_controlconn_failed=Could not connect to Tor control port.
torlauncher.tor_failed_to_start=Tor failed to start. torlauncher.tor_failed_to_start=Tor failed to start.
torlauncher.tor_control_failed=Failed to take control of Tor. torlauncher.tor_control_failed=Failed to take control of Tor.
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<!-- Other: --> <!-- Other: -->
<!ENTITY torsettings.startingTor "Waiting for Tor to start…"> <!ENTITY torsettings.startingTor "Waiting for Tor to start…">
<!ENTITY torsettings.restart "Restart"> <!ENTITY torsettings.restartTor "Restart Tor">
<!ENTITY torsettings.optional "Optional"> <!ENTITY torsettings.optional "Optional">
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
torlauncher.error_title=Tor Launcher torlauncher.error_title=Tor Launcher
torlauncher.tor_exited=Tor unexpectedly exited. torlauncher.tor_exited=Tor unexpectedly exited.
torlauncher.please_restart_app=Please restart this application.
torlauncher.tor_controlconn_failed=Could not connect to Tor control port. torlauncher.tor_controlconn_failed=Could not connect to Tor control port.
torlauncher.tor_failed_to_start=Tor failed to start. torlauncher.tor_failed_to_start=Tor failed to start.
torlauncher.tor_control_failed=Failed to take control of Tor. torlauncher.tor_control_failed=Failed to take control of Tor.
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<!-- Other: --> <!-- Other: -->
<!ENTITY torsettings.startingTor "Waiting for Tor to start…"> <!ENTITY torsettings.startingTor "Waiting for Tor to start…">
<!ENTITY torsettings.restart "Restart"> <!ENTITY torsettings.restartTor "Restart Tor">
<!ENTITY torsettings.optional "Optional"> <!ENTITY torsettings.optional "Optional">
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
torlauncher.error_title=Tor Launcher torlauncher.error_title=Tor Launcher
torlauncher.tor_exited=Tor unexpectedly exited. torlauncher.tor_exited=Tor unexpectedly exited.
torlauncher.please_restart_app=Please restart this application.
torlauncher.tor_controlconn_failed=Could not connect to Tor control port. torlauncher.tor_controlconn_failed=Could not connect to Tor control port.
torlauncher.tor_failed_to_start=Tor failed to start. torlauncher.tor_failed_to_start=Tor failed to start.
torlauncher.tor_control_failed=Failed to take control of Tor. torlauncher.tor_control_failed=Failed to take control of Tor.
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
torlauncher.error_title=Tor Launcher torlauncher.error_title=Tor Launcher
torlauncher.tor_exited=Tor unexpectedly exited. torlauncher.tor_exited=Tor unexpectedly exited.
torlauncher.please_restart_app=Please restart this application.
torlauncher.tor_controlconn_failed=Could not connect to Tor control port. torlauncher.tor_controlconn_failed=Could not connect to Tor control port.
torlauncher.tor_failed_to_start=Tor failed to start. torlauncher.tor_failed_to_start=Tor failed to start.
torlauncher.tor_control_failed=Failed to take control of Tor. torlauncher.tor_control_failed=Failed to take control of Tor.
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<!-- Other: --> <!-- Other: -->
<!ENTITY torsettings.startingTor "Waiting for Tor to start…"> <!ENTITY torsettings.startingTor "Waiting for Tor to start…">
<!ENTITY torsettings.restart "Restart"> <!ENTITY torsettings.restartTor "Restart Tor">
<!ENTITY torsettings.optional "Optional"> <!ENTITY torsettings.optional "Optional">
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
torlauncher.error_title=Tor Launcher torlauncher.error_title=Tor Launcher
torlauncher.tor_exited=Tor unexpectedly exited. torlauncher.tor_exited=Tor unexpectedly exited.
torlauncher.please_restart_app=Please restart this application.
torlauncher.tor_controlconn_failed=Could not connect to Tor control port. torlauncher.tor_controlconn_failed=Could not connect to Tor control port.
torlauncher.tor_failed_to_start=Tor failed to start. torlauncher.tor_failed_to_start=Tor failed to start.
torlauncher.tor_control_failed=Failed to take control of Tor. torlauncher.tor_control_failed=Failed to take control of Tor.
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<!-- Other: --> <!-- Other: -->
<!ENTITY torsettings.startingTor "في انتظار تور حتي يبدء بالعمل..."> <!ENTITY torsettings.startingTor "في انتظار تور حتي يبدء بالعمل...">
<!ENTITY torsettings.restart "إعادة تشغيل"> <!ENTITY torsettings.restartTor "Restart Tor">
<!ENTITY torsettings.optional "اختياري"> <!ENTITY torsettings.optional "اختياري">
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
torlauncher.error_title=مُشغل تور torlauncher.error_title=مُشغل تور
torlauncher.tor_exited=توقف تور عن العمل بشكل غير متوقع. torlauncher.tor_exited=توقف تور عن العمل بشكل غير متوقع.
torlauncher.please_restart_app=يرجي إعادة تشغيل هذا البرنامج.
torlauncher.tor_controlconn_failed=تعذر الاتصال بمنفذ التحكم الخاص بتور. torlauncher.tor_controlconn_failed=تعذر الاتصال بمنفذ التحكم الخاص بتور.
torlauncher.tor_failed_to_start=تور فشل في بدء التشغيل. torlauncher.tor_failed_to_start=تور فشل في بدء التشغيل.
torlauncher.tor_control_failed=تعذر التحكم في تور. torlauncher.tor_control_failed=تعذر التحكم في تور.
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<!-- Other: --> <!-- Other: -->
<!ENTITY torsettings.startingTor "Waiting for Tor to start…"> <!ENTITY torsettings.startingTor "Waiting for Tor to start…">
<!ENTITY torsettings.restart "Restart"> <!ENTITY torsettings.restartTor "Restart Tor">
<!ENTITY torsettings.optional "Optional"> <!ENTITY torsettings.optional "Optional">
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
torlauncher.error_title=Tor Launcher torlauncher.error_title=Tor Launcher
torlauncher.tor_exited=Tor unexpectedly exited. torlauncher.tor_exited=Tor unexpectedly exited.
torlauncher.please_restart_app=Please restart this application.
torlauncher.tor_controlconn_failed=Could not connect to Tor control port. torlauncher.tor_controlconn_failed=Could not connect to Tor control port.
torlauncher.tor_failed_to_start=Tor failed to start. torlauncher.tor_failed_to_start=Tor failed to start.
torlauncher.tor_control_failed=Failed to take control of Tor. torlauncher.tor_control_failed=Failed to take control of Tor.
......
Supports Markdown
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