Merge branch 'develop' into 866_receive_mode_crash

This commit is contained in:
Micah Lee 2019-01-20 15:42:09 -08:00
commit 0ef0659e2f
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
24 changed files with 161 additions and 176 deletions

View File

@ -175,7 +175,7 @@ def main(cwd=None):
print('') print('')
if mode == 'receive': if mode == 'receive':
print(strings._('receive_mode_downloads_dir').format(common.settings.get('downloads_dir'))) print(strings._('receive_mode_data_dir').format(common.settings.get('data_dir')))
print('') print('')
print(strings._('receive_mode_warning')) print(strings._('receive_mode_warning'))
print('') print('')

View File

@ -100,7 +100,7 @@ class Settings(object):
'public_mode': False, 'public_mode': False,
'slug': '', 'slug': '',
'hidservauth_string': '', 'hidservauth_string': '',
'downloads_dir': self.build_default_downloads_dir(), 'data_dir': self.build_default_data_dir(),
'locale': None # this gets defined in fill_in_defaults() 'locale': None # this gets defined in fill_in_defaults()
} }
self._settings = {} self._settings = {}
@ -140,7 +140,7 @@ class Settings(object):
""" """
return os.path.join(self.common.build_data_dir(), 'onionshare.json') return os.path.join(self.common.build_data_dir(), 'onionshare.json')
def build_default_downloads_dir(self): def build_default_data_dir(self):
""" """
Returns the path of the default Downloads directory for receive mode. Returns the path of the default Downloads directory for receive mode.
""" """
@ -174,9 +174,9 @@ class Settings(object):
except: except:
pass pass
# Make sure downloads_dir exists # Make sure data_dir exists
try: try:
os.makedirs(self.get('downloads_dir'), exist_ok=True) os.makedirs(self.get('data_dir'), exist_ok=True)
except: except:
pass pass

View File

@ -64,7 +64,7 @@ class ReceiveModeWeb(object):
now = datetime.now() now = datetime.now()
date_dir = now.strftime("%Y-%m-%d") date_dir = now.strftime("%Y-%m-%d")
time_dir = now.strftime("%H.%M.%S") time_dir = now.strftime("%H.%M.%S")
receive_mode_dir = os.path.join(self.common.settings.get('downloads_dir'), date_dir, time_dir) receive_mode_dir = os.path.join(self.common.settings.get('data_dir'), date_dir, time_dir)
files = request.files.getlist('file[]') files = request.files.getlist('file[]')
filenames = [] filenames = []

View File

@ -35,12 +35,11 @@ class Web(object):
REQUEST_OTHER = 3 REQUEST_OTHER = 3
REQUEST_CANCELED = 4 REQUEST_CANCELED = 4
REQUEST_RATE_LIMIT = 5 REQUEST_RATE_LIMIT = 5
REQUEST_CLOSE_SERVER = 6 REQUEST_UPLOAD_FILE_RENAMED = 6
REQUEST_UPLOAD_FILE_RENAMED = 7 REQUEST_UPLOAD_SET_DIR = 7
REQUEST_UPLOAD_SET_DIR = 8 REQUEST_UPLOAD_FINISHED = 8
REQUEST_UPLOAD_FINISHED = 9 REQUEST_UPLOAD_CANCELED = 9
REQUEST_UPLOAD_CANCELED = 10 REQUEST_ERROR_DATA_DIR_CANNOT_CREATE = 10
REQUEST_ERROR_DOWNLOADS_DIR_CANNOT_CREATE = 11
def __init__(self, common, is_gui, mode='share'): def __init__(self, common, is_gui, mode='share'):
self.common = common self.common = common

View File

@ -312,12 +312,6 @@ class Mode(QtWidgets.QWidget):
""" """
pass pass
def handle_request_close_server(self, event):
"""
Handle REQUEST_CLOSE_SERVER event.
"""
pass
def handle_request_upload_file_renamed(self, event): def handle_request_upload_file_renamed(self, event):
""" """
Handle REQUEST_UPLOAD_FILE_RENAMED event. Handle REQUEST_UPLOAD_FILE_RENAMED event.

View File

