X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclient.cpp;h=9e3fc9a25adade45e070fa9e594c536c8361e76c;hp=ecfc109276809891fe26682a337efcd5f6fd593d;hb=a76d5716fff14a3f21e6c62542e10646981c1067;hpb=59912f14782c193a2394a2b0d044902a59c96870 diff --git a/src/client/client.cpp b/src/client/client.cpp index ecfc1092..9e3fc9a2 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -29,7 +29,6 @@ #include "network.h" #include "networkmodel.h" #include "buffermodel.h" -#include "nickmodel.h" #include "quasselui.h" #include "signalproxy.h" #include "util.h" @@ -61,10 +60,10 @@ Client::Client(QObject *parent) mainUi(0), _networkModel(0), _bufferModel(0), - _nickModel(0), _connectedToCore(false), _syncedToCore(false) { + _monitorBuffer = new Buffer(BufferInfo(), this); } Client::~Client() { @@ -78,22 +77,11 @@ void Client::init() { _networkModel, SLOT(bufferUpdated(BufferInfo))); _bufferModel = new BufferModel(_networkModel); - _nickModel = new NickModel(_networkModel); 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 &))); - //p->attachSlot(SIGNAL(networkConnected(uint)), - //FIXME this, SLOT(networkConnected(uint))); - //p->attachSlot(SIGNAL(networkDisconnected(uint)), - //FIXME this, SLOT(networkDisconnected(uint))); - p->attachSlot(SIGNAL(displayMsg(const Message &)), - this, SLOT(recvMessage(const Message &))); - p->attachSlot(SIGNAL(displayStatusMsg(QString, QString)), - this, SLOT(recvStatusMsg(QString, QString))); + p->attachSlot(SIGNAL(displayMsg(const Message &)), this, SLOT(recvMessage(const Message &))); + p->attachSlot(SIGNAL(displayStatusMsg(QString, QString)), this, SLOT(recvStatusMsg(QString, QString))); p->attachSlot(SIGNAL(backlogData(BufferInfo, const QVariantList &, bool)), this, SLOT(recvBacklogData(BufferInfo, const QVariantList &, bool))); p->attachSlot(SIGNAL(bufferInfoUpdated(BufferInfo)), this, SLOT(updateBufferInfo(BufferInfo))); @@ -109,7 +97,7 @@ void Client::init() { p->attachSignal(this, SIGNAL(requestCreateNetwork(const NetworkInfo &)), SIGNAL(createNetwork(const NetworkInfo &))); p->attachSignal(this, SIGNAL(requestUpdateNetwork(const NetworkInfo &)), SIGNAL(updateNetwork(const NetworkInfo &))); p->attachSignal(this, SIGNAL(requestRemoveNetwork(NetworkId)), SIGNAL(removeNetwork(NetworkId))); - p->attachSlot(SIGNAL(networkCreated(const NetworkInfo &)), this, SLOT(coreNetworkCreated(const NetworkInfo &))); + p->attachSlot(SIGNAL(networkCreated(NetworkId)), this, SLOT(coreNetworkCreated(NetworkId))); p->attachSlot(SIGNAL(networkRemoved(NetworkId)), this, SLOT(coreNetworkRemoved(NetworkId))); connect(p, SIGNAL(disconnected()), this, SLOT(disconnectFromCore())); @@ -165,6 +153,10 @@ Buffer *Client::buffer(BufferInfo id) { return buff; } +Buffer *Client::monitorBuffer() { + return instance()->_monitorBuffer; +} + NetworkModel *Client::networkModel() { return instance()->_networkModel; @@ -174,11 +166,6 @@ BufferModel *Client::bufferModel() { return instance()->_bufferModel; } -NickModel *Client::nickModel() { - return instance()->_nickModel; -} - - SignalProxy *Client::signalProxy() { return instance()->_signalProxy; } @@ -202,6 +189,43 @@ const Network * Client::network(NetworkId networkid) { else return 0; } +void Client::createNetwork(const NetworkInfo &info) { + emit instance()->requestCreateNetwork(info); +} + +void Client::updateNetwork(const NetworkInfo &info) { + emit instance()->requestUpdateNetwork(info); +} + +void Client::removeNetwork(NetworkId id) { + emit instance()->requestRemoveNetwork(id); +} + +void Client::addNetwork(Network *net) { + net->setProxy(signalProxy()); + signalProxy()->synchronize(net); + networkModel()->attachNetwork(net); + connect(net, SIGNAL(destroyed()), instance(), SLOT(networkDestroyed())); + instance()->_networks[net->networkId()] = net; + emit instance()->networkCreated(net->networkId()); +} + +void Client::coreNetworkCreated(NetworkId id) { + if(_networks.contains(id)) { + qWarning() << "Creation of already existing network requested!"; + return; + } + Network *net = new Network(id, this); + addNetwork(net); +} + +void Client::coreNetworkRemoved(NetworkId id) { + if(!_networks.contains(id)) return; + Network *net = _networks.take(id); + emit networkRemoved(net->networkId()); + net->deleteLater(); +} + /*** Identity handling ***/ QList Client::identityIds() { @@ -280,6 +304,7 @@ void Client::disconnectFromCore() { QHash::iterator netIter = _networks.begin(); while(netIter != _networks.end()) { Network *net = netIter.value(); + emit networkRemoved(net->networkId()); disconnect(net, SIGNAL(destroyed()), this, 0); netIter = _networks.erase(netIter); net->deleteLater(); @@ -304,7 +329,6 @@ void Client::disconnectFromCore() { } Q_ASSERT(_identities.isEmpty()); - sessionData.clear(); layoutQueue.clear(); layoutTimer->stop(); } @@ -313,82 +337,6 @@ void Client::setCoreConfiguration(const QVariantMap &settings) { SignalProxy::writeDataToDevice(socket, settings); } -/*** Session data ***/ - -void Client::recvSessionData(const QString &key, const QVariant &data) { - sessionData[key] = data; - emit sessionDataChanged(key, data); - emit sessionDataChanged(key); -} - -void Client::storeSessionData(const QString &key, const QVariant &data) { - // Not sure if this is a good idea, but we'll try it anyway: - // Calling this function only sends a signal to core. Data is stored upon reception of the update signal, - // rather than immediately. - emit instance()->sendSessionData(key, data); -} - -QVariant Client::retrieveSessionData(const QString &key, const QVariant &def) { - if(instance()->sessionData.contains(key)) return instance()->sessionData[key]; - else return def; -} - -QStringList Client::sessionDataKeys() { - return instance()->sessionData.keys(); -} - -/*** ***/ - -// FIXME -void Client::disconnectFromNetwork(NetworkId id) { - if(!instance()->_networks.contains(id)) return; - Network *net = instance()->_networks[id]; - net->requestDisconnect(); -} - -/* -void Client::networkConnected(uint netid) { - // TODO: create statusBuffer / switch to networkids - //BufferInfo id = statusBufferInfo(net); - //Buffer *b = buffer(id); - //b->setActive(true); - - Network *netinfo = new Network(netid, this); - netinfo->setProxy(signalProxy()); - networkModel()->attachNetwork(netinfo); - connect(netinfo, SIGNAL(destroyed()), this, SLOT(networkDestroyed())); - _networks[netid] = netinfo; -} - -void Client::networkDisconnected(NetworkId networkid) { - if(!_networks.contains(networkid)) { - qWarning() << "Client::networkDisconnected(uint): unknown Network" << networkid; - return; - } - - Network *net = _networks.take(networkid); - if(!net->isInitialized()) { - qDebug() << "Network" << networkid << "disconnected while not yet initialized!"; - updateCoreConnectionProgress(); - } - net->deleteLater(); -} -*/ - -void Client::addNetwork(Network *net) { - net->setProxy(signalProxy()); - signalProxy()->synchronize(net); - networkModel()->attachNetwork(net); - connect(net, SIGNAL(destroyed()), instance(), SLOT(networkDestroyed())); - instance()->_networks[net->networkId()] = net; - emit instance()->networkCreated(net->networkId()); -} - -void Client::createNetwork(const NetworkInfo &info) { - - -} - /*** ***/ void Client::updateBufferInfo(BufferInfo id) { @@ -419,6 +367,13 @@ void Client::recvMessage(const Message &msg) { Buffer *b = buffer(msg.buffer()); b->appendMsg(msg); networkModel()->updateBufferActivity(msg); + + if(msg.type() == Message::Plain || msg.type() == Message::Notice || msg.type() == Message::Action) { + QString sender = msg.buffer().network() + ":" + msg.buffer().buffer() + ":" + msg.sender(); + Message mmsg = Message(msg.timestamp(), msg.buffer(), msg.type(), msg.text(), sender, msg.flags()); + monitorBuffer()->appendMsg(mmsg); + } + } void Client::recvStatusMsg(QString /*net*/, QString /*msg*/) {