Search in sources :

Example 1 with List

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

the class MessageArchiveManager method requestList.

private String requestList(String account, String bareAddress, String before) {
    List packet = new List();
    packet.setType(Type.get);
    Set rsm = new Set();
    rsm.setMax(RSM_MAX);
    rsm.setBefore(before);
    packet.setRsm(rsm);
    packet.setWith(bareAddress);
    packet.setEnd(connected.get(account));
    String packetId = packet.getPacketID();
    try {
        ConnectionManager.getInstance().sendStanza(account, packet);
    } catch (NetworkException e) {
    }
    return packetId;
}
Also used : Set(com.xabber.xmpp.rsm.Set) List(com.xabber.xmpp.archive.List) NetworkException(com.xabber.android.data.NetworkException)

Example 2 with List

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

the class MessageArchiveManager method onPacket.

@Override
public void onPacket(ConnectionItem connection, final String bareAddress, Stanza packet) {
    if (!(connection instanceof AccountItem))
        return;
    String account = ((AccountItem) connection).getAccount();
    if (AccountManager.getInstance().getArchiveMode(account) != ArchiveMode.server)
        return;
    if (bareAddress != null && !Jid.getServer(account).equals(bareAddress))
        return;
    if (!(packet instanceof IQ))
        return;
    IQ iq = (IQ) packet;
    if (iq.getType() == Type.set && packet instanceof Pref && ((Pref) packet).isValid())
        onPreferenceReceived(account, (Pref) packet);
    else if (iq.getType() == Type.set && packet instanceof ItemRemove && ((ItemRemove) packet).isValid())
        onItemRemoveReceived(account, (ItemRemove) packet);
    else if (iq.getType() == Type.set && packet instanceof SessionRemove && ((SessionRemove) packet).isValid())
        onSessionRemoveReceived(account, (SessionRemove) packet);
    else if (iq.getType() == Type.result && packet instanceof List && ((List) packet).isValid())
        onListReceived(account, (List) packet);
    else if (iq.getType() == Type.result && packet instanceof Chat && ((Chat) packet).isValid())
        onChatReceived(account, (Chat) packet);
}
Also used : AccountItem(com.xabber.android.data.account.AccountItem) Pref(com.xabber.xmpp.archive.Pref) ItemRemove(com.xabber.xmpp.archive.ItemRemove) SessionRemove(com.xabber.xmpp.archive.SessionRemove) IQ(org.jivesoftware.smack.packet.IQ) AbstractChat(com.xabber.android.data.message.AbstractChat) Chat(com.xabber.xmpp.archive.Chat) List(com.xabber.xmpp.archive.List)

Aggregations

List (com.xabber.xmpp.archive.List)2 NetworkException (com.xabber.android.data.NetworkException)1 AccountItem (com.xabber.android.data.account.AccountItem)1 AbstractChat (com.xabber.android.data.message.AbstractChat)1 Chat (com.xabber.xmpp.archive.Chat)1 ItemRemove (com.xabber.xmpp.archive.ItemRemove)1 Pref (com.xabber.xmpp.archive.Pref)1 SessionRemove (com.xabber.xmpp.archive.SessionRemove)1 Set (com.xabber.xmpp.rsm.Set)1 IQ (org.jivesoftware.smack.packet.IQ)1