blob: 8e1fc075975325c1b8dd1d16318902b297946f7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package de.thedevstack.conversationsplus.xmpp.disco;
import de.thedevstack.conversationsplus.ConversationsPlusApplication;
import de.thedevstack.conversationsplus.xml.Element;
import de.thedevstack.conversationsplus.xmpp.jid.Jid;
import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket;
import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacketGenerator;
/**
*/
public class ServiceDiscoveryIqPacketGenerator {
public static IqPacket generateRequest(Jid jid) {
IqPacket request = IqPacketGenerator.generateIqGetPacket();
request.setTo(jid);
request.query(ServiceDiscovery.NAMESPACE);
return request;
}
public static IqPacket generateResponse(IqPacket packet) {
IqPacket responsePacket = IqPacketGenerator.generateIqResultPacket();
responsePacket.setTo(packet.getFrom());
responsePacket.setId(packet.getId());
Element query = responsePacket.addChild(ServiceDiscovery.ELEMENT, ServiceDiscovery.NAMESPACE);
query.setAttribute("node", packet.query().getAttribute("node"));
final Element identity = query.addChild("identity");
identity.setAttribute("category", "client");
identity.setAttribute("type", FeatureRegistry.IDENTITY_TYPE);
identity.setAttribute("name", ConversationsPlusApplication.getNameAndVersion());
for (final String feature : FeatureRegistry.getFeatures()) {
query.addChild("feature").setAttribute("var", feature);
}
return responsePacket;
}
}
|