Search in sources :

Example 1 with Default

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

the class MessageArchiveManager method checkForDefaults.

private void checkForDefaults(String account, Default received) {
    if (received == null || !received.isUnset() || received.getSave() != SaveMode.fls)
        return;
    Default defaultItem = new Default();
    defaultItem.setExpire(received.getExpire());
    defaultItem.setOtr(received.getOtr());
    defaultItem.setSave(SaveMode.body);
    Pref pref = new Pref();
    pref.setDefault(defaultItem);
    pref.setType(Type.set);
    try {
        ConnectionManager.getInstance().sendStanza(account, pref);
    } catch (NetworkException e) {
    }
}
Also used : Pref(com.xabber.xmpp.archive.Pref) Default(com.xabber.xmpp.archive.Default) NetworkException(com.xabber.android.data.NetworkException)

Example 2 with Default

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

the class MessageArchiveManager method onPreferenceReceived.

private void onPreferenceReceived(String account, Pref pref) {
    Default defaultItem = pref.getDefault();
    if (defaultItem != null)
        defaults.put(account, new ArchivePreference(defaultItem.getOtr(), defaultItem.getSave()));
    for (Item item : pref.getItems()) {
        MatchMode matchMode;
        String value = Jid.getStringPrep(item.getJid());
        if (item.getExactmatch() != null && item.getExactmatch()) {
            matchMode = MatchMode.exect;
        } else {
            String resource = Jid.getResource(item.getJid());
            if (resource != null && !"".equals(resource))
                matchMode = MatchMode.exect;
            else {
                String name = Jid.getName(item.getJid());
                if (name != null && !"".equals(name)) {
                    matchMode = MatchMode.bare;
                    value = Jid.getBareAddress(value);
                } else {
                    matchMode = MatchMode.domain;
                    value = Jid.getServer(value);
                }
            }
            items.get(account).get(matchMode).put(value, new ArchivePreference(item.getOtr(), item.getSave()));
        }
    }
    for (Session session : pref.getSessions()) sessionSaves.put(account, session.getThread(), session.getSave());
}
Also used : AccountItem(com.xabber.android.data.account.AccountItem) Item(com.xabber.xmpp.archive.Item) MessageItem(com.xabber.android.data.message.MessageItem) ConnectionItem(com.xabber.android.data.connection.ConnectionItem) Default(com.xabber.xmpp.archive.Default) Session(com.xabber.xmpp.archive.Session)

Aggregations

Default (com.xabber.xmpp.archive.Default)2 NetworkException (com.xabber.android.data.NetworkException)1 AccountItem (com.xabber.android.data.account.AccountItem)1 ConnectionItem (com.xabber.android.data.connection.ConnectionItem)1 MessageItem (com.xabber.android.data.message.MessageItem)1 Item (com.xabber.xmpp.archive.Item)1 Pref (com.xabber.xmpp.archive.Pref)1 Session (com.xabber.xmpp.archive.Session)1