From 24109004cfdb115418bf82759ea0c99caa8b293a Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Wed, 16 Mar 2016 23:56:35 +0300 Subject: [PATCH] file transfers - profile.py update --- src/callbacks.py | 5 ++++- src/profile.py | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/callbacks.py b/src/callbacks.py index a80fb5d..d95622d 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -136,7 +136,7 @@ def tox_file_recv(window, tray): settings = Settings.get_instance() if file_type == TOX_FILE_KIND['DATA']: print 'file' - file_name = file_name[:].decode('utf8') + file_name = file_name[:file_name_size].decode('utf8') invoke_in_main_thread(profile.incoming_file_transfer, friend_number, file_number, @@ -156,6 +156,9 @@ def tox_file_recv(window, tray): size) return wrapped + +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) # ----------------------------------------------------------------------------------------------------------------- # Callbacks - initialization # ----------------------------------------------------------------------------------------------------------------- diff --git a/src/profile.py b/src/profile.py index 9ef7a44..d5266aa 100644 --- a/src/profile.py +++ b/src/profile.py @@ -8,6 +8,7 @@ from ctypes import * from util import curr_time, log, Singleton, curr_directory, convert_time from tox_dns import tox_dns from history import * +from file_transfers import * import time @@ -696,13 +697,15 @@ class Profile(Contact, Singleton): self.status = None for friend in self._friends: friend.status = None + # TODO: FT reset # ----------------------------------------------------------------------------------------------------------------- # File transfers support # ----------------------------------------------------------------------------------------------------------------- def incoming_file_transfer(self, friend_number, file_number, size, file_name): - pass + rt = ReceiveTransfer(Settings.get_default_path() + file_name, self._tox, friend_number) + self._file_transfers.append(rt) def incoming_avatar(self, friend_number, file_number, size): """ @@ -723,6 +726,9 @@ class Profile(Contact, Singleton): else: pass + def incoming_chunk(self, friend_number, file_number, position, chunk, length): + pass + def send_avatar(self, friend_number): pass