diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-03-22 10:28:33 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-03-22 10:28:33 +0000 |
| commit | 348b173dd5cf746ce9f8939aeb7bd2cc3ebb766d (patch) | |
| tree | ac2d2dcd20dbbd020a719220ace4cb244dd469fc /source/QXmppBind.cpp | |
| parent | f05f29132920c00568b867456adc15fdde576fbf (diff) | |
| download | qxmpp-348b173dd5cf746ce9f8939aeb7bd2cc3ebb766d.tar.gz | |
make it possible to detect / parse bind and session IQs
Diffstat (limited to 'source/QXmppBind.cpp')
| -rw-r--r-- | source/QXmppBind.cpp | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/source/QXmppBind.cpp b/source/QXmppBind.cpp index fe04ba74..34f326d5 100644 --- a/source/QXmppBind.cpp +++ b/source/QXmppBind.cpp @@ -1,8 +1,9 @@ /* * Copyright (C) 2008-2010 Manjeet Dahiya * - * Author: + * Authors: * Manjeet Dahiya + * Jeremy Lainé * * Source: * http://code.google.com/p/qxmpp @@ -21,27 +22,24 @@ * */ +#include <QDomElement> +#include <QTextStream> +#include <QXmlStreamWriter> #include "QXmppBind.h" #include "QXmppUtils.h" #include "QXmppConstants.h" -#include <QTextStream> -#include <QXmlStreamWriter> - QXmppBind::QXmppBind(QXmppIq::Type type) : QXmppIq(type) { } + QXmppBind::QXmppBind(const QString& type) : QXmppIq(type) { } -QXmppBind::~QXmppBind() -{ -} - QString QXmppBind::jid() const { return m_jid; @@ -62,12 +60,28 @@ void QXmppBind::setResource(const QString& str) m_resource = str; } +bool QXmppBind::isBind(const QDomElement &element) +{ + QDomElement bindElement = element.firstChildElement("bind"); + return (bindElement.namespaceURI() == ns_bind); +} + +void QXmppBind::parse(const QDomElement &element) +{ + QXmppStanza::parse(element); + setTypeFromStr(element.attribute("type")); + + QDomElement bindElement = element.firstChildElement("bind"); + m_jid = bindElement.firstChildElement("jid").text(); + m_resource = bindElement.firstChildElement("resource").text(); +} + void QXmppBind::toXmlElementFromChild(QXmlStreamWriter *writer) const { writer->writeStartElement("bind"); helperToXmlAddAttribute(writer, "xmlns", ns_bind); - helperToXmlAddTextElement(writer, "jid", jid() ); - helperToXmlAddTextElement(writer, "resource", resource()); + helperToXmlAddTextElement(writer, "jid", m_jid); + helperToXmlAddTextElement(writer, "resource", m_resource); writer->writeEndElement(); } |
