From c1192f18b4e4ad0761108e5cabb6442b33a15a8e Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 2 Jun 2015 23:58:50 +0200 Subject: [PATCH 1/6] Add support for vCard PREFIX and SUFFIX elements SMACK-673 --- .../smackx/vcardtemp/packet/VCard.java | 25 ++++++++++++++++++- .../vcardtemp/provider/VCardProvider.java | 6 +++++ .../smackx/vcardtemp/VCardTest.java | 4 +++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java index fd18638e4..1dffba285 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java @@ -107,6 +107,8 @@ public class VCard extends IQ { private String firstName; private String lastName; private String middleName; + private String prefix; + private String suffix; private String emailHome; private String emailWork; @@ -197,6 +199,24 @@ public class VCard extends IQ { updateFN(); } + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + updateFN(); + } + + public String getSuffix() { + return suffix; + } + + public void setSuffix(String suffix) { + this.suffix = suffix; + updateFN(); + } + public String getNickName() { return otherSimpleFields.get("NICKNAME"); } @@ -568,6 +588,8 @@ public class VCard extends IQ { xml.optElement("FAMILY", lastName); xml.optElement("GIVEN", firstName); xml.optElement("MIDDLE", middleName); + xml.optElement("PREFIX", prefix); + xml.optElement("SUFFIX", suffix); xml.closeElement("N"); } if (hasOrganizationFields()) { @@ -692,7 +714,8 @@ public class VCard extends IQ { } private boolean hasNameField() { - return firstName != null || lastName != null || middleName != null; + return firstName != null || lastName != null || middleName != null + || prefix != null || suffix != null; } private boolean hasOrganizationFields() { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/provider/VCardProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/provider/VCardProvider.java index 753805dd2..f4612fd19 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/provider/VCardProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/provider/VCardProvider.java @@ -284,6 +284,12 @@ public class VCardProvider extends IQProvider { case "MIDDLE": vCard.setMiddleName(parser.nextText()); break; + case "PREFIX": + vCard.setPrefix(parser.nextText()); + break; + case "SUFFIX": + vCard.setSuffix(parser.nextText()); + break; default: break; } diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/vcardtemp/VCardTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/vcardtemp/VCardTest.java index 419762896..1f29fd6cb 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/vcardtemp/VCardTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/vcardtemp/VCardTest.java @@ -48,6 +48,8 @@ public class VCardTest extends InitExtensions { + "Name" + "User" + "PJ" + + "Mr." + + "III" + "" + "User dude" + "http://www.igniterealtime.org" @@ -99,6 +101,8 @@ public class VCardTest extends InitExtensions { assertEquals("Name", vCard.getLastName()); assertEquals("PJ", vCard.getMiddleName()); assertEquals("User dude", vCard.getNickName()); + assertEquals("Mr.", vCard.getPrefix()); + assertEquals("III", vCard.getSuffix()); assertEquals("Programmer & tester", vCard.getField("TITLE")); assertEquals("Bug fixer", vCard.getField("ROLE")); From 4b0767ba9ad3aa607f348d4747888616cd2e8d5b Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 22 Jun 2015 22:49:36 +0200 Subject: [PATCH 2/6] Fix concurrency exception in ServerPingWithAlarmManager Fixes SMACK-676. --- .../android/ServerPingWithAlarmManager.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/smack-android-extensions/src/main/java/org/jivesoftware/smackx/ping/android/ServerPingWithAlarmManager.java b/smack-android-extensions/src/main/java/org/jivesoftware/smackx/ping/android/ServerPingWithAlarmManager.java index d203aa097..623c4c66e 100644 --- a/smack-android-extensions/src/main/java/org/jivesoftware/smackx/ping/android/ServerPingWithAlarmManager.java +++ b/smack-android-extensions/src/main/java/org/jivesoftware/smackx/ping/android/ServerPingWithAlarmManager.java @@ -17,8 +17,10 @@ package org.jivesoftware.smackx.ping.android; -import java.util.Iterator; +import java.util.HashSet; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; import java.util.WeakHashMap; import java.util.logging.Logger; @@ -111,10 +113,16 @@ public class ServerPingWithAlarmManager extends Manager { @Override public void onReceive(Context context, Intent intent) { LOGGER.fine("Ping Alarm broadcast received"); - Iterator it = INSTANCES.keySet().iterator(); - while (it.hasNext()) { - XMPPConnection connection = it.next(); - if (ServerPingWithAlarmManager.getInstanceFor(connection).isEnabled()) { + Set> managers; + synchronized (ServerPingWithAlarmManager.class) { + // Make a copy to avoid ConcurrentModificationException when + // iterating directly over INSTANCES and the Set is modified + // concurrently by creating a new ServerPingWithAlarmManager. + managers = new HashSet<>(INSTANCES.entrySet()); + } + for (Entry entry : managers) { + XMPPConnection connection = entry.getKey(); + if (entry.getValue().isEnabled()) { LOGGER.fine("Calling pingServerIfNecessary for connection " + connection.getConnectionCounter()); final PingManager pingManager = PingManager.getInstanceFor(connection); From d54dafc499403435f23712830cc5a7501d0fd3e1 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 25 Jun 2015 11:07:25 +0200 Subject: [PATCH 3/6] Don't return if securityMode is 'disabled' in afterFeaturesReceived. As this will cause maybeCompressFeaturesReceived.reportSuccess() never to be called if the server announces 'starttls' but security mode is set to 'disabled' and if 'compression' is also announced. Fixes SMACK-678. --- .../java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 64de91db5..afa817fc3 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 @@ -884,11 +884,9 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { return; } - if (config.getSecurityMode() == ConnectionConfiguration.SecurityMode.disabled) { - // Do not secure the connection using TLS since TLS was disabled - return; + if (config.getSecurityMode() != ConnectionConfiguration.SecurityMode.disabled) { + send(new StartTls()); } - send(new StartTls()); } // If TLS is required but the server doesn't offer it, disconnect // from the server and throw an error. First check if we've already negotiated TLS From a997283304a40bc8247c4375d8a7a616b712bde6 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 26 Jun 2015 14:04:46 +0200 Subject: [PATCH 4/6] Make AbstractXMPPConnection.getConfiguration public --- .../org/jivesoftware/smack/AbstractXMPPConnection.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 f8cb376cf..d7c79c6c7 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -300,7 +300,12 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { config = configuration; } - protected ConnectionConfiguration getConfiguration() { + /** + * Get the connection configuration used by this connection. + * + * @return the connection configuration. + */ + public ConnectionConfiguration getConfiguration() { return config; } From 65788389ea9c3e7e7fd2d96b9bb74df31be2a430 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sat, 27 Jun 2015 14:25:19 +0200 Subject: [PATCH 5/6] Reset ReconnectionManager's 'attempts' to 0 on successful reconnects. Fixes SMACK-668. --- .../org/jivesoftware/smack/ReconnectionManager.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 a38cd1715..f14362736 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java @@ -20,6 +20,7 @@ import org.jivesoftware.smack.XMPPException.StreamErrorException; import org.jivesoftware.smack.packet.StreamError; import org.jivesoftware.smack.util.Async; +import java.io.IOException; import java.lang.ref.WeakReference; import java.util.Map; import java.util.Random; @@ -239,8 +240,17 @@ public class ReconnectionManager { if (isReconnectionPossible(connection)) { connection.connect(); } + // TODO Starting with Smack 4.2, connect() will no + // longer login automatically. So change this and the + // previous lines to connection.connect().login() in the + // 4.2, or any later, branch. + if (!connection.isAuthenticated()) { + connection.login(); + } + // Successfully reconnected. + attempts = 0; } - catch (Exception e) { + catch (SmackException | IOException | XMPPException e) { // Fires the failed reconnection notification for (ConnectionListener listener : connection.connectionListeners) { listener.reconnectionFailed(e); From 54719a43e2d5274e6c6f0eeb0f01c09a5df998b1 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sat, 27 Jun 2015 14:33:14 +0200 Subject: [PATCH 6/6] Smack 4.1.2 --- resources/releasedocs/changelog.html | 31 ++++++++++++++++++++++++++++ version.gradle | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/resources/releasedocs/changelog.html b/resources/releasedocs/changelog.html index 974abf4ab..7a805d5f5 100644 --- a/resources/releasedocs/changelog.html +++ b/resources/releasedocs/changelog.html @@ -141,6 +141,37 @@ hr {
+

4.1.2 -- 2015-06-27

+ +

Bug +

+
    +
  • [SMACK-664] - Invalid IQ error response to OfferRequestPacket and OfferRevokePacket +
  • +
  • [SMACK-668] - ReconnectionManager's value of 'attempts' is not reset after successful reconnection +
  • +
  • [SMACK-669] - Only add Entity Capabilities extension to available presences +
  • +
  • [SMACK-670] - SASLMechanism.authenticate should treat an empty byte array like 'null' byte array +
  • +
  • [SMACK-672] - Memory leak caused by RosterGroup declaring a strong reference to XMPPConnection +
  • +
  • [SMACK-673] - VCard API does not support all elements +
  • +
  • [SMACK-676] - ConcurrentModificationException in ServerPingWithAlarmManager +
  • +
  • [SMACK-678] - Login hangs if starttls advertised, but security is set to 'disabled' and compression is also advertised +
  • +
+ +

Improvement +

+
    +
  • [SMACK-667] - Request Stream Mangement Acknowledgement after re-sending unack'ed stanzas after stream resumption +
  • +
  • [SMACK-671] - Don't disable Scoks5BytestreamManager on connection termination +
  • +

4.1.1 -- 2015-05-09

diff --git a/version.gradle b/version.gradle index 184deec47..123c48fe5 100644 --- a/version.gradle +++ b/version.gradle @@ -1,7 +1,7 @@ allprojects { ext { shortVersion = '4.1.2' - isSnapshot = true + isSnapshot = false jxmppVersion = '0.4.2-beta1' smackMinAndroidSdk = 8 }