mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-15 09:17:25 -05:00
Add Tor connection status to the main window status bar
This commit is contained in:
parent
80d475f65b
commit
1fa88c3d07
@ -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)
|
||||
|
||||
|
@ -356,3 +356,4 @@ class Onion(object):
|
||||
# Stop tor process
|
||||
if self.tor_proc:
|
||||
self.tor_proc.terminate()
|
||||
self.tor_proc = None
|
||||
|
@ -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:
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user