mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Merge branch 'mig5-local_only_gui' into develop
This commit is contained in:
commit
bb39ef9a34
@ -108,7 +108,7 @@ def main():
|
||||
app = OnionShare(onion, local_only, stay_open, shutdown_timeout)
|
||||
|
||||
# Launch the gui
|
||||
gui = OnionShareGui(onion, qtapp, app, filenames, config)
|
||||
gui = OnionShareGui(onion, qtapp, app, filenames, config, local_only)
|
||||
|
||||
# Clean up when app quits
|
||||
def shutdown():
|
||||
|
@ -43,7 +43,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
starting_server_step3 = QtCore.pyqtSignal()
|
||||
starting_server_error = QtCore.pyqtSignal(str)
|
||||
|
||||
def __init__(self, onion, qtapp, app, filenames, config=False):
|
||||
def __init__(self, onion, qtapp, app, filenames, config=False, local_only=False):
|
||||
super(OnionShareGui, self).__init__()
|
||||
|
||||
self._initSystemTray()
|
||||
@ -53,6 +53,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
self.onion = onion
|
||||
self.qtapp = qtapp
|
||||
self.app = app
|
||||
self.local_only = local_only
|
||||
|
||||
self.setWindowTitle('OnionShare')
|
||||
self.setWindowIcon(QtGui.QIcon(common.get_resource_path('images/logo.png')))
|
||||
@ -218,7 +219,8 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
tor_con = TorConnectionDialog(self.qtapp, self.settings, self.onion)
|
||||
tor_con.canceled.connect(self._tor_connection_canceled)
|
||||
tor_con.open_settings.connect(self._tor_connection_open_settings)
|
||||
tor_con.start()
|
||||
if not self.local_only:
|
||||
tor_con.start()
|
||||
|
||||
# Start the timer
|
||||
self.timer.start(500)
|
||||
@ -338,19 +340,20 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
# We might've stopped the main requests timer if a Tor connection failed.
|
||||
# If we've reloaded settings, we probably succeeded in obtaining a new
|
||||
# connection. If so, restart the timer.
|
||||
if self.onion.is_authenticated():
|
||||
if not self.timer.isActive():
|
||||
self.timer.start(500)
|
||||
# If there were some files listed for sharing, we should be ok to
|
||||
# re-enable the 'Start Sharing' button now.
|
||||
if self.server_status.file_selection.get_num_files() > 0:
|
||||
self.server_status.server_button.setEnabled(True)
|
||||
self.status_bar.clearMessage()
|
||||
if not self.local_only:
|
||||
if self.onion.is_authenticated():
|
||||
if not self.timer.isActive():
|
||||
self.timer.start(500)
|
||||
# If there were some files listed for sharing, we should be ok to
|
||||
# re-enable the 'Start Sharing' button now.
|
||||
if self.server_status.file_selection.get_num_files() > 0:
|
||||
self.server_status.server_button.setEnabled(True)
|
||||
self.status_bar.clearMessage()
|
||||
# If we switched off the shutdown timeout setting, ensure the widget is hidden.
|
||||
if not self.settings.get('shutdown_timeout'):
|
||||
self.server_status.shutdown_timeout_container.hide()
|
||||
|
||||
d = SettingsDialog(self.onion, self.qtapp, self.config)
|
||||
d = SettingsDialog(self.onion, self.qtapp, self.config, self.local_only)
|
||||
d.settings_saved.connect(reload_settings)
|
||||
d.exec_()
|
||||
|
||||
@ -547,15 +550,16 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
"""
|
||||
self.update()
|
||||
|
||||
# Have we lost connection to Tor somehow?
|
||||
if not self.onion.is_authenticated():
|
||||
self.timer.stop()
|
||||
if self.server_status.status != self.server_status.STATUS_STOPPED:
|
||||
self.server_status.stop_server()
|
||||
self.server_status.server_button.setEnabled(False)
|
||||
self.status_bar.showMessage(strings._('gui_tor_connection_lost', True))
|
||||
if self.systemTray.supportsMessages() and self.settings.get('systray_notifications'):
|
||||
self.systemTray.showMessage(strings._('gui_tor_connection_lost', True), strings._('gui_tor_connection_error_settings', True))
|
||||
if not self.local_only:
|
||||
# Have we lost connection to Tor somehow?
|
||||
if not self.onion.is_authenticated():
|
||||
self.timer.stop()
|
||||
if self.server_status.status != self.server_status.STATUS_STOPPED:
|
||||
self.server_status.stop_server()
|
||||
self.server_status.server_button.setEnabled(False)
|
||||
self.status_bar.showMessage(strings._('gui_tor_connection_lost', True))
|
||||
if self.systemTray.supportsMessages() and self.settings.get('systray_notifications'):
|
||||
self.systemTray.showMessage(strings._('gui_tor_connection_lost', True), strings._('gui_tor_connection_error_settings', True))
|
||||
|
||||
# scroll to the bottom of the dl progress bar log pane
|
||||
# if a new download has been added
|
||||
|
@ -34,13 +34,14 @@ class SettingsDialog(QtWidgets.QDialog):
|
||||
"""
|
||||
settings_saved = QtCore.pyqtSignal()
|
||||
|
||||
def __init__(self, onion, qtapp, config=False):
|
||||
def __init__(self, onion, qtapp, config=False, local_only=False):
|
||||
super(SettingsDialog, self).__init__()
|
||||
common.log('SettingsDialog', '__init__')
|
||||
|
||||
self.onion = onion
|
||||
self.qtapp = qtapp
|
||||
self.config = config
|
||||
self.local_only = local_only
|
||||
|
||||
self.setModal(True)
|
||||
self.setWindowTitle(strings._('gui_settings_window_title', True))
|
||||
@ -677,48 +678,52 @@ class SettingsDialog(QtWidgets.QDialog):
|
||||
# If Tor isn't connected, or if Tor settings have changed, Reinitialize
|
||||
# the Onion object
|
||||
reboot_onion = False
|
||||
if self.onion.is_authenticated():
|
||||
common.log('SettingsDialog', 'save_clicked', 'Connected to Tor')
|
||||
def changed(s1, s2, keys):
|
||||
"""
|
||||
Compare the Settings objects s1 and s2 and return true if any values
|
||||
have changed for the given keys.
|
||||
"""
|
||||
for key in keys:
|
||||
if s1.get(key) != s2.get(key):
|
||||
return True
|
||||
return False
|
||||
if not self.local_only:
|
||||
if self.onion.is_authenticated():
|
||||
common.log('SettingsDialog', 'save_clicked', 'Connected to Tor')
|
||||
def changed(s1, s2, keys):
|
||||
"""
|
||||
Compare the Settings objects s1 and s2 and return true if any values
|
||||
have changed for the given keys.
|
||||
"""
|
||||
for key in keys:
|
||||
if s1.get(key) != s2.get(key):
|
||||
return True
|
||||
return False
|
||||
|
||||
if changed(settings, self.old_settings, [
|
||||
'connection_type', 'control_port_address',
|
||||
'control_port_port', 'socks_address', 'socks_port',
|
||||
'socket_file_path', 'auth_type', 'auth_password',
|
||||
'no_bridges', 'tor_bridges_use_obfs4',
|
||||
'tor_bridges_use_meek_lite_amazon', 'tor_bridges_use_meek_lite_azure',
|
||||
'tor_bridges_use_custom_bridges']):
|
||||
if changed(settings, self.old_settings, [
|
||||
'connection_type', 'control_port_address',
|
||||
'control_port_port', 'socks_address', 'socks_port',
|
||||
'socket_file_path', 'auth_type', 'auth_password',
|
||||
'no_bridges', 'tor_bridges_use_obfs4',
|
||||
'tor_bridges_use_meek_lite_amazon', 'tor_bridges_use_meek_lite_azure',
|
||||
'tor_bridges_use_custom_bridges']):
|
||||
|
||||
reboot_onion = True
|
||||
|
||||
else:
|
||||
common.log('SettingsDialog', 'save_clicked', 'Not connected to Tor')
|
||||
# Tor isn't connected, so try connecting
|
||||
reboot_onion = True
|
||||
|
||||
else:
|
||||
common.log('SettingsDialog', 'save_clicked', 'Not connected to Tor')
|
||||
# Tor isn't connected, so try connecting
|
||||
reboot_onion = True
|
||||
# Do we need to reinitialize Tor?
|
||||
if reboot_onion:
|
||||
# Reinitialize the Onion object
|
||||
common.log('SettingsDialog', 'save_clicked', 'rebooting the Onion')
|
||||
self.onion.cleanup()
|
||||
|
||||
# Do we need to reinitialize Tor?
|
||||
if reboot_onion:
|
||||
# Reinitialize the Onion object
|
||||
common.log('SettingsDialog', 'save_clicked', 'rebooting the Onion')
|
||||
self.onion.cleanup()
|
||||
tor_con = TorConnectionDialog(self.qtapp, settings, self.onion)
|
||||
tor_con.start()
|
||||
|
||||
tor_con = TorConnectionDialog(self.qtapp, settings, self.onion)
|
||||
tor_con.start()
|
||||
common.log('SettingsDialog', 'save_clicked', 'Onion done rebooting, connected to Tor: {}'.format(self.onion.connected_to_tor))
|
||||
|
||||
common.log('SettingsDialog', 'save_clicked', 'Onion done rebooting, connected to Tor: {}'.format(self.onion.connected_to_tor))
|
||||
if self.onion.is_authenticated() and not tor_con.wasCanceled():
|
||||
self.settings_saved.emit()
|
||||
self.close()
|
||||
|
||||
if self.onion.is_authenticated() and not tor_con.wasCanceled():
|
||||
else:
|
||||
self.settings_saved.emit()
|
||||
self.close()
|
||||
|
||||
else:
|
||||
self.settings_saved.emit()
|
||||
self.close()
|
||||
@ -862,11 +867,12 @@ class SettingsDialog(QtWidgets.QDialog):
|
||||
common.log('SettingsDialog', 'closeEvent')
|
||||
|
||||
# On close, if Tor isn't connected, then quit OnionShare altogether
|
||||
if not self.onion.is_authenticated():
|
||||
common.log('SettingsDialog', 'closeEvent', 'Closing while not connected to Tor')
|
||||
if not self.local_only:
|
||||
if not self.onion.is_authenticated():
|
||||
common.log('SettingsDialog', 'closeEvent', 'Closing while not connected to Tor')
|
||||
|
||||
# Wait 1ms for the event loop to finish, then quit
|
||||
QtCore.QTimer.singleShot(1, self.qtapp.quit)
|
||||
# Wait 1ms for the event loop to finish, then quit
|
||||
QtCore.QTimer.singleShot(1, self.qtapp.quit)
|
||||
|
||||
def _update_autoupdate_timestamp(self, autoupdate_timestamp):
|
||||
common.log('SettingsDialog', '_update_autoupdate_timestamp')
|
||||
|
Loading…
Reference in New Issue
Block a user