fixed npe with unsuccesfull bind

This commit is contained in:
iNPUTmice 2014-07-26 15:44:32 +02:00
parent 5182a92e58
commit 29f089c954
1 changed files with 25 additions and 18 deletions

View File

@ -609,9 +609,11 @@ public class XmppConnection implements Runnable {
this.sendUnboundIqPacket(iq, new OnIqPacketReceived() { this.sendUnboundIqPacket(iq, new OnIqPacketReceived() {
@Override @Override
public void onIqPacketReceived(Account account, IqPacket packet) { public void onIqPacketReceived(Account account, IqPacket packet) {
String resource = packet.findChild("bind").findChild("jid") Element bind = packet.findChild("bind");
.getContent().split("/")[1]; if (bind!=null) {
account.setResource(resource); Element jid = bind.findChild("jid");
if (jid!=null) {
account.setResource(jid.getContent().split("/")[1]);
if (streamFeatures.hasChild("sm", "urn:xmpp:sm:3")) { if (streamFeatures.hasChild("sm", "urn:xmpp:sm:3")) {
smVersion = 3; smVersion = 3;
EnablePacket enable = new EnablePacket(smVersion); EnablePacket enable = new EnablePacket(smVersion);
@ -626,8 +628,13 @@ public class XmppConnection implements Runnable {
if (bindListener != null) { if (bindListener != null) {
bindListener.onBind(account); bindListener.onBind(account);
} }
changeStatus(Account.STATUS_ONLINE); changeStatus(Account.STATUS_ONLINE);
} else {
disconnect(true);
}
} else {
disconnect(true);
}
} }
}); });
if (this.streamFeatures.hasChild("session")) { if (this.streamFeatures.hasChild("session")) {