X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclient.cpp;h=772601f54c928231916cfbf7496e0d5e028ed180;hp=de43a0b6b55d39244bc8ed04d46836035e124bc7;hb=e7696b65e76e50137b8bab0ec3e43ce66a94f190;hpb=770b7ef54b03f3ebd1e29a58b4757505e1809b2d diff --git a/src/client/client.cpp b/src/client/client.cpp index de43a0b6..772601f5 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -65,6 +65,7 @@ Client::Client(QObject *parent) _connectedToCore(false), _syncedToCore(false) { + _monitorBuffer = new Buffer(BufferInfo(), this); } Client::~Client() { @@ -105,7 +106,13 @@ void Client::init() { p->attachSignal(this, SIGNAL(requestRemoveIdentity(IdentityId)), SIGNAL(removeIdentity(IdentityId))); p->attachSlot(SIGNAL(identityCreated(const Identity &)), this, SLOT(coreIdentityCreated(const Identity &))); p->attachSlot(SIGNAL(identityRemoved(IdentityId)), this, SLOT(coreIdentityRemoved(IdentityId))); - +/* + 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(networkRemoved(NetworkId)), this, SLOT(coreNetworkRemoved(NetworkId))); +*/ connect(p, SIGNAL(disconnected()), this, SLOT(disconnectFromCore())); //connect(mainUi, SIGNAL(connectToCore(const QVariantMap &)), this, SLOT(connectToCore(const QVariantMap &))); @@ -159,6 +166,10 @@ Buffer *Client::buffer(BufferInfo id) { return buff; } +Buffer *Client::monitorBuffer() { + return instance()->_monitorBuffer; +} + NetworkModel *Client::networkModel() { return instance()->_networkModel; @@ -333,6 +344,13 @@ QStringList Client::sessionDataKeys() { /*** ***/ +// 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 @@ -362,19 +380,18 @@ void Client::networkDisconnected(NetworkId networkid) { } */ -void Client::addNetwork(NetworkId netid) { - Network *net = new Network(netid, instance()); - addNetwork(net); -} - 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()->networkAdded(net->networkId()); - //if(net->networkId() == 1) net->requestConnect(); // FIXME + emit instance()->networkCreated(net->networkId()); +} + +void Client::createNetwork(const NetworkInfo &info) { + + } /*** ***/ @@ -396,8 +413,9 @@ void Client::bufferDestroyed() { } void Client::networkDestroyed() { - Network *netinfo = static_cast(sender()); - NetworkId networkId = netinfo->networkId(); + // FIXME this is not gonna work, net is a QObject here already! + Network *net = static_cast(sender()); + NetworkId networkId = net->networkId(); if(_networks.contains(networkId)) _networks.remove(networkId); } @@ -406,6 +424,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*/) {