aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-03-04 11:06:16 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-03-04 11:06:16 +0000
commit8d2a59d20853d1c1ddb937196cfc9a10b67c6aad (patch)
treebd41e59ccb7987c50201fad77f4254c576baf226 /source
parentcc1f2420a04a190b350f455e29224b354a19e118 (diff)
downloadqxmpp-8d2a59d20853d1c1ddb937196cfc9a10b67c6aad.tar.gz
add support for XEP-0092: Software Version
Diffstat (limited to 'source')
-rw-r--r--source/QXmppVersionIq.cpp94
-rw-r--r--source/QXmppVersionIq.h54
-rw-r--r--source/source.pro2
3 files changed, 150 insertions, 0 deletions
diff --git a/source/QXmppVersionIq.cpp b/source/QXmppVersionIq.cpp
new file mode 100644
index 00000000..ab6f5e52
--- /dev/null
+++ b/source/QXmppVersionIq.cpp
@@ -0,0 +1,94 @@
+/*
+ * 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 <QDomElement>
+
+#include "QXmppUtils.h"
+#include "QXmppVersionIq.h"
+
+static const char *ns_version = "jabber:iq:version";
+
+QString QXmppVersionIq::name() const
+{
+ return m_name;
+}
+
+void QXmppVersionIq::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QString QXmppVersionIq::os() const
+{
+ return m_os;
+}
+
+void QXmppVersionIq::setOs(const QString &os)
+{
+ m_os = os;
+}
+
+QString QXmppVersionIq::version() const
+{
+ return m_version;
+}
+
+void QXmppVersionIq::setVersion(const QString &version)
+{
+ m_version = version;
+}
+
+bool QXmppVersionIq::isVersionIq(const QDomElement &element)
+{
+ QDomElement queryElement = element.firstChildElement("query");
+ return queryElement.namespaceURI() == ns_version;
+}
+
+void QXmppVersionIq::parse(const QDomElement &element)
+{
+ QXmppStanza::parse(element);
+ setTypeFromStr(element.attribute("type"));
+
+ QDomElement queryElement = element.firstChildElement("query");
+ m_name = element.firstChildElement("name").text();
+ m_os = element.firstChildElement("os").text();
+ m_version = element.firstChildElement("version").text();
+}
+
+void QXmppVersionIq::toXmlElementFromChild(QXmlStreamWriter *writer) const
+{
+ writer->writeStartElement("query");
+ helperToXmlAddAttribute(writer, "xmlns", ns_version);
+
+ if (!m_name.isEmpty())
+ helperToXmlAddTextElement(writer, "name", m_name);
+
+ if (!m_os.isEmpty())
+ helperToXmlAddTextElement(writer, "os", m_os);
+
+ if (!m_version.isEmpty())
+ helperToXmlAddTextElement(writer, "version", m_version);
+
+ writer->writeEndElement();
+}
+
diff --git a/source/QXmppVersionIq.h b/source/QXmppVersionIq.h
new file mode 100644
index 00000000..7f02d112
--- /dev/null
+++ b/source/QXmppVersionIq.h
@@ -0,0 +1,54 @@
+/*
+ * 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 QXMPPVERSIONIQ_H
+#define QXMPPVERSIONIQ_H
+
+#include "QXmppIq.h"
+
+/// XEP-0092: Software Version
+/// http://xmpp.org/extensions/xep-0092.html
+
+class QXmppVersionIq : public QXmppIq
+{
+public:
+ QString name() const;
+ void setName(const QString &name);
+
+ QString os() const;
+ void setOs(const QString &os);
+
+ QString version() const;
+ void setVersion(const QString &version);
+
+ static bool isVersionIq(const QDomElement &element);
+ void parse(const QDomElement &element);
+ void toXmlElementFromChild(QXmlStreamWriter *writer) const;
+
+private:
+ QString m_name;
+ QString m_os;
+ QString m_version;
+};
+
+#endif
diff --git a/source/source.pro b/source/source.pro
index 5d355ce6..5f5d8300 100644
--- a/source/source.pro
+++ b/source/source.pro
@@ -46,6 +46,7 @@ HEADERS += QXmppUtils.h \
QXmppRpcIq.h \
QXmppVCardManager.h \
QXmppVCard.h \
+ QXmppVersionIq.h \
xmlrpc.h
# Source files
@@ -82,4 +83,5 @@ SOURCES += QXmppUtils.cpp \
QXmppRpcIq.cpp \
QXmppVCardManager.cpp \
QXmppVCard.cpp \
+ QXmppVersionIq.cpp \
xmlrpc.cpp