From 130a8216d156752e46d469e2d2b40ac8b415131b Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 24 Mar 2015 11:22:59 +0100 Subject: [PATCH] EntityCapsManager must not use CapsVersionAndHash.toString() as it would return Object.toString(). Instead the entity version string was required. Use getLocalNodeVer() instead. --- .../smackx/caps/EntityCapsManager.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java index dd5d55051..8afc94a16 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java @@ -350,7 +350,7 @@ public class EntityCapsManager extends Manager { public void processPacket(Stanza packet) { if (!entityCapsEnabled) return; - CapsVersionAndHash capsVersionAndHash = getCapsVersion(); + CapsVersionAndHash capsVersionAndHash = getCapsVersionAndHash(); CapsExtension caps = new CapsExtension(entityNode, capsVersionAndHash.version, capsVersionAndHash.hash); packet.addExtension(caps); } @@ -411,7 +411,7 @@ public class EntityCapsManager extends Manager { * * @return our own caps version */ - public CapsVersionAndHash getCapsVersion() { + public CapsVersionAndHash getCapsVersionAndHash() { return currentCapsVersion; } @@ -423,7 +423,11 @@ public class EntityCapsManager extends Manager { * @return the local NodeVer */ public String getLocalNodeVer() { - return entityNode + '#' + getCapsVersion(); + CapsVersionAndHash capsVersionAndHash = getCapsVersionAndHash(); + if (capsVersionAndHash == null) { + return null; + } + return entityNode + '#' + capsVersionAndHash.version; } /** @@ -464,12 +468,11 @@ public class EntityCapsManager extends Manager { DiscoverInfo discoverInfo = new DiscoverInfo(); discoverInfo.setType(IQ.Type.result); discoverInfo.setNode(getLocalNodeVer()); - if (connection != null) - discoverInfo.setFrom(connection.getUser()); sdm.addDiscoverInfoTo(discoverInfo); currentCapsVersion = generateVerificationString(discoverInfo); - addDiscoverInfoByNode(entityNode + '#' + currentCapsVersion.version, discoverInfo); + final String localNodeVer = getLocalNodeVer(); + addDiscoverInfoByNode(localNodeVer, discoverInfo); if (lastLocalCapsVersions.size() > 10) { CapsVersionAndHash oldCapsVersion = lastLocalCapsVersions.poll(); sdm.removeNodeInformationProvider(entityNode + '#' + oldCapsVersion.version); @@ -480,7 +483,7 @@ public class EntityCapsManager extends Manager { JID_TO_NODEVER_CACHE.put(connection.getUser(), new NodeVerHash(entityNode, currentCapsVersion)); final List identities = new LinkedList(ServiceDiscoveryManager.getInstanceFor(connection).getIdentities()); - sdm.setNodeInformationProvider(entityNode + '#' + currentCapsVersion, new AbstractNodeInformationProvider() { + sdm.setNodeInformationProvider(localNodeVer, new AbstractNodeInformationProvider() { List features = sdm.getFeatures(); List packetExtensions = sdm.getExtendedInfoAsList(); @Override