1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-12-14 00:51:19 +01:00

Enable PacketExtensions for IQs

This is actually only part one, i.e. with this commit if the user adds a
PacketExtension to an IQ it will be included in IQ.toXml(). Which was
previously only the case if the IQ subclass explicitly included packet
extensions.

The second part of the change is to change the IQ provider, so that
packet extensions are automatically parsed.

Cases where PacketExtensions are used for Message and IQ are slightly
changed. The IQ sublcass now only has a field with this
PacketExtension (see for example
bytestreams.ibb.packet.DataPacketExtension).

Also changed hoxt API: Removed unnecessary indirection and made the
API more Smack idiomatic.
This commit is contained in:
Florian Schmaus 2014-11-07 21:12:01 +01:00
parent a9c798f3bb
commit 9e797c1b17
93 changed files with 1347 additions and 1438 deletions

View file

@ -20,7 +20,6 @@ package org.jivesoftware.smackx.iqversion.packet;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.util.XmlStringBuilder;
/**
* A Version IQ packet, which is used by XMPP clients to discover version information
@ -49,6 +48,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
* @author Gaston Dombiak
*/
public class Version extends IQ {
public static final String ELEMENT = QUERY_ELEMENT;
public static final String NAMESPACE = "jabber:iq:version";
private final String name;
@ -56,6 +56,7 @@ public class Version extends IQ {
private String os;
public Version() {
super(ELEMENT, NAMESPACE);
name = null;
version = null;
setType(Type.get);
@ -83,6 +84,7 @@ public class Version extends IQ {
* @param os The operating system of the queried entity. This element is OPTIONAL.
*/
public Version(String name, String version, String os) {
super(ELEMENT, NAMESPACE);
if (name == null)
{
throw new IllegalArgumentException("name must not be null");
@ -141,15 +143,13 @@ public class Version extends IQ {
}
@Override
public XmlStringBuilder getChildElementXML() {
XmlStringBuilder xml = new XmlStringBuilder();
xml.halfOpenElement(IQ.QUERY_ELEMENT).xmlnsAttribute(NAMESPACE).rightAngleBracket();
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
xml.rightAngleBracket();
// Although not really optional elements, 'name' and 'version' are not set when sending a
// version request. So we must handle the case that those are 'null' here.
xml.optElement("name", name);
xml.optElement("version", version);
xml.optElement("os", os);
xml.closeElement(IQ.QUERY_ELEMENT);
return xml;
}