Add Tor connection status to the main window status bar

This commit is contained in:
Micah Lee 2017-04-13 23:08:25 -07:00
parent 80d475f65b
commit 1fa88c3d07
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
4 changed files with 16 additions and 6 deletions

View File

@ -73,7 +73,7 @@ class OnionShare(object):
self.port = tmpsock.getsockname()[1]
tmpsock.close()
def start_onion_service(self):
def start_onion_service(self, bundled_tor_func=None):
"""
Start the onionshare onion service.
"""
@ -85,7 +85,7 @@ class OnionShare(object):
return
if not self.onion:
self.onion = Onion(self.stealth)
self.onion = Onion(self.stealth, bundled_tor_func=bundled_tor_func)
self.onion_host = self.onion.start(self.port)

View File

@ -356,3 +356,4 @@ class Onion(object):
# Stop tor process
if self.tor_proc:
self.tor_proc.terminate()
self.tor_proc = None

View File

@ -171,9 +171,18 @@ class OnionShareGui(QtWidgets.QMainWindow):
# start the onion service in a new thread
def start_onion_service(self):
self.status_bar.showMessage(strings._('gui_starting_server1', True))
try:
self.app.start_onion_service()
# Show Tor connection status if connection type is bundled tor
if settings.get('connection_type') == 'bundled':
def bundled_tor_func(message):
self.status_bar.showMessage(message)
if 'Done' in message:
self.status_bar.showMessage(strings._('gui_starting_server1', True))
else:
self.status_bar.showMessage(strings._('gui_starting_server1', True))
bundled_tor_func = None
self.app.start_onion_service(bundled_tor_func)
self.starting_server_step2.emit()
except (onionshare.onion.TorTooOld, onionshare.onion.TorErrorInvalidSetting, onionshare.onion.TorErrorAutomatic, onionshare.onion.TorErrorSocketPort, onionshare.onion.TorErrorSocketFile, onionshare.onion.TorErrorMissingPassword, onionshare.onion.TorErrorUnreadableCookieFile, onionshare.onion.TorErrorAuthError, onionshare.onion.TorErrorProtocolError) as e:

View File

@ -286,14 +286,14 @@ class SettingsDialog(QtWidgets.QDialog):
settings = self.settings_from_fields()
try:
# Create dialog for showing Tor connection status
# Show Tor connection status if connection type is bundled tor
if settings.get('connection_type') == 'bundled':
self.tor_status.show()
self.test_button.setEnabled(False)
self.save_button.setEnabled(False)
self.cancel_button.setEnabled(False)
def bundled_tor_func(message):
self.tor_status.setText('<strong>{}</strong><br>{}'.format(strings._('connecting_to_tor'), message))
self.tor_status.setText('<strong>{}</strong><br>{}'.format(strings._('connecting_to_tor', True), message))
self.qtapp.processEvents()
if 'Done' in message:
self.tor_status.hide()