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();
}
}
}
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();
}
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;
}
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;
}
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;
}
Aggregations