mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-29 07:22:07 +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
|
* @param m Message object to add a request to
|
||||||
* @return the Message ID which will be used as receipt ID
|
* @return the Message ID which will be used as receipt ID
|
||||||
|
* @deprecated use {@link DeliveryReceiptRequest#addTo(Message)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static String addDeliveryReceiptRequest(Message m) {
|
public static String addDeliveryReceiptRequest(Message m) {
|
||||||
m.addExtension(new DeliveryReceiptRequest());
|
return DeliveryReceiptRequest.addTo(m);
|
||||||
return m.getPacketID();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.receipts;
|
package org.jivesoftware.smackx.receipts;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.Message;
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
import org.jivesoftware.smack.packet.PacketExtension;
|
import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||||
|
@ -68,6 +69,20 @@ public class DeliveryReceiptRequest implements PacketExtension
|
||||||
return packet.getExtension(ELEMENT, DeliveryReceipt.NAMESPACE);
|
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.
|
* 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);
|
Message m = new Message("romeo@montague.com", Message.Type.normal);
|
||||||
assertFalse(DeliveryReceiptManager.hasDeliveryReceiptRequest(m));
|
assertFalse(DeliveryReceiptManager.hasDeliveryReceiptRequest(m));
|
||||||
DeliveryReceiptManager.addDeliveryReceiptRequest(m);
|
DeliveryReceiptRequest.addTo(m);
|
||||||
assertTrue(DeliveryReceiptManager.hasDeliveryReceiptRequest(m));
|
assertTrue(DeliveryReceiptManager.hasDeliveryReceiptRequest(m));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public class DeliveryReceiptTest extends InitExtensions {
|
||||||
Message m = new Message("julia@capulet.com", Message.Type.normal);
|
Message m = new Message("julia@capulet.com", Message.Type.normal);
|
||||||
m.setFrom("romeo@montague.com");
|
m.setFrom("romeo@montague.com");
|
||||||
m.setPacketID("test-receipt-request");
|
m.setPacketID("test-receipt-request");
|
||||||
DeliveryReceiptManager.addDeliveryReceiptRequest(m);
|
DeliveryReceiptRequest.addTo(m);
|
||||||
|
|
||||||
// the DRM will send a reply-packet
|
// the DRM will send a reply-packet
|
||||||
assertEquals(0, c.getNumberOfSentPackets());
|
assertEquals(0, c.getNumberOfSentPackets());
|
||||||
|
|
Loading…
Reference in a new issue