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