Flowdalic/smack — pull request #3 by ge0rg (2012-03-11 14:13:04+00:00)
Title: Implement XEP-0184 delivery notifications

This patch provides three components required to implement XEP-0184:

* DeliveryReceiptRequest is a PacketExtension to request a receipt
* DeliveryReceipt is a PacketExtension that contains the receipt
* DeliveryReceiptProvider generates DeliveryReceipt's from the stream

Implementation:

For requesting a receipt, just add a new DeliveryReceiptRequest() to
your message.

To answer a receipt request, you need to register the Provider first:

providermanager.addExtensionProvider("received",
DeliveryReceipt.NAMESPACE,
new DeliveryReceiptProvider());

Then, you can check if a received message contains a request:

if (msg.getExtension("request", DeliveryReceipt.NAMESPACE) != null) {
Message ack = new Message(msg.getFrom(), Message.Type.normal);
ack.addExtension(new DeliveryReceipt(msg.getPacketID()));
xmppconnection.sendPacket(ack);
}

Do not forget to add the feature to your ServiceDiscoveryManager, and to
handle incoming receipts in your PacketListener!