use of com.xabber.xmpp.archive.AbstractMessage in project xabber-android by redsolution.
the class MessageArchiveManager method onChatReceived.
private void onChatReceived(String account, Chat chat) {
Boolean modification = modificationRequests.remove(account, chat.getPacketID());
if (modification == null)
return;
ChatStorage chatStorage = chatStorages.get(account, chat.getWith(), chat.getStartString());
if (chatStorage == null) {
LogManager.w(this, "Unexpected chat " + chat.getStartString() + " recevied by " + account + " from " + chat.getWith());
chatStorage = new ChatStorage(chat.getStart());
chatStorages.put(account, chat.getWith(), chat.getStartString(), chatStorage);
}
String bareAddress = Jid.getBareAddress(chat.getWith());
HeaderSequence sequence;
if (modification)
sequence = modificationStorages.get(account);
else
sequence = historyStorages.get(account, bareAddress);
if (sequence == null)
return;
AbstractChat abstractChat = MessageManager.getInstance().getOrCreateChat(account, bareAddress);
for (AbstractMessage abstractMessage : chat.getMessages()) chatStorage.addItem(abstractChat, chat, abstractMessage, TimeManager.getInstance().getServerTimeOffset(account));
if (chat.getRsm() == null || chat.getRsm().isForwardFinished(chat.getMessages().size())) {
chatStorage.onItemsReceived(chat.getVersion());
sequence.pollHeader();
if (sequence instanceof HistoryStorage)
if (apply(account, bareAddress, chat.getStartString(), chatStorage, (HistoryStorage) sequence))
return;
requestSequence(account, bareAddress, sequence);
} else {
requestChat(account, chat, chat.getRsm().getLast(), modification);
}
}
Aggregations