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):
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]
message.mark_as_sent()
except Exception as ex:

View file

@ -48,7 +48,7 @@ class History:
def delete_message(self, message):
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():
self._db.delete_message(contact.tox_id, message.id)
contact.delete_message(message.message_id)

View file

@ -224,7 +224,8 @@ class Messenger(tox_save.ToxSave):
return
message = util_ui.tr('User {} is now known as {}')
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)
# -----------------------------------------------------------------------------------------------------------------

View file

@ -645,7 +645,7 @@ class MainWindow(QtWidgets.QMainWindow):
self._contacts_manager.delete_friend(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)
@staticmethod
@ -656,12 +656,6 @@ class MainWindow(QtWidgets.QMainWindow):
def clear_history(self, 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):
tox_id = self._contacts_manager.friend_public_key(num)
if value:

View file

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

View file

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