@ -40,13 +40,36 @@ class HistoryItem(QtWidgets.QWidget):
def cancel(self): def cancel(self):
pass pass
def get_finished_label_text(self, started):
"""
When an item finishes, returns a string displaying the start/end datetime range.
started is a datetime object.
"""
ended = datetime.now()
if started.year == ended.year and started.month == ended.month and started.day == ended.day:
if started.hour == ended.hour and started.minute == ended.minute:
text = strings._('gui_all_modes_transfer_finished').format(
started.strftime("%b %d, %I:%M%p")
)
else:
text = strings._('gui_all_modes_transfer_finished_range').format(
started.strftime("%b %d, %I:%M%p"),
ended.strftime("%I:%M%p")
)
else:
text = strings._('gui_all_modes_transfer_finished_range').format(
started.strftime("%b %d, %I:%M%p"),
ended.strftime("%b %d, %I:%M%p")
)
return text
class DownloadHistoryItem(HistoryItem):
class ShareHistoryItem(HistoryItem):
""" """
Download history item, for share mode Download history item, for share mode
""" """
def __init__(self, common, id, total_bytes): def __init__(self, common, id, total_bytes):
super(DownloadHistoryItem, self).__init__() super(ShareHistoryItem, self).__init__()
self.common = common self.common = common
self.id = id self.id = id
@ -56,7 +79,7 @@ class DownloadHistoryItem(HistoryItem):
self.started_dt = datetime.fromtimestamp(self.started) self.started_dt = datetime.fromtimestamp(self.started)
# Label # Label
self.label = QtWidgets.QLabel(strings._('gui_download_in_progress').format(self.started_dt.strftime("%b %d, %I:%M%p"))) self.label = QtWidgets.QLabel(strings._('gui_all_modes_transfer_started').format(self.started_dt.strftime("%b %d, %I:%M%p")))
# Progress bar # Progress bar
self.progress_bar = QtWidgets.QProgressBar() self.progress_bar = QtWidgets.QProgressBar()
@ -83,18 +106,22 @@ class DownloadHistoryItem(HistoryItem):
self.progress_bar.setValue(downloaded_bytes) self.progress_bar.setValue(downloaded_bytes)
if downloaded_bytes == self.progress_bar.total_bytes: if downloaded_bytes == self.progress_bar.total_bytes:
pb_fmt = strings._('gui_download_upload_progress_complete').format( pb_fmt = strings._('gui_all_modes_progress_complete').format(
self.common.format_seconds(time.time() - self.started)) self.common.format_seconds(time.time() - self.started))
# Change the label
self.label.setText(self.get_finished_label_text(self.started_dt))
else: else:
elapsed = time.time() - self.started elapsed = time.time() - self.started
if elapsed < 10: if elapsed < 10:
# Wait a couple of seconds for the download rate to stabilize. # Wait a couple of seconds for the download rate to stabilize.
# This prevents a "Windows copy dialog"-esque experience at # This prevents a "Windows copy dialog"-esque experience at
# the beginning of the download. # the beginning of the download.
pb_fmt = strings._('gui_download_upload_progress_starting').format( pb_fmt = strings._('gui_all_modes_progress_starting').format(
self.common.human_readable_filesize(downloaded_bytes)) self.common.human_readable_filesize(downloaded_bytes))
else: else:
pb_fmt = strings._('gui_download_upload_progress_eta').format( pb_fmt = strings._('gui_all_modes_progress_eta').format(
self.common.human_readable_filesize(downloaded_bytes), self.common.human_readable_filesize(downloaded_bytes),
self.estimated_time_remaining) self.estimated_time_remaining)
@ -110,12 +137,12 @@ class DownloadHistoryItem(HistoryItem):
self.started) self.started)
class UploadHistoryItemFile(QtWidgets.QWidget): class ReceiveHistoryItemFile(QtWidgets.QWidget):
def __init__(self, common, filename): def __init__(self, common, filename):
super(UploadHistoryItemFile, self).__init__() super(ReceiveHistoryItemFile, self).__init__()
self.common = common self.common = common
self.common.log('UploadHistoryItemFile', '__init__', 'filename: {}'.format(filename)) self.common.log('ReceiveHistoryItemFile', '__init__', 'filename: {}'.format(filename))
self.filename = filename self.filename = filename
self.dir = None self.dir = None
@ -166,10 +193,10 @@ class UploadHistoryItemFile(QtWidgets.QWidget):
""" """
Open the downloads folder, with the file selected, in a cross-platform manner Open the downloads folder, with the file selected, in a cross-platform manner
""" """
self.common.log('UploadHistoryItemFile', 'open_folder') self.common.log('ReceiveHistoryItemFile', 'open_folder')
if not self.dir: if not self.dir:
self.common.log('UploadHistoryItemFile', 'open_folder', "dir has not been set yet, can't open folder") self.common.log('ReceiveHistoryItemFile', 'open_folder', "dir has not been set yet, can't open folder")
return return
abs_filename = os.path.join(self.dir, self.filename) abs_filename = os.path.join(self.dir, self.filename)
@ -190,16 +217,16 @@ class UploadHistoryItemFile(QtWidgets.QWidget):
elif self.common.platform == 'Windows': elif self.common.platform == 'Windows':
subprocess.Popen(['explorer', '/select,{}'.format(abs_filename)]) subprocess.Popen(['explorer', '/select,{}'.format(abs_filename)])
class UploadHistoryItem(HistoryItem): class ReceiveHistoryItem(HistoryItem):
def __init__(self, common, id, content_length): def __init__(self, common, id, content_length):
super(UploadHistoryItem, self).__init__() super(ReceiveHistoryItem, self).__init__()
self.common = common self.common = common
self.id = id self.id = id
self.content_length = content_length self.content_length = content_length
self.started = datetime.now() self.started = datetime.now()
# Label # Label
self.label = QtWidgets.QLabel(strings._('gui_upload_in_progress').format(self.started.strftime("%b %d, %I:%M%p"))) self.label = QtWidgets.QLabel(strings._('gui_all_modes_transfer_started').format(self.started.strftime("%b %d, %I:%M%p")))
# Progress bar # Progress bar
self.progress_bar = QtWidgets.QProgressBar() self.progress_bar = QtWidgets.QProgressBar()
@ -244,14 +271,14 @@ class UploadHistoryItem(HistoryItem):
elapsed = datetime.now() - self.started elapsed = datetime.now() - self.started
if elapsed.seconds < 10: if elapsed.seconds < 10:
pb_fmt = strings._('gui_download_upload_progress_starting').format( pb_fmt = strings._('gui_all_modes_progress_starting').format(
self.common.human_readable_filesize(total_uploaded_bytes)) self.common.human_readable_filesize(total_uploaded_bytes))
else: else:
estimated_time_remaining = self.common.estimated_time_remaining( estimated_time_remaining = self.common.estimated_time_remaining(
total_uploaded_bytes, total_uploaded_bytes,
self.content_length, self.content_length,
self.started.timestamp()) self.started.timestamp())
pb_fmt = strings._('gui_download_upload_progress_eta').format( pb_fmt = strings._('gui_all_modes_progress_eta').format(
self.common.human_readable_filesize(total_uploaded_bytes), self.common.human_readable_filesize(total_uploaded_bytes),
estimated_time_remaining) estimated_time_remaining)
@ -259,7 +286,7 @@ class UploadHistoryItem(HistoryItem):
for filename in list(data['progress']): for filename in list(data['progress']):
# Add a new file if needed # Add a new file if needed
if filename not in self.files: if filename not in self.files:
self.files[filename] = UploadHistoryItemFile(self.common, filename) self.files[filename] = ReceiveHistoryItemFile(self.common, filename)
self.files_layout.addWidget(self.files[filename]) self.files_layout.addWidget(self.files[filename])
# Update the file # Update the file
@ -277,23 +304,7 @@ class UploadHistoryItem(HistoryItem):
self.progress_bar.hide() self.progress_bar.hide()
# Change the label # Change the label
self.ended = self.started = datetime.now() self.label.setText(self.get_finished_label_text(self.started))
if self.started.year == self.ended.year and self.started.month == self.ended.month and self.started.day == self.ended.day:
if self.started.hour == self.ended.hour and self.started.minute == self.ended.minute:
text = strings._('gui_upload_finished').format(
self.started.strftime("%b %d, %I:%M%p")
)
else:
text = strings._('gui_upload_finished_range').format(
self.started.strftime("%b %d, %I:%M%p"),
self.ended.strftime("%I:%M%p")
)
else:
text = strings._('gui_upload_finished_range').format(
self.started.strftime("%b %d, %I:%M%p"),
self.ended.strftime("%b %d, %I:%M%p")
)
self.label.setText(text)
elif data['action'] == 'canceled': elif data['action'] == 'canceled':
# Hide the progress bar # Hide the progress bar
@ -393,7 +404,7 @@ class History(QtWidgets.QWidget):
# Header # Header
self.header_label = QtWidgets.QLabel(header_text) self.header_label = QtWidgets.QLabel(header_text)
self.header_label.setStyleSheet(self.common.css['downloads_uploads_label']) self.header_label.setStyleSheet(self.common.css['downloads_uploads_label'])
clear_button = QtWidgets.QPushButton(strings._('gui_clear_history')) clear_button = QtWidgets.QPushButton(strings._('gui_all_modes_clear_history'))
clear_button.setStyleSheet(self.common.css['downloads_uploads_clear']) clear_button.setStyleSheet(self.common.css['downloads_uploads_clear'])
clear_button.setFlat(True) clear_button.setFlat(True)
clear_button.clicked.connect(self.reset) clear_button.clicked.connect(self.reset)

