Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.jabber.extensions.jingle
Class JingleIQ

java.lang.Object
  extended by org.jivesoftware.smack.packet.Packet
      extended by org.jivesoftware.smack.packet.IQ
          extended by net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.JingleIQ

public class JingleIQ
extends org.jivesoftware.smack.packet.IQ

A straightforward extension of the IQ. A JingleIQ object is created by smack via the JingleIQProvider. It contains all the information extracted from a jingle IQ.

Author:
Emil Ivov

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jivesoftware.smack.packet.IQ
org.jivesoftware.smack.packet.IQ.Type
 
Field Summary
static String ACTION_ATTR_NAME
          The name of the argument that contains the jingle action value.
static String ELEMENT_NAME
          The name of the element that contains the jingle data.
static String INITIATOR_ATTR_NAME
          The name of the argument that contains the "initiator" jid.
static String NAMESPACE
          The name space that jingle belongs to.
static String RESPONDER_ATTR_NAME
          The name of the argument that contains the "responder" jid.
static String SID_ATTR_NAME
          The name of the argument that contains the session id.
 
Fields inherited from class org.jivesoftware.smack.packet.Packet
DEFAULT_LANGUAGE, ID_NOT_AVAILABLE
 
Constructor Summary
JingleIQ()
           
 
Method Summary
 void addContent(ContentPacketExtension contentPacket)
          Adds contentPacket to this IQ's content list.
 boolean containsContentChildOfType(Class<? extends org.jivesoftware.smack.packet.PacketExtension> contentType)
          Determines if this packet contains a content with a child matching the specified contentType.
static String generateSID()
          Generates a random String usable as a jingle session ID.
 JingleAction getAction()
          Returns the value of this element's action attribute.
 String getChildElementXML()
          Returns the XML string of this Jingle IQ's "section" sub-element.
 ContentPacketExtension getContentForType(Class<? extends org.jivesoftware.smack.packet.PacketExtension> contentType)
          Determines if this packet contains a content with a child matching the specified contentType and returns it.
 List<ContentPacketExtension> getContentList()
          Returns a reference (and not a copy so be careful how you are handling it) of this element's content list.
 String getInitiator()
          Returns the full JID of the entity that has initiated the session flow.
 ReasonPacketExtension getReason()
          Returns this IQ's reason extension.
 String getResponder()
          Returns the full JID of the entity that replies to a Jingle initiation.
 SessionInfoPacketExtension getSessionInfo()
          Returns a SessionInfoPacketExtension if this JingleIQ contains one and null otherwise.
 String getSID()
          Returns this element's session ID value.
 void setAction(JingleAction action)
          Sets the value of this element's action attribute.
 void setInitiator(String initiator)
          Sets the full JID of the entity that has initiated the session flow.
 void setReason(ReasonPacketExtension reason)
          Specifies this IQ's reason extension.
 void setResponder(String responder)
          Sets the full JID of the entity that replies to a Jingle initiation.
 void setSessionInfo(SessionInfoPacketExtension si)
          Sets si as the session info extension for this packet.
 void setSID(String sid)
          Sets this element's session ID value.
 
Methods inherited from class org.jivesoftware.smack.packet.IQ
createErrorResponse, createResultIQ, getType, setType, toXML
 
Methods inherited from class org.jivesoftware.smack.packet.Packet
addExtension, deleteProperty, equals, getDefaultLanguage, getError, getExtension, getExtension, getExtensions, getExtensionsXML, getFrom, getPacketID, getProperty, getPropertyNames, getTo, getXmlns, hashCode, nextID, removeExtension, setDefaultXmlns, setError, setFrom, setPacketID, setProperty, setTo
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMESPACE

public static final String NAMESPACE
The name space that jingle belongs to.

See Also:
Constant Field Values

ELEMENT_NAME

public static final String ELEMENT_NAME
The name of the element that contains the jingle data.

See Also:
Constant Field Values

ACTION_ATTR_NAME

public static final String ACTION_ATTR_NAME
The name of the argument that contains the jingle action value.

See Also:
Constant Field Values

INITIATOR_ATTR_NAME

public static final String INITIATOR_ATTR_NAME
The name of the argument that contains the "initiator" jid.

See Also:
Constant Field Values

RESPONDER_ATTR_NAME

public static final String RESPONDER_ATTR_NAME
The name of the argument that contains the "responder" jid.

See Also:
Constant Field Values

SID_ATTR_NAME

public static final String SID_ATTR_NAME
The name of the argument that contains the session id.

See Also:
Constant Field Values
Constructor Detail

JingleIQ

public JingleIQ()
Method Detail

getChildElementXML

public String getChildElementXML()
Returns the XML string of this Jingle IQ's "section" sub-element. Extensions of this class must override this method.

Specified by:
getChildElementXML in class org.jivesoftware.smack.packet.IQ
Returns:
the child element section of the IQ XML.

setSID

public void setSID(String sid)
Sets this element's session ID value. A "sid" is a random session identifier generated by the initiator, which effectively maps to the local-part of a SIP "Call-ID" parameter.

Parameters:
sid - the session ID to set

getSID

public String getSID()
Returns this element's session ID value. A "sid" is a random session identifier generated by the initiator, which effectively maps to the local-part of a SIP "Call-ID" parameter.

Returns:
this element's session ID.

generateSID

public static String generateSID()
Generates a random String usable as a jingle session ID.

Returns:
a newly generated random sid String

setResponder

public void setResponder(String responder)
Sets the full JID of the entity that replies to a Jingle initiation. The responder can be different from the 'to' address on the IQ-set. Only present when the JingleAction is session-accept.

Parameters:
responder - the full JID of the session responder.

getResponder

public String getResponder()
Returns the full JID of the entity that replies to a Jingle initiation. The responder can be different from the 'to' address on the IQ-set. Only present when the JingleAction is session-accept.

Returns:
the full JID of the session responder

setInitiator

public void setInitiator(String initiator)
Sets the full JID of the entity that has initiated the session flow. Only present when the JingleAction is session-accept.

Parameters:
initiator - the full JID of the initiator.

getInitiator

public String getInitiator()
Returns the full JID of the entity that has initiated the session flow. Only present when the JingleAction is session-accept.

Returns:
the full JID of the initiator.

setAction

public void setAction(JingleAction action)
Sets the value of this element's action attribute. The value of the 'action' attribute MUST be one of the values enumerated here. If an entity receives a value not defined here, it MUST ignore the attribute and MUST return a bad-request error to the sender. There is no default value for the 'action' attribute.

Parameters:
action - the value of the action attribute.

getAction

public JingleAction getAction()
Returns the value of this element's action attribute. The value of the 'action' attribute MUST be one of the values enumerated here. If an entity receives a value not defined here, it MUST ignore the attribute and MUST return a bad-request error to the sender. There is no default value for the 'action' attribute.

Returns:
the value of the action attribute.

setReason

public void setReason(ReasonPacketExtension reason)
Specifies this IQ's reason extension. The reason extension in a jingle IQ provides machine and possibly human -readable information about the reason for the action.

Parameters:
reason - this IQ's reason extension.

getReason

public ReasonPacketExtension getReason()
Returns this IQ's reason extension. The reason extension in a jingle IQ provides machine and possibly human -readable information about the reason for the action.

Returns:
this IQ's reason extension.

getContentList

public List<ContentPacketExtension> getContentList()
Returns a reference (and not a copy so be careful how you are handling it) of this element's content list.

Returns:
a reference to this element's content list.

addContent

public void addContent(ContentPacketExtension contentPacket)
Adds contentPacket to this IQ's content list.

Parameters:
contentPacket - the content packet extension we'd like to add to this element's content list.

containsContentChildOfType

public boolean containsContentChildOfType(Class<? extends org.jivesoftware.smack.packet.PacketExtension> contentType)
Determines if this packet contains a content with a child matching the specified contentType. The method is meant to allow to easily determine the purpose of a jingle IQ. A telephony initiation IQ would for example contain a content element of type RtpDescriptionPacketExtension.

Parameters:
contentType - the type of the content child we are looking for.
Returns:
true if one of this IQ's content elements contains a child of the specified contentType and false otherwise.

getContentForType

public ContentPacketExtension getContentForType(Class<? extends org.jivesoftware.smack.packet.PacketExtension> contentType)
Determines if this packet contains a content with a child matching the specified contentType and returns it. Returns null otherwise. The method is meant to allow to easily extract specific IQ elements like an RTP description for example.

Parameters:
contentType - the type of the content child we are looking for.
Returns:
a reference to the content element that has a child of the specified contentType or null if no such child was found.

setSessionInfo

public void setSessionInfo(SessionInfoPacketExtension si)
Sets si as the session info extension for this packet.

Parameters:
si - a SessionInfoPacketExtension that we'd like to add here.

getSessionInfo

public SessionInfoPacketExtension getSessionInfo()
Returns a SessionInfoPacketExtension if this JingleIQ contains one and null otherwise.

Returns:
a SessionInfoPacketExtension if this JingleIQ contains one and null otherwise.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.