X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=core%2Fcore.cpp;h=169d28ad820e936cab82adbc8c91262db69d56e1;hb=04e21ce26ebabdde9586ca9d2a3168431e448df5;hp=10c9d3d65d0929f547567ea281f6ff522b4f8242;hpb=8b192b08f3df4ce0e7cc4a08564645c76efa688d;p=quassel.git diff --git a/core/core.cpp b/core/core.cpp index 10c9d3d6..169d28ad 100644 --- a/core/core.cpp +++ b/core/core.cpp @@ -20,40 +20,50 @@ #include "core.h" #include "server.h" +#include "quassel.h" +#include "coreproxy.h" #include -void Core::init() { +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(&server, SIGNAL(recvLine(QString)), coreProxy, SLOT(csCoreMessage(QString))); -void Core::run() { + // Read global settings from config file + QSettings s; + s.beginGroup("Global"); + QString key; + foreach(key, s.childKeys()) { + global->updateData(key, s.value(key)); + } + global->updateData("CoreReady", true); + // Now that we are in sync, we can connect signals to automatically store further updates. + // I don't think we care if global data changed locally or if it was updated by a client. + connect(global, SIGNAL(dataUpdatedRemotely(QString)), SLOT(globalDataUpdated(QString))); + connect(global, SIGNAL(dataPutLocally(QString)), SLOT(globalDataUpdated(QString))); - connect(this, SIGNAL(connectToIrc( const QString&, quint16 )), &server, SLOT(connectToIrc( const QString&, quint16 ))); - connect(&server, SIGNAL(recvLine(const QString &)), this, SIGNAL(outputLine(const QString &))); - //connect( server.start(); - qDebug() << "Core running..."; - - exec(); } -void Core::connectToIrc( const QString &h, quint16 port) { +void Core::connectToIrc(const QString &h, quint16 port) { + if(server.isConnected()) return; + qDebug() << "Core: Connecting to " << h << ":" << port; server.connectToIrc(h, port); } -void Core::inputLine(const QString &s) { - server.putRawLine( s); +void Core::inputLine(QString s) { + server.putRawLine(s); } -VarMap Core::loadIdentities() { +void Core::globalDataUpdated(QString key) { + QVariant data = global->getData(key); QSettings s; - return s.value("Network/Identities").toMap(); + s.setValue(QString("Global/")+key, data); } -void Core::storeIdentities(VarMap identities) { - QSettings s; - s.setValue("Network/Identities", identities); -} +Core *core = 0;