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

@ -29,39 +29,20 @@ import org.jivesoftware.smack.packet.IQ;
*/
public class PEPPubSub extends IQ {
PEPItem item;
public static final String ELEMENT = "pubsub";
public static final String NAMESPACE = "http://jabber.org/protocol/pubsub";
private final PEPItem item;
/**
* Creates a new PubSub.
*
*/
public PEPPubSub(PEPItem item) {
super();
super(ELEMENT, NAMESPACE);
this.item = item;
}
/**
* Returns the XML element name of the extension sub-packet root element.
* Always returns "x"
*
* @return the XML element name of the packet extension.
*/
public String getElementName() {
return "pubsub";
}
/**
* Returns the XML namespace of the extension sub-packet root element.
* According the specification the namespace is always "jabber:x:roster"
* (which is not to be confused with the 'jabber:iq:roster' namespace
*
* @return the XML namespace of the packet extension.
*/
public String getNamespace() {
return "http://jabber.org/protocol/pubsub";
}
/**
* Returns the XML representation of a Personal Event Publish according the specification.
*
@ -79,14 +60,15 @@ public class PEPPubSub extends IQ {
* </pre>
*
*/
public String getChildElementXML() {
StringBuilder buf = new StringBuilder();
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append("\">");
buf.append("<publish node=\"").append(item.getNode()).append("\">");
@Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder buf) {
buf.rightAngleBracket();
buf.openElement("publish").attribute("node", item.getNode()).rightAngleBracket();
buf.append(item.toXML());
buf.append("</publish>");
buf.append("</").append(getElementName()).append(">");
return buf.toString();
buf.closeElement("publish");
return buf;
}
}