From 507c886007aaada1044d5cea447d510f0cd97c6e Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Mon, 15 Feb 2010 15:49:19 +0000 Subject: revert changes to discovery query items --- source/QXmppDiscoveryIq.cpp | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'source/QXmppDiscoveryIq.cpp') 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 +QList QXmppDiscoveryIq::getQueryItems() const +{ + return m_queryItems; +} + +void QXmppDiscoveryIq::setQueryItems(const QList &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 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(); } -- cgit v1.2.3