Search in sources :

Example 1 with JingleAction

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();
}
Also used : Jingle(org.jivesoftware.smackx.jingle.element.Jingle) JingleAction(org.jivesoftware.smackx.jingle.element.JingleAction) JingleReason(org.jivesoftware.smackx.jingle.element.JingleReason) FullJid(org.jxmpp.jid.FullJid) JingleContent(org.jivesoftware.smackx.jingle.element.JingleContent)

Example 2 with JingleAction

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()));
    }
}
Also used : JingleAction(org.jivesoftware.smackx.jingle.element.JingleAction) Test(org.junit.jupiter.api.Test)

Aggregations

JingleAction (org.jivesoftware.smackx.jingle.element.JingleAction)2 Jingle (org.jivesoftware.smackx.jingle.element.Jingle)1 JingleContent (org.jivesoftware.smackx.jingle.element.JingleContent)1 JingleReason (org.jivesoftware.smackx.jingle.element.JingleReason)1 Test (org.junit.jupiter.api.Test)1 FullJid (org.jxmpp.jid.FullJid)1