Smack 4.1.1

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQF8BAABCgBmBQJVTgmuXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
 ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQxMzU3QjAxODY1QjI1MDNDMTg0NTNEMjA4
 Q0FDMkE5Njc4NTQ4RTM1AAoJEIysKpZ4VI41MXUH/3A5Jc6rzALhnXMT4yj+jXow
 rLLX5/ypOvkAXEMRlTf9xd2apz4hT8dMsBcL3JvZscuVmkw0/woh9eV/PFSDoc7t
 HA7bMZRqWqUuVOezFD0ggHsJ7zfpcIuxsgoNARQlCRMPHzCLzKhMNctz5UApAdfy
 +wPpTMpc3K5SM1bNlM60qp+dbPCqQcLwYP02KrOQASgenVDm6iKFpzx0ieVpPY1M
 hOBMyaZg3n2j+267gpqBG6c7PVmEq3deAlB6BOBAsL/Bp1w5B5Smq959LWJLstrU
 /LeYJFi1TeIASiFy1vZyTV0Tw+Pe++3gB6ppLqkQhfWV8vXzm0coCXx29qWxAzM=
 =pGJt
 -----END PGP SIGNATURE-----

Merge tag '4.1.1'

Smack 4.1.1

Conflicts:
	smack-extensions/src/main/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProvider.java
	smack-im/src/main/java/org/jivesoftware/smack/roster/RosterEntry.java
	smack-java7/src/main/java/org/jivesoftware/smack/java7/Java7SmackInitializer.java
	version.gradle
This commit is contained in:
Florian Schmaus 2015-05-09 15:31:47 +02:00
commit bbc7aaae77
9 changed files with 112 additions and 15 deletions

View File

