use of com.xabber.xmpp.archive.Retrieve in project xabber-android by redsolution.
the class MessageArchiveManager method requestChat.
private void requestChat(String account, CollectionHeader header, String after, boolean modification) {
Retrieve packet = new Retrieve();
packet.setType(Type.get);
Set rsm = new Set();
rsm.setMax(RSM_MAX);
rsm.setAfter(after);
packet.setRsm(rsm);
packet.setWith(header.getWith());
packet.setStartString(header.getStartString());
modificationRequests.put(account, packet.getPacketID(), modification);
try {
if (!modification) {
ConnectionManager.getInstance().sendStanza(account, packet);
return;
}
ConnectionManager.getInstance().sendRequest(account, packet, new OnResponseListener() {
@Override
public void onReceived(String account, String packetId, IQ iq) {
if (iq instanceof Chat && ((Chat) iq).isValid())
onChatReceived(account, (Chat) iq);
else
onError(account, packetId, iq);
}
@Override
public void onError(String account, String packetId, IQ iq) {
onModifiedAvailable(account);
}
@Override
public void onTimeout(String account, String packetId) {
onError(account, packetId, null);
}
@Override
public void onDisconnect(String account, String packetId) {
}
});
} catch (NetworkException e) {
}
}
Aggregations