1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-12 14:01:08 +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

@ -40,6 +40,7 @@ import java.util.Set;
*/
public class DiscoverInfo extends IQ implements Cloneable {
public static final String ELEMENT = QUERY_ELEMENT;
public static final String NAMESPACE = "http://jabber.org/protocol/disco#info";
private final List<Feature> features = new LinkedList<Feature>();
@ -50,7 +51,7 @@ public class DiscoverInfo extends IQ implements Cloneable {
private boolean containsDuplicateFeatures;
public DiscoverInfo() {
super();
super(ELEMENT, NAMESPACE);
}
/**
@ -212,10 +213,7 @@ public class DiscoverInfo extends IQ implements Cloneable {
}
@Override
public CharSequence getChildElementXML() {
XmlStringBuilder xml = new XmlStringBuilder();
xml.halfOpenElement("query");
xml.xmlnsAttribute(NAMESPACE);
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
xml.optAttribute("node", getNode());
xml.rightAngleBracket();
for (Identity identity : identities) {
@ -224,9 +222,7 @@ public class DiscoverInfo extends IQ implements Cloneable {
for (Feature feature : features) {
xml.append(feature.toXML());
}
// Add packet extensions, if any are defined.
xml.append(getExtensionsXML());
xml.closeElement("query");
return xml;
}

View file

@ -35,11 +35,16 @@ import java.util.List;
*/
public class DiscoverItems extends IQ {
public static final String ELEMENT = QUERY_ELEMENT;
public static final String NAMESPACE = "http://jabber.org/protocol/disco#items";
private final List<Item> items = new LinkedList<Item>();
private String node;
public DiscoverItems() {
super(ELEMENT, NAMESPACE);
}
/**
* Adds a new item to the discovered information.
*
@ -97,10 +102,8 @@ public class DiscoverItems extends IQ {
this.node = node;
}
public XmlStringBuilder getChildElementXML() {
XmlStringBuilder xml = new XmlStringBuilder();
xml.halfOpenElement("query");
xml.xmlnsAttribute(NAMESPACE);
@Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
xml.optAttribute("node", getNode());
xml.rightAngleBracket();
@ -108,7 +111,6 @@ public class DiscoverItems extends IQ {
xml.append(item.toXML());
}
xml.closeElement("query");
return xml;
}