include node when requesting disco features

This commit is contained in:
Daniel Gultsch 2018-04-14 18:43:11 +02:00
parent afb7c0592b
commit fa13d2336e
2 changed files with 28 additions and 17 deletions

View File

@ -44,19 +44,22 @@ public class Presence implements Comparable {
private ServiceDiscoveryResult disco;
private final String ver;
private final String hash;
private final String node;
private final String message;
private Presence(Status status, String ver, String hash, String message) {
private Presence(Status status, String ver, String hash, String node, String message) {
this.status = status;
this.ver = ver;
this.hash = hash;
this.node = node;
this.message = message;
}
public static Presence parse(String show, Element caps, String message) {
final String hash = caps == null ? null : caps.getAttribute("hash");
final String ver = caps == null ? null : caps.getAttribute("ver");
return new Presence(Status.fromShowString(show), ver, hash, message);
final String node = caps == null ? null : caps.getAttribute("node");
return new Presence(Status.fromShowString(show), ver, hash, node, message);
}
public int compareTo(Object other) {
@ -75,6 +78,10 @@ public class Presence implements Comparable {
return this.ver;
}
public String getNode() {
return this.node;
}
public String getHash() {
return this.hash;
}

View File

@ -166,6 +166,15 @@ public class XmppConnectionService extends Service {
private final IqGenerator mIqGenerator = new IqGenerator(this);
private final List<String> mInProgressAvatarFetches = new ArrayList<>();
private final HashSet<Jid> mLowPingTimeoutMode = new HashSet<>();
private final OnIqPacketReceived mDefaultIqHandler = (account, packet) -> {
if (packet.getType() != IqPacket.TYPE.RESULT) {
Element error = packet.findChild("error");
String text = error != null ? error.findChildContent("text") : null;
if (text != null) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received iq error - " + text);
}
}
};
public DatabaseBackend databaseBackend;
private ReplacingSerialSingleThreadExecutor mContactMergerExecutor = new ReplacingSerialSingleThreadExecutor(true);
private long mLastActivity = 0;
@ -188,15 +197,6 @@ public class XmppConnectionService extends Service {
private OnMessagePacketReceived mMessageParser = new MessageParser(this);
private OnPresencePacketReceived mPresenceParser = new PresenceParser(this);
private IqParser mIqParser = new IqParser(this);
private final OnIqPacketReceived mDefaultIqHandler = (account, packet) -> {
if (packet.getType() != IqPacket.TYPE.RESULT) {
Element error = packet.findChild("error");
String text = error != null ? error.findChildContent("text") : null;
if (text != null) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received iq error - " + text);
}
}
};
private MessageGenerator mMessageGenerator = new MessageGenerator(this);
public OnContactStatusChanged onContactStatusChanged = (contact, online) -> {
Conversation conversation = find(getConversations(), contact);
@ -3653,19 +3653,23 @@ public class XmppConnectionService extends Service {
account.inProgressDiscoFetches.add(key);
IqPacket request = new IqPacket(IqPacket.TYPE.GET);
request.setTo(jid);
request.query("http://jabber.org/protocol/disco#info");
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": making disco request for " + key.second + " to " + jid);
sendIqPacket(account, request, (account1, discoPacket) -> {
String node = presence.getNode();
Element query = request.query("http://jabber.org/protocol/disco#info");
if (node != null) {
query.setAttribute("node",node);
}
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": making disco request for " + key.second + " to " + jid+ "node="+node);
sendIqPacket(account, request, (a, discoPacket) -> {
if (discoPacket.getType() == IqPacket.TYPE.RESULT) {
ServiceDiscoveryResult disco1 = new ServiceDiscoveryResult(discoPacket);
if (presence.getVer().equals(disco1.getVer())) {
databaseBackend.insertDiscoveryResult(disco1);
injectServiceDiscorveryResult(account1.getRoster(), presence.getHash(), presence.getVer(), disco1);
injectServiceDiscorveryResult(a.getRoster(), presence.getHash(), presence.getVer(), disco1);
} else {
Log.d(Config.LOGTAG, account1.getJid().asBareJid() + ": mismatch in caps for contact " + jid + " " + presence.getVer() + " vs " + disco1.getVer());
Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": mismatch in caps for contact " + jid + " " + presence.getVer() + " vs " + disco1.getVer());
}
}
account1.inProgressDiscoFetches.remove(key);
a.inProgressDiscoFetches.remove(key);
});
}
}