do not attempt resume when already in smacks session
This commit is contained in:
parent
052c58f377
commit
e0bd1d168c
|
@ -1,30 +1,31 @@
|
||||||
package eu.siacs.conversations.utils;
|
package eu.siacs.conversations.utils;
|
||||||
|
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
|
|
||||||
public class XmlHelper {
|
public class XmlHelper {
|
||||||
public static String encodeEntities(String content) {
|
public static String encodeEntities(String content) {
|
||||||
content = content.replace("&", "&");
|
content = content.replace("&", "&");
|
||||||
content = content.replace("<", "<");
|
content = content.replace("<", "<");
|
||||||
content = content.replace(">", ">");
|
content = content.replace(">", ">");
|
||||||
content = content.replace("\"", """);
|
content = content.replace("\"", """);
|
||||||
content = content.replace("'", "'");
|
content = content.replace("'", "'");
|
||||||
content = content.replaceAll("[\\p{Cntrl}&&[^\n\t\r]]", "");
|
content = content.replaceAll("[\\p{Cntrl}&&[^\n\t\r]]", "");
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String printElementNames(final Element element) {
|
public static String printElementNames(final Element element) {
|
||||||
final StringBuilder builder = new StringBuilder();
|
final List<String> features =
|
||||||
builder.append('[');
|
element == null
|
||||||
if (element != null) {
|
? Collections.emptyList()
|
||||||
for (Element child : element.getChildren()) {
|
: Lists.transform(
|
||||||
if (builder.length() != 1) {
|
element.getChildren(),
|
||||||
builder.append(',');
|
child -> child != null ? child.getName() : null);
|
||||||
}
|
return Joiner.on(", ").join(features);
|
||||||
builder.append(child.getName());
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
builder.append(']');
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -817,7 +817,7 @@ public class XmppConnection implements Runnable {
|
||||||
this.stanzasReceived = 0;
|
this.stanzasReceived = 0;
|
||||||
this.inSmacksSession = true;
|
this.inSmacksSession = true;
|
||||||
final RequestPacket r = new RequestPacket();
|
final RequestPacket r = new RequestPacket();
|
||||||
// tagWriter.writeStanzaAsync(r);
|
tagWriter.writeStanzaAsync(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processResumed(final Element resumed) throws StateChangingException {
|
private void processResumed(final Element resumed) throws StateChangingException {
|
||||||
|
@ -1180,7 +1180,8 @@ public class XmppConnection implements Runnable {
|
||||||
&& isSecure) {
|
&& isSecure) {
|
||||||
authenticate(SaslMechanism.Version.SASL);
|
authenticate(SaslMechanism.Version.SASL);
|
||||||
} else if (this.streamFeatures.hasChild("sm", Namespace.STREAM_MANAGEMENT)
|
} else if (this.streamFeatures.hasChild("sm", Namespace.STREAM_MANAGEMENT)
|
||||||
&& streamId != null) {
|
&& streamId != null
|
||||||
|
&& !inSmacksSession) {
|
||||||
if (Config.EXTENDED_SM_LOGGING) {
|
if (Config.EXTENDED_SM_LOGGING) {
|
||||||
Log.d(
|
Log.d(
|
||||||
Config.LOGTAG,
|
Config.LOGTAG,
|
||||||
|
@ -1208,7 +1209,7 @@ public class XmppConnection implements Runnable {
|
||||||
Config.LOGTAG,
|
Config.LOGTAG,
|
||||||
account.getJid().asBareJid()
|
account.getJid().asBareJid()
|
||||||
+ ": received NOP stream features "
|
+ ": received NOP stream features "
|
||||||
+ this.streamFeatures);
|
+ XmlHelper.printElementNames(this.streamFeatures));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1295,7 +1296,6 @@ public class XmppConnection implements Runnable {
|
||||||
+ "/"
|
+ "/"
|
||||||
+ saslMechanism.getMechanism());
|
+ saslMechanism.getMechanism());
|
||||||
authenticate.setAttribute("mechanism", saslMechanism.getMechanism());
|
authenticate.setAttribute("mechanism", saslMechanism.getMechanism());
|
||||||
Log.d(Config.LOGTAG, "authenticate " + authenticate);
|
|
||||||
tagWriter.writeElement(authenticate);
|
tagWriter.writeElement(authenticate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1310,7 +1310,7 @@ public class XmppConnection implements Runnable {
|
||||||
features.addChild("enable", Namespace.CARBONS);
|
features.addChild("enable", Namespace.CARBONS);
|
||||||
}
|
}
|
||||||
if (bindFeatures.contains(Namespace.STREAM_MANAGEMENT)) {
|
if (bindFeatures.contains(Namespace.STREAM_MANAGEMENT)) {
|
||||||
features.addChild("enable", Namespace.STREAM_MANAGEMENT);
|
features.addChild(new EnablePacket());
|
||||||
}
|
}
|
||||||
return bind;
|
return bind;
|
||||||
}
|
}
|
||||||
|
@ -2365,8 +2365,8 @@ public class XmppConnection implements Runnable {
|
||||||
|
|
||||||
private boolean hasDiscoFeature(final Jid server, final String feature) {
|
private boolean hasDiscoFeature(final Jid server, final String feature) {
|
||||||
synchronized (XmppConnection.this.disco) {
|
synchronized (XmppConnection.this.disco) {
|
||||||
return connection.disco.containsKey(server)
|
final ServiceDiscoveryResult sdr = connection.disco.get(server);
|
||||||
&& connection.disco.get(server).getFeatures().contains(feature);
|
return sdr != null && sdr.getFeatures().contains(feature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue