Search in sources :

Example 26 with File

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

the class IOCipherOmemoStore method isFreshInstallation.

@Override
public boolean isFreshInstallation(OmemoManager omemoManager) {
    File userDirectory = hierarchy.getUserDeviceDirectory(omemoManager);
    File[] files = userDirectory.listFiles();
    return files == null || files.length == 0;
}
Also used : File(info.guardianproject.iocipher.File)

Example 27 with File

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

the class IOCipherOmemoStore method purgeOwnDeviceKeys.

@Override
public void purgeOwnDeviceKeys(OmemoManager omemoManager) {
    File deviceDirectory = hierarchy.getUserDeviceDirectory(omemoManager);
    deleteDirectory(deviceDirectory);
}
Also used : File(info.guardianproject.iocipher.File)

Example 28 with File

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

the class IOCipherOmemoStore method removeOmemoPreKey.

@Override
public void removeOmemoPreKey(OmemoManager omemoManager, int preKeyId) {
    File preKeyPath = hierarchy.getPreKeyPath(omemoManager, preKeyId);
    preKeyPath.delete();
}
Also used : File(info.guardianproject.iocipher.File)

Example 29 with File

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

the class IOCipherOmemoStore method removeOmemoSignedPreKey.

@Override
public void removeOmemoSignedPreKey(OmemoManager omemoManager, int signedPreKeyId) {
    File signedPreKeyPath = new File(hierarchy.getSignedPreKeysDirectory(omemoManager), Integer.toString(signedPreKeyId));
    signedPreKeyPath.delete();
}
Also used : File(info.guardianproject.iocipher.File)

Example 30 with File

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

the class IOCipherOmemoStore method loadAllRawSessionsOf.

@Override
public HashMap<Integer, T_Sess> loadAllRawSessionsOf(OmemoManager omemoManager, BareJid contact) {
    File contactsDirectory = hierarchy.getContactsDir(omemoManager, contact);
    HashMap<Integer, T_Sess> sessions = new HashMap<>();
    String[] devices = contactsDirectory.list();
    for (String deviceId : devices != null ? devices : new String[0]) {
        int id;
        try {
            id = Integer.parseInt(deviceId);
        } catch (NumberFormatException e) {
            continue;
        }
        OmemoDevice device = new OmemoDevice(contact, id);
        File session = hierarchy.getContactsSessionPath(omemoManager, device);
        try {
            byte[] bytes = readBytes(session);
            if (bytes == null) {
                continue;
            }
            T_Sess s = keyUtil().rawSessionFromBytes(bytes);
            sessions.put(id, s);
        } catch (IOException e) {
        // Do nothing
        }
    }
    return sessions;
}
Also used : OmemoDevice(org.jivesoftware.smackx.omemo.internal.OmemoDevice) HashMap(java.util.HashMap) IOException(java.io.IOException) File(info.guardianproject.iocipher.File) OmemoFingerprint(org.jivesoftware.smackx.omemo.OmemoFingerprint)

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