file transfers fixes - part 6

This commit is contained in:
ingvar1995 2018-05-17 23:31:48 +03:00
parent 9365ca2913
commit a3103f6fb9
3 changed files with 6 additions and 7 deletions

View file

@ -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'')

View file

@ -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

View file

@ -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: