Search in sources :

Example 1 with DelayInformationProvider

use of org.jivesoftware.smackx.delay.provider.DelayInformationProvider in project xabber-android by redsolution.

the class ForwardedProvider method parse.

@Override
public Forwarded parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
    DelayInformationProvider delayInformationProvider = new DelayInformationProvider();
    DelayInformation delayInformation = null;
    Stanza packet = null;
    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("delay"))
                delayInformation = delayInformationProvider.parse(parser);
            else if (parser.getName().equals("message"))
                packet = PacketParserUtils.parseMessage(parser);
            else
                throw new SmackException("Unsupported forwarded packet type: " + parser.getName());
        } else if (eventType == XmlPullParser.END_TAG && parser.getName().equals(Forwarded.ELEMENT_NAME))
            done = true;
    }
    if (packet == null)
        throw new SmackException("forwarded extension must contain a packet");
    return new Forwarded(delayInformation, packet);
}
Also used : DelayInformation(org.jivesoftware.smackx.delay.packet.DelayInformation) Stanza(org.jivesoftware.smack.packet.Stanza) SmackException(org.jivesoftware.smack.SmackException) DelayInformationProvider(org.jivesoftware.smackx.delay.provider.DelayInformationProvider)

Aggregations

SmackException (org.jivesoftware.smack.SmackException)1 Stanza (org.jivesoftware.smack.packet.Stanza)1 DelayInformation (org.jivesoftware.smackx.delay.packet.DelayInformation)1 DelayInformationProvider (org.jivesoftware.smackx.delay.provider.DelayInformationProvider)1