blob: c4961c1d44e94c5402a44ae2304d073878dc8bd5 (
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
39
40
41
42
43
44
45
46
47
48
49
|
package de.thedevstack.conversationsplus.xmpp.iqversion;
import android.os.Build;
import de.thedevstack.conversationsplus.ConversationsPlusApplication;
import de.thedevstack.conversationsplus.ConversationsPlusPreferences;
import de.thedevstack.conversationsplus.xml.Element;
import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket;
import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacketGenerator;
/**
* Generates the IQ Packets for Software Version
* as defined in XEP-0092.
* @see <a href="http://xmpp.org/extensions/xep-0092.html">http://xmpp.org/extensions/xep-0092.html</a>
*/
public final class IqVersionPacketGenerator {
/**
* Generates the IqPacket to reply the software version.
* <pre>
* <iq from='juliet@capulet.com/balcony'
* type='result'
* to='romeo@montague.net/orchard'
* id='version_1'>
* <query xmlns='jabber:iq:version'>
* <name>Exodus</name>
* <version>0.7.0.4</version>
* <os>Windows-XP 5.01.2600</os>
* </query>
* </iq>
* </pre>
* @param packet the packet to respond to
* @return
*/
public static IqPacket generateResponse(IqPacket packet) {
IqPacket responsePacket = IqPacketGenerator.generateIqResultResponse(packet);
Element query = responsePacket.addChild(IqVersion.ELEMENT, IqVersion.NAMESPACE);
query.addChild("name").setContent(ConversationsPlusApplication.getName());
query.addChild("version").setContent(ConversationsPlusApplication.getVersion());
if (ConversationsPlusPreferences.sendOsInformation()) {
query.addChild("os").setContent("Android " + Build.VERSION.RELEASE);
}
return responsePacket;
}
private IqVersionPacketGenerator() {}
}
|