use of org.jivesoftware.smackx.rsm.packet.RSMSet in project Smack by igniterealtime.
the class RSMSetProviderTest method testRsmSetProvider.
@Test
public void testRsmSetProvider() throws Exception {
// @formatter:off
final String rsmset = "<iq type='get' id='iqget'>" + "<pubsub xmlns='http://jabber.org/protocol/pubsub'>" + "<set xmlns='http://jabber.org/protocol/rsm'>" + "<after>aftervalue</after>" + "<before>beforevalue</before>" + "<count>1</count>" + "<first index='2'>foo@bar.com</first>" + "<index>3</index>" + "<last>lastvalue</last>" + "<max>4</max>" + "</set>" + "</pubsub>" + "</iq>";
// @formatter:on
IQ iqWithRsm = (IQ) PacketParserUtils.parseStanza(rsmset);
RSMSet rsm = (RSMSet) iqWithRsm.getExtension(RSMSet.ELEMENT, RSMSet.NAMESPACE);
assertNotNull(rsm);
assertEquals("aftervalue", rsm.getAfter());
assertEquals("beforevalue", rsm.getBefore());
assertEquals(1, rsm.getCount());
assertEquals(2, rsm.getFirstIndex());
assertEquals("foo@bar.com", rsm.getFirst());
assertEquals(3, rsm.getIndex());
assertEquals("lastvalue", rsm.getLast());
assertEquals(4, rsm.getMax());
}
use of org.jivesoftware.smackx.rsm.packet.RSMSet in project Smack by igniterealtime.
the class MamFinProviderTest method checkMamFinProvider.
@Test
public void checkMamFinProvider() throws Exception {
XmlPullParser parser = PacketParserUtils.getParserFor(exmapleMamFinXml);
MamFinIQ mamFinIQ = new MamFinIQProvider().parse(parser);
Assert.assertFalse(mamFinIQ.isComplete());
Assert.assertTrue(mamFinIQ.isStable());
Assert.assertNull(mamFinIQ.getQueryId());
RSMSet rsmSet = mamFinIQ.getRSMSet();
Assert.assertEquals(rsmSet.getAfter(), "09af3-cc343-b409f");
Assert.assertEquals(rsmSet.getMax(), 10);
}
use of org.jivesoftware.smackx.rsm.packet.RSMSet in project Smack by igniterealtime.
the class RSMManager method page.
Collection<ExtensionElement> page(int max) {
List<ExtensionElement> packetExtensions = new LinkedList<ExtensionElement>();
packetExtensions.add(new RSMSet(max));
return packetExtensions;
}
use of org.jivesoftware.smackx.rsm.packet.RSMSet in project Smack by igniterealtime.
the class MamManager method pageBefore.
/**
* Obtain page before the first 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 before should be received.
* @param max
* @return the MAM query result
* @throws XMPPErrorException
* @throws NotLoggedInException
* @throws NotConnectedException
* @throws InterruptedException
* @throws NoResponseException
*/
public MamQueryResult pageBefore(Jid chatJid, String messageUid, int max) throws XMPPErrorException, NotLoggedInException, NotConnectedException, InterruptedException, NoResponseException {
RSMSet rsmSet = new RSMSet(null, messageUid, -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 addResultsLimit.
private static void addResultsLimit(Integer max, MamQueryIQ mamQueryIQ) {
if (max == null) {
return;
}
RSMSet rsmSet = new RSMSet(max);
mamQueryIQ.addExtension(rsmSet);
}
Aggregations