warns about sending large files in GUI (#123)

This commit is contained in:
Micah Lee 2014-09-18 01:35:30 +00:00
parent 5b9176c9d4
commit 4f6cff6503
6 changed files with 19 additions and 6 deletions

View file

@ -239,9 +239,9 @@ def main():
app.cleanup_filenames.append(web.zip_filename)
# warn about sending large files over Tor
if web.zip_filesize >= 209715200: # 200mb
if web.zip_filesize >= 157286400: # 150mb
print ''
print strings._("large_filesize").format(helpers.human_readable_filesize(web.zip_filesize))
print strings._("large_filesize")
print ''
# start onionshare service in new thread

View file

@ -18,7 +18,7 @@
"close_on_finish": "Stop server automatically",
"choose_file": "Choose a file to share",
"closing_automatically": "Closing automatically because download finished",
"large_filesize": "You are sending a total of {0}. Transferring large files using OnionShare might take hours.",
"large_filesize": "Warning: Sending large files could take hours",
"error_tails_invalid_port": "Invalid value, port must be an integer",
"error_tails_unknown_root": "Unknown error with Tails root process",
"help_tails_port": "Tails only: port for opening firewall, starting hidden service",

View file

@ -25,7 +25,6 @@ from onionshare import strings, helpers
class Downloads(QtGui.QVBoxLayout):
def __init__(self):
super(Downloads, self).__init__()
self.addSpacing(10)
self.progress_bars = {}

View file

@ -45,6 +45,7 @@ class Application(QtGui.QApplication):
class OnionShareGui(QtGui.QWidget):
start_server_finished = QtCore.pyqtSignal()
stop_server_finished = QtCore.pyqtSignal()
server_starting = QtCore.pyqtSignal()
def __init__(self, qtapp, app):
super(OnionShareGui, self).__init__()
@ -73,6 +74,12 @@ class OnionShareGui(QtGui.QWidget):
self.file_selection.file_list.files_updated.connect(self.server_status.update)
self.server_status.url_copied.connect(self.copy_url)
# filesize warning
self.filesize_warning = QtGui.QLabel()
self.filesize_warning.setStyleSheet('padding: 10px 0; font-weight: bold; color: #333333;')
self.filesize_warning.hide()
self.server_starting.connect(self.server_start_update)
# downloads
self.downloads = Downloads()
@ -87,6 +94,7 @@ class OnionShareGui(QtGui.QWidget):
self.layout = QtGui.QVBoxLayout()
self.layout.addLayout(self.file_selection)
self.layout.addLayout(self.server_status)
self.layout.addWidget(self.filesize_warning)
self.layout.addLayout(self.downloads)
self.layout.addLayout(self.options)
self.layout.addWidget(self.status_bar)
@ -98,6 +106,12 @@ class OnionShareGui(QtGui.QWidget):
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.check_for_requests)
self.timer.start(500)
def server_start_update(self):
# warn about sending large files over Tor
if web.zip_filesize >= 157286400: # 150mb
self.filesize_warning.setText(strings._("large_filesize", True))
self.filesize_warning.show()
def start_server(self):
# start the hidden service
self.status_bar.showMessage(strings._('gui_starting_server', True).format(self.app.port))
@ -126,6 +140,7 @@ class OnionShareGui(QtGui.QWidget):
# prepare files to share
web.set_file_info(self.file_selection.file_list.filenames)
self.app.cleanup_filenames.append(web.zip_filename)
self.server_starting.emit()
# wait for hs
self.app.wait_for_hs()
@ -141,6 +156,7 @@ class OnionShareGui(QtGui.QWidget):
if self.server_status.status == self.server_status.STATUS_STARTED:
web.stop(self.app.port)
self.app.cleanup()
self.filesize_warning.hide()
self.stop_server_finished.emit()
def check_for_requests(self):

View file

@ -25,7 +25,6 @@ from onionshare import strings, helpers
class Options(QtGui.QHBoxLayout):
def __init__(self, web):
super(Options, self).__init__()
self.addSpacing(10)
self.web = web

View file

@ -35,7 +35,6 @@ class ServerStatus(QtGui.QVBoxLayout):
def __init__(self, qtapp, app, web, file_selection):
super(ServerStatus, self).__init__()
self.status = self.STATUS_STOPPED
self.addSpacing(10)
self.qtapp = qtapp
self.app = app