aboutsummaryrefslogtreecommitdiff
path: root/source/QXmppVersionIq.cpp
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/QXmppVersionIq.cpp
parentcc1f2420a04a190b350f455e29224b354a19e118 (diff)
downloadqxmpp-8d2a59d20853d1c1ddb937196cfc9a10b67c6aad.tar.gz
add support for XEP-0092: Software Version
Diffstat (limited to 'source/QXmppVersionIq.cpp')
-rw-r--r--source/QXmppVersionIq.cpp94
1 files changed, 94 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();
+}
+