From 097fe3e1b69ae0c3bf98a7c1d5ec0a99f848b446 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 12 Aug 2017 22:17:04 +0200 Subject: [PATCH] no automatic reconnect on registration failures --- .../siacs/conversations/entities/Account.java | 62 +++++++++++-------- .../services/XmppConnectionService.java | 4 +- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java index d25deab40..6967fe5fa 100644 --- a/src/main/java/eu/siacs/conversations/entities/Account.java +++ b/src/main/java/eu/siacs/conversations/entities/Account.java @@ -109,45 +109,55 @@ public class Account extends AbstractEntity { } public enum State { - DISABLED, - OFFLINE, - CONNECTING, - ONLINE, - NO_INTERNET, - UNAUTHORIZED(true), - SERVER_NOT_FOUND(true), - REGISTRATION_FAILED(true), - REGISTRATION_WEB(true), - REGISTRATION_CONFLICT(true), - REGISTRATION_SUCCESSFUL, - REGISTRATION_NOT_SUPPORTED(true), - TLS_ERROR(true), - INCOMPATIBLE_SERVER(true), - TOR_NOT_AVAILABLE(true), - DOWNGRADE_ATTACK(true), - SESSION_FAILURE(true), - BIND_FAILURE(true), - HOST_UNKNOWN(true), - REGISTRATION_PLEASE_WAIT(true), - STREAM_ERROR(true), - POLICY_VIOLATION(true), - REGISTRATION_PASSWORD_TOO_WEAK(true), - PAYMENT_REQUIRED(true), - MISSING_INTERNET_PERMISSION(true), + DISABLED(false,false), + OFFLINE(false), + CONNECTING(false), + ONLINE(false), + NO_INTERNET(false), + UNAUTHORIZED, + SERVER_NOT_FOUND, + REGISTRATION_SUCCESSFUL(false), + REGISTRATION_FAILED(true,false), + REGISTRATION_WEB(true,false), + REGISTRATION_CONFLICT(true,false), + REGISTRATION_NOT_SUPPORTED(true,false), + REGISTRATION_PLEASE_WAIT(true,false), + REGISTRATION_PASSWORD_TOO_WEAK(true,false), + TLS_ERROR, + INCOMPATIBLE_SERVER, + TOR_NOT_AVAILABLE, + DOWNGRADE_ATTACK, + SESSION_FAILURE, + BIND_FAILURE, + HOST_UNKNOWN, + STREAM_ERROR, + POLICY_VIOLATION, + PAYMENT_REQUIRED, + MISSING_INTERNET_PERMISSION(false), NETWORK_IS_UNREACHABLE(false); private final boolean isError; + private final boolean attemptReconnect; public boolean isError() { return this.isError; } + public boolean isAttemptReconnect() { + return this.attemptReconnect; + } + State(final boolean isError) { + this(isError,true); + } + + State(final boolean isError, final boolean reconnect) { this.isError = isError; + this.attemptReconnect = reconnect; } State() { - this(false); + this(true,true); } public int getReadableId() { diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 9c54741d5..c48c83296 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -375,7 +375,7 @@ public class XmppConnectionService extends Service { reconnectAccount(account, true, false); } else if (account.getStatus() != Account.State.CONNECTING && account.getStatus() != Account.State.NO_INTERNET) { resetSendingToWaiting(account); - if (connection != null) { + if (connection != null && account.getStatus().isAttemptReconnect()) { final int next = connection.getTimeToNextAttempt(); final boolean lowPingTimeoutMode = isInLowPingTimeoutMode(account); if (next <= 0) { @@ -749,7 +749,7 @@ public class XmppConnectionService extends Service { private boolean processAccountState(Account account, boolean interactive, boolean isUiAction, boolean isAccountPushed, HashSet pingCandidates) { boolean pingNow = false; - if (!account.isOptionSet(Account.OPTION_DISABLED)) { + if (account.getStatus().isAttemptReconnect()) { if (!hasInternetConnection()) { account.setStatus(Account.State.NO_INTERNET); if (statusListener != null) {