aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-12-09 11:16:03 +0100
committerDaniel Gultsch <daniel@gultsch.de>2015-12-09 11:16:03 +0100
commit5e151c7311bed98ce7eafa041735484c32bd7dda (patch)
tree36a507964457c7415f639d341f1a28bed7a2c5d9
parent11e58607c93f152aad82cfe7951355e03274bf47 (diff)
wait with status change to online after all disco queries have been made
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index 9ec4d9bb..7455ff8d 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -116,6 +116,7 @@ public class XmppConnection implements Runnable {
private long lastPingSent = 0;
private long lastConnect = 0;
private long lastSessionStarted = 0;
+ private int mPendingServiceDiscoveries = 0;
private boolean mInteractive = false;
private int attempt = 0;
private final Hashtable<String, Pair<IqPacket, OnIqPacketReceived>> packetCallbacks = new Hashtable<>();
@@ -926,18 +927,16 @@ public class XmppConnection implements Runnable {
synchronized (this.disco) {
this.disco.clear();
}
+ mPendingServiceDiscoveries = 0;
+ sendServiceDiscoveryItems(account.getServer());
sendServiceDiscoveryInfo(account.getServer());
sendServiceDiscoveryInfo(account.getJid().toBareJid());
- sendServiceDiscoveryItems(account.getServer());
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": online with resource " + account.getResource());
this.lastSessionStarted = SystemClock.elapsedRealtime();
- changeStatus(Account.State.ONLINE);
- if (bindListener != null) {
- bindListener.onBind(account);
- }
}
private void sendServiceDiscoveryInfo(final Jid jid) {
+ mPendingServiceDiscoveries++;
final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
iq.setTo(jid);
iq.query("http://jabber.org/protocol/disco#info");
@@ -988,6 +987,16 @@ public class XmppConnection implements Runnable {
} else {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not query disco info for " + jid.toString());
}
+ if (packet.getType() != IqPacket.TYPE.TIMEOUT) {
+ mPendingServiceDiscoveries--;
+ if (mPendingServiceDiscoveries <= 0) {
+ Log.d(Config.LOGTAG,account.getJid().toBareJid()+": done with service discovery");
+ changeStatus(Account.State.ONLINE);
+ if (bindListener != null) {
+ bindListener.onBind(account);
+ }
+ }
+ }
}
});
}