1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 18:48:00 +01:00

Merge pull request #86 from esl/ramabit.mam.doc

Add MAM documentation
This commit is contained in:
Florian Schmaus 2016-07-30 11:14:38 +02:00 committed by GitHub
commit c74d16f68a
2 changed files with 193 additions and 1 deletions

View file

@ -85,7 +85,7 @@ Experimental Smack Extensions and currently supported XEPs of smack-experimental
| [Internet of Things - Discovery](iot.md) | [XEP-0347](http://xmpp.org/extensions/xep-0347.html) | Describes how Things can be installed and discovered by their owners. |
| Google GCM JSON payload | n/a | Semantically the same as XEP-0335: JSON Containers |
| Client State Indication | [XEP-0352](http://xmpp.org/extensions/xep-0352.html) | A way for the client to indicate its active/inactive state. |
| Message Archive Management | [XEP-0313](http://xmpp.org/extensions/xep-0313.html) | Query and control an archive of messages stored on a server. |
| [Message Archive Management](mam.md) | [XEP-0313](http://xmpp.org/extensions/xep-0313.html) | Query and control an archive of messages stored on a server. |
Legacy Smack Extensions and currently supported XEPs of smack-legacy

View file

@ -0,0 +1,192 @@
Message Archive Management
==========================
Query and control an archive of messages stored on a server.
* Check MAM support
* Query archive
* Paging
* Get form fields
* Get preferences
* Update preferences
**XEP related:** [XEP-0313](http://xmpp.org/extensions/xep-0313.html)
Get an instance of Message Archive Management Manager
-----------------------------------------------------
```
MamManager mamManager = MamManager.getInstanceFor(connection);
```
Check MAM support
-----------------
```
boolean isSupported = mamManager.isSupportedByServer();
```
Query archive
-------------
```
MamQueryResult mamQueryResult = mamManager.queryArchive(max);
```
*max* is an `Integer`
or
```
MamQueryResult mamQueryResult = mamManager.queryArchive(withJid);
```
*withJid* is a `Jid`
or
```
MamQueryResult mamQueryResult = mamManager.queryArchive(start, end);
```
*start* is a `Date`
*end* is a `Date`
or
```
MamQueryResult mamQueryResult = mamManager.queryArchive(additionalFields);
```
*additionalFields* is a `List<FormField>`
or
```
MamQueryResult mamQueryResult = mamManager.queryArchiveWithStartDate(start);
```
*start* is a `Date`
or
```
MamQueryResult mamQueryResult = mamManager.queryArchiveWithEndDate(end);
```
*end* is a `Date`
or
```
MamQueryResult mamQueryResult = mamManager.queryArchive(max, start, end, withJid, additionalFields);
```
*max* is an `Integer`
*start* is a `Date`
*end* is a `Date`
*withJid* is a `Jid`
*additionalFields* is a `List<FormField>`
**Get data from mamQueryResult object**
```
// Get forwarded messages
List<Forwarded> forwardedMessages = mamQueryResult.forwardedMessages;
// Get fin IQ
MamFinIQ mamFinIQ = mamQueryResult.mamFinIQ;
```
Paging
------
**Get a page**
```
MamQueryResult mamQueryResult = mamManager.page(dataForm, rsmSet);
```
*dataForm* is a `DataForm`
*rsmSet* is a `RSMSet`
**Get the next page**
```
MamQueryResult mamQueryResult = mamManager.pageNext(previousMamQueryResult, count);
```
*previousMamQueryResult* is a `MamQueryResult`
*count* is an `int`
**Get page before the first message saved (specific chat)**
```
MamQueryResult mamQueryResult = mamManager.pageBefore(chatJid, firstMessageId, max);
```
*chatJid* is a `Jid`
*firstMessageId* is a `String`
*max* is an `int`
**Get page after the last message saved (specific chat)**
```
MamQueryResult mamQueryResult = mamManager.pageAfter(chatJid, lastMessageId, max);
```
*chatJid* is a `Jid`
*lastMessageId* is a `String`
*max* is an `int`
Get form fields
---------------
```
List<FormField> formFields = mamManager.retrieveFormFields();
```
Get preferences
---------------
```
MamPrefsResult mamPrefsResult = mamManager.retrieveArchivingPreferences();
// Get preferences IQ
MamPrefsIQ mamPrefs = mamPrefsResult.mamPrefs;
// Obtain always and never list
List<Jid> alwaysJids = mamPrefs.getAlwaysJids();
List<Jid> neverJids = mamPrefs.getNeverJids();
// Obtain default behaviour (can be 'always', 'never' or 'roster')
DefaultBehavior defaultBehavior = mamPrefs.getDefault();
// Get the data form
DataForm dataForm = mamPrefs.form;
```
Update preferences
------------------
```
MamPrefsResult mamPrefsResult = mamManager.updateArchivingPreferences(alwaysJids, neverJids, defaultBehavior);
```
*alwaysJids* is a `List<Jid>`
*neverJids* is a `List<Jid>`
*defaultBehavior* is a `DefaultBehavior`