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

[disco/caps] Fix DiscoverInfo.asBuilder()

The method would not copy the extensions elements, which would lead to
a false calculation of the caps hash by EntityCapsManager.
This commit is contained in:
Florian Schmaus 2020-05-22 15:38:16 +02:00
parent 0db6406262
commit a137944e50
5 changed files with 16 additions and 8 deletions

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2019 Florian Schmaus * Copyright 2019-2020 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,6 +23,10 @@ public abstract class AbstractIqBuilder<IB extends AbstractIqBuilder<IB>> extend
protected IQ.Type type = IQ.Type.get; protected IQ.Type type = IQ.Type.get;
AbstractIqBuilder(IQ other, String stanzaId) {
super(other, stanzaId);
}
AbstractIqBuilder(AbstractIqBuilder<?> other) { AbstractIqBuilder(AbstractIqBuilder<?> other) {
super(other); super(other);
type = other.type; type = other.type;

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2019 Florian Schmaus * Copyright 2019-2020 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,6 +22,10 @@ import org.jivesoftware.smack.util.Objects;
public abstract class IqBuilder<IB extends IqBuilder<IB, I>, I extends IQ> public abstract class IqBuilder<IB extends IqBuilder<IB, I>, I extends IQ>
extends AbstractIqBuilder<IB> { extends AbstractIqBuilder<IB> {
protected IqBuilder(IQ other, String stanzaId) {
super(other, stanzaId);
}
protected IqBuilder(AbstractIqBuilder<?> other) { protected IqBuilder(AbstractIqBuilder<?> other) {
super(other); super(other);
} }

View file

@ -496,7 +496,7 @@ public final class EntityCapsManager extends Manager {
private void updateLocalEntityCaps(DiscoverInfo synthesizedDiscoveryInfo) { private void updateLocalEntityCaps(DiscoverInfo synthesizedDiscoveryInfo) {
XMPPConnection connection = connection(); XMPPConnection connection = connection();
DiscoverInfoBuilder discoverInfoBuilder = synthesizedDiscoveryInfo.asBuilder(); DiscoverInfoBuilder discoverInfoBuilder = synthesizedDiscoveryInfo.asBuilder("synthesized-disco-info-result");
// getLocalNodeVer() will return a result only after currentCapsVersion is set. Therefore // getLocalNodeVer() will return a result only after currentCapsVersion is set. Therefore
// set it first and then call getLocalNodeVer() // set it first and then call getLocalNodeVer()
currentCapsVersion = generateVerificationString(discoverInfoBuilder); currentCapsVersion = generateVerificationString(discoverInfoBuilder);

View file

@ -299,8 +299,8 @@ public class DiscoverInfo extends IQ implements DiscoverInfoView, TypedCloneable
return containsDuplicateFeatures; return containsDuplicateFeatures;
} }
public DiscoverInfoBuilder asBuilder() { public DiscoverInfoBuilder asBuilder(String stanzaId) {
return new DiscoverInfoBuilder(this); return new DiscoverInfoBuilder(this, stanzaId);
} }
// TODO: Deprecate in favor of asBuilder(). // TODO: Deprecate in favor of asBuilder().

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2019 Florian Schmaus * Copyright 2019-2020 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -48,8 +48,8 @@ public class DiscoverInfoBuilder extends IqBuilder<DiscoverInfoBuilder, Discover
super(stanzaId); super(stanzaId);
} }
public DiscoverInfoBuilder(DiscoverInfo discoverInfo) { public DiscoverInfoBuilder(DiscoverInfo discoverInfo, String stanzaId) {
super(discoverInfo.getStanzaId()); super(discoverInfo, stanzaId);
features.addAll(discoverInfo.getFeatures()); features.addAll(discoverInfo.getFeatures());
identities.addAll(discoverInfo.getIdentities()); identities.addAll(discoverInfo.getIdentities());
node = discoverInfo.getNode(); node = discoverInfo.getNode();