report bind failure as account state

This commit is contained in:
Daniel Gultsch 2016-05-05 20:22:47 +02:00
parent 0157039e87
commit a7cd05bd4e
3 changed files with 14 additions and 9 deletions

View file

@ -93,7 +93,8 @@ public class Account extends AbstractEntity {
REGISTRATION_NOT_SUPPORTED(true), REGISTRATION_NOT_SUPPORTED(true),
SECURITY_ERROR(true), SECURITY_ERROR(true),
INCOMPATIBLE_SERVER(true), INCOMPATIBLE_SERVER(true),
TOR_NOT_AVAILABLE(true); TOR_NOT_AVAILABLE(true),
BIND_FAILURE(true);
private final boolean isError; private final boolean isError;
@ -139,6 +140,8 @@ public class Account extends AbstractEntity {
return R.string.account_status_incompatible_server; return R.string.account_status_incompatible_server;
case TOR_NOT_AVAILABLE: case TOR_NOT_AVAILABLE:
return R.string.account_status_tor_unavailable; return R.string.account_status_tor_unavailable;
case BIND_FAILURE:
return R.string.account_status_bind_failure;
default: default:
return R.string.account_status_unknown; return R.string.account_status_unknown;
} }

View file

@ -906,22 +906,23 @@ public class XmppConnection implements Runnable {
if (jid != null && jid.getContent() != null) { if (jid != null && jid.getContent() != null) {
try { try {
account.setResource(Jid.fromString(jid.getContent()).getResourcepart()); account.setResource(Jid.fromString(jid.getContent()).getResourcepart());
} catch (final InvalidJidException e) {
// TODO: Handle the case where an external JID is technically invalid?
}
if (streamFeatures.hasChild("session")) { if (streamFeatures.hasChild("session")) {
sendStartSession(); sendStartSession();
} else { } else {
sendPostBindInitialization(); sendPostBindInitialization();
} }
return;
} catch (final InvalidJidException e) {
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": server reported invalid jid ("+jid.getContent()+") on bind");
}
} else { } else {
Log.d(Config.LOGTAG, account.getJid() + ": disconnecting because of bind failure. (no jid)"); Log.d(Config.LOGTAG, account.getJid() + ": disconnecting because of bind failure. (no jid)");
disconnect(true);
} }
} else { } else {
Log.d(Config.LOGTAG, account.getJid() + ": disconnecting because of bind failure (" + packet.toString()); Log.d(Config.LOGTAG, account.getJid() + ": disconnecting because of bind failure (" + packet.toString());
disconnect(true);
} }
forceCloseSocket();
changeStatus(Account.State.BIND_FAILURE);
} }
}); });
} }

View file

@ -541,6 +541,7 @@
<string name="pref_use_white_background">Use white background</string> <string name="pref_use_white_background">Use white background</string>
<string name="pref_use_white_background_summary">Show received messages as black text on a white background</string> <string name="pref_use_white_background_summary">Show received messages as black text on a white background</string>
<string name="account_status_tor_unavailable">Tor network unavailable</string> <string name="account_status_tor_unavailable">Tor network unavailable</string>
<string name="account_status_bind_failure">Bind failure</string>
<string name="server_info_broken">Broken</string> <string name="server_info_broken">Broken</string>
<string name="pref_presence_settings">Presence</string> <string name="pref_presence_settings">Presence</string>
<string name="pref_away_when_screen_off">Away when screen is off</string> <string name="pref_away_when_screen_off">Away when screen is off</string>