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

[tor-commits] [torbutton/master] Bug #3649: Make permissions and disk errors human-readable.



commit f0f34bfdff94a64adc348a1b546e985be489107c
Author: Mike Perry <mikeperry-git@xxxxxxxxxx>
Date:   Fri Sep 9 15:04:31 2011 -0700

    Bug #3649: Make permissions and disk errors human-readable.
    
    Never write "this should never happen" in a comment. Doing so is apparently a
    an ancient voodoo curse that ensures that it does.
---
 src/chrome/content/torbutton.js           |   41 ++++++++++++++++++++++++----
 src/chrome/locale/en/torbutton.properties |    3 ++
 2 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 3998770..2e52830 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -402,10 +402,24 @@ function torbutton_set_status() {
         try {
             torbutton_update_status(true, false);
         } catch(e) {
-            // This should never happen.. 
-            // FIXME: Do we need to translate it? I'm guessing not.
-            window.alert("Torbutton: Please file bug report! Error applying Tor settings: "+e);
             torbutton_log(5,'Error applying tor settings: '+e);
+            var wm = Cc["@mozilla.org/appshell/window-mediator;1"]
+                .getService(Components.interfaces.nsIWindowMediator);
+            var chrome = wm.getMostRecentWindow("navigator:browser");
+            var o_stringbundle = torbutton_get_stringbundle();
+            var warning1 = o_stringbundle.GetStringFromName("torbutton.popup.pref_error");
+
+            if (e.result == 0x80520015 || e.result == 0x80520013) { // NS_ERROR_FILE_ACCESS_DENIED/NS_ERROR_FILE_READ_ONLY
+                var warning2 = o_stringbundle.GetStringFromName("torbutton.popup.permission_denied");
+                chrome.alert(warning1+"\n\n"+warning2);
+            } else if (e.result == 0x80520010) { // NS_ERROR_FILE_NO_DEVICE_SPACE
+                var o_stringbundle = torbutton_get_stringbundle();
+                var warning2 = o_stringbundle.GetStringFromName("torbutton.popup.device_full");
+                chrome.alert(warning1+"\n\n"+warning2);
+            } else {
+                // This should never happen.. 
+                chrome.alert(warning1+"\n\n"+e);
+            }
             // Setting these prefs should avoid ininite recursion
             // because torbutton_update_status should return immediately
             // on the next call.
@@ -419,10 +433,25 @@ function torbutton_set_status() {
         try {
             torbutton_update_status(false, false);
         } catch(e) {
-            // This should never happen.. 
-            // FIXME: Do we need to translate it? I'm guessing not.
-            window.alert("Torbutton: Please file bug report! Error applying Non-Tor settings: "+e);
             torbutton_log(5,'Error applying nontor settings: '+e);
+
+            var wm = Cc["@mozilla.org/appshell/window-mediator;1"]
+                .getService(Components.interfaces.nsIWindowMediator);
+            var chrome = wm.getMostRecentWindow("navigator:browser");
+            var o_stringbundle = torbutton_get_stringbundle();
+            var warning1 = o_stringbundle.GetStringFromName("torbutton.popup.pref_error");
+
+            if (e.result == 0x80520015 || e.result == 0x80520013) { // NS_ERROR_FILE_ACCESS_DENIED/NS_ERROR_FILE_READ_ONLY
+                var warning2 = o_stringbundle.GetStringFromName("torbutton.popup.permission_denied");
+                chrome.alert(warning1+"\n\n"+warning2);
+            } else if (e.result == 0x80520010) { // NS_ERROR_FILE_NO_DEVICE_SPACE
+                var o_stringbundle = torbutton_get_stringbundle();
+                var warning2 = o_stringbundle.GetStringFromName("torbutton.popup.device_full");
+                chrome.alert(warning1+"\n\n"+warning2);
+            } else {
+                // This should never happen.. 
+                chrome.alert(warning1+"\n\n"+e);
+            }
             // Setting these prefs should avoid infinite recursion
             // because torbutton_update_status should return immediately
             // on the next call.
diff --git a/src/chrome/locale/en/torbutton.properties b/src/chrome/locale/en/torbutton.properties
index c1aa1b6..773e8db 100644
--- a/src/chrome/locale/en/torbutton.properties
+++ b/src/chrome/locale/en/torbutton.properties
@@ -37,3 +37,6 @@ torbutton.popup.no_redirect = Don't Redirect
 torbutton.popup.prompted_language = To give you more privacy, Torbutton can request the English language version of web pages. This may cause web pages that you prefer to read in your native language to display in English instead.\n\nWould you like to request English language web pages for better privacy?
 torbutton.popup.no_newnym = Torbutton cannot safely give you a new identity. It does not have access to the Tor Control Port.\n\nAre you running Tor Browser Bundle?
 torbutton.popup.use_tbb = It appears that you are using Torbutton with Firefox, which is no longer a recommended safe configuration.\n\nInstead, we recommend that you obtain the latest Tor Browser Bundle by sending email to gettor@xxxxxxxxxxxxxx or by downloading it at the following URL: 
+torbutton.popup.pref_error = Torbutton cannot update preferences in the Tor Browser profile directory.
+torbutton.popup.permission_denied = Please either reset the permissions of the Tor Browser directory or copy it to a new location.
+torbutton.popup.device_full = The disk appears to be full. Please free up space or move Tor Browser to a new device.

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