/***************************************************************************
- * Copyright (C) 2005-2013 by the Quassel Project *
+ * Copyright (C) 2005-2015 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
#include "corenetwork.h"
#include "corenetworkconfig.h"
#include "coresessioneventprocessor.h"
+#include "coretransfermanager.h"
#include "coreusersettings.h"
#include "ctcpparser.h"
#include "eventstringifier.h"
#include "ircuser.h"
#include "logger.h"
#include "messageevent.h"
+#include "remotepeer.h"
#include "storage.h"
#include "util.h"
-#include "protocols/legacy/legacypeer.h"
class ProcessMessagesEvent : public QEvent
{
_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)),
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()));
p->attachSlot(SIGNAL(createNetwork(const NetworkInfo &, const QStringList &)), this, SLOT(createNetwork(const NetworkInfo &, const QStringList &)));
p->attachSlot(SIGNAL(removeNetwork(NetworkId)), this, SLOT(removeNetwork(NetworkId)));
+ p->attachSlot(SIGNAL(clientChangePassword(QString)), this, SLOT(changePassword(QString)));
+
loadSettings();
initScriptEngine();
p->synchronize(networkConfig());
p->synchronize(&_coreInfo);
p->synchronize(&_ignoreListManager);
+ p->synchronize(transferManager());
// Restore session state
if (restoreState)
restoreSessionState();
void CoreSession::addClient(RemotePeer *peer)
{
- QVariantMap reply;
- reply["MsgType"] = "SessionInit";
- reply["SessionState"] = sessionState();
- peer->writeSocketData(reply);
+ peer->dispatch(sessionState());
signalProxy()->addPeer(peer);
}
}
-void CoreSession::removeClient(SignalProxy::AbstractPeer *peer)
+void CoreSession::removeClient(Peer *peer)
{
RemotePeer *p = qobject_cast<RemotePeer *>(peer);
if (p)
bufferInfo = Core::bufferInfo(user(), rawMsg.networkId, BufferInfo::StatusBuffer, "");
}
Message msg(bufferInfo, rawMsg.type, rawMsg.text, rawMsg.sender, rawMsg.flags);
- Core::storeMessage(msg);
- emit displayMsg(msg);
+ if(Core::storeMessage(msg))
+ emit displayMsg(msg);
}
else {
QHash<NetworkId, QHash<QString, BufferInfo> > bufferInfoCache;
// 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];
}
messages << msg;
}
- Core::storeMessages(messages);
- // FIXME: extend protocol to a displayMessages(MessageList)
- for (int i = 0; i < messages.count(); i++) {
- emit displayMsg(messages[i]);
+ if(Core::storeMessages(messages)) {
+ // FIXME: extend protocol to a displayMessages(MessageList)
+ for (int i = 0; i < messages.count(); i++) {
+ emit displayMsg(messages[i]);
+ }
}
}
_processMessages = false;
}
-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;
+ QVariantList bufferInfos;
+ QVariantList networkIds;
+ QVariantList identities;
- quint32 ircusercount = 0;
- quint32 ircchannelcount = 0;
- foreach(Network *net, _networks.values()) {
- ircusercount += net->ircUserCount();
- ircchannelcount += net->ircChannelCount();
- }
- v["IrcUserCount"] = ircusercount;
- v["IrcChannelCount"] = ircchannelcount;
-
- QList<QVariant> 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);
}
net->userInputHandler()->issueAway(msg, false /* no force away */);
}
}
+
+void CoreSession::changePassword(QString password)
+{
+ emit passwordChangeRequested(_user, password);
+}