@ -141,6 +141,32 @@ hr {
<div id="pageBody">
<h2>4.1.1 -- <span style="font-weight: normal;">2015-05-09</span></h2>
<h2> Bug
</h2>
<ul>
<li>[<a href='https://igniterealtime.org/issues/browse/SMACK-649'>SMACK-649</a>] - DIGEST-MD5 challenge/response parsing must handle linear white spaces after the comma
</li>
<li>[<a href='https://igniterealtime.org/issues/browse/SMACK-652'>SMACK-652</a>] - SynchronizationPoint should use signalAll
</li>
<li>[<a href='https://igniterealtime.org/issues/browse/SMACK-653'>SMACK-653</a>] - Integer overflow if both client and server don&#39;t specify a max resumption time
</li>
<li>[<a href='https://igniterealtime.org/issues/browse/SMACK-654'>SMACK-654</a>] - isSmResumptionPossible() returns wrong values
</li>
<li>[<a href='https://igniterealtime.org/issues/browse/SMACK-656'>SMACK-656</a>] - DeliveryReceipts auto add should use packet interceptors and should not be requested for messages with ACKs.
</li>
<li>[<a href='https://igniterealtime.org/issues/browse/SMACK-659'>SMACK-659</a>] - Memory leak caused by RosterEntry declaring a strong reference to XMPPConnection
</li>
<li>[<a href='https://igniterealtime.org/issues/browse/SMACK-660'>SMACK-660</a>] - ReconnectionManager&#39;s RANDOM_INCREASING_DELAY is erroneously using a fixed value.
</li>
<li>[<a href='https://igniterealtime.org/issues/browse/SMACK-661'>SMACK-661</a>] - Add method to set ProxyInfo in ConnectionConfiguration.Builder
</li>
<li>[<a href='https://igniterealtime.org/issues/browse/SMACK-662'>SMACK-662</a>] - RosterEntry.setName() does not change the name
</li>
</ul>
<h2>4.1.0 -- <span style="font-weight: normal;">2015-03-29</span></h2>
<h2> Sub-task

View File

@ -684,6 +684,17 @@ public abstract class ConnectionConfiguration {
return getThis();
}
/**
* Set the information about the Proxy used for the connection.
*
* @param proxyInfo the Proxy information.
* @return a reference to this builder.
*/
public B setProxyInfo(ProxyInfo proxyInfo) {
this.proxy = proxyInfo;
return getThis();
}
/**
* Allow <code>null</code> or the empty String as username.
*

View File

@ -186,10 +186,12 @@ public final class ReconnectionManager {
if (attempts > 13) {
delay = randomBase * 6 * 5; // between 2.5 and 7.5 minutes (~5 minutes)
}
if (attempts > 7) {
else if (attempts > 7) {
delay = randomBase * 6; // between 30 and 90 seconds (~1 minutes)
}
delay = randomBase; // 10 seconds
else {
delay = randomBase; // 10 seconds
}
break;
default:
throw new AssertionError("Unknown reconnection policy " + reconnectionPolicy);

View File

@ -572,7 +572,9 @@ public class PacketParserUtils {
try {
PacketParserUtils.addExtensionElement(presence, parser, elementName, namespace);
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Failed to parse extension packet in Presence packet.", e);
LOGGER.log(Level.WARNING,
"Failed to parse extension packet in Presence packet. Attributes: from="
+ presence.getFrom() + " id=" + presence.getStanzaId(), e);
}
break;
}

View File

@ -0,0 +1,28 @@
/**
*
* Copyright 2015 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smack.util;
public class SystemUtil {
public static final String PROPERTY_JAVA_VENDOR = "java.vendor";
public static boolean onAndroid() {
String vendor = System.getProperty(PROPERTY_JAVA_VENDOR);
return vendor.contains("Android");
}
}

View File

@ -51,7 +51,8 @@ public class CapsExtensionProvider extends ExtensionElementProvider<CapsExtensio
if (hash != null && version != null && node != null) {
return new CapsExtension(node, version, hash);
} else {
throw new SmackException("Caps element with missing attributes");
throw new SmackException("Caps elment with missing attributes. Attributes: hash=" + hash + " version="
+ version + " node=" + node);
}
}

View File

@ -31,6 +31,7 @@ import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.MessageTypeFilter;
import org.jivesoftware.smack.filter.NotFilter;
import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
import org.jivesoftware.smack.filter.StanzaTypeFilter;
@ -234,6 +235,16 @@ public final class DeliveryReceiptManager extends Manager {
receiptReceivedListeners.remove(listener);
}
/**
* A filter for stanzas to request delivery receipts for. Notably those are message stanzas of type normal, chat or
* headline, which <b>do not</b>contain a delivery receipt, i.e. are ack messages.
*
* @see <a href="http://xmpp.org/extensions/xep-0184.html#when-ack">XEP-184 § 5.4 Ack Messages</a>
*/
private static final StanzaFilter MESSAGES_TO_REQUEST_RECEIPTS_FOR = new AndFilter(
MessageTypeFilter.NORMAL_OR_CHAT_OR_HEADLINE, new NotFilter(new StanzaExtensionFilter(
DeliveryReceipt.ELEMENT, DeliveryReceipt.NAMESPACE)));
private static final StanzaListener AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER = new StanzaListener() {
@Override
public void processPacket(Stanza packet) throws NotConnectedException {
@ -249,8 +260,8 @@ public final class DeliveryReceiptManager extends Manager {
* @see #dontAutoAddDeliveryReceiptRequests()
*/
public void autoAddDeliveryReceiptRequests() {
connection().addPacketSendingListener(AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER,
MessageTypeFilter.NORMAL_OR_CHAT_OR_HEADLINE);
connection().addPacketInterceptor(AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER,
MESSAGES_TO_REQUEST_RECEIPTS_FOR);
}
/**
@ -260,7 +271,7 @@ public final class DeliveryReceiptManager extends Manager {
* @see #autoAddDeliveryReceiptRequests()
*/
public void dontAutoAddDeliveryReceiptRequests() {
connection().removePacketSendingListener(AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER);
connection().removePacketInterceptor(AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER);
}
/**

View File

@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.SmackException.NotConnectedException;
@ -37,7 +38,7 @@ import org.jxmpp.jid.Jid;
*
* @author Matt Tucker
*/
public class RosterEntry {
public final class RosterEntry extends Manager {
/**
* The JID of the entity/user.
@ -49,7 +50,6 @@ public class RosterEntry {
private RosterPacket.ItemStatus status;
private final boolean approved;
final private Roster roster;
final private XMPPConnection connection;
/**
* Creates a new roster entry.
@ -63,13 +63,13 @@ public class RosterEntry {
*/
RosterEntry(Jid user, String name, RosterPacket.ItemType type,
RosterPacket.ItemStatus status, boolean approved, Roster roster, XMPPConnection connection) {
super(connection);
this.user = user;
this.name = name;
this.type = type;
this.status = status;
this.approved = approved;
this.roster = roster;
this.connection = connection;
}
/**
@ -99,7 +99,7 @@ public class RosterEntry {
* @throws NoResponseException
* @throws InterruptedException
*/
public void setName(String name) throws NotConnectedException, NoResponseException, XMPPErrorException, InterruptedException {
public synchronized void setName(String name) throws NotConnectedException, NoResponseException, XMPPErrorException, InterruptedException {
// Do nothing if the name hasn't changed.
if (name != null && name.equals(this.name)) {
return;
@ -107,8 +107,11 @@ public class RosterEntry {
RosterPacket packet = new RosterPacket();
packet.setType(IQ.Type.set);
packet.addRosterItem(toRosterItem(this));
connection.createPacketCollectorAndSend(packet).nextResultOrThrow();
// Create a new roster item with the current RosterEntry and the *new* name. Note that we can't set the name of
// RosterEntry right away, as otherwise the updated event wont get fired, because equalsDeep would return true.
packet.addRosterItem(toRosterItem(this, name));
connection().createPacketCollectorAndSend(packet).nextResultOrThrow();
// We have received a result response to the IQ set, the name was successfully changed
this.name = name;
@ -262,7 +265,11 @@ public class RosterEntry {
}
static RosterPacket.Item toRosterItem(RosterEntry entry) {
RosterPacket.Item item = new RosterPacket.Item(entry.getUser(), entry.getName());
return toRosterItem(entry, entry.getName());
}
private static RosterPacket.Item toRosterItem(RosterEntry entry, String name) {
RosterPacket.Item item = new RosterPacket.Item(entry.getUser(), name);
item.setItemType(entry.getType());
item.setItemStatus(entry.getStatus());
item.setApproved(entry.isApproved());

View File

@ -1,6 +1,6 @@
/**
*
* Copyright 2014 the original author or authors
* Copyright 2014-2015 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,6 +22,7 @@ import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.initializer.SmackInitializer;
import org.jivesoftware.smack.util.DNSUtil;
import org.jivesoftware.smack.util.StringTransformer;
import org.jivesoftware.smack.util.SystemUtil;
import org.jivesoftware.smack.util.stringencoder.Base64;
import org.jivesoftware.smack.util.stringencoder.Base64UrlSafeEncoder;
import org.jivesoftware.smack.util.stringencoder.java7.Java7Base64Encoder;
@ -31,6 +32,14 @@ public class Java7SmackInitializer implements SmackInitializer {
@Override
public List<Exception> initialize() {
if (SystemUtil.onAndroid()) {
// @formatter:off
throw new RuntimeException(
"You need to remove the smack-java7 dependency/jar from your build, " +
"as it does not run on Android. " +
"Use smack-android instead.");
// @formatter:on
}
SmackConfiguration.setDefaultHostnameVerifier(new XmppHostnameVerifier());
Base64.setEncoder(Java7Base64Encoder.getInstance());
Base64UrlSafeEncoder.setEncoder(Java7Base64UrlSafeEncoder.getInstance());