From 38b8016ab7df19e06e95c95486d6d70c48414077 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 15 Jul 2015 12:30:39 +0200 Subject: [PATCH 01/10] Smack 4.1.4-SNAPSHOT --- version.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.gradle b/version.gradle index 9ac4f3d96..60927f5ab 100644 --- a/version.gradle +++ b/version.gradle @@ -1,7 +1,7 @@ allprojects { ext { - shortVersion = '4.1.3' - isSnapshot = false + shortVersion = '4.1.4' + isSnapshot = true jxmppVersion = '0.4.2-beta1' smackMinAndroidSdk = 8 } From 9884eee85da99771071286787779fb5a0f7a7899 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 29 Jul 2015 08:20:46 +0200 Subject: [PATCH 02/10] Provide a hint in NotConnectedException that connect() needs to be called prior login(). SMACK-686 --- .../org/jivesoftware/smack/AbstractXMPPConnection.java | 8 ++++++-- .../main/java/org/jivesoftware/smack/SmackException.java | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index d7c79c6c7..7653da444 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -403,7 +403,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { */ public synchronized void login() throws XMPPException, SmackException, IOException { if (isAnonymous()) { - throwNotConnectedExceptionIfAppropriate(); + throwNotConnectedExceptionIfAppropriate("Did you call connect() before login()?"); throwAlreadyLoggedInExceptionIfAppropriate(); loginAnonymously(); } else { @@ -584,8 +584,12 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } protected void throwNotConnectedExceptionIfAppropriate() throws NotConnectedException { + throwNotConnectedExceptionIfAppropriate(null); + } + + protected void throwNotConnectedExceptionIfAppropriate(String optionalHint) throws NotConnectedException { if (!isConnected()) { - throw new NotConnectedException(); + throw new NotConnectedException(optionalHint); } } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/SmackException.java b/smack-core/src/main/java/org/jivesoftware/smack/SmackException.java index 1a2fd3f76..7187c6b0d 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/SmackException.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/SmackException.java @@ -1,6 +1,6 @@ /** * - * Copyright 2014 Florian Schmaus + * 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. @@ -152,7 +152,12 @@ public class SmackException extends Exception { private static final long serialVersionUID = 9197980400776001173L; public NotConnectedException() { - super("Client is not, or no longer, connected"); + this(null); + } + + public NotConnectedException(String optionalHint) { + super("Client is not, or no longer, connected." + + (optionalHint != null ? ' ' + optionalHint : "")); } } From 8db082e5ea0bafb98a12f57b5c004e8a726ac48a Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 29 Jul 2015 08:21:20 +0200 Subject: [PATCH 03/10] Bump jxmpp to 0.4.2 SMACK-687 --- version.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.gradle b/version.gradle index 60927f5ab..ad05ecab1 100644 --- a/version.gradle +++ b/version.gradle @@ -2,7 +2,7 @@ allprojects { ext { shortVersion = '4.1.4' isSnapshot = true - jxmppVersion = '0.4.2-beta1' + jxmppVersion = '0.4.2' smackMinAndroidSdk = 8 } } From 8c6e56b122a841986b2ecb3d71bff46ce42066dc Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 31 Jul 2015 13:27:03 +0200 Subject: [PATCH 04/10] Reset carbons state on clean disconnect and if session was not resumed. Fixes SMACK-688. --- .../smackx/carbons/CarbonManager.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java index 92e8134d3..28744f26e 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java @@ -19,6 +19,7 @@ package org.jivesoftware.smackx.carbons; import java.util.Map; import java.util.WeakHashMap; +import org.jivesoftware.smack.AbstractConnectionListener; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NotConnectedException; @@ -65,6 +66,22 @@ public class CarbonManager extends Manager { super(connection); ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection); sdm.addFeature(CarbonExtension.NAMESPACE); + connection.addConnectionListener(new AbstractConnectionListener() { + @Override + public void connectionClosed() { + // Reset the state if the connection was cleanly closed. Note that this is not strictly necessary, + // because we also reset in authenticated() if the stream got not resumed, but for maximum correctness, + // also reset here. + enabled_state = false; + } + @Override + public void authenticated(XMPPConnection connection, boolean resumed) { + if (!resumed) { + // Non-resumed XMPP sessions always start with disabled carbons + enabled_state = false; + } + } + }); } /** From 6b7f69b42f7f7d184b1a4aae7a39e9213adccffa Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 17 Aug 2015 12:34:24 +0200 Subject: [PATCH 05/10] Fix MUCs UserStatusListener use oldPresence instead of packet. This bug was introduced with e6aa2416e4e03efa909475aba381f4eceed43e8d. Fixes SMACK-693. --- .../main/java/org/jivesoftware/smackx/muc/MultiUserChat.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java index fd1b5f879..d1714ca6b 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java @@ -169,7 +169,7 @@ public class MultiUserChat { Presence oldPresence = occupantsMap.put(from, presence); if (oldPresence != null) { // Get the previous occupant's affiliation & role - MUCUser mucExtension = MUCUser.from(packet); + MUCUser mucExtension = MUCUser.from(oldPresence); MUCAffiliation oldAffiliation = mucExtension.getItem().getAffiliation(); MUCRole oldRole = mucExtension.getItem().getRole(); // Get the new occupant's affiliation & role From b1e4884fbbaebf12ec8448a9065bf5e73962b6f1 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 24 Aug 2015 09:32:28 +0200 Subject: [PATCH 06/10] Remove erroneous next() from AbstractJsonExtensionProvider Fixes SMACK-695. --- .../java/org/jivesoftware/smack/util/PacketParserUtils.java | 3 ++- .../smackx/json/provider/AbstractJsonExtensionProvider.java | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) 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 0dc960583..a2e965777 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 @@ -301,7 +301,8 @@ public class PacketParserUtils { } /** - * Returns the textual content of an element as String. + * Returns the textual content of an element as String. After this method returns the parser + * position will be END_TAG, following the established pull parser calling convention. *

* The parser must be positioned on a START_TAG of an element which MUST NOT contain Mixed * Content (as defined in XML 3.2.2), or else an XmlPullParserException will be thrown. diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/json/provider/AbstractJsonExtensionProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/json/provider/AbstractJsonExtensionProvider.java index 821557017..ab96a7d0b 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/json/provider/AbstractJsonExtensionProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/json/provider/AbstractJsonExtensionProvider.java @@ -1,6 +1,6 @@ /** * - * Copyright © 2014 Florian Schmaus + * 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. @@ -31,7 +31,6 @@ public abstract class AbstractJsonExtensionProvider extends ExtensionElementProv public AbstractJsonPacketExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { String json = PacketParserUtils.parseElementText(parser); - parser.next(); return from(json); } From 8aa3f94c9011a879bf6222b3517d4b713d94bb8d Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 26 Aug 2015 18:47:05 +0200 Subject: [PATCH 07/10] Drop stream state after stream error Fixes SMACK-696. --- .../smack/tcp/XMPPTCPConnection.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index afa817fc3..2cf635221 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -16,6 +16,7 @@ */ package org.jivesoftware.smack.tcp; +import org.jivesoftware.smack.AbstractConnectionListener; import org.jivesoftware.smack.AbstractXMPPConnection; import org.jivesoftware.smack.ConnectionConfiguration; import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; @@ -295,6 +296,14 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { public XMPPTCPConnection(XMPPTCPConnectionConfiguration config) { super(config); this.config = config; + addConnectionListener(new AbstractConnectionListener() { + @Override + public void connectionClosedOnError(Exception e) { + if (e instanceof XMPPException.StreamErrorException) { + dropSmState(); + } + } + }); } /** @@ -402,7 +411,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { // connection instance though). This is used in writePackets to decide if stanzas should // be added to the unacknowledged stanzas queue, because they have to be added right // after the 'enable' stream element has been sent. - unacknowledgedStanzas = null; + dropSmState(); } if (isSmAvailable() && useSm) { // Remove what is maybe left from previously stream managed sessions @@ -1707,6 +1716,17 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { } } + /** + * Drop the stream management state. Sets {@link #smSessionId} and + * {@link #unacknowledgedStanzas} to null. + */ + private void dropSmState() { + // clientHandledCount and serverHandledCount will be reset on and + // respective. No need to reset them here. + smSessionId = null; + unacknowledgedStanzas = null; + } + /** * Get the maximum resumption time in seconds after which a managed stream can be resumed. *

From aa832ec1f0a572ace856beecf7acfdfa4b3715a2 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 4 Sep 2015 11:22:52 +0200 Subject: [PATCH 08/10] Handle cases where no privacy lists are set. The is when no default or active list is, then don't perform a privacy list request where list name is 'null'. Fixes SMACK-697. --- .../smackx/privacy/PrivacyListManager.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java index 360671031..f0d7e7bb9 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java @@ -41,6 +41,7 @@ import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler; import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.Stanza; +import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.privacy.filter.SetActiveListFilter; import org.jivesoftware.smackx.privacy.filter.SetDefaultListFilter; @@ -267,7 +268,7 @@ public class PrivacyListManager extends Manager { } /** - * Answer the active privacy list. + * Answer the active privacy list. Returns null if there is no active list. * * @return the privacy list of the active list. * @throws XMPPErrorException @@ -277,6 +278,9 @@ public class PrivacyListManager extends Manager { public PrivacyList getActiveList() throws NoResponseException, XMPPErrorException, NotConnectedException { Privacy privacyAnswer = this.getPrivacyWithListNames(); String listName = privacyAnswer.getActiveName(); + if (StringUtils.isNullOrEmpty(listName)) { + return null; + } boolean isDefaultAndActive = listName != null && listName.equals(privacyAnswer.getDefaultName()); return new PrivacyList(true, isDefaultAndActive, listName, getPrivacyListItems(listName)); } @@ -298,7 +302,7 @@ public class PrivacyListManager extends Manager { } /** - * Answer the default privacy list. + * Answer the default privacy list. Returns null if there is no default list. * * @return the privacy list of the default list. * @throws XMPPErrorException @@ -308,7 +312,10 @@ public class PrivacyListManager extends Manager { public PrivacyList getDefaultList() throws NoResponseException, XMPPErrorException, NotConnectedException { Privacy privacyAnswer = this.getPrivacyWithListNames(); String listName = privacyAnswer.getDefaultName(); - boolean isDefaultAndActive = listName != null && listName.equals(privacyAnswer.getActiveName()); + if (StringUtils.isNullOrEmpty(listName)) { + return null; + } + boolean isDefaultAndActive = listName.equals(privacyAnswer.getActiveName()); return new PrivacyList(isDefaultAndActive, true, listName, getPrivacyListItems(listName)); } @@ -359,6 +366,7 @@ public class PrivacyListManager extends Manager { * @throws NotConnectedException */ private List getPrivacyListItems(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException { + assert StringUtils.isNotEmpty(listName); // The request of the list is an privacy message with an empty list Privacy request = new Privacy(); request.setPrivacyList(listName, new ArrayList()); @@ -379,6 +387,7 @@ public class PrivacyListManager extends Manager { * @throws NotConnectedException */ public PrivacyList getPrivacyList(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException { + listName = StringUtils.requireNotNullOrEmpty(listName, "List name must not be null"); return new PrivacyList(false, false, listName, getPrivacyListItems(listName)); } From 23b7626c18f9c2b1f1216ab4e709dcbbdf49ba57 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 7 Sep 2015 09:31:51 +0200 Subject: [PATCH 09/10] Suppress warning if roster isn't set to load automatically. --- .../src/main/java/org/jivesoftware/smack/roster/Roster.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java index dfaa3ea55..65db297df 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java @@ -1195,7 +1195,7 @@ public class Roster extends Manager { } } - if (!isLoaded()) { + if (!isLoaded() && rosterLoadedAtLogin) { LOGGER.warning("Roster not loaded while processing presence stanza"); } final XMPPConnection connection = connection(); From 86de237b2cdb08a94922b972becd0ed58738b5cd Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 14 Sep 2015 08:58:21 +0200 Subject: [PATCH 10/10] Smack 4.1.4 --- resources/releasedocs/changelog.html | 29 ++++++++++++++++++++++++++++ version.gradle | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/resources/releasedocs/changelog.html b/resources/releasedocs/changelog.html index 184c15f70..688d8bd6f 100644 --- a/resources/releasedocs/changelog.html +++ b/resources/releasedocs/changelog.html @@ -141,6 +141,35 @@ hr {

+ +

4.1.4 -- 2015-09-14

+ +

Bug +

+
    +
  • [SMACK-688] - Reset carbons state if session got not resumed or cleanly disconnected +
  • +
  • [SMACK-689] - PEPPubSub creates malformed XML +
  • +
  • [SMACK-693] - MultiUserChat's UserStatusListener is not getting triggered +
  • +
  • [SMACK-695] - JSON and GCM parser does an erroneous extra next() +
  • +
  • [SMACK-697] - PrivacyListManager should handle the case where not default and active list are currently set +
  • +
+ +

Improvement +

+
    +
  • [SMACK-686] - Provide a hint that connect() needs to be called prior login() in NotConnectedException +
  • +
  • [SMACK-687] - Update to jxmpp 0.4.2 +
  • +
  • [SMACK-696] - Drop stream state after stream error +
  • +
+

4.1.3 -- 2015-07-15

Bug diff --git a/version.gradle b/version.gradle index ad05ecab1..e9955e1e4 100644 --- a/version.gradle +++ b/version.gradle @@ -1,7 +1,7 @@ allprojects { ext { shortVersion = '4.1.4' - isSnapshot = true + isSnapshot = false jxmppVersion = '0.4.2' smackMinAndroidSdk = 8 }