Allow canceling share in Windows

This commit is contained in:
Micah Lee 2021-05-31 10:01:10 -07:00
parent 64c7f4e5b8
commit ead2825327
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
3 changed files with 37 additions and 8 deletions

View File

@ -33,7 +33,8 @@
"gui_show_url_qr_code": "Show QR Code",
"gui_qr_code_dialog_title": "OnionShare QR Code",
"gui_waiting_to_start": "Scheduled to start in {}. Click to cancel.",
"gui_please_wait": "Starting…",
"gui_please_wait_no_button": "Starting…",
"gui_please_wait": "Starting… Click to cancel.",
"error_rate_limit": "Someone has made too many wrong attempts to guess your password, so OnionShare has stopped the server. Start sharing again and send the recipient a new address to share.",
"zip_progress_bar_format": "Compressing: %p%",
"gui_settings_window_title": "Settings",
@ -202,4 +203,4 @@
"error_port_not_available": "OnionShare port not available",
"history_receive_read_message_button": "Read Message",
"error_tor_protocol_error": "There was an error with Tor: {}"
}
}

View File

@ -158,9 +158,16 @@ class Mode(QtWidgets.QWidget):
)
)
else:
self.server_status.server_button.setText(
strings._("gui_please_wait")
)
if self.common.platform == "Windows" or self.settings.get(
"general", "autostart_timer"
):
self.server_status.server_button.setText(
strings._("gui_please_wait")
)
else:
self.server_status.server_button.setText(
strings._("gui_please_wait_no_button")
)
# If the auto-stop timer has stopped, stop the server
if self.server_status.status == ServerStatus.STATUS_STARTED:
@ -354,6 +361,19 @@ class Mode(QtWidgets.QWidget):
self.app.onion.scheduled_key = None
self.app.onion.scheduled_auth_cookie = None
self.startup_thread.quit()
# Canceling only works in Windows
# https://github.com/micahflee/onionshare/issues/1371
if self.common.platform == "Windows":
if self.onion_thread:
self.common.log("Mode", "cancel_server: quitting onion thread")
self.onion_thread.terminate()
self.onion_thread.wait()
if self.web_thread:
self.common.log("Mode", "cancel_server: quitting web thread")
self.web_thread.terminate()
self.web_thread.wait()
self.stop_server()
def cancel_server_custom(self):

View File

@ -306,13 +306,18 @@ class ServerStatus(QtWidgets.QWidget):
)
)
else:
self.server_button.setText(strings._("gui_please_wait"))
if self.common.platform == "Windows":
self.server_button.setText(strings._("gui_please_wait"))
else:
self.server_button.setText(
strings._("gui_please_wait_no_button")
)
else:
self.server_button.setStyleSheet(
self.common.gui.css["server_status_button_working"]
)
self.server_button.setEnabled(False)
self.server_button.setText(strings._("gui_please_wait"))
self.server_button.setText(strings._("gui_please_wait_no_button"))
def server_button_clicked(self):
"""
@ -379,7 +384,10 @@ class ServerStatus(QtWidgets.QWidget):
self.start_server()
elif self.status == self.STATUS_STARTED:
self.stop_server()
elif self.status == self.STATUS_WORKING and self.settings.get("general", "autostart_timer"):
elif self.status == self.STATUS_WORKING and (
self.common.platform == "Windows"
or self.settings.get("general", "autostart_timer")
):
self.cancel_server()
self.button_clicked.emit()