Search in sources :

Example 1 with Set

use of com.xabber.xmpp.rsm.Set 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 Set

use of com.xabber.xmpp.rsm.Set in project xabber-android by redsolution.

the class MessageArchiveManager method requestModified.

private void requestModified(String account, String before) {
    Modified packet = new Modified();
    packet.setType(Type.get);
    Set rsm = new Set();
    rsm.setMax(RSM_MAX);
    rsm.setBefore(before);
    packet.setRsm(rsm);
    packet.setStart(modificationStorages.get(account).getLastRequest());
    try {
        ConnectionManager.getInstance().sendRequest(account, packet, new OnResponseListener() {

            @Override
            public void onReceived(String account, String packetId, IQ iq) {
                if (iq instanceof Modified && ((Modified) iq).isValid())
                    onModifiedReceived(account, (Modified) iq);
                else
                    onError(account, packetId, iq);
            }

            @Override
            public void onError(String account, String packetId, IQ iq) {
                onModifiedAvailable(account);
            }

            @Override
            public void onTimeout(String account, String packetId) {
                onError(account, packetId, null);
            }

            @Override
            public void onDisconnect(String account, String packetId) {
            }
        });
    } catch (NetworkException e) {
    }
}
Also used : Modified(com.xabber.xmpp.archive.Modified) Set(com.xabber.xmpp.rsm.Set) OnResponseListener(com.xabber.android.data.connection.OnResponseListener) IQ(org.jivesoftware.smack.packet.IQ) NetworkException(com.xabber.android.data.NetworkException)

Example 3 with Set

use of com.xabber.xmpp.rsm.Set in project xabber-android by redsolution.

the class MessageArchiveManager method requestChat.

private void requestChat(String account, CollectionHeader header, String after, boolean modification) {
    Retrieve packet = new Retrieve();
    packet.setType(Type.get);
    Set rsm = new Set();
    rsm.setMax(RSM_MAX);
    rsm.setAfter(after);
    packet.setRsm(rsm);
    packet.setWith(header.getWith());
    packet.setStartString(header.getStartString());
    modificationRequests.put(account, packet.getPacketID(), modification);
    try {
        if (!modification) {
            ConnectionManager.getInstance().sendStanza(account, packet);
            return;
        }
        ConnectionManager.getInstance().sendRequest(account, packet, new OnResponseListener() {

            @Override
            public void onReceived(String account, String packetId, IQ iq) {
                if (iq instanceof Chat && ((Chat) iq).isValid())
                    onChatReceived(account, (Chat) iq);
                else
                    onError(account, packetId, iq);
            }

            @Override
            public void onError(String account, String packetId, IQ iq) {
                onModifiedAvailable(account);
            }

            @Override
            public void onTimeout(String account, String packetId) {
                onError(account, packetId, null);
            }

            @Override
            public void onDisconnect(String account, String packetId) {
            }
        });
    } catch (NetworkException e) {
    }
}
Also used : Retrieve(com.xabber.xmpp.archive.Retrieve) Set(com.xabber.xmpp.rsm.Set) OnResponseListener(com.xabber.android.data.connection.OnResponseListener) IQ(org.jivesoftware.smack.packet.IQ) AbstractChat(com.xabber.android.data.message.AbstractChat) Chat(com.xabber.xmpp.archive.Chat) NetworkException(com.xabber.android.data.NetworkException)

Aggregations

NetworkException (com.xabber.android.data.NetworkException)3 Set (com.xabber.xmpp.rsm.Set)3 OnResponseListener (com.xabber.android.data.connection.OnResponseListener)2 IQ (org.jivesoftware.smack.packet.IQ)2 AbstractChat (com.xabber.android.data.message.AbstractChat)1 Chat (com.xabber.xmpp.archive.Chat)1 List (com.xabber.xmpp.archive.List)1 Modified (com.xabber.xmpp.archive.Modified)1 Retrieve (com.xabber.xmpp.archive.Retrieve)1