aboutsummaryrefslogtreecommitdiff
path: root/source/QXmppStanza.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-02-18 13:36:55 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-02-18 13:36:55 +0000
commitc12a2d1eca2d73d0842584724629e00dbbc52952 (patch)
treeaec8723e03194759af974bfd290e92a5edf18974 /source/QXmppStanza.cpp
parentec7b4b11603a5ecaacfc717d0ce30dc68099b636 (diff)
downloadqxmpp-c12a2d1eca2d73d0842584724629e00dbbc52952.tar.gz
move stanza error parsing to QXmppStanza
Diffstat (limited to 'source/QXmppStanza.cpp')
-rw-r--r--source/QXmppStanza.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/source/QXmppStanza.cpp b/source/QXmppStanza.cpp
index 5c5fadbe..f8bc1fa7 100644
--- a/source/QXmppStanza.cpp
+++ b/source/QXmppStanza.cpp
@@ -26,6 +26,7 @@
#include "QXmppUtils.h"
#include "QXmppConstants.h"
+#include <QDomElement>
#include <QXmlStreamWriter>
uint QXmppStanza::s_uniqeIdNo = 0;
@@ -330,3 +331,32 @@ bool QXmppStanza::isErrorStanza()
return !(m_error.getTypeStr().isEmpty() &&
m_error.getConditionStr().isEmpty());
}
+
+QXmppStanza::Error QXmppStanza::parseError(const QDomElement &errorElement)
+{
+ QXmppStanza::Error error;
+
+ if(errorElement.isNull())
+ return error;
+
+ QString type = errorElement.attribute("type");
+ QString text;
+ QString cond;
+ QDomElement element = errorElement.firstChildElement();
+ while(!element.isNull())
+ {
+ if(element.tagName() == "text")
+ text = element.text();
+ else if(element.namespaceURI() == ns_stanza)
+ {
+ cond = element.tagName();
+ }
+ element = element.nextSiblingElement();
+ }
+
+ error.setConditionFromStr(cond);
+ error.setTypeFromStr(type);
+ error.setText(text);
+ return error;
+}
+