From a7cd05bd4e5e350a91361da18f5437ca7f64e1bd Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 5 May 2016 20:22:47 +0200 Subject: [PATCH] report bind failure as account state --- .../siacs/conversations/entities/Account.java | 5 ++++- .../conversations/xmpp/XmppConnection.java | 17 +++++++++-------- src/main/res/values/strings.xml | 1 + 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java index 1bcb15c07..1a7798b2d 100644 --- a/src/main/java/eu/siacs/conversations/entities/Account.java +++ b/src/main/java/eu/siacs/conversations/entities/Account.java @@ -93,7 +93,8 @@ public class Account extends AbstractEntity { REGISTRATION_NOT_SUPPORTED(true), SECURITY_ERROR(true), INCOMPATIBLE_SERVER(true), - TOR_NOT_AVAILABLE(true); + TOR_NOT_AVAILABLE(true), + BIND_FAILURE(true); private final boolean isError; @@ -139,6 +140,8 @@ public class Account extends AbstractEntity { return R.string.account_status_incompatible_server; case TOR_NOT_AVAILABLE: return R.string.account_status_tor_unavailable; + case BIND_FAILURE: + return R.string.account_status_bind_failure; default: return R.string.account_status_unknown; } diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 26139f8e0..26610561f 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -906,22 +906,23 @@ public class XmppConnection implements Runnable { if (jid != null && jid.getContent() != null) { try { account.setResource(Jid.fromString(jid.getContent()).getResourcepart()); + if (streamFeatures.hasChild("session")) { + sendStartSession(); + } else { + sendPostBindInitialization(); + } + return; } catch (final InvalidJidException e) { - // TODO: Handle the case where an external JID is technically invalid? - } - if (streamFeatures.hasChild("session")) { - sendStartSession(); - } else { - sendPostBindInitialization(); + Log.d(Config.LOGTAG,account.getJid().toBareJid()+": server reported invalid jid ("+jid.getContent()+") on bind"); } } else { Log.d(Config.LOGTAG, account.getJid() + ": disconnecting because of bind failure. (no jid)"); - disconnect(true); } } else { Log.d(Config.LOGTAG, account.getJid() + ": disconnecting because of bind failure (" + packet.toString()); - disconnect(true); } + forceCloseSocket(); + changeStatus(Account.State.BIND_FAILURE); } }); } diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 06da9f6dc..d11e897c8 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -541,6 +541,7 @@ Use white background Show received messages as black text on a white background Tor network unavailable + Bind failure Broken Presence Away when screen is off