diff --git a/resources/releasedocs/changelog.html b/resources/releasedocs/changelog.html index b78611f32..974abf4ab 100644 --- a/resources/releasedocs/changelog.html +++ b/resources/releasedocs/changelog.html @@ -141,6 +141,32 @@ hr {
+ +

4.1.1 -- 2015-05-09

+ +

Bug +

+ +

4.1.0 -- 2015-03-29

Sub-task diff --git a/smack-core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java b/smack-core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java index 4b91bc710..2341f380f 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java @@ -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 null or the empty String as username. * diff --git a/smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java b/smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java index 2ebcaff8c..833c92cd1 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java @@ -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); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java index fb2fa7118..3363a725f 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java @@ -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; } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/SystemUtil.java b/smack-core/src/main/java/org/jivesoftware/smack/util/SystemUtil.java new file mode 100644 index 000000000..a3cf17b12 --- /dev/null +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/SystemUtil.java @@ -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"); + } + +} diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProvider.java index cb48ed42c..e7efd791a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProvider.java @@ -51,7 +51,8 @@ public class CapsExtensionProvider extends ExtensionElementProviderXEP-184 ยง 5.4 Ack Messages + */ + 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); } /** diff --git a/smack-im/src/main/java/org/jivesoftware/smack/roster/RosterEntry.java b/smack-im/src/main/java/org/jivesoftware/smack/roster/RosterEntry.java index 5db749306..da5debe3b 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/roster/RosterEntry.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/roster/RosterEntry.java @@ -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()); diff --git a/smack-java7/src/main/java/org/jivesoftware/smack/java7/Java7SmackInitializer.java b/smack-java7/src/main/java/org/jivesoftware/smack/java7/Java7SmackInitializer.java index a61ffd7f6..a3add870c 100644 --- a/smack-java7/src/main/java/org/jivesoftware/smack/java7/Java7SmackInitializer.java +++ b/smack-java7/src/main/java/org/jivesoftware/smack/java7/Java7SmackInitializer.java @@ -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 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());