aboutsummaryrefslogtreecommitdiff
path: root/src/base/QXmppMessage.cpp
diff options
context:
space:
mode:
author0xd34df00d <0xd34df00d@gmail.com>2014-02-11 14:34:34 +0400
committer0xd34df00d <0xd34df00d@gmail.com>2014-02-11 14:34:34 +0400
commit11b347b62ff9cd0d88d69262533675adac4f4ff0 (patch)
tree1acf1c29224573587ed239a40b67b2fd0454cda7 /src/base/QXmppMessage.cpp
parentfa656fe56a34300e9718a3c83c9db21f56b94ac5 (diff)
Support other extensions besides 'x' in QXmppMessage.
Diffstat (limited to 'src/base/QXmppMessage.cpp')
-rw-r--r--src/base/QXmppMessage.cpp56
1 files changed, 42 insertions, 14 deletions
diff --git a/src/base/QXmppMessage.cpp b/src/base/QXmppMessage.cpp
index 4952fb54..e88e40f1 100644
--- a/src/base/QXmppMessage.cpp
+++ b/src/base/QXmppMessage.cpp
@@ -342,6 +342,26 @@ void QXmppMessage::setXhtml(const QString &xhtml)
d->xhtml = xhtml;
}
+namespace
+{
+ static QStringList knownMessageSubelems()
+ {
+ QStringList result;
+ result << "body"
+ << "subject"
+ << "thread"
+ << "html"
+ << "received"
+ << "request"
+ << "delay"
+ << "attention"
+ << "addresses";
+ for (int i = QXmppMessage::Active; i <= QXmppMessage::Paused; i++)
+ result << chat_states[i];
+ return result;
+ }
+}
+
/// \cond
void QXmppMessage::parse(const QDomElement &element)
{
@@ -412,27 +432,35 @@ void QXmppMessage::parse(const QDomElement &element)
// XEP-0224: Attention
d->attentionRequested = element.firstChildElement("attention").namespaceURI() == ns_attention;
+ const QStringList &knownElems = knownMessageSubelems();
+
QXmppElementList extensions;
- QDomElement xElement = element.firstChildElement("x");
+ QDomElement xElement = element.firstChildElement();
while (!xElement.isNull())
{
- if (xElement.namespaceURI() == ns_legacy_delayed_delivery)
+ if (xElement.tagName() == "x")
{
- // XEP-0091: Legacy Delayed Delivery
- const QString str = xElement.attribute("stamp");
- d->stamp = QDateTime::fromString(str, "yyyyMMddThh:mm:ss");
- d->stamp.setTimeSpec(Qt::UTC);
- d->stampType = LegacyDelayedDelivery;
- } else if (xElement.namespaceURI() == ns_conference) {
- // XEP-0249: Direct MUC Invitations
- d->mucInvitationJid = xElement.attribute("jid");
- d->mucInvitationPassword = xElement.attribute("password");
- d->mucInvitationReason = xElement.attribute("reason");
- } else {
+ if (xElement.namespaceURI() == ns_legacy_delayed_delivery)
+ {
+ // XEP-0091: Legacy Delayed Delivery
+ const QString str = xElement.attribute("stamp");
+ d->stamp = QDateTime::fromString(str, "yyyyMMddThh:mm:ss");
+ d->stamp.setTimeSpec(Qt::UTC);
+ d->stampType = LegacyDelayedDelivery;
+ } else if (xElement.namespaceURI() == ns_conference) {
+ // XEP-0249: Direct MUC Invitations
+ d->mucInvitationJid = xElement.attribute("jid");
+ d->mucInvitationPassword = xElement.attribute("password");
+ d->mucInvitationReason = xElement.attribute("reason");
+ }
+ else {
+ extensions << QXmppElement(xElement);
+ }
+ } else if (!knownElems.contains(xElement.tagName())) {
// other extensions
extensions << QXmppElement(xElement);
}
- xElement = xElement.nextSiblingElement("x");
+ xElement = xElement.nextSiblingElement();
}
setExtensions(extensions);
}