X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fclient%2Fclient.cpp;h=e09684b64033b179947844494f8c8ec41ee7c4a3;hb=ba9d9d766830eab8cc238c60a69f67c8b527aa7e;hp=c73e49669ac6c603dd58dae7bcc2d6801e357f8e;hpb=36f65bf2531e3bf94dd8d968f4eb9c598cd7cd61;p=quassel.git diff --git a/src/client/client.cpp b/src/client/client.cpp index c73e4966..e09684b6 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -34,6 +34,7 @@ #include "util.h" QPointer Client::instanceptr = 0; +AccountId Client::_currentCoreAccount = 0; /*** Initialization/destruction ***/ @@ -71,7 +72,7 @@ Client::~Client() { } void Client::init() { - + _currentCoreAccount = 0; _networkModel = new NetworkModel(this); connect(this, SIGNAL(bufferUpdated(BufferInfo)), _networkModel, SLOT(bufferUpdated(BufferInfo))); @@ -116,6 +117,14 @@ void Client::init() { /*** public static methods ***/ +AccountId Client::currentCoreAccount() { + return _currentCoreAccount; +} + +void Client::setCurrentCoreAccount(AccountId id) { + _currentCoreAccount = id; +} + QList Client::allBufferInfos() { QList bufferids; foreach(Buffer *buffer, buffers()) { @@ -276,10 +285,11 @@ void Client::userInput(BufferInfo bufferInfo, QString message) { /*** core connection stuff ***/ -void Client::setConnectedToCore(QIODevice *sock) { +void Client::setConnectedToCore(QIODevice *sock, AccountId id) { socket = sock; signalProxy()->addPeer(socket); _connectedToCore = true; + setCurrentCoreAccount(id); } void Client::setSyncedToCore() { @@ -295,6 +305,7 @@ void Client::disconnectFromCore() { } _connectedToCore = false; _syncedToCore = false; + setCurrentCoreAccount(0); emit disconnected(); emit coreConnectionStateChanged(false); @@ -369,9 +380,22 @@ void Client::networkDestroyed() { } void Client::recvMessage(const Message &msg) { - Buffer *b = buffer(msg.bufferInfo()); - b->appendMsg(msg); - networkModel()->updateBufferActivity(msg); + if(msg.type() == Message::Error) { + Buffer *b = buffer(msg.bufferInfo().bufferId()); + if(b) { + b->appendMsg(msg); + networkModel()->updateBufferActivity(msg); + } else { + //TODO: display message in the status buffer + b = buffer(msg.bufferInfo()); + b->appendMsg(msg); + networkModel()->updateBufferActivity(msg); + } + } else { + Buffer *b = buffer(msg.bufferInfo()); + b->appendMsg(msg); + networkModel()->updateBufferActivity(msg); + } if(msg.type() == Message::Plain || msg.type() == Message::Notice || msg.type() == Message::Action) { const Network *net = network(msg.bufferInfo().networkId()); @@ -394,7 +418,7 @@ void Client::recvBacklogData(BufferInfo id, QVariantList msgs, bool /*done*/) { foreach(QVariant v, msgs) { Message msg = v.value(); b->prependMsg(msg); - // networkModel()->updateBufferActivity(msg); + networkModel()->updateBufferActivity(msg); if(!layoutQueue.contains(b)) layoutQueue.append(b); } if(layoutQueue.count() && !layoutTimer->isActive()) layoutTimer->start();