From 9d2948db0eb57f2087685b9e711bcef38dfa3394 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Mon, 1 Feb 2010 12:09:47 +0000 Subject: reply to server -> client XMPP Ping (XEP-1099) --- source/QXmppPingIq.cpp | 3 ++- source/QXmppStream.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/QXmppPingIq.cpp b/source/QXmppPingIq.cpp index ccf34cf6..3b29139d 100644 --- a/source/QXmppPingIq.cpp +++ b/source/QXmppPingIq.cpp @@ -34,7 +34,8 @@ QXmppPingIq::QXmppPingIq() : QXmppIq(QXmppIq::Get) bool QXmppPingIq::isPingIq( QDomElement &element ) { QDomElement pingElement = element.firstChildElement("ping"); - return (pingElement.namespaceURI() == ns_ping); + return (element.attribute("type") == "get" && + pingElement.namespaceURI() == ns_ping); } void QXmppPingIq::toXmlElementFromChild(QXmlStreamWriter *writer) const diff --git a/source/QXmppStream.cpp b/source/QXmppStream.cpp index 7d252a35..33394e48 100644 --- a/source/QXmppStream.cpp +++ b/source/QXmppStream.cpp @@ -41,6 +41,7 @@ #include "QXmppDataIq.h" #include "QXmppRpcIq.h" #include "QXmppIbbTransferManager.h" +#include "QXmppPingIq.h" #include "QXmppLogger.h" #include "QXmppUtils.h" @@ -572,6 +573,15 @@ void QXmppStream::parser(const QByteArray& data) sendNonSASLAuth(plainText); } } + // XEP-0199 ping + else if(QXmppPingIq::isPingIq(nodeRecv)) + { + QXmppIq iq(QXmppIq::Result); + iq.setId(id); + iq.setTo(from); + iq.setFrom(to); + sendPacket(iq); + } else // didn't understant the iq...reply with error { if(type != "result") // but not incase of result iqs -- cgit v1.2.3