aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/generator/IqGenerator.java
blob: 7b3350d4c45122e0d0c300da383f4ae0beb2a9b3 (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
package eu.siacs.conversations.generator;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xmpp.stanzas.IqPacket;

public class IqGenerator extends AbstractGenerator {

	

	public IqPacket discoResponse(IqPacket request) {
		IqPacket packet = new IqPacket(IqPacket.TYPE_RESULT);
		packet.setId(request.getId());
		packet.setTo(request.getFrom());
		Element query = packet.addChild("query","http://jabber.org/protocol/disco#info");
		query.setAttribute("node", request.query().getAttribute("node"));
		Element identity = query.addChild("identity");
		identity.setAttribute("category","client");
		identity.setAttribute("type", this.IDENTITY_TYPE);
		identity.setAttribute("name", IDENTITY_NAME);
		List<String> features = Arrays.asList(FEATURES);
		Collections.sort(features);
		for(String feature : features) {
			query.addChild("feature").setAttribute("var",feature);
		}
		return packet;
	}
}