print available stream features / mechanisms on incompat server

This commit is contained in:
Daniel Gultsch 2019-02-09 20:21:29 +01:00
parent ef09b0ab1a
commit bebce313b2
3 changed files with 22 additions and 1 deletions

View file

@ -358,7 +358,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
final boolean groupChat = mConversation != null && mConversation.isPrivateAndNonAnonymous(); final boolean groupChat = mConversation != null && mConversation.isPrivateAndNonAnonymous();
getMenuInflater().inflate(R.menu.muc_details, menu); getMenuInflater().inflate(R.menu.muc_details, menu);
final MenuItem share = menu.findItem(R.id.action_share); final MenuItem share = menu.findItem(R.id.action_share);
share.setVisible(groupChat); share.setVisible(!groupChat);
final MenuItem destroy = menu.findItem(R.id.action_destroy_room); final MenuItem destroy = menu.findItem(R.id.action_destroy_room);
destroy.setTitle(groupChat ? R.string.destroy_room : R.string.destroy_channel); destroy.setTitle(groupChat ? R.string.destroy_room : R.string.destroy_channel);
AccountUtils.showHideMenuItems(menu); AccountUtils.showHideMenuItems(menu);

View file

@ -1,5 +1,7 @@
package eu.siacs.conversations.utils; package eu.siacs.conversations.utils;
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("&", "&");
@ -10,4 +12,19 @@ public class XmlHelper {
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) {
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();
}
} }

View file

@ -78,6 +78,7 @@ import eu.siacs.conversations.utils.Patterns;
import eu.siacs.conversations.utils.Resolver; import eu.siacs.conversations.utils.Resolver;
import eu.siacs.conversations.utils.SSLSocketHelper; import eu.siacs.conversations.utils.SSLSocketHelper;
import eu.siacs.conversations.utils.SocksSocketFactory; import eu.siacs.conversations.utils.SocksSocketFactory;
import eu.siacs.conversations.utils.XmlHelper;
import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xml.Namespace; import eu.siacs.conversations.xml.Namespace;
import eu.siacs.conversations.xml.Tag; import eu.siacs.conversations.xml.Tag;
@ -847,6 +848,7 @@ public class XmppConnection implements Runnable {
if (isSecure) { if (isSecure) {
sendRegistryRequest(); sendRegistryRequest();
} else { } else {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": unable to find STARTTLS for registration process "+ XmlHelper.printElementNames(this.streamFeatures));
throw new StateChangingException(Account.State.INCOMPATIBLE_SERVER); throw new StateChangingException(Account.State.INCOMPATIBLE_SERVER);
} }
} else if (!this.streamFeatures.hasChild("register") && account.isOptionSet(Account.OPTION_REGISTER)) { } else if (!this.streamFeatures.hasChild("register") && account.isOptionSet(Account.OPTION_REGISTER)) {
@ -865,6 +867,7 @@ public class XmppConnection implements Runnable {
if (this.streamFeatures.hasChild("bind") && isSecure) { if (this.streamFeatures.hasChild("bind") && isSecure) {
sendBindRequest(); sendBindRequest();
} else { } else {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": unable to find bind feature "+ XmlHelper.printElementNames(this.streamFeatures));
throw new StateChangingException(Account.State.INCOMPATIBLE_SERVER); throw new StateChangingException(Account.State.INCOMPATIBLE_SERVER);
} }
} }
@ -903,6 +906,7 @@ public class XmppConnection implements Runnable {
} }
tagWriter.writeElement(auth); tagWriter.writeElement(auth);
} else { } else {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": unable to find SASL mechanism "+ saslMechanism.toString());
throw new StateChangingException(Account.State.INCOMPATIBLE_SERVER); throw new StateChangingException(Account.State.INCOMPATIBLE_SERVER);
} }
} }