Search in sources :

Example 1 with From

use of com.xabber.xmpp.archive.From in project xabber-android by redsolution.

the class ChatStorage method addItem.

public void addItem(AbstractChat abstractChat, Chat chat, AbstractMessage message, long offset) {
    boolean incoming = message instanceof From;
    if (message.getUtc() == null)
        timestamp = new Date(timestamp.getTime() + message.getSecs() * 1000);
    else
        timestamp = message.getUtc();
    String body = message.getBody();
    net.java.otr4j.io.messages.AbstractMessage otrMessage;
    try {
        otrMessage = SerializationUtils.toMessage(body);
    } catch (IOException e) {
        return;
    }
    if (otrMessage != null) {
        if (otrMessage.messageType != net.java.otr4j.io.messages.AbstractMessage.MESSAGE_PLAINTEXT)
            return;
        body = ((PlainTextMessage) otrMessage).cleanText;
    }
    MessageItem messageItem = new MessageItem(abstractChat, chat.getStartString(), Jid.getResource(chat.getWith()), body, null, new Date(timestamp.getTime() - offset), null, incoming, true, true, false, true, false, false);
    items.add(messageItem);
}
Also used : MessageItem(com.xabber.android.data.message.MessageItem) From(com.xabber.xmpp.archive.From) IOException(java.io.IOException) Date(java.util.Date)

Aggregations

MessageItem (com.xabber.android.data.message.MessageItem)1 From (com.xabber.xmpp.archive.From)1 IOException (java.io.IOException)1 Date (java.util.Date)1