use of org.jivesoftware.smackx.rsm.packet.RSMSet in project Smack by igniterealtime.
the class MamFinIQProvider method parse.
@Override
public MamFinIQ parse(XmlPullParser parser, int initialDepth) throws Exception {
String queryId = parser.getAttributeValue("", "queryid");
boolean complete = ParserUtils.getBooleanAttribute(parser, "complete", false);
boolean stable = ParserUtils.getBooleanAttribute(parser, "stable", true);
RSMSet rsmSet = null;
outerloop: while (true) {
int eventType = parser.next();
switch(eventType) {
case XmlPullParser.START_TAG:
if (parser.getName().equals(RSMSet.ELEMENT)) {
rsmSet = RSMSetProvider.INSTANCE.parse(parser);
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
}
}
return new MamFinIQ(queryId, rsmSet, complete, stable);
}
use of org.jivesoftware.smackx.rsm.packet.RSMSet in project Smack by igniterealtime.
the class PagingTest method checkPageQueryStanza.
@Test
public void checkPageQueryStanza() throws Exception {
DataForm dataForm = getNewMamForm();
int max = 10;
RSMSet rsmSet = new RSMSet(max);
MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId, dataForm);
mamQueryIQ.setStanzaId("sarasa");
mamQueryIQ.setType(IQ.Type.set);
mamQueryIQ.addExtension(rsmSet);
Assert.assertEquals(mamQueryIQ.getDataForm(), dataForm);
Assert.assertEquals(mamQueryIQ.getDataForm().getFields().get(0).getValues().get(0), "urn:xmpp:mam:1");
Assert.assertEquals(mamQueryIQ.toXML().toString(), pagingStanza);
}
use of org.jivesoftware.smackx.rsm.packet.RSMSet in project Smack by igniterealtime.
the class RSMManager method continuePage.
Collection<ExtensionElement> continuePage(int max, Collection<ExtensionElement> returnedExtensions, Collection<ExtensionElement> additionalExtensions) {
if (returnedExtensions == null) {
throw new IllegalArgumentException("returnedExtensions must no be null");
}
if (additionalExtensions == null) {
additionalExtensions = new LinkedList<ExtensionElement>();
}
RSMSet resultRsmSet = PacketUtil.extensionElementFrom(returnedExtensions, RSMSet.ELEMENT, RSMSet.NAMESPACE);
if (resultRsmSet == null) {
throw new IllegalArgumentException("returnedExtensions did not contain a RSMset");
}
RSMSet continePageRsmSet = new RSMSet(max, resultRsmSet.getLast(), PageDirection.after);
additionalExtensions.add(continePageRsmSet);
return additionalExtensions;
}
use of org.jivesoftware.smackx.rsm.packet.RSMSet in project Smack by igniterealtime.
the class MamManager method pageAfter.
/**
* Obtain page after the last message saved (specific chat).
* <p>
* Note that the messageUid is the XEP-0313 UID and <b>not</> the stanza ID of the message.
* </p>
*
* @param chatJid
* @param messageUid the UID of the message of which messages after should be received.
* @param max
* @return the MAM query result
* @throws XMPPErrorException
* @throws NotLoggedInException
* @throws NotConnectedException
* @throws InterruptedException
* @throws NoResponseException
*/
public MamQueryResult pageAfter(Jid chatJid, String messageUid, int max) throws XMPPErrorException, NotLoggedInException, NotConnectedException, InterruptedException, NoResponseException {
RSMSet rsmSet = new RSMSet(messageUid, null, -1, -1, null, max, null, -1);
DataForm dataForm = getNewMamForm();
addWithJid(chatJid, dataForm);
return page(null, dataForm, rsmSet);
}
use of org.jivesoftware.smackx.rsm.packet.RSMSet in project Smack by igniterealtime.
the class MamManager method pageNext.
/**
* Returns the next 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 pageNext(MamQueryResult mamQueryResult, int count) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotLoggedInException {
RSMSet previousResultRsmSet = mamQueryResult.mamFin.getRSMSet();
RSMSet requestRsmSet = new RSMSet(count, previousResultRsmSet.getLast(), RSMSet.PageDirection.after);
return page(mamQueryResult, requestRsmSet);
}
Aggregations