1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 10:37:59 +01:00

DeliveryReceipt helper methods take Message as argument

Since it makes only sense for messages to have delivery receipts.
This commit is contained in:
Florian Schmaus 2015-03-04 15:27:30 +01:00
parent b813e3aa9e
commit 183af99ffb
3 changed files with 9 additions and 9 deletions

View file

@ -19,7 +19,7 @@ package org.jivesoftware.smackx.receipts;
import java.util.List;
import java.util.Map;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.provider.EmbeddedExtensionProvider;
import org.jivesoftware.smack.util.XmlStringBuilder;
@ -76,21 +76,21 @@ public class DeliveryReceipt implements ExtensionElement
*
* @param p the packet
* @return the {@link DeliveryReceipt} extension or {@code null}
* @deprecated use {@link #from(Stanza)} instead
* @deprecated use {@link #from(Message)} instead
*/
@Deprecated
public static DeliveryReceipt getFrom(Stanza p) {
public static DeliveryReceipt getFrom(Message p) {
return from(p);
}
/**
* Get the {@link DeliveryReceipt} extension of the packet, if any.
* Get the {@link DeliveryReceipt} extension of the message, if any.
*
* @param packet the packet
* @param message the message.
* @return the {@link DeliveryReceipt} extension or {@code null}
*/
public static DeliveryReceipt from(Stanza packet) {
return packet.getExtension(ELEMENT, NAMESPACE);
public static DeliveryReceipt from(Message message) {
return message.getExtension(ELEMENT, NAMESPACE);
}
/**

View file

@ -130,7 +130,7 @@ public class DeliveryReceiptManager extends Manager {
connection.addAsyncStanzaListener(new StanzaListener() {
@Override
public void processPacket(Stanza packet) throws NotConnectedException {
DeliveryReceipt dr = DeliveryReceipt.from(packet);
DeliveryReceipt dr = DeliveryReceipt.from((Message) packet);
// notify listeners of incoming receipt
for (ReceiptReceivedListener l : receiptReceivedListeners) {
l.onReceiptReceived(packet.getFrom(), packet.getTo(), dr.getId(), packet);

View file

@ -115,7 +115,7 @@ public class DeliveryReceiptTest extends InitExtensions {
c.processPacket(m);
Stanza reply = c.getSentPacket();
DeliveryReceipt r = DeliveryReceipt.from(reply);
DeliveryReceipt r = DeliveryReceipt.from((Message) reply);
assertEquals("romeo@montague.com", reply.getTo());
assertEquals("test-receipt-request", r.getId());
}