deduplicate disco items before disco#info

This commit is contained in:
Daniel Gultsch 2017-06-30 08:45:16 +02:00
parent 7c1e1132b0
commit 4a2e222b34
1 changed files with 7 additions and 1 deletions

View File

@ -31,6 +31,7 @@ import java.security.cert.X509Certificate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -1092,6 +1093,7 @@ public class XmppConnection implements Runnable {
public void sendDiscoTimeout() { public void sendDiscoTimeout() {
if (mWaitForDisco.compareAndSet(true, false)) { if (mWaitForDisco.compareAndSet(true, false)) {
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": finalizing bind after disco timeout");
finalizeBind(); finalizeBind();
} }
} }
@ -1231,15 +1233,19 @@ public class XmppConnection implements Runnable {
@Override @Override
public void onIqPacketReceived(final Account account, final IqPacket packet) { public void onIqPacketReceived(final Account account, final IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT) { if (packet.getType() == IqPacket.TYPE.RESULT) {
HashSet<Jid> items = new HashSet<Jid>();
final List<Element> elements = packet.query().getChildren(); final List<Element> elements = packet.query().getChildren();
for (final Element element : elements) { for (final Element element : elements) {
if (element.getName().equals("item")) { if (element.getName().equals("item")) {
final Jid jid = element.getAttributeAsJid("jid"); final Jid jid = element.getAttributeAsJid("jid");
if (jid != null && !jid.equals(account.getServer())) { if (jid != null && !jid.equals(account.getServer())) {
items.add(jid);
}
}
}
for(Jid jid : items) {
sendServiceDiscoveryInfo(jid); sendServiceDiscoveryInfo(jid);
} }
}
}
} else { } else {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not query disco items of " + server); Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not query disco items of " + server);
} }