use of org.jivesoftware.smackx.jingle.element.JingleAction in project Smack by igniterealtime.
the class JingleProvider method parse.
@Override
public Jingle parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
Jingle.Builder builder = Jingle.builder(iqData);
String actionString = parser.getAttributeValue("", Jingle.ACTION_ATTRIBUTE_NAME);
if (actionString != null) {
JingleAction action = JingleAction.fromString(actionString);
builder.setAction(action);
}
FullJid initiator = ParserUtils.getFullJidAttribute(parser, Jingle.INITIATOR_ATTRIBUTE_NAME);
builder.setInitiator(initiator);
FullJid responder = ParserUtils.getFullJidAttribute(parser, Jingle.RESPONDER_ATTRIBUTE_NAME);
builder.setResponder(responder);
String sessionId = parser.getAttributeValue("", Jingle.SESSION_ID_ATTRIBUTE_NAME);
builder.setSessionId(sessionId);
outerloop: while (true) {
XmlPullParser.Event eventType = parser.next();
switch(eventType) {
case START_ELEMENT:
String tagName = parser.getName();
switch(tagName) {
case JingleContent.ELEMENT:
JingleContent content = parseJingleContent(parser, parser.getDepth());
builder.addJingleContent(content);
break;
case JingleReason.ELEMENT:
JingleReason reason = parseJingleReason(parser);
builder.setReason(reason);
break;
default:
LOGGER.severe("Unknown Jingle element: " + tagName);
break;
}
break;
case END_ELEMENT:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
default:
// Catch all for incomplete switch (MissingCasesInEnumSwitch) statement.
break;
}
}
return builder.build();
}
use of org.jivesoftware.smackx.jingle.element.JingleAction in project Smack by igniterealtime.
the class JingleActionTest method enumTest.
@Test
public void enumTest() {
assertEquals("content-accept", JingleAction.content_accept.toString());
assertEquals(JingleAction.content_accept, JingleAction.fromString("content-accept"));
for (JingleAction a : JingleAction.values()) {
assertEquals(a, JingleAction.fromString(a.toString()));
}
}
Aggregations