Search in sources :

Example 1 with Jingle

use of org.jivesoftware.smackx.jingle.element.Jingle 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 Jingle

use of org.jivesoftware.smackx.jingle.element.Jingle in project Smack by igniterealtime.

the class JingleUtil method createTransportAccept.

public Jingle createTransportAccept(FullJid recipient, FullJid initiator, String sessionId, JingleContent.Creator contentCreator, String contentName, JingleContentTransport transport) {
    Jingle.Builder jb = Jingle.builder(connection);
    jb.setAction(JingleAction.transport_accept).setInitiator(initiator).setSessionId(sessionId);
    JingleContent.Builder cb = JingleContent.getBuilder();
    cb.setCreator(contentCreator).setName(contentName).setTransport(transport);
    Jingle jingle = jb.addJingleContent(cb.build()).build();
    jingle.setTo(recipient);
    jingle.setFrom(connection.getUser());
    return jingle;
}
Also used : Jingle(org.jivesoftware.smackx.jingle.element.Jingle) JingleContent(org.jivesoftware.smackx.jingle.element.JingleContent)

Example 3 with Jingle

use of org.jivesoftware.smackx.jingle.element.Jingle in project Smack by igniterealtime.

the class JingleUtil method createTransportReplace.

public Jingle createTransportReplace(FullJid recipient, FullJid initiator, String sessionId, JingleContent.Creator contentCreator, String contentName, JingleContentTransport transport) {
    Jingle.Builder jb = Jingle.builder(connection);
    jb.setInitiator(initiator).setSessionId(sessionId).setAction(JingleAction.transport_replace);
    JingleContent.Builder cb = JingleContent.getBuilder();
    cb.setName(contentName).setCreator(contentCreator).setTransport(transport);
    Jingle jingle = jb.addJingleContent(cb.build()).build();
    jingle.setTo(recipient);
    jingle.setFrom(connection.getUser());
    return jingle;
}
Also used : Jingle(org.jivesoftware.smackx.jingle.element.Jingle) JingleContent(org.jivesoftware.smackx.jingle.element.JingleContent)

Example 4 with Jingle

use of org.jivesoftware.smackx.jingle.element.Jingle in project Smack by igniterealtime.

the class JingleUtil method createSessionInitiate.

public Jingle createSessionInitiate(FullJid recipient, String sessionId, JingleContent.Creator contentCreator, String contentName, JingleContent.Senders contentSenders, JingleContentDescription description, JingleContentTransport transport) {
    Jingle.Builder jb = Jingle.builder(connection);
    jb.setAction(JingleAction.session_initiate).setSessionId(sessionId).setInitiator(connection.getUser());
    JingleContent.Builder cb = JingleContent.getBuilder();
    cb.setCreator(contentCreator).setName(contentName).setSenders(contentSenders).setDescription(description).setTransport(transport);
    Jingle jingle = jb.addJingleContent(cb.build()).build();
    jingle.setFrom(connection.getUser());
    jingle.setTo(recipient);
    return jingle;
}
Also used : Jingle(org.jivesoftware.smackx.jingle.element.Jingle) JingleContent(org.jivesoftware.smackx.jingle.element.JingleContent)

Example 5 with Jingle

use of org.jivesoftware.smackx.jingle.element.Jingle in project Smack by igniterealtime.

the class JingleUtil method createTransportReject.

public Jingle createTransportReject(FullJid recipient, FullJid initiator, String sessionId, JingleContent.Creator contentCreator, String contentName, JingleContentTransport transport) {
    Jingle.Builder jb = Jingle.builder(connection);
    jb.setAction(JingleAction.transport_reject).setInitiator(initiator).setSessionId(sessionId);
    JingleContent.Builder cb = JingleContent.getBuilder();
    cb.setCreator(contentCreator).setName(contentName).setTransport(transport);
    Jingle jingle = jb.addJingleContent(cb.build()).build();
    jingle.setTo(recipient);
    jingle.setFrom(connection.getUser());
    return jingle;
}
Also used : Jingle(org.jivesoftware.smackx.jingle.element.Jingle) JingleContent(org.jivesoftware.smackx.jingle.element.JingleContent)

Aggregations

Jingle (org.jivesoftware.smackx.jingle.element.Jingle)19 JingleContent (org.jivesoftware.smackx.jingle.element.JingleContent)13 JingleS5BTransport (org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransport)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 EnumSource (org.junit.jupiter.params.provider.EnumSource)3 JingleReason (org.jivesoftware.smackx.jingle.element.JingleReason)2 FullJid (org.jxmpp.jid.FullJid)2 IOException (java.io.IOException)1 TimeoutException (java.util.concurrent.TimeoutException)1 SmackException (org.jivesoftware.smack.SmackException)1 XMPPException (org.jivesoftware.smack.XMPPException)1 StandardExtensionElement (org.jivesoftware.smack.packet.StandardExtensionElement)1 XmlElement (org.jivesoftware.smack.packet.XmlElement)1 Socks5BytestreamSession (org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamSession)1 Bytestream (org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream)1 JingleAction (org.jivesoftware.smackx.jingle.element.JingleAction)1 JingleContentDescription (org.jivesoftware.smackx.jingle.element.JingleContentDescription)1 JingleContentTransport (org.jivesoftware.smackx.jingle.element.JingleContentTransport)1 Test (org.junit.jupiter.api.Test)1