add payment required error
This commit is contained in:
parent
343bb7ff28
commit
b5d3859b22
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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")) {
|
||||
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,
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue