various fixes

This commit is contained in:
ingvar1995 2018-08-09 23:30:05 +03:00
parent 318c9c942d
commit 4ecf666b2f
6 changed files with 21 additions and 23 deletions

View File

@ -135,7 +135,7 @@ class Contact(basecontact.BaseContact):
def mark_as_sent(self, tox_message_id): def mark_as_sent(self, tox_message_id):
try: try:
message = list(filter(lambda m: m.author.type == MESSAGE_AUTHOR['NOT_SENT'] message = list(filter(lambda m: m.author is not None and m.author.type == MESSAGE_AUTHOR['NOT_SENT']
and m.tox_message_id == tox_message_id, self._corr))[0] and m.tox_message_id == tox_message_id, self._corr))[0]
message.mark_as_sent() message.mark_as_sent()
except Exception as ex: except Exception as ex:

View File

@ -48,7 +48,7 @@ class History:
def delete_message(self, message): def delete_message(self, message):
contact = self._contacts_manager.get_curr_contact() contact = self._contacts_manager.get_curr_contact()
if message.type in (MESSAGE_TYPE['NORMAL'], MESSAGE_TYPE['ACTION']): if message.type in (MESSAGE_TYPE['TEXT'], MESSAGE_TYPE['ACTION']):
if message.is_saved(): if message.is_saved():
self._db.delete_message(contact.tox_id, message.id) self._db.delete_message(contact.tox_id, message.id)
contact.delete_message(message.message_id) contact.delete_message(message.message_id)

View File

@ -224,7 +224,8 @@ class Messenger(tox_save.ToxSave):
return return
message = util_ui.tr('User {} is now known as {}') message = util_ui.tr('User {} is now known as {}')
message = message.format(old_name, new_name) message = message.format(old_name, new_name)
friend.actions = True if self._contacts_manager.is_friend_active(friend.number):
friend.actions = True
self._add_info_message(friend.number, message) self._add_info_message(friend.number, message)
# ----------------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------------

View File

@ -645,7 +645,7 @@ class MainWindow(QtWidgets.QMainWindow):
self._contacts_manager.delete_friend(num) self._contacts_manager.delete_friend(num)
def block_friend(self, num): def block_friend(self, num):
friend = self._contacts_managere.get_contact(num) friend = self._contacts_manager.get_contact(num)
self._contacts_manager.block_user(friend.tox_id) self._contacts_manager.block_user(friend.tox_id)
@staticmethod @staticmethod
@ -656,12 +656,6 @@ class MainWindow(QtWidgets.QMainWindow):
def clear_history(self, num): def clear_history(self, num):
self._contacts_manager.clear_history(num) self._contacts_manager.clear_history(num)
def leave_gc(self, num):
self.profile.leave_gc(num)
def set_title(self, num):
self.profile.set_title(num)
def auto_accept(self, num, value): def auto_accept(self, num, value):
tox_id = self._contacts_manager.friend_public_key(num) tox_id = self._contacts_manager.friend_public_key(num)
if value: if value:

View File

@ -165,5 +165,6 @@ def is_re_valid(regex):
return True return True
@cached
def get_platform(): def get_platform():
return platform.system() return platform.system()

View File

@ -1,4 +1,3 @@
from platform import system
from ctypes import CDLL from ctypes import CDLL
import utils.util as util import utils.util as util
@ -6,16 +5,17 @@ import utils.util as util
class LibToxCore: class LibToxCore:
def __init__(self): def __init__(self):
if system() == 'Windows': platform = util.get_platform()
self._libtoxcore = CDLL(util.curr_directory() + '/libs/libtox.dll') if platform == 'Windows':
elif system() == 'Darwin': self._libtoxcore = CDLL(util.join_path(util.get_libs_directory(), 'libtox.dll'))
elif platform == 'Darwin':
self._libtoxcore = CDLL('libtoxcore.dylib') self._libtoxcore = CDLL('libtoxcore.dylib')
else: else:
# libtoxcore and libsodium must be installed in your os # libtoxcore and libsodium must be installed in your os
try: try:
self._libtoxcore = CDLL('libtoxcore.so') self._libtoxcore = CDLL('libtoxcore.so')
except: except:
self._libtoxcore = CDLL(util.curr_directory() + '/libs/libtoxcore.so') self._libtoxcore = CDLL(util.join_path(util.get_libs_directory(), 'libtoxcore.so'))
def __getattr__(self, item): def __getattr__(self, item):
return self._libtoxcore.__getattr__(item) return self._libtoxcore.__getattr__(item)
@ -24,17 +24,18 @@ class LibToxCore:
class LibToxAV: class LibToxAV:
def __init__(self): def __init__(self):
if system() == 'Windows': platform = util.get_platform()
if platform == 'Windows':
# on Windows av api is in libtox.dll # on Windows av api is in libtox.dll
self._libtoxav = CDLL(util.curr_directory() + '/libs/libtox.dll') self._libtoxav = CDLL(util.join_path(util.get_libs_directory(), 'libtox.dll'))
elif system() == 'Darwin': elif platform == 'Darwin':
self._libtoxav = CDLL('libtoxcore.dylib') self._libtoxav = CDLL('libtoxcore.dylib')
else: else:
# /usr/lib/libtoxcore.so must exists # /usr/lib/libtoxcore.so must exists
try: try:
self._libtoxav = CDLL('libtoxcore.so') self._libtoxav = CDLL('libtoxcore.so')
except: except:
self._libtoxav = CDLL(util.curr_directory() + '/libs/libtoxcore.so') self._libtoxav = CDLL(util.join_path(util.get_libs_directory(), 'libtoxcore.so'))
def __getattr__(self, item): def __getattr__(self, item):
return self._libtoxav.__getattr__(item) return self._libtoxav.__getattr__(item)
@ -43,17 +44,18 @@ class LibToxAV:
class LibToxEncryptSave: class LibToxEncryptSave:
def __init__(self): def __init__(self):
if system() == 'Windows': platform = util.get_platform()
if platform == 'Windows':
# on Windows profile encryption api is in libtox.dll # on Windows profile encryption api is in libtox.dll
self._lib_tox_encrypt_save = CDLL(util.curr_directory() + '/libs/libtox.dll') self._lib_tox_encrypt_save = CDLL(util.join_path(util.get_libs_directory(), 'libtox.dll'))
elif system() == 'Darwin': elif platform == 'Darwin':
self._lib_tox_encrypt_save = CDLL('libtoxcore.dylib') self._lib_tox_encrypt_save = CDLL('libtoxcore.dylib')
else: else:
# /usr/lib/libtoxcore.so must exists # /usr/lib/libtoxcore.so must exists
try: try:
self._lib_tox_encrypt_save = CDLL('libtoxcore.so') self._lib_tox_encrypt_save = CDLL('libtoxcore.so')
except: except:
self._lib_tox_encrypt_save = CDLL(util.curr_directory() + '/libs/libtoxcore.so') self._lib_tox_encrypt_save = CDLL(util.join_path(util.get_libs_directory(), 'libtoxcore.so'))
def __getattr__(self, item): def __getattr__(self, item):
return self._lib_tox_encrypt_save.__getattr__(item) return self._lib_tox_encrypt_save.__getattr__(item)