Introducing Network::requestSetNetworkInfo() to simplify client-side updates
[quassel.git] / src / client / client.cpp
index 48c471c..a2ffd8e 100644 (file)
@@ -110,13 +110,11 @@ void Client::init() {
   p->attachSignal(this, SIGNAL(requestNetworkStates()));
 
   p->attachSignal(this, SIGNAL(requestCreateIdentity(const Identity &)), SIGNAL(createIdentity(const Identity &)));
-  p->attachSignal(this, SIGNAL(requestUpdateIdentity(const Identity &)), SIGNAL(updateIdentity(const Identity &)));
   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(NetworkId)), this, SLOT(coreNetworkCreated(NetworkId)));
   p->attachSlot(SIGNAL(networkRemoved(NetworkId)), this, SLOT(coreNetworkRemoved(NetworkId)));
@@ -208,14 +206,19 @@ 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::updateNetwork(const NetworkInfo &info) {
+  Network *netptr = instance()->_networks.value(info.networkId, 0);
+  if(!netptr) {
+    qWarning() << "Update for unknown network requested:" << info;
+    return;
+  }
+  netptr->requestSetNetworkInfo(info);
+}
+
 void Client::addNetwork(Network *net) {
   net->setProxy(signalProxy());
   signalProxy()->synchronize(net);
@@ -257,8 +260,13 @@ void Client::createIdentity(const Identity &id) {
   emit instance()->requestCreateIdentity(id);
 }
 
-void Client::updateIdentity(const Identity &id) {
-  emit instance()->requestUpdateIdentity(id);
+void Client::updateIdentity(IdentityId id, const QVariantMap &ser) {
+  Identity *idptr = instance()->_identities.value(id, 0);
+  if(!idptr) {
+    qWarning() << "Update for unknown identity requested:" << id;
+    return;
+  }
+  idptr->requestUpdate(ser);
 }
 
 void Client::removeIdentity(IdentityId id) {