public MamQuery queryMostRecentPage(Jid jid, int max) throws NoResponseException, XMPPErrorException, NotConnectedException, NotLoggedInException, InterruptedException { MamQueryArgs mamQueryArgs = MamQueryArgs.builder() // Produces an empty <before/> element for XEP-0059 § 2.5 .queryLastPage() .limitResultsToJid(jid) .setResultPageSize(max) .build(); return queryArchive(mamQueryArgs); }
public MamPrefsResult setDefaultBehavior(DefaultBehavior desiredDefaultBehavior) throws NoResponseException, XMPPErrorException, NotConnectedException, NotLoggedInException, InterruptedException { MamPrefsResult mamPrefsResult = retrieveArchivingPreferences(); if (mamPrefsResult.mamPrefs.getDefault() == desiredDefaultBehavior) { return mamPrefsResult; } MamPrefs mamPrefs = mamPrefsResult.asMamPrefs(); mamPrefs.setDefaultBehavior(desiredDefaultBehavior); return updateArchivingPreferences(mamPrefs); }
public Builder withAdditionalFormFields(List<FormField> additionalFields) { for (FormField formField : additionalFields) { withAdditionalFormField(formField); } return this; }
@Test public void checkResultsLimit() throws Exception { DataForm dataForm = getNewMamForm(); MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId, dataForm); mamQueryIQ.setType(IQ.Type.set); mamQueryIQ.setStanzaId("sarasa"); MamQueryArgs mamQueryArgs = MamQueryArgs.builder().setResultPageSize(10).build(); mamQueryArgs.maybeAddRsmSet(mamQueryIQ); Assert.assertEquals(mamQueryIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), resultsLimitStanza); }
public MamQuery queryArchive(MamQueryArgs mamQueryArgs) throws NoResponseException, XMPPErrorException, NotConnectedException, NotLoggedInException, InterruptedException { String queryId = UUID.randomUUID().toString(); String node = mamQueryArgs.node; DataForm dataForm = mamQueryArgs.getDataForm(); MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId, node, dataForm); mamQueryIQ.setType(IQ.Type.set); mamQueryIQ.setTo(archiveAddress); mamQueryArgs.maybeAddRsmSet(mamQueryIQ); return queryArchive(mamQueryIQ); }
private MamQuery queryArchive(MamQueryIQ mamQueryIq) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotLoggedInException { MamQueryPage mamQueryPage = queryArchivePage(mamQueryIq); return new MamQuery(mamQueryPage, mamQueryIq.getNode(), DataForm.from(mamQueryIq)); }
public MamIntegrationTest(SmackIntegrationTestEnvironment environment) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, TestNotPossibleException, NotLoggedInException { super(environment); mamManagerConTwo = MamManager.getInstanceFor(conTwo); if (!mamManagerConTwo.isSupported()) { throw new TestNotPossibleException("Message Archive Management (XEP-0313) is not supported by the server."); } // Make sure MAM is archiving messages. mamManagerConTwo.enableMamForAllMessages(); }
@Override public void connectionCreated(XMPPConnection connection) { getInstanceFor(connection); } });
public List<Message> pagePrevious(int count) throws NoResponseException, XMPPErrorException, NotConnectedException, NotLoggedInException, InterruptedException { RSMSet previousResultRsmSet = getPreviousRsmSet(); RSMSet requestRsmSet = new RSMSet(count, previousResultRsmSet.getFirst(), RSMSet.PageDirection.before); return page(requestRsmSet); }
private MamPrefsResult queryMamPrefs(MamPrefsIQ mamPrefsIQ) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotLoggedInException { final XMPPConnection connection = getAuthenticatedConnectionOrThrow(); MamPrefsIQ mamPrefsResultIQ = connection.createStanzaCollectorAndSend(mamPrefsIQ).nextResultOrThrow(); return new MamPrefsResult(mamPrefsResultIQ, DataForm.from(mamPrefsIQ)); }
/** * Only return the count of messages the query yields, not the actual messages. Note that not all services * return a correct count, some return an approximate count. * * @return an reference to this builder. * @see <a href="https://xmpp.org/extensions/xep-0059.html#count">XEP-0059 § 2.7</a> */ public Builder onlyReturnMessageCount() { return setResultPageSizeTo(0); }
public MamPrefsResult enableMamForAllMessages() throws NoResponseException, XMPPErrorException, NotConnectedException, NotLoggedInException, InterruptedException { return setDefaultBehavior(DefaultBehavior.always); }
/** * Query from the last, i.e. most recent, page of the archive. This will return the very last page of the * archive holding the most recent matching messages. You usually would page backwards from there on. * * @return a reference to this builder. * @see <a href="https://xmpp.org/extensions/xep-0059.html#last">XEP-0059 § 2.5. Requesting the Last Page in * a Result Set</a> */ public Builder queryLastPage() { return beforeUid(""); }
public MamQueryArgs build() { return new MamQueryArgs(this); } }
public MamPrefs asMamPrefs() { return new MamPrefs(this); } }
/** * Get the form fields supported by the server. * * @return the list of form fields. * @throws NoResponseException * @throws XMPPErrorException * @throws NotConnectedException * @throws InterruptedException * @throws NotLoggedInException */ public List<FormField> retrieveFormFields() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotLoggedInException { return retrieveFormFields(null); }
public static Builder builder() { return new Builder(); }
/** * Get a MamManager for the MAM archive of the local entity (the "user") of the given connection. * * @param connection the XMPP connection to get the archive for. * @return the instance of MamManager. */ public static MamManager getInstanceFor(XMPPConnection connection) { return getInstanceFor(connection, (Jid) null); }
public Builder setResultPageSize(Integer max) { if (max == null) { maxResults = -1; return this; } return setResultPageSizeTo(max.intValue()); }
public MamPrefsResult enableMamForRosterMessages() throws NoResponseException, XMPPErrorException, NotConnectedException, NotLoggedInException, InterruptedException { return setDefaultBehavior(DefaultBehavior.roster); }