sending bug fix
This commit is contained in:
parent
9d5353640b
commit
976a6c139d
@ -1,5 +1,3 @@
|
||||
# TODO: add support of file transfers
|
||||
# TODO: add support of avatars
|
||||
from toxcore_enums_and_consts import TOX_FILE_KIND, TOX_FILE_CONTROL
|
||||
from os.path import basename, getsize, exists
|
||||
from os import remove
|
||||
@ -58,9 +56,13 @@ class SendTransfer(FileTransfer):
|
||||
self._file = open(path, 'rb')
|
||||
|
||||
def send_chunk(self, position, size):
|
||||
self._file.seek(position)
|
||||
data = self._file.read(size)
|
||||
return self._tox.file_send_chunk(self._friend_number, self._file_number, position, data)
|
||||
if size:
|
||||
self._file.seek(position)
|
||||
data = self._file.read(size)
|
||||
return self._tox.file_send_chunk(self._friend_number, self._file_number, position, data)
|
||||
else:
|
||||
self._file.close()
|
||||
self.state = TOX_FILE_TRANSFER_STATE['FINISHED']
|
||||
|
||||
|
||||
class SendAvatar(SendTransfer):
|
||||
|
@ -2,6 +2,7 @@ from PySide import QtGui
|
||||
from PySide.phonon import Phonon
|
||||
from util import curr_directory
|
||||
# TODO: make app icon active
|
||||
# TODO: add all sound notifications
|
||||
|
||||
|
||||
SOUND_NOTIFICATION = {
|
||||
@ -19,9 +20,10 @@ def tray_notification(title, text, tray):
|
||||
|
||||
|
||||
def sound_notification(t):
|
||||
# TODO: add other sound notifications
|
||||
if t == SOUND_NOTIFICATION['MESSAGE']:
|
||||
f = curr_directory() + '/sounds/message.wav'
|
||||
elif t == SOUND_NOTIFICATION['FILE_TRANSFER']:
|
||||
f = curr_directory() + '/sounds/file.wav'
|
||||
else:
|
||||
return
|
||||
m = Phonon.MediaSource(f)
|
||||
|
@ -313,7 +313,7 @@ class Profile(Contact, Singleton):
|
||||
self._screen = screen
|
||||
self._messages = screen.messages
|
||||
self._tox = tox
|
||||
self._file_transfers = {} # dict of file transfers
|
||||
self._file_transfers = {} # dict of file transfers. key - tuple (friend_number, file_number)
|
||||
settings = Settings.get_instance()
|
||||
self._show_online = settings['show_online_friends']
|
||||
screen.online_contacts.setChecked(self._show_online)
|
||||
@ -533,11 +533,12 @@ class Profile(Contact, Singleton):
|
||||
Save history to db
|
||||
"""
|
||||
print 'In save'
|
||||
if Settings.get_instance()['save_history']:
|
||||
for friend in self._friends:
|
||||
messages = friend.get_corr_for_saving()
|
||||
self._history.save_messages_to_db(friend.tox_id, messages)
|
||||
del self._history
|
||||
if hasattr(self, '_history'):
|
||||
if Settings.get_instance()['save_history']:
|
||||
for friend in self._friends:
|
||||
messages = friend.get_corr_for_saving()
|
||||
self._history.save_messages_to_db(friend.tox_id, messages)
|
||||
del self._history
|
||||
|
||||
def clear_history(self, num=None):
|
||||
if num is not None:
|
||||
@ -744,6 +745,8 @@ class Profile(Contact, Singleton):
|
||||
def outgoing_chunk(self, friend_number, file_number, position, size):
|
||||
transfer = self._file_transfers[(friend_number, file_number)]
|
||||
transfer.send_chunk(position, size)
|
||||
if transfer.state:
|
||||
del self._file_transfers[(friend_number, file_number)]
|
||||
|
||||
|
||||
def tox_factory(data=None, settings=None):
|
||||
|
Loading…
Reference in New Issue
Block a user