Skip to content

Commit

Permalink
Merge branch 'master' into ramabit.tbr.opt2
Browse files Browse the repository at this point in the history
  • Loading branch information
ramabit committed Aug 3, 2016
2 parents 0d9ede2 + f1e24e2 commit df79818
Show file tree
Hide file tree
Showing 44 changed files with 2,898 additions and 36 deletions.
1 change: 1 addition & 0 deletions documentation/extensions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,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](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
Expand Down
192 changes: 192 additions & 0 deletions documentation/extensions/mam.md
Original file line number Diff line number Diff line change
@@ -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`

28 changes: 18 additions & 10 deletions resources/releasedocs/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,28 @@ <h1>Smack Readme</h1>

<p>
Thank you for downloading Smack! This version of Smack is compatible
with JVMs @targetCompatibility@ or higher. If you dont' use a
with JVMs @targetCompatibility@ or higher. Using a build system which
is able to consume Maven artifacts, like gradle or Maven, is highly
recommended when using Smack.
</p>

<p>
<b>This is not the real README.</b> Please visit
<center>
<a href="https://www.igniterealtime.org/projects/smack/readme">https://www.igniterealtime.org/projects/smack/readme</a>
</center>
for the README of the current stable Smack version.
</p>

<p>
If you dont' use a
dependency resolution system, like gradle or maven, then you will need
to download at least
the <a href="http://www.extreme.indiana.edu/xgws/xsoap/xpp/mxp1/">Xml
Pull Parser 3rd Edition (XPP3) library</a> or any other library that
implements the XmlPullParser interface
(like <a href="http://kxml.org/">kXML</a>).
(like <a href="http://kxml.org/">kXML</a>) and the set of
<a href="http://jxmpp.org">jXMPP libraries</a>.
</p>

<p>
Expand All @@ -174,21 +189,14 @@ <h1>Smack Readme</h1>
<a href="https://community.igniterealtime.org">online forum</a>.
</p>

<p><b>About the Distribution</b></p>

The <tt>smack-core.jar</tt> file in the main distribution folder. The optional
<tt>smack-extensions.jar</tt> contains the <a href="documentation/extensions/index.html">Smack extensions</a>
while <tt>smack-debug.jar</tt> contains an enhanced debugger.<p>

<p><b>Changelog and Upgrading</b><p>

View the <a href="changelog.html">changelog</a> for a list of changes since the
last release.
If you are upgrading from Smack 3 to Smack 4, then please consult the <a href="https://community.igniterealtime.org/docs/DOC-2703">Smack 4 Readme and Upgrade Guide</a>

<p><b>License Agreements</b><p>
<ul>
<li>Use of the Smack source code is governed by the Apache License:
<li>Use of the Smack source code is governed by the Apache License Version 2.0:
<pre>
Copyright 2002-2008 Jive Software.

Expand Down
15 changes: 15 additions & 0 deletions resources/releasedocs/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@ <h1>Smack Changelog</h1>

<div id="pageBody">

<h2>4.1.8 -- <span style="font-weight: normal;">2016-07-30</span></h2>

<h2> Bug
</h2>
<ul>
<li>[<a href='https://issues.igniterealtime.org/browse/SMACK-722'>SMACK-722</a>] - SASL X-OAUTH2 implementation incorrectly performs Base64 encoding twice
</li>
<li>[<a href='https://issues.igniterealtime.org/browse/SMACK-724'>SMACK-724</a>] - Do not re-use the Socket after connect() failed.
</li>
<li>[<a href='https://issues.igniterealtime.org/browse/SMACK-725'>SMACK-725</a>] - ReconnectionManager should handle AlreadyConnectedException and AlreadyLoggedInException not as failure
</li>
<li>[<a href='https://issues.igniterealtime.org/browse/SMACK-726'>SMACK-726</a>] - &#39;purge&#39; and &#39;remove&#39; IQ of XEP-0013 must be of type &#39;set&#39;
</li>
</ul>

<h2>4.1.7 -- <span style="font-weight: normal;">2016-04-14</span></h2>

<h2> Bug
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.jivesoftware.smack.util.TypedCloneable;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jxmpp.jid.Jid;
import org.jxmpp.jid.impl.JidCreate;
import org.jxmpp.stringprep.XmppStringprepException;

/**
* Represents XMPP message packets. A message can be one of several types:
Expand Down Expand Up @@ -101,6 +103,17 @@ public Message(Jid to, String body) {
setBody(body);
}

/**
* Creates a new message to the specified recipient and with the specified body.
*
* @param to the user to send the message to.
* @param body the body of the message.
* @throws XmppStringprepException if 'to' is not a valid XMPP address.
*/
public Message(String to, String body) throws XmppStringprepException {
this(JidCreate.from(to), body);
}

/**
* Copy constructor.
* <p>
Expand Down
13 changes: 13 additions & 0 deletions smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,19 @@ public boolean hasStanzaIdSet() {
return id != null;
}

/**
* Set the stanza id if none is set.
*
* @return the stanza id.
* @since 4.2
*/
public String setStanzaId() {
if (!hasStanzaIdSet()) {
setStanzaId(StanzaIdUtil.newStanzaId());
}
return getStanzaId();
}

/**
* Returns who the stanza(/packet) is being sent "to", or <tt>null</tt> if
* the value is not set. The XMPP protocol often makes the "to"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.iot.Thing;
Expand Down Expand Up @@ -202,7 +203,7 @@ public IQ handleIQRequest(IQ iqRequest) {
/**
* Try to find an XMPP IoT registry.
*
* @return the JID of a Thing Registry if one could be found.
* @return the JID of a Thing Registry if one could be found, <code>null</code> otherwise.
* @throws InterruptedException
* @throws NotConnectedException
* @throws XMPPErrorException
Expand Down Expand Up @@ -373,9 +374,11 @@ public void disownThing(Jid registry, Jid thing, NodeInfo nodeInfo)
// Registry utility methods

public boolean isRegistry(BareJid jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Objects.requireNonNull(jid, "JID argument must not be null");
// At some point 'usedRegistries' will also contain the registry returned by findRegistry(), but since this is
// not the case from the beginning, we perform findRegistry().equals(jid) too.
if (findRegistry().equals(jid)) {
Jid registry = findRegistry();
if (jid.equals(registry)) {
return true;
}
if (usedRegistries.contains(jid)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public IQ handleIQRequest(IQ iqRequest) {
});

roster = Roster.getInstanceFor(connection);
roster.setSubscribeListener(new SubscribeListener() {
roster.addSubscribeListener(new SubscribeListener() {
@Override
public SubscribeAnswer processSubscribe(Jid from, Presence subscribeRequest) {
// First check if the subscription request comes from a known registry and accept the request if so.
Expand Down
Loading

0 comments on commit df79818

Please sign in to comment.