X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcoresession.cpp;h=508e2b99e519271f03c82536837681d15a995e5a;hp=d44cf2b5f2f426e8d94159cf6c1201e248b1410e;hb=9d54503555534a2c554f09a33df6afa33d6308ec;hpb=76db8cdfbeffaaba359c8e80cf2146da9e9e7f8a diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index d44cf2b5..508e2b99 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2013 by the Quassel Project * + * Copyright (C) 2005-2014 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -34,6 +34,7 @@ #include "corenetwork.h" #include "corenetworkconfig.h" #include "coresessioneventprocessor.h" +#include "coretransfermanager.h" #include "coreusersettings.h" #include "ctcpparser.h" #include "eventstringifier.h" @@ -66,6 +67,7 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent) _ircListHelper(new CoreIrcListHelper(this)), _networkConfig(new CoreNetworkConfig("GlobalNetworkConfig", this)), _coreInfo(this), + _transferManager(new CoreTransferManager(this)), _eventManager(new CoreEventManager(this)), _eventStringifier(new EventStringifier(this)), _sessionEventProcessor(new CoreSessionEventProcessor(this)), @@ -79,7 +81,7 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent) p->setHeartBeatInterval(30); p->setMaxHeartBeatCount(60); // 30 mins until we throw a dead socket out - connect(p, SIGNAL(peerRemoved(SignalProxy::AbstractPeer*)), SLOT(removeClient(SignalProxy::AbstractPeer*))); + connect(p, SIGNAL(peerRemoved(Peer*)), SLOT(removeClient(Peer*))); connect(p, SIGNAL(connected()), SLOT(clientsConnected())); connect(p, SIGNAL(disconnected()), SLOT(clientsDisconnected())); @@ -120,6 +122,7 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent) p->synchronize(networkConfig()); p->synchronize(&_coreInfo); p->synchronize(&_ignoreListManager); + p->synchronize(transferManager()); // Restore session state if (restoreState) restoreSessionState(); @@ -208,10 +211,7 @@ void CoreSession::restoreSessionState() void CoreSession::addClient(RemotePeer *peer) { - QVariantMap reply; - reply["MsgType"] = "SessionInit"; - reply["SessionState"] = sessionState(); - peer->writeSocketData(reply); + peer->dispatch(sessionState()); signalProxy()->addPeer(peer); } @@ -223,7 +223,7 @@ void CoreSession::addClient(InternalPeer *peer) } -void CoreSession::removeClient(SignalProxy::AbstractPeer *peer) +void CoreSession::removeClient(Peer *peer) { RemotePeer *p = qobject_cast(peer); if (p) @@ -350,7 +350,7 @@ void CoreSession::processMessages() // recheck if there exists a buffer to store a redirected message in for (int i = 0; i < redirectedMessages.count(); i++) { - const RawMessage &rawMsg = _messageQueue.at(i); + const RawMessage &rawMsg = redirectedMessages.at(i); if (bufferInfoCache.contains(rawMsg.networkId) && bufferInfoCache[rawMsg.networkId].contains(rawMsg.target)) { bufferInfo = bufferInfoCache[rawMsg.networkId][rawMsg.target]; } @@ -375,34 +375,20 @@ void CoreSession::processMessages() } -QVariant CoreSession::sessionState() +Protocol::SessionState CoreSession::sessionState() const { - QVariantMap v; - - v["CoreFeatures"] = (int)Quassel::features(); - - QVariantList bufs; - foreach(BufferInfo id, buffers()) bufs << qVariantFromValue(id); - v["BufferInfos"] = bufs; - QVariantList networkids; - foreach(NetworkId id, _networks.keys()) networkids << qVariantFromValue(id); - v["NetworkIds"] = networkids; - - quint32 ircusercount = 0; - quint32 ircchannelcount = 0; - foreach(Network *net, _networks.values()) { - ircusercount += net->ircUserCount(); - ircchannelcount += net->ircChannelCount(); - } - v["IrcUserCount"] = ircusercount; - v["IrcChannelCount"] = ircchannelcount; + QVariantList bufferInfos; + QVariantList networkIds; + QVariantList identities; - QList idlist; - foreach(Identity *i, _identities.values()) idlist << qVariantFromValue(*i); - v["Identities"] = idlist; + foreach(const BufferInfo &id, buffers()) + bufferInfos << QVariant::fromValue(id); + foreach(const NetworkId &id, _networks.keys()) + networkIds << QVariant::fromValue(id); + foreach(const Identity *i, _identities.values()) + identities << QVariant::fromValue(*i); - //v["Payload"] = QByteArray(100000000, 'a'); // for testing purposes - return v; + return Protocol::SessionState(identities, bufferInfos, networkIds); }