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),
|
REGISTRATION_PLEASE_WAIT(true),
|
||||||
STREAM_ERROR(true),
|
STREAM_ERROR(true),
|
||||||
POLICY_VIOLATION(true),
|
POLICY_VIOLATION(true),
|
||||||
REGISTRATION_PASSWORD_TOO_WEAK(true);
|
REGISTRATION_PASSWORD_TOO_WEAK(true),
|
||||||
|
PAYMENT_REQUIRED(true);
|
||||||
|
|
||||||
private final boolean isError;
|
private final boolean isError;
|
||||||
|
|
||||||
|
@ -169,6 +170,8 @@ public class Account extends AbstractEntity {
|
||||||
return R.string.registration_password_too_weak;
|
return R.string.registration_password_too_weak;
|
||||||
case STREAM_ERROR:
|
case STREAM_ERROR:
|
||||||
return R.string.account_status_stream_error;
|
return R.string.account_status_stream_error;
|
||||||
|
case PAYMENT_REQUIRED:
|
||||||
|
return R.string.payment_required;
|
||||||
default:
|
default:
|
||||||
return R.string.account_status_unknown;
|
return R.string.account_status_unknown;
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,6 +384,8 @@ public class XmppConnection implements Runnable {
|
||||||
this.changeStatus(Account.State.SECURITY_ERROR);
|
this.changeStatus(Account.State.SECURITY_ERROR);
|
||||||
} catch (final UnauthorizedException e) {
|
} catch (final UnauthorizedException e) {
|
||||||
this.changeStatus(Account.State.UNAUTHORIZED);
|
this.changeStatus(Account.State.UNAUTHORIZED);
|
||||||
|
} catch (final PaymentRequiredException e) {
|
||||||
|
this.changeStatus(Account.State.PAYMENT_REQUIRED);
|
||||||
} catch (final UnknownHostException | ConnectException e) {
|
} catch (final UnknownHostException | ConnectException e) {
|
||||||
this.changeStatus(Account.State.SERVER_NOT_FOUND);
|
this.changeStatus(Account.State.SERVER_NOT_FOUND);
|
||||||
} catch (final SocksSocketFactory.SocksProxyNotFoundException e) {
|
} catch (final SocksSocketFactory.SocksProxyNotFoundException e) {
|
||||||
|
@ -505,7 +507,16 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else if (nextTag.isStart("failure")) {
|
} 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();
|
throw new UnauthorizedException();
|
||||||
|
}
|
||||||
} else if (nextTag.isStart("challenge")) {
|
} else if (nextTag.isStart("challenge")) {
|
||||||
final String challenge = tagReader.readElement(nextTag).getContent();
|
final String challenge = tagReader.readElement(nextTag).getContent();
|
||||||
final Element response = new Element("response");
|
final Element response = new Element("response");
|
||||||
|
@ -1535,6 +1546,10 @@ public class XmppConnection implements Runnable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class PaymentRequiredException extends IOException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public enum Identity {
|
public enum Identity {
|
||||||
FACEBOOK,
|
FACEBOOK,
|
||||||
SLACK,
|
SLACK,
|
||||||
|
|
|
@ -674,4 +674,5 @@
|
||||||
<string name="type_tablet">Tablet</string>
|
<string name="type_tablet">Tablet</string>
|
||||||
<string name="type_web">Web browser</string>
|
<string name="type_web">Web browser</string>
|
||||||
<string name="type_console">Console</string>
|
<string name="type_console">Console</string>
|
||||||
|
<string name="payment_required">Payment required</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue