GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

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