|
|
|
@ -87,7 +87,7 @@ IDLE_PERIOD = 0.10
|
|
|
|
|
iNODES=8
|
|
|
|
|
bSHOW_TRAY=False
|
|
|
|
|
|
|
|
|
|
def setup_logging(oArgs):
|
|
|
|
|
def setup_logging(oArgs) -> None:
|
|
|
|
|
global LOG
|
|
|
|
|
logging._defaultFormatter = logging.Formatter(datefmt='%m-%d %H:%M:%S',
|
|
|
|
|
fmt='%(levelname)s:%(name)s %(message)s')
|
|
|
|
@ -185,14 +185,14 @@ class App:
|
|
|
|
|
|
|
|
|
|
# Public methods
|
|
|
|
|
|
|
|
|
|
def set_trace(self):
|
|
|
|
|
def set_trace(self) -> None:
|
|
|
|
|
"""unused"""
|
|
|
|
|
LOG.debug('pdb.set_trace ')
|
|
|
|
|
sys.stdin = sys.__stdin__
|
|
|
|
|
sys.stdout = sys.__stdout__
|
|
|
|
|
import pdb; pdb.set_trace()
|
|
|
|
|
|
|
|
|
|
def ten(self, i=0):
|
|
|
|
|
def ten(self, i=0) -> None:
|
|
|
|
|
"""unused"""
|
|
|
|
|
global iI
|
|
|
|
|
iI += 1
|
|
|
|
@ -204,7 +204,7 @@ class App:
|
|
|
|
|
#sys.stderr.write(f"ten '+str(iI)+' {i}"+' '+repr(LOG) +'\n')
|
|
|
|
|
#LOG.debug('ten '+str(iI))
|
|
|
|
|
|
|
|
|
|
def iMain(self):
|
|
|
|
|
def iMain(self) -> int:
|
|
|
|
|
"""
|
|
|
|
|
Main function of app. loads login screen if needed and starts main screen
|
|
|
|
|
"""
|
|
|
|
@ -257,7 +257,7 @@ class App:
|
|
|
|
|
|
|
|
|
|
# App executing
|
|
|
|
|
|
|
|
|
|
def _execute_app(self):
|
|
|
|
|
def _execute_app(self) -> None:
|
|
|
|
|
LOG.debug("_execute_app")
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
@ -268,7 +268,7 @@ class App:
|
|
|
|
|
else:
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
def quit(self, retval=0):
|
|
|
|
|
def quit(self, retval=0) -> None:
|
|
|
|
|
LOG.debug("quit")
|
|
|
|
|
self._stop_app()
|
|
|
|
|
|
|
|
|
@ -293,7 +293,7 @@ class App:
|
|
|
|
|
|
|
|
|
|
raise SystemExit(retval)
|
|
|
|
|
|
|
|
|
|
def _stop_app(self):
|
|
|
|
|
def _stop_app(self) -> None:
|
|
|
|
|
LOG.debug("_stop_app")
|
|
|
|
|
self._save_profile()
|
|
|
|
|
#? self._history.save_history()
|
|
|
|
@ -321,7 +321,7 @@ class App:
|
|
|
|
|
|
|
|
|
|
# App loading
|
|
|
|
|
|
|
|
|
|
def _load_base_style(self):
|
|
|
|
|
def _load_base_style(self) -> None:
|
|
|
|
|
if self._args.theme in ['', 'default']: return
|
|
|
|
|
|
|
|
|
|
if qdarkstyle:
|
|
|
|
@ -341,7 +341,7 @@ class App:
|
|
|
|
|
style += '\n' +sSTYLE
|
|
|
|
|
self._app.setStyleSheet(style)
|
|
|
|
|
|
|
|
|
|
def _load_app_styles(self):
|
|
|
|
|
def _load_app_styles(self) -> None:
|
|
|
|
|
LOG.debug(f"_load_app_styles {list(settings.built_in_themes().keys())!r}")
|
|
|
|
|
# application color scheme
|
|
|
|
|
if self._settings['theme'] in ['', 'default']: return
|
|
|
|
@ -371,7 +371,7 @@ class App:
|
|
|
|
|
LOG.info('_load_app_styles: loaded theme ' +self._args.theme)
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
def _load_login_screen_translations(self):
|
|
|
|
|
def _load_login_screen_translations(self) -> None:
|
|
|
|
|
LOG.debug("_load_login_screen_translations")
|
|
|
|
|
current_language, supported_languages = self._get_languages()
|
|
|
|
|
if current_language not in supported_languages:
|
|
|
|
@ -382,13 +382,13 @@ class App:
|
|
|
|
|
self._app.installTranslator(translator)
|
|
|
|
|
self._app.translator = translator
|
|
|
|
|
|
|
|
|
|
def _load_icon(self):
|
|
|
|
|
def _load_icon(self) -> None:
|
|
|
|
|
LOG.debug("_load_icon")
|
|
|
|
|
icon_file = os.path.join(util.get_images_directory(), 'icon.png')
|
|
|
|
|
self._app.setWindowIcon(QtGui.QIcon(icon_file))
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def _get_languages():
|
|
|
|
|
def _get_languages() -> tuple:
|
|
|
|
|
LOG.debug("_get_languages")
|
|
|
|
|
current_locale = QtCore.QLocale()
|
|
|
|
|
curr_language = current_locale.languageToString(current_locale.language())
|
|
|
|
@ -396,7 +396,7 @@ class App:
|
|
|
|
|
|
|
|
|
|
return curr_language, supported_languages
|
|
|
|
|
|
|
|
|
|
def _load_app_translations(self):
|
|
|
|
|
def _load_app_translations(self) -> None:
|
|
|
|
|
LOG.debug("_load_app_translations")
|
|
|
|
|
lang = settings.supported_languages()[self._settings['language']]
|
|
|
|
|
translator = QtCore.QTranslator()
|
|
|
|
@ -404,7 +404,7 @@ class App:
|
|
|
|
|
self._app.installTranslator(translator)
|
|
|
|
|
self._app.translator = translator
|
|
|
|
|
|
|
|
|
|
def _select_and_load_profile(self):
|
|
|
|
|
def _select_and_load_profile(self) -> bool:
|
|
|
|
|
LOG.debug("_select_and_load_profile: " +repr(self._path))
|
|
|
|
|
|
|
|
|
|
if self._path is not None:
|
|
|
|
@ -468,7 +468,7 @@ class App:
|
|
|
|
|
|
|
|
|
|
# Threads
|
|
|
|
|
|
|
|
|
|
def _start_threads(self, initial_start=True):
|
|
|
|
|
def _start_threads(self, initial_start=True) -> None:
|
|
|
|
|
LOG.debug(f"_start_threads before: {threading.enumerate()!r}")
|
|
|
|
|
# init thread
|
|
|
|
|
self._init = threads.InitThread(self._tox,
|
|
|
|
@ -491,7 +491,7 @@ class App:
|
|
|
|
|
threads.start_file_transfer_thread()
|
|
|
|
|
LOG.debug(f"_start_threads after: {[t.name for t in threading.enumerate()]!r}")
|
|
|
|
|
|
|
|
|
|
def _stop_threads(self, is_app_closing=True):
|
|
|
|
|
def _stop_threads(self, is_app_closing=True) -> None:
|
|
|
|
|
LOG.debug("_stop_threads")
|
|
|
|
|
self._init.stop_thread(1.0)
|
|
|
|
|
|
|
|
|
@ -501,7 +501,7 @@ class App:
|
|
|
|
|
if is_app_closing:
|
|
|
|
|
threads.stop_file_transfer_thread()
|
|
|
|
|
|
|
|
|
|
def iterate(self, n=100):
|
|
|
|
|
def iterate(self, n=100) -> None:
|
|
|
|
|
interval = self._tox.iteration_interval()
|
|
|
|
|
for i in range(n):
|
|
|
|
|
self._tox.iterate()
|
|
|
|
@ -520,7 +520,7 @@ class App:
|
|
|
|
|
self._app.exec_()
|
|
|
|
|
return ls.result
|
|
|
|
|
|
|
|
|
|
def _load_existing_profile(self, profile_path):
|
|
|
|
|
def _load_existing_profile(self, profile_path) -> None:
|
|
|
|
|
LOG.info("_load_existing_profile " +repr(profile_path))
|
|
|
|
|
assert os.path.exists(profile_path), profile_path
|
|
|
|
|
self._profile_manager = ProfileManager(self._toxes, profile_path)
|
|
|
|
@ -536,7 +536,7 @@ class App:
|
|
|
|
|
self._tox = self._create_tox(data, self._settings)
|
|
|
|
|
LOG.debug("created _tox")
|
|
|
|
|
|
|
|
|
|
def _create_new_profile(self, profile_name):
|
|
|
|
|
def _create_new_profile(self, profile_name) -> bool:
|
|
|
|
|
LOG.info("_create_new_profile " + profile_name)
|
|
|
|
|
result = self._get_create_profile_screen_result()
|
|
|
|
|
if result is None:
|
|
|
|
@ -587,7 +587,7 @@ class App:
|
|
|
|
|
|
|
|
|
|
return cps.result
|
|
|
|
|
|
|
|
|
|
def _save_profile(self, data=None):
|
|
|
|
|
def _save_profile(self, data=None) -> None:
|
|
|
|
|
LOG.debug("_save_profile")
|
|
|
|
|
data = data or self._tox.get_savedata()
|
|
|
|
|
self._profile_manager.save_profile(data)
|
|
|
|
@ -608,7 +608,7 @@ class App:
|
|
|
|
|
self._force_exit(0)
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def _reset(self):
|
|
|
|
|
def _reset(self) -> None:
|
|
|
|
|
LOG.debug("_reset")
|
|
|
|
|
"""
|
|
|
|
|
Create new tox instance (new network settings)
|
|
|
|
@ -648,7 +648,7 @@ class App:
|
|
|
|
|
text = util_ui.tr('Error:') + str(e)
|
|
|
|
|
util_ui.message_box(text, title)
|
|
|
|
|
|
|
|
|
|
def _create_dependencies(self):
|
|
|
|
|
def _create_dependencies(self) -> None:
|
|
|
|
|
LOG.info(f"_create_dependencies toxygen version {self._version}")
|
|
|
|
|
if hasattr(self._args, 'update') and self._args.update:
|
|
|
|
|
self._backup_service = BackupService(self._settings,
|
|
|
|
@ -794,11 +794,11 @@ class App:
|
|
|
|
|
self._tox = retval
|
|
|
|
|
return retval
|
|
|
|
|
|
|
|
|
|
def _force_exit(self, retval=0):
|
|
|
|
|
def _force_exit(self, retval=0) -> None:
|
|
|
|
|
LOG.debug("_force_exit")
|
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|
|
def _init_callbacks(self, ms=None):
|
|
|
|
|
def _init_callbacks(self, ms=None) -> None:
|
|
|
|
|
LOG.debug("_init_callbacks")
|
|
|
|
|
# this will block if you are not connected
|
|
|
|
|
callbacks.init_callbacks(self._tox, self._profile, self._settings,
|
|
|
|
@ -809,21 +809,21 @@ class App:
|
|
|
|
|
self._messenger, self._groups_service,
|
|
|
|
|
self._contacts_provider, self._ms)
|
|
|
|
|
|
|
|
|
|
def _init_profile(self):
|
|
|
|
|
def _init_profile(self) -> None:
|
|
|
|
|
LOG.debug("_init_profile")
|
|
|
|
|
if not self._profile.has_avatar():
|
|
|
|
|
self._profile.reset_avatar(self._settings['identicons'])
|
|
|
|
|
|
|
|
|
|
def _kill_toxav(self):
|
|
|
|
|
def _kill_toxav(self) -> None:
|
|
|
|
|
# LOG_debug("_kill_toxav")
|
|
|
|
|
self._calls_manager.set_toxav(None)
|
|
|
|
|
self._tox.AV.kill()
|
|
|
|
|
|
|
|
|
|
def _kill_tox(self):
|
|
|
|
|
def _kill_tox(self) -> None:
|
|
|
|
|
# LOG.debug("_kill_tox")
|
|
|
|
|
self._tox.kill()
|
|
|
|
|
|
|
|
|
|
def loop(self, n):
|
|
|
|
|
def loop(self, n) -> None:
|
|
|
|
|
"""
|
|
|
|
|
Im guessings - there are 3 sleeps - time, tox, and Qt
|
|
|
|
|
"""
|
|
|
|
@ -834,11 +834,11 @@ class App:
|
|
|
|
|
# NO QtCore.QCoreApplication.processEvents()
|
|
|
|
|
sleep(interval / 1000.0)
|
|
|
|
|
|
|
|
|
|
def _test_tox(self):
|
|
|
|
|
def _test_tox(self) -> None:
|
|
|
|
|
self.test_net(iMax=8)
|
|
|
|
|
self._ms.log_console()
|
|
|
|
|
|
|
|
|
|
def test_net(self, lElts=None, oThread=None, iMax=4):
|
|
|
|
|
def test_net(self, lElts=None, oThread=None, iMax=4) -> None:
|
|
|
|
|
|
|
|
|
|
# bootstrap
|
|
|
|
|
LOG.debug('test_net: Calling generate_nodes: udp')
|
|
|
|
@ -906,7 +906,7 @@ class App:
|
|
|
|
|
LOG.trace(f"Connected status #{i}: {status!r}")
|
|
|
|
|
self.loop(2)
|
|
|
|
|
|
|
|
|
|
def _test_env(self):
|
|
|
|
|
def _test_env(self) -> None:
|
|
|
|
|
_settings = self._settings
|
|
|
|
|
if 'proxy_type' not in _settings or _settings['proxy_type'] == 0 or \
|
|
|
|
|
not _settings['proxy_host'] or not _settings['proxy_port']:
|
|
|
|
@ -929,7 +929,7 @@ class App:
|
|
|
|
|
# LOG.debug(f"test_env {len(lElts)}")
|
|
|
|
|
return env
|
|
|
|
|
|
|
|
|
|
def _test_bootstrap(self, lElts=None):
|
|
|
|
|
def _test_bootstrap(self, lElts=None) -> None:
|
|
|
|
|
if lElts is None:
|
|
|
|
|
lElts = self._settings['current_nodes_udp']
|
|
|
|
|
LOG.debug(f"_test_bootstrap #Elts={len(lElts)}")
|
|
|
|
@ -939,14 +939,14 @@ class App:
|
|
|
|
|
ts.bootstrap_udp(lElts[:iNODES], [self._tox])
|
|
|
|
|
LOG.info("Connected status: " +repr(self._tox.self_get_connection_status()))
|
|
|
|
|
|
|
|
|
|
def _test_relays(self, lElts=None):
|
|
|
|
|
def _test_relays(self, lElts=None) -> None:
|
|
|
|
|
if lElts is None:
|
|
|
|
|
lElts = self._settings['current_nodes_tcp']
|
|
|
|
|
shuffle(lElts)
|
|
|
|
|
LOG.debug(f"_test_relays {len(lElts)}")
|
|
|
|
|
ts.bootstrap_tcp(lElts[:iNODES], [self._tox])
|
|
|
|
|
|
|
|
|
|
def _test_nmap(self, lElts=None):
|
|
|
|
|
def _test_nmap(self, lElts=None) -> None:
|
|
|
|
|
LOG.debug("_test_nmap")
|
|
|
|
|
if not self._tox: return
|
|
|
|
|
title = 'Extended Test Suite'
|
|
|
|
@ -980,7 +980,7 @@ class App:
|
|
|
|
|
# LOG.info("Connected status: " +repr(self._tox.self_get_connection_status()))
|
|
|
|
|
self._ms.log_console()
|
|
|
|
|
|
|
|
|
|
def _test_main(self):
|
|
|
|
|
def _test_main(self) -> None:
|
|
|
|
|
from toxygen_tox_wrapper.tox_wrapper.tests.tests_wrapper import main as tests_main
|
|
|
|
|
LOG.debug("_test_main")
|
|
|
|
|
if not self._tox: return
|
|
|
|
@ -1017,11 +1017,13 @@ class GEventProcessing:
|
|
|
|
|
self._timer = QTimer()
|
|
|
|
|
self._timer.timeout.connect(self.process_events)
|
|
|
|
|
self._timer.start(0)
|
|
|
|
|
def __enter__(self):
|
|
|
|
|
def __enter__(self) -> None:
|
|
|
|
|
pass
|
|
|
|
|
def __exit__(self, *exc_info):
|
|
|
|
|
|
|
|
|
|
def __exit__(self, *exc_info) -> None:
|
|
|
|
|
self._timer.stop()
|
|
|
|
|
def process_events(self, idle_period=None):
|
|
|
|
|
|
|
|
|
|
def process_events(self, idle_period=None) -> None:
|
|
|
|
|
if idle_period is None:
|
|
|
|
|
idle_period = self._idle_period
|
|
|
|
|
# Cooperative yield, allow gevent to monitor file handles via libevent
|
|
|
|
|