View File

@ -22,7 +22,7 @@ from PyQt5 import QtCore, QtWidgets, QtGui
from onionshare import strings from onionshare import strings
from onionshare.web import Web from onionshare.web import Web
from ..history import History, ToggleHistory, UploadHistoryItem from ..history import History, ToggleHistory, ReceiveHistoryItem
from .. import Mode from .. import Mode
class ReceiveMode(Mode): class ReceiveMode(Mode):
@ -49,17 +49,17 @@ class ReceiveMode(Mode):
# Upload history # Upload history
self.history = History( self.history = History(
self.common, self.common,
QtGui.QPixmap.fromImage(QtGui.QImage(self.common.get_resource_path('images/uploads_transparent.png'))), QtGui.QPixmap.fromImage(QtGui.QImage(self.common.get_resource_path('images/receive_icon_transparent.png'))),
strings._('gui_no_uploads'), strings._('gui_receive_mode_no_files'),
strings._('gui_uploads') strings._('gui_all_modes_history')
) )
self.history.hide() self.history.hide()
# Toggle history # Toggle history
self.toggle_history = ToggleHistory( self.toggle_history = ToggleHistory(
self.common, self, self.history, self.common, self, self.history,
QtGui.QIcon(self.common.get_resource_path('images/uploads_toggle.png')), QtGui.QIcon(self.common.get_resource_path('images/receive_icon_toggle.png')),
QtGui.QIcon(self.common.get_resource_path('images/uploads_toggle_selected.png')) QtGui.QIcon(self.common.get_resource_path('images/receive_icon_toggle_selected.png'))
) )
# Receive mode warning # Receive mode warning
@ -103,7 +103,7 @@ class ReceiveMode(Mode):
return True return True
# An upload is probably still running - hold off on stopping the share, but block new shares. # An upload is probably still running - hold off on stopping the share, but block new shares.
else: else:
self.server_status_label.setText(strings._('timeout_upload_still_running')) self.server_status_label.setText(strings._('gui_receive_mode_timeout_waiting'))
self.web.receive_mode.can_upload = False self.web.receive_mode.can_upload = False
return False return False
@ -136,19 +136,19 @@ class ReceiveMode(Mode):
""" """
Handle REQUEST_LOAD event. Handle REQUEST_LOAD event.
""" """
self.system_tray.showMessage(strings._('systray_page_loaded_title'), strings._('systray_upload_page_loaded_message')) self.system_tray.showMessage(strings._('systray_page_loaded_title'), strings._('systray_page_loaded_message'))
def handle_request_started(self, event): def handle_request_started(self, event):
""" """
Handle REQUEST_STARTED event. Handle REQUEST_STARTED event.
""" """
item = UploadHistoryItem(self.common, event["data"]["id"], event["data"]["content_length"]) item = ReceiveHistoryItem(self.common, event["data"]["id"], event["data"]["content_length"])
self.history.add(event["data"]["id"], item) self.history.add(event["data"]["id"], item)
self.toggle_history.update_indicator(True) self.toggle_history.update_indicator(True)
self.history.in_progress_count += 1 self.history.in_progress_count += 1
self.history.update_in_progress() self.history.update_in_progress()
self.system_tray.showMessage(strings._('systray_upload_started_title'), strings._('systray_upload_started_message')) self.system_tray.showMessage(strings._('systray_receive_started_title'), strings._('systray_receive_started_message'))
def handle_request_progress(self, event): def handle_request_progress(self, event):
""" """
@ -159,13 +159,6 @@ class ReceiveMode(Mode):
'progress': event["data"]["progress"] 'progress': event["data"]["progress"]
}) })
def handle_request_close_server(self, event):
"""
Handle REQUEST_CLOSE_SERVER event.
"""
self.stop_server()
self.system_tray.showMessage(strings._('systray_close_server_title'), strings._('systray_close_server_message'))
def handle_request_upload_file_renamed(self, event): def handle_request_upload_file_renamed(self, event):
""" """
Handle REQUEST_UPLOAD_FILE_RENAMED event. Handle REQUEST_UPLOAD_FILE_RENAMED event.

View File

@ -28,7 +28,7 @@ from onionshare.web import Web
from .file_selection import FileSelection from .file_selection import FileSelection
from .threads import CompressThread from .threads import CompressThread
from .. import Mode from .. import Mode
from ..history import History, ToggleHistory, DownloadHistoryItem from ..history import History, ToggleHistory, ShareHistoryItem
from ...widgets import Alert from ...widgets import Alert
@ -74,9 +74,9 @@ class ShareMode(Mode):
# Download history # Download history
self.history = History( self.history = History(
self.common, self.common,
QtGui.QPixmap.fromImage(QtGui.QImage(self.common.get_resource_path('images/downloads_transparent.png'))), QtGui.QPixmap.fromImage(QtGui.QImage(self.common.get_resource_path('images/share_icon_transparent.png'))),
strings._('gui_no_downloads'), strings._('gui_share_mode_no_files'),
strings._('gui_downloads') strings._('gui_all_modes_history')
) )
self.history.hide() self.history.hide()
@ -87,8 +87,8 @@ class ShareMode(Mode):
# Toggle history # Toggle history
self.toggle_history = ToggleHistory( self.toggle_history = ToggleHistory(
self.common, self, self.history, self.common, self, self.history,
QtGui.QIcon(self.common.get_resource_path('images/downloads_toggle.png')), QtGui.QIcon(self.common.get_resource_path('images/share_icon_toggle.png')),
QtGui.QIcon(self.common.get_resource_path('images/downloads_toggle_selected.png')) QtGui.QIcon(self.common.get_resource_path('images/share_icon_toggle_selected.png'))
) )
# Top bar # Top bar
@ -138,7 +138,7 @@ class ShareMode(Mode):
return True return True
# A download is probably still running - hold off on stopping the share # A download is probably still running - hold off on stopping the share
else: else:
self.server_status_label.setText(strings._('timeout_download_still_running')) self.server_status_label.setText(strings._('gui_share_mode_timeout_waiting'))
return False return False
def start_server_custom(self): def start_server_custom(self):
@ -229,7 +229,7 @@ class ShareMode(Mode):
""" """
Handle REQUEST_LOAD event. Handle REQUEST_LOAD event.
""" """
self.system_tray.showMessage(strings._('systray_page_loaded_title'), strings._('systray_download_page_loaded_message')) self.system_tray.showMessage(strings._('systray_page_loaded_title'), strings._('systray_page_loaded_message'))
def handle_request_started(self, event): def handle_request_started(self, event):
""" """
@ -240,13 +240,13 @@ class ShareMode(Mode):
else: else:
filesize = self.web.share_mode.download_filesize filesize = self.web.share_mode.download_filesize
item = DownloadHistoryItem(self.common, event["data"]["id"], filesize) item = ShareHistoryItem(self.common, event["data"]["id"], filesize)
self.history.add(event["data"]["id"], item) self.history.add(event["data"]["id"], item)
self.toggle_history.update_indicator(True) self.toggle_history.update_indicator(True)
self.history.in_progress_count += 1 self.history.in_progress_count += 1
self.history.update_in_progress() self.history.update_in_progress()
self.system_tray.showMessage(strings._('systray_download_started_title'), strings._('systray_download_started_message')) self.system_tray.showMessage(strings._('systray_share_started_title'), strings._('systray_share_started_message'))
def handle_request_progress(self, event): def handle_request_progress(self, event):
""" """
@ -256,7 +256,7 @@ class ShareMode(Mode):
# Is the download complete? # Is the download complete?
if event["data"]["bytes"] == self.web.share_mode.filesize: if event["data"]["bytes"] == self.web.share_mode.filesize:
self.system_tray.showMessage(strings._('systray_download_completed_title'), strings._('systray_download_completed_message')) self.system_tray.showMessage(strings._('systray_share_completed_title'), strings._('systray_share_completed_message'))
# Update completed and in progress labels # Update completed and in progress labels
self.history.completed_count += 1 self.history.completed_count += 1
@ -284,7 +284,7 @@ class ShareMode(Mode):
# Update in progress count # Update in progress count
self.history.in_progress_count -= 1 self.history.in_progress_count -= 1
self.history.update_in_progress() self.history.update_in_progress()
self.system_tray.showMessage(strings._('systray_download_canceled_title'), strings._('systray_download_canceled_message')) self.system_tray.showMessage(strings._('systray_share_canceled_title'), strings._('systray_share_canceled_message'))
def on_reload_settings(self): def on_reload_settings(self):
""" """

View File

@ -384,9 +384,6 @@ class OnionShareGui(QtWidgets.QMainWindow):
elif event["type"] == Web.REQUEST_CANCELED: elif event["type"] == Web.REQUEST_CANCELED:
mode.handle_request_canceled(event) mode.handle_request_canceled(event)
elif event["type"] == Web.REQUEST_CLOSE_SERVER:
mode.handle_request_close_server(event)
elif event["type"] == Web.REQUEST_UPLOAD_FILE_RENAMED: elif event["type"] == Web.REQUEST_UPLOAD_FILE_RENAMED:
mode.handle_request_upload_file_renamed(event) mode.handle_request_upload_file_renamed(event)
@ -399,8 +396,8 @@ class OnionShareGui(QtWidgets.QMainWindow):
elif event["type"] == Web.REQUEST_UPLOAD_CANCELED: elif event["type"] == Web.REQUEST_UPLOAD_CANCELED:
mode.handle_request_upload_canceled(event) mode.handle_request_upload_canceled(event)
if event["type"] == Web.REQUEST_ERROR_DOWNLOADS_DIR_CANNOT_CREATE: if event["type"] == Web.REQUEST_ERROR_DATA_DIR_CANNOT_CREATE:
Alert(self.common, strings._('error_cannot_create_downloads_dir').format(event["data"]["receive_mode_dir"])) Alert(self.common, strings._('error_cannot_create_data_dir').format(event["data"]["receive_mode_dir"]))
if event["type"] == Web.REQUEST_OTHER: if event["type"] == Web.REQUEST_OTHER:
if event["path"] != '/favicon.ico' and event["path"] != "/{}/shutdown".format(mode.web.shutdown_slug): if event["path"] != '/favicon.ico' and event["path"] != "/{}/shutdown".format(mode.web.shutdown_slug):

View File

@ -187,20 +187,20 @@ class SettingsDialog(QtWidgets.QDialog):
sharing_group = QtWidgets.QGroupBox(strings._("gui_settings_sharing_label")) sharing_group = QtWidgets.QGroupBox(strings._("gui_settings_sharing_label"))
sharing_group.setLayout(sharing_group_layout) sharing_group.setLayout(sharing_group_layout)
# Downloads dir # OnionShare data dir
downloads_label = QtWidgets.QLabel(strings._('gui_settings_downloads_label')); data_dir_label = QtWidgets.QLabel(strings._('gui_settings_data_dir_label'));
self.downloads_dir_lineedit = QtWidgets.QLineEdit() self.data_dir_lineedit = QtWidgets.QLineEdit()
self.downloads_dir_lineedit.setReadOnly(True) self.data_dir_lineedit.setReadOnly(True)
downloads_button = QtWidgets.QPushButton(strings._('gui_settings_downloads_button')) data_dir_button = QtWidgets.QPushButton(strings._('gui_settings_data_dir_browse_button'))
downloads_button.clicked.connect(self.downloads_button_clicked) data_dir_button.clicked.connect(self.data_dir_button_clicked)
downloads_layout = QtWidgets.QHBoxLayout() data_dir_layout = QtWidgets.QHBoxLayout()
downloads_layout.addWidget(downloads_label) data_dir_layout.addWidget(data_dir_label)
downloads_layout.addWidget(self.downloads_dir_lineedit) data_dir_layout.addWidget(self.data_dir_lineedit)
downloads_layout.addWidget(downloads_button) data_dir_layout.addWidget(data_dir_button)
# Receiving options layout # Receiving options layout
receiving_group_layout = QtWidgets.QVBoxLayout() receiving_group_layout = QtWidgets.QVBoxLayout()
receiving_group_layout.addLayout(downloads_layout) receiving_group_layout.addLayout(data_dir_layout)
receiving_group = QtWidgets.QGroupBox(strings._("gui_settings_receiving_label")) receiving_group = QtWidgets.QGroupBox(strings._("gui_settings_receiving_label"))
receiving_group.setLayout(receiving_group_layout) receiving_group.setLayout(receiving_group_layout)
@ -508,8 +508,8 @@ class SettingsDialog(QtWidgets.QDialog):
if use_legacy_v2_onions or save_private_key: if use_legacy_v2_onions or save_private_key:
self.use_legacy_v2_onions_checkbox.setCheckState(QtCore.Qt.Checked) self.use_legacy_v2_onions_checkbox.setCheckState(QtCore.Qt.Checked)
downloads_dir = self.old_settings.get('downloads_dir') data_dir = self.old_settings.get('data_dir')
self.downloads_dir_lineedit.setText(downloads_dir) self.data_dir_lineedit.setText(data_dir)
public_mode = self.old_settings.get('public_mode') public_mode = self.old_settings.get('public_mode')
if public_mode: if public_mode:
@ -747,17 +747,17 @@ class SettingsDialog(QtWidgets.QDialog):
if not self.save_private_key_checkbox.isChecked(): if not self.save_private_key_checkbox.isChecked():
self.use_legacy_v2_onions_checkbox.setEnabled(True) self.use_legacy_v2_onions_checkbox.setEnabled(True)
def downloads_button_clicked(self): def data_dir_button_clicked(self):
""" """
Browse for a new downloads directory Browse for a new OnionShare data directory
""" """
downloads_dir = self.downloads_dir_lineedit.text() data_dir = self.data_dir_lineedit.text()
selected_dir = QtWidgets.QFileDialog.getExistingDirectory(self, selected_dir = QtWidgets.QFileDialog.getExistingDirectory(self,
strings._('gui_settings_downloads_label'), downloads_dir) strings._('gui_settings_data_dir_label'), data_dir)
if selected_dir: if selected_dir:
self.common.log('SettingsDialog', 'downloads_button_clicked', 'selected dir: {}'.format(selected_dir)) self.common.log('SettingsDialog', 'data_dir_button_clicked', 'selected dir: {}'.format(selected_dir))
self.downloads_dir_lineedit.setText(selected_dir) self.data_dir_lineedit.setText(selected_dir)
def test_tor_clicked(self): def test_tor_clicked(self):
""" """
@ -981,7 +981,7 @@ class SettingsDialog(QtWidgets.QDialog):
# Also unset the HidServAuth if we are removing our reusable private key # Also unset the HidServAuth if we are removing our reusable private key
settings.set('hidservauth_string', '') settings.set('hidservauth_string', '')
settings.set('downloads_dir', self.downloads_dir_lineedit.text()) settings.set('data_dir', self.data_dir_lineedit.text())
settings.set('public_mode', self.public_mode_checkbox.isChecked()) settings.set('public_mode', self.public_mode_checkbox.isChecked())
settings.set('use_stealth', self.stealth_checkbox.isChecked()) settings.set('use_stealth', self.stealth_checkbox.isChecked())
# Always unset the HidServAuth if Stealth mode is unset # Always unset the HidServAuth if Stealth mode is unset

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 380 B

After

Width:  |  Height:  |  Size: 380 B

View File

Before

Width:  |  Height:  |  Size: 468 B

After

Width:  |  Height:  |  Size: 468 B

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 389 B

After

Width:  |  Height:  |  Size: 389 B

View File

Before

Width:  |  Height:  |  Size: 473 B

After

Width:  |  Height:  |  Size: 473 B

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -11,21 +11,10 @@
"no_available_port": "Could not find an available port to start the onion service", "no_available_port": "Could not find an available port to start the onion service",
"other_page_loaded": "Address loaded", "other_page_loaded": "Address loaded",
"close_on_timeout": "Stopped because auto-stop timer ran out", "close_on_timeout": "Stopped because auto-stop timer ran out",
"closing_automatically": "Stopped because download finished", "closing_automatically": "Stopped because transfer is complete",
"timeout_download_still_running": "Waiting for download to complete",
"timeout_upload_still_running": "Waiting for upload to complete",
"large_filesize": "Warning: Sending a large share could take hours", "large_filesize": "Warning: Sending a large share could take hours",
"systray_menu_exit": "Quit",
"systray_download_started_title": "OnionShare Download Started",
"systray_download_started_message": "A user started downloading your files",
"systray_download_completed_title": "OnionShare Download Finished",
"systray_download_completed_message": "The user finished downloading your files",
"systray_download_canceled_title": "OnionShare Download Canceled",
"systray_download_canceled_message": "The user canceled the download",
"systray_upload_started_title": "OnionShare Upload Started",
"systray_upload_started_message": "A user started uploading files to your computer",
"help_local_only": "Don't use Tor (only for development)", "help_local_only": "Don't use Tor (only for development)",
"help_stay_open": "Keep sharing after first download", "help_stay_open": "Continue sharing after files have been sent",
"help_shutdown_timeout": "Stop sharing after a given amount of seconds", "help_shutdown_timeout": "Stop sharing after a given amount of seconds",
"help_stealth": "Use client authorization (advanced)", "help_stealth": "Use client authorization (advanced)",
"help_receive": "Receive shares instead of sending them", "help_receive": "Receive shares instead of sending them",
@ -48,17 +37,12 @@
"gui_receive_stop_server_shutdown_timeout_tooltip": "Auto-stop timer ends at {}", "gui_receive_stop_server_shutdown_timeout_tooltip": "Auto-stop timer ends at {}",
"gui_copy_url": "Copy Address", "gui_copy_url": "Copy Address",
"gui_copy_hidservauth": "Copy HidServAuth", "gui_copy_hidservauth": "Copy HidServAuth",
"gui_downloads": "Download History",
"gui_no_downloads": "No Downloads Yet",
"gui_canceled": "Canceled", "gui_canceled": "Canceled",
"gui_copied_url_title": "Copied OnionShare Address", "gui_copied_url_title": "Copied OnionShare Address",
"gui_copied_url": "OnionShare address copied to clipboard", "gui_copied_url": "OnionShare address copied to clipboard",
"gui_copied_hidservauth_title": "Copied HidServAuth", "gui_copied_hidservauth_title": "Copied HidServAuth",
"gui_copied_hidservauth": "HidServAuth line copied to clipboard", "gui_copied_hidservauth": "HidServAuth line copied to clipboard",
"gui_please_wait": "Starting… Click to cancel.", "gui_please_wait": "Starting… Click to cancel.",
"gui_download_upload_progress_complete": "%p%, {0:s} elapsed.",
"gui_download_upload_progress_starting": "{0:s}, %p% (calculating)",
"gui_download_upload_progress_eta": "{0:s}, ETA: {1:s}, %p%",
"version_string": "OnionShare {0:s} | https://onionshare.org/", "version_string": "OnionShare {0:s} | https://onionshare.org/",
"gui_quit_title": "Not so fast", "gui_quit_title": "Not so fast",
"gui_share_quit_warning": "You're in the process of sending files. Are you sure you want to quit OnionShare?", "gui_share_quit_warning": "You're in the process of sending files. Are you sure you want to quit OnionShare?",
@ -80,7 +64,7 @@
"gui_settings_autoupdate_check_button": "Check for New Version", "gui_settings_autoupdate_check_button": "Check for New Version",
"gui_settings_general_label": "General settings", "gui_settings_general_label": "General settings",
"gui_settings_sharing_label": "Sharing settings", "gui_settings_sharing_label": "Sharing settings",
"gui_settings_close_after_first_download_option": "Stop sharing after first download", "gui_settings_close_after_first_download_option": "Stop sharing after files have been sent",
"gui_settings_connection_type_label": "How should OnionShare connect to Tor?", "gui_settings_connection_type_label": "How should OnionShare connect to Tor?",
"gui_settings_connection_type_bundled_option": "Use the Tor version built into OnionShare", "gui_settings_connection_type_bundled_option": "Use the Tor version built into OnionShare",
"gui_settings_connection_type_automatic_option": "Attempt auto-configuration with Tor Browser", "gui_settings_connection_type_automatic_option": "Attempt auto-configuration with Tor Browser",
@ -156,10 +140,8 @@
"gui_file_info_single": "{} file, {}", "gui_file_info_single": "{} file, {}",
"history_in_progress_tooltip": "{} in progress", "history_in_progress_tooltip": "{} in progress",
"history_completed_tooltip": "{} completed", "history_completed_tooltip": "{} completed",
"info_in_progress_uploads_tooltip": "{} upload(s) in progress", "error_cannot_create_data_dir": "Could not create OnionShare data folder: {}",
"info_completed_uploads_tooltip": "{} upload(s) completed", "receive_mode_data_dir": "Files sent to you appear in this folder: {}",
"error_cannot_create_downloads_dir": "Could not create receive mode folder: {}",
"receive_mode_downloads_dir": "Files sent to you appear in this folder: {}",
"receive_mode_warning": "Warning: Receive mode lets people upload files to your computer. Some files can potentially take control of your computer if you open them. Only open things from people you trust, or if you know what you are doing.", "receive_mode_warning": "Warning: Receive mode lets people upload files to your computer. Some files can potentially take control of your computer if you open them. Only open things from people you trust, or if you know what you are doing.",
"gui_receive_mode_warning": "Receive mode lets people upload files to your computer.<br><br><b>Some files can potentially take control of your computer if you open them. Only open things from people you trust, or if you know what you are doing.</b>", "gui_receive_mode_warning": "Receive mode lets people upload files to your computer.<br><br><b>Some files can potentially take control of your computer if you open them. Only open things from people you trust, or if you know what you are doing.</b>",
"receive_mode_upload_starting": "Upload of total size {} is starting", "receive_mode_upload_starting": "Upload of total size {} is starting",
@ -167,22 +149,33 @@
"gui_mode_share_button": "Share Files", "gui_mode_share_button": "Share Files",
"gui_mode_receive_button": "Receive Files", "gui_mode_receive_button": "Receive Files",
"gui_settings_receiving_label": "Receiving settings", "gui_settings_receiving_label": "Receiving settings",
"gui_settings_downloads_label": "Save files to", "gui_settings_data_dir_label": "Save files to",
"gui_settings_downloads_button": "Browse", "gui_settings_data_dir_browse_button": "Browse",
"gui_settings_public_mode_checkbox": "Public mode", "gui_settings_public_mode_checkbox": "Public mode",
"systray_close_server_title": "OnionShare Server Closed",
"systray_close_server_message": "A user closed the server",
"systray_page_loaded_title": "OnionShare Page Loaded",
"systray_download_page_loaded_message": "A user loaded the download page",
"systray_upload_page_loaded_message": "A user loaded the upload page",
"gui_uploads": "Upload History",
"gui_no_uploads": "No Uploads Yet",
"gui_clear_history": "Clear All",
"gui_upload_in_progress": "Upload Started {}",
"gui_upload_finished_range": "Uploaded {} to {}",
"gui_upload_finished": "Uploaded {}",
"gui_download_in_progress": "Download Started {}",
"gui_open_folder_error_nautilus": "Cannot open folder because nautilus is not available. The file is here: {}", "gui_open_folder_error_nautilus": "Cannot open folder because nautilus is not available. The file is here: {}",
"gui_settings_language_label": "Preferred language", "gui_settings_language_label": "Preferred language",
"gui_settings_language_changed_notice": "Restart OnionShare for your change in language to take effect." "gui_settings_language_changed_notice": "Restart OnionShare for your change in language to take effect.",
"systray_menu_exit": "Quit",
"systray_page_loaded_title": "Page Loaded",
"systray_page_loaded_message": "OnionShare address loaded",
"systray_share_started_title": "Sharing Started",
"systray_share_started_message": "Starting to send files to someone",
"systray_share_completed_title": "Sharing Complete",
"systray_share_completed_message": "Finished sending files",
"systray_share_canceled_title": "Sharing Canceled",
"systray_share_canceled_message": "Someone canceled receiving your files",
"systray_receive_started_title": "Receiving Started",
"systray_receive_started_message": "Someone is sending files to you",
"gui_all_modes_history": "History",
"gui_all_modes_clear_history": "Clear All",
"gui_all_modes_transfer_started": "Started {}",
"gui_all_modes_transfer_finished_range": "Transferred {} - {}",
"gui_all_modes_transfer_finished": "Transferred {}",
"gui_all_modes_progress_complete": "%p%, {0:s} elapsed.",
"gui_all_modes_progress_starting": "{0:s}, %p% (calculating)",
"gui_all_modes_progress_eta": "{0:s}, ETA: {1:s}, %p%",
"gui_share_mode_no_files": "No Files Sent Yet",
"gui_share_mode_timeout_waiting": "Waiting to finish sending",
"gui_receive_mode_no_files": "No Files Received Yet",
"gui_receive_mode_timeout_waiting": "Waiting to finish receiving"
} }

View File

@ -39,7 +39,7 @@ class GuiBaseTest(object):
strings.load_strings(common) strings.load_strings(common)
# Get all of the settings in test_settings # Get all of the settings in test_settings
test_settings['downloads_dir'] = '/tmp/OnionShare' test_settings['data_dir'] = '/tmp/OnionShare'
for key, val in common.settings.default_settings.items(): for key, val in common.settings.default_settings.items():
if key not in test_settings: if key not in test_settings:
test_settings[key] = val test_settings[key] = val
@ -319,5 +319,3 @@ class GuiBaseTest(object):
self.windowTitle_seen() self.windowTitle_seen()
self.settings_button_is_visible() self.settings_button_is_visible()
self.server_status_bar_is_visible() self.server_status_bar_is_visible()

View File

@ -21,7 +21,7 @@ class GuiReceiveTest(GuiBaseTest):
for i in range(10): for i in range(10):
date_dir = now.strftime("%Y-%m-%d") date_dir = now.strftime("%Y-%m-%d")
time_dir = now.strftime("%H.%M.%S") time_dir = now.strftime("%H.%M.%S")
receive_mode_dir = os.path.join(self.gui.common.settings.get('downloads_dir'), date_dir, time_dir) receive_mode_dir = os.path.join(self.gui.common.settings.get('data_dir'), date_dir, time_dir)
expected_filename = os.path.join(receive_mode_dir, expected_basename) expected_filename = os.path.join(receive_mode_dir, expected_basename)
if os.path.exists(expected_filename): if os.path.exists(expected_filename):
exists = True exists = True

View File

@ -148,7 +148,7 @@ class SettingsGuiBaseTest(object):
self.assertFalse(self.gui.close_after_first_download_checkbox.isChecked()) self.assertFalse(self.gui.close_after_first_download_checkbox.isChecked())
# receive mode # receive mode
self.gui.downloads_dir_lineedit.setText('/tmp/OnionShareSettingsTest') self.gui.data_dir_lineedit.setText('/tmp/OnionShareSettingsTest')
# bundled mode is enabled # bundled mode is enabled
@ -234,7 +234,7 @@ class SettingsGuiBaseTest(object):
self.assertFalse(data["save_private_key"]) self.assertFalse(data["save_private_key"])
self.assertFalse(data["use_stealth"]) self.assertFalse(data["use_stealth"])
self.assertEqual(data["downloads_dir"], "/tmp/OnionShareSettingsTest") self.assertEqual(data["data_dir"], "/tmp/OnionShareSettingsTest")
self.assertFalse(data["close_after_first_download"]) self.assertFalse(data["close_after_first_download"])
self.assertEqual(data["connection_type"], "bundled") self.assertEqual(data["connection_type"], "bundled")
self.assertFalse(data["tor_bridges_use_obfs4"]) self.assertFalse(data["tor_bridges_use_obfs4"])

View File

@ -39,7 +39,7 @@ class TorGuiBaseTest(GuiBaseTest):
# Get all of the settings in test_settings # Get all of the settings in test_settings
test_settings['connection_type'] = 'automatic' test_settings['connection_type'] = 'automatic'
test_settings['downloads_dir'] = '/tmp/OnionShare' test_settings['data_dir'] = '/tmp/OnionShare'
for key, val in common.settings.default_settings.items(): for key, val in common.settings.default_settings.items():
if key not in test_settings: if key not in test_settings:
test_settings[key] = val test_settings[key] = val

View File

@ -64,7 +64,7 @@ class TestSettings:
'private_key': '', 'private_key': '',
'slug': '', 'slug': '',
'hidservauth_string': '', 'hidservauth_string': '',
'downloads_dir': os.path.expanduser('~/OnionShare'), 'data_dir': os.path.expanduser('~/OnionShare'),
'public_mode': False 'public_mode': False
} }
for key in settings_obj._settings: for key in settings_obj._settings: