diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-07-14 17:05:43 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-07-17 15:22:19 +0200 |
commit | 47f559310b72a23d8049af5a423f353e8aea841e (patch) | |
tree | 97fe182aea15e9116938c9a45308314ea7bdbf59 /src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | |
parent | 78a60fb85a6b5101f6cee8b4efa156746ac279a3 (diff) |
add more error states for stream errors
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 88765c147..a4476c052 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -374,6 +374,12 @@ public class XmppConnection implements Runnable { this.changeStatus(Account.State.SERVER_NOT_FOUND); } catch (final SocksSocketFactory.SocksProxyNotFoundException e) { this.changeStatus(Account.State.TOR_NOT_AVAILABLE); + } catch(final StreamErrorHostUnknown e) { + this.changeStatus(Account.State.HOST_UNKNOWN); + } catch(final StreamErrorPolicyViolation e) { + this.changeStatus(Account.State.POLICY_VIOLATION); + } catch(final StreamError e) { + this.changeStatus(Account.State.STREAM_ERROR); } catch (final IOException | XmlPullParserException | NoSuchAlgorithmException e) { Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage()); this.changeStatus(Account.State.OFFLINE); @@ -1189,17 +1195,21 @@ public class XmppConnection implements Runnable { if (streamError == null) { return; } - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": stream error "+streamError.toString()); if (streamError.hasChild("conflict")) { final String resource = account.getResource().split("\\.")[0]; account.setResource(resource + "." + nextRandomId()); Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": switching resource due to conflict (" + account.getResource() + ")"); + throw new IOException(); } else if (streamError.hasChild("host-unknown")) { - changeStatus(Account.State.HOST_UNKNOWN); + throw new StreamErrorHostUnknown(); + } else if (streamError.hasChild("policy-violation")) { + throw new StreamErrorPolicyViolation(); + } else { + Log.d(Config.LOGTAG,account.getJid().toBareJid()+": stream error "+streamError.toString()); + throw new StreamError(); } - forceCloseSocket(); } private void sendStartStream() throws IOException { @@ -1498,6 +1508,18 @@ public class XmppConnection implements Runnable { } + private class StreamErrorHostUnknown extends StreamError { + + } + + private class StreamErrorPolicyViolation extends StreamError { + + } + + private class StreamError extends IOException { + + } + public enum Identity { FACEBOOK, SLACK, |