aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-02-06 19:12:19 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2012-02-06 19:12:19 +0000
commit78711c314a4cc20aaf276e519d9db1d91cf22fa7 (patch)
treea2ae5b3c1c0fef7e231f828444d5878ad0ad5b41 /src
parentf38253b159f7cbb4bc2c9990d76255d167d3af7b (diff)
downloadqxmpp-78711c314a4cc20aaf276e519d9db1d91cf22fa7.tar.gz
add an attribute to QXmppMessage to carry delivery receipt request
Diffstat (limited to 'src')
-rw-r--r--src/QXmppConstants.cpp1
-rw-r--r--src/QXmppConstants.h1
-rw-r--r--src/QXmppMessage.cpp33
-rw-r--r--src/QXmppMessage.h6
4 files changed, 40 insertions, 1 deletions
diff --git a/src/QXmppConstants.cpp b/src/QXmppConstants.cpp
index 026b55b7..c77859b6 100644
--- a/src/QXmppConstants.cpp
+++ b/src/QXmppConstants.cpp
@@ -47,6 +47,7 @@ const char* ns_ibb = "http://jabber.org/protocol/ibb";
const char* ns_rpc = "jabber:iq:rpc";
const char *ns_ping = "urn:xmpp:ping";
const char *ns_conference = "jabber:x:conference";
+const char *ns_message_receipts = "urn:xmpp:receipts";
const char *ns_delayed_delivery = "urn:xmpp:delay";
const char *ns_legacy_delayed_delivery = "jabber:x:delay";
const char *ns_muc = "http://jabber.org/protocol/muc";
diff --git a/src/QXmppConstants.h b/src/QXmppConstants.h
index a4f742a2..909bddd9 100644
--- a/src/QXmppConstants.h
+++ b/src/QXmppConstants.h
@@ -48,6 +48,7 @@ extern const char* ns_ibb;
extern const char* ns_rpc;
extern const char* ns_ping;
extern const char *ns_conference;
+extern const char *ns_message_receipts;
extern const char *ns_delayed_delivery;
extern const char *ns_legacy_delayed_delivery;
extern const char *ns_muc;
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");
diff --git a/src/QXmppMessage.h b/src/QXmppMessage.h
index 9d518f74..645bd96d 100644
--- a/src/QXmppMessage.h
+++ b/src/QXmppMessage.h
@@ -68,6 +68,9 @@ public:
bool isAttentionRequested() const;
void setAttentionRequested(bool requested);
+ bool isReceiptRequested() const;
+ void setReceiptRequested(bool requested);
+
QDateTime stamp() const;
void setStamp(const QDateTime &stamp);
@@ -108,6 +111,9 @@ private:
QString m_body;
QString m_subject;
QString m_thread;
+
+ // Request message receipt as per XEP-0184.
+ bool m_receiptRequested;
};
#endif // QXMPPMESSAGE_H