show regitration failed try again later in UI

This commit is contained in:
Daniel Gultsch 2016-05-24 13:26:30 +02:00
parent abbdf232c6
commit b69ab65b12
3 changed files with 19 additions and 8 deletions

View file

@ -99,7 +99,8 @@ public class Account extends AbstractEntity {
INCOMPATIBLE_SERVER(true), INCOMPATIBLE_SERVER(true),
TOR_NOT_AVAILABLE(true), TOR_NOT_AVAILABLE(true),
BIND_FAILURE(true), BIND_FAILURE(true),
HOST_UNKNOWN(true); HOST_UNKNOWN(true),
REGISTRATION_PLEASE_WAIT(true);
private final boolean isError; private final boolean isError;
@ -149,6 +150,8 @@ public class Account extends AbstractEntity {
return R.string.account_status_bind_failure; return R.string.account_status_bind_failure;
case HOST_UNKNOWN: case HOST_UNKNOWN:
return R.string.account_status_host_unknown; return R.string.account_status_host_unknown;
case REGISTRATION_PLEASE_WAIT:
return R.string.registration_please_wait;
default: default:
return R.string.account_status_unknown; return R.string.account_status_unknown;
} }

View file

@ -183,16 +183,23 @@ public class XmppConnection implements Runnable {
account.setOption(Account.OPTION_REGISTER, false); account.setOption(Account.OPTION_REGISTER, false);
forceCloseSocket(); forceCloseSocket();
changeStatus(Account.State.REGISTRATION_SUCCESSFUL); changeStatus(Account.State.REGISTRATION_SUCCESSFUL);
} else if (packet.hasChild("error") } else {
&& (packet.findChild("error").hasChild("conflict"))) { Element error = packet.findChild("error");
if (error != null && error.hasChild("conflict")) {
forceCloseSocket(); forceCloseSocket();
changeStatus(Account.State.REGISTRATION_CONFLICT); changeStatus(Account.State.REGISTRATION_CONFLICT);
} else if (error != null
&& "wait".equals(error.getAttribute("type"))
&& error.hasChild("resource-constraint")) {
forceCloseSocket();
changeStatus(Account.State.REGISTRATION_PLEASE_WAIT);
} else { } else {
forceCloseSocket(); forceCloseSocket();
changeStatus(Account.State.REGISTRATION_FAILED); changeStatus(Account.State.REGISTRATION_FAILED);
Log.d(Config.LOGTAG, packet.toString()); Log.d(Config.LOGTAG, packet.toString());
} }
} }
}
}; };
public XmppConnection(final Account account, final XmppConnectionService service) { public XmppConnection(final Account account, final XmppConnectionService service) {

View file

@ -641,4 +641,5 @@
<string name="secure_password_generated">A secure password has been generated</string> <string name="secure_password_generated">A secure password has been generated</string>
<string name="device_does_not_support_battery_op">Your device does not support opting out of battery optimization</string> <string name="device_does_not_support_battery_op">Your device does not support opting out of battery optimization</string>
<string name="show_password">Show password</string> <string name="show_password">Show password</string>
<string name="registration_please_wait">Registration failed: Try again later</string>
</resources> </resources>