diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2011-09-20 15:20:28 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2011-09-20 15:20:28 +0000 |
| commit | 44593bd7f234284a515df59cce3332f8b91d5022 (patch) | |
| tree | c826e4a4b658c9f4cf9a6c9f5792743bac3b55d4 /src | |
| parent | 037e07e751c4ebd443a5dfff99bebabdd5c9f407 (diff) | |
| download | qxmpp-44593bd7f234284a515df59cce3332f8b91d5022.tar.gz | |
add support for XEP-0224: Attention (Fixes issue #109)
Diffstat (limited to 'src')
| -rw-r--r-- | src/QXmppConstants.cpp | 4 | ||||
| -rw-r--r-- | src/QXmppConstants.h | 1 | ||||
| -rw-r--r-- | src/QXmppDiscoveryManager.cpp | 3 | ||||
| -rw-r--r-- | src/QXmppMessage.cpp | 29 | ||||
| -rw-r--r-- | src/QXmppMessage.h | 6 |
5 files changed, 40 insertions, 3 deletions
diff --git a/src/QXmppConstants.cpp b/src/QXmppConstants.cpp index ae7f00a1..026b55b7 100644 --- a/src/QXmppConstants.cpp +++ b/src/QXmppConstants.cpp @@ -68,5 +68,7 @@ const char* ns_jingle_ice_udp = "urn:xmpp:jingle:transports:ice-udp:1"; const char *ns_jingle_rtp = "urn:xmpp:jingle:apps:rtp:1"; const char *ns_jingle_rtp_audio = "urn:xmpp:jingle:apps:rtp:audio"; const char *ns_jingle_rtp_video = "urn:xmpp:jingle:apps:rtp:video"; - +// XEP-0202: Entity Time const char *ns_entity_time = "urn:xmpp:time"; +// XEP-0224: Attention +const char *ns_attention = "urn:xmpp:attention:0"; diff --git a/src/QXmppConstants.h b/src/QXmppConstants.h index 4b4c1cfa..a4f742a2 100644 --- a/src/QXmppConstants.h +++ b/src/QXmppConstants.h @@ -68,5 +68,6 @@ extern const char *ns_jingle_rtp; extern const char *ns_jingle_rtp_audio; extern const char *ns_jingle_rtp_video; extern const char *ns_entity_time; +extern const char *ns_attention; #endif // QXMPPCONSTANTS_H diff --git a/src/QXmppDiscoveryManager.cpp b/src/QXmppDiscoveryManager.cpp index a687d07e..061f6472 100644 --- a/src/QXmppDiscoveryManager.cpp +++ b/src/QXmppDiscoveryManager.cpp @@ -126,7 +126,8 @@ QXmppDiscoveryIq QXmppDiscoveryManager::capabilities() features << ns_chat_states // XEP-0085: Chat State Notifications << ns_capabilities // XEP-0115 : Entity Capabilities - << ns_ping; // XEP-0199: XMPP Ping + << ns_ping // XEP-0199: XMPP Ping + << ns_attention; // XEP-0224: Attention foreach(QXmppClientExtension* extension, client()->extensions()) { 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); diff --git a/src/QXmppMessage.h b/src/QXmppMessage.h index 201debcc..b73b5a0b 100644 --- a/src/QXmppMessage.h +++ b/src/QXmppMessage.h @@ -61,10 +61,13 @@ public: QXmppMessage(const QString& from = "", const QString& to = "", const QString& body = "", const QString& thread = ""); ~QXmppMessage(); - + QString body() const; void setBody(const QString&); + bool isAttentionRequested() const; + void setAttentionRequested(bool requested); + QDateTime stamp() const; void setStamp(const QDateTime &stamp); @@ -101,6 +104,7 @@ private: StampType m_stampType; State m_state; + bool m_attentionRequested; QString m_body; QString m_subject; QString m_thread; |
