1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 22:32:06 +01:00

EntityCapsManager must not use CapsVersionAndHash.toString()

as it would return Object.toString(). Instead the entity version string
was required. Use getLocalNodeVer() instead.
This commit is contained in:
Florian Schmaus 2015-03-24 11:22:59 +01:00
parent 451eb4c826
commit 130a8216d1

View file

@ -350,7 +350,7 @@ public class EntityCapsManager extends Manager {
public void processPacket(Stanza packet) { public void processPacket(Stanza packet) {
if (!entityCapsEnabled) if (!entityCapsEnabled)
return; return;
CapsVersionAndHash capsVersionAndHash = getCapsVersion(); CapsVersionAndHash capsVersionAndHash = getCapsVersionAndHash();
CapsExtension caps = new CapsExtension(entityNode, capsVersionAndHash.version, capsVersionAndHash.hash); CapsExtension caps = new CapsExtension(entityNode, capsVersionAndHash.version, capsVersionAndHash.hash);
packet.addExtension(caps); packet.addExtension(caps);
} }
@ -411,7 +411,7 @@ public class EntityCapsManager extends Manager {
* *
* @return our own caps version * @return our own caps version
*/ */
public CapsVersionAndHash getCapsVersion() { public CapsVersionAndHash getCapsVersionAndHash() {
return currentCapsVersion; return currentCapsVersion;
} }
@ -423,7 +423,11 @@ public class EntityCapsManager extends Manager {
* @return the local NodeVer * @return the local NodeVer
*/ */
public String getLocalNodeVer() { 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 discoverInfo = new DiscoverInfo();
discoverInfo.setType(IQ.Type.result); discoverInfo.setType(IQ.Type.result);
discoverInfo.setNode(getLocalNodeVer()); discoverInfo.setNode(getLocalNodeVer());
if (connection != null)
discoverInfo.setFrom(connection.getUser());
sdm.addDiscoverInfoTo(discoverInfo); sdm.addDiscoverInfoTo(discoverInfo);
currentCapsVersion = generateVerificationString(discoverInfo); currentCapsVersion = generateVerificationString(discoverInfo);
addDiscoverInfoByNode(entityNode + '#' + currentCapsVersion.version, discoverInfo); final String localNodeVer = getLocalNodeVer();
addDiscoverInfoByNode(localNodeVer, discoverInfo);
if (lastLocalCapsVersions.size() > 10) { if (lastLocalCapsVersions.size() > 10) {
CapsVersionAndHash oldCapsVersion = lastLocalCapsVersions.poll(); CapsVersionAndHash oldCapsVersion = lastLocalCapsVersions.poll();
sdm.removeNodeInformationProvider(entityNode + '#' + oldCapsVersion.version); 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)); JID_TO_NODEVER_CACHE.put(connection.getUser(), new NodeVerHash(entityNode, currentCapsVersion));
final List<Identity> identities = new LinkedList<Identity>(ServiceDiscoveryManager.getInstanceFor(connection).getIdentities()); final List<Identity> identities = new LinkedList<Identity>(ServiceDiscoveryManager.getInstanceFor(connection).getIdentities());
sdm.setNodeInformationProvider(entityNode + '#' + currentCapsVersion, new AbstractNodeInformationProvider() { sdm.setNodeInformationProvider(localNodeVer, new AbstractNodeInformationProvider() {
List<String> features = sdm.getFeatures(); List<String> features = sdm.getFeatures();
List<ExtensionElement> packetExtensions = sdm.getExtendedInfoAsList(); List<ExtensionElement> packetExtensions = sdm.getExtendedInfoAsList();
@Override @Override