Search in sources :

Example 1 with File

use of info.guardianproject.iocipher.File in project Zom-Android by zom.

the class IOCipherOmemoStore method deleteDirectory.

public static void deleteDirectory(File root) {
    File[] currList;
    Stack<File> stack = new Stack<>();
    stack.push(root);
    while (!stack.isEmpty()) {
        if (stack.lastElement().isDirectory()) {
            currList = stack.lastElement().listFiles();
            if (currList != null && currList.length > 0) {
                for (File curr : currList) {
                    stack.push(curr);
                }
            } else {
                stack.pop().delete();
            }
        } else {
            stack.pop().delete();
        }
    }
}
Also used : File(info.guardianproject.iocipher.File) Stack(java.util.Stack)

Example 2 with File

use of info.guardianproject.iocipher.File in project Zom-Android by zom.

the class IOCipherOmemoStore method removeRawSession.

@Override
public void removeRawSession(OmemoManager omemoManager, OmemoDevice device) {
    File sessionPath = hierarchy.getContactsSessionPath(omemoManager, device);
    sessionPath.delete();
}
Also used : File(info.guardianproject.iocipher.File)

Example 3 with File

use of info.guardianproject.iocipher.File in project Zom-Android by zom.

the class IOCipherOmemoStore method loadOmemoSignedPreKeys.

@Override
public HashMap<Integer, T_SigPreKey> loadOmemoSignedPreKeys(OmemoManager omemoManager) {
    File signedPreKeysDirectory = hierarchy.getSignedPreKeysDirectory(omemoManager);
    HashMap<Integer, T_SigPreKey> signedPreKeys = new HashMap<>();
    if (signedPreKeysDirectory == null) {
        return signedPreKeys;
    }
    File[] keys = signedPreKeysDirectory.listFiles();
    for (File f : keys != null ? keys : new File[0]) {
        try {
            byte[] bytes = readBytes(f);
            if (bytes == null) {
                continue;
            }
            T_SigPreKey p = keyUtil().signedPreKeyFromBytes(bytes);
            signedPreKeys.put(Integer.parseInt(f.getName()), p);
        } catch (IOException e) {
        // Do nothing
        }
    }
    return signedPreKeys;
}
Also used : HashMap(java.util.HashMap) IOException(java.io.IOException) File(info.guardianproject.iocipher.File)

Example 4 with File

use of info.guardianproject.iocipher.File 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 5 with File

use of info.guardianproject.iocipher.File in project Zom-Android by zom.

the class IOCipherOmemoStore method loadOmemoPreKeys.

@Override
public HashMap<Integer, T_PreKey> loadOmemoPreKeys(OmemoManager omemoManager) {
    File preKeyDirectory = hierarchy.getPreKeysDirectory(omemoManager);
    HashMap<Integer, T_PreKey> preKeys = new HashMap<>();
    if (preKeyDirectory == null) {
        return preKeys;
    }
    File[] keys = preKeyDirectory.listFiles();
    for (File f : keys != null ? keys : new File[0]) {
        try {
            byte[] bytes = readBytes(f);
            if (bytes == null) {
                continue;
            }
            T_PreKey p = keyUtil().preKeyFromBytes(bytes);
            preKeys.put(Integer.parseInt(f.getName()), p);
        } catch (IOException e) {
        // Do nothing
        }
    }
    return preKeys;
}
Also used : HashMap(java.util.HashMap) IOException(java.io.IOException) File(info.guardianproject.iocipher.File)

Aggregations

File (info.guardianproject.iocipher.File)32 IOException (java.io.IOException)14 FileOutputStream (info.guardianproject.iocipher.FileOutputStream)6 FileInputStream (info.guardianproject.iocipher.FileInputStream)5 FileNotFoundException (java.io.FileNotFoundException)5 Bitmap (android.graphics.Bitmap)4 Uri (android.net.Uri)4 HashMap (java.util.HashMap)4 RemoteException (android.os.RemoteException)3 RandomAccessFile (info.guardianproject.iocipher.RandomAccessFile)3 BitmapFactory (android.graphics.BitmapFactory)2 MediaDataSource (android.media.MediaDataSource)2 MediaPlayer (android.media.MediaPlayer)2 HttpRequest (cz.msebera.android.httpclient.HttpRequest)2 BasicHttpRequest (cz.msebera.android.httpclient.message.BasicHttpRequest)2 InputStream (java.io.InputStream)2 HttpMediaStreamer (org.awesomeapp.messenger.util.HttpMediaStreamer)2 OmemoFingerprint (org.jivesoftware.smackx.omemo.OmemoFingerprint)2 OmemoDevice (org.jivesoftware.smackx.omemo.internal.OmemoDevice)2 XmppStringprepException (org.jxmpp.stringprep.XmppStringprepException)2