From 6192688e0c0096fd7e23f6c2ae68ed18a1b2f68b Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Tue, 10 May 2016 22:57:52 +0300 Subject: [PATCH] wrapper fixes and file transfer fix (pause) --- src/file_transfers.py | 2 -- src/profile.py | 10 ++++++++-- src/tox.py | 2 +- src/toxav.py | 6 +++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/file_transfers.py b/src/file_transfers.py index 15eb554..dc34946 100644 --- a/src/file_transfers.py +++ b/src/file_transfers.py @@ -239,7 +239,6 @@ class ReceiveAvatar(ReceiveTransfer): elif exists(path): if not size: self.send_control(TOX_FILE_CONTROL['CANCEL']) - self.state = TOX_FILE_TRANSFER_STATE['CANCELED'] self._file.close() remove(path) remove(path + '.tmp') @@ -250,7 +249,6 @@ class ReceiveAvatar(ReceiveTransfer): existing_hash = Tox.hash(data) if hash == existing_hash: self.send_control(TOX_FILE_CONTROL['CANCEL']) - self.state = TOX_FILE_TRANSFER_STATE['CANCELED'] remove(path + '.tmp') else: self.send_control(TOX_FILE_CONTROL['RESUME']) diff --git a/src/profile.py b/src/profile.py index 497b862..d7b4999 100644 --- a/src/profile.py +++ b/src/profile.py @@ -956,12 +956,18 @@ class Profile(Contact, Singleton): self._tox.file_control(friend_number, file_number, TOX_FILE_CONTROL['CANCEL']) def pause_transfer(self, friend_number, file_number, by_friend=False): + """ + Pause transfer with specified data + """ tr = self._file_transfers[(friend_number, file_number)] tr.pause(by_friend) t = FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_FRIEND'] if by_friend else FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_USER'] self.get_friend_by_number(friend_number).update_transfer_data(file_number, t) def resume_transfer(self, friend_number, file_number, by_friend=False): + """ + Resume transfer with specified data + """ self.get_friend_by_number(friend_number).update_transfer_data(file_number, FILE_TRANSFER_MESSAGE_STATUS['OUTGOING']) tr = self._file_transfers[(friend_number, file_number)] @@ -1001,7 +1007,7 @@ class Profile(Contact, Singleton): self._file_transfers[(friend.number, st.get_file_number())] = st tm = TransferMessage(MESSAGE_OWNER['ME'], time.time(), - FILE_TRANSFER_MESSAGE_STATUS['OUTGOING'], + FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_FRIEND'], # OUTGOING NOT STARTED len(data), 'toxygen_inline.png', friend.number, @@ -1021,7 +1027,7 @@ class Profile(Contact, Singleton): self._file_transfers[(friend_number, st.get_file_number())] = st tm = TransferMessage(MESSAGE_OWNER['ME'], time.time(), - FILE_TRANSFER_MESSAGE_STATUS['OUTGOING'], + FILE_TRANSFER_MESSAGE_STATUS['PAUSED_BY_FRIEND'], # OUTGOING NOT STARTED os.path.getsize(path), os.path.basename(path), friend_number, diff --git a/src/tox.py b/src/tox.py index ae0e819..8b87a28 100644 --- a/src/tox.py +++ b/src/tox.py @@ -221,7 +221,7 @@ class Tox(object): """ tox_err_bootstrap = c_int() result = Tox.libtoxcore.tox_add_tcp_relay(self._tox_pointer, c_char_p(address), c_uint16(port), - c_char_p(public_key), byref(tox_err_bootstrap)) + string_to_bin(public_key), byref(tox_err_bootstrap)) tox_err_bootstrap = tox_err_bootstrap.value if tox_err_bootstrap == TOX_ERR_BOOTSTRAP['OK']: return bool(result) diff --git a/src/toxav.py b/src/toxav.py index 479285d..29e3d52 100644 --- a/src/toxav.py +++ b/src/toxav.py @@ -344,7 +344,7 @@ class ToxAV(object): height Height (c_uint16) of the frame in pixels. y u - v Plane data (c_char_p). + v Plane data (POINTER(c_uint8)). The size of plane data is derived from width and height where Y = MAX(width, abs(ystride)) * height, U = MAX(width/2, abs(ustride)) * (height/2) and @@ -357,7 +357,7 @@ class ToxAV(object): user_data pointer (c_void_p) to user_data :param user_data: pointer (c_void_p) to user data """ - c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_uint16, c_uint16, c_char_p, c_char_p, c_char_p, c_int32, - c_int32, c_int32, c_void_p) + c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_uint16, c_uint16, POINTER(c_uint8), POINTER(c_uint8), + POINTER(c_uint8), c_int32, c_int32, c_int32, c_void_p) self.video_receive_frame_cb = c_callback(callback) ToxAV.libtoxav.toxav_callback_video_receive_frame(self._toxav_pointer, self.video_receive_frame_cb, user_data)