X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcore%2Fsessionthread.cpp;h=a56c42b29ccb9ef06b6e0c3ada4cbc4ec159ec57;hb=c4f9c122f56d2c58296c6a8663f79d605b033ae2;hp=6a17bd9f402836cb872774d50a2975a066e4bf67;hpb=01922b87be01cd5c9844d2a273acd9a71aee8e96;p=quassel.git diff --git a/src/core/sessionthread.cpp b/src/core/sessionthread.cpp index 6a17bd9f..a56c42b2 100644 --- a/src/core/sessionthread.cpp +++ b/src/core/sessionthread.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel IRC Team * + * Copyright (C) 2005-2012 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include @@ -26,82 +26,102 @@ #include "core.h" SessionThread::SessionThread(UserId uid, bool restoreState, QObject *parent) - : QThread(parent), + : QThread(parent), _session(0), _user(uid), _sessionInitialized(false), _restoreState(restoreState) { - connect(this, SIGNAL(initialized()), this, SLOT(setSessionInitialized())); + connect(this, SIGNAL(initialized()), this, SLOT(setSessionInitialized())); } -SessionThread::~SessionThread() { - // shut down thread gracefully - quit(); - wait(); -} -CoreSession *SessionThread::session() { - return _session; +SessionThread::~SessionThread() +{ + // shut down thread gracefully + quit(); + wait(); } -UserId SessionThread::user() { - return _user; -} -bool SessionThread::isSessionInitialized() { - return _sessionInitialized; +CoreSession *SessionThread::session() +{ + return _session; } -void SessionThread::setSessionInitialized() { - _sessionInitialized = true; - foreach(QObject *peer, clientQueue) { - addClientToSession(peer); - } - clientQueue.clear(); + +UserId SessionThread::user() +{ + return _user; } -void SessionThread::addClient(QObject *peer) { - if(isSessionInitialized()) { - addClientToSession(peer); - } else { - clientQueue.append(peer); - } + +bool SessionThread::isSessionInitialized() +{ + return _sessionInitialized; } -void SessionThread::addClientToSession(QObject *peer) { - QIODevice *socket = qobject_cast(peer); - if(socket) { - addRemoteClientToSession(socket); - return; - } - SignalProxy *proxy = qobject_cast(peer); - if(proxy) { - addInternalClientToSession(proxy); - return; - } +void SessionThread::setSessionInitialized() +{ + _sessionInitialized = true; + foreach(QObject *peer, clientQueue) { + addClientToSession(peer); + } + clientQueue.clear(); +} + - qWarning() << "SessionThread::addClient() received neither QIODevice nor SignalProxy as peer!" << peer; +void SessionThread::addClient(QObject *peer) +{ + if (isSessionInitialized()) { + addClientToSession(peer); + } + else { + clientQueue.append(peer); + } } -void SessionThread::addRemoteClientToSession(QIODevice *socket) { - socket->setParent(0); - socket->moveToThread(session()->thread()); - emit addRemoteClient(socket); + +void SessionThread::addClientToSession(QObject *peer) +{ + QIODevice *socket = qobject_cast(peer); + if (socket) { + addRemoteClientToSession(socket); + return; + } + + SignalProxy *proxy = qobject_cast(peer); + if (proxy) { + addInternalClientToSession(proxy); + return; + } + + qWarning() << "SessionThread::addClient() received neither QIODevice nor SignalProxy as peer!" << peer; } -void SessionThread::addInternalClientToSession(SignalProxy *proxy) { - emit addInternalClient(proxy); + +void SessionThread::addRemoteClientToSession(QIODevice *socket) +{ + socket->setParent(0); + socket->moveToThread(session()->thread()); + emit addRemoteClient(socket); } -void SessionThread::run() { - _session = new CoreSession(user(), _restoreState); - connect(this, SIGNAL(addRemoteClient(QIODevice *)), _session, SLOT(addClient(QIODevice *))); - connect(this, SIGNAL(addInternalClient(SignalProxy *)), _session, SLOT(addClient(SignalProxy *))); - connect(_session, SIGNAL(sessionState(const QVariant &)), Core::instance(), SIGNAL(sessionState(const QVariant &))); - emit initialized(); - exec(); - delete _session; + +void SessionThread::addInternalClientToSession(SignalProxy *proxy) +{ + emit addInternalClient(proxy); } + +void SessionThread::run() +{ + _session = new CoreSession(user(), _restoreState); + connect(this, SIGNAL(addRemoteClient(QIODevice *)), _session, SLOT(addClient(QIODevice *))); + connect(this, SIGNAL(addInternalClient(SignalProxy *)), _session, SLOT(addClient(SignalProxy *))); + connect(_session, SIGNAL(sessionState(const QVariant &)), Core::instance(), SIGNAL(sessionState(const QVariant &))); + emit initialized(); + exec(); + delete _session; +}