Search in sources :

Example 11 with DelayInformation

use of org.jivesoftware.smackx.delay.packet.DelayInformation 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

DelayInformation (org.jivesoftware.smackx.delay.packet.DelayInformation)11 Test (org.junit.Test)7 Date (java.util.Date)6 GregorianCalendar (java.util.GregorianCalendar)4 SmackException (org.jivesoftware.smack.SmackException)3 Forwarded (org.jivesoftware.smackx.forward.packet.Forwarded)3 Message (org.jivesoftware.smack.packet.Message)2 Presence (org.jivesoftware.smack.packet.Presence)2 Stanza (org.jivesoftware.smack.packet.Stanza)2 XmlPullParser (org.xmlpull.v1.XmlPullParser)2 NetworkException (com.xabber.android.data.NetworkException)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 DelayInformationProvider (org.jivesoftware.smackx.delay.provider.DelayInformationProvider)1 ForwardedProvider (org.jivesoftware.smackx.forward.provider.ForwardedProvider)1 MamResultExtension (org.jivesoftware.smackx.mam.element.MamElements.MamResultExtension)1