aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/eu/siacs/conversations/generator/IqGenerator.java6
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java5
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java49
3 files changed, 25 insertions, 35 deletions
diff --git a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java
index b7911ef7..daacfe59 100644
--- a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java
+++ b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java
@@ -303,8 +303,10 @@ public class IqGenerator extends AbstractGenerator {
register.setTo(account.getServer());
register.setId(id);
- register.query("jabber:iq:register").addChild(data);
-
+ Element query = register.query("jabber:iq:register");
+ if (data != null) {
+ query.addChild(data);
+ }
return register;
}
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 5fd8a053..ba9d7968 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -3002,9 +3002,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
public void sendCreateAccountWithCaptchaPacket(Account account, String id, Data data) {
- XmppConnection connection = account.getXmppConnection();
+ final XmppConnection connection = account.getXmppConnection();
if (connection != null) {
- connection.sendCaptchaRegistryRequest(id, data);
+ IqPacket request = mIqGenerator.generateCreateAccountWithCaptcha(account, id, data);
+ sendIqPacket(account, request, connection.registrationResponseListener);
}
}
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index c1e26a70..687f07da 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -176,28 +176,24 @@ public class XmppConnection implements Runnable {
};
private Identity mServerIdentity = Identity.UNKNOWN;
- private OnIqPacketReceived createPacketReceiveHandler() {
- return new OnIqPacketReceived() {
- @Override
- public void onIqPacketReceived(Account account, IqPacket packet) {
- if (packet.getType() == IqPacket.TYPE.RESULT) {
- account.setOption(Account.OPTION_REGISTER,
- false);
- forceCloseSocket();
- changeStatus(Account.State.REGISTRATION_SUCCESSFUL);
- } else if (packet.hasChild("error")
- && (packet.findChild("error")
- .hasChild("conflict"))) {
- forceCloseSocket();
- changeStatus(Account.State.REGISTRATION_CONFLICT);
- } else {
- forceCloseSocket();
- changeStatus(Account.State.REGISTRATION_FAILED);
- Log.d(Config.LOGTAG, packet.toString());
- }
+ public final OnIqPacketReceived registrationResponseListener = new OnIqPacketReceived() {
+ @Override
+ public void onIqPacketReceived(Account account, IqPacket packet) {
+ if (packet.getType() == IqPacket.TYPE.RESULT) {
+ account.setOption(Account.OPTION_REGISTER, false);
+ forceCloseSocket();
+ changeStatus(Account.State.REGISTRATION_SUCCESSFUL);
+ } else if (packet.hasChild("error")
+ && (packet.findChild("error").hasChild("conflict"))) {
+ forceCloseSocket();
+ changeStatus(Account.State.REGISTRATION_CONFLICT);
+ } else {
+ forceCloseSocket();
+ changeStatus(Account.State.REGISTRATION_FAILED);
+ Log.d(Config.LOGTAG, packet.toString());
}
- };
- }
+ }
+ };
public XmppConnection(final Account account, final XmppConnectionService service) {
this.account = account;
@@ -809,15 +805,6 @@ public class XmppConnection implements Runnable {
return mechanisms;
}
- public void sendCaptchaRegistryRequest(String id, Data data) {
- if (data == null) {
- setAccountCreationFailed("");
- } else {
- IqPacket request = getIqGenerator().generateCreateAccountWithCaptcha(account, id, data);
- sendIqPacket(request, createPacketReceiveHandler());
- }
- }
-
private void sendRegistryRequest() {
final IqPacket register = new IqPacket(IqPacket.TYPE.GET);
register.query("jabber:iq:register");
@@ -835,7 +822,7 @@ public class XmppConnection implements Runnable {
final Element password = new Element("password").setContent(account.getPassword());
register.query("jabber:iq:register").addChild(username);
register.query().addChild(password);
- sendIqPacket(register, createPacketReceiveHandler());
+ sendIqPacket(register, registrationResponseListener);
} else if (packet.getType() == IqPacket.TYPE.RESULT
&& (packet.query().hasChild("x", "jabber:x:data"))) {
final Data data = Data.parse(packet.query().findChild("x", "jabber:x:data"));