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

[tor-commits] [tor-launcher/master] Bug #9675: Provide feedback mechanism for clock-skew and other bad problems



commit 8a64ec3b07e2bfe82ab47401993f52f4ec5b0163
Author: Kathy Brade <brade@xxxxxxxxxxxxxxxxx>
Date:   Fri Sep 13 10:38:22 2013 -0400

    Bug #9675: Provide feedback mechanism for clock-skew and other bad problems
    
    If a tor error or warning message is received by Tor Launcher, add a
    caution icon to the "Open Settings" and "Copy Tor Log to Clipboard" buttons.
---
 src/chrome/content/network-settings.js |   35 ++++++++++++++++++++------------
 src/chrome/content/progress.js         |   11 ++++++++++
 src/chrome/skin/network-settings.css   |    9 ++++++++
 src/chrome/skin/progress.css           |    9 ++++++++
 src/chrome/skin/warning.png            |  Bin 0 -> 2190 bytes
 5 files changed, 51 insertions(+), 13 deletions(-)

diff --git a/src/chrome/content/network-settings.js b/src/chrome/content/network-settings.js
index c9e43ce..573393d 100644
--- a/src/chrome/content/network-settings.js
+++ b/src/chrome/content/network-settings.js
@@ -22,7 +22,7 @@ const kTorProcessReadyTopic = "TorProcessIsReady";
 const kTorProcessExitedTopic = "TorProcessExited";
 const kTorProcessDidNotStartTopic = "TorProcessDidNotStart";
 const kTorBootstrapErrorTopic = "TorBootstrapError";
-const kTorLogHasWarnOrErr = "TorLogHasWarnOrErr";
+const kTorLogHasWarnOrErrTopic = "TorLogHasWarnOrErr";
 
 const kWizardProxyRadioGroup = "proxyRadioGroup";
 const kWizardFirewallRadioGroup = "firewallRadioGroup";
@@ -120,7 +120,7 @@ function initDialog()
     if (gTorProcessService.TorBootstrapErrorOccurred ||
         gProtocolSvc.TorLogHasWarnOrErr)
     {
-      wizardShowCopyLogButton();
+      showCopyLogButton(true);
     }
 
     // Use "Connect" as the finish button label (on the last wizard page)..
@@ -143,7 +143,7 @@ function initDialog()
   }
 
   gObsService.addObserver(gObserver, kTorBootstrapErrorTopic, false);
-  gObsService.addObserver(gObserver, kTorLogHasWarnOrErr, false);
+  gObsService.addObserver(gObserver, kTorLogHasWarnOrErrTopic, false);
 
   if (TorLauncherUtil.shouldStartAndOwnTor &&
       !gTorProcessService.TorIsProcessReady)
@@ -216,9 +216,10 @@ function showWizardNavButtons(aShow)
 var gObserver = {
   observe: function(aSubject, aTopic, aData)
   {
-    if ((kTorBootstrapErrorTopic == aTopic) || (kTorLogHasWarnOrErr == aTopic))
+    if ((kTorBootstrapErrorTopic == aTopic) ||
+         (kTorLogHasWarnOrErrTopic == aTopic))
     {
-      wizardShowCopyLogButton();
+      showCopyLogButton(true);
       return;
     }
 
@@ -296,20 +297,28 @@ function showPanel(aPanelID)
 
 function showErrorPanel()
 {
-    showPanel("errorPanel");
-    wizardShowCopyLogButton();
+  showPanel("errorPanel");
+  var haveErrorOrWarning = (gTorProcessService.TorBootstrapErrorOccurred ||
+                            gProtocolSvc.TorLogHasWarnOrErr)
+  showCopyLogButton(haveErrorOrWarning);
 }
 
 
-function wizardShowCopyLogButton()
+function showCopyLogButton(aHaveErrorOrWarning)
 {
-  if (getWizard())
+  var copyLogBtn = document.documentElement.getButton("extra2");
+  if (copyLogBtn)
   {
-    var copyLogBtn = document.documentElement.getButton("extra2");
-    if (copyLogBtn)
-    {
+    if (getWizard())
       copyLogBtn.setAttribute("wizardCanCopyLog", true);
-      copyLogBtn.removeAttribute("hidden");
+
+    copyLogBtn.removeAttribute("hidden");
+
+    if (aHaveErrorOrWarning)
+    {
+      var clz = copyLogBtn.getAttribute("class");
+      copyLogBtn.setAttribute("class", clz ? clz + " torWarning"
+                                           : "torWarning");
     }
   }
 }
diff --git a/src/chrome/content/progress.js b/src/chrome/content/progress.js
index 3a40dbf..6a826e0 100644
--- a/src/chrome/content/progress.js
+++ b/src/chrome/content/progress.js
@@ -9,6 +9,7 @@ const Cu = Components.utils;
 
 const kTorProcessExitedTopic = "TorProcessExited";
 const kBootstrapStatusTopic = "TorBootstrapStatus";
+const kTorLogHasWarnOrErrTopic = "TorLogHasWarnOrErr";
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "TorLauncherUtil",
@@ -26,6 +27,7 @@ function initDialog()
                   .getService(Ci.nsIObserverService);
     gObsSvc.addObserver(gObserver, kTorProcessExitedTopic, false);
     gObsSvc.addObserver(gObserver, kBootstrapStatusTopic, false);
+    gObsSvc.addObserver(gObserver, kTorLogHasWarnOrErrTopic, false);
   }
   catch (e) {}
 
@@ -68,6 +70,7 @@ function cleanup()
   {
     gObsSvc.removeObserver(gObserver, kTorProcessExitedTopic);
     gObsSvc.removeObserver(gObserver, kBootstrapStatusTopic);
+    gObsSvc.removeObserver(gObserver, kTorLogHasWarnOrErrTopic);
   }
 }
 
@@ -155,5 +158,13 @@ var gObserver = {
       if (labelText && desc)
         desc.textContent = labelText;
     }
+    else if (kTorLogHasWarnOrErrTopic == aTopic)
+    {
+      var extra2Btn = document.documentElement.getButton("extra2");
+      var clz = extra2Btn.getAttribute("class");
+      extra2Btn.setAttribute("class", clz ? clz + " torWarning" : "torWarning");
+
+      // TODO: show error / warning message in this dialog?
+    }
   },
 };
diff --git a/src/chrome/skin/network-settings.css b/src/chrome/skin/network-settings.css
index 4c51e4a..1d92151 100644
--- a/src/chrome/skin/network-settings.css
+++ b/src/chrome/skin/network-settings.css
@@ -128,3 +128,12 @@ dialog .help {
 {
   font-size: 120%;
 }
+
+.torWarning {
+  list-style-image: url("chrome://torlauncher/skin/warning.png");
+}
+
+/* Ensure that our caution icon is always shown on GTK-based platforms. */
+.torWarning .button-icon {
+  display: inline !important;
+}
diff --git a/src/chrome/skin/progress.css b/src/chrome/skin/progress.css
index 671870f..711a679 100644
--- a/src/chrome/skin/progress.css
+++ b/src/chrome/skin/progress.css
@@ -33,3 +33,12 @@ dialog {
 #progressMeter {
   margin-bottom: 16px;
 }
+
+.torWarning {
+  list-style-image: url("chrome://torlauncher/skin/warning.png");
+}
+
+/* Ensure that our caution icon is always shown on GTK-based platforms. */
+.torWarning .button-icon {
+  display: inline !important;
+}
diff --git a/src/chrome/skin/warning.png b/src/chrome/skin/warning.png
new file mode 100644
index 0000000..da90d1a
Binary files /dev/null and b/src/chrome/skin/warning.png differ

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits