aboutsummaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2020-11-27 14:50:07 -0800
committerMicah Lee <micah@micahflee.com>2020-11-27 14:50:07 -0800
commit134611a3253cc61904c10a61d3434c7bed2d2975 (patch)
tree4f8cd057af197484f21abe6a3e109a65a30c6dfc /desktop
parent184f1261896855fcfadf09d36ade36dd9c275d57 (diff)
downloadonionshare-134611a3253cc61904c10a61d3434c7bed2d2975.tar.gz
onionshare-134611a3253cc61904c10a61d3434c7bed2d2975.zip
Show a dialog while waiting for Tor rendezvous nodes to close, and let the user quit early
Diffstat (limited to 'desktop')
-rw-r--r--desktop/src/onionshare/main_window.py26
-rw-r--r--desktop/src/onionshare/resources/locale/en.json4
-rw-r--r--desktop/src/onionshare/threads.py15
3 files changed, 43 insertions, 2 deletions
diff --git a/desktop/src/onionshare/main_window.py b/desktop/src/onionshare/main_window.py
index 5a099cbc..a1b44032 100644
--- a/desktop/src/onionshare/main_window.py
+++ b/desktop/src/onionshare/main_window.py
@@ -30,6 +30,7 @@ from .widgets import Alert
from .update_checker import UpdateThread
from .tab_widget import TabWidget
from .gui_common import GuiCommon
+from .threads import OnionCleanupThread
class MainWindow(QtWidgets.QMainWindow):
@@ -287,7 +288,30 @@ class MainWindow(QtWidgets.QMainWindow):
def cleanup(self):
self.common.log("MainWindow", "cleanup")
self.tabs.cleanup()
- self.common.gui.onion.cleanup()
+
+ alert = Alert(
+ self.common,
+ strings._("gui_rendezvous_cleanup"),
+ QtWidgets.QMessageBox.Information,
+ buttons=QtWidgets.QMessageBox.NoButton,
+ autostart=False,
+ )
+ quit_early_button = QtWidgets.QPushButton(
+ strings._("gui_rendezvous_cleanup_quit_early")
+ )
+ alert.addButton(quit_early_button, QtWidgets.QMessageBox.RejectRole)
+
+ self.onion_cleanup_thread = OnionCleanupThread(self.common)
+ self.onion_cleanup_thread.finished.connect(alert.accept)
+ self.onion_cleanup_thread.start()
+
+ alert.exec_()
+ if alert.clickedButton() == quit_early_button:
+ self.common.log("MainWindow", "cleanup", "quitting early")
+ if self.onion_cleanup_thread.isRunning():
+ self.onion_cleanup_thread.terminate()
+ self.onion_cleanup_thread.wait()
+ self.common.gui.onion.cleanup(wait=False)
# Wait 1 second for threads to close gracefully, so tests finally pass
time.sleep(1)
diff --git a/desktop/src/onionshare/resources/locale/en.json b/desktop/src/onionshare/resources/locale/en.json
index 1f98d7a7..aa34fd82 100644
--- a/desktop/src/onionshare/resources/locale/en.json
+++ b/desktop/src/onionshare/resources/locale/en.json
@@ -187,5 +187,7 @@
"settings_error_unreadable_cookie_file": "Connected to the Tor controller, but password may be wrong, or your user is not permitted to read the cookie file.",
"settings_error_bundled_tor_not_supported": "Using the Tor version that comes with OnionShare does not work in developer mode on Windows or macOS.",
"settings_error_bundled_tor_timeout": "Taking too long to connect to Tor. Maybe you aren't connected to the Internet, or have an inaccurate system clock?",
- "settings_error_bundled_tor_broken": "OnionShare could not connect to Tor:\n{}"
+ "settings_error_bundled_tor_broken": "OnionShare could not connect to Tor:\n{}",
+ "gui_rendezvous_cleanup": "Waiting for Tor rendezvous circuits to close to be sure that the files you shared downloaded successfully.\n\nThis might take a few minutes.",
+ "gui_rendezvous_cleanup_quit_early": "Quit Early"
} \ No newline at end of file
diff --git a/desktop/src/onionshare/threads.py b/desktop/src/onionshare/threads.py
index d5e2dc6c..22e264e5 100644
--- a/desktop/src/onionshare/threads.py
+++ b/desktop/src/onionshare/threads.py
@@ -252,3 +252,18 @@ class EventHandlerThread(QtCore.QThread):
if self.should_quit:
break
time.sleep(0.2)
+
+
+class OnionCleanupThread(QtCore.QThread):
+ """
+ Wait for Tor rendezvous circuits to close in a separate thread
+ """
+
+ def __init__(self, common):
+ super(OnionCleanupThread, self).__init__()
+ self.common = common
+ self.common.log("OnionCleanupThread", "__init__")
+
+ def run(self):
+ self.common.log("OnionCleanupThread", "run")
+ self.common.gui.onion.cleanup()