aboutsummaryrefslogtreecommitdiff
path: root/source/QXmppRosterIq.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-04-15 07:49:58 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-04-15 07:49:58 +0000
commit9720d62c6d626fc8ef14e0fb1964ba8686e603b1 (patch)
treed463ee0d4ae5f48c10110bad6562c0e4db9a9c97 /source/QXmppRosterIq.cpp
parent42c462b544044bb7795211789fc589a6e54f01f1 (diff)
downloadqxmpp-9720d62c6d626fc8ef14e0fb1964ba8686e603b1.tar.gz
add a "parse" method to QXmppRosterIq
Diffstat (limited to 'source/QXmppRosterIq.cpp')
-rw-r--r--source/QXmppRosterIq.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/source/QXmppRosterIq.cpp b/source/QXmppRosterIq.cpp
index 1c5a4997..46fa6bc1 100644
--- a/source/QXmppRosterIq.cpp
+++ b/source/QXmppRosterIq.cpp
@@ -21,11 +21,12 @@
*
*/
+#include <QDomElement>
+#include <QXmlStreamWriter>
#include "QXmppRosterIq.h"
#include "QXmppConstants.h"
#include "QXmppUtils.h"
-#include <QXmlStreamWriter>
QXmppRosterIq::QXmppRosterIq(QXmppIq::Type type)
: QXmppIq(type)
@@ -53,6 +54,30 @@ QList<QXmppRosterIq::Item> QXmppRosterIq::items() const
return m_items;
}
+void QXmppRosterIq::parse(const QDomElement &element)
+{
+ QXmppStanza::parse(element);
+ setTypeFromStr(element.attribute("type"));
+
+ QDomElement itemElement = element.
+ firstChildElement("query").
+ firstChildElement("item");
+ while(!itemElement.isNull())
+ {
+ QXmppRosterIq::Item item;
+ item.setName(itemElement.attribute("name"));
+ item.setBareJid(itemElement.attribute("jid"));
+ item.setSubscriptionTypeFromStr(
+ itemElement.attribute("subscription"));
+ item.setSubscriptionStatus(
+ itemElement.attribute("ask"));
+ item.addGroup(
+ itemElement.firstChildElement("group").firstChildElement().text());
+ m_items.append(item);
+ itemElement = itemElement.nextSiblingElement();
+ }
+}
+
void QXmppRosterIq::toXmlElementFromChild(QXmlStreamWriter *writer) const
{
writer->writeStartElement("query");