aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/de/pixart/messenger/ui/EditAccountActivity.java9
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/XmppConnection.java11
2 files changed, 18 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
index 88623b600..8e58def2d 100644
--- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
@@ -187,6 +187,9 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
return;
}
if (registerNewAccount) {
+ if (XmppConnection.errorMessage != null) {
+ Toast.makeText(EditAccountActivity.this,XmppConnection.errorMessage,Toast.LENGTH_LONG).show();
+ }
if (!password.equals(passwordConfirm)) {
mPasswordConfirm.setError(getString(R.string.passwords_do_not_match));
mPasswordConfirm.requestFocus();
@@ -200,7 +203,11 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
mAccount.setJid(jid);
mAccount.setPort(numericPort);
mAccount.setHostname(hostname);
- mAccountJid.setError(null);
+ if (XmppConnection.errorMessage != null) {
+ mAccountJid.setError(XmppConnection.errorMessage);
+ } else {
+ mAccountJid.setError(null);
+ }
mPasswordConfirm.setError(null);
mAccount.setPassword(password);
mAccount.setOption(Account.OPTION_REGISTER, registerNewAccount);
diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
index a70c8e0c3..87afcdcee 100644
--- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
@@ -67,6 +67,7 @@ import de.pixart.messenger.entities.Message;
import de.pixart.messenger.entities.ServiceDiscoveryResult;
import de.pixart.messenger.generator.IqGenerator;
import de.pixart.messenger.services.XmppConnectionService;
+import de.pixart.messenger.ui.EditAccountActivity;
import de.pixart.messenger.utils.DNSHelper;
import de.pixart.messenger.utils.SSLSocketHelper;
import de.pixart.messenger.utils.SocksSocketFactory;
@@ -124,6 +125,7 @@ public class XmppConnection implements Runnable {
private AtomicBoolean mWaitForDisco = new AtomicBoolean(true);
private boolean mInteractive = false;
private int attempt = 0;
+ public static String errorMessage = null;
private final Hashtable<String, Pair<IqPacket, OnIqPacketReceived>> packetCallbacks = new Hashtable<>();
private OnPresencePacketReceived presenceListener = null;
private OnJinglePacketReceived jingleListener = null;
@@ -134,6 +136,7 @@ public class XmppConnection implements Runnable {
private final ArrayList<OnAdvancedStreamFeaturesLoaded> advancedStreamFeaturesLoadedListeners = new ArrayList<>();
private OnMessageAcknowledged acknowledgedListener = null;
private XmppConnectionService mXmppConnectionService = null;
+ private EditAccountActivity mEditAccountActivity = null;
private SaslMechanism saslMechanism;
@@ -189,9 +192,14 @@ public class XmppConnection implements Runnable {
final List<String> PASSWORD_TOO_WEAK_MSGS = Arrays.asList(
"The password is too weak",
"Please use a longer password.");
- Element error = packet.findChild("error");
+ final Element error = packet.findChild("error");
Account.State state = Account.State.REGISTRATION_FAILED;
+ mXmppConnectionService.deleteAccount(account);
if (error != null) {
+ if (error.hasChild("text")) {
+ errorMessage = error.findChildContent("text");
+ Log.d(Config.LOGTAG, "Error creating account : " + error.findChildContent("text"));
+ }
if (error.hasChild("conflict")) {
state = Account.State.REGISTRATION_CONFLICT;
} else if (error.hasChild("resource-constraint")
@@ -202,6 +210,7 @@ public class XmppConnection implements Runnable {
state = Account.State.REGISTRATION_PASSWORD_TOO_WEAK;
}
}
+ Log.d(Config.LOGTAG, "Delete account because of error " + error);
changeStatus(state);
forceCloseSocket();
}