file transfers fixes - part 5

This commit is contained in:
ingvar1995 2018-05-17 21:45:35 +03:00
parent bfa91df927
commit 9365ca2913
3 changed files with 13 additions and 10 deletions

View File

@ -49,8 +49,8 @@ class Friend(contact.Contact):
self._corr = list(filter(is_valid, self._corr))
def delete_one_unsent_file(self, time):
self._corr = list(filter(lambda x: not (type(x) is UnsentFile and x.get_data()[2] == time), self._corr))
def delete_one_unsent_file(self, message_id):
self._corr = list(filter(lambda m: not (type(m) is UnsentFile and m.message_id == message_id), self._corr))
# -----------------------------------------------------------------------------------------------------------------
# History support

View File

@ -81,8 +81,8 @@ class FileTransfersHandler:
elif not already_cancelled:
self._tox.file_control(friend_number, file_number, TOX_FILE_CONTROL['CANCEL'])
def cancel_not_started_transfer(self, cancel_time):
self.get_curr_friend().delete_one_unsent_file(cancel_time)
def cancel_not_started_transfer(self, friend_number, message_id):
self._get_friend_by_number(friend_number).delete_one_unsent_file(message_id)
def pause_transfer(self, friend_number, file_number, by_friend=False):
"""
@ -128,7 +128,8 @@ class FileTransfersHandler:
def send_screenshot(self, data, friend_number):
"""
Send screenshot
:param data: raw data - png
:param data: raw data - png format
:param friend_number: friend number
"""
self.send_inline(data, 'toxygen_inline.png', friend_number)
@ -158,7 +159,7 @@ class FileTransfersHandler:
"""
friend = self._get_friend_by_number(friend_number)
if friend.status is None and not is_resend:
m = UnsentFile(path, None, time.time())
m = UnsentFile(path, None, util.get_unix_time())
friend.append_message(m)
return
elif friend.status is None and is_resend:
@ -220,9 +221,9 @@ class FileTransfersHandler:
if friend_num == friend_number:
ft = self._file_transfers[(friend_num, file_num)]
if type(ft) is SendTransfer:
self._paused_file_transfers[ft.get_id()] = [ft.get_path(), friend_num, False, -1]
self._paused_file_transfers[ft.file_id] = [ft.path, friend_num, False, -1]
elif type(ft) is ReceiveTransfer and ft.state != FILE_TRANSFER_STATE['INCOMING_NOT_STARTED']:
self._paused_file_transfers[ft.get_id()] = [ft.get_path(), friend_num, True, ft.total_size()]
self._paused_file_transfers[ft.file_id] = [ft.path, friend_num, True, ft.total_size()]
self.cancel_transfer(friend_num, file_num, True)
# -----------------------------------------------------------------------------------------------------------------
@ -235,7 +236,7 @@ class FileTransfersHandler:
:param avatar_path: path to avatar or None if reset
"""
sa = SendAvatar(avatar_path, self._tox, friend_number)
self._file_transfers[(friend_number, sa.get_file_number())] = sa
self._file_transfers[(friend_number, sa.file_number)] = sa
def incoming_avatar(self, friend_number, file_number, size):
"""

View File

@ -397,9 +397,11 @@ class UnsentFileItem(FileTransferItem):
movie = QtGui.QMovie(util.join_path(util.get_images_directory(), 'spinner.gif'))
self.time.setMovie(movie)
movie.start()
self._message_id = transfer_message.message_id
self._friend_number = transfer_message.friend_number
def cancel_transfer(self, *args):
self._file_transfer_handler.cancel_not_started_transfer(self._time)
self._file_transfer_handler.cancel_not_started_transfer(self._friend_number, self._message_id)
class InlineImageItem(QtWidgets.QScrollArea):