fixes
This commit is contained in:
parent
99136cd4e3
commit
68f28fdac5
39 changed files with 219 additions and 285 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
||||||
|
.pylint.err
|
||||||
|
.pylint.out
|
||||||
*.pyc
|
*.pyc
|
||||||
*.pyo
|
*.pyo
|
||||||
toxygen/toxcore
|
toxygen/toxcore
|
||||||
|
@ -9,6 +11,7 @@ tests/avatars
|
||||||
toxygen/libs
|
toxygen/libs
|
||||||
.idea
|
.idea
|
||||||
*~
|
*~
|
||||||
|
#*
|
||||||
*.iml
|
*.iml
|
||||||
*.so
|
*.so
|
||||||
*.log
|
*.log
|
||||||
|
|
7
.rsync.sh
Normal file
7
.rsync.sh
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
find * -name \*.py | xargs grep -l '[ ]*$' | xargs sed -i -e 's/[ ]*$//'
|
||||||
|
rsync "$@" -vax --include \*.py \
|
||||||
|
--exclude Toxygen.egg-info --exclude build \
|
||||||
|
--exclude \*.pyc --exclude .pyl\* --exclude \*~ \
|
||||||
|
./ ../toxygen.git/|grep -v /$
|
62
setup.py
62
setup.py
|
@ -1,45 +1,15 @@
|
||||||
from setuptools import setup
|
|
||||||
from setuptools.command.install import install
|
|
||||||
from platform import system
|
|
||||||
from subprocess import call
|
|
||||||
import main
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from utils.util import curr_directory, join_path
|
from setuptools import setup
|
||||||
|
from setuptools.command.install import install
|
||||||
|
|
||||||
|
version = '1.0.0'
|
||||||
|
|
||||||
version = main.__version__ + '.0'
|
MODULES = ['argparse', 'PyQt5', 'PyAudio', 'numpy', 'opencv-python', 'cv2',
|
||||||
|
'pydenticon', 'pyqtconsole', 'toxygen_wrapper'] # qweechat
|
||||||
|
|
||||||
if system() == 'Windows':
|
|
||||||
MODULES = ['PyQt5', 'PyAudio', 'numpy', 'opencv-python', 'pydenticon', 'cv2']
|
|
||||||
else:
|
|
||||||
MODULES = ['pydenticon']
|
|
||||||
MODULES.append('PyQt5')
|
|
||||||
try:
|
|
||||||
import pyaudio
|
|
||||||
except ImportError:
|
|
||||||
MODULES.append('PyAudio')
|
|
||||||
try:
|
|
||||||
import numpy
|
|
||||||
except ImportError:
|
|
||||||
MODULES.append('numpy')
|
|
||||||
try:
|
|
||||||
import cv2
|
|
||||||
except ImportError:
|
|
||||||
MODULES.append('opencv-python')
|
|
||||||
try:
|
|
||||||
import coloredlogs
|
|
||||||
except ImportError:
|
|
||||||
MODULES.append('coloredlogs')
|
|
||||||
try:
|
|
||||||
import pyqtconsole
|
|
||||||
except ImportError:
|
|
||||||
MODULES.append('pyqtconsole')
|
|
||||||
|
|
||||||
|
|
||||||
def get_packages():
|
def get_packages():
|
||||||
directory = join_path(curr_directory(__file__), 'toxygen')
|
directory = os.path.join(os.path.dirname(__file__), 'tox_wrapper')
|
||||||
for root, dirs, files in os.walk(directory):
|
for root, dirs, files in os.walk(directory):
|
||||||
packages = map(lambda d: 'toxygen.' + d, dirs)
|
packages = map(lambda d: 'toxygen.' + d, dirs)
|
||||||
packages = ['toxygen'] + list(packages)
|
packages = ['toxygen'] + list(packages)
|
||||||
|
@ -50,22 +20,6 @@ class InstallScript(install):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
install.run(self)
|
install.run(self)
|
||||||
try:
|
|
||||||
if system() != 'Windows':
|
|
||||||
call(["toxygen", "--clean"])
|
|
||||||
except:
|
|
||||||
try:
|
|
||||||
params = list(filter(lambda x: x.startswith('--prefix='), sys.argv))
|
|
||||||
if params:
|
|
||||||
path = params[0][len('--prefix='):]
|
|
||||||
if path[-1] not in ('/', '\\'):
|
|
||||||
path += '/'
|
|
||||||
path += 'bin/toxygen'
|
|
||||||
if system() != 'Windows':
|
|
||||||
call([path, "--clean"])
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
setup(name='Toxygen',
|
setup(name='Toxygen',
|
||||||
version=version,
|
version=version,
|
||||||
|
@ -81,13 +35,13 @@ setup(name='Toxygen',
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Programming Language :: Python :: 3 :: Only',
|
'Programming Language :: Python :: 3 :: Only',
|
||||||
'Programming Language :: Python :: 3.9',
|
'Programming Language :: Python :: 3.11',
|
||||||
],
|
],
|
||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts': ['toxygen=toxygen.main:main']
|
'console_scripts': ['toxygen=toxygen.main:main']
|
||||||
},
|
},
|
||||||
cmdclass={
|
cmdclass={
|
||||||
'install': InstallScript
|
'install': InstallScript,
|
||||||
},
|
},
|
||||||
zip_safe=False
|
zip_safe=False
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import traceback
|
||||||
from random import shuffle
|
from random import shuffle
|
||||||
import threading
|
import threading
|
||||||
from time import sleep, time
|
from time import sleep, time
|
||||||
|
from copy import deepcopy
|
||||||
|
|
||||||
from gevent import monkey; monkey.patch_all(); del monkey # noqa
|
from gevent import monkey; monkey.patch_all(); del monkey # noqa
|
||||||
import gevent
|
import gevent
|
||||||
|
@ -36,7 +37,7 @@ from middleware import threads
|
||||||
import middleware.callbacks as callbacks
|
import middleware.callbacks as callbacks
|
||||||
import updater.updater as updater
|
import updater.updater as updater
|
||||||
from middleware.tox_factory import tox_factory
|
from middleware.tox_factory import tox_factory
|
||||||
import wrapper.toxencryptsave as tox_encrypt_save
|
import tox_wrapper.toxencryptsave as tox_encrypt_save
|
||||||
import user_data.toxes
|
import user_data.toxes
|
||||||
from user_data import settings
|
from user_data import settings
|
||||||
from user_data.settings import get_user_config_path, merge_args_into_settings
|
from user_data.settings import get_user_config_path, merge_args_into_settings
|
||||||
|
@ -74,7 +75,7 @@ from ui.widgets_factory import WidgetsFactory
|
||||||
from user_data.backup_service import BackupService
|
from user_data.backup_service import BackupService
|
||||||
import styles.style # TODO: dynamic loading
|
import styles.style # TODO: dynamic loading
|
||||||
|
|
||||||
import wrapper_tests.support_testing as ts
|
import tox_wrapper.tests.support_testing as ts
|
||||||
|
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
|
@ -147,7 +148,6 @@ sSTYLE = """
|
||||||
.QTextSingleLine {font-family Courier; weight: 75; }
|
.QTextSingleLine {font-family Courier; weight: 75; }
|
||||||
.QToolBar { font-weight: bold; }
|
.QToolBar { font-weight: bold; }
|
||||||
"""
|
"""
|
||||||
from copy import deepcopy
|
|
||||||
class App:
|
class App:
|
||||||
|
|
||||||
def __init__(self, version, oArgs):
|
def __init__(self, version, oArgs):
|
||||||
|
@ -170,7 +170,8 @@ class App:
|
||||||
self._app = self._settings = self._profile_manager = None
|
self._app = self._settings = self._profile_manager = None
|
||||||
self._plugin_loader = self._messenger = None
|
self._plugin_loader = self._messenger = None
|
||||||
self._tox = self._ms = self._init = self._main_loop = self._av_loop = None
|
self._tox = self._ms = self._init = self._main_loop = self._av_loop = None
|
||||||
self._uri = self._toxes = self._tray = self._file_transfer_handler = self._contacts_provider = None
|
self._uri = self._toxes = self._tray = None
|
||||||
|
self._file_transfer_handler = self._contacts_provider = None
|
||||||
self._friend_factory = self._calls_manager = None
|
self._friend_factory = self._calls_manager = None
|
||||||
self._contacts_manager = self._smiley_loader = None
|
self._contacts_manager = self._smiley_loader = None
|
||||||
self._group_peer_factory = self._tox_dns = self._backup_service = None
|
self._group_peer_factory = self._tox_dns = self._backup_service = None
|
||||||
|
@ -223,8 +224,6 @@ class App:
|
||||||
|
|
||||||
self._load_app_styles()
|
self._load_app_styles()
|
||||||
if self._args.language != 'English':
|
if self._args.language != 'English':
|
||||||
# > /var/local/src/toxygen/toxygen/app.py(303)_load_app_translations()->None
|
|
||||||
# -> self._app.translator = translator
|
|
||||||
# (Pdb) Fatal Python error: Segmentation fault
|
# (Pdb) Fatal Python error: Segmentation fault
|
||||||
self._load_app_translations()
|
self._load_app_translations()
|
||||||
self._create_dependencies()
|
self._create_dependencies()
|
||||||
|
@ -270,7 +269,7 @@ class App:
|
||||||
LOG.debug("quit")
|
LOG.debug("quit")
|
||||||
self._stop_app()
|
self._stop_app()
|
||||||
|
|
||||||
# failsafe: segfaults on exit
|
# failsafe: segfaults on exit - maybe it's Qt
|
||||||
if hasattr(self, '_tox'):
|
if hasattr(self, '_tox'):
|
||||||
if self._tox and hasattr(self._tox, 'kill'):
|
if self._tox and hasattr(self._tox, 'kill'):
|
||||||
LOG.debug(f"quit: Killing {self._tox}")
|
LOG.debug(f"quit: Killing {self._tox}")
|
||||||
|
@ -739,7 +738,7 @@ class App:
|
||||||
self._groups_service,
|
self._groups_service,
|
||||||
history,
|
history,
|
||||||
self._contacts_provider)
|
self._contacts_provider)
|
||||||
if False:
|
if True: # try it
|
||||||
self._tray = tray.init_tray(self._profile,
|
self._tray = tray.init_tray(self._profile,
|
||||||
self._settings,
|
self._settings,
|
||||||
self._ms, self._toxes)
|
self._ms, self._toxes)
|
||||||
|
@ -754,7 +753,7 @@ class App:
|
||||||
self._calls_manager,
|
self._calls_manager,
|
||||||
self._groups_service, self._toxes, self)
|
self._groups_service, self._toxes, self)
|
||||||
|
|
||||||
if False:
|
if True: # try it
|
||||||
# the tray icon does not die with the app
|
# the tray icon does not die with the app
|
||||||
self._tray.show()
|
self._tray.show()
|
||||||
self._ms.show()
|
self._ms.show()
|
||||||
|
@ -979,7 +978,7 @@ class App:
|
||||||
self._ms.log_console()
|
self._ms.log_console()
|
||||||
|
|
||||||
def _test_main(self):
|
def _test_main(self):
|
||||||
from toxygen_wrapper.wrapper_tests.tests_wrapper import main as tests_main
|
from toxygen_tox_wrapper.tox_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'
|
||||||
|
|
|
@ -4,13 +4,16 @@ import time
|
||||||
import threading
|
import threading
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
from wrapper.toxav_enums import *
|
from tox_wrapper.toxav_enums import *
|
||||||
|
from tox_wrapper.tests import support_testing as ts
|
||||||
|
from tox_wrapper.tests.support_testing import LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG, LOG_TRACE
|
||||||
|
|
||||||
from av import screen_sharing
|
from av import screen_sharing
|
||||||
from av.call import Call
|
from av.call import Call
|
||||||
import common.tox_save
|
import common.tox_save
|
||||||
|
|
||||||
from utils import ui as util_ui
|
from utils import ui as util_ui
|
||||||
import wrapper_tests.support_testing as ts
|
import tox_wrapper.tests.support_testing as ts
|
||||||
from middleware.threads import invoke_in_main_thread
|
from middleware.threads import invoke_in_main_thread
|
||||||
from main import sleep
|
from main import sleep
|
||||||
from middleware.threads import BaseThread
|
from middleware.threads import BaseThread
|
||||||
|
@ -18,18 +21,6 @@ from middleware.threads import BaseThread
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
LOG = logging.getLogger('app.'+__name__)
|
LOG = logging.getLogger('app.'+__name__)
|
||||||
# callbacks can be called in any thread so were being careful
|
|
||||||
def LOG_ERROR(l): print('EROR< '+l)
|
|
||||||
def LOG_WARN(l): print('WARN< '+l)
|
|
||||||
def LOG_INFO(l):
|
|
||||||
bIsVerbose = hasattr(__builtins__, 'app') and app.oArgs.loglevel <= 20-1
|
|
||||||
if bIsVerbose: print('INFO< '+l)
|
|
||||||
def LOG_DEBUG(l):
|
|
||||||
bIsVerbose = hasattr(__builtins__, 'app') and app.oArgs.loglevel <= 10-1
|
|
||||||
if bIsVerbose: print('DBUG< '+l)
|
|
||||||
def LOG_TRACE(l):
|
|
||||||
bIsVerbose = hasattr(__builtins__, 'app') and app.oArgs.loglevel < 10-1
|
|
||||||
pass # print('TRACE+ '+l)
|
|
||||||
|
|
||||||
TIMER_TIMEOUT = 30.0
|
TIMER_TIMEOUT = 30.0
|
||||||
bSTREAM_CALLBACK = False
|
bSTREAM_CALLBACK = False
|
||||||
|
@ -132,7 +123,7 @@ class AV(common.tox_save.ToxAvSave):
|
||||||
self._toxav.answer(friend_number,
|
self._toxav.answer(friend_number,
|
||||||
self._audio_krate_tox_audio if audio_enabled else 0,
|
self._audio_krate_tox_audio if audio_enabled else 0,
|
||||||
self._audio_krate_tox_video if video_enabled else 0)
|
self._audio_krate_tox_video if video_enabled else 0)
|
||||||
except ArgumentError as e:
|
except Exception as e:
|
||||||
LOG.debug(f"AV accept_call error from {friend_number} {self._running}" +
|
LOG.debug(f"AV accept_call error from {friend_number} {self._running}" +
|
||||||
f"{e}")
|
f"{e}")
|
||||||
raise
|
raise
|
||||||
|
|
|
@ -11,9 +11,9 @@ except ImportError:
|
||||||
certifi = None
|
certifi = None
|
||||||
|
|
||||||
from user_data.settings import get_user_config_path
|
from user_data.settings import get_user_config_path
|
||||||
from wrapper_tests.support_testing import _get_nodes_path
|
from tox_wrapper.tests.support_testing import _get_nodes_path
|
||||||
from wrapper_tests.support_http import download_url
|
from tox_wrapper.tests.support_http import download_url
|
||||||
import wrapper_tests.support_testing as ts
|
import tox_wrapper.tests.support_testing as ts
|
||||||
|
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*-
|
# -*- mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*-
|
||||||
from user_data.settings import *
|
from user_data.settings import *
|
||||||
from PyQt5 import QtCore, QtGui
|
from PyQt5 import QtCore, QtGui
|
||||||
from wrapper.toxcore_enums_and_consts import TOX_PUBLIC_KEY_SIZE
|
from tox_wrapper.toxcore_enums_and_consts import TOX_PUBLIC_KEY_SIZE
|
||||||
import utils.util as util
|
import utils.util as util
|
||||||
import common.event as event
|
import common.event as event
|
||||||
import contacts.common as common
|
import contacts.common as common
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
from PyQt5 import QtWidgets
|
from PyQt5 import QtWidgets
|
||||||
|
|
||||||
import utils.ui as util_ui
|
import utils.ui as util_ui
|
||||||
from wrapper.toxcore_enums_and_consts import *
|
from tox_wrapper.toxcore_enums_and_consts import *
|
||||||
|
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
|
|
|
@ -7,17 +7,7 @@ import logging
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
# callbacks can be called in any thread so were being careful
|
# callbacks can be called in any thread so were being careful
|
||||||
def LOG_ERROR(l): print('EROR< '+l)
|
from av.calls import LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG, LOG_TRACE
|
||||||
def LOG_WARN(l): print('WARN< '+l)
|
|
||||||
def LOG_INFO(l):
|
|
||||||
bIsVerbose = hasattr(__builtins__, 'app') and app.oArgs.loglevel <= 20-1
|
|
||||||
if bIsVerbose: print('INFO< '+l)
|
|
||||||
def LOG_DEBUG(l):
|
|
||||||
bIsVerbose = hasattr(__builtins__, 'app') and app.oArgs.loglevel <= 10-1
|
|
||||||
if bIsVerbose: print('DBUG< '+l)
|
|
||||||
def LOG_TRACE(l):
|
|
||||||
bIsVerbose = hasattr(__builtins__, 'app') and app.oArgs.loglevel < 10-1
|
|
||||||
pass # print('TRACE+ '+l)
|
|
||||||
|
|
||||||
class ContactProvider(tox_save.ToxSave):
|
class ContactProvider(tox_save.ToxSave):
|
||||||
|
|
||||||
|
@ -52,10 +42,9 @@ 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"CP.get_all_friends NO {friend_numbers} {e} ")
|
LOG_WARN(f"CP.get_all_friends EXCEPTION {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)
|
||||||
|
|
||||||
return list(friends)
|
return list(friends)
|
||||||
|
|
||||||
# Groups
|
# Groups
|
||||||
|
@ -121,7 +110,7 @@ class ContactProvider(tox_save.ToxSave):
|
||||||
return group
|
return group
|
||||||
group = self._group_factory.create_group_by_public_key(public_key)
|
group = self._group_factory.create_group_by_public_key(public_key)
|
||||||
if group is None:
|
if group is None:
|
||||||
LOG_ERROR(f"get_group_by_public_key NULL group public_key={get_group_by_chat_id}")
|
LOG_ERROR(f"get_group_by_public_key NULL group public_key={public_key}")
|
||||||
else:
|
else:
|
||||||
self._add_to_cache(public_key, group)
|
self._add_to_cache(public_key, group)
|
||||||
|
|
||||||
|
@ -139,7 +128,7 @@ class ContactProvider(tox_save.ToxSave):
|
||||||
|
|
||||||
def get_group_peer_by_public_key(self, group, public_key):
|
def get_group_peer_by_public_key(self, group, public_key):
|
||||||
peer = group.get_peer_by_public_key(public_key)
|
peer = group.get_peer_by_public_key(public_key)
|
||||||
|
if peer:
|
||||||
return self._get_group_peer(group, peer)
|
return self._get_group_peer(group, peer)
|
||||||
|
|
||||||
# All contacts
|
# All contacts
|
||||||
|
|
|
@ -8,23 +8,19 @@ from messenger.messages import *
|
||||||
from common.tox_save import ToxSave
|
from common.tox_save import ToxSave
|
||||||
from contacts.group_peer_contact import GroupPeerContact
|
from contacts.group_peer_contact import GroupPeerContact
|
||||||
from groups.group_peer import GroupChatPeer
|
from groups.group_peer import GroupChatPeer
|
||||||
|
from middleware.callbacks import LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG, LOG_TRACE
|
||||||
|
import tox_wrapper.toxcore_enums_and_consts as enums
|
||||||
|
|
||||||
# LOG=util.log
|
# LOG=util.log
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
LOG = logging.getLogger('app.'+__name__)
|
LOG = logging.getLogger('app.'+__name__)
|
||||||
|
|
||||||
def LOG_ERROR(l): print('ERROR_: '+l)
|
|
||||||
def LOG_WARN(l): print('WARN_: '+l)
|
|
||||||
def LOG_INFO(l): print('INFO_: '+l)
|
|
||||||
def LOG_DEBUG(l): print('DEBUG_: '+l)
|
|
||||||
def LOG_TRACE(l): pass # print('TRACE+ '+l)
|
|
||||||
|
|
||||||
|
|
||||||
UINT32_MAX = 2 ** 32 -1
|
UINT32_MAX = 2 ** 32 -1
|
||||||
|
|
||||||
def set_contact_kind(contact):
|
def set_contact_kind(contact):
|
||||||
bInvite = len(contact.name) == TOX_PUBLIC_KEY_SIZE * 2 and \
|
bInvite = len(contact.name) == enums.TOX_PUBLIC_KEY_SIZE * 2 and \
|
||||||
contact.status_message == ''
|
contact.status_message == ''
|
||||||
bBot = not bInvite and contact.name.lower().endswith(' bot')
|
bBot = not bInvite and contact.name.lower().endswith(' bot')
|
||||||
if type(contact) == Friend and bInvite:
|
if type(contact) == Friend and bInvite:
|
||||||
|
@ -377,8 +373,8 @@ class ContactsManager(ToxSave):
|
||||||
"""
|
"""
|
||||||
Block user with specified tox id (or public key) - delete from friends list and ignore friend requests
|
Block user with specified tox id (or public key) - delete from friends list and ignore friend requests
|
||||||
"""
|
"""
|
||||||
tox_id = tox_id[:TOX_PUBLIC_KEY_SIZE * 2]
|
tox_id = tox_id[:enums.TOX_PUBLIC_KEY_SIZE * 2]
|
||||||
if tox_id == self._tox.self_get_address()[:TOX_PUBLIC_KEY_SIZE * 2]:
|
if tox_id == self._tox.self_get_address()[:enums.TOX_PUBLIC_KEY_SIZE * 2]:
|
||||||
return
|
return
|
||||||
if tox_id not in self._settings['blocked']:
|
if tox_id not in self._settings['blocked']:
|
||||||
self._settings['blocked'].append(tox_id)
|
self._settings['blocked'].append(tox_id)
|
||||||
|
@ -484,14 +480,14 @@ class ContactsManager(ToxSave):
|
||||||
retval = ''
|
retval = ''
|
||||||
try:
|
try:
|
||||||
message = message or 'Hello! Add me to your contact list please'
|
message = message or 'Hello! Add me to your contact list please'
|
||||||
if len(sToxPkOrId) == TOX_PUBLIC_KEY_SIZE * 2: # public key
|
if len(sToxPkOrId) == enums.TOX_PUBLIC_KEY_SIZE * 2: # public key
|
||||||
self.add_friend(sToxPkOrId)
|
self.add_friend(sToxPkOrId)
|
||||||
title = 'Friend added'
|
title = 'Friend added'
|
||||||
text = 'Friend added without sending friend request'
|
text = 'Friend added without sending friend request'
|
||||||
else:
|
else:
|
||||||
num = self._tox.friend_add(sToxPkOrId, message.encode('utf-8'))
|
num = self._tox.friend_add(sToxPkOrId, message.encode('utf-8'))
|
||||||
if num < UINT32_MAX:
|
if num < UINT32_MAX:
|
||||||
tox_pk = sToxPkOrId[:TOX_PUBLIC_KEY_SIZE * 2]
|
tox_pk = sToxPkOrId[:enums.TOX_PUBLIC_KEY_SIZE * 2]
|
||||||
self._add_friend(tox_pk)
|
self._add_friend(tox_pk)
|
||||||
self.update_filtration()
|
self.update_filtration()
|
||||||
title = 'Friend added'
|
title = 'Friend added'
|
||||||
|
|
|
@ -4,18 +4,14 @@ from contacts import contact
|
||||||
from contacts.contact_menu import GroupMenuGenerator
|
from contacts.contact_menu import GroupMenuGenerator
|
||||||
import utils.util as util
|
import utils.util as util
|
||||||
from groups.group_peer import GroupChatPeer
|
from groups.group_peer import GroupChatPeer
|
||||||
from wrapper import toxcore_enums_and_consts as constants
|
from tox_wrapper import toxcore_enums_and_consts as constants
|
||||||
from common.tox_save import ToxSave
|
from common.tox_save import ToxSave
|
||||||
from groups.group_ban import GroupBan
|
from groups.group_ban import GroupBan
|
||||||
|
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
def LOG_ERROR(l): print('ERROR_: '+l)
|
from av.calls import LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG, LOG_TRACE
|
||||||
def LOG_WARN(l): print('WARN_: '+l)
|
|
||||||
def LOG_INFO(l): print('INFO_: '+l)
|
|
||||||
def LOG_DEBUG(l): print('DEBUG_: '+l)
|
|
||||||
def LOG_TRACE(l): pass # print('TRACE+ '+l)
|
|
||||||
|
|
||||||
class GroupChat(contact.Contact, ToxSave):
|
class GroupChat(contact.Contact, ToxSave):
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
from contacts.group_chat import GroupChat
|
from contacts.group_chat import GroupChat
|
||||||
from common.tox_save import ToxSave
|
from common.tox_save import ToxSave
|
||||||
import wrapper.toxcore_enums_and_consts as constants
|
import tox_wrapper.toxcore_enums_and_consts as constants
|
||||||
|
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
|
|
1
toxygen/file_transfers/.#file_transfers.py
Symbolic link
1
toxygen/file_transfers/.#file_transfers.py
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
root@devuan.29604:1700913818
|
|
@ -1,11 +1,13 @@
|
||||||
|
import os
|
||||||
from os import chdir, remove, rename
|
from os import chdir, remove, rename
|
||||||
from os.path import basename, getsize, exists, dirname
|
from os.path import basename, getsize, exists, dirname
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from common.event import Event
|
from common.event import Event
|
||||||
from middleware.threads import invoke_in_main_thread
|
from middleware.threads import invoke_in_main_thread
|
||||||
from wrapper.tox import Tox
|
from tox_wrapper.tox import Tox
|
||||||
from wrapper.toxcore_enums_and_consts import TOX_FILE_KIND, TOX_FILE_CONTROL
|
from tox_wrapper.toxcore_enums_and_consts import TOX_FILE_KIND, TOX_FILE_CONTROL
|
||||||
|
from middleware.callbacks import LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG, LOG_TRACE
|
||||||
|
|
||||||
FILE_TRANSFER_STATE = {
|
FILE_TRANSFER_STATE = {
|
||||||
'RUNNING': 0,
|
'RUNNING': 0,
|
||||||
|
@ -172,11 +174,14 @@ class SendAvatar(SendTransfer):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, path, tox, friend_number):
|
def __init__(self, path, tox, friend_number):
|
||||||
if path is None:
|
LOG_DEBUG(f"SendAvatar path={path} friend_number={friend_number}")
|
||||||
|
if path is None or not os.path.exists(path):
|
||||||
avatar_hash = None
|
avatar_hash = None
|
||||||
else:
|
else:
|
||||||
with open(path, 'rb') as fl:
|
with open(path, 'rb') as fl:
|
||||||
avatar_hash = Tox.hash(fl.read())
|
data=fl.read()
|
||||||
|
LOG_DEBUG(f"SendAvatar data={data} type={type(data)}")
|
||||||
|
avatar_hash = tox.hash(data, None)
|
||||||
super().__init__(path, tox, friend_number, TOX_FILE_KIND['AVATAR'], avatar_hash)
|
super().__init__(path, tox, friend_number, TOX_FILE_KIND['AVATAR'], avatar_hash)
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,8 +223,8 @@ class SendFromFileBuffer(SendTransfer):
|
||||||
def send_chunk(self, position, size):
|
def send_chunk(self, position, size):
|
||||||
super().send_chunk(position, size)
|
super().send_chunk(position, size)
|
||||||
if not size:
|
if not size:
|
||||||
chdir(dirname(self._path))
|
os.chdir(dirname(self._path))
|
||||||
remove(self._path)
|
os.remove(self._path)
|
||||||
|
|
||||||
# Receive file
|
# Receive file
|
||||||
|
|
||||||
|
@ -311,7 +316,6 @@ class ReceiveAvatar(ReceiveTransfer):
|
||||||
Get friend's avatar. Doesn't need file transfer item
|
Get friend's avatar. Doesn't need file transfer item
|
||||||
"""
|
"""
|
||||||
MAX_AVATAR_SIZE = 512 * 1024
|
MAX_AVATAR_SIZE = 512 * 1024
|
||||||
|
|
||||||
def __init__(self, path, tox, friend_number, size, file_number):
|
def __init__(self, path, tox, friend_number, size, file_number):
|
||||||
full_path = path + '.tmp'
|
full_path = path + '.tmp'
|
||||||
super().__init__(full_path, tox, friend_number, size, file_number)
|
super().__init__(full_path, tox, friend_number, size, file_number)
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
# -*- mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*-
|
# -*- mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*-
|
||||||
|
from copy import deepcopy
|
||||||
|
|
||||||
from messenger.messages import *
|
from messenger.messages import *
|
||||||
|
from file_transfers.file_transfers import SendAvatar, is_inline
|
||||||
from ui.contact_items import *
|
from ui.contact_items import *
|
||||||
import utils.util as util
|
import utils.util as util
|
||||||
from common.tox_save import ToxSave
|
from common.tox_save import ToxSave
|
||||||
from wrapper_tests.support_testing import assert_main_thread
|
|
||||||
from copy import deepcopy
|
from middleware.callbacks import LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG, LOG_TRACE
|
||||||
|
|
||||||
# LOG=util.log
|
# LOG=util.log
|
||||||
global LOG
|
global LOG
|
||||||
|
@ -36,6 +39,7 @@ class FileTransfersHandler(ToxSave):
|
||||||
# File transfers support
|
# File transfers support
|
||||||
|
|
||||||
def incoming_file_transfer(self, friend_number, file_number, size, file_name):
|
def incoming_file_transfer(self, friend_number, file_number, size, file_name):
|
||||||
|
# main thread
|
||||||
"""
|
"""
|
||||||
New transfer
|
New transfer
|
||||||
:param friend_number: number of friend who sent file
|
:param friend_number: number of friend who sent file
|
||||||
|
@ -44,12 +48,15 @@ class FileTransfersHandler(ToxSave):
|
||||||
:param file_name: file name without path
|
:param file_name: file name without path
|
||||||
"""
|
"""
|
||||||
friend = self._get_friend_by_number(friend_number)
|
friend = self._get_friend_by_number(friend_number)
|
||||||
if friend is None: return None
|
if friend is None:
|
||||||
|
LOG.info(f'incoming_file_handler Friend NULL friend_number={friend_number}')
|
||||||
|
return None
|
||||||
auto = self._settings['allow_auto_accept'] and friend.tox_id in self._settings['auto_accept_from_friends']
|
auto = self._settings['allow_auto_accept'] and friend.tox_id in self._settings['auto_accept_from_friends']
|
||||||
inline = is_inline(file_name) and self._settings['allow_inline']
|
inline = False # ?is_inline(file_name) and self._settings['allow_inline']
|
||||||
file_id = self._tox.file_get_file_id(friend_number, file_number)
|
file_id = self._tox.file_get_file_id(friend_number, file_number)
|
||||||
accepted = True
|
accepted = True
|
||||||
if file_id in self._paused_file_transfers:
|
if file_id in self._paused_file_transfers:
|
||||||
|
LOG_INFO(f'incoming_file_handler paused friend_number={friend_number}')
|
||||||
(path, ft_friend_number, is_incoming, start_position) = self._paused_file_transfers[file_id]
|
(path, ft_friend_number, is_incoming, start_position) = self._paused_file_transfers[file_id]
|
||||||
pos = start_position if os.path.exists(path) else 0
|
pos = start_position if os.path.exists(path) else 0
|
||||||
if pos >= size:
|
if pos >= size:
|
||||||
|
@ -60,16 +67,22 @@ class FileTransfersHandler(ToxSave):
|
||||||
friend, accepted, size, file_name, file_number)
|
friend, accepted, size, file_name, file_number)
|
||||||
self.accept_transfer(path, friend_number, file_number, size, False, pos)
|
self.accept_transfer(path, friend_number, file_number, size, False, pos)
|
||||||
elif inline and size < 1024 * 1024:
|
elif inline and size < 1024 * 1024:
|
||||||
|
LOG_INFO(f'incoming_file_handler small friend_number={friend_number}')
|
||||||
self._file_transfers_message_service.add_incoming_transfer_message(
|
self._file_transfers_message_service.add_incoming_transfer_message(
|
||||||
friend, accepted, size, file_name, file_number)
|
friend, accepted, size, file_name, file_number)
|
||||||
self.accept_transfer('', friend_number, file_number, size, True)
|
self.accept_transfer('', friend_number, file_number, size, True)
|
||||||
elif auto:
|
elif auto:
|
||||||
|
# accepted is really started
|
||||||
|
LOG_INFO(f'incoming_file_handler auto friend_number={friend_number}')
|
||||||
path = self._settings['auto_accept_path'] or util.curr_directory()
|
path = self._settings['auto_accept_path'] or util.curr_directory()
|
||||||
self._file_transfers_message_service.add_incoming_transfer_message(
|
self._file_transfers_message_service.add_incoming_transfer_message(
|
||||||
friend, accepted, size, file_name, file_number)
|
friend, accepted, size, file_name, file_number)
|
||||||
self.accept_transfer(path + '/' + file_name, friend_number, file_number, size)
|
self.accept_transfer(path + '/' + file_name, friend_number, file_number, size)
|
||||||
else:
|
else:
|
||||||
|
LOG_INFO(f'incoming_file_handler reject friend_number={friend_number}')
|
||||||
accepted = False
|
accepted = False
|
||||||
|
# FixME: need GUI ask
|
||||||
|
# accepted is really started
|
||||||
self._file_transfers_message_service.add_incoming_transfer_message(
|
self._file_transfers_message_service.add_incoming_transfer_message(
|
||||||
friend, accepted, size, file_name, file_number)
|
friend, accepted, size, file_name, file_number)
|
||||||
|
|
||||||
|
@ -156,12 +169,15 @@ class FileTransfersHandler(ToxSave):
|
||||||
|
|
||||||
def send_inline(self, data, file_name, friend_number, is_resend=False):
|
def send_inline(self, data, file_name, friend_number, is_resend=False):
|
||||||
friend = self._get_friend_by_number(friend_number)
|
friend = self._get_friend_by_number(friend_number)
|
||||||
if friend is None: return None
|
if friend is None:
|
||||||
|
LOG_WARN("fsend_inline Error friend is None file_name: {file_name}")
|
||||||
|
return
|
||||||
if friend.status is None and not is_resend:
|
if friend.status is None and not is_resend:
|
||||||
self._file_transfers_message_service.add_unsent_file_message(friend, file_name, data)
|
self._file_transfers_message_service.add_unsent_file_message(friend, file_name, data)
|
||||||
return
|
return
|
||||||
elif friend.status is None and is_resend:
|
elif friend.status is None and is_resend:
|
||||||
raise RuntimeError()
|
LOG_WARN("fsend_inline Error friend.status is None file_name: {file_name}")
|
||||||
|
return
|
||||||
st = SendFromBuffer(self._tox, friend.number, data, file_name)
|
st = SendFromBuffer(self._tox, friend.number, data, file_name)
|
||||||
self._send_file_add_set_handlers(st, friend, file_name, True)
|
self._send_file_add_set_handlers(st, friend, file_name, True)
|
||||||
|
|
||||||
|
@ -179,7 +195,7 @@ class FileTransfersHandler(ToxSave):
|
||||||
self._file_transfers_message_service.add_unsent_file_message(friend, path, None)
|
self._file_transfers_message_service.add_unsent_file_message(friend, path, None)
|
||||||
return
|
return
|
||||||
elif friend.status is None and is_resend:
|
elif friend.status is None and is_resend:
|
||||||
LOG.error('Error in sending')
|
LOG_WARN('Error in sending')
|
||||||
return
|
return
|
||||||
st = SendTransfer(path, self._tox, friend_number, TOX_FILE_KIND['DATA'], file_id)
|
st = SendTransfer(path, self._tox, friend_number, TOX_FILE_KIND['DATA'], file_id)
|
||||||
file_name = os.path.basename(path)
|
file_name = os.path.basename(path)
|
||||||
|
@ -236,7 +252,7 @@ class FileTransfersHandler(ToxSave):
|
||||||
self.send_file(path, friend_number, True, key)
|
self.send_file(path, friend_number, True, key)
|
||||||
del self._paused_file_transfers[key]
|
del self._paused_file_transfers[key]
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
LOG.error('Exception in file sending: ' + str(ex))
|
LOG_ERROR('send_files EXCEPTION in file sending: ' + str(ex))
|
||||||
|
|
||||||
def friend_exit(self, friend_number):
|
def friend_exit(self, friend_number):
|
||||||
# RuntimeError: dictionary changed size during iteration
|
# RuntimeError: dictionary changed size during iteration
|
||||||
|
@ -248,9 +264,21 @@ class FileTransfersHandler(ToxSave):
|
||||||
continue
|
continue
|
||||||
ft = self._file_transfers[(friend_num, file_num)]
|
ft = self._file_transfers[(friend_num, file_num)]
|
||||||
if type(ft) is SendTransfer:
|
if type(ft) is SendTransfer:
|
||||||
self._paused_file_transfers[ft.file_id] = [ft.path, friend_num, False, -1]
|
try:
|
||||||
|
file_id = ft.file_id
|
||||||
|
except Exception as e:
|
||||||
|
LOG_WARN("friend_exit SendTransfer Error getting file_id: {e}")
|
||||||
|
# drop through
|
||||||
|
else:
|
||||||
|
self._paused_file_transfers[file_id] = [ft.path, friend_num, False, -1]
|
||||||
elif type(ft) is ReceiveTransfer and ft.state != FILE_TRANSFER_STATE['INCOMING_NOT_STARTED']:
|
elif type(ft) is ReceiveTransfer and ft.state != FILE_TRANSFER_STATE['INCOMING_NOT_STARTED']:
|
||||||
self._paused_file_transfers[ft.file_id] = [ft.path, friend_num, True, ft.total_size()]
|
try:
|
||||||
|
file_id = ft.file_id
|
||||||
|
except Exception as e:
|
||||||
|
LOG_WARN("friend_exit ReceiveTransfer Error getting file_id: {e}")
|
||||||
|
# drop through
|
||||||
|
else:
|
||||||
|
self._paused_file_transfers[file_id] = [ft.path, friend_num, True, ft.total_size()]
|
||||||
self.cancel_transfer(friend_num, file_num, True)
|
self.cancel_transfer(friend_num, file_num, True)
|
||||||
|
|
||||||
# Avatars support
|
# Avatars support
|
||||||
|
@ -260,15 +288,24 @@ class FileTransfersHandler(ToxSave):
|
||||||
:param friend_number: number of friend who should get new avatar
|
:param friend_number: number of friend who should get new avatar
|
||||||
:param avatar_path: path to avatar or None if reset
|
:param avatar_path: path to avatar or None if reset
|
||||||
"""
|
"""
|
||||||
|
return
|
||||||
if (avatar_path, friend_number,) in self.lBlockAvatars:
|
if (avatar_path, friend_number,) in self.lBlockAvatars:
|
||||||
return
|
return
|
||||||
|
if friend_number is None:
|
||||||
|
LOG_WARN(f"send_avatar friend_number NULL {friend_number}")
|
||||||
|
return
|
||||||
|
if avatar_path and type(avatar_path) != str:
|
||||||
|
LOG_WARN(f"send_avatar avatar_path type {type(avatar_path)}")
|
||||||
|
return
|
||||||
|
LOG_INFO(f"send_avatar avatar_path={avatar_path} friend_number={friend_number}")
|
||||||
try:
|
try:
|
||||||
|
# self NOT missing - who's self?
|
||||||
sa = SendAvatar(avatar_path, self._tox, friend_number)
|
sa = SendAvatar(avatar_path, self._tox, friend_number)
|
||||||
|
LOG_INFO(f"send_avatar avatar_path={avatar_path} sa={sa}")
|
||||||
self._file_transfers[(friend_number, sa.file_number)] = sa
|
self._file_transfers[(friend_number, sa.file_number)] = sa
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# ArgumentError('This client is currently not connected to the friend.')
|
# ArgumentError('This client is currently not connected to the friend.')
|
||||||
LOG.error(f"send_avatar {e}")
|
LOG_WARN(f"send_avatar EXCEPTION {e}")
|
||||||
self.lBlockAvatars.append( (avatar_path, friend_number,) )
|
self.lBlockAvatars.append( (avatar_path, friend_number,) )
|
||||||
|
|
||||||
def incoming_avatar(self, friend_number, file_number, size):
|
def incoming_avatar(self, friend_number, file_number, size):
|
||||||
|
|
|
@ -6,11 +6,7 @@ global LOG
|
||||||
import logging
|
import logging
|
||||||
LOG = logging.getLogger('app.'+__name__)
|
LOG = logging.getLogger('app.'+__name__)
|
||||||
|
|
||||||
def LOG_ERROR(l): print('ERROR_: '+l)
|
from av.calls import LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG, LOG_TRACE
|
||||||
def LOG_WARN(l): print('WARN_: '+l)
|
|
||||||
def LOG_INFO(l): print('INFO_: '+l)
|
|
||||||
def LOG_DEBUG(l): print('DEBUG_: '+l)
|
|
||||||
def LOG_TRACE(l): pass # print('TRACE+ '+l)
|
|
||||||
|
|
||||||
class FileTransfersMessagesService:
|
class FileTransfersMessagesService:
|
||||||
|
|
||||||
|
@ -23,6 +19,7 @@ class FileTransfersMessagesService:
|
||||||
def add_incoming_transfer_message(self, friend, accepted, size, file_name, file_number):
|
def add_incoming_transfer_message(self, friend, accepted, size, file_name, file_number):
|
||||||
assert friend
|
assert friend
|
||||||
author = MessageAuthor(friend.name, MESSAGE_AUTHOR['FRIEND'])
|
author = MessageAuthor(friend.name, MESSAGE_AUTHOR['FRIEND'])
|
||||||
|
# accepted is really started
|
||||||
status = FILE_TRANSFER_STATE['RUNNING'] if accepted else FILE_TRANSFER_STATE['INCOMING_NOT_STARTED']
|
status = FILE_TRANSFER_STATE['RUNNING'] if accepted else FILE_TRANSFER_STATE['INCOMING_NOT_STARTED']
|
||||||
tm = TransferMessage(author, util.get_unix_time(), status, size, file_name, friend.number, file_number)
|
tm = TransferMessage(author, util.get_unix_time(), status, size, file_name, friend.number, file_number)
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ class GroupChatPeer:
|
||||||
is_current_user = property(get_is_current_user)
|
is_current_user = property(get_is_current_user)
|
||||||
|
|
||||||
def get_status_message(self):
|
def get_status_message(self):
|
||||||
return self._peer_status_message
|
return self._status_message
|
||||||
|
|
||||||
status_message = property(get_status_message)
|
status_message = property(get_status_message)
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@ import common.tox_save as tox_save
|
||||||
import utils.ui as util_ui
|
import utils.ui as util_ui
|
||||||
from groups.peers_list import PeersListGenerator
|
from groups.peers_list import PeersListGenerator
|
||||||
from groups.group_invite import GroupInvite
|
from groups.group_invite import GroupInvite
|
||||||
import wrapper.toxcore_enums_and_consts as constants
|
import tox_wrapper.toxcore_enums_and_consts as constants
|
||||||
from wrapper.toxcore_enums_and_consts import *
|
from tox_wrapper.toxcore_enums_and_consts import *
|
||||||
from wrapper.tox import UINT32_MAX
|
from tox_wrapper.tox import UINT32_MAX
|
||||||
|
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from ui.group_peers_list import PeerItem, PeerTypeItem
|
from ui.group_peers_list import PeerItem, PeerTypeItem
|
||||||
from wrapper.toxcore_enums_and_consts import *
|
from tox_wrapper.toxcore_enums_and_consts import *
|
||||||
from ui.widgets import *
|
from ui.widgets import *
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import app
|
import app
|
||||||
import argparse
|
|
||||||
import logging
|
import logging
|
||||||
import signal
|
import signal
|
||||||
|
|
||||||
|
@ -12,7 +11,7 @@ faulthandler.enable()
|
||||||
import warnings
|
import warnings
|
||||||
warnings.filterwarnings('ignore')
|
warnings.filterwarnings('ignore')
|
||||||
|
|
||||||
import wrapper_tests.support_testing as ts
|
import tox_wrapper.tests.support_testing as ts
|
||||||
try:
|
try:
|
||||||
from trepan.interfaces import server as Mserver
|
from trepan.interfaces import server as Mserver
|
||||||
from trepan.api import debug
|
from trepan.api import debug
|
||||||
|
@ -182,7 +181,6 @@ def main_parser(_=None, iMode=2):
|
||||||
audio = setup_default_audio()
|
audio = setup_default_audio()
|
||||||
default_video = setup_default_video()
|
default_video = setup_default_video()
|
||||||
|
|
||||||
# parser = argparse.ArgumentParser()
|
|
||||||
parser = ts.oMainArgparser()
|
parser = ts.oMainArgparser()
|
||||||
parser.add_argument('--version', action='store_true', help='Prints Toxygen version')
|
parser.add_argument('--version', action='store_true', help='Prints Toxygen version')
|
||||||
parser.add_argument('--clean', action='store_true', help='Delete toxcore libs from libs folder')
|
parser.add_argument('--clean', action='store_true', help='Delete toxcore libs from libs folder')
|
||||||
|
@ -240,10 +238,10 @@ def main_parser(_=None, iMode=2):
|
||||||
parser.add_argument('--theme', type=str, default='default',
|
parser.add_argument('--theme', type=str, default='default',
|
||||||
choices=['dark', 'default'],
|
choices=['dark', 'default'],
|
||||||
help='Theme - style of UI')
|
help='Theme - style of UI')
|
||||||
parser.add_argument('--sleep', type=str, default='time',
|
# parser.add_argument('--sleep', type=str, default='time',
|
||||||
# could expand this to tk, gtk, gevent...
|
# # could expand this to tk, gtk, gevent...
|
||||||
choices=['qt','gevent','time'],
|
# choices=['qt','gevent','time'],
|
||||||
help='Sleep method - one of qt, gevent , time')
|
# help='Sleep method - one of qt, gevent , time')
|
||||||
supported_languages = settings.supported_languages()
|
supported_languages = settings.supported_languages()
|
||||||
parser.add_argument('--language', type=str, default='English',
|
parser.add_argument('--language', type=str, default='English',
|
||||||
choices=supported_languages,
|
choices=supported_languages,
|
||||||
|
@ -318,6 +316,7 @@ def main(lArgs):
|
||||||
aArgs = A()
|
aArgs = A()
|
||||||
for key in oArgs.__dict__.keys():
|
for key in oArgs.__dict__.keys():
|
||||||
setattr(aArgs, key, getattr(oArgs, key))
|
setattr(aArgs, key, getattr(oArgs, key))
|
||||||
|
|
||||||
#setattr(aArgs, 'video', setup_video(oArgs))
|
#setattr(aArgs, 'video', setup_video(oArgs))
|
||||||
aArgs.video = setup_video(oArgs)
|
aArgs.video = setup_video(oArgs)
|
||||||
assert 'video' in aArgs.__dict__
|
assert 'video' in aArgs.__dict__
|
||||||
|
@ -327,10 +326,10 @@ def main(lArgs):
|
||||||
assert 'audio' in aArgs.__dict__
|
assert 'audio' in aArgs.__dict__
|
||||||
oArgs = aArgs
|
oArgs = aArgs
|
||||||
|
|
||||||
toxygen = app.App(__version__, oArgs)
|
oApp = app.App(__version__, oArgs)
|
||||||
# for pyqtconsole
|
# for pyqtconsole
|
||||||
__builtins__.app = toxygen
|
__builtins__.app = oApp
|
||||||
i = toxygen.iMain()
|
i = oApp.iMain()
|
||||||
return i
|
return i
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -83,7 +83,7 @@ class Message:
|
||||||
|
|
||||||
def _create_widget(self, *args):
|
def _create_widget(self, *args):
|
||||||
# overridden
|
# overridden
|
||||||
pass
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_id():
|
def _get_id():
|
||||||
|
|
|
@ -3,8 +3,8 @@ import common.tox_save as tox_save
|
||||||
import utils.ui as util_ui
|
import utils.ui as util_ui
|
||||||
|
|
||||||
from messenger.messages import *
|
from messenger.messages import *
|
||||||
from wrapper_tests.support_testing import assert_main_thread
|
from tox_wrapper.tests.support_testing import assert_main_thread
|
||||||
from wrapper.toxcore_enums_and_consts import TOX_MAX_MESSAGE_LENGTH
|
from tox_wrapper.toxcore_enums_and_consts import TOX_MAX_MESSAGE_LENGTH
|
||||||
|
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
|
|
|
@ -3,9 +3,9 @@ import sys
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
from PyQt5 import QtGui
|
from PyQt5 import QtGui
|
||||||
from wrapper.toxcore_enums_and_consts import *
|
from tox_wrapper.toxcore_enums_and_consts import *
|
||||||
from wrapper.toxav_enums import *
|
from tox_wrapper.toxav_enums import *
|
||||||
from wrapper.tox import bin_to_string
|
from tox_wrapper.tox import bin_to_string
|
||||||
import utils.ui as util_ui
|
import utils.ui as util_ui
|
||||||
import utils.util as util
|
import utils.util as util
|
||||||
from middleware.threads import invoke_in_main_thread, execute
|
from middleware.threads import invoke_in_main_thread, execute
|
||||||
|
@ -15,17 +15,17 @@ from datetime import datetime
|
||||||
|
|
||||||
iMAX_INT32 = 4294967295
|
iMAX_INT32 = 4294967295
|
||||||
# callbacks can be called in any thread so were being careful
|
# callbacks can be called in any thread so were being careful
|
||||||
def LOG_ERROR(l): print('EROR< '+l)
|
def LOG_ERROR(l): print(f"EROR. {l}")
|
||||||
def LOG_WARN(l): print('WARN< '+l)
|
def LOG_WARN(l): print(f"WARN. {l}")
|
||||||
def LOG_INFO(l):
|
def LOG_INFO(l):
|
||||||
bIsVerbose = hasattr(__builtins__, 'app') and app.oArgs.loglevel <= 20-1
|
bIsVerbose = not hasattr(__builtins__, 'app') or app.oArgs.loglevel <= 20-1
|
||||||
if bIsVerbose: print('INFO< '+l)
|
if bIsVerbose: print(f"INFO. {l}")
|
||||||
def LOG_DEBUG(l):
|
def LOG_DEBUG(l):
|
||||||
bIsVerbose = hasattr(__builtins__, 'app') and app.oArgs.loglevel <= 10-1
|
bIsVerbose = not hasattr(__builtins__, 'app') or app.oArgs.loglevel <= 10-1
|
||||||
if bIsVerbose: print('DBUG< '+l)
|
if bIsVerbose: print(f"DBUG. {l}")
|
||||||
def LOG_TRACE(l):
|
def LOG_TRACE(l):
|
||||||
bIsVerbose = hasattr(__builtins__, 'app') and app.oArgs.loglevel < 10-1
|
bIsVerbose = not hasattr(__builtins__, 'app') or app.oArgs.loglevel < 10-1
|
||||||
pass # print('TRACE+ '+l)
|
pass # print(f"TRACE. {l}")
|
||||||
|
|
||||||
global aTIMES
|
global aTIMES
|
||||||
aTIMES=dict()
|
aTIMES=dict()
|
||||||
|
@ -102,7 +102,7 @@ def friend_status(contacts_manager, file_transfer_handler, profile, settings):
|
||||||
"""
|
"""
|
||||||
Check friend's status (none, busy, away)
|
Check friend's status (none, busy, away)
|
||||||
"""
|
"""
|
||||||
LOG_DEBUG(f"Friend's #{friend_number} status changed")
|
LOG_INFO(f"Friend's #{friend_number} status changed")
|
||||||
key = f"friend_number {friend_number}"
|
key = f"friend_number {friend_number}"
|
||||||
if bTooSoon(key, sSlot, 10): return
|
if bTooSoon(key, sSlot, 10): return
|
||||||
friend = contacts_manager.get_friend_by_number(friend_number)
|
friend = contacts_manager.get_friend_by_number(friend_number)
|
||||||
|
@ -240,7 +240,7 @@ def tox_file_recv(window, tray, profile, file_transfer_handler, contacts_manager
|
||||||
"""
|
"""
|
||||||
def wrapped(tox, friend_number, file_number, file_type, size, file_name, file_name_size, user_data):
|
def wrapped(tox, friend_number, file_number, file_type, size, file_name, file_name_size, user_data):
|
||||||
if file_type == TOX_FILE_KIND['DATA']:
|
if file_type == TOX_FILE_KIND['DATA']:
|
||||||
LOG_DEBUG(f'file_transfer_handler File')
|
LOG_INFO(f'file_transfer_handler File friend_number={friend_number}')
|
||||||
try:
|
try:
|
||||||
file_name = str(file_name[:file_name_size], 'utf-8')
|
file_name = str(file_name[:file_name_size], 'utf-8')
|
||||||
except:
|
except:
|
||||||
|
|
|
@ -6,8 +6,8 @@ from PyQt5 import QtCore
|
||||||
|
|
||||||
from bootstrap.bootstrap import *
|
from bootstrap.bootstrap import *
|
||||||
from bootstrap.bootstrap import download_nodes_list
|
from bootstrap.bootstrap import download_nodes_list
|
||||||
from wrapper.toxcore_enums_and_consts import TOX_USER_STATUS, TOX_CONNECTION
|
from tox_wrapper.toxcore_enums_and_consts import TOX_USER_STATUS, TOX_CONNECTION
|
||||||
import wrapper_tests.support_testing as ts
|
import tox_wrapper.tests.support_testing as ts
|
||||||
from utils import util
|
from utils import util
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
@ -86,7 +86,7 @@ class InitThread(BaseThread):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# DBUG+ InitThread run: ERROR name 'ts' is not defined
|
# DBUG+ InitThread run: ERROR name 'ts' is not defined
|
||||||
import wrapper_tests.support_testing as ts
|
import tox_wrapper.tests.support_testing as ts
|
||||||
LOG_DEBUG('InitThread run: ')
|
LOG_DEBUG('InitThread run: ')
|
||||||
try:
|
try:
|
||||||
if self._is_first_start and ts.bAreWeConnected() and \
|
if self._is_first_start and ts.bAreWeConnected() and \
|
||||||
|
|
|
@ -1,59 +1,25 @@
|
||||||
# -*- mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*-
|
# -*- mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*-
|
||||||
import user_data.settings
|
|
||||||
import wrapper.tox
|
|
||||||
import wrapper.toxcore_enums_and_consts as enums
|
|
||||||
import ctypes
|
import ctypes
|
||||||
import traceback
|
import traceback
|
||||||
import os
|
import os
|
||||||
|
from ctypes import *
|
||||||
|
|
||||||
|
import user_data.settings
|
||||||
|
import tox_wrapper.tox
|
||||||
|
import tox_wrapper.toxcore_enums_and_consts as enums
|
||||||
|
from tox_wrapper.tests import support_testing as ts
|
||||||
|
# callbacks can be called in any thread so were being careful
|
||||||
|
# tox.py can be called by callbacks
|
||||||
|
from tox_wrapper.tests.support_testing import LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG, LOG_TRACE
|
||||||
|
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
LOG = logging.getLogger('app.'+'tox_factory')
|
LOG = logging.getLogger('app.'+'tox_factory')
|
||||||
|
|
||||||
from ctypes import *
|
|
||||||
from utils import util
|
from utils import util
|
||||||
from utils import ui as util_ui
|
from utils import ui as util_ui
|
||||||
|
|
||||||
# callbacks can be called in any thread so were being careful
|
|
||||||
# tox.py can be called by callbacks
|
|
||||||
def LOG_ERROR(a): print('EROR> '+a)
|
|
||||||
def LOG_WARN(a): print('WARN> '+a)
|
|
||||||
def LOG_INFO(a):
|
|
||||||
bVERBOSE = hasattr(__builtins__, 'app') and app.oArgs.loglevel <= 20
|
|
||||||
if bVERBOSE: print('INFO> '+a)
|
|
||||||
def LOG_DEBUG(a):
|
|
||||||
bVERBOSE = hasattr(__builtins__, 'app') and app.oArgs.loglevel <= 10
|
|
||||||
if bVERBOSE: print('DBUG> '+a)
|
|
||||||
def LOG_TRACE(a):
|
|
||||||
bVERBOSE = hasattr(__builtins__, 'app') and app.oArgs.loglevel < 10
|
|
||||||
if bVERBOSE: print('TRAC> '+a)
|
|
||||||
def LOG_LOG(a): print('TRAC> '+a)
|
|
||||||
|
|
||||||
def tox_log_cb(iTox, level, file, line, func, message, *args):
|
|
||||||
"""
|
|
||||||
* @param level The severity of the log message.
|
|
||||||
* @param file The source file from which the message originated.
|
|
||||||
* @param line The source line from which the message originated.
|
|
||||||
* @param func The function from which the message originated.
|
|
||||||
* @param message The log message.
|
|
||||||
* @param user_data The user data pointer passed to tox_new in options.
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
file = str(file, 'UTF-8')
|
|
||||||
# root WARNING 3network.c#944:b'send_packet'attempted to send message with network family 10 (probably IPv6) on IPv4 socket
|
|
||||||
if file == 'network.c' and line in [944, 660]: return
|
|
||||||
func = str(func, 'UTF-8')
|
|
||||||
message = str(message, 'UTF-8')
|
|
||||||
message = f"{file}#{line}:{func} {message}"
|
|
||||||
LOG_LOG(message)
|
|
||||||
except Exception as e:
|
|
||||||
LOG_ERROR(f"tox_log_cb {e}")
|
|
||||||
|
|
||||||
#tox_log_handler (context=0x24763d0,
|
|
||||||
# level=LOGGER_LEVEL_TRACE, file=0x7fffe599fb99 "TCP_common.c", line=203,
|
|
||||||
# func=0x7fffe599fc50 <__func__.2> "read_TCP_packet",
|
|
||||||
# message=0x7fffba7fabd0 "recv buffer has 0 bytes, but requested 10 bytes",
|
|
||||||
# userdata=0x0) at /var/local/src/c-toxcore/toxcore/tox.c:78
|
|
||||||
|
|
||||||
def tox_factory(data=None, settings=None, args=None, app=None):
|
def tox_factory(data=None, settings=None, args=None, app=None):
|
||||||
"""
|
"""
|
||||||
|
@ -68,7 +34,7 @@ def tox_factory(data=None, settings=None, args=None, app=None):
|
||||||
user_data.settings.clean_settings(settings)
|
user_data.settings.clean_settings(settings)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tox_options = wrapper.tox.Tox.options_new()
|
tox_options = tox_wrapper.tox.Tox.options_new()
|
||||||
tox_options.contents.ipv6_enabled = settings['ipv6_enabled']
|
tox_options.contents.ipv6_enabled = settings['ipv6_enabled']
|
||||||
tox_options.contents.udp_enabled = settings['udp_enabled']
|
tox_options.contents.udp_enabled = settings['udp_enabled']
|
||||||
tox_options.contents.proxy_type = int(settings['proxy_type'])
|
tox_options.contents.proxy_type = int(settings['proxy_type'])
|
||||||
|
@ -99,27 +65,28 @@ def tox_factory(data=None, settings=None, args=None, app=None):
|
||||||
tox_options.contents.ipv6_enabled = False
|
tox_options.contents.ipv6_enabled = False
|
||||||
tox_options.contents.hole_punching_enabled = False
|
tox_options.contents.hole_punching_enabled = False
|
||||||
|
|
||||||
LOG.debug("wrapper.tox.Tox settings: " +repr(settings))
|
LOG.debug("tox_wrapper.tox.Tox settings: " +repr(settings))
|
||||||
|
|
||||||
if 'trace_enabled' in settings and settings['trace_enabled']:
|
if 'trace_enabled' in settings and not settings['trace_enabled']:
|
||||||
LOG_INFO("settings['trace_enabled' disabled" )
|
LOG_DEBUG("settings['trace_enabled' disabled" )
|
||||||
elif tox_options._options_pointer:
|
elif tox_options._options_pointer:
|
||||||
c_callback = CFUNCTYPE(None, c_void_p, c_int, c_char_p, c_int, c_char_p, c_char_p, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, c_int, c_char_p, c_int, c_char_p, c_char_p, c_void_p)
|
||||||
tox_options.self_logger_cb = c_callback(tox_log_cb)
|
tox_options.self_logger_cb = c_callback(ts.tox_log_cb)
|
||||||
wrapper.tox.Tox.libtoxcore.tox_options_set_log_callback(
|
tox_wrapper.tox.Tox.libtoxcore.tox_options_set_log_callback(
|
||||||
tox_options._options_pointer,
|
tox_options._options_pointer,
|
||||||
tox_options.self_logger_cb)
|
tox_options.self_logger_cb)
|
||||||
|
LOG_INFO("c-toxcore trace_enabled enabled" )
|
||||||
else:
|
else:
|
||||||
LOG_WARN("No tox_options._options_pointer to add self_logger_cb" )
|
LOG_WARN("No tox_options._options_pointer to add self_logger_cb" )
|
||||||
|
|
||||||
retval = wrapper.tox.Tox(tox_options)
|
retval = tox_wrapper.tox.Tox(tox_options)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if app and hasattr(app, '_log'):
|
if app and hasattr(app, '_log'):
|
||||||
pass
|
pass
|
||||||
LOG_ERROR(f"wrapper.tox.Tox failed: {e}")
|
LOG_ERROR(f"tox_wrapper.tox.Tox failed: {e}")
|
||||||
LOG_WARN(traceback.format_exc())
|
LOG_WARN(traceback.format_exc())
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if app and hasattr(app, '_log'):
|
if app and hasattr(app, '_log'):
|
||||||
app._log("DEBUG: wrapper.tox.Tox succeeded")
|
app._log("DEBUG: tox_wrapper.tox.Tox succeeded")
|
||||||
return retval
|
return retval
|
||||||
|
|
|
@ -32,15 +32,15 @@ def LOG_debug(a): print('DBUG_ '+a)
|
||||||
def LOG_trace(a): pass # print('TRAC_ '+a)
|
def LOG_trace(a): pass # print('TRAC_ '+a)
|
||||||
|
|
||||||
from middleware.tox_factory import tox_factory
|
from middleware.tox_factory import tox_factory
|
||||||
import wrapper
|
import tox_wrapper
|
||||||
import wrapper.toxcore_enums_and_consts as enums
|
import tox_wrapper.toxcore_enums_and_consts as enums
|
||||||
from wrapper.toxcore_enums_and_consts import TOX_CONNECTION, TOX_USER_STATUS, \
|
from tox_wrapper.toxcore_enums_and_consts import TOX_CONNECTION, TOX_USER_STATUS, \
|
||||||
TOX_MESSAGE_TYPE, TOX_PUBLIC_KEY_SIZE, TOX_FILE_CONTROL
|
TOX_MESSAGE_TYPE, TOX_PUBLIC_KEY_SIZE, TOX_FILE_CONTROL
|
||||||
import user_data
|
import user_data
|
||||||
from wrapper.libtox import LibToxCore
|
from tox_wrapper.libtox import LibToxCore
|
||||||
import wrapper_tests.support_testing as ts
|
import tox_wrapper.tests.support_testing as ts
|
||||||
from wrapper_tests.support_testing import oMainArgparser
|
from tox_wrapper.tests.support_testing import oMainArgparser
|
||||||
from wrapper_tests.support_testing import logging_toxygen_echo
|
from tox_wrapper.tests.support_testing import logging_toxygen_echo
|
||||||
|
|
||||||
def sleep(fSec):
|
def sleep(fSec):
|
||||||
if 'QtCore' in globals():
|
if 'QtCore' in globals():
|
||||||
|
@ -57,7 +57,7 @@ except ImportError as e:
|
||||||
# logging.log(logging.DEBUG, f"coloredlogs not available: {e}")
|
# logging.log(logging.DEBUG, f"coloredlogs not available: {e}")
|
||||||
coloredlogs = None
|
coloredlogs = None
|
||||||
|
|
||||||
import wrapper_tests.support_testing as ts
|
import tox_wrapper.tests.support_testing as ts
|
||||||
if 'USER' in os.environ:
|
if 'USER' in os.environ:
|
||||||
sDATA_FILE = '/tmp/logging_toxygen_' +os.environ['USER'] +'.tox'
|
sDATA_FILE = '/tmp/logging_toxygen_' +os.environ['USER'] +'.tox'
|
||||||
elif 'USERNAME' in os.environ:
|
elif 'USERNAME' in os.environ:
|
||||||
|
@ -71,7 +71,7 @@ iDHT_TRY = 0
|
||||||
|
|
||||||
#?SERVER = lLOCAL[-1]
|
#?SERVER = lLOCAL[-1]
|
||||||
|
|
||||||
class AV(wrapper.tox.ToxAV):
|
class AV(tox_wrapper.tox.ToxAV):
|
||||||
def __init__(self, core):
|
def __init__(self, core):
|
||||||
super(AV, self).__init__(core)
|
super(AV, self).__init__(core)
|
||||||
self.core = self.get_tox()
|
self.core = self.get_tox()
|
||||||
|
@ -149,7 +149,7 @@ class EchoBot():
|
||||||
message_data_size,
|
message_data_size,
|
||||||
*largs):
|
*largs):
|
||||||
key = ''.join(chr(x) for x in public_key[:TOX_PUBLIC_KEY_SIZE])
|
key = ''.join(chr(x) for x in public_key[:TOX_PUBLIC_KEY_SIZE])
|
||||||
sPk = wrapper.tox.bin_to_string(key, TOX_PUBLIC_KEY_SIZE)
|
sPk = tox_wrapper.tox.bin_to_string(key, TOX_PUBLIC_KEY_SIZE)
|
||||||
sMd = str(message_data, 'UTF-8')
|
sMd = str(message_data, 'UTF-8')
|
||||||
LOG.debug('on_friend_request ' +sPk +' ' +sMd)
|
LOG.debug('on_friend_request ' +sPk +' ' +sMd)
|
||||||
self.on_friend_request(sPk, sMd)
|
self.on_friend_request(sPk, sMd)
|
||||||
|
@ -339,7 +339,7 @@ def iMain(oArgs):
|
||||||
oTox = tox_factory(data=opts.savedata_data,
|
oTox = tox_factory(data=opts.savedata_data,
|
||||||
settings=opts, args=oArgs, app=None)
|
settings=opts, args=oArgs, app=None)
|
||||||
else:
|
else:
|
||||||
oTox = wrapper.tox.Tox(opts)
|
oTox = tox_wrapper.tox.Tox(opts)
|
||||||
t = EchoBot(oTox)
|
t = EchoBot(oTox)
|
||||||
t._oargs = oArgs
|
t._oargs = oArgs
|
||||||
t.start()
|
t.start()
|
||||||
|
@ -358,7 +358,7 @@ def iMain(oArgs):
|
||||||
return iRet
|
return iRet
|
||||||
|
|
||||||
def oToxygenToxOptions(oArgs, data=None):
|
def oToxygenToxOptions(oArgs, data=None):
|
||||||
tox_options = wrapper.tox.Tox.options_new()
|
tox_options = tox_wrapper.tox.Tox.options_new()
|
||||||
|
|
||||||
tox_options.contents.local_discovery_enabled = False
|
tox_options.contents.local_discovery_enabled = False
|
||||||
tox_options.contents.dht_announcements_enabled = False
|
tox_options.contents.dht_announcements_enabled = False
|
||||||
|
|
|
@ -36,11 +36,11 @@ try:
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
nmap = False
|
nmap = False
|
||||||
|
|
||||||
import wrapper
|
import tox_wrapper
|
||||||
from wrapper.toxcore_enums_and_consts import TOX_CONNECTION, TOX_USER_STATUS
|
from tox_wrapper.toxcore_enums_and_consts import TOX_CONNECTION, TOX_USER_STATUS
|
||||||
|
|
||||||
from wrapper_tests.support_http import bAreWeConnected
|
from tox_wrapper.tests.support_http import bAreWeConnected
|
||||||
from wrapper_tests.support_onions import (is_valid_fingerprint,
|
from tox_wrapper.tests.support_onions import (is_valid_fingerprint,
|
||||||
lIntroductionPoints,
|
lIntroductionPoints,
|
||||||
oGetStemController,
|
oGetStemController,
|
||||||
sMapaddressResolv, sTorResolve)
|
sMapaddressResolv, sTorResolve)
|
||||||
|
@ -245,7 +245,7 @@ def tox_log_cb(level, filename, line, func, message, *args):
|
||||||
|
|
||||||
def vAddLoggerCallback(tox_options, callback=None):
|
def vAddLoggerCallback(tox_options, callback=None):
|
||||||
if callback is None:
|
if callback is None:
|
||||||
wrapper.tox.Tox.libtoxcore.tox_options_set_log_callback(
|
tox_wrapper.tox.Tox.libtoxcore.tox_options_set_log_callback(
|
||||||
tox_options._options_pointer,
|
tox_options._options_pointer,
|
||||||
POINTER(None)())
|
POINTER(None)())
|
||||||
tox_options.self_logger_cb = None
|
tox_options.self_logger_cb = None
|
||||||
|
@ -253,7 +253,7 @@ def vAddLoggerCallback(tox_options, callback=None):
|
||||||
|
|
||||||
c_callback = CFUNCTYPE(None, c_void_p, c_int, c_char_p, c_int, c_char_p, c_char_p, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, c_int, c_char_p, c_int, c_char_p, c_char_p, c_void_p)
|
||||||
tox_options.self_logger_cb = c_callback(callback)
|
tox_options.self_logger_cb = c_callback(callback)
|
||||||
wrapper.tox.Tox.libtoxcore.tox_options_set_log_callback(
|
tox_wrapper.tox.Tox.libtoxcore.tox_options_set_log_callback(
|
||||||
tox_options._options_pointer,
|
tox_options._options_pointer,
|
||||||
tox_options.self_logger_cb)
|
tox_options.self_logger_cb)
|
||||||
|
|
||||||
|
|
|
@ -854,14 +854,14 @@ id(42)
|
||||||
cmd = textwrap.dedent('''
|
cmd = textwrap.dedent('''
|
||||||
class MyList(list):
|
class MyList(list):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__() # wrapper_call()
|
super().__init__() # tox_wrapper_call()
|
||||||
|
|
||||||
id("first break point")
|
id("first break point")
|
||||||
l = MyList()
|
l = MyList()
|
||||||
''')
|
''')
|
||||||
# Verify with "py-bt":
|
# Verify with "py-bt":
|
||||||
gdb_output = self.get_stack_trace(cmd,
|
gdb_output = self.get_stack_trace(cmd,
|
||||||
cmds_after_breakpoint=['break wrapper_call', 'continue', 'py-bt'])
|
cmds_after_breakpoint=['break tox_wrapper_call', 'continue', 'py-bt'])
|
||||||
self.assertRegex(gdb_output,
|
self.assertRegex(gdb_output,
|
||||||
r"<method-wrapper u?'__init__' of MyList object at ")
|
r"<method-wrapper u?'__init__' of MyList object at ")
|
||||||
|
|
||||||
|
|
|
@ -67,10 +67,10 @@ except ImportError as e:
|
||||||
logging.log(logging.DEBUG, f"color_runner not available: {e}")
|
logging.log(logging.DEBUG, f"color_runner not available: {e}")
|
||||||
color_runner = None
|
color_runner = None
|
||||||
|
|
||||||
import wrapper
|
import tox_wrapper
|
||||||
import wrapper.toxcore_enums_and_consts as enums
|
import tox_wrapper.toxcore_enums_and_consts as enums
|
||||||
from wrapper.tox import Tox
|
from tox_wrapper.tox import Tox
|
||||||
from wrapper.toxcore_enums_and_consts import (TOX_ADDRESS_SIZE, TOX_CONNECTION,
|
from tox_wrapper.toxcore_enums_and_consts import (TOX_ADDRESS_SIZE, TOX_CONNECTION,
|
||||||
TOX_FILE_CONTROL,
|
TOX_FILE_CONTROL,
|
||||||
TOX_MESSAGE_TYPE,
|
TOX_MESSAGE_TYPE,
|
||||||
TOX_SECRET_KEY_SIZE,
|
TOX_SECRET_KEY_SIZE,
|
||||||
|
@ -79,7 +79,7 @@ from wrapper.toxcore_enums_and_consts import (TOX_ADDRESS_SIZE, TOX_CONNECTION,
|
||||||
try:
|
try:
|
||||||
import support_testing as ts
|
import support_testing as ts
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import wrapper_tests.support_testing as ts
|
import tox_wrapper.tests.support_testing as ts
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from tests.toxygen_tests import test_sound_notification
|
from tests.toxygen_tests import test_sound_notification
|
||||||
|
@ -1788,7 +1788,7 @@ def iMain(oArgs):
|
||||||
|
|
||||||
def oToxygenToxOptions(oArgs):
|
def oToxygenToxOptions(oArgs):
|
||||||
data = None
|
data = None
|
||||||
tox_options = wrapper.tox.Tox.options_new()
|
tox_options = tox_wrapper.tox.Tox.options_new()
|
||||||
if oArgs.proxy_type:
|
if oArgs.proxy_type:
|
||||||
tox_options.contents.proxy_type = int(oArgs.proxy_type)
|
tox_options.contents.proxy_type = int(oArgs.proxy_type)
|
||||||
tox_options.contents.proxy_host = bytes(oArgs.proxy_host, 'UTF-8')
|
tox_options.contents.proxy_host = bytes(oArgs.proxy_host, 'UTF-8')
|
||||||
|
|
|
@ -67,10 +67,10 @@ except ImportError as e:
|
||||||
logging.log(logging.DEBUG, f"color_runner not available: {e}")
|
logging.log(logging.DEBUG, f"color_runner not available: {e}")
|
||||||
color_runner = None
|
color_runner = None
|
||||||
|
|
||||||
import wrapper
|
import tox_wrapper
|
||||||
import wrapper.toxcore_enums_and_consts as enums
|
import tox_wrapper.toxcore_enums_and_consts as enums
|
||||||
from wrapper.tox import Tox
|
from tox_wrapper.tox import Tox
|
||||||
from wrapper.toxcore_enums_and_consts import (TOX_ADDRESS_SIZE, TOX_CONNECTION,
|
from tox_wrapper.toxcore_enums_and_consts import (TOX_ADDRESS_SIZE, TOX_CONNECTION,
|
||||||
TOX_FILE_CONTROL,
|
TOX_FILE_CONTROL,
|
||||||
TOX_MESSAGE_TYPE,
|
TOX_MESSAGE_TYPE,
|
||||||
TOX_SECRET_KEY_SIZE,
|
TOX_SECRET_KEY_SIZE,
|
||||||
|
@ -79,7 +79,7 @@ from wrapper.toxcore_enums_and_consts import (TOX_ADDRESS_SIZE, TOX_CONNECTION,
|
||||||
try:
|
try:
|
||||||
import support_testing as ts
|
import support_testing as ts
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import wrapper_tests.support_testing as ts
|
import tox_wrapper.tests.support_testing as ts
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from tests.toxygen_tests import test_sound_notification
|
from tests.toxygen_tests import test_sound_notification
|
||||||
|
@ -1788,7 +1788,7 @@ def iMain(oArgs):
|
||||||
|
|
||||||
def oToxygenToxOptions(oArgs):
|
def oToxygenToxOptions(oArgs):
|
||||||
data = None
|
data = None
|
||||||
tox_options = wrapper.tox.Tox.options_new()
|
tox_options = tox_wrapper.tox.Tox.options_new()
|
||||||
if oArgs.proxy_type:
|
if oArgs.proxy_type:
|
||||||
tox_options.contents.proxy_type = int(oArgs.proxy_type)
|
tox_options.contents.proxy_type = int(oArgs.proxy_type)
|
||||||
tox_options.contents.proxy_host = bytes(oArgs.proxy_host, 'UTF-8')
|
tox_options.contents.proxy_host = bytes(oArgs.proxy_host, 'UTF-8')
|
||||||
|
|
|
@ -6,7 +6,7 @@ import wave
|
||||||
|
|
||||||
from ui import widgets
|
from ui import widgets
|
||||||
import utils.util as util
|
import utils.util as util
|
||||||
import wrapper_tests.support_testing as ts
|
import tox_wrapper.tests.support_testing as ts
|
||||||
|
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from wrapper.toxcore_enums_and_consts import *
|
from tox_wrapper.toxcore_enums_and_consts import *
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
from utils.util import *
|
from utils.util import *
|
||||||
from ui.widgets import DataLabel
|
from ui.widgets import DataLabel
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from ui.widgets import *
|
from ui.widgets import *
|
||||||
from wrapper.toxcore_enums_and_consts import *
|
from tox_wrapper.toxcore_enums_and_consts import *
|
||||||
|
|
||||||
|
|
||||||
class PeerItem(QtWidgets.QWidget):
|
class PeerItem(QtWidgets.QWidget):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from PyQt5 import uic
|
from PyQt5 import uic
|
||||||
import utils.util as util
|
import utils.util as util
|
||||||
from ui.widgets import *
|
from ui.widgets import *
|
||||||
from wrapper.toxcore_enums_and_consts import *
|
from tox_wrapper.toxcore_enums_and_consts import *
|
||||||
|
|
||||||
|
|
||||||
class BaseGroupScreen(CenteredWidget):
|
class BaseGroupScreen(CenteredWidget):
|
||||||
|
|
|
@ -7,7 +7,7 @@ from utils.util import *
|
||||||
from ui.widgets import CenteredWidget, DataLabel, LineEdit, RubberBandWindow
|
from ui.widgets import CenteredWidget, DataLabel, LineEdit, RubberBandWindow
|
||||||
import updater.updater as updater
|
import updater.updater as updater
|
||||||
import utils.ui as util_ui
|
import utils.ui as util_ui
|
||||||
import wrapper_tests.support_testing as ts
|
import tox_wrapper.tests.support_testing as ts
|
||||||
from user_data import settings
|
from user_data import settings
|
||||||
|
|
||||||
global LOG
|
global LOG
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from wrapper.toxcore_enums_and_consts import *
|
from tox_wrapper.toxcore_enums_and_consts import *
|
||||||
import ui.widgets as widgets
|
import ui.widgets as widgets
|
||||||
import utils.util as util
|
import utils.util as util
|
||||||
import ui.menu as menu
|
import ui.menu as menu
|
||||||
|
|
|
@ -3,7 +3,7 @@ from PyQt5 import uic
|
||||||
import utils.util as util
|
import utils.util as util
|
||||||
import utils.ui as util_ui
|
import utils.ui as util_ui
|
||||||
from ui.contact_items import *
|
from ui.contact_items import *
|
||||||
import wrapper.toxcore_enums_and_consts as consts
|
import tox_wrapper.toxcore_enums_and_consts as consts
|
||||||
|
|
||||||
|
|
||||||
class PeerScreen(CenteredWidget):
|
class PeerScreen(CenteredWidget):
|
||||||
|
|
|
@ -9,13 +9,7 @@ from user_data.settings import get_user_config_path
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
LOG = logging.getLogger('app.'+__name__)
|
LOG = logging.getLogger('app.'+__name__)
|
||||||
|
from av.calls import LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG, LOG_TRACE
|
||||||
|
|
||||||
def LOG_ERROR(l): print('ERROR_: '+l)
|
|
||||||
def LOG_WARN(l): print('WARN_: '+l)
|
|
||||||
def LOG_INFO(l): print('INFO_: '+l)
|
|
||||||
def LOG_DEBUG(l): print('DEBUG_: '+l)
|
|
||||||
def LOG_TRACE(l): pass # print('TRACE+ '+l)
|
|
||||||
|
|
||||||
class ProfileManager:
|
class ProfileManager:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -3,15 +3,13 @@
|
||||||
import os
|
import os
|
||||||
from platform import system
|
from platform import system
|
||||||
import json
|
import json
|
||||||
from pprint import pprint
|
|
||||||
|
|
||||||
from utils.util import *
|
from utils import util
|
||||||
from utils.util import log, join_path
|
from utils.util import log, join_path
|
||||||
from common.event import Event
|
from common.event import Event
|
||||||
import utils.ui as util_ui
|
import utils.ui as util_ui
|
||||||
import utils.util as util_utils
|
import utils.util as util_utils
|
||||||
import user_data
|
import user_data
|
||||||
import wrapper_tests.support_testing as ts
|
|
||||||
|
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
|
@ -106,8 +104,8 @@ def built_in_themes():
|
||||||
'default': 'style.qss'
|
'default': 'style.qss'
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_global_settings_path():
|
#def get_global_settings_path():
|
||||||
return os.path.join(get_base_directory(), 'toxygen.json')
|
# return os.path.join(get_base_directory(), 'toxygen.json')
|
||||||
|
|
||||||
def is_active_profile(profile_path):
|
def is_active_profile(profile_path):
|
||||||
sFile = profile_path + '.lock'
|
sFile = profile_path + '.lock'
|
||||||
|
@ -138,6 +136,7 @@ class Settings(dict):
|
||||||
self._profile_path = path.replace('.json', '.tox')
|
self._profile_path = path.replace('.json', '.tox')
|
||||||
self._toxes = toxes
|
self._toxes = toxes
|
||||||
self._app = app
|
self._app = app
|
||||||
|
self._path = app._path
|
||||||
self._args = app._args
|
self._args = app._args
|
||||||
self._oArgs = app._args
|
self._oArgs = app._args
|
||||||
self._log = lambda l: LOG.log(self._oArgs.loglevel, l)
|
self._log = lambda l: LOG.log(self._oArgs.loglevel, l)
|
||||||
|
@ -179,6 +178,7 @@ class Settings(dict):
|
||||||
merge_args_into_settings(app._args, info)
|
merge_args_into_settings(app._args, info)
|
||||||
info['audio'] = getattr(app._args, 'audio')
|
info['audio'] = getattr(app._args, 'audio')
|
||||||
info['video'] = getattr(app._args, 'video')
|
info['video'] = getattr(app._args, 'video')
|
||||||
|
info['trace_enabled'] = getattr(app._args, 'trace_enabled')
|
||||||
super().__init__(info)
|
super().__init__(info)
|
||||||
self._upgrade()
|
self._upgrade()
|
||||||
|
|
||||||
|
@ -191,7 +191,6 @@ class Settings(dict):
|
||||||
self.closing = False
|
self.closing = False
|
||||||
self.unlockScreen = False
|
self.unlockScreen = False
|
||||||
|
|
||||||
|
|
||||||
# Properties
|
# Properties
|
||||||
|
|
||||||
def get_settings_saved_event(self):
|
def get_settings_saved_event(self):
|
||||||
|
@ -252,7 +251,8 @@ class Settings(dict):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_auto_profile():
|
def get_auto_profile():
|
||||||
p = get_global_settings_path()
|
# self._path =
|
||||||
|
p = os.path.join(os.path.dirname(self._app._path), 'toxygen.json')
|
||||||
if not os.path.isfile(p):
|
if not os.path.isfile(p):
|
||||||
return None
|
return None
|
||||||
with open(p) as fl:
|
with open(p) as fl:
|
||||||
|
@ -276,7 +276,7 @@ class Settings(dict):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set_auto_profile(path):
|
def set_auto_profile(path):
|
||||||
p = get_global_settings_path()
|
p = os.path.join(os.path.dirname(self._app._path), 'toxygen.json')
|
||||||
if os.path.isfile(p):
|
if os.path.isfile(p):
|
||||||
with open(p) as fl:
|
with open(p) as fl:
|
||||||
data = fl.read()
|
data = fl.read()
|
||||||
|
@ -289,7 +289,7 @@ class Settings(dict):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def reset_auto_profile():
|
def reset_auto_profile():
|
||||||
p = get_global_settings_path()
|
p = os.path.join(os.path.dirname(self._app._path), 'toxygen.json')
|
||||||
if os.path.isfile(p):
|
if os.path.isfile(p):
|
||||||
with open(p) as fl:
|
with open(p) as fl:
|
||||||
data = fl.read()
|
data = fl.read()
|
||||||
|
|
Loading…
Reference in a new issue