1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-25 15:52:06 +01:00

Add MAM methods to load previous page and to load most recent page

This commit is contained in:
Fernando Ramirez 2016-12-27 15:04:30 -03:00 committed by Florian Schmaus
parent 6f66b31fb7
commit f7fcff139c

View file

@ -318,6 +318,27 @@ public final class MamManager extends Manager {
return page(mamQueryResult.form, requestRsmSet); return page(mamQueryResult.form, requestRsmSet);
} }
/**
* Returns the previous page of the archive.
*
* @param mamQueryResult
* is the previous query result
* @param count
* is the amount of messages that a page contains
* @return the MAM query result
* @throws NoResponseException
* @throws XMPPErrorException
* @throws NotConnectedException
* @throws InterruptedException
* @throws NotLoggedInException
*/
public MamQueryResult pagePrevious(MamQueryResult mamQueryResult, int count) throws NoResponseException,
XMPPErrorException, NotConnectedException, InterruptedException, NotLoggedInException {
RSMSet previousResultRsmSet = mamQueryResult.mamFin.getRSMSet();
RSMSet requestRsmSet = new RSMSet(count, previousResultRsmSet.getFirst(), RSMSet.PageDirection.before);
return page(mamQueryResult.form, requestRsmSet);
}
/** /**
* Obtain page before the first message saved (specific chat). * Obtain page before the first message saved (specific chat).
* *
@ -360,6 +381,23 @@ public final class MamManager extends Manager {
return page(dataForm, rsmSet); return page(dataForm, rsmSet);
} }
/**
* Obtain the most recent page of a chat.
*
* @param chatJid
* @param max
* @return the MAM query result
* @throws XMPPErrorException
* @throws NotLoggedInException
* @throws NotConnectedException
* @throws InterruptedException
* @throws NoResponseException
*/
public MamQueryResult mostRecentPage(Jid chatJid, int max) throws XMPPErrorException, NotLoggedInException,
NotConnectedException, InterruptedException, NoResponseException {
return pageBefore(chatJid, "", max);
}
/** /**
* Get the form fields supported by the server. * Get the form fields supported by the server.
* *