use of com.amaze.filemanager.database.models.OperationData in project AmazeFileManager by TeamAmaze.
the class UtilsHandler method addCommonBookmarks.
public void addCommonBookmarks() {
File sd = Environment.getExternalStorageDirectory();
String[] dirs = new String[] { new File(sd, Environment.DIRECTORY_DCIM).getAbsolutePath(), new File(sd, Environment.DIRECTORY_DOWNLOADS).getAbsolutePath(), new File(sd, Environment.DIRECTORY_MOVIES).getAbsolutePath(), new File(sd, Environment.DIRECTORY_MUSIC).getAbsolutePath(), new File(sd, Environment.DIRECTORY_PICTURES).getAbsolutePath() };
for (String dir : dirs) {
saveToDatabase(new OperationData(Operation.BOOKMARKS, new File(dir).getName(), dir));
}
}
use of com.amaze.filemanager.database.models.OperationData in project AmazeFileManager by TeamAmaze.
the class MainActivity method deleteConnection.
@Override
public void deleteConnection(final String name, final String path) {
int i = dataUtils.containsServer(new String[] { name, path });
if (i != -1) {
dataUtils.removeServer(i);
AppConfig.getInstance().runInBackground(() -> {
utilsHandler.removeFromDatabase(new OperationData(UtilsHandler.Operation.SMB, name, path));
});
// grid.removePath(name, path, DataUtils.SMB);
drawer.refreshDrawer();
}
}
use of com.amaze.filemanager.database.models.OperationData in project AmazeFileManager by TeamAmaze.
the class MainActivity method addConnection.
@Override
public void addConnection(boolean edit, @NonNull final String name, @NonNull final String path, @Nullable final String encryptedPath, @Nullable final String oldname, @Nullable final String oldPath) {
String[] s = new String[] { name, path };
if (!edit) {
if ((dataUtils.containsServer(path)) == -1) {
dataUtils.addServer(s);
drawer.refreshDrawer();
utilsHandler.saveToDatabase(new OperationData(UtilsHandler.Operation.SMB, name, encryptedPath));
// grid.addPath(name, encryptedPath, DataUtils.SMB, 1);
executeWithMainFragment(mainFragment -> {
mainFragment.loadlist(path, false, OpenMode.UNKNOWN);
return null;
}, true);
} else {
Snackbar.make(findViewById(R.id.navigation), getString(R.string.connection_exists), Snackbar.LENGTH_SHORT).show();
}
} else {
int i = dataUtils.containsServer(new String[] { oldname, oldPath });
if (i != -1) {
dataUtils.removeServer(i);
AppConfig.getInstance().runInBackground(() -> {
utilsHandler.renameSMB(oldname, oldPath, name, path);
});
// mainActivity.grid.removePath(oldname, oldPath, DataUtils.SMB);
}
dataUtils.addServer(s);
Collections.sort(dataUtils.getServers(), new BookSorter());
drawer.refreshDrawer();
// mainActivity.grid.addPath(name, encryptedPath, DataUtils.SMB, 1);
}
}
use of com.amaze.filemanager.database.models.OperationData in project AmazeFileManager by TeamAmaze.
the class TestUtils method saveSshConnectionSettings.
public static void saveSshConnectionSettings(@NonNull KeyPair hostKeyPair, @NonNull String validUsername, @Nullable String validPassword, @Nullable PrivateKey privateKey) {
UtilsHandler utilsHandler = AppConfig.getInstance().getUtilsHandler();
String privateKeyContents = null;
if (privateKey != null) {
StringWriter writer = new StringWriter();
JcaPEMWriter jw = new JcaPEMWriter(writer);
try {
jw.writeObject(privateKey);
jw.flush();
jw.close();
} catch (IOException shallNeverHappen) {
}
privateKeyContents = writer.toString();
}
StringBuilder fullUri = new StringBuilder().append(SSH_URI_PREFIX).append(validUsername);
if (validPassword != null)
fullUri.append(':').append(validPassword);
fullUri.append("@127.0.0.1:22222");
if (validPassword != null)
utilsHandler.saveToDatabase(new OperationData(UtilsHandler.Operation.SFTP, SshClientUtils.encryptSshPathAsNecessary(fullUri.toString()), "Test", SecurityUtils.getFingerprint(hostKeyPair.getPublic()), null, null));
else
utilsHandler.saveToDatabase(new OperationData(UtilsHandler.Operation.SFTP, SshClientUtils.encryptSshPathAsNecessary(fullUri.toString()), "Test", SecurityUtils.getFingerprint(hostKeyPair.getPublic()), "id_rsa", privateKeyContents));
shadowOf(Looper.getMainLooper()).idle();
}
use of com.amaze.filemanager.database.models.OperationData in project AmazeFileManager by TeamAmaze.
the class UtilsHandlerTest method performEncryptUriTest.
private void performEncryptUriTest(@NonNull final String origPath) {
String encryptedPath = SshClientUtils.encryptSshPathAsNecessary(origPath);
utilsHandler.saveToDatabase(new OperationData(UtilsHandler.Operation.SFTP, encryptedPath, "Test", "00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff", null, null));
await().atMost(10, TimeUnit.SECONDS).until(() -> {
List<String[]> result = utilsHandler.getSftpList();
assertEquals(1, result.size());
assertEquals("Test", result.get(0)[0]);
assertEquals(origPath, result.get(0)[1]);
assertEquals("00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff", utilsHandler.getSshHostKey(origPath));
return true;
});
}
Aggregations