Commit 0a3b7127 authored by Dan Pascu's avatar Dan Pascu

Removed AuxiliaryThread and replaced it with threads from sipsimple

parent 371f0925
......@@ -13,7 +13,6 @@ import sys
from collections import defaultdict
import cjson
from PyQt4.QtCore import QThread
from PyQt4.QtGui import QApplication
from application import log
from application.notification import IObserver, NotificationCenter
......@@ -40,26 +39,6 @@ from blink.update import UpdateManager
from blink.util import QSingleton, run_in_gui_thread
class AuxiliaryThread(QThread):
def __init__(self, parent=None):
super(AuxiliaryThread, self).__init__(parent)
self.moveToThread(self)
def run(self):
self.exec_()
def customEvent(self, event):
handler = getattr(self, '_EH_%s' % event.name, Null)
handler(event)
def _EH_CallFunctionEvent(self, event):
try:
event.function(*event.args, **event.kw)
except:
log.error('Exception occured while calling function %s in the auxiliary thread' % event.function.__name__)
log.err()
class Blink(QApplication):
__metaclass__ = QSingleton
......@@ -68,7 +47,6 @@ class Blink(QApplication):
def __init__(self):
super(Blink, self).__init__(sys.argv)
self.application = SIPApplication()
self.auxiliary_thread = AuxiliaryThread()
self.first_run = False
self.main_window = MainWindow()
......@@ -85,7 +63,6 @@ class Blink(QApplication):
def run(self):
from blink.util import call_in_gui_thread as call_later
call_later(self._initialize_sipsimple) # initialize sipsimple after the qt event loop is started
self.auxiliary_thread.start()
self.exec_()
self.update_manager.shutdown()
self.application.stop()
......
......@@ -26,11 +26,12 @@ from zope.interface import implements
from sipsimple.account import Account, AccountExists, AccountManager, BonjourAccount
from sipsimple.configuration.settings import SIPSimpleSettings
from sipsimple.threading import run_in_thread
from sipsimple.util import user_info
from blink.resources import Resources
from blink.widgets.labels import Status
from blink.util import QSingleton, call_in_gui_thread, run_in_auxiliary_thread, run_in_gui_thread
from blink.util import QSingleton, call_in_gui_thread, run_in_gui_thread
class AccountInfo(object):
......@@ -415,7 +416,7 @@ class AddAccountDialog(base_class, ui_class):
self.verify_password = u''
self.email_address = u''
@run_in_auxiliary_thread
@run_in_thread('network-io')
def _create_sip_account(self, username, password, email_address, display_name, timezone=None):
red = '#cc0000'
if timezone is None and sys.platform != 'win32':
......
......@@ -32,14 +32,14 @@ from zope.interface import implements
from sipsimple.account import AccountManager, BonjourAccount
from sipsimple.configuration.settings import SIPSimpleSettings
from sipsimple.threading import run_in_twisted_thread
from sipsimple.threading import run_in_thread, run_in_twisted_thread
from sipsimple.threading.green import run_in_green_thread
from sipsimple.util import makedirs
from blink.configuration.datatypes import AuthorizationToken, InvalidToken
from blink.resources import ApplicationData, Resources, IconCache
from blink.sessions import SessionManager
from blink.util import QSingleton, call_in_gui_thread, call_later, run_in_auxiliary_thread, run_in_gui_thread
from blink.util import QSingleton, call_in_gui_thread, call_later, run_in_gui_thread
from blink.widgets.buttons import SwitchViewButton
from blink.widgets.labels import Status
......@@ -1188,7 +1188,7 @@ class ContactModel(QAbstractListModel):
self.endRemoveRows()
return items
@run_in_auxiliary_thread
@run_in_thread('file-io')
def _store_contacts(self, data):
makedirs(ApplicationData.directory)
filename = ApplicationData.get('contacts')
......
......@@ -24,12 +24,13 @@ from sipsimple.application import SIPApplication
from sipsimple.configuration import DefaultValue
from sipsimple.configuration.datatypes import MSRPRelayAddress, PortRange, SIPProxyAddress
from sipsimple.configuration.settings import SIPSimpleSettings
from sipsimple.threading import run_in_thread
from sipsimple.util import limit
from blink.accounts import AddAccountDialog
from blink.resources import ApplicationData, Resources
from blink.logging import LogManager
from blink.util import QSingleton, call_in_gui_thread, run_in_auxiliary_thread, run_in_gui_thread
from blink.util import QSingleton, call_in_gui_thread, run_in_gui_thread
......@@ -1148,7 +1149,7 @@ class PreferencesWindow(base_class, ui_class):
settings.logs.pjsip_level = value
settings.save()
@run_in_auxiliary_thread
@run_in_thread('file-io')
def _SH_ClearLogFilesButtonClicked(self):
log_manager = LogManager()
log_manager.stop()
......
# Copyright (C) 2010 AG Projects. See LICENSE for details.
#
__all__ = ['QSingleton', 'call_in_gui_thread', 'call_later', 'run_in_gui_thread', 'call_in_auxiliary_thread', 'run_in_auxiliary_thread']
__all__ = ['QSingleton', 'call_in_gui_thread', 'call_later', 'run_in_gui_thread']
from PyQt4.QtCore import QObject, QTimer
from PyQt4.QtGui import QApplication
......@@ -34,16 +34,3 @@ def run_in_gui_thread(func):
return wrapper
def call_in_auxiliary_thread(function, *args, **kw):
application = QApplication.instance()
application.postEvent(application.auxiliary_thread, CallFunctionEvent(function, args, kw))
def run_in_auxiliary_thread(func):
@preserve_signature(func)
def wrapper(*args, **kw):
application = QApplication.instance()
application.postEvent(application.auxiliary_thread, CallFunctionEvent(func, args, kw))
return wrapper
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment