aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-02-01 11:55:35 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-02-01 11:55:35 +0000
commitb41ac3387971d843e9db0785d7f693d5cb828461 (patch)
tree526142b542503d849022783de9c4078a02fc3f89
parent8114fb0467e713e7735d4b63ec8a772ff86ccc01 (diff)
downloadqxmpp-b41ac3387971d843e9db0785d7f693d5cb828461.tar.gz
add QXmppPingIq class for XEP-0199 pings
-rw-r--r--source/QXmppConstants.cpp1
-rw-r--r--source/QXmppConstants.h1
-rw-r--r--source/QXmppPingIq.cpp46
-rw-r--r--source/QXmppPingIq.h40
-rw-r--r--source/source.pro2
5 files changed, 90 insertions, 0 deletions
diff --git a/source/QXmppConstants.cpp b/source/QXmppConstants.cpp
index 4c392f34..8b29b61e 100644
--- a/source/QXmppConstants.cpp
+++ b/source/QXmppConstants.cpp
@@ -38,3 +38,4 @@ const char* ns_authFeature = "http://jabber.org/features/iq-auth";
const char* ns_disco_info = "http://jabber.org/protocol/disco#info";
const char* ns_ibb = "http://jabber.org/protocol/ibb";
const char* ns_rpc = "jabber:iq:rpc";
+const char *ns_ping = "urn:xmpp:ping";
diff --git a/source/QXmppConstants.h b/source/QXmppConstants.h
index 4181fb14..40bcce73 100644
--- a/source/QXmppConstants.h
+++ b/source/QXmppConstants.h
@@ -39,5 +39,6 @@ extern const char* ns_authFeature;
extern const char* ns_disco_info;
extern const char* ns_ibb;
extern const char* ns_rpc;
+extern const char* ns_ping;
#endif // QXMPPCONSTANTS_H
diff --git a/source/QXmppPingIq.cpp b/source/QXmppPingIq.cpp
new file mode 100644
index 00000000..ccf34cf6
--- /dev/null
+++ b/source/QXmppPingIq.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2010 Bolloré telecom
+ *
+ * Author:
+ * Jeremy Lainé
+ *
+ * Source:
+ * http://code.google.com/p/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ */
+
+#include "QXmppConstants.h"
+#include "QXmppPingIq.h"
+#include "QXmppUtils.h"
+
+#include <QDomElement>
+
+QXmppPingIq::QXmppPingIq() : QXmppIq(QXmppIq::Get)
+{
+}
+
+bool QXmppPingIq::isPingIq( QDomElement &element )
+{
+ QDomElement pingElement = element.firstChildElement("ping");
+ return (pingElement.namespaceURI() == ns_ping);
+}
+
+void QXmppPingIq::toXmlElementFromChild(QXmlStreamWriter *writer) const
+{
+ writer->writeStartElement("ping");
+ helperToXmlAddAttribute(writer, "xmlns", ns_ping);
+ writer->writeEndElement();
+}
+
diff --git a/source/QXmppPingIq.h b/source/QXmppPingIq.h
new file mode 100644
index 00000000..83b7db4d
--- /dev/null
+++ b/source/QXmppPingIq.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2010 Bolloré telecom
+ *
+ * Author:
+ * Jeremy Lainé
+ *
+ * Source:
+ * http://code.google.com/p/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ */
+
+#ifndef QXMPPPINGIQ_H
+#define QXMPPPINGIQ_H
+
+#include "QXmppIq.h"
+
+class QXmlStreamWriter;
+class QDomElement;
+
+class QXmppPingIq : public QXmppIq
+{
+public:
+ QXmppPingIq();
+ void toXmlElementFromChild(QXmlStreamWriter *writer) const;
+ static bool isPingIq( QDomElement &element );
+};
+
+#endif
diff --git a/source/source.pro b/source/source.pro
index 6866e87b..ef66431d 100644
--- a/source/source.pro
+++ b/source/source.pro
@@ -21,6 +21,7 @@ HEADERS += QXmppUtils.h \
QXmppIq.h \
QXmppMessage.h \
QXmppPacket.h \
+ QXmppPingIq.h \
QXmppPresence.h \
QXmppRoster.h \
QXmppRosterIq.h \
@@ -51,6 +52,7 @@ SOURCES += QXmppUtils.cpp \
QXmppIq.cpp \
QXmppMessage.cpp \
QXmppPacket.cpp \
+ QXmppPingIq.cpp \
QXmppPresence.cpp \
QXmppRoster.cpp \
QXmppRosterIq.cpp \