read new stream features directly after success

This commit is contained in:
Daniel Gultsch 2022-10-14 13:13:21 +02:00
parent 3d6c7bbf1c
commit 9a0c90f066

View file

@ -556,7 +556,7 @@ public class XmppConnection implements Runnable {
while (nextTag != null && !nextTag.isEnd("stream")) { while (nextTag != null && !nextTag.isEnd("stream")) {
if (nextTag.isStart("error")) { if (nextTag.isStart("error")) {
processStreamError(nextTag); processStreamError(nextTag);
} else if (nextTag.isStart("features")) { } else if (nextTag.isStart("features", Namespace.STREAMS)) {
processStreamFeatures(nextTag); processStreamFeatures(nextTag);
} else if (nextTag.isStart("proceed", Namespace.TLS)) { } else if (nextTag.isStart("proceed", Namespace.TLS)) {
switchOverToTls(); switchOverToTls();
@ -705,6 +705,22 @@ public class XmppConnection implements Runnable {
account.getJid().asBareJid().toString() + ": logged in (using " + version + ")"); account.getJid().asBareJid().toString() + ": logged in (using " + version + ")");
account.setPinnedMechanism(saslMechanism); account.setPinnedMechanism(saslMechanism);
if (version == SaslMechanism.Version.SASL_2) { if (version == SaslMechanism.Version.SASL_2) {
final Tag tag = tagReader.readTag();
if (tag != null && tag.isStart("features", Namespace.STREAMS)) {
this.streamFeatures = tagReader.readElement(tag);
Log.d(
Config.LOGTAG,
account.getJid().asBareJid()
+ ": processed NOP stream features after success "
+ XmlHelper.printElementNames(this.streamFeatures));
} else {
Log.d(
Config.LOGTAG,
account.getJid().asBareJid()
+ ": server did not send stream features after SASL2 success");
throw new StateChangingException(Account.State.INCOMPATIBLE_SERVER);
}
Log.d(Config.LOGTAG, "success: " + success);
final String authorizationIdentifier = final String authorizationIdentifier =
success.findChildContent("authorization-identifier"); success.findChildContent("authorization-identifier");
final Jid authorizationJid; final Jid authorizationJid;
@ -746,7 +762,13 @@ public class XmppConnection implements Runnable {
final Element bound = success.findChild("bound", Namespace.BIND2); final Element bound = success.findChild("bound", Namespace.BIND2);
final Element resumed = success.findChild("resumed", "urn:xmpp:sm:3"); final Element resumed = success.findChild("resumed", "urn:xmpp:sm:3");
final Element failed = success.findChild("failed", "urn:xmpp:sm:3"); final Element failed = success.findChild("failed", "urn:xmpp:sm:3");
// TODO check if resumed and bound exist and throw bind failure if (bound != null && resumed != null) {
Log.d(
Config.LOGTAG,
account.getJid().asBareJid()
+ ": server sent bound and resumed in SASL2 success");
throw new StateChangingException(Account.State.INCOMPATIBLE_SERVER);
}
if (resumed != null && streamId != null) { if (resumed != null && streamId != null) {
processResumed(resumed); processResumed(resumed);
} else if (failed != null) { } else if (failed != null) {
@ -767,6 +789,7 @@ public class XmppConnection implements Runnable {
account.getJid().asBareJid() + ": successfully enabled carbons"); account.getJid().asBareJid() + ": successfully enabled carbons");
features.carbonsEnabled = true; features.carbonsEnabled = true;
} }
// TODO if we didnt enable stream managment in bind do it now
// TODO if both are set mark account ready for pipelining // TODO if both are set mark account ready for pipelining
sendPostBindInitialization(streamManagementEnabled != null, carbonsEnabled != null); sendPostBindInitialization(streamManagementEnabled != null, carbonsEnabled != null);
} }
@ -1761,7 +1784,7 @@ public class XmppConnection implements Runnable {
lastDiscoStarted = SystemClock.elapsedRealtime(); lastDiscoStarted = SystemClock.elapsedRealtime();
mXmppConnectionService.scheduleWakeUpCall( mXmppConnectionService.scheduleWakeUpCall(
Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode()); Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode());
Element caps = streamFeatures.findChild("c"); final Element caps = streamFeatures.findChild("c");
final String hash = caps == null ? null : caps.getAttribute("hash"); final String hash = caps == null ? null : caps.getAttribute("hash");
final String ver = caps == null ? null : caps.getAttribute("ver"); final String ver = caps == null ? null : caps.getAttribute("ver");
ServiceDiscoveryResult discoveryResult = null; ServiceDiscoveryResult discoveryResult = null;