From a3103f6fb94619512b963190d16dff3b18c4b610 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Thu, 17 May 2018 23:31:48 +0300 Subject: [PATCH] file transfers fixes - part 6 --- toxygen/file_transfers/file_transfers.py | 4 +++- toxygen/middleware/callbacks.py | 7 ++----- toxygen/ui/items_factories.py | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/toxygen/file_transfers/file_transfers.py b/toxygen/file_transfers/file_transfers.py index aa1be58..e5c2bb4 100644 --- a/toxygen/file_transfers/file_transfers.py +++ b/toxygen/file_transfers/file_transfers.py @@ -136,11 +136,13 @@ class SendTransfer(FileTransfer): def __init__(self, path, tox, friend_number, kind=TOX_FILE_KIND['DATA'], file_id=None): if path is not None: - self._file = open(path, 'rb') + fl = open(path, 'rb') size = getsize(path) else: + fl = None size = 0 super().__init__(path, tox, friend_number, size) + self._file = fl self.state = FILE_TRANSFER_STATE['OUTGOING_NOT_STARTED'] self._file_number = tox.file_send(friend_number, kind, size, file_id, bytes(basename(path), 'utf-8') if path else b'') diff --git a/toxygen/middleware/callbacks.py b/toxygen/middleware/callbacks.py index 860070f..9f4cdd8 100644 --- a/toxygen/middleware/callbacks.py +++ b/toxygen/middleware/callbacks.py @@ -26,11 +26,8 @@ def self_connection_status(tox, profile): """ def wrapped(tox_link, connection, user_data): print('Connection status: ', str(connection)) - if profile.status is None: - status = tox.self_get_status() - invoke_in_main_thread(profile.set_status, status) - elif connection == TOX_CONNECTION['NONE']: - invoke_in_main_thread(profile.set_status, None) + status = None if connection == TOX_CONNECTION['NONE'] else tox.self_get_status() + invoke_in_main_thread(profile.set_status, None) return wrapped diff --git a/toxygen/ui/items_factories.py b/toxygen/ui/items_factories.py index a9b1c1a..46e9df8 100644 --- a/toxygen/ui/items_factories.py +++ b/toxygen/ui/items_factories.py @@ -70,7 +70,7 @@ class MessagesItemsFactory: return item def create_file_transfer_item(self, tm, append=True): - item = tm.get_widget(self._file_transfers_handler, self._settings, self._messages.width()) + item = tm.get_widget(self._file_transfers_handler, self._settings, self._messages.width(), self._messages) elem = QtWidgets.QListWidgetItem() elem.setSizeHint(QtCore.QSize(self._messages.width() - 30, 34)) if append: