1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-15 07:21: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

@ -18,7 +18,6 @@ package org.jivesoftware.smackx.pubsub.packet;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.pubsub.PubSubElementType;
/**
@ -36,9 +35,11 @@ public class PubSub extends IQ
private PubSubNamespace ns = PubSubNamespace.BASIC;
public PubSub() {
super(ELEMENT, NAMESPACE);
}
public PubSub(String to, Type type) {
this();
setTo(to);
setType(type);
}
@ -119,11 +120,11 @@ public class PubSub extends IQ
*
*/
@Override
public XmlStringBuilder getChildElementXML() {
XmlStringBuilder xml = new XmlStringBuilder();
xml.halfOpenElement(getElementName()).xmlnsAttribute(getNamespace()).rightAngleBracket();
xml.append(getExtensionsXML());
xml.closeElement(getElementName());
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
// N.B. We could use SimpleIQ here, but PubSub IQs will nearly *always* have packet extensions, which means that
// SimpleIQs xml.setEmptyElement() is counter-productive in this case and we use xml.rightAngleBracket()
// instead, as there are likely sub-elements to follow.
xml.rightAngleBracket();
return xml;
}