diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-02-15 15:49:19 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-02-15 15:49:19 +0000 |
| commit | 507c886007aaada1044d5cea447d510f0cd97c6e (patch) | |
| tree | 1d78016e07c9fb2db213b77f5f1f145dde126d94 /source | |
| parent | d18646274885a4dcc376094e372f24b6922155b8 (diff) | |
| download | qxmpp-507c886007aaada1044d5cea447d510f0cd97c6e.tar.gz | |
revert changes to discovery query items
Diffstat (limited to 'source')
| -rw-r--r-- | source/QXmppDiscoveryIq.cpp | 39 | ||||
| -rw-r--r-- | source/QXmppDiscoveryIq.h | 8 |
2 files changed, 35 insertions, 12 deletions
diff --git a/source/QXmppDiscoveryIq.cpp b/source/QXmppDiscoveryIq.cpp index f38ee180..f8557265 100644 --- a/source/QXmppDiscoveryIq.cpp +++ b/source/QXmppDiscoveryIq.cpp @@ -27,20 +27,24 @@ #include <QDomElement> +QList<QXmppElement> QXmppDiscoveryIq::getQueryItems() const +{ + return m_queryItems; +} + +void QXmppDiscoveryIq::setQueryItems(const QList<QXmppElement> &items) +{ + m_queryItems = items; +} + enum QXmppDiscoveryIq::QueryType QXmppDiscoveryIq::getQueryType() const { - if (getQueryNamespace() == ns_disco_items) - return ItemsQuery; - else - return InfoQuery; + return m_queryType; } void QXmppDiscoveryIq::setQueryType(enum QXmppDiscoveryIq::QueryType type) { - if (type == ItemsQuery) - setQueryNamespace(ns_disco_items); - else - setQueryNamespace(ns_disco_info); + m_queryType = type; } bool QXmppDiscoveryIq::isDiscoveryIq( QDomElement &element ) @@ -56,15 +60,26 @@ void QXmppDiscoveryIq::parse( QDomElement &element ) setTo(element.attribute("to")); setTypeFromStr(element.attribute("type")); QDomElement queryElement = element.firstChildElement("query"); - setQueryNamespace(queryElement.namespaceURI()); + if (queryElement.namespaceURI() == ns_disco_items) + m_queryType = ItemsQuery; + else + m_queryType = InfoQuery; - QList<QXmppElement> items; QDomElement itemElement = queryElement.firstChildElement(); while (!itemElement.isNull()) { - items.append(QXmppElement(itemElement)); + m_queryItems.append(QXmppElement(element)); itemElement = itemElement.nextSiblingElement(); } - setQueryItems(items); +} + +void QXmppDiscoveryIq::toXmlElementFromChild(QXmlStreamWriter *writer) const +{ + writer->writeStartElement("query"); + helperToXmlAddAttribute(writer, "xmlns", + m_queryType == InfoQuery ? ns_disco_info : ns_disco_items); + foreach (const QXmppElement &item, m_queryItems) + item.toXml(writer); + writer->writeEndElement(); } diff --git a/source/QXmppDiscoveryIq.h b/source/QXmppDiscoveryIq.h index f4355670..a7e09c23 100644 --- a/source/QXmppDiscoveryIq.h +++ b/source/QXmppDiscoveryIq.h @@ -37,11 +37,19 @@ public: ItemsQuery, }; + void toXmlElementFromChild(QXmlStreamWriter *writer) const; void parse( QDomElement &element ); static bool isDiscoveryIq( QDomElement &element ); + QList<QXmppElement> getQueryItems() const; + void setQueryItems(const QList<QXmppElement> &items); + enum QueryType getQueryType() const; void setQueryType(enum QueryType type); + +private: + QList<QXmppElement> m_queryItems; + enum QueryType m_queryType; }; #endif |
