diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/jingle/GroupPacketExtension.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/jingle/GroupPacketExtension.java new file mode 100644 index 000000000..340d6a65c --- /dev/null +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/jingle/GroupPacketExtension.java @@ -0,0 +1,116 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.impl.protocol.jabber.extensions.jingle; + +import net.java.sip.communicator.impl.protocol.jabber.extensions.*; + +import java.util.*; + +/** + * Jingle group packet extension(XEP-0338). + * + * @author Pawel Domas + */ +public class GroupPacketExtension + extends AbstractPacketExtension +{ + /** + * The name of the "group" element. + */ + public static final String ELEMENT_NAME = "group"; + + /** + * The namespace for the "group" element. + */ + public static final String NAMESPACE = "urn:xmpp:jingle:apps:grouping:0"; + + /** + * The name of the payload id SDP argument. + */ + public static final String SEMANTICS_ATTR_NAME = "semantics"; + + /** + * Name of the "bundle" semantics. + */ + public static final String SEMANTICS_BUNDLE = "BUNDLE"; + + /** + * Creates a new {@link GroupPacketExtension} instance with the proper + * element name and namespace. + */ + public GroupPacketExtension() + { + super(NAMESPACE, ELEMENT_NAME); + } + + /** + * Creates new GroupPacketExtension for BUNDLE semantics + * initialized with given contents list. + * + * @param contents the list that contains the contents to be bundled. + * + * @return new GroupPacketExtension for BUNDLE semantics + * initialized with given contents list. + */ + public static GroupPacketExtension createBundleGroup( + List contents) + { + GroupPacketExtension group = new GroupPacketExtension(); + + group.setSemantics(SEMANTICS_BUNDLE); + + group.addContents(contents); + + return group; + } + + /** + * Gets the semantics of this group. + * + * @return the semantics of this group. + */ + public String getSemantics() + { + return getAttributeAsString(SEMANTICS_ATTR_NAME); + } + + /** + * Sets the semantics of this group. + */ + public void setSemantics(String semantics) + { + this.setAttribute(SEMANTICS_ATTR_NAME, semantics); + } + + /** + * Gets the contents of this group. + * + * @return the contents of this group. + */ + public List getContents() + { + return getChildExtensionsOfType(ContentPacketExtension.class); + } + + /** + * Sets the contents of this group. For each content from given + * contentslist only it's name is being preserved. + * + * @param contents the contents of this group. + */ + public void addContents(List contents) + { + for (ContentPacketExtension content : contents) + { + ContentPacketExtension copy = new ContentPacketExtension(); + + copy.setName(content.getName()); + + addChildExtension(copy); + } + } +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/jingle/JingleIQProvider.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/jingle/JingleIQProvider.java index a0d4e45f7..b59dda23a 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/jingle/JingleIQProvider.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/jingle/JingleIQProvider.java @@ -78,6 +78,13 @@ public JingleIQProvider() new DefaultPacketExtensionProvider (CryptoPacketExtension.class)); + // provider + providerManager.addExtensionProvider( + GroupPacketExtension.ELEMENT_NAME, + GroupPacketExtension.NAMESPACE, + new DefaultPacketExtensionProvider + (GroupPacketExtension.class)); + //ice-udp transport providerManager.addExtensionProvider( IceUdpTransportPacketExtension.ELEMENT_NAME,