[Pkg-privacy-commits] [onionshare] 158/256: Made clicking Exit in the TorConnectionDialog exit the app

Ulrike Uhlig ulrike at moszumanska.debian.org
Fri May 26 12:53:32 UTC 2017


This is an automated email from the git hooks/post-receive script.

ulrike pushed a commit to branch master
in repository onionshare.

commit bcf2e518ded509ada984750b945bcd65a001f2be
Author: Micah Lee <micah at micahflee.com>
Date:   Mon Apr 17 20:49:50 2017 -0700

    Made clicking Exit in the TorConnectionDialog exit the app
---
 onionshare_gui/__init__.py              | 10 +++++++++-
 onionshare_gui/tor_connection_dialog.py | 23 +++++++++++------------
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/onionshare_gui/__init__.py b/onionshare_gui/__init__.py
index e59c6cf..8a8b955 100644
--- a/onionshare_gui/__init__.py
+++ b/onionshare_gui/__init__.py
@@ -22,7 +22,7 @@ import os, sys, platform, argparse
 from PyQt5 import QtCore, QtWidgets
 
 from onionshare import strings, helpers, web
-from onionshare.onion import *
+from onionshare.onion import Onion
 from onionshare.onionshare import OnionShare
 from onionshare.settings import Settings
 
@@ -93,7 +93,15 @@ def main():
 
     # Start the Onion
     onion = Onion()
+
+    def exit_early():
+        # Wait for tor to exit
+        onion.cleanup()
+        sys.exit()
+
     tor_con = TorConnectionDialog(settings, onion)
+    tor_con.canceled.connect(exit_early)
+    tor_con.start()
 
     # Start the OnionShare app
     web.set_stay_open(stay_open)
diff --git a/onionshare_gui/tor_connection_dialog.py b/onionshare_gui/tor_connection_dialog.py
index 734d2f5..8c23f3c 100644
--- a/onionshare_gui/tor_connection_dialog.py
+++ b/onionshare_gui/tor_connection_dialog.py
@@ -20,6 +20,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 from PyQt5 import QtCore, QtWidgets, QtGui
 
 from onionshare import strings, helpers
+from onionshare.onion import *
 
 class TorConnectionDialog(QtWidgets.QProgressDialog):
     """
@@ -28,6 +29,7 @@ class TorConnectionDialog(QtWidgets.QProgressDialog):
     def __init__(self, settings, onion):
         super(TorConnectionDialog, self).__init__(None)
         self.settings = settings
+        self.onion = onion
 
         self.setWindowTitle("OnionShare")
         self.setWindowIcon(QtGui.QIcon(helpers.get_resource_path('images/logo.png')))
@@ -39,11 +41,12 @@ class TorConnectionDialog(QtWidgets.QProgressDialog):
 
         # Progress bar ticks from 0 to 100
         self.setRange(0, 100)
-        # Don't show if connection takes less than 200ms (for non-bundled tor)
-        self.setMinimumDuration(200)
+        # Don't show if connection takes less than 100ms (for non-bundled tor)
+        self.setMinimumDuration(100)
 
+    def start(self):
         # If bundled tor, prepare to display Tor connection status
-        if settings.get('connection_type') == 'bundled':
+        if self.settings.get('connection_type') == 'bundled':
             tor_status_update = self.tor_status_update
         else:
             tor_status_update = None
@@ -51,18 +54,14 @@ class TorConnectionDialog(QtWidgets.QProgressDialog):
         # Connect to the Onion
         self.setValue(0)
         try:
-            onion.connect(self.settings, tor_status_update)
-        except (TorTooOld, TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError, BundledTorNotSupported, BundledTorTimeout) as e:
+            self.onion.connect(self.settings, tor_status_update)
+        except BundledTorCanceled as e:
+            self.close()
+        except Exception as e:
             print(e.args[0])
             # TODO: Open settings to connect to Tor properly
             sys.exit()
 
-        self.exec_()
-
     def tor_status_update(self, progress, summary):
-        if summary == 'Done':
-            # All done
-            self.close()
-        else:
-            self.setValue(int(progress))
+        self.setValue(int(progress))
         self.setLabelText("<strong>{}</strong><br>{}".format(strings._('connecting_to_tor', True), summary))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git



More information about the Pkg-privacy-commits mailing list