diff options
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/Account.java | 5 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | 17 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 1 |
3 files changed, 21 insertions, 2 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java index 7085c7ba..b77d85c4 100644 --- a/src/main/java/eu/siacs/conversations/entities/Account.java +++ b/src/main/java/eu/siacs/conversations/entities/Account.java @@ -111,7 +111,8 @@ public class Account extends AbstractEntity { REGISTRATION_PLEASE_WAIT(true), STREAM_ERROR(true), POLICY_VIOLATION(true), - REGISTRATION_PASSWORD_TOO_WEAK(true); + REGISTRATION_PASSWORD_TOO_WEAK(true), + PAYMENT_REQUIRED(true); private final boolean isError; @@ -169,6 +170,8 @@ public class Account extends AbstractEntity { return R.string.registration_password_too_weak; case STREAM_ERROR: return R.string.account_status_stream_error; + case PAYMENT_REQUIRED: + return R.string.payment_required; 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 89ffa05d..6e36a546 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -384,6 +384,8 @@ public class XmppConnection implements Runnable { this.changeStatus(Account.State.SECURITY_ERROR); } catch (final UnauthorizedException e) { this.changeStatus(Account.State.UNAUTHORIZED); + } catch (final PaymentRequiredException e) { + this.changeStatus(Account.State.PAYMENT_REQUIRED); } catch (final UnknownHostException | ConnectException e) { this.changeStatus(Account.State.SERVER_NOT_FOUND); } catch (final SocksSocketFactory.SocksProxyNotFoundException e) { @@ -505,7 +507,16 @@ public class XmppConnection implements Runnable { } break; } else if (nextTag.isStart("failure")) { - throw new UnauthorizedException(); + final Element failure = tagReader.readElement(nextTag); + final String accountDisabled = failure.findChildContent("account-disabled"); + if (accountDisabled != null + && accountDisabled.contains("renew") + && Config.MAGIC_CREATE_DOMAIN != null + && accountDisabled.contains(Config.MAGIC_CREATE_DOMAIN)) { + throw new PaymentRequiredException(); + } else { + throw new UnauthorizedException(); + } } else if (nextTag.isStart("challenge")) { final String challenge = tagReader.readElement(nextTag).getContent(); final Element response = new Element("response"); @@ -1535,6 +1546,10 @@ public class XmppConnection implements Runnable { } + private class PaymentRequiredException extends IOException { + + } + public enum Identity { FACEBOOK, SLACK, diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 96d7d3cc..71b641db 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -674,4 +674,5 @@ <string name="type_tablet">Tablet</string> <string name="type_web">Web browser</string> <string name="type_console">Console</string> + <string name="payment_required">Payment required</string> </resources> |