public final class MamManager
extends org.jivesoftware.smack.Manager
MamManager you need to obtain an instance for a particular archive.
To get the instance for the default archive on the user's server, use the getInstanceFor(XMPPConnection) method.
XMPPConnection connection = ...
MamManager mamManager = MamManager.getInstanceFor(connection);
If you want to retrieve a manager for a different archive use getInstanceFor(XMPPConnection, Jid), which takes the archive's XMPP address as second argument.
isSupported() to check if there is a MAM archive available.
boolean isSupported = mamManager.isSupported();
enableMamForAllMessages().
retrieveArchivingPreferences().
MamManager.MamPrefsResult.asMamPrefs() to get a modifiable MamManager.MamPrefs instance.
After performing the desired changes, use updateArchivingPreferences(MamPrefs) to update the preferences.
MamManager.MamQueryArgs instance, which can be build using MamManager.MamQueryArgs.Builder.
After you have build such an instance, use queryArchive(MamQueryArgs) to issue the query.
MamQueryArgs mamQueryArgs = MamQueryArgs.builder()
.limitResultsToJid(jid)
.setResultPageSizeTo(10)
.queryLastPage()
.build();
MamQuery mamQuery = mamManager.queryArchive(mamQueryArgs);
On success queryArchive(MamQueryArgs) returns a MamManager.MamQuery instance.
The instance will hold one page of the queries result set.
Use MamManager.MamQuery.getMessages() to retrieve the messages of the archive belonging to the page.
You can get the whole page including all metadata using MamManager.MamQuery.getPage().
MamManager.MamQuery.isComplete().
If this method returns false, then you may want to page through the archive.
MamManager.MamQuery provides convince methods to do so: MamManager.MamQuery.pageNext(int) and MamManager.MamQuery.pagePrevious(int).
MamQuery nextPageMamQuery = mamQuery.pageNext(10);
retrieveFormFields() to retrieve a list of the supported additional form fields by this archive.
Those fields can be used for further restrict a query.| Modifier and Type | Class and Description |
|---|---|
static class |
MamManager.MamPrefs |
static class |
MamManager.MamPrefsResult
MAM preferences result class.
|
class |
MamManager.MamQuery |
static class |
MamManager.MamQueryArgs |
static class |
MamManager.MamQueryPage |
| Modifier and Type | Method and Description |
|---|---|
MamManager.MamPrefsResult |
enableMamForAllMessages() |
MamManager.MamPrefsResult |
enableMamForRosterMessages() |
org.jivesoftware.smackx.commands.RemoteCommand |
getAdvancedConfigurationCommand() |
org.jxmpp.jid.Jid |
getArchiveAddress()
The the XMPP address of this MAM archive.
|
static MamManager |
getInstanceFor(org.jivesoftware.smackx.muc.MultiUserChat multiUserChat)
Get a MamManager for the MAM archive of the given
MultiUserChat. |
static MamManager |
getInstanceFor(org.jivesoftware.smack.XMPPConnection connection)
Get a MamManager for the MAM archive of the local entity (the "user") of the given connection.
|
static MamManager |
getInstanceFor(org.jivesoftware.smack.XMPPConnection connection,
org.jxmpp.jid.Jid archiveAddress) |
java.lang.String |
getMessageUidOfLatestMessage()
Lookup the archive's message ID of the latest message in the archive.
|
boolean |
isAdvancedConfigurationSupported() |
boolean |
isSupported()
Check if this MamManager's archive address supports MAM.
|
MamManager.MamQuery |
queryArchive(MamManager.MamQueryArgs mamQueryArgs) |
MamManager.MamQuery |
queryMostRecentPage(org.jxmpp.jid.Jid jid,
int max) |
MamManager.MamPrefsResult |
retrieveArchivingPreferences()
Get the preferences stored in the server.
|
java.util.List<org.jivesoftware.smackx.xdata.FormField> |
retrieveFormFields()
Get the form fields supported by the server.
|
java.util.List<org.jivesoftware.smackx.xdata.FormField> |
retrieveFormFields(java.lang.String node)
Get the form fields supported by the server.
|
MamManager.MamPrefsResult |
setDefaultBehavior(MamPrefsIQ.DefaultBehavior desiredDefaultBehavior) |
MamManager.MamPrefsResult |
updateArchivingPreferences(MamManager.MamPrefs mamPrefs)
Update the preferences in the server.
|
public static MamManager getInstanceFor(org.jivesoftware.smack.XMPPConnection connection)
connection - the XMPP connection to get the archive for.public static MamManager getInstanceFor(org.jivesoftware.smackx.muc.MultiUserChat multiUserChat)
MultiUserChat. Note that not all MUCs support MAM,
hence it is recommended to use isSupported() to check if MAM is supported by the MUC.multiUserChat - the MultiUserChat to retrieve the MamManager for.public static MamManager getInstanceFor(org.jivesoftware.smack.XMPPConnection connection, org.jxmpp.jid.Jid archiveAddress)
public org.jxmpp.jid.Jid getArchiveAddress()
null if this MamManager
handles the local entity's archive and if the connection has never been authenticated at least once.null.public MamManager.MamQuery queryArchive(MamManager.MamQueryArgs mamQueryArgs) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, org.jivesoftware.smack.SmackException.NotLoggedInException, java.lang.InterruptedException
org.jivesoftware.smack.SmackException.NoResponseExceptionorg.jivesoftware.smack.XMPPException.XMPPErrorExceptionorg.jivesoftware.smack.SmackException.NotConnectedExceptionorg.jivesoftware.smack.SmackException.NotLoggedInExceptionjava.lang.InterruptedExceptionpublic MamManager.MamQuery queryMostRecentPage(org.jxmpp.jid.Jid jid, int max) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, org.jivesoftware.smack.SmackException.NotLoggedInException, java.lang.InterruptedException
org.jivesoftware.smack.SmackException.NoResponseExceptionorg.jivesoftware.smack.XMPPException.XMPPErrorExceptionorg.jivesoftware.smack.SmackException.NotConnectedExceptionorg.jivesoftware.smack.SmackException.NotLoggedInExceptionjava.lang.InterruptedExceptionpublic java.util.List<org.jivesoftware.smackx.xdata.FormField> retrieveFormFields()
throws org.jivesoftware.smack.SmackException.NoResponseException,
org.jivesoftware.smack.XMPPException.XMPPErrorException,
org.jivesoftware.smack.SmackException.NotConnectedException,
java.lang.InterruptedException,
org.jivesoftware.smack.SmackException.NotLoggedInException
org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.java.lang.InterruptedException - if the calling thread was interrupted.org.jivesoftware.smack.SmackException.NotLoggedInException - if the XMPP connection is not authenticated.public java.util.List<org.jivesoftware.smackx.xdata.FormField> retrieveFormFields(java.lang.String node)
throws org.jivesoftware.smack.SmackException.NoResponseException,
org.jivesoftware.smack.XMPPException.XMPPErrorException,
org.jivesoftware.smack.SmackException.NotConnectedException,
java.lang.InterruptedException,
org.jivesoftware.smack.SmackException.NotLoggedInException
node - The PubSub node name, can be nullorg.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.java.lang.InterruptedException - if the calling thread was interrupted.org.jivesoftware.smack.SmackException.NotLoggedInException - if the XMPP connection is not authenticated.public boolean isSupported()
throws org.jivesoftware.smack.SmackException.NoResponseException,
org.jivesoftware.smack.XMPPException.XMPPErrorException,
org.jivesoftware.smack.SmackException.NotConnectedException,
java.lang.InterruptedException
falseotherwise.org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.java.lang.InterruptedException - if the calling thread was interrupted.public boolean isAdvancedConfigurationSupported()
throws java.lang.InterruptedException,
org.jivesoftware.smack.XMPPException,
org.jivesoftware.smack.SmackException
java.lang.InterruptedExceptionorg.jivesoftware.smack.XMPPExceptionorg.jivesoftware.smack.SmackExceptionpublic org.jivesoftware.smackx.commands.RemoteCommand getAdvancedConfigurationCommand()
throws java.lang.InterruptedException,
org.jivesoftware.smack.XMPPException,
org.jivesoftware.smack.SmackException
java.lang.InterruptedExceptionorg.jivesoftware.smack.XMPPExceptionorg.jivesoftware.smack.SmackExceptionpublic java.lang.String getMessageUidOfLatestMessage()
throws org.jivesoftware.smack.SmackException.NoResponseException,
org.jivesoftware.smack.XMPPException.XMPPErrorException,
org.jivesoftware.smack.SmackException.NotConnectedException,
org.jivesoftware.smack.SmackException.NotLoggedInException,
java.lang.InterruptedException
null if the archive is
empty.null.org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.org.jivesoftware.smack.SmackException.NotLoggedInException - if the XMPP connection is not authenticated.java.lang.InterruptedException - if the calling thread was interrupted.public MamManager.MamPrefsResult retrieveArchivingPreferences() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException, org.jivesoftware.smack.SmackException.NotLoggedInException
org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.java.lang.InterruptedException - if the calling thread was interrupted.org.jivesoftware.smack.SmackException.NotLoggedInException - if the XMPP connection is not authenticated.public MamManager.MamPrefsResult updateArchivingPreferences(MamManager.MamPrefs mamPrefs) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException, org.jivesoftware.smack.SmackException.NotLoggedInException
mamPrefs - the MAM preferences to set the archive toorg.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.java.lang.InterruptedException - if the calling thread was interrupted.org.jivesoftware.smack.SmackException.NotLoggedInException - if the XMPP connection is not authenticated.public MamManager.MamPrefsResult enableMamForAllMessages() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, org.jivesoftware.smack.SmackException.NotLoggedInException, java.lang.InterruptedException
org.jivesoftware.smack.SmackException.NoResponseExceptionorg.jivesoftware.smack.XMPPException.XMPPErrorExceptionorg.jivesoftware.smack.SmackException.NotConnectedExceptionorg.jivesoftware.smack.SmackException.NotLoggedInExceptionjava.lang.InterruptedExceptionpublic MamManager.MamPrefsResult enableMamForRosterMessages() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, org.jivesoftware.smack.SmackException.NotLoggedInException, java.lang.InterruptedException
org.jivesoftware.smack.SmackException.NoResponseExceptionorg.jivesoftware.smack.XMPPException.XMPPErrorExceptionorg.jivesoftware.smack.SmackException.NotConnectedExceptionorg.jivesoftware.smack.SmackException.NotLoggedInExceptionjava.lang.InterruptedExceptionpublic MamManager.MamPrefsResult setDefaultBehavior(MamPrefsIQ.DefaultBehavior desiredDefaultBehavior) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, org.jivesoftware.smack.SmackException.NotLoggedInException, java.lang.InterruptedException
org.jivesoftware.smack.SmackException.NoResponseExceptionorg.jivesoftware.smack.XMPPException.XMPPErrorExceptionorg.jivesoftware.smack.SmackException.NotConnectedExceptionorg.jivesoftware.smack.SmackException.NotLoggedInExceptionjava.lang.InterruptedException