bug fixes

This commit is contained in:
ingvar1995 2018-09-13 23:04:22 +03:00
parent 5e788a543d
commit 9a58082496
7 changed files with 24 additions and 69 deletions

View File

@ -107,8 +107,8 @@ class App:
self._tray.hide()
self._save_profile()
self._settings.close()
self._unset_callbacks()
self._kill_toxav()
self._kill_tox()
del self._tox
# -----------------------------------------------------------------------------------------------------------------
@ -320,8 +320,8 @@ class App:
self._stop_threads(False)
data = self._tox.get_savedata()
self._save_profile(data)
self._unset_callbacks()
self._kill_toxav()
self._kill_tox()
del self._tox
# create new tox instance
self._tox = self._create_tox(data)
@ -410,9 +410,6 @@ class App:
self._calls_manager, self._file_transfer_handler, self._ms, self._tray,
self._messenger, self._groups_service, self._contacts_provider)
def _unset_callbacks(self):
callbacks.unset_callbacks(self._tox)
def _init_profile(self):
if not self._profile.has_avatar():
self._profile.reset_avatar(self._settings['identicons'])
@ -420,3 +417,6 @@ class App:
def _kill_toxav(self):
self._calls_manager.set_toxav(None)
self._tox.AV.kill()
def _kill_tox(self):
self._tox.kill()

View File

@ -29,7 +29,7 @@ SHOW_PROGRESS_BAR = (0, 1, 4)
def is_inline(file_name):
allowed_inlines = ('toxygen_inline.png', 'utox-inline.png', 'sticker.png')
return file_name in allowed_inlines or file_name.startswith('qTox_Screenshot_')
return file_name in allowed_inlines or file_name.startswith('qTox_Image_')
class FileTransfer:

View File

@ -257,7 +257,7 @@ class FileTransfersHandler(ToxSave):
elif not size:
friend.reset_avatar(self._settings['identicons'])
def _send_avatar_to_contacts(self):
def _send_avatar_to_contacts(self, _):
friends = self._get_all_friends()
for friend in friends:
self.send_avatar(friend.number)
@ -286,13 +286,13 @@ class FileTransfersHandler(ToxSave):
path, file_name = os.path.split(path)
new_file_name, i = file_name, 1
if not from_position:
while os.path.isfile(path + '/' + new_file_name): # file with same name already exists
while os.path.isfile(join_path(path, new_file_name)): # file with same name already exists
if '.' in file_name: # has extension
d = file_name.rindex('.')
else: # no extension
d = len(file_name)
new_file_name = file_name[:d] + ' ({})'.format(i) + file_name[d:]
i += 1
path = os.path.join(path, new_file_name)
path = join_path(path, new_file_name)
return path

View File

@ -224,7 +224,7 @@ class Messenger(tox_save.ToxSave):
return
message = util_ui.tr('User {} is now known as {}')
message = message.format(old_name, new_name)
if self._contacts_manager.is_friend_active(friend.number):
if not self._contacts_manager.is_friend_active(friend.number):
friend.actions = True
self._add_info_message(friend.number, message)
@ -236,14 +236,14 @@ class Messenger(tox_save.ToxSave):
def _split_message(message):
messages = []
while len(message) > TOX_MAX_MESSAGE_LENGTH:
size = TOX_MAX_MESSAGE_LENGTH * 4 / 5
size = TOX_MAX_MESSAGE_LENGTH * 4 // 5
last_part = message[size:TOX_MAX_MESSAGE_LENGTH]
if ' ' in last_part:
index = last_part.index(' ')
elif ',' in last_part:
index = last_part.index(',')
elif '.' in last_part:
index = last_part.index('.')
if b' ' in last_part:
index = last_part.index(b' ')
elif b',' in last_part:
index = last_part.index(b',')
elif b'.' in last_part:
index = last_part.index(b'.')
else:
index = TOX_MAX_MESSAGE_LENGTH - size - 1
index += size + 1

View File

@ -604,50 +604,3 @@ def init_callbacks(tox, profile, settings, plugin_loader, contacts_manager,
tox.callback_group_password(group_password(contacts_provider), 0)
tox.callback_group_peer_limit(group_peer_limit(contacts_provider), 0)
tox.callback_group_privacy_state(group_privacy_state(contacts_provider), 0)
def unset_callbacks(tox):
# self callbacks
tox.callback_self_connection_status(0)
# friend callbacks
tox.callback_friend_status(0)
tox.callback_friend_message(0)
tox.callback_friend_connection_status(0)
tox.callback_friend_name(0)
tox.callback_friend_status_message(0)
tox.callback_friend_request(0)
tox.callback_friend_typing(0)
tox.callback_friend_read_receipt(0)
# file transfer
tox.callback_file_recv(0)
tox.callback_file_recv_chunk(0)
tox.callback_file_chunk_request(0)
tox.callback_file_recv_control(0)
# av
toxav = tox.AV
toxav.callback_call_state(0, 0)
toxav.callback_call(0, 0)
toxav.callback_audio_receive_frame(0, 0)
toxav.callback_video_receive_frame(0, 0)
# custom packets
tox.callback_friend_lossless_packet(0)
tox.callback_friend_lossy_packet(0)
# gc callbacks
tox.callback_group_message(0, 0)
tox.callback_group_private_message(0, 0)
tox.callback_group_invite(0, 0)
tox.callback_group_self_join(0, 0)
tox.callback_group_peer_join(0, 0)
tox.callback_group_peer_exit(0, 0)
tox.callback_group_peer_name(0, 0)
tox.callback_group_peer_status(0, 0)
tox.callback_group_topic(0, 0)
tox.callback_group_moderation(0, 0)
tox.callback_group_password(0, 0)
tox.callback_group_peer_limit(0, 0)
tox.callback_group_privacy_state(0, 0)

View File

@ -59,8 +59,9 @@ class Tox:
self._tox_pointer = tox_pointer
else:
tox_err_new = c_int()
Tox.libtoxcore.tox_new.restype = POINTER(c_void_p)
self._tox_pointer = Tox.libtoxcore.tox_new(tox_options, byref(tox_err_new))
f = Tox.libtoxcore.tox_new
f.restype = POINTER(c_void_p)
self._tox_pointer = f(tox_options, byref(tox_err_new))
tox_err_new = tox_err_new.value
if tox_err_new == TOX_ERR_NEW['NULL']:
raise ArgumentError('One of the arguments to the function was NULL when it was not expected.')
@ -120,7 +121,7 @@ class Tox:
self.AV = ToxAV(self._tox_pointer)
def __del__(self):
def kill(self):
del self.AV
Tox.libtoxcore.tox_kill(self._tox_pointer)

View File

@ -24,8 +24,9 @@ class ToxAV:
"""
self.libtoxav = LibToxAV()
toxav_err_new = c_int()
self.libtoxav.toxav_new.restype = POINTER(c_void_p)
self._toxav_pointer = self.libtoxav.toxav_new(tox_pointer, byref(toxav_err_new))
f = self.libtoxav.toxav_new
f.restype = POINTER(c_void_p)
self._toxav_pointer = f(tox_pointer, byref(toxav_err_new))
toxav_err_new = toxav_err_new.value
if toxav_err_new == TOXAV_ERR_NEW['NULL']:
raise ArgumentError('One of the arguments to the function was NULL when it was not expected.')