mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-28 00:39:37 -05:00
Made automatic check for update in a separate thread work
This commit is contained in:
parent
da70c71d8a
commit
dff13d9568
@ -64,7 +64,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, qtapp, app):
|
def __init__(self, qtapp, app, filenames):
|
||||||
super(OnionShareGui, self).__init__()
|
super(OnionShareGui, self).__init__()
|
||||||
self.qtapp = qtapp
|
self.qtapp = qtapp
|
||||||
self.app = app
|
self.app = app
|
||||||
@ -81,23 +81,20 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||||||
settings = Settings()
|
settings = Settings()
|
||||||
settings.load()
|
settings.load()
|
||||||
if settings.get('use_autoupdate'):
|
if settings.get('use_autoupdate'):
|
||||||
# TODO: make updates actually work
|
def update_available(update_url, installed_version, latest_version):
|
||||||
print("Updating in another thread")
|
Alert(strings._("update_available", True).format(update_url, installed_version, latest_version))
|
||||||
#t = UpdateThread()
|
|
||||||
#t.start()
|
|
||||||
|
|
||||||
def send_files(self, filenames=None):
|
t = UpdateThread()
|
||||||
"""
|
t.update_available.connect(update_available)
|
||||||
Build the GUI in send files mode.
|
t.start()
|
||||||
Note that this is the only mode currently implemented.
|
|
||||||
"""
|
# File selection
|
||||||
# file selection
|
|
||||||
self.file_selection = FileSelection()
|
self.file_selection = FileSelection()
|
||||||
if filenames:
|
if filenames:
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
self.file_selection.file_list.add_file(filename)
|
self.file_selection.file_list.add_file(filename)
|
||||||
|
|
||||||
# server status
|
# Server status
|
||||||
self.server_status = ServerStatus(self.qtapp, self.app, web, self.file_selection)
|
self.server_status = ServerStatus(self.qtapp, self.app, web, self.file_selection)
|
||||||
self.server_status.server_started.connect(self.file_selection.server_started)
|
self.server_status.server_started.connect(self.file_selection.server_started)
|
||||||
self.server_status.server_started.connect(self.start_server)
|
self.server_status.server_started.connect(self.start_server)
|
||||||
@ -113,12 +110,12 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||||||
self.starting_server_step3.connect(self.start_server_step3)
|
self.starting_server_step3.connect(self.start_server_step3)
|
||||||
self.starting_server_error.connect(self.start_server_error)
|
self.starting_server_error.connect(self.start_server_error)
|
||||||
|
|
||||||
# filesize warning
|
# Filesize warning
|
||||||
self.filesize_warning = QtWidgets.QLabel()
|
self.filesize_warning = QtWidgets.QLabel()
|
||||||
self.filesize_warning.setStyleSheet('padding: 10px 0; font-weight: bold; color: #333333;')
|
self.filesize_warning.setStyleSheet('padding: 10px 0; font-weight: bold; color: #333333;')
|
||||||
self.filesize_warning.hide()
|
self.filesize_warning.hide()
|
||||||
|
|
||||||
# downloads
|
# Downloads
|
||||||
self.downloads = Downloads()
|
self.downloads = Downloads()
|
||||||
self.downloads_container = QtWidgets.QScrollArea()
|
self.downloads_container = QtWidgets.QScrollArea()
|
||||||
self.downloads_container.setWidget(self.downloads)
|
self.downloads_container.setWidget(self.downloads)
|
||||||
@ -128,7 +125,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||||||
self.downloads_container.hide() # downloads start out hidden
|
self.downloads_container.hide() # downloads start out hidden
|
||||||
self.new_download = False
|
self.new_download = False
|
||||||
|
|
||||||
# status bar
|
# Status bar
|
||||||
self.status_bar = QtWidgets.QStatusBar()
|
self.status_bar = QtWidgets.QStatusBar()
|
||||||
self.status_bar.setSizeGripEnabled(False)
|
self.status_bar.setSizeGripEnabled(False)
|
||||||
version_label = QtWidgets.QLabel('v{0:s}'.format(helpers.get_version()))
|
version_label = QtWidgets.QLabel('v{0:s}'.format(helpers.get_version()))
|
||||||
@ -136,10 +133,10 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||||||
self.status_bar.addPermanentWidget(version_label)
|
self.status_bar.addPermanentWidget(version_label)
|
||||||
self.setStatusBar(self.status_bar)
|
self.setStatusBar(self.status_bar)
|
||||||
|
|
||||||
# status bar, zip progress bar
|
# Status bar, zip progress bar
|
||||||
self._zip_progress_bar = None
|
self._zip_progress_bar = None
|
||||||
|
|
||||||
# main layout
|
# Main layout
|
||||||
self.layout = QtWidgets.QVBoxLayout()
|
self.layout = QtWidgets.QVBoxLayout()
|
||||||
self.layout.addLayout(self.file_selection)
|
self.layout.addLayout(self.file_selection)
|
||||||
self.layout.addLayout(self.server_status)
|
self.layout.addLayout(self.server_status)
|
||||||
@ -461,8 +458,7 @@ def main():
|
|||||||
qtapp.aboutToQuit.connect(shutdown)
|
qtapp.aboutToQuit.connect(shutdown)
|
||||||
|
|
||||||
# launch the gui
|
# launch the gui
|
||||||
gui = OnionShareGui(qtapp, app)
|
gui = OnionShareGui(qtapp, app, filenames)
|
||||||
gui.send_files(filenames)
|
|
||||||
|
|
||||||
# all done
|
# all done
|
||||||
sys.exit(qtapp.exec_())
|
sys.exit(qtapp.exec_())
|
||||||
|
@ -24,7 +24,6 @@ from onionshare.settings import Settings
|
|||||||
from onionshare.onion import Onion
|
from onionshare.onion import Onion
|
||||||
|
|
||||||
from . import strings, helpers
|
from . import strings, helpers
|
||||||
from .alert import Alert
|
|
||||||
|
|
||||||
class UpdateCheckerTorError(Exception):
|
class UpdateCheckerTorError(Exception):
|
||||||
"""
|
"""
|
||||||
@ -149,17 +148,24 @@ class UpdateChecker(QtCore.QObject):
|
|||||||
self.tor_status_update.emit(message)
|
self.tor_status_update.emit(message)
|
||||||
|
|
||||||
class UpdateThread(QtCore.QThread):
|
class UpdateThread(QtCore.QThread):
|
||||||
|
update_available = QtCore.pyqtSignal(str, str, str)
|
||||||
|
tor_status_update = QtCore.pyqtSignal(str)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(UpdateThread, self).__init__()
|
super(UpdateThread, self).__init__()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
u = UpdateChecker()
|
u = UpdateChecker()
|
||||||
u.update_available.connect(self.update_available)
|
u.update_available.connect(self._update_available)
|
||||||
|
u.tor_status_update.connect(self._tor_status_update)
|
||||||
try:
|
try:
|
||||||
u.check()
|
u.check()
|
||||||
except:
|
except:
|
||||||
# If update check fails, silently ignore
|
# If update check fails, silently ignore
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def update_available(update_url, installed_version, latest_version):
|
def _update_available(self, update_url, installed_version, latest_version):
|
||||||
Alert(strings._("update_available", True).format(update_url, installed_version, latest_version))
|
self.update_available.emit(update_url, installed_version, latest_version)
|
||||||
|
|
||||||
|
def _tor_status_update(self, message):
|
||||||
|
self.tor_status_update.emit(message)
|
||||||
|
Loading…
Reference in New Issue
Block a user