Search in sources :

Example 1 with CachedDeviceList

use of org.jivesoftware.smackx.omemo.internal.CachedDeviceList in project Zom-Android by zom.

the class IOCipherOmemoStore method loadCachedDeviceList.

@Override
public CachedDeviceList loadCachedDeviceList(OmemoManager omemoManager, BareJid contact) {
    CachedDeviceList cachedDeviceList = new CachedDeviceList();
    if (contact == null) {
        return null;
    }
    // active
    File activeDevicesPath = hierarchy.getContactsActiveDevicesPath(omemoManager, contact);
    try {
        cachedDeviceList.getActiveDevices().addAll(readIntegers(activeDevicesPath));
    } catch (IOException e) {
    // Don't worry...
    }
    // inactive
    File inactiveDevicesPath = hierarchy.getContactsInactiveDevicesPath(omemoManager, contact);
    try {
        cachedDeviceList.getInactiveDevices().addAll(readIntegers(inactiveDevicesPath));
    } catch (IOException e) {
    // It's ok :)
    }
    return cachedDeviceList;
}
Also used : IOException(java.io.IOException) CachedDeviceList(org.jivesoftware.smackx.omemo.internal.CachedDeviceList) File(info.guardianproject.iocipher.File)

Example 2 with CachedDeviceList

use of org.jivesoftware.smackx.omemo.internal.CachedDeviceList in project Zom-Android by zom.

the class Omemo method getFingerprints.

public ArrayList<String> getFingerprints(BareJid jid, boolean autoload) throws CorruptedOmemoKeyException, SmackException, XMPPException.XMPPErrorException, InterruptedException {
    try {
        mOmemoManager.buildSessionsWith(jid);
    } catch (CannotEstablishOmemoSessionException e) {
        debug(TAG, "couldn't establish omemo session: " + e);
    }
    CachedDeviceList list = mOmemoStore.loadCachedDeviceList(mOmemoManager, jid);
    if (list == null) {
        list = new CachedDeviceList();
    }
    ArrayList<String> fps = new ArrayList<>();
    for (int id : list.getActiveDevices()) {
        OmemoDevice d = new OmemoDevice(jid, id);
        IdentityKey idk = (IdentityKey) mOmemoStore.loadOmemoIdentityKey(mOmemoManager, d);
        if (idk == null) {
            System.out.println("No identityKey for " + d);
        } else {
            fps.add(mOmemoStore.keyUtil().getFingerprint(idk).toString());
        }
    }
    return fps;
}
Also used : IdentityKey(org.whispersystems.libsignal.IdentityKey) OmemoDevice(org.jivesoftware.smackx.omemo.internal.OmemoDevice) ArrayList(java.util.ArrayList) CachedDeviceList(org.jivesoftware.smackx.omemo.internal.CachedDeviceList) OmemoFingerprint(org.jivesoftware.smackx.omemo.OmemoFingerprint) CannotEstablishOmemoSessionException(org.jivesoftware.smackx.omemo.exceptions.CannotEstablishOmemoSessionException)

Aggregations

CachedDeviceList (org.jivesoftware.smackx.omemo.internal.CachedDeviceList)2 File (info.guardianproject.iocipher.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 OmemoFingerprint (org.jivesoftware.smackx.omemo.OmemoFingerprint)1 CannotEstablishOmemoSessionException (org.jivesoftware.smackx.omemo.exceptions.CannotEstablishOmemoSessionException)1 OmemoDevice (org.jivesoftware.smackx.omemo.internal.OmemoDevice)1 IdentityKey (org.whispersystems.libsignal.IdentityKey)1