X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclient.cpp;h=b561fd12737cd6904210d86905b1691fff6fe548;hp=3cb067b9b18309fdd5e2e11e58ee5e97029c5016;hb=999dd26d04c96a142ee0ee8e1d066d939b7c4499;hpb=06a03c2c69ee934aaeec83512bae2fffee83a340 diff --git a/src/client/client.cpp b/src/client/client.cpp index 3cb067b9..b561fd12 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -22,7 +22,6 @@ #include "buffer.h" #include "buffertreemodel.h" -//#include "clientproxy.h" #include "quasselui.h" #include "signalproxy.h" #include "util.h" @@ -51,12 +50,8 @@ void Client::destroy() { } Client::Client() { - //clientProxy = ClientProxy::instance(); _signalProxy = new SignalProxy(SignalProxy::Client, 0, this); - // TODO: make this configurable (allow monolithic client to connect to remote cores) - //if(Global::runMode == Global::Monolithic) clientMode = LocalCore; - //else clientMode = RemoteCore; connectedToCore = false; socket = 0; } @@ -75,33 +70,6 @@ void Client::init() { connect(this, SIGNAL(bufferUpdated(Buffer *)), _bufferModel, SLOT(bufferUpdated(Buffer *))); connect(this, SIGNAL(bufferActivity(Buffer::ActivityLevel, Buffer *)), _bufferModel, SLOT(bufferActivity(Buffer::ActivityLevel, Buffer *))); - //connect(&socket, SIGNAL(readyRead()), this, SLOT(serverHasData())); - //connect(&socket, SIGNAL(connected()), this, SLOT(coreSocketConnected())); - //connect(&socket, SIGNAL(disconnected()), this, SLOT(coreSocketDisconnected())); - //connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(serverError(QAbstractSocket::SocketError))); - - //connect(this, SIGNAL(sendSessionData(const QString &, const QVariant &)), clientProxy, SLOT(gsSessionDataChanged(const QString &, const QVariant &))); - //connect(clientProxy, SIGNAL(csSessionDataChanged(const QString &, const QVariant &)), this, SLOT(recvSessionData(const QString &, const QVariant &))); - - //connect(clientProxy, SIGNAL(send(ClientSignal, QVariant, QVariant, QVariant)), this, SLOT(recvProxySignal(ClientSignal, QVariant, QVariant, QVariant))); - //connect(clientProxy, SIGNAL(csCoreState(QVariant)), this, SLOT(recvCoreState(const QVariant &))); - //connect(clientProxy, SIGNAL(csServerState(QString, QVariant)), this, SLOT(recvNetworkState(QString, QVariant))); - //connect(clientProxy, SIGNAL(csServerConnected(QString)), this, SLOT(networkConnected(QString))); - //connect(clientProxy, SIGNAL(csServerDisconnected(QString)), this, SLOT(networkDisconnected(QString))); - //connect(clientProxy, SIGNAL(csDisplayMsg(Message)), this, SLOT(recvMessage(const Message &))); - //connect(clientProxy, SIGNAL(csDisplayStatusMsg(QString, QString)), this, SLOT(recvStatusMsg(QString, QString))); - //connect(clientProxy, SIGNAL(csTopicSet(QString, QString, QString)), this, SLOT(setTopic(QString, QString, QString))); - //connect(clientProxy, SIGNAL(csNickAdded(QString, QString, QVariantMap)), this, SLOT(addNick(QString, QString, QVariantMap))); - //connect(clientProxy, SIGNAL(csNickRemoved(QString, QString)), this, SLOT(removeNick(QString, QString))); - //connect(clientProxy, SIGNAL(csNickRenamed(QString, QString, QString)), this, SLOT(renameNick(QString, QString, QString))); - //connect(clientProxy, SIGNAL(csNickUpdated(QString, QString, QVariantMap)), this, SLOT(updateNick(QString, QString, QVariantMap))); - //connect(clientProxy, SIGNAL(csOwnNickSet(QString, QString)), this, SLOT(setOwnNick(QString, QString))); - //connect(clientProxy, SIGNAL(csBacklogData(BufferId, const QList &, bool)), this, SLOT(recvBacklogData(BufferId, QList, bool))); - //connect(clientProxy, SIGNAL(csUpdateBufferId(BufferId)), this, SLOT(updateBufferId(BufferId))); - //connect(this, SIGNAL(sendInput(BufferId, QString)), clientProxy, SLOT(gsUserInput(BufferId, QString))); - //connect(this, SIGNAL(requestBacklog(BufferId, QVariant, QVariant)), clientProxy, SLOT(gsRequestBacklog(BufferId, QVariant, QVariant))); - //connect(this, SIGNAL(requestNetworkStates()), clientProxy, SLOT(gsRequestNetworkStates())); - SignalProxy *p = signalProxy(); p->attachSignal(this, SIGNAL(sendSessionData(const QString &, const QVariant &)), SIGNAL(clientSessionDataChanged(const QString &, const QVariant &))); p->attachSlot(SIGNAL(coreSessionDataChanged(const QString &, const QVariant &)), this, SLOT(recvSessionData(const QString &, const QVariant &))); @@ -120,7 +88,6 @@ void Client::init() { p->attachSlot(SIGNAL(backlogData(BufferId, const QVariantList &, bool)), this, SLOT(recvBacklogData(BufferId, const QVariantList &, bool))); p->attachSlot(SIGNAL(bufferIdUpdated(BufferId)), this, SLOT(updateBufferId(BufferId))); p->attachSignal(this, SIGNAL(sendInput(BufferId, QString))); - //p->attachSignal(this, SIGNAL(requestBacklog(BufferId, QVariant, QVariant)), "requestBacklog"); p->attachSignal(this, SIGNAL(requestNetworkStates())); connect(mainUi, SIGNAL(connectToCore(const QVariantMap &)), this, SLOT(connectToCore(const QVariantMap &))); @@ -132,14 +99,10 @@ void Client::init() { layoutTimer->setInterval(0); layoutTimer->setSingleShot(false); connect(layoutTimer, SIGNAL(timeout()), this, SLOT(layoutMsg())); - } Client::~Client() { - //delete mainUi; - //delete _bufferModel; foreach(Buffer *buf, buffers.values()) delete buf; // this is done by disconnectFromCore()! FIXME? - //ClientProxy::destroy(); Q_ASSERT(!buffers.count()); } @@ -158,10 +121,11 @@ bool Client::isConnected() { void Client::connectToCore(const QVariantMap &conn) { // TODO implement SSL coreConnectionInfo = conn; - if(isConnected() || socket != 0) { + if(isConnected()) { emit coreConnectionError(tr("Already connected to Core!")); return; } + if(socket != 0) socket->deleteLater(); if(conn["Host"].toString().isEmpty()) { clientMode = LocalCore; socket = new QBuffer(this); @@ -213,6 +177,7 @@ void Client::coreSocketDisconnected() { connectedToCore = false; emit disconnected(); socket->deleteLater(); + blockSize = 0; /* Clear internal data. Hopefully nothing relies on it at this point. */ _bufferModel->clear(); @@ -231,7 +196,7 @@ void Client::coreSocketDisconnected() { layoutTimer->stop(); } -void Client::coreSocketStateChanged(QAbstractSocket::SocketState state) { qDebug() << state; +void Client::coreSocketStateChanged(QAbstractSocket::SocketState state) { if(state == QAbstractSocket::UnconnectedState) coreSocketDisconnected(); } @@ -242,6 +207,7 @@ void Client::recvCoreState(const QVariant &state) { syncToCore(state); } +// TODO: auth errors void Client::syncToCore(const QVariant &coreState) { if(!coreState.toMap().contains("SessionState")) { emit coreConnectionError(tr("Invalid data received from core!")); @@ -296,25 +262,15 @@ QStringList Client::sessionDataKeys() { return instance()->sessionData.keys(); } -void Client::recvProxySignal(ClientSignal sig, QVariant arg1, QVariant arg2, QVariant arg3) { - if(clientMode == LocalCore) return; - QList sigdata; - sigdata.append(sig); sigdata.append(arg1); sigdata.append(arg2); sigdata.append(arg3); - //qDebug() << "Sending signal: " << sigdata; - writeDataToDevice(socket, QVariant(sigdata)); -} - void Client::coreSocketError(QAbstractSocket::SocketError) { emit coreConnectionError(socket->errorString()); + socket->deleteLater(); } void Client::coreHasData() { QVariant item; if(readDataFromDevice(socket, blockSize, item)) { emit recvPartialItem(1,1); - //QList sigdata = item.toList(); - //Q_ASSERT(sigdata.size() == 4); - //ClientProxy::instance()->recv((CoreSignal)sigdata[0].toInt(), sigdata[1], sigdata[2], sigdata[3]); recvCoreState(item); blockSize = 0; return; @@ -413,13 +369,13 @@ void Client::recvNetworkState(QString net, QVariant state) { } void Client::recvMessage(const Message &msg) { - Buffer *b = buffer(msg.buffer); + Buffer *b = buffer(msg.buffer()); Buffer::ActivityLevel level = Buffer::OtherActivity; - if(msg.type == Message::Plain || msg.type == Message::Notice){ + if(msg.type() == Message::Plain || msg.type() == Message::Notice){ level |= Buffer::NewMessage; } - if(msg.flags & Message::Highlight){ + if(msg.flags() & Message::Highlight){ level |= Buffer::Highlight; } emit bufferActivity(level, b);