Adds a 'recording' element to a Colibri IQ.

fix-message-formatting
Boris Grozev 12 years ago
parent d0decfda96
commit 2d4cc999cc

@ -59,6 +59,11 @@ public class ColibriConferenceIQ
*/
private String id;
/**
* Media recording.
*/
public Recording recording = null;
/** Initializes a new <tt>ColibriConferenceIQ</tt> instance. */
public ColibriConferenceIQ()
{
@ -121,7 +126,11 @@ public String getChildElementXML()
List<Content> contents = getContents();
if (contents.size() == 0)
int childrenCount = contents.size();
if (recording != null)
childrenCount++;
if (childrenCount == 0)
{
xml.append(" />");
}
@ -130,6 +139,8 @@ public String getChildElementXML()
xml.append('>');
for (Content content : contents)
content.toXML(xml);
if (recording != null)
recording.toXML(xml);
xml.append("</").append(ELEMENT_NAME).append('>');
}
return xml.toString();
@ -175,6 +186,24 @@ public String getID()
return id;
}
/**
* Gets the value of the recording field.
* @return the value of the recording field.
*/
public Recording getRecording()
{
return recording;
}
/**
* Sets the recording field.
* @param recording the value to set.
*/
public void setRecording(Recording recording)
{
this.recording = recording;
}
/**
* Returns a <tt>Content</tt> from the list of <tt>Content</tt>s of this
* <tt>conference</tt> IQ which has a specific name. If no such
@ -1002,7 +1031,8 @@ public void setRTCPPort(int rtcpPort)
* section 2.3 &quot;Mixers and Translators&quot;) used for this
* <tt>Channel</tt>.
*
* @param s the type of RTP-level relay used for this <tt>Channel</tt>
* @param rtpLevelRelayType the type of RTP-level relay used for
* this <tt>Channel</tt>
*/
public void setRTPLevelRelayType(RTPLevelRelayType rtpLevelRelayType)
{
@ -1487,4 +1517,63 @@ protected void printContent(StringBuilder xml)
// No other content than the transport shared from ChannelCommon
}
}
/**
* Represents a <tt>recording</tt> element.
*/
public static class Recording
{
/**
* The XML name of the <tt>recording</tt> element.
*/
public static final String ELEMENT_NAME = "recording";
/**
* The XML name of the <tt>state</tt> attribute.
*/
public static final String STATE_ATTR_NAME = "state";
/**
* The XML name of the <tt>token</tt> attribute.
*/
public static final String TOKEN_ATTR_NAME = "token";
private String token = null;
private boolean state;
public Recording(boolean state)
{
this.state = state;
}
public Recording(boolean state, String token)
{
this(state);
this.token = token;
}
public String getToken()
{
return token;
}
public boolean getState()
{
return state;
}
public void toXML(StringBuilder xml)
{
xml.append('<').append(ELEMENT_NAME);
xml.append(' ').append(STATE_ATTR_NAME).append("='")
.append(state).append('\'');
if (token != null)
{
xml.append(' ').append(TOKEN_ATTR_NAME).append("='")
.append(token).append('\'');
}
xml.append("/>");
}
}
}

@ -160,6 +160,7 @@ public IQ parseIQ(XmlPullParser parser)
ColibriConferenceIQ.Channel channel = null;
ColibriConferenceIQ.SctpConnection sctpConnection = null;
ColibriConferenceIQ.Content content = null;
ColibriConferenceIQ.Recording recording = null;
StringBuilder ssrc = null;
while (!done)
@ -214,6 +215,12 @@ else if (ColibriConferenceIQ.Content.ELEMENT_NAME.equals(
conference.addContent(content);
content = null;
}
else if (ColibriConferenceIQ.Recording.ELEMENT_NAME.equals(
name))
{
conference.setRecording(recording);
recording = null;
}
break;
}
@ -348,6 +355,25 @@ else if (ColibriConferenceIQ.Content.ELEMENT_NAME.equals(
&& (contentName.length() != 0))
content.setName(contentName);
}
else if (ColibriConferenceIQ.Recording.ELEMENT_NAME.equals(
name))
{
String stateStr
= parser.getAttributeValue(
"",
ColibriConferenceIQ.Recording.STATE_ATTR_NAME);
boolean state = Boolean.parseBoolean(stateStr);
String token
= parser.getAttributeValue(
"",
ColibriConferenceIQ.Recording.TOKEN_ATTR_NAME);
recording
= new ColibriConferenceIQ.Recording(
state,
token);
}
else if (ColibriConferenceIQ.SctpConnection.ELEMENT_NAME
.equals(name))
{

@ -0,0 +1,84 @@
/*
* 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.colibri;
import net.java.sip.communicator.impl.protocol.jabber.extensions.*;
/**
* Implements <tt>AbstractPacketExtension</tt> for a "recording" element.
*
* @author Boris Grozev
*/
public class RecordingPacketExtension
extends AbstractPacketExtension
{
/**
* The XML name of the <tt>recording</tt> element.
*/
public static final String ELEMENT_NAME = "recording";
/**
* The XML name of the <tt>state</tt> attribute.
*/
private static final String STATE_ATTR_NAME = "state";
/**
* The XML name of the <tt>token</tt> attribute.
*/
private static final String TOKEN_ATTR_NAME = "token";
/**
* Initializes a new <tt>RecordingPacketExtension</tt> instance.
*/
public RecordingPacketExtension()
{
super(ColibriConferenceIQ.NAMESPACE, ELEMENT_NAME);
}
public String getToken()
{
return getAttributeAsString(TOKEN_ATTR_NAME);
}
public void setToken(String token)
{
setAttribute(TOKEN_ATTR_NAME, token);
}
public State getState()
{
return State.parseString(getAttributeAsString(STATE_ATTR_NAME));
}
public void setState(State state)
{
setAttribute(STATE_ATTR_NAME, state.toString());
}
private enum State
{
ON("on"),
OFF("off");
private String name;
private State(String name)
{
this.name = name;
}
public String toString()
{
return name;
}
public static State parseString(String s)
{
if (ON.toString().equalsIgnoreCase(s))
return ON;
return OFF;
}
}
}
Loading…
Cancel
Save