1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-23 02:58:00 +01:00

Use new PacketExtensionFilter constructor

in OfflineMessageManager
This commit is contained in:
Florian Schmaus 2014-06-10 18:54:53 +02:00
parent 1b2231be0b
commit 92bf90d059

View file

@ -58,15 +58,13 @@ public class OfflineMessageManager {
private final static String namespace = "http://jabber.org/protocol/offline"; private final static String namespace = "http://jabber.org/protocol/offline";
private XMPPConnection connection; private final XMPPConnection connection;
private PacketFilter packetFilter; private static final PacketFilter PACKET_FILTER = new AndFilter(new PacketExtensionFilter(
new OfflineMessageInfo()), new PacketTypeFilter(Message.class));;
public OfflineMessageManager(XMPPConnection connection) { public OfflineMessageManager(XMPPConnection connection) {
this.connection = connection; this.connection = connection;
packetFilter =
new AndFilter(new PacketExtensionFilter("offline", namespace),
new PacketTypeFilter(Message.class));
} }
/** /**
@ -148,7 +146,7 @@ public class OfflineMessageManager {
request.addItem(item); request.addItem(item);
} }
// Filter offline messages that were requested by this request // Filter offline messages that were requested by this request
PacketFilter messageFilter = new AndFilter(packetFilter, new PacketFilter() { PacketFilter messageFilter = new AndFilter(PACKET_FILTER, new PacketFilter() {
public boolean accept(Packet packet) { public boolean accept(Packet packet) {
OfflineMessageInfo info = (OfflineMessageInfo) packet.getExtension("offline", OfflineMessageInfo info = (OfflineMessageInfo) packet.getExtension("offline",
namespace); namespace);
@ -185,7 +183,7 @@ public class OfflineMessageManager {
request.setFetch(true); request.setFetch(true);
connection.createPacketCollectorAndSend(request).nextResultOrThrow(); connection.createPacketCollectorAndSend(request).nextResultOrThrow();
PacketCollector messageCollector = connection.createPacketCollector(packetFilter); PacketCollector messageCollector = connection.createPacketCollector(PACKET_FILTER);
// Collect the received offline messages // Collect the received offline messages
Message message = (Message) messageCollector.nextResult(); Message message = (Message) messageCollector.nextResult();
while (message != null) { while (message != null) {