Search in sources :

Example 1 with AbstractStanza

use of de.pixart.messenger.xmpp.stanzas.AbstractStanza in project Pix-Art-Messenger by kriztan.

the class AbstractParser method parseTimestamp.

public static Long parseTimestamp(Element element, Long d, boolean ignoreCsiAndSm) {
    long min = Long.MAX_VALUE;
    boolean returnDefault = true;
    final Jid to;
    if (ignoreCsiAndSm && element instanceof AbstractStanza) {
        to = ((AbstractStanza) element).getTo();
    } else {
        to = null;
    }
    for (Element child : element.getChildren()) {
        if ("delay".equals(child.getName()) && "urn:xmpp:delay".equals(child.getNamespace())) {
            final Jid f = to == null ? null : child.getAttributeAsJid("from");
            if (f != null && (to.toBareJid().equals(f) || to.getDomainpart().equals(f.toString()))) {
                continue;
            }
            final String stamp = child.getAttribute("stamp");
            if (stamp != null) {
                try {
                    min = Math.min(min, AbstractParser.parseTimestamp(stamp));
                    returnDefault = false;
                } catch (Throwable t) {
                // ignore
                }
            }
        }
    }
    if (returnDefault) {
        return d;
    } else {
        return min;
    }
}
Also used : Jid(de.pixart.messenger.xmpp.jid.Jid) AbstractStanza(de.pixart.messenger.xmpp.stanzas.AbstractStanza) Element(de.pixart.messenger.xml.Element)

Aggregations

Element (de.pixart.messenger.xml.Element)1 Jid (de.pixart.messenger.xmpp.jid.Jid)1 AbstractStanza (de.pixart.messenger.xmpp.stanzas.AbstractStanza)1