sending updates
This commit is contained in:
parent
498545c3bf
commit
1bb145728f
@ -164,6 +164,19 @@ def file_recv_chunk(tox, friend_number, file_number, position, chunk, length, us
|
||||
file_number,
|
||||
position,
|
||||
chunk[:length] if length else None)
|
||||
|
||||
|
||||
def file_chunk_request(tox, friend_number, file_number, position, size, user_data):
|
||||
invoke_in_main_thread(Profile.get_instance().outgoing_chunck,
|
||||
friend_number,
|
||||
file_number,
|
||||
position,
|
||||
size)
|
||||
|
||||
|
||||
def file_recv_control(tox, friend_number, file_number, file_control, user_data):
|
||||
pass
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# Callbacks - initialization
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
@ -187,3 +200,5 @@ def init_callbacks(tox, window, tray):
|
||||
|
||||
tox.callback_file_recv(tox_file_recv(window, tray), 0)
|
||||
tox.callback_file_recv_chunk(file_recv_chunk, 0)
|
||||
tox.callback_file_chunk_request(file_chunk_request, 0)
|
||||
tox.callback_file_recv_control(file_recv_control, 0)
|
||||
|
@ -280,7 +280,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
if self.profile.is_active_online(): # active friend exists and online
|
||||
name = QtGui.QFileDialog.getOpenFileName(self, 'Choose file')
|
||||
if name:
|
||||
self.profile.send_file(name)
|
||||
self.profile.send_file(name[0])
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# Functions which called when user open context menu in friends list
|
||||
|
@ -704,7 +704,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)
|
||||
rt = ReceiveTransfer(Settings.get_default_path() + file_name, self._tox, friend_number, file_number)
|
||||
self._file_transfers[(friend_number, file_number)] = rt
|
||||
self._tox.file_control(friend_number, file_number, TOX_FILE_CONTROL['RESUME'])
|
||||
|
||||
@ -726,7 +726,7 @@ class Profile(Contact, Singleton):
|
||||
self._tox.file_control(friend_number, file_number, TOX_FILE_CONTROL['CANCEL']) # ignore file
|
||||
else: # get new avatar
|
||||
path = ProfileHelper.get_path() + '/avatars/{}.png'.format(friend.tox_id)
|
||||
rt = ReceiveTransfer(path, self._tox, friend_number)
|
||||
rt = ReceiveTransfer(path, self._tox, friend_number, file_number)
|
||||
self._file_transfers[(friend_number, file_number)] = rt
|
||||
self._tox.file_control(friend_number, file_number, TOX_FILE_CONTROL['RESUME'])
|
||||
|
||||
@ -742,7 +742,13 @@ class Profile(Contact, Singleton):
|
||||
pass
|
||||
|
||||
def send_file(self, path):
|
||||
pass
|
||||
friend_number = self.get_active_number()
|
||||
st = SendTransfer(path, self._tox, friend_number)
|
||||
self._file_transfers[(friend_number, st.get_file_number())] = st
|
||||
|
||||
def outgoing_chunk(self, friend_number, file_number, position, size):
|
||||
transfer = self._file_transfers[(friend_number, file_number)]
|
||||
transfer.send_chunk(position, size)
|
||||
|
||||
|
||||
def tox_factory(data=None, settings=None):
|
||||
|
Loading…
Reference in New Issue
Block a user