|
|
|
@ -3,8 +3,13 @@ import threading
|
|
|
|
|
import queue
|
|
|
|
|
from utils import util
|
|
|
|
|
import time
|
|
|
|
|
from PyQt5 import QtCore
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------------------------------------------
|
|
|
|
|
# Base threads
|
|
|
|
|
# -----------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
class BaseThread(threading.Thread):
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
@ -16,6 +21,21 @@ class BaseThread(threading.Thread):
|
|
|
|
|
self.join()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BaseQThread(QtCore.QThread):
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
super().__init__()
|
|
|
|
|
self._stop_thread = False
|
|
|
|
|
|
|
|
|
|
def stop_thread(self):
|
|
|
|
|
self._stop_thread = True
|
|
|
|
|
self.wait()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------------------------------------------
|
|
|
|
|
# Toxcore threads
|
|
|
|
|
# -----------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
class InitThread(BaseThread):
|
|
|
|
|
|
|
|
|
|
def __init__(self, tox, plugin_loader, settings):
|
|
|
|
@ -53,7 +73,7 @@ class InitThread(BaseThread):
|
|
|
|
|
time.sleep(5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ToxIterateThread(BaseThread):
|
|
|
|
|
class ToxIterateThread(BaseQThread):
|
|
|
|
|
|
|
|
|
|
def __init__(self, tox):
|
|
|
|
|
super().__init__()
|
|
|
|
@ -65,7 +85,7 @@ class ToxIterateThread(BaseThread):
|
|
|
|
|
time.sleep(self._tox.iteration_interval() / 1000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ToxAVIterateThread(BaseThread):
|
|
|
|
|
class ToxAVIterateThread(BaseQThread):
|
|
|
|
|
|
|
|
|
|
def __init__(self, toxav):
|
|
|
|
|
super().__init__()
|
|
|
|
@ -77,6 +97,10 @@ class ToxAVIterateThread(BaseThread):
|
|
|
|
|
time.sleep(self._toxav.iteration_interval() / 1000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------------------------------------------
|
|
|
|
|
# File transfers thread
|
|
|
|
|
# -----------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
class FileTransfersThread(BaseThread):
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
@ -115,6 +139,10 @@ def execute(func, *args, **kwargs):
|
|
|
|
|
_thread.execute(func, *args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------------------------------------------
|
|
|
|
|
# Invoking in main thread
|
|
|
|
|
# -----------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
class InvokeEvent(QtCore.QEvent):
|
|
|
|
|
EVENT_TYPE = QtCore.QEvent.Type(QtCore.QEvent.registerEventType())
|
|
|
|
|
|
|
|
|
|