aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-08-16 10:39:59 +0200
committerChristian Schneppe <christian@pix-art.de>2016-08-26 19:41:18 +0200
commitda1edafd495b82a0a9b176f7718cd3fe7b334521 (patch)
tree87e3db8671b84de9177d758de43761c24e7d4448 /src/main
parentbbf63481873eaa39a215b6c5b2f88f16ba807d61 (diff)
add payment required error
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Account.java5
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/XmppConnection.java17
-rw-r--r--src/main/res/values/strings.xml1
3 files changed, 21 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Account.java b/src/main/java/de/pixart/messenger/entities/Account.java
index 8c9ed51f2..333bb58c9 100644
--- a/src/main/java/de/pixart/messenger/entities/Account.java
+++ b/src/main/java/de/pixart/messenger/entities/Account.java
@@ -110,7 +110,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;
@@ -168,6 +169,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/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
index 9af0a0eb3..081f8975c 100644
--- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
@@ -397,6 +397,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) {
@@ -518,7 +520,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");
@@ -1548,6 +1559,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 b2aaaf2c9..baec6bad6 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -685,4 +685,5 @@
<string name="databaseimport_started">Backup will be imported, this may take awhile.</string>
<string name="pref_export_plain_text_logs_summary">Enable an export of chat logs as human readable text files</string>
<string name="pref_export_plain_text_logs">Export human readable chat logs</string>
+ <string name="payment_required">Payment required</string>
</resources>