From 44593bd7f234284a515df59cce3332f8b91d5022 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Tue, 20 Sep 2011 15:20:28 +0000 Subject: add support for XEP-0224: Attention (Fixes issue #109) --- src/QXmppMessage.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/QXmppMessage.cpp') diff --git a/src/QXmppMessage.cpp b/src/QXmppMessage.cpp index 07846ec7..100b82e3 100644 --- a/src/QXmppMessage.cpp +++ b/src/QXmppMessage.cpp @@ -51,6 +51,7 @@ QXmppMessage::QXmppMessage(const QString& from, const QString& to, const m_type(Chat), m_stampType(QXmppMessage::DelayedDelivery), m_state(None), + m_attentionRequested(false), m_body(body), m_thread(thread) { @@ -78,6 +79,24 @@ void QXmppMessage::setBody(const QString& body) m_body = body; } +/// Returns true if the user's attention is requested, as defined +/// by XEP-0224: Attention. + +bool QXmppMessage::isAttentionRequested() const +{ + return m_attentionRequested; +} + +/// Sets whether the user's attention is requested, as defined +/// by XEP-0224: Attention. +/// +/// \a param requested + +void QXmppMessage::setAttentionRequested(bool requested) +{ + m_attentionRequested = requested; +} + /// Returns the message's type. /// @@ -219,6 +238,9 @@ void QXmppMessage::parse(const QDomElement &element) m_stampType = QXmppMessage::DelayedDelivery; } + // XEP-0224: Attention + m_attentionRequested = element.firstChildElement("attention").namespaceURI() == ns_attention; + QXmppElementList extensions; QDomElement xElement = element.firstChildElement("x"); while (!xElement.isNull()) @@ -284,6 +306,13 @@ void QXmppMessage::toXml(QXmlStreamWriter *xmlWriter) const } } + // XEP-0224: Attention + if (m_attentionRequested) { + xmlWriter->writeStartElement("attention"); + xmlWriter->writeAttribute("xmlns", ns_attention); + xmlWriter->writeEndElement(); + } + // other extensions foreach (const QXmppElement &extension, extensions()) extension.toXml(xmlWriter); -- cgit v1.2.3