short fix

This commit is contained in:
ingvar1995 2016-06-07 12:27:58 +03:00
parent 7901aad3e7
commit bc248a9e30
2 changed files with 14 additions and 4 deletions

View file

@ -114,6 +114,10 @@ class History(object):
finally: finally:
db.close() db.close()
def update_messages(self, tox_id, count):
# TODO: mark all unsent messages to friend with specified public key :tox_id (except last :count) as sent
pass
def delete_messages(self, tox_id): def delete_messages(self, tox_id):
chdir(settings.ProfileHelper.get_path()) chdir(settings.ProfileHelper.get_path())
db = connect(self._name + '.hstr') db = connect(self._name + '.hstr')

View file

@ -450,7 +450,7 @@ class Profile(Contact, Singleton):
data = message.get_data() data = message.get_data()
self.create_message_item(data[0], self.create_message_item(data[0],
convert_time(data[2]), convert_time(data[2]),
friend.name if data[1] else self._name, friend.name if data[1] == MESSAGE_OWNER['FRIEND'] else self._name,
data[3]) data[3])
elif message.get_type() == 2: elif message.get_type() == 2:
item = self.create_file_transfer_item(message) item = self.create_file_transfer_item(message)
@ -506,6 +506,10 @@ class Profile(Contact, Singleton):
if self._active_friend + 1: if self._active_friend + 1:
self.set_active(self._active_friend) self.set_active(self._active_friend)
# -----------------------------------------------------------------------------------------------------------------
# Friend connection status callbacks
# -----------------------------------------------------------------------------------------------------------------
def friend_online(self, friend_number): def friend_online(self, friend_number):
for key in filter(lambda x: x[0] == friend_number, self._file_transfers.keys()): for key in filter(lambda x: x[0] == friend_number, self._file_transfers.keys()):
self.resume_transfer(key[0], key[1], True) self.resume_transfer(key[0], key[1], True)
@ -645,6 +649,8 @@ class Profile(Contact, Singleton):
if not self._history.friend_exists_in_db(friend.tox_id): if not self._history.friend_exists_in_db(friend.tox_id):
self._history.add_friend_to_db(friend.tox_id) self._history.add_friend_to_db(friend.tox_id)
self._history.save_messages_to_db(friend.tox_id, messages) self._history.save_messages_to_db(friend.tox_id, messages)
unsent_count = len(friend.unsent_messages())
self._history.update_messages(friend.tox_id, unsent_count)
self._history.save() self._history.save()
del self._history del self._history
@ -681,7 +687,7 @@ class Profile(Contact, Singleton):
data = message.get_data() data = message.get_data()
self.create_message_item(data[0], self.create_message_item(data[0],
convert_time(data[2]), convert_time(data[2]),
friend.name if data[1] else self._name, friend.name if data[1] == MESSAGE_OWNER['FRIEND'] else self._name,
data[3], data[3],
False) False)
elif message.get_type() == 2: elif message.get_type() == 2:
@ -1130,7 +1136,7 @@ class Profile(Contact, Singleton):
if type(transfer) is ReceiveAvatar: if type(transfer) is ReceiveAvatar:
self.get_friend_by_number(friend_number).load_avatar() self.get_friend_by_number(friend_number).load_avatar()
self.set_active(None) self.set_active(None)
elif type(transfer) is ReceiveToBuffer: elif type(transfer) is ReceiveToBuffer: # inline image
inline = InlineImage(transfer.get_data()) inline = InlineImage(transfer.get_data())
i = self.get_friend_by_number(friend_number).update_transfer_data(file_number, i = self.get_friend_by_number(friend_number).update_transfer_data(file_number,
FILE_TRANSFER_MESSAGE_STATUS['FINISHED'], FILE_TRANSFER_MESSAGE_STATUS['FINISHED'],
@ -1149,7 +1155,7 @@ class Profile(Contact, Singleton):
def outgoing_chunk(self, friend_number, file_number, position, size): def outgoing_chunk(self, friend_number, file_number, position, size):
""" """
Ougoing chubk Outgoing chunk
""" """
if (friend_number, file_number) in self._file_transfers: if (friend_number, file_number) in self._file_transfers:
transfer = self._file_transfers[(friend_number, file_number)] transfer = self._file_transfers[(friend_number, file_number)]