1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 09:09:38 +02: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

@ -93,6 +93,7 @@ public class RTPBridge extends IQ {
* @param sid
*/
public RTPBridge(String sid) {
this();
this.sid = sid;
}
@ -102,6 +103,7 @@ public class RTPBridge extends IQ {
* @param action
*/
public RTPBridge(BridgeAction action) {
this();
this.bridgeAction = action;
}
@ -112,6 +114,7 @@ public class RTPBridge extends IQ {
* @param bridgeAction
*/
public RTPBridge(String sid, BridgeAction bridgeAction) {
this();
this.sid = sid;
this.bridgeAction = bridgeAction;
}
@ -120,6 +123,7 @@ public class RTPBridge extends IQ {
* Creates a RTPBridge Packet without Session ID
*/
public RTPBridge() {
super(ELEMENT_NAME, NAMESPACE);
}
/**
@ -298,9 +302,9 @@ public class RTPBridge extends IQ {
*
* @return the Child Element XML of the Packet
*/
public String getChildElementXML() {
StringBuilder str = new StringBuilder();
str.append("<" + ELEMENT_NAME + " xmlns='" + NAMESPACE + "' sid='").append(sid).append("'>");
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder str) {
str.attribute("sid", sid);
str.rightAngleBracket();
if (bridgeAction.equals(BridgeAction.create))
str.append("<candidate/>");
@ -309,8 +313,7 @@ public class RTPBridge extends IQ {
else
str.append("<publicip ").append(getAttributes()).append(" />");
str.append("</" + ELEMENT_NAME + ">");
return str.toString();
return str;
}
/**

View file

@ -26,7 +26,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.SimpleIQ;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.provider.ProviderManager;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
@ -44,7 +44,7 @@ import org.xmlpull.v1.XmlPullParserException;
*
* @author Thiago Camargo
*/
public class STUN extends IQ {
public class STUN extends SimpleIQ {
private static final Logger LOGGER = Logger.getLogger(STUN.class.getName());
@ -75,6 +75,7 @@ public class STUN extends IQ {
* Creates a STUN IQ
*/
public STUN() {
super(ELEMENT_NAME, NAMESPACE);
}
/**
@ -104,17 +105,6 @@ public class STUN extends IQ {
this.publicIp = publicIp;
}
/**
* Get the Child Element XML of the Packet
*
* @return the child element XML
*/
public String getChildElementXML() {
StringBuilder str = new StringBuilder();
str.append("<" + ELEMENT_NAME + " xmlns='" + NAMESPACE + "'/>");
return str.toString();
}
/**
* IQProvider for RTP Bridge packets.
* Parse receive RTPBridge packet to a RTPBridge instance

View file

@ -66,7 +66,7 @@ public class Jingle extends IQ {
*/
public Jingle(final List<JingleContent> contents, final JingleContentInfo mi,
final String sid) {
super();
this();
if (contents != null) {
contents.addAll(contents);
@ -87,7 +87,7 @@ public class Jingle extends IQ {
* @param content a content
*/
public Jingle(final JingleContent content) {
super();
this();
addContent(content);
@ -106,7 +106,7 @@ public class Jingle extends IQ {
* @param info The content info
*/
public Jingle(final JingleContentInfo info) {
super();
this();
setContentInfo(info);
@ -146,7 +146,7 @@ public class Jingle extends IQ {
* The default constructor
*/
public Jingle() {
super();
super(NODENAME, NAMESPACE);
}
/**
@ -338,11 +338,7 @@ public class Jingle extends IQ {
*
* @return the XML string
*/
public String getChildElementXML() {
StringBuilder buf = new StringBuilder();
buf.append("<").append(getElementName());
buf.append(" xmlns=\"").append(getNamespace()).append("\"");
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder buf) {
if (getInitiator() != null) {
buf.append(" initiator=\"").append(getInitiator()).append("\"");
}
@ -350,7 +346,7 @@ public class Jingle extends IQ {
buf.append(" responder=\"").append(getResponder()).append("\"");
}
if (getAction() != null) {
buf.append(" action=\"").append(getAction()).append("\"");
buf.append(" action=\"").append(getAction().name()).append("\"");
}
if (getSid() != null) {
buf.append(" sid=\"").append(getSid()).append("\"");
@ -368,7 +364,6 @@ public class Jingle extends IQ {
buf.append(contentInfo.toXML());
}
buf.append("</").append(getElementName()).append(">");
return buf.toString();
return buf;
}
}