This commit is contained in:
emdee 2023-12-10 04:43:53 +00:00
parent 4109c822b3
commit ba013b6a81
7 changed files with 21 additions and 19 deletions

View File

@ -979,7 +979,7 @@ class App:
self._ms.log_console() self._ms.log_console()
def _test_main(self): def _test_main(self):
from toxygen_wrapper.tests_wrapper import main as tests_main from toxygen_wrapper.wrapper_tests.tests_wrapper import main as tests_main
LOG.debug("_test_main") LOG.debug("_test_main")
if not self._tox: return if not self._tox: return
title = 'Extended Test Suite' title = 'Extended Test Suite'

View File

@ -105,7 +105,7 @@ class AV(common.tox_save.ToxAvSave):
self._toxav.call(friend_number, self._toxav.call(friend_number,
self._audio_krate_tox_audio if audio else 0, self._audio_krate_tox_audio if audio else 0,
self._audio_krate_tox_video if video else 0) self._audio_krate_tox_video if video else 0)
except ArgumentError as e: except Exception as e:
LOG.warn(f"_toxav.call already has {friend_number}") LOG.warn(f"_toxav.call already has {friend_number}")
return return
self._calls[friend_number] = Call(audio, video) self._calls[friend_number] = Call(audio, video)
@ -114,7 +114,7 @@ class AV(common.tox_save.ToxAvSave):
def accept_call(self, friend_number, audio_enabled, video_enabled): def accept_call(self, friend_number, audio_enabled, video_enabled):
# obsolete # obsolete
return call_accept_call(self, friend_number, audio_enabled, video_enabled) return self.call_accept_call(friend_number, audio_enabled, video_enabled)
def call_accept_call(self, friend_number, audio_enabled, video_enabled): def call_accept_call(self, friend_number, audio_enabled, video_enabled):
LOG.debug(f"call_accept_call from {friend_number} {self._running}" + LOG.debug(f"call_accept_call from {friend_number} {self._running}" +

View File

@ -132,10 +132,11 @@ class Contact(basecontact.BaseContact):
""" """
:return list of unsent messages for saving :return list of unsent messages for saving
""" """
message = list(filter(lambda m: m.author is not None # and m.tox_message_id == tox_message_id,
messages = filter(lambda m: m.author is not None
and m.author.type == MESSAGE_AUTHOR['NOT_SENT'] and m.author.type == MESSAGE_AUTHOR['NOT_SENT']
and m.tox_message_id == tox_message_id, self._corr)
self._corr))[0] # was message = list(...)[0]
return list(messages) return list(messages)
def mark_as_sent(self, tox_message_id): def mark_as_sent(self, tox_message_id):

View File

@ -34,7 +34,7 @@ class ContactProvider(tox_save.ToxSave):
try: try:
public_key = self._tox.friend_get_public_key(friend_number) public_key = self._tox.friend_get_public_key(friend_number)
except Exception as e: except Exception as e:
LOG_WARN(f"get_friend_by_number NO {friend_number} {e} ") LOG_WARN(f"CP.get_friend_by_number NO {friend_number} {e} ")
return None return None
return self.get_friend_by_public_key(public_key) return self.get_friend_by_public_key(public_key)
@ -44,7 +44,7 @@ class ContactProvider(tox_save.ToxSave):
return friend return friend
friend = self._friend_factory.create_friend_by_public_key(public_key) friend = self._friend_factory.create_friend_by_public_key(public_key)
self._add_to_cache(public_key, friend) self._add_to_cache(public_key, friend)
LOG_INFO(f"get_friend_by_public_key ADDED {friend} ") LOG_INFO(f"CP.get_friend_by_public_key ADDED {friend} ")
return friend return friend
@ -52,7 +52,7 @@ class ContactProvider(tox_save.ToxSave):
try: try:
friend_numbers = self._tox.self_get_friend_list() friend_numbers = self._tox.self_get_friend_list()
except Exception as e: except Exception as e:
LOG_WARN(f"get_all_friends NO {friend_numbers} {e} ") LOG_WARN(f"CP.get_all_friends NO {friend_numbers} {e} ")
return None return None
friends = map(lambda n: self.get_friend_by_number(n), friend_numbers) friends = map(lambda n: self.get_friend_by_number(n), friend_numbers)
@ -71,11 +71,11 @@ class ContactProvider(tox_save.ToxSave):
# failsafe in case there are bogus None groups? # failsafe in case there are bogus None groups?
fgroups = list(filter(lambda x: x, groups)) fgroups = list(filter(lambda x: x, groups))
if len(fgroups) != len_groups: if len(fgroups) != len_groups:
LOG_WARN(f"are there are bogus None groups in libtoxcore? {len(fgroups)} != {len_groups}") LOG_WARN(f"CP.are there are bogus None groups in libtoxcore? {len(fgroups)} != {len_groups}")
for group_num in group_numbers: for group_num in group_numbers:
group = self.get_group_by_number(group_num) group = self.get_group_by_number(group_num)
if group is None: if group is None:
LOG_ERROR(f"there are bogus None groups in libtoxcore {group_num}!") LOG_ERROR(f"There are bogus None groups in libtoxcore {group_num}!")
# fixme: do something # fixme: do something
groups = fgroups groups = fgroups
return groups return groups
@ -83,7 +83,7 @@ class ContactProvider(tox_save.ToxSave):
def get_group_by_number(self, group_number): def get_group_by_number(self, group_number):
group = None group = None
try: try:
LOG_INFO(f"CP.group_get_number {group_number} ") LOG_INFO(f"CP.CP.group_get_number {group_number} ")
# original code # original code
chat_id = self._tox.group_get_chat_id(group_number) chat_id = self._tox.group_get_chat_id(group_number)
if chat_id is None: if chat_id is None:
@ -91,16 +91,16 @@ class ContactProvider(tox_save.ToxSave):
elif chat_id == '-1': elif chat_id == '-1':
LOG_ERROR(f"get_group_by_number <0 chat_id ({group_number})") LOG_ERROR(f"get_group_by_number <0 chat_id ({group_number})")
else: else:
LOG_INFO(f"group_get_number {group_number} {chat_id}") LOG_INFO(f"CP.group_get_number {group_number} {chat_id}")
group = self.get_group_by_chat_id(chat_id) group = self.get_group_by_chat_id(chat_id)
if group is None or group == '-1': if group is None or group == '-1':
LOG_WARN(f"get_group_by_number leaving {group} ({group_number})") LOG_WARN(f"CP.get_group_by_number leaving {group} ({group_number})")
#? iRet = self._tox.group_leave(group_number) #? iRet = self._tox.group_leave(group_number)
# invoke in main thread? # invoke in main thread?
# self._contacts_manager.delete_group(group_number) # self._contacts_manager.delete_group(group_number)
return group return group
except Exception as e: except Exception as e:
LOG_WARN(f"group_get_number {group_number} {e}") LOG_WARN(f"CP.group_get_number {group_number} {e}")
return None return None
def get_group_by_chat_id(self, chat_id): def get_group_by_chat_id(self, chat_id):

View File

@ -78,6 +78,9 @@ class FileTransfer:
def get_file_id(self): def get_file_id(self):
return self._file_id return self._file_id
# WTF
def get_file_id(self):
return self._tox.file_get_file_id(self._friend_number, self._file_number)
file_id = property(get_file_id) file_id = property(get_file_id)
@ -112,9 +115,6 @@ class FileTransfer:
if self._tox.file_control(self._friend_number, self._file_number, control): if self._tox.file_control(self._friend_number, self._file_number, control):
self.set_state(control) self.set_state(control)
def get_file_id(self):
return self._tox.file_get_file_id(self._friend_number, self._file_number)
def _signal(self): def _signal(self):
percentage = self._done / self._size if self._size else 0 percentage = self._done / self._size if self._size else 0
if self._creation_time is None or not percentage: if self._creation_time is None or not percentage:

View File

@ -3,7 +3,7 @@ import os
from PyQt5 import uic from PyQt5 import uic
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5 import QtCore, QtGui, QtWidgets
from qtpy.QtGui import (QColor, QTextCharFormat, QFont, QSyntaxHighlighter) from qtpy.QtGui import (QColor, QTextCharFormat, QFont, QSyntaxHighlighter, QFontMetrics)
from ui.contact_items import * from ui.contact_items import *
from ui.widgets import MultilineEdit from ui.widgets import MultilineEdit

1
toxygen/wrapper_tests Symbolic link
View File

@ -0,0 +1 @@
../../toxygen_wrapper.git/wrapper_tests/