Search in sources :

Example 1 with RSMSet

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());
}
Also used : RSMSet(org.jivesoftware.smackx.rsm.packet.RSMSet) IQ(org.jivesoftware.smack.packet.IQ) Test(org.junit.Test)

Example 2 with RSMSet

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);
}
Also used : MamFinIQProvider(org.jivesoftware.smackx.mam.provider.MamFinIQProvider) RSMSet(org.jivesoftware.smackx.rsm.packet.RSMSet) XmlPullParser(org.xmlpull.v1.XmlPullParser) MamFinIQ(org.jivesoftware.smackx.mam.element.MamFinIQ) Test(org.junit.Test)

Example 3 with RSMSet

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;
}
Also used : RSMSet(org.jivesoftware.smackx.rsm.packet.RSMSet) ExtensionElement(org.jivesoftware.smack.packet.ExtensionElement) LinkedList(java.util.LinkedList)

Example 4 with RSMSet

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);
}
Also used : RSMSet(org.jivesoftware.smackx.rsm.packet.RSMSet) DataForm(org.jivesoftware.smackx.xdata.packet.DataForm)

Example 5 with 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);
}
Also used : RSMSet(org.jivesoftware.smackx.rsm.packet.RSMSet)

Aggregations

RSMSet (org.jivesoftware.smackx.rsm.packet.RSMSet)11 DataForm (org.jivesoftware.smackx.xdata.packet.DataForm)3 Test (org.junit.Test)3 ExtensionElement (org.jivesoftware.smack.packet.ExtensionElement)2 MamFinIQ (org.jivesoftware.smackx.mam.element.MamFinIQ)2 LinkedList (java.util.LinkedList)1 IQ (org.jivesoftware.smack.packet.IQ)1 MamQueryIQ (org.jivesoftware.smackx.mam.element.MamQueryIQ)1 MamFinIQProvider (org.jivesoftware.smackx.mam.provider.MamFinIQProvider)1 XmlPullParser (org.xmlpull.v1.XmlPullParser)1