X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclient.cpp;h=9e3fc9a25adade45e070fa9e594c536c8361e76c;hp=c63632d9f746c0e459f4ce6609769a76136a394b;hb=a76d5716fff14a3f21e6c62542e10646981c1067;hpb=7f8acf4ede38a0178a97eb701a9382e455ca7c2d diff --git a/src/client/client.cpp b/src/client/client.cpp index c63632d9..9e3fc9a2 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -79,19 +79,9 @@ void Client::init() { _bufferModel = new BufferModel(_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))); @@ -103,13 +93,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(networkCreated(NetworkId)), this, SLOT(coreNetworkCreated(NetworkId))); 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 &))); @@ -199,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() { @@ -277,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(); @@ -301,7 +329,6 @@ void Client::disconnectFromCore() { } Q_ASSERT(_identities.isEmpty()); - sessionData.clear(); layoutQueue.clear(); layoutTimer->stop(); } @@ -310,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) {