mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-22 10:37:59 +01:00
Add DeliveryReceiptRequest.addTo(Message)
This commit is contained in:
parent
19ee9f016b
commit
387be5bded
3 changed files with 20 additions and 4 deletions
|
@ -188,9 +188,10 @@ public class DeliveryReceiptManager extends Manager implements PacketListener {
|
|||
*
|
||||
* @param m Message object to add a request to
|
||||
* @return the Message ID which will be used as receipt ID
|
||||
* @deprecated use {@link DeliveryReceiptRequest#addTo(Message)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String addDeliveryReceiptRequest(Message m) {
|
||||
m.addExtension(new DeliveryReceiptRequest());
|
||||
return m.getPacketID();
|
||||
return DeliveryReceiptRequest.addTo(m);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.receipts;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
|
@ -68,6 +69,20 @@ public class DeliveryReceiptRequest implements PacketExtension
|
|||
return packet.getExtension(ELEMENT, DeliveryReceipt.NAMESPACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a delivery receipt request to an outgoing packet.
|
||||
*
|
||||
* Only message packets may contain receipt requests as of XEP-0184,
|
||||
* therefore only allow Message as the parameter type.
|
||||
*
|
||||
* @param message Message object to add a request to
|
||||
* @return the Message ID which will be used as receipt ID
|
||||
*/
|
||||
public static String addTo(Message message) {
|
||||
message.addExtension(new DeliveryReceiptRequest());
|
||||
return message.getPacketID();
|
||||
}
|
||||
|
||||
/**
|
||||
* This Provider parses and returns DeliveryReceiptRequest packets.
|
||||
*/
|
||||
|
|
|
@ -63,7 +63,7 @@ public class DeliveryReceiptTest extends InitExtensions {
|
|||
|
||||
Message m = new Message("romeo@montague.com", Message.Type.normal);
|
||||
assertFalse(DeliveryReceiptManager.hasDeliveryReceiptRequest(m));
|
||||
DeliveryReceiptManager.addDeliveryReceiptRequest(m);
|
||||
DeliveryReceiptRequest.addTo(m);
|
||||
assertTrue(DeliveryReceiptManager.hasDeliveryReceiptRequest(m));
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ public class DeliveryReceiptTest extends InitExtensions {
|
|||
Message m = new Message("julia@capulet.com", Message.Type.normal);
|
||||
m.setFrom("romeo@montague.com");
|
||||
m.setPacketID("test-receipt-request");
|
||||
DeliveryReceiptManager.addDeliveryReceiptRequest(m);
|
||||
DeliveryReceiptRequest.addTo(m);
|
||||
|
||||
// the DRM will send a reply-packet
|
||||
assertEquals(0, c.getNumberOfSentPackets());
|
||||
|
|
Loading…
Reference in a new issue