diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-09-06 11:22:27 +0200 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-09-06 11:22:27 +0200 |
| commit | 72db593c53abf6e9d56c8ac50a0a8ab576f99807 (patch) | |
| tree | cf90e36dfd9d7c6b98c552bd838b69b05c2f1393 /src/client/QXmppDiscoveryManager.cpp | |
| parent | 889a0b49764605e6500f8fc555a580444c9ffc4a (diff) | |
| download | qxmpp-72db593c53abf6e9d56c8ac50a0a8ab576f99807.tar.gz | |
clarify discovery IQ handling
Diffstat (limited to 'src/client/QXmppDiscoveryManager.cpp')
| -rw-r--r-- | src/client/QXmppDiscoveryManager.cpp | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/src/client/QXmppDiscoveryManager.cpp b/src/client/QXmppDiscoveryManager.cpp index 0bd588b0..3ab7dd18 100644 --- a/src/client/QXmppDiscoveryManager.cpp +++ b/src/client/QXmppDiscoveryManager.cpp @@ -256,30 +256,38 @@ bool QXmppDiscoveryManager::handleStanza(const QDomElement &element) QXmppDiscoveryIq receivedIq; receivedIq.parse(element); - const bool isReplyType = receivedIq.type() == QXmppIq::Result || - receivedIq.type() == QXmppIq::Error; - - if(receivedIq.type() == QXmppIq::Get && - receivedIq.queryType() == QXmppDiscoveryIq::InfoQuery && - (receivedIq.queryNode().isEmpty() || - receivedIq.queryNode().startsWith(d->clientCapabilitiesNode))) { - // respond to query - QXmppDiscoveryIq qxmppFeatures = capabilities(); - qxmppFeatures.setId(receivedIq.id()); - qxmppFeatures.setTo(receivedIq.from()); - qxmppFeatures.setQueryNode(receivedIq.queryNode()); - client()->sendPacket(qxmppFeatures); - } else if(isReplyType && - receivedIq.queryType() == QXmppDiscoveryIq::InfoQuery) { - // info result - emit infoReceived(receivedIq); - } else if(isReplyType && - receivedIq.queryType() == QXmppDiscoveryIq::ItemsQuery) { - // items result - emit itemsReceived(receivedIq); + switch (receivedIq.type()) { + case QXmppIq::Get: + if (receivedIq.queryType() == QXmppDiscoveryIq::InfoQuery && + (receivedIq.queryNode().isEmpty() || + receivedIq.queryNode().startsWith(d->clientCapabilitiesNode))) { + + // respond to info queries for the client itself + QXmppDiscoveryIq qxmppFeatures = capabilities(); + qxmppFeatures.setId(receivedIq.id()); + qxmppFeatures.setTo(receivedIq.from()); + qxmppFeatures.setQueryNode(receivedIq.queryNode()); + client()->sendPacket(qxmppFeatures); + return true; + } else { + // let other managers handle other queries + return false; + } + + case QXmppIq::Result: + case QXmppIq::Error: + // handle all replies + if (receivedIq.queryType() == QXmppDiscoveryIq::InfoQuery) { + emit infoReceived(receivedIq); + } else if (receivedIq.queryType() == QXmppDiscoveryIq::ItemsQuery) { + emit itemsReceived(receivedIq); + } + return true; + + case QXmppIq::Set: + // let other manager handle "set" IQs + return false; } - - return true; } return false; } |
