From 4ce7f6c6a5ecd26ed5544fcc02869f1dafc077ee Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Thu, 17 Mar 2016 12:54:05 +0300 Subject: [PATCH] callback for chunk update --- src/callbacks.py | 3 ++- src/profile.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/callbacks.py b/src/callbacks.py index d95622d..efdcc33 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -158,7 +158,7 @@ def tox_file_recv(window, tray): def file_recv_chunk(tox, friend_number, file_number, position, chunk, length, user_data): - Profile.get_instance().incoming_chunk(friend_number, file_number, position, chunk, length) + Profile.get_instance().incoming_chunk(friend_number, file_number, position, chunk if length else None) # ----------------------------------------------------------------------------------------------------------------- # Callbacks - initialization # ----------------------------------------------------------------------------------------------------------------- @@ -181,3 +181,4 @@ def init_callbacks(tox, window, tray): tox.callback_friend_request(friend_request, 0) tox.callback_file_recv(tox_file_recv(window, tray), 0) + tox.callback_file_recv_chunk(file_recv_chunk, 0) diff --git a/src/profile.py b/src/profile.py index d5266aa..5ce5cf2 100644 --- a/src/profile.py +++ b/src/profile.py @@ -706,6 +706,7 @@ class Profile(Contact, Singleton): def incoming_file_transfer(self, friend_number, file_number, size, file_name): rt = ReceiveTransfer(Settings.get_default_path() + file_name, self._tox, friend_number) self._file_transfers.append(rt) + self._tox.file_control(friend_number, file_number, TOX_FILE_CONTROL['RESUME']) def incoming_avatar(self, friend_number, file_number, size): """ @@ -726,8 +727,10 @@ class Profile(Contact, Singleton): else: pass - def incoming_chunk(self, friend_number, file_number, position, chunk, length): - pass + def incoming_chunk(self, friend_number, file_number, position, data): + # TODO: better transfer filtering + transfer = filter(lambda x: x._friend_number == friend_number, self._file_transfers)[0] + transfer.write_chunk(position, data) def send_avatar(self, friend_number): pass