mirror of
https://github.com/onionshare/onionshare.git
synced 2025-02-10 11:48:56 -05:00
#662 Allow local-only mode in GUI
This commit is contained in:
parent
b16c654e77
commit
46a9a2a0a1
@ -108,7 +108,7 @@ def main():
|
|||||||
app = OnionShare(onion, local_only, stay_open, shutdown_timeout)
|
app = OnionShare(onion, local_only, stay_open, shutdown_timeout)
|
||||||
|
|
||||||
# Launch the gui
|
# Launch the gui
|
||||||
gui = OnionShareGui(onion, qtapp, app, filenames, config)
|
gui = OnionShareGui(onion, qtapp, app, filenames, config, local_only)
|
||||||
|
|
||||||
# Clean up when app quits
|
# Clean up when app quits
|
||||||
def shutdown():
|
def shutdown():
|
||||||
|
@ -43,7 +43,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||||||
starting_server_step3 = QtCore.pyqtSignal()
|
starting_server_step3 = QtCore.pyqtSignal()
|
||||||
starting_server_error = QtCore.pyqtSignal(str)
|
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__()
|
super(OnionShareGui, self).__init__()
|
||||||
|
|
||||||
self._initSystemTray()
|
self._initSystemTray()
|
||||||
@ -53,6 +53,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||||||
self.onion = onion
|
self.onion = onion
|
||||||
self.qtapp = qtapp
|
self.qtapp = qtapp
|
||||||
self.app = app
|
self.app = app
|
||||||
|
self.local_only = local_only
|
||||||
|
|
||||||
self.setWindowTitle('OnionShare')
|
self.setWindowTitle('OnionShare')
|
||||||
self.setWindowIcon(QtGui.QIcon(common.get_resource_path('images/logo.png')))
|
self.setWindowIcon(QtGui.QIcon(common.get_resource_path('images/logo.png')))
|
||||||
@ -219,6 +220,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||||||
tor_con = TorConnectionDialog(self.qtapp, self.settings, self.onion)
|
tor_con = TorConnectionDialog(self.qtapp, self.settings, self.onion)
|
||||||
tor_con.canceled.connect(self._tor_connection_canceled)
|
tor_con.canceled.connect(self._tor_connection_canceled)
|
||||||
tor_con.open_settings.connect(self._tor_connection_open_settings)
|
tor_con.open_settings.connect(self._tor_connection_open_settings)
|
||||||
|
if not self.local_only:
|
||||||
tor_con.start()
|
tor_con.start()
|
||||||
|
|
||||||
# Start the timer
|
# Start the timer
|
||||||
@ -339,6 +341,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||||||
# We might've stopped the main requests timer if a Tor connection failed.
|
# 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
|
# If we've reloaded settings, we probably succeeded in obtaining a new
|
||||||
# connection. If so, restart the timer.
|
# connection. If so, restart the timer.
|
||||||
|
if not self.local_only:
|
||||||
if self.onion.is_authenticated():
|
if self.onion.is_authenticated():
|
||||||
if not self.timer.isActive():
|
if not self.timer.isActive():
|
||||||
self.timer.start(500)
|
self.timer.start(500)
|
||||||
@ -351,7 +354,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||||||
if not self.settings.get('shutdown_timeout'):
|
if not self.settings.get('shutdown_timeout'):
|
||||||
self.server_status.shutdown_timeout_container.hide()
|
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.settings_saved.connect(reload_settings)
|
||||||
d.exec_()
|
d.exec_()
|
||||||
|
|
||||||
@ -549,6 +552,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||||||
"""
|
"""
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
if not self.local_only:
|
||||||
# Have we lost connection to Tor somehow?
|
# Have we lost connection to Tor somehow?
|
||||||
if not self.onion.is_authenticated():
|
if not self.onion.is_authenticated():
|
||||||
self.timer.stop()
|
self.timer.stop()
|
||||||
|
@ -34,13 +34,14 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||||||
"""
|
"""
|
||||||
settings_saved = QtCore.pyqtSignal()
|
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__()
|
super(SettingsDialog, self).__init__()
|
||||||
common.log('SettingsDialog', '__init__')
|
common.log('SettingsDialog', '__init__')
|
||||||
|
|
||||||
self.onion = onion
|
self.onion = onion
|
||||||
self.qtapp = qtapp
|
self.qtapp = qtapp
|
||||||
self.config = config
|
self.config = config
|
||||||
|
self.local_only = local_only
|
||||||
|
|
||||||
self.setModal(True)
|
self.setModal(True)
|
||||||
self.setWindowTitle(strings._('gui_settings_window_title', True))
|
self.setWindowTitle(strings._('gui_settings_window_title', True))
|
||||||
@ -671,6 +672,7 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||||||
# If Tor isn't connected, or if Tor settings have changed, Reinitialize
|
# If Tor isn't connected, or if Tor settings have changed, Reinitialize
|
||||||
# the Onion object
|
# the Onion object
|
||||||
reboot_onion = False
|
reboot_onion = False
|
||||||
|
if not self.local_only:
|
||||||
if self.onion.is_authenticated():
|
if self.onion.is_authenticated():
|
||||||
common.log('SettingsDialog', 'save_clicked', 'Connected to Tor')
|
common.log('SettingsDialog', 'save_clicked', 'Connected to Tor')
|
||||||
def changed(s1, s2, keys):
|
def changed(s1, s2, keys):
|
||||||
@ -716,6 +718,9 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||||||
else:
|
else:
|
||||||
self.settings_saved.emit()
|
self.settings_saved.emit()
|
||||||
self.close()
|
self.close()
|
||||||
|
else:
|
||||||
|
self.settings_saved.emit()
|
||||||
|
self.close()
|
||||||
|
|
||||||
def cancel_clicked(self):
|
def cancel_clicked(self):
|
||||||
"""
|
"""
|
||||||
@ -856,6 +861,7 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||||||
common.log('SettingsDialog', 'closeEvent')
|
common.log('SettingsDialog', 'closeEvent')
|
||||||
|
|
||||||
# On close, if Tor isn't connected, then quit OnionShare altogether
|
# On close, if Tor isn't connected, then quit OnionShare altogether
|
||||||
|
if not self.local_only:
|
||||||
if not self.onion.is_authenticated():
|
if not self.onion.is_authenticated():
|
||||||
common.log('SettingsDialog', 'closeEvent', 'Closing while not connected to Tor')
|
common.log('SettingsDialog', 'closeEvent', 'Closing while not connected to Tor')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user