X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fcoresession.cpp;h=696825d6e6bc8d332d2e8a591b6c8da0e28cc0e1;hb=c00b7e45809b6f3d6d02abbc1285728fe01af374;hp=68f31271f88b19571ffd09648d305d498f85bb08;hpb=cc7f376eb105f7bf931fb7f96c9601a7b3f69511;p=quassel.git diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index 68f31271..696825d6 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -23,14 +23,16 @@ #include "core.h" #include "coresession.h" #include "networkconnection.h" +#include "userinputhandler.h" #include "signalproxy.h" #include "buffersyncer.h" #include "corebacklogmanager.h" #include "corebufferviewmanager.h" +#include "coreirclisthelper.h" #include "storage.h" -#include "network.h" +#include "corenetwork.h" #include "ircuser.h" #include "ircchannel.h" #include "identity.h" @@ -42,9 +44,12 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent) : QObject(parent), _user(uid), _signalProxy(new SignalProxy(SignalProxy::Server, 0, this)), + _aliasManager(this), _bufferSyncer(new BufferSyncer(this)), _backlogManager(new CoreBacklogManager(this)), _bufferViewManager(new CoreBufferViewManager(_signalProxy, this)), + _ircListHelper(new CoreIrcListHelper(this)), + _coreInfo(this), scriptEngine(new QScriptEngine(this)) { @@ -84,9 +89,18 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent) p->synchronize(_bufferSyncer); - // init BacklogManager; + // init alias manager + p->synchronize(&aliasManager()); + + // init BacklogManager p->synchronize(_backlogManager); - + + // init IrcListHelper + p->synchronize(ircListHelper()); + + // init CoreInfo + p->synchronize(&_coreInfo); + // Restore session state if(restoreState) restoreSessionState(); @@ -98,7 +112,7 @@ CoreSession::~CoreSession() { foreach(NetworkConnection *conn, _connections.values()) { delete conn; } - foreach(Network *net, _networks.values()) { + foreach(CoreNetwork *net, _networks.values()) { delete net; } } @@ -107,7 +121,7 @@ UserId CoreSession::user() const { return _user; } -Network *CoreSession::network(NetworkId id) const { +CoreNetwork *CoreSession::network(NetworkId id) const { if(_networks.contains(id)) return _networks[id]; return 0; } @@ -169,7 +183,7 @@ void CoreSession::updateBufferInfo(UserId uid, const BufferInfo &bufinfo) { } void CoreSession::connectToNetwork(NetworkId id) { - Network *net = network(id); + CoreNetwork *net = network(id); if(!net) { qWarning() << "Connect to unknown network requested! net:" << id << "user:" << user(); return; @@ -205,8 +219,11 @@ void CoreSession::attachNetworkConnection(NetworkConnection *conn) { } void CoreSession::disconnectFromNetwork(NetworkId id) { - if(!_connections.contains(id)) return; - _connections[id]->disconnectFromIrc(); + if(!_connections.contains(id)) + return; + + //_connections[id]->disconnectFromIrc(); + _connections[id]->userInputHandler()->handleQuit(BufferInfo(), QString()); } void CoreSession::networkStateRequested() { @@ -229,7 +246,7 @@ void CoreSession::removeClient(QIODevice *iodev) { // no checks for validity check - privateslot... QTcpSocket *socket = qobject_cast(iodev); if(socket) - qDebug() << qPrintable(tr("Client %1 disconnected (UserId: %2).").arg(socket->peerAddress().toString()).arg(user().toInt())); + qDebug() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("disconnected (UserId: %1).").arg(user().toInt())); else qDebug() << "Local client disconnedted."; disconnect(socket, 0, this, 0); @@ -404,7 +421,7 @@ void CoreSession::createNetwork(const NetworkInfo &info_) { id = info.networkId.toInt(); if(!_networks.contains(id)) { - Network *net = new Network(id, this); + CoreNetwork *net = new CoreNetwork(id, this); connect(net, SIGNAL(connectRequested(NetworkId)), this, SLOT(connectToNetwork(NetworkId))); connect(net, SIGNAL(disconnectRequested(NetworkId)), this, SLOT(disconnectFromNetwork(NetworkId))); net->setNetworkInfo(info); @@ -418,6 +435,7 @@ void CoreSession::createNetwork(const NetworkInfo &info_) { } } +// FIXME: move to CoreNetwork void CoreSession::updateNetwork(const NetworkInfo &info) { if(!_networks.contains(info.networkId)) { qWarning() << "Update request for unknown network received!"; @@ -448,8 +466,12 @@ void CoreSession::destroyNetwork(NetworkId id) { // this can happen if the network was reconnecting while being removed _connections.take(id)->deleteLater(); } + QList removedBuffers = Core::requestBufferIdsForNetwork(user(), id); Network *net = _networks.take(id); if(net && Core::removeNetwork(user(), id)) { + foreach(BufferId bufferId, removedBuffers) { + _bufferSyncer->removeBuffer(bufferId); + } emit networkRemoved(id); net->deleteLater(); } @@ -468,7 +490,7 @@ void CoreSession::removeBufferRequested(BufferId bufferId) { } if(bufferInfo.type() == BufferInfo::ChannelBuffer) { - Network *net = network(bufferInfo.networkId()); + CoreNetwork *net = network(bufferInfo.networkId()); if(!net) { qWarning() << "CoreSession::removeBufferRequested(): Received BufferInfo with unknown networkId!"; return;