X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=core%2Fcore.cpp;h=44c925a01c27a8737728f5dac9d23e985692d6d3;hp=169d28ad820e936cab82adbc8c91262db69d56e1;hb=057883f768f86257c9dbefeb5ef12403b207b773;hpb=04e21ce26ebabdde9586ca9d2a3168431e448df5 diff --git a/core/core.cpp b/core/core.cpp index 169d28ad..44c925a0 100644 --- a/core/core.cpp +++ b/core/core.cpp @@ -20,7 +20,7 @@ #include "core.h" #include "server.h" -#include "quassel.h" +#include "global.h" #include "coreproxy.h" #include @@ -28,12 +28,12 @@ Core::Core() { if(core) qFatal("Trying to instantiate more than one Core object!"); - connect(coreProxy, SIGNAL(gsRequestConnect(QString, quint16)), this, SLOT(connectToIrc(QString, quint16))); - connect(coreProxy, SIGNAL(gsUserInput(QString)), this, SLOT(inputLine(QString))); + connect(coreProxy, SIGNAL(gsRequestConnect(QStringList)), this, SLOT(connectToIrc(QStringList))); + connect(coreProxy, SIGNAL(gsUserInput(QString, QString, QString)), this, SIGNAL(msgFromGUI(QString, QString, QString))); + connect(this, SIGNAL(displayMsg(QString, QString, Message)), coreProxy, SLOT(csDisplayMsg(QString, QString, Message))); + connect(this, SIGNAL(displayStatusMsg(QString, QString)), coreProxy, SLOT(csDisplayStatusMsg(QString, QString))); - connect(&server, SIGNAL(recvLine(QString)), coreProxy, SLOT(csCoreMessage(QString))); - - // Read global settings from config file + // Read global settings from config file QSettings s; s.beginGroup("Global"); QString key; @@ -46,24 +46,54 @@ Core::Core() { connect(global, SIGNAL(dataUpdatedRemotely(QString)), SLOT(globalDataUpdated(QString))); connect(global, SIGNAL(dataPutLocally(QString)), SLOT(globalDataUpdated(QString))); - server.start(); } -void Core::connectToIrc(const QString &h, quint16 port) { - if(server.isConnected()) return; - qDebug() << "Core: Connecting to " << h << ":" << port; - server.connectToIrc(h, port); +void Core::globalDataUpdated(QString key) { + QVariant data = global->getData(key); + QSettings s; + s.setValue(QString("Global/")+key, data); } -void Core::inputLine(QString s) { - server.putRawLine(s); +void Core::connectToIrc(QStringList networks) { + foreach(QString net, networks) { + if(servers.contains(net)) { + + } else { + Server *server = new Server(net); + connect(this, SIGNAL(connectToIrc(QString)), server, SLOT(connectToIrc(QString))); + connect(this, SIGNAL(disconnectFromIrc(QString)), server, SLOT(disconnectFromIrc(QString))); + connect(this, SIGNAL(msgFromGUI(QString, QString, QString)), server, SLOT(userInput(QString, QString, QString))); + connect(server, SIGNAL(displayMsg(QString, Message)), this, SLOT(recvMessageFromServer(QString, Message))); + connect(server, SIGNAL(displayStatusMsg(QString)), this, SLOT(recvStatusMsgFromServer(QString))); + connect(server, SIGNAL(modeSet(QString, QString, QString)), coreProxy, SLOT(csModeSet(QString, QString, QString))); + connect(server, SIGNAL(topicSet(QString, QString, QString)), coreProxy, SLOT(csTopicSet(QString, QString, QString))); + connect(server, SIGNAL(setNicks(QString, QString, QStringList)), coreProxy, SLOT(csSetNicks(QString, QString, QStringList))); + connect(server, SIGNAL(nickAdded(QString, QString, VarMap)), coreProxy, SLOT(csNickAdded(QString, QString, VarMap))); + connect(server, SIGNAL(nickRemoved(QString, QString)), coreProxy, SLOT(csNickRemoved(QString, QString))); + connect(server, SIGNAL(nickUpdated(QString, QString, VarMap)), coreProxy, SLOT(csNickUpdated(QString, QString, VarMap))); + connect(server, SIGNAL(ownNickSet(QString, QString)), coreProxy, SLOT(csOwnNickSet(QString, QString))); + // add error handling + + server->start(); + servers[net] = server; + } + emit connectToIrc(net); + } +} +// ALL messages coming pass through these functions before going to the GUI. +// So this is the perfect place for storing the backlog and log stuff. +void Core::recvMessageFromServer(QString buf, Message msg) { + Q_ASSERT(sender()); + QString net = qobject_cast(sender())->getNetwork(); + emit displayMsg(net, buf, msg); } -void Core::globalDataUpdated(QString key) { - QVariant data = global->getData(key); - QSettings s; - s.setValue(QString("Global/")+key, data); +void Core::recvStatusMsgFromServer(QString msg) { + Q_ASSERT(sender()); + QString net = qobject_cast(sender())->getNetwork(); + emit displayStatusMsg(net, msg); } + Core *core = 0;