settings encryption fix and todo's

This commit is contained in:
ingvar1995 2016-06-06 13:05:11 +03:00
parent c114e9b6c3
commit 17a8d81486
3 changed files with 8 additions and 4 deletions

View File

@ -335,6 +335,7 @@ class Toxygen(object):
if __name__ == '__main__': if __name__ == '__main__':
# TODO: add tox: URI support
if len(sys.argv) == 1: if len(sys.argv) == 1:
toxygen = Toxygen() toxygen = Toxygen()
else: # path to profile else: # path to profile

View File

@ -506,12 +506,15 @@ class Profile(Contact, Singleton):
""" """
Friend with specified number quit Friend with specified number quit
""" """
# TODO: fix # TODO: fix and add full file resuming support
self.get_friend_by_number(friend_number).status = None self.get_friend_by_number(friend_number).status = None
self.friend_typing(friend_number, False) self.friend_typing(friend_number, False)
if friend_number in self._call: if friend_number in self._call:
self._call.finish_call(friend_number, True) self._call.finish_call(friend_number, True)
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()):
if type(self._file_transfers[key]) in (ReceiveAvatar, SendAvatar):
self._file_transfers[key].cancelled()
else:
self._file_transfers[key].pause(False) self._file_transfers[key].pause(False)
# ----------------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------------

View File

@ -16,7 +16,7 @@ class Settings(Singleton, dict):
self.path = ProfileHelper.get_path() + str(name) + '.json' self.path = ProfileHelper.get_path() + str(name) + '.json'
self.name = name self.name = name
if os.path.isfile(self.path): if os.path.isfile(self.path):
with open(self.path) as fl: with open(self.path, 'rb') as fl:
data = fl.read() data = fl.read()
inst = LibToxEncryptSave.get_instance() inst = LibToxEncryptSave.get_instance()
try: try:
@ -105,7 +105,7 @@ class Settings(Singleton, dict):
inst = LibToxEncryptSave.get_instance() inst = LibToxEncryptSave.get_instance()
if inst.has_password(): if inst.has_password():
text = inst.pass_encrypt(text) text = inst.pass_encrypt(text)
with open(self.path, 'w') as fl: with open(self.path, 'wb') as fl:
fl.write(text) fl.write(text)
def close(self): def close(self):