* @throws XMPPException If the user is not allowed to make this request or the server does
* not support offline message retrieval.
*/
public Iterator<Message> getMessages(final List<String> nodes) throws XMPPException {
List<Message> messages = new ArrayList<Message>();
OfflineMessageRequest request = new OfflineMessageRequest();
for (String node : nodes) {
OfflineMessageRequest.Item item = new OfflineMessageRequest.Item(node);
item.setAction("view");
request.addItem(item);
}
// Filter packets looking for an answer from the server.
PacketFilter responseFilter = new PacketIDFilter(request.getPacketID());
PacketCollector response = connection.createPacketCollector(responseFilter);
// Filter offline messages that were requested by this request
PacketFilter messageFilter = new AndFilter(packetFilter, new PacketFilter() {
public boolean accept(Packet packet) {
OfflineMessageInfo info = (OfflineMessageInfo) packet.getExtension("offline",