diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-02-06 19:12:19 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-02-06 19:12:19 +0000 |
| commit | 78711c314a4cc20aaf276e519d9db1d91cf22fa7 (patch) | |
| tree | a2ae5b3c1c0fef7e231f828444d5878ad0ad5b41 /src/QXmppMessage.cpp | |
| parent | f38253b159f7cbb4bc2c9990d76255d167d3af7b (diff) | |
| download | qxmpp-78711c314a4cc20aaf276e519d9db1d91cf22fa7.tar.gz | |
add an attribute to QXmppMessage to carry delivery receipt request
Diffstat (limited to 'src/QXmppMessage.cpp')
| -rw-r--r-- | src/QXmppMessage.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/QXmppMessage.cpp b/src/QXmppMessage.cpp index a76e02ec..a10ee7e5 100644 --- a/src/QXmppMessage.cpp +++ b/src/QXmppMessage.cpp @@ -53,7 +53,8 @@ QXmppMessage::QXmppMessage(const QString& from, const QString& to, const m_state(None), m_attentionRequested(false), m_body(body), - m_thread(thread) + m_thread(thread), + m_receiptRequested(false) { } @@ -97,6 +98,26 @@ void QXmppMessage::setAttentionRequested(bool requested) m_attentionRequested = requested; } +/// Returns true if a delivery receipt is requested, as defined +/// by XEP-0184: Message Delivery Receipts. + +bool QXmppMessage::isReceiptRequested() const +{ + return m_receiptRequested; +} + +/// Sets whether a delivery receipt is requested, as defined +/// by XEP-0184: Message Delivery Receipts. +/// +/// \a param requested + +void QXmppMessage::setReceiptRequested(bool requested) +{ + m_receiptRequested = requested; + if (requested && id().isEmpty()) + generateAndSetNextId(); +} + /// Returns the message's type. /// @@ -229,6 +250,9 @@ void QXmppMessage::parse(const QDomElement &element) } } + // XEP-0184: Message Delivery Receipts + m_receiptRequested = element.firstChildElement("request").namespaceURI() == ns_message_receipts; + // XEP-0203: Delayed Delivery QDomElement delayElement = element.firstChildElement("delay"); if (!delayElement.isNull() && delayElement.namespaceURI() == ns_delayed_delivery) @@ -306,6 +330,13 @@ void QXmppMessage::toXml(QXmlStreamWriter *xmlWriter) const } } + // XEP-0184: Message Delivery Receipts + if (m_receiptRequested) { + xmlWriter->writeStartElement("request"); + xmlWriter->writeAttribute("xmlns", ns_message_receipts); + xmlWriter->writeEndElement(); + } + // XEP-0224: Attention if (m_attentionRequested) { xmlWriter->writeStartElement("attention"); |
