diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-02-06 20:33:02 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-02-06 20:33:02 +0000 |
| commit | 28be283f9a1bc9e5b18c4e52a2c815354deee82e (patch) | |
| tree | f1e6b16ad4b53e431e20969a8c0e013765faa15a /src | |
| parent | 8ed3dad8fe6aa729ffc3c0732a442e38b66c9e2a (diff) | |
| download | qxmpp-28be283f9a1bc9e5b18c4e52a2c815354deee82e.tar.gz | |
make use of QXmppMessage's receipt methods
Diffstat (limited to 'src')
| -rw-r--r-- | src/QXmppMessageReceiptManager.cpp | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/src/QXmppMessageReceiptManager.cpp b/src/QXmppMessageReceiptManager.cpp index 720ac970..268f3036 100644 --- a/src/QXmppMessageReceiptManager.cpp +++ b/src/QXmppMessageReceiptManager.cpp @@ -69,37 +69,27 @@ bool QXmppMessageReceiptManager::handleStanza(const QDomElement &stanza) if (stanza.tagName() != "message") return false; - // Case 1: incoming receipt - // This way we handle the receipt and cancel any further processing. - const QDomElement &received = stanza.firstChildElement("received"); - if (received.namespaceURI() == ns_message_receipts) - { - QString id = received.attribute("id"); + QXmppMessage message; + message.parse(stanza); - // check if it's old-style XEP - if (id.isEmpty()) - id = stanza.attribute("id"); - - emit messageDelivered(stanza.attribute("from"), id); + // Handle receipts and cancel any further processing. + if (!message.receiptId().isEmpty()) { + emit messageDelivered(message.from(), message.receiptId()); return true; } - // Case 2: incoming message requesting receipt // If autoreceipt is enabled, we queue sending back receipt, otherwise // we just ignore the message. In either case, we don't cancel any // further processing. - if (m_autoReceipt && stanza.firstChildElement("request").namespaceURI() == ns_message_receipts) - { - const QString &jid = stanza.attribute("from"); - const QString &id = stanza.attribute("id"); - - // Send out receipt only if jid and id is not empty, otherwise fail - // silently. - if (!jid.isEmpty() && !id.isEmpty()) - QMetaObject::invokeMethod(this, - "sendReceipt", - Q_ARG(QString, jid), - Q_ARG(QString, id)); + if (m_autoReceipt + && message.isReceiptRequested() + && !message.from().isEmpty() + && !message.id().isEmpty()) { + + QMetaObject::invokeMethod(this, + "sendReceipt", + Q_ARG(QString, message.from()), + Q_ARG(QString, message.id())); } return false; |
