1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 18:48:00 +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) {
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<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<ExtensionElement> packetExtensions = sdm.getExtendedInfoAsList();
@Override