aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/xmpp
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2014-03-14 18:56:52 +0100
committerDaniel Gultsch <daniel@gultsch.de>2014-03-14 18:56:52 +0100
commit4e20b81bd9a7e91c8570328e7390726d07aecff2 (patch)
tree5a091100385dc5fdb67eb71dd084dc7d30bed0bb /src/eu/siacs/conversations/xmpp
parent71cb5548eb453be94ea62e6e2b87d654287c2d29 (diff)
fixed problem with null messages. added ask again button
Diffstat (limited to 'src/eu/siacs/conversations/xmpp')
-rw-r--r--src/eu/siacs/conversations/xmpp/XmppConnection.java80
1 files changed, 44 insertions, 36 deletions
diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java
index 677c0ba6..668391ad 100644
--- a/src/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -441,42 +441,11 @@ public class XmppConnection implements Runnable {
&& account.isOptionSet(Account.OPTION_USETLS)) {
sendStartTLS();
} else if (this.streamFeatures.hasChild("register")&&(account.isOptionSet(Account.OPTION_REGISTER))) {
- IqPacket register = new IqPacket(IqPacket.TYPE_GET);
- register.query("jabber:iq:register");
- register.setTo(account.getServer());
- sendIqPacket(register, new OnIqPacketReceived() {
-
- @Override
- public void onIqPacketReceived(Account account, IqPacket packet) {
- Element instructions = packet.query().findChild("instructions");
- if (packet.query().hasChild("username")&&(packet.query().hasChild("password"))) {
- IqPacket register = new IqPacket(IqPacket.TYPE_SET);
- Element username = new Element("username").setContent(account.getUsername());
- Element password = new Element("password").setContent(account.getPassword());
- register.query("jabber:iq:register").addChild(username).addChild(password);
- sendIqPacket(register, new OnIqPacketReceived() {
-
- @Override
- public void onIqPacketReceived(Account account, IqPacket packet) {
- if (packet.getType()==IqPacket.TYPE_RESULT) {
- account.setOption(Account.OPTION_REGISTER, false);
- changeStatus(Account.STATUS_REGISTRATION_SUCCESSFULL);
- Log.d(LOGTAG,"successfull");
- } else if (packet.hasChild("error")&&(packet.findChild("error").hasChild("conflict"))){
- changeStatus(Account.STATUS_REGISTRATION_CONFLICT);
- } else {
- changeStatus(Account.STATUS_REGISTRATION_FAILED);
- Log.d(LOGTAG,packet.toString());
- }
- disconnect(true);
- }
- });
- Log.d(LOGTAG,"registering: "+register.toString());
- } else {
- Log.d(LOGTAG,account.getJid()+": could not register. instructions are"+instructions.getContent());
- }
- }
- });
+ sendRegistryRequest();
+ } else if (!this.streamFeatures.hasChild("register")&&(account.isOptionSet(Account.OPTION_REGISTER))) {
+ //Log.d(LOGTAG,"registration not supported. stream features where"+this.streamFeatures.toString());
+ changeStatus(Account.STATUS_REGISTRATION_NOT_SUPPORTED);
+ disconnect(true);
} else if (this.streamFeatures.hasChild("mechanisms")
&& shouldAuthenticate) {
sendSaslAuth();
@@ -499,6 +468,45 @@ public class XmppConnection implements Runnable {
}
}
+ private void sendRegistryRequest() {
+ IqPacket register = new IqPacket(IqPacket.TYPE_GET);
+ register.query("jabber:iq:register");
+ register.setTo(account.getServer());
+ sendIqPacket(register, new OnIqPacketReceived() {
+
+ @Override
+ public void onIqPacketReceived(Account account, IqPacket packet) {
+ Element instructions = packet.query().findChild("instructions");
+ if (packet.query().hasChild("username")&&(packet.query().hasChild("password"))) {
+ IqPacket register = new IqPacket(IqPacket.TYPE_SET);
+ Element username = new Element("username").setContent(account.getUsername());
+ Element password = new Element("password").setContent(account.getPassword());
+ register.query("jabber:iq:register").addChild(username).addChild(password);
+ sendIqPacket(register, new OnIqPacketReceived() {
+
+ @Override
+ public void onIqPacketReceived(Account account, IqPacket packet) {
+ if (packet.getType()==IqPacket.TYPE_RESULT) {
+ account.setOption(Account.OPTION_REGISTER, false);
+ changeStatus(Account.STATUS_REGISTRATION_SUCCESSFULL);
+ } else if (packet.hasChild("error")&&(packet.findChild("error").hasChild("conflict"))){
+ changeStatus(Account.STATUS_REGISTRATION_CONFLICT);
+ } else {
+ changeStatus(Account.STATUS_REGISTRATION_FAILED);
+ Log.d(LOGTAG,packet.toString());
+ }
+ disconnect(true);
+ }
+ });
+ } else {
+ changeStatus(Account.STATUS_REGISTRATION_FAILED);
+ disconnect(true);
+ Log.d(LOGTAG,account.getJid()+": could not register. instructions are"+instructions.getContent());
+ }
+ }
+ });
+ }
+
private void sendInitialPresence() {
PresencePacket packet = new PresencePacket();
packet.setAttribute("from", account.getFullJid());