aboutsummaryrefslogtreecommitdiff
path: root/source/QXmppDiscoveryIq.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-02-15 15:22:25 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-02-15 15:22:25 +0000
commita2475a40b4f8fcc6b8689cb736b016000fe50160 (patch)
tree884db898b1c47f5995cd8d3162ba52f5fbf7b113 /source/QXmppDiscoveryIq.cpp
parent6ea00ab75bed9575691473075d792598e5822635 (diff)
downloadqxmpp-a2475a40b4f8fcc6b8689cb736b016000fe50160.tar.gz
make use of QXmppIq::getQueryItems and ::setQueryItems
Diffstat (limited to 'source/QXmppDiscoveryIq.cpp')
-rw-r--r--source/QXmppDiscoveryIq.cpp39
1 files changed, 12 insertions, 27 deletions
diff --git a/source/QXmppDiscoveryIq.cpp b/source/QXmppDiscoveryIq.cpp
index 5b25011f..f38ee180 100644
--- a/source/QXmppDiscoveryIq.cpp
+++ b/source/QXmppDiscoveryIq.cpp
@@ -27,24 +27,20 @@
#include <QDomElement>
-QList<QXmppElement> QXmppDiscoveryIq::getItems() const
-{
- return m_items;
-}
-
-void QXmppDiscoveryIq::setItems(const QList<QXmppElement> &items)
-{
- m_items = items;
-}
-
enum QXmppDiscoveryIq::QueryType QXmppDiscoveryIq::getQueryType() const
{
- return m_queryType;
+ if (getQueryNamespace() == ns_disco_items)
+ return ItemsQuery;
+ else
+ return InfoQuery;
}
void QXmppDiscoveryIq::setQueryType(enum QXmppDiscoveryIq::QueryType type)
{
- m_queryType = type;
+ if (type == ItemsQuery)
+ setQueryNamespace(ns_disco_items);
+ else
+ setQueryNamespace(ns_disco_info);
}
bool QXmppDiscoveryIq::isDiscoveryIq( QDomElement &element )
@@ -60,26 +56,15 @@ void QXmppDiscoveryIq::parse( QDomElement &element )
setTo(element.attribute("to"));
setTypeFromStr(element.attribute("type"));
QDomElement queryElement = element.firstChildElement("query");
- if (queryElement.namespaceURI() == ns_disco_items)
- m_queryType = ItemsQuery;
- else
- m_queryType = InfoQuery;
+ setQueryNamespace(queryElement.namespaceURI());
+ QList<QXmppElement> items;
QDomElement itemElement = queryElement.firstChildElement();
while (!itemElement.isNull())
{
- m_items.append(QXmppElement(itemElement));
+ items.append(QXmppElement(itemElement));
itemElement = itemElement.nextSiblingElement();
}
-}
-
-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_items)
- item.toXml(writer);
- writer->writeEndElement();
+ setQueryItems(items);
}