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