mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Finish database encapsulation
This commit is contained in:
@@ -19,8 +19,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.kunzisoft.keepass.tests.database;
|
package com.kunzisoft.keepass.tests.database;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@@ -30,6 +28,8 @@ import com.kunzisoft.keepass.database.element.PwDatabaseV3Debug;
|
|||||||
import com.kunzisoft.keepass.database.load.Importer;
|
import com.kunzisoft.keepass.database.load.Importer;
|
||||||
import com.kunzisoft.keepass.tests.TestUtil;
|
import com.kunzisoft.keepass.tests.TestUtil;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
public class TestData {
|
public class TestData {
|
||||||
private static final String TEST1_KEYFILE = "";
|
private static final String TEST1_KEYFILE = "";
|
||||||
private static final String TEST1_KDB = "test1.kdb";
|
private static final String TEST1_KDB = "test1.kdb";
|
||||||
@@ -72,6 +72,7 @@ public class TestData {
|
|||||||
GetDb1(ctx);
|
GetDb1(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (PwDatabaseV3Debug) mDb1.getPwDatabase();
|
//return (PwDatabaseV3Debug) mDb1.getPwDatabase();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class EntryActivity extends LockingHideActivity {
|
|||||||
PwNodeId keyEntry;
|
PwNodeId keyEntry;
|
||||||
try {
|
try {
|
||||||
keyEntry = i.getParcelableExtra(KEY_ENTRY);
|
keyEntry = i.getParcelableExtra(KEY_ENTRY);
|
||||||
mEntry = db.getPwDatabase().getEntryById(keyEntry);
|
mEntry = db.getEntryById(keyEntry);
|
||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
Log.e(TAG, "Unable to retrieve the entry key");
|
Log.e(TAG, "Unable to retrieve the entry key");
|
||||||
}
|
}
|
||||||
@@ -157,8 +157,7 @@ public class EntryActivity extends LockingHideActivity {
|
|||||||
|
|
||||||
Database database = App.getDB();
|
Database database = App.getDB();
|
||||||
// Start to manage field reference to copy a value from ref
|
// Start to manage field reference to copy a value from ref
|
||||||
if (database != null)
|
database.startManageEntry(mEntry);
|
||||||
database.startManageEntry(mEntry);
|
|
||||||
|
|
||||||
boolean containsUsernameToCopy =
|
boolean containsUsernameToCopy =
|
||||||
mEntry.getUsername().length() > 0;
|
mEntry.getUsername().length() > 0;
|
||||||
@@ -234,8 +233,7 @@ public class EntryActivity extends LockingHideActivity {
|
|||||||
startService(intent);
|
startService(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (database != null)
|
database.stopManageEntry(mEntry);
|
||||||
database.stopManageEntry(mEntry);
|
|
||||||
}
|
}
|
||||||
firstLaunchOfActivity = false;
|
firstLaunchOfActivity = false;
|
||||||
}
|
}
|
||||||
@@ -315,11 +313,9 @@ public class EntryActivity extends LockingHideActivity {
|
|||||||
|
|
||||||
protected void fillData() {
|
protected void fillData() {
|
||||||
Database database = App.getDB();
|
Database database = App.getDB();
|
||||||
if (database != null) {
|
database.startManageEntry(mEntry);
|
||||||
database.startManageEntry(mEntry);
|
// Assign title icon
|
||||||
// Assign title icon
|
database.getDrawFactory().assignDatabaseIconTo(this, titleIconView, mEntry.getIcon(), iconColor);
|
||||||
database.getDrawFactory().assignDatabaseIconTo(this, titleIconView, mEntry.getIcon(), iconColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assign title text
|
// Assign title text
|
||||||
titleView.setText(PwEntryInterface.getVisualTitle(mEntry));
|
titleView.setText(PwEntryInterface.getVisualTitle(mEntry));
|
||||||
@@ -397,8 +393,7 @@ public class EntryActivity extends LockingHideActivity {
|
|||||||
entryContentsView.assignExpiresDate(getString(R.string.never));
|
entryContentsView.assignExpiresDate(getString(R.string.never));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (database != null)
|
database.stopManageEntry(mEntry);
|
||||||
database.stopManageEntry(mEntry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -420,10 +420,8 @@ public class EntryEditActivity extends LockingHideActivity
|
|||||||
|
|
||||||
PwEntryInterface newEntry = mEntry.duplicate();
|
PwEntryInterface newEntry = mEntry.duplicate();
|
||||||
|
|
||||||
if (database != null) {
|
database.startManageEntry(newEntry);
|
||||||
database.startManageEntry(newEntry);
|
database.createBackupOf(newEntry);
|
||||||
database.createBackupOf(newEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
newEntry.setLastAccessTime(new PwDate());
|
newEntry.setLastAccessTime(new PwDate());
|
||||||
newEntry.setLastModificationTime(new PwDate());
|
newEntry.setLastModificationTime(new PwDate());
|
||||||
@@ -449,8 +447,7 @@ public class EntryEditActivity extends LockingHideActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (database != null)
|
database.stopManageEntry(newEntry);
|
||||||
database.stopManageEntry(newEntry);
|
|
||||||
|
|
||||||
return newEntry;
|
return newEntry;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,11 +72,10 @@ import com.kunzisoft.keepass.database.action.node.MoveEntryRunnable;
|
|||||||
import com.kunzisoft.keepass.database.action.node.MoveGroupRunnable;
|
import com.kunzisoft.keepass.database.action.node.MoveGroupRunnable;
|
||||||
import com.kunzisoft.keepass.database.action.node.UpdateGroupRunnable;
|
import com.kunzisoft.keepass.database.action.node.UpdateGroupRunnable;
|
||||||
import com.kunzisoft.keepass.database.element.Database;
|
import com.kunzisoft.keepass.database.element.Database;
|
||||||
import com.kunzisoft.keepass.database.element.PwDatabase;
|
|
||||||
import com.kunzisoft.keepass.database.element.PwEntryInterface;
|
import com.kunzisoft.keepass.database.element.PwEntryInterface;
|
||||||
import com.kunzisoft.keepass.database.element.PwNodeId;
|
|
||||||
import com.kunzisoft.keepass.database.element.PwGroupInterface;
|
import com.kunzisoft.keepass.database.element.PwGroupInterface;
|
||||||
import com.kunzisoft.keepass.database.element.PwIcon;
|
import com.kunzisoft.keepass.database.element.PwIcon;
|
||||||
|
import com.kunzisoft.keepass.database.element.PwNodeId;
|
||||||
import com.kunzisoft.keepass.database.element.PwNodeInterface;
|
import com.kunzisoft.keepass.database.element.PwNodeInterface;
|
||||||
import com.kunzisoft.keepass.dialogs.AssignMasterKeyDialogFragment;
|
import com.kunzisoft.keepass.dialogs.AssignMasterKeyDialogFragment;
|
||||||
import com.kunzisoft.keepass.dialogs.GroupEditDialogFragment;
|
import com.kunzisoft.keepass.dialogs.GroupEditDialogFragment;
|
||||||
@@ -242,7 +241,7 @@ public class GroupActivity extends LockingActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
rootGroup = database.getPwDatabase().getRootGroup();
|
rootGroup = database.getRootGroup();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
Log.e(TAG, "Unable to get rootGroup");
|
Log.e(TAG, "Unable to get rootGroup");
|
||||||
}
|
}
|
||||||
@@ -400,7 +399,7 @@ public class GroupActivity extends LockingActivity
|
|||||||
if (pwGroupId == null) {
|
if (pwGroupId == null) {
|
||||||
currentGroup = rootGroup;
|
currentGroup = rootGroup;
|
||||||
} else {
|
} else {
|
||||||
currentGroup = database.getPwDatabase().getGroupById(pwGroupId);
|
currentGroup = database.getGroupById(pwGroupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return currentGroup;
|
return currentGroup;
|
||||||
@@ -1058,10 +1057,9 @@ public class GroupActivity extends LockingActivity
|
|||||||
|
|
||||||
if (actionNodeValues.getOldNode() != null) {
|
if (actionNodeValues.getOldNode() != null) {
|
||||||
PwGroupInterface parent = actionNodeValues.getOldNode().getParent();
|
PwGroupInterface parent = actionNodeValues.getOldNode().getParent();
|
||||||
Database db = App.getDB();
|
Database database = App.getDB();
|
||||||
PwDatabase database = db.getPwDatabase();
|
if (database.isRecycleBinAvailable() &&
|
||||||
if (db.isRecycleBinAvailable() &&
|
database.isRecycleBinEnabled()) {
|
||||||
db.isRecycleBinEnabled()) {
|
|
||||||
PwGroupInterface recycleBin = database.getRecycleBin();
|
PwGroupInterface recycleBin = database.getRecycleBin();
|
||||||
// Add trash if it doesn't exists
|
// Add trash if it doesn't exists
|
||||||
if (parent.equals(recycleBin)
|
if (parent.equals(recycleBin)
|
||||||
@@ -1126,7 +1124,7 @@ public class GroupActivity extends LockingActivity
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
// Show the progress dialog now or after dialog confirmation
|
// Show the progress dialog now or after dialog confirmation
|
||||||
if (database.getPwDatabase().validatePasswordEncoding(masterPassword)) {
|
if (database.validatePasswordEncoding(masterPassword)) {
|
||||||
taskThread.start();
|
taskThread.start();
|
||||||
} else {
|
} else {
|
||||||
new PasswordEncodingDialogHelper()
|
new PasswordEncodingDialogHelper()
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ import android.view.ViewGroup;
|
|||||||
|
|
||||||
import com.kunzisoft.keepass.R;
|
import com.kunzisoft.keepass.R;
|
||||||
import com.kunzisoft.keepass.adapters.NodeAdapter;
|
import com.kunzisoft.keepass.adapters.NodeAdapter;
|
||||||
import com.kunzisoft.keepass.app.App;
|
|
||||||
import com.kunzisoft.keepass.database.SortNodeEnum;
|
import com.kunzisoft.keepass.database.SortNodeEnum;
|
||||||
import com.kunzisoft.keepass.database.element.PwDatabase;
|
|
||||||
import com.kunzisoft.keepass.database.element.PwGroupInterface;
|
import com.kunzisoft.keepass.database.element.PwGroupInterface;
|
||||||
import com.kunzisoft.keepass.database.element.PwNodeInterface;
|
import com.kunzisoft.keepass.database.element.PwNodeInterface;
|
||||||
import com.kunzisoft.keepass.dialogs.SortDialogFragment;
|
import com.kunzisoft.keepass.dialogs.SortDialogFragment;
|
||||||
@@ -213,7 +211,6 @@ public class ListNodesFragment extends StylishFragment implements
|
|||||||
case R.id.menu_sort:
|
case R.id.menu_sort:
|
||||||
SortDialogFragment sortDialogFragment;
|
SortDialogFragment sortDialogFragment;
|
||||||
|
|
||||||
PwDatabase database = App.getDB().getPwDatabase();
|
|
||||||
/*
|
/*
|
||||||
// TODO Recycle bin bottom
|
// TODO Recycle bin bottom
|
||||||
if (database.isRecycleBinAvailable() && database.isRecycleBinEnabled()) {
|
if (database.isRecycleBinAvailable() && database.isRecycleBinEnabled()) {
|
||||||
|
|||||||
@@ -251,8 +251,7 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
|||||||
if (subNode.getType().equals(PwNodeInterface.Type.ENTRY)) {
|
if (subNode.getType().equals(PwNodeInterface.Type.ENTRY)) {
|
||||||
PwEntryInterface entry = (PwEntryInterface) subNode;
|
PwEntryInterface entry = (PwEntryInterface) subNode;
|
||||||
|
|
||||||
if (database != null)
|
database.startManageEntry(entry);
|
||||||
database.startManageEntry(entry);
|
|
||||||
|
|
||||||
holder.text.setText(PwEntryInterface.getVisualTitle(entry));
|
holder.text.setText(PwEntryInterface.getVisualTitle(entry));
|
||||||
|
|
||||||
@@ -262,8 +261,7 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
|||||||
holder.subText.setText(username);
|
holder.subText.setText(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (database != null)
|
database.stopManageEntry(entry);
|
||||||
database.stopManageEntry(entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign image and text size
|
// Assign image and text size
|
||||||
@@ -351,8 +349,10 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
|||||||
MenuItem menuItem = contextMenu.findItem(R.id.menu_open);
|
MenuItem menuItem = contextMenu.findItem(R.id.menu_open);
|
||||||
menuItem.setOnMenuItemClickListener(mOnMyActionClickListener);
|
menuItem.setOnMenuItemClickListener(mOnMyActionClickListener);
|
||||||
|
|
||||||
|
Database database = App.getDB();
|
||||||
|
|
||||||
// Edition
|
// Edition
|
||||||
if (readOnly || node.equals(App.getDB().getPwDatabase().getRecycleBin())) {
|
if (readOnly || node.equals(database.getRecycleBin())) {
|
||||||
contextMenu.removeItem(R.id.menu_edit);
|
contextMenu.removeItem(R.id.menu_edit);
|
||||||
} else {
|
} else {
|
||||||
menuItem = contextMenu.findItem(R.id.menu_edit);
|
menuItem = contextMenu.findItem(R.id.menu_edit);
|
||||||
@@ -362,7 +362,7 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
|||||||
// Copy (not for group)
|
// Copy (not for group)
|
||||||
if (readOnly
|
if (readOnly
|
||||||
|| isASearchResult
|
|| isASearchResult
|
||||||
|| node.equals(App.getDB().getPwDatabase().getRecycleBin())
|
|| node.equals(database.getRecycleBin())
|
||||||
|| node.getType().equals(PwNodeInterface.Type.GROUP)) {
|
|| node.getType().equals(PwNodeInterface.Type.GROUP)) {
|
||||||
// TODO COPY For Group
|
// TODO COPY For Group
|
||||||
contextMenu.removeItem(R.id.menu_copy);
|
contextMenu.removeItem(R.id.menu_copy);
|
||||||
@@ -374,7 +374,7 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
|||||||
// Move
|
// Move
|
||||||
if (readOnly
|
if (readOnly
|
||||||
|| isASearchResult
|
|| isASearchResult
|
||||||
|| node.equals(App.getDB().getPwDatabase().getRecycleBin())) {
|
|| node.equals(database.getRecycleBin())) {
|
||||||
contextMenu.removeItem(R.id.menu_move);
|
contextMenu.removeItem(R.id.menu_move);
|
||||||
} else {
|
} else {
|
||||||
menuItem = contextMenu.findItem(R.id.menu_move);
|
menuItem = contextMenu.findItem(R.id.menu_move);
|
||||||
@@ -382,7 +382,7 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Deletion
|
// Deletion
|
||||||
if (readOnly || node.equals(App.getDB().getPwDatabase().getRecycleBin())) {
|
if (readOnly || node.equals(database.getRecycleBin())) {
|
||||||
contextMenu.removeItem(R.id.menu_delete);
|
contextMenu.removeItem(R.id.menu_delete);
|
||||||
} else {
|
} else {
|
||||||
menuItem = contextMenu.findItem(R.id.menu_delete);
|
menuItem = contextMenu.findItem(R.id.menu_delete);
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class SearchEntryCursorAdapter extends CursorAdapter {
|
|||||||
// Retrieve elements from cursor
|
// Retrieve elements from cursor
|
||||||
UUID uuid = new UUID(cursor.getLong(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_UUID_MOST_SIGNIFICANT_BITS)),
|
UUID uuid = new UUID(cursor.getLong(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_UUID_MOST_SIGNIFICANT_BITS)),
|
||||||
cursor.getLong(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_UUID_LEAST_SIGNIFICANT_BITS)));
|
cursor.getLong(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_UUID_LEAST_SIGNIFICANT_BITS)));
|
||||||
PwIconFactory iconFactory = database.getPwDatabase().getIconFactory();
|
PwIconFactory iconFactory = database.getIconFactory();
|
||||||
PwIcon icon = iconFactory.getIcon(
|
PwIcon icon = iconFactory.getIcon(
|
||||||
new UUID(cursor.getLong(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_ICON_CUSTOM_UUID_MOST_SIGNIFICANT_BITS)),
|
new UUID(cursor.getLong(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_ICON_CUSTOM_UUID_MOST_SIGNIFICANT_BITS)),
|
||||||
cursor.getLong(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_ICON_CUSTOM_UUID_LEAST_SIGNIFICANT_BITS))));
|
cursor.getLong(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_ICON_CUSTOM_UUID_LEAST_SIGNIFICANT_BITS))));
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ class AssignPasswordInDatabaseRunnable @JvmOverloads constructor(
|
|||||||
withMasterPassword: Boolean,
|
withMasterPassword: Boolean,
|
||||||
masterPassword: String?,
|
masterPassword: String?,
|
||||||
withKeyFile: Boolean,
|
withKeyFile: Boolean,
|
||||||
keyfile: Uri?,
|
keyFile: Uri?,
|
||||||
actionRunnable: ActionRunnable? = null,
|
actionRunnable: ActionRunnable? = null,
|
||||||
save: Boolean)
|
save: Boolean)
|
||||||
: SaveDatabaseRunnable(ctx, db, actionRunnable, save) {
|
: SaveDatabaseRunnable(ctx, db, actionRunnable, save) {
|
||||||
|
|
||||||
private var mMasterPassword: String? = null
|
private var mMasterPassword: String? = null
|
||||||
private var mKeyfile: Uri? = null
|
private var mKeyFile: Uri? = null
|
||||||
|
|
||||||
private var mBackupKey: ByteArray? = null
|
private var mBackupKey: ByteArray? = null
|
||||||
|
|
||||||
@@ -47,19 +47,18 @@ class AssignPasswordInDatabaseRunnable @JvmOverloads constructor(
|
|||||||
if (withMasterPassword)
|
if (withMasterPassword)
|
||||||
this.mMasterPassword = masterPassword
|
this.mMasterPassword = masterPassword
|
||||||
if (withKeyFile)
|
if (withKeyFile)
|
||||||
this.mKeyfile = keyfile
|
this.mKeyFile = keyFile
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
// Set key
|
// Set key
|
||||||
try {
|
try {
|
||||||
val pm = database.pwDatabase
|
|
||||||
// TODO move master key methods
|
// TODO move master key methods
|
||||||
mBackupKey = ByteArray(pm.getMasterKey().size)
|
mBackupKey = ByteArray(database.masterKey.size)
|
||||||
System.arraycopy(pm.getMasterKey(), 0, mBackupKey!!, 0, mBackupKey!!.size)
|
System.arraycopy(database.masterKey, 0, mBackupKey!!, 0, mBackupKey!!.size)
|
||||||
|
|
||||||
val uriInputStream = UriUtil.getUriInputStream(context, mKeyfile)
|
val uriInputStream = UriUtil.getUriInputStream(context, mKeyFile)
|
||||||
pm.retrieveMasterKey(mMasterPassword, uriInputStream)
|
database.retrieveMasterKey(mMasterPassword, uriInputStream)
|
||||||
// To save the database
|
// To save the database
|
||||||
super.run()
|
super.run()
|
||||||
finishRun(true)
|
finishRun(true)
|
||||||
@@ -75,8 +74,8 @@ class AssignPasswordInDatabaseRunnable @JvmOverloads constructor(
|
|||||||
override fun onFinishRun(isSuccess: Boolean, message: String?) {
|
override fun onFinishRun(isSuccess: Boolean, message: String?) {
|
||||||
if (!isSuccess) {
|
if (!isSuccess) {
|
||||||
// Erase the current master key
|
// Erase the current master key
|
||||||
erase(database.pwDatabase.getMasterKey())
|
erase(database.masterKey)
|
||||||
database.pwDatabase.setMasterKey(mBackupKey)
|
database.masterKey = mBackupKey
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onFinishRun(isSuccess, message)
|
super.onFinishRun(isSuccess, message)
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import com.kunzisoft.keepass.database.cursor.EntryCursorV3;
|
|||||||
import com.kunzisoft.keepass.database.cursor.EntryCursorV4;
|
import com.kunzisoft.keepass.database.cursor.EntryCursorV4;
|
||||||
import com.kunzisoft.keepass.database.exception.ContentFileNotFoundException;
|
import com.kunzisoft.keepass.database.exception.ContentFileNotFoundException;
|
||||||
import com.kunzisoft.keepass.database.exception.InvalidDBException;
|
import com.kunzisoft.keepass.database.exception.InvalidDBException;
|
||||||
|
import com.kunzisoft.keepass.database.exception.InvalidKeyFileException;
|
||||||
import com.kunzisoft.keepass.database.exception.PwDbOutputException;
|
import com.kunzisoft.keepass.database.exception.PwDbOutputException;
|
||||||
import com.kunzisoft.keepass.database.load.Importer;
|
import com.kunzisoft.keepass.database.load.Importer;
|
||||||
import com.kunzisoft.keepass.database.load.ImporterFactory;
|
import com.kunzisoft.keepass.database.load.ImporterFactory;
|
||||||
@@ -109,10 +110,6 @@ public class Database {
|
|||||||
return filename.substring(0, lastExtDot);
|
return filename.substring(0, lastExtDot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PwDatabase getPwDatabase() {
|
|
||||||
return pwDatabase;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUri(Uri mUri) {
|
public void setUri(Uri mUri) {
|
||||||
this.mUri = mUri;
|
this.mUri = mUri;
|
||||||
}
|
}
|
||||||
@@ -229,7 +226,7 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Cursor searchEntry(String query) {
|
public Cursor searchEntry(String query) {
|
||||||
PwVersion version = getPwDatabase().getVersion();
|
PwVersion version = pwDatabase.getVersion();
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case V3:
|
case V3:
|
||||||
EntryCursorV3 cursorV3 = new EntryCursorV3();
|
EntryCursorV3 cursorV3 = new EntryCursorV3();
|
||||||
@@ -262,10 +259,10 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PwEntryInterface getEntryFrom(Cursor cursor) {
|
public PwEntryInterface getEntryFrom(Cursor cursor) {
|
||||||
PwIconFactory iconFactory = getPwDatabase().getIconFactory();
|
PwIconFactory iconFactory = pwDatabase.getIconFactory();
|
||||||
PwEntryInterface pwEntry = createEntry();
|
PwEntryInterface pwEntry = createEntry();
|
||||||
try {
|
try {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
case V3:
|
case V3:
|
||||||
((EntryCursorV3) cursor).populateEntry((PwEntryV3) pwEntry, iconFactory);
|
((EntryCursorV3) cursor).populateEntry((PwEntryV3) pwEntry, iconFactory);
|
||||||
break;
|
break;
|
||||||
@@ -358,11 +355,11 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return getPwDatabase().getVersion().toString();
|
return pwDatabase.getVersion().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsName() {
|
public boolean containsName() {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
case V4:
|
case V4:
|
||||||
@@ -371,18 +368,18 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
case V4:
|
case V4:
|
||||||
return ((PwDatabaseV4) getPwDatabase()).getName();
|
return ((PwDatabaseV4) pwDatabase).getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assignName(String name) {
|
public void assignName(String name) {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
case V4:
|
case V4:
|
||||||
PwDatabaseV4 databaseV4 = ((PwDatabaseV4) getPwDatabase());
|
PwDatabaseV4 databaseV4 = ((PwDatabaseV4) pwDatabase);
|
||||||
databaseV4.setName(name);
|
databaseV4.setName(name);
|
||||||
databaseV4.setNameChanged(new PwDate());
|
databaseV4.setNameChanged(new PwDate());
|
||||||
break;
|
break;
|
||||||
@@ -390,7 +387,7 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsDescription() {
|
public boolean containsDescription() {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
case V4:
|
case V4:
|
||||||
@@ -399,45 +396,45 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
case V4:
|
case V4:
|
||||||
return ((PwDatabaseV4) getPwDatabase()).getDescription();
|
return ((PwDatabaseV4) pwDatabase).getDescription();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assignDescription(String description) {
|
public void assignDescription(String description) {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
case V4:
|
case V4:
|
||||||
((PwDatabaseV4) getPwDatabase()).setDescription(description);
|
((PwDatabaseV4) pwDatabase).setDescription(description);
|
||||||
((PwDatabaseV4) getPwDatabase()).setDescriptionChanged(new PwDate());
|
((PwDatabaseV4) pwDatabase).setDescriptionChanged(new PwDate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDefaultUsername() {
|
public String getDefaultUsername() {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
case V4:
|
case V4:
|
||||||
return ((PwDatabaseV4) getPwDatabase()).getDefaultUserName();
|
return ((PwDatabaseV4) pwDatabase).getDefaultUserName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultUsername(String username) {
|
public void setDefaultUsername(String username) {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
case V4:
|
case V4:
|
||||||
((PwDatabaseV4) getPwDatabase()).setDefaultUserName(username);
|
((PwDatabaseV4) pwDatabase).setDefaultUserName(username);
|
||||||
((PwDatabaseV4) getPwDatabase()).setDefaultUserNameChanged(new PwDate());
|
((PwDatabaseV4) pwDatabase).setDefaultUserNameChanged(new PwDate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PwEncryptionAlgorithm getEncryptionAlgorithm() {
|
public PwEncryptionAlgorithm getEncryptionAlgorithm() {
|
||||||
return getPwDatabase().getEncryptionAlgorithm();
|
return pwDatabase.getEncryptionAlgorithm();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PwEncryptionAlgorithm> getAvailableEncryptionAlgorithms() {
|
public List<PwEncryptionAlgorithm> getAvailableEncryptionAlgorithms() {
|
||||||
return getPwDatabase().getAvailableEncryptionAlgorithms();
|
return pwDatabase.getAvailableEncryptionAlgorithms();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean allowEncryptionAlgorithmModification() {
|
public boolean allowEncryptionAlgorithmModification() {
|
||||||
@@ -445,20 +442,20 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void assignEncryptionAlgorithm(PwEncryptionAlgorithm algorithm) {
|
public void assignEncryptionAlgorithm(PwEncryptionAlgorithm algorithm) {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
case V4:
|
case V4:
|
||||||
((PwDatabaseV4) getPwDatabase()).setEncryptionAlgorithm(algorithm);
|
((PwDatabaseV4) pwDatabase).setEncryptionAlgorithm(algorithm);
|
||||||
((PwDatabaseV4) getPwDatabase()).setDataEngine(algorithm.getCipherEngine());
|
((PwDatabaseV4) pwDatabase).setDataEngine(algorithm.getCipherEngine());
|
||||||
((PwDatabaseV4) getPwDatabase()).setDataCipher(algorithm.getDataCipher());
|
((PwDatabaseV4) pwDatabase).setDataCipher(algorithm.getDataCipher());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEncryptionAlgorithmName(Resources resources) {
|
public String getEncryptionAlgorithmName(Resources resources) {
|
||||||
return getPwDatabase().getEncryptionAlgorithm().getName(resources);
|
return pwDatabase.getEncryptionAlgorithm().getName(resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<KdfEngine> getAvailableKdfEngines() {
|
public List<KdfEngine> getAvailableKdfEngines() {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
case V4:
|
case V4:
|
||||||
return KdfFactory.kdfListV4;
|
return KdfFactory.kdfListV4;
|
||||||
case V3:
|
case V3:
|
||||||
@@ -472,9 +469,9 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public KdfEngine getKdfEngine() {
|
public KdfEngine getKdfEngine() {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
case V4:
|
case V4:
|
||||||
KdfEngine kdfEngine = ((PwDatabaseV4) getPwDatabase()).getKdfEngine();
|
KdfEngine kdfEngine = ((PwDatabaseV4) pwDatabase).getKdfEngine();
|
||||||
if (kdfEngine == null)
|
if (kdfEngine == null)
|
||||||
return KdfFactory.aesKdf;
|
return KdfFactory.aesKdf;
|
||||||
return kdfEngine;
|
return kdfEngine;
|
||||||
@@ -485,9 +482,9 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void assignKdfEngine(KdfEngine kdfEngine) {
|
public void assignKdfEngine(KdfEngine kdfEngine) {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
case V4:
|
case V4:
|
||||||
PwDatabaseV4 db = ((PwDatabaseV4) getPwDatabase());
|
PwDatabaseV4 db = ((PwDatabaseV4) pwDatabase);
|
||||||
if (db.getKdfParameters() == null
|
if (db.getKdfParameters() == null
|
||||||
|| !db.getKdfParameters().getUUID().equals(kdfEngine.getDefaultParameters().getUUID()))
|
|| !db.getKdfParameters().getUUID().equals(kdfEngine.getDefaultParameters().getUUID()))
|
||||||
db.setKdfParameters(kdfEngine.getDefaultParameters());
|
db.setKdfParameters(kdfEngine.getDefaultParameters());
|
||||||
@@ -511,11 +508,11 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long getNumberKeyEncryptionRounds() {
|
public long getNumberKeyEncryptionRounds() {
|
||||||
return getPwDatabase().getNumberKeyEncryptionRounds();
|
return pwDatabase.getNumberKeyEncryptionRounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNumberKeyEncryptionRounds(long numberRounds) throws NumberFormatException {
|
public void setNumberKeyEncryptionRounds(long numberRounds) throws NumberFormatException {
|
||||||
getPwDatabase().setNumberKeyEncryptionRounds(numberRounds);
|
pwDatabase.setNumberKeyEncryptionRounds(numberRounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMemoryUsageAsString() {
|
public String getMemoryUsageAsString() {
|
||||||
@@ -523,17 +520,17 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long getMemoryUsage() {
|
public long getMemoryUsage() {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
case V4:
|
case V4:
|
||||||
return ((PwDatabaseV4) getPwDatabase()).getMemoryUsage();
|
return ((PwDatabaseV4) pwDatabase).getMemoryUsage();
|
||||||
}
|
}
|
||||||
return KdfEngine.UNKNOW_VALUE;
|
return KdfEngine.UNKNOW_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMemoryUsage(long memory) {
|
public void setMemoryUsage(long memory) {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
case V4:
|
case V4:
|
||||||
((PwDatabaseV4) getPwDatabase()).setMemoryUsage(memory);
|
((PwDatabaseV4) pwDatabase).setMemoryUsage(memory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,23 +539,44 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getParallelism() {
|
public int getParallelism() {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
case V4:
|
case V4:
|
||||||
return ((PwDatabaseV4) getPwDatabase()).getParallelism();
|
return ((PwDatabaseV4) pwDatabase).getParallelism();
|
||||||
}
|
}
|
||||||
return KdfEngine.UNKNOW_VALUE;
|
return KdfEngine.UNKNOW_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParallelism(int parallelism) {
|
public void setParallelism(int parallelism) {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
case V4:
|
case V4:
|
||||||
((PwDatabaseV4) getPwDatabase()).setParallelism(parallelism);
|
((PwDatabaseV4) pwDatabase).setParallelism(parallelism);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean validatePasswordEncoding(String key) {
|
||||||
|
return pwDatabase.validatePasswordEncoding(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getMasterKey() {
|
||||||
|
return pwDatabase.getMasterKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMasterKey(byte[] masterKey) {
|
||||||
|
pwDatabase.masterKey = masterKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void retrieveMasterKey(String key, InputStream keyInputStream)
|
||||||
|
throws InvalidKeyFileException, IOException {
|
||||||
|
pwDatabase.retrieveMasterKey(key, keyInputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PwGroupInterface getRootGroup() {
|
||||||
|
return pwDatabase.getRootGroup();
|
||||||
|
}
|
||||||
|
|
||||||
public PwEntryInterface createEntry() {
|
public PwEntryInterface createEntry() {
|
||||||
try {
|
try {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
case V3:
|
case V3:
|
||||||
return new PwEntryV3();
|
return new PwEntryV3();
|
||||||
case V4:
|
case V4:
|
||||||
@@ -573,7 +591,7 @@ public class Database {
|
|||||||
public PwGroupInterface createGroup() {
|
public PwGroupInterface createGroup() {
|
||||||
PwGroupInterface newPwGroup = null;
|
PwGroupInterface newPwGroup = null;
|
||||||
try {
|
try {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
case V3:
|
case V3:
|
||||||
newPwGroup = new PwGroupV3();
|
newPwGroup = new PwGroupV3();
|
||||||
case V4:
|
case V4:
|
||||||
@@ -587,16 +605,16 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PwEntryInterface getEntryById(PwNodeId id) {
|
public PwEntryInterface getEntryById(PwNodeId id) {
|
||||||
return pwDatabase.entryIndexes.get(id);
|
return pwDatabase.getEntryById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PwGroupInterface getGroupById(PwNodeId id) {
|
public PwGroupInterface getGroupById(PwNodeId id) {
|
||||||
return pwDatabase.groupIndexes.get(id);
|
return pwDatabase.getGroupById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addEntryTo(PwEntryInterface entry, PwGroupInterface parent) {
|
public void addEntryTo(PwEntryInterface entry, PwGroupInterface parent) {
|
||||||
try {
|
try {
|
||||||
getPwDatabase().addEntryTo(entry, parent);
|
pwDatabase.addEntryTo(entry, parent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "This version of PwEntry can't be added from this version of PwGroup", e);
|
Log.e(TAG, "This version of PwEntry can't be added from this version of PwGroup", e);
|
||||||
}
|
}
|
||||||
@@ -604,7 +622,7 @@ public class Database {
|
|||||||
|
|
||||||
public void removeEntryFrom(PwEntryInterface entry, PwGroupInterface parent) {
|
public void removeEntryFrom(PwEntryInterface entry, PwGroupInterface parent) {
|
||||||
try {
|
try {
|
||||||
getPwDatabase().removeEntryFrom(entry, parent);
|
pwDatabase.removeEntryFrom(entry, parent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "This version of PwEntry can't be removed from this version of PwGroup", e);
|
Log.e(TAG, "This version of PwEntry can't be removed from this version of PwGroup", e);
|
||||||
}
|
}
|
||||||
@@ -612,7 +630,7 @@ public class Database {
|
|||||||
|
|
||||||
public void addGroupTo(PwGroupInterface group, PwGroupInterface parent) {
|
public void addGroupTo(PwGroupInterface group, PwGroupInterface parent) {
|
||||||
try {
|
try {
|
||||||
getPwDatabase().addGroupTo(group, parent);
|
pwDatabase.addGroupTo(group, parent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "This version of PwGroup can't be added in this version of PwGroup", e);
|
Log.e(TAG, "This version of PwGroup can't be added in this version of PwGroup", e);
|
||||||
}
|
}
|
||||||
@@ -620,7 +638,7 @@ public class Database {
|
|||||||
|
|
||||||
public void removeGroupFrom(PwGroupInterface group, PwGroupInterface parent) {
|
public void removeGroupFrom(PwGroupInterface group, PwGroupInterface parent) {
|
||||||
try {
|
try {
|
||||||
getPwDatabase().removeGroupFrom(group, parent);
|
pwDatabase.removeGroupFrom(group, parent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "This version of PwGroup can't be removed from this version of PwGroup", e);
|
Log.e(TAG, "This version of PwGroup can't be removed from this version of PwGroup", e);
|
||||||
}
|
}
|
||||||
@@ -628,7 +646,7 @@ public class Database {
|
|||||||
|
|
||||||
public boolean canRecycle(PwEntryInterface entry) {
|
public boolean canRecycle(PwEntryInterface entry) {
|
||||||
try {
|
try {
|
||||||
getPwDatabase().canRecycle(entry);
|
pwDatabase.canRecycle(entry);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "This version of PwEntry can't be recycled", e);
|
Log.e(TAG, "This version of PwEntry can't be recycled", e);
|
||||||
}
|
}
|
||||||
@@ -637,7 +655,7 @@ public class Database {
|
|||||||
|
|
||||||
public boolean canRecycle(PwGroupInterface group) {
|
public boolean canRecycle(PwGroupInterface group) {
|
||||||
try {
|
try {
|
||||||
getPwDatabase().canRecycle(group);
|
pwDatabase.canRecycle(group);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "This version of PwGroup can't be recycled", e);
|
Log.e(TAG, "This version of PwGroup can't be recycled", e);
|
||||||
}
|
}
|
||||||
@@ -646,7 +664,7 @@ public class Database {
|
|||||||
|
|
||||||
public void recycle(PwEntryInterface entry) {
|
public void recycle(PwEntryInterface entry) {
|
||||||
try {
|
try {
|
||||||
getPwDatabase().recycle(entry);
|
pwDatabase.recycle(entry);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "This version of PwEntry can't be recycled", e);
|
Log.e(TAG, "This version of PwEntry can't be recycled", e);
|
||||||
}
|
}
|
||||||
@@ -654,7 +672,7 @@ public class Database {
|
|||||||
|
|
||||||
public void recycle(PwGroupInterface group) {
|
public void recycle(PwGroupInterface group) {
|
||||||
try {
|
try {
|
||||||
getPwDatabase().recycle(group);
|
pwDatabase.recycle(group);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "This version of PwGroup can't be recycled", e);
|
Log.e(TAG, "This version of PwGroup can't be recycled", e);
|
||||||
}
|
}
|
||||||
@@ -662,7 +680,7 @@ public class Database {
|
|||||||
|
|
||||||
public void updateEntry(PwEntryInterface oldEntry, PwEntryInterface newEntry) {
|
public void updateEntry(PwEntryInterface oldEntry, PwEntryInterface newEntry) {
|
||||||
try {
|
try {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
case V3:
|
case V3:
|
||||||
((PwEntryV3) oldEntry).updateWith((PwEntryV3) newEntry);
|
((PwEntryV3) oldEntry).updateWith((PwEntryV3) newEntry);
|
||||||
break;
|
break;
|
||||||
@@ -677,7 +695,7 @@ public class Database {
|
|||||||
|
|
||||||
public void updateGroup(PwGroupInterface oldGroup, PwGroupInterface newGroup) {
|
public void updateGroup(PwGroupInterface oldGroup, PwGroupInterface newGroup) {
|
||||||
try {
|
try {
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
case V3:
|
case V3:
|
||||||
((PwGroupV3) oldGroup).updateWith((PwGroupV3) newGroup);
|
((PwGroupV3) oldGroup).updateWith((PwGroupV3) newGroup);
|
||||||
break;
|
break;
|
||||||
@@ -698,7 +716,7 @@ public class Database {
|
|||||||
public @Nullable PwEntryInterface copyEntry(PwEntryInterface entryToCopy, PwGroupInterface newParent) {
|
public @Nullable PwEntryInterface copyEntry(PwEntryInterface entryToCopy, PwGroupInterface newParent) {
|
||||||
try {
|
try {
|
||||||
PwEntryInterface entryCopied = null;
|
PwEntryInterface entryCopied = null;
|
||||||
switch (getPwDatabase().getVersion()) {
|
switch (pwDatabase.getVersion()) {
|
||||||
case V3:
|
case V3:
|
||||||
entryCopied = ((PwEntryV3) entryToCopy).clone();
|
entryCopied = ((PwEntryV3) entryToCopy).clone();
|
||||||
break;
|
break;
|
||||||
@@ -759,16 +777,24 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRecycleBinAvailable() {
|
public boolean isRecycleBinAvailable() {
|
||||||
return getPwDatabase().isRecycleBinAvailable();
|
return pwDatabase.isRecycleBinAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRecycleBinEnabled() {
|
public boolean isRecycleBinEnabled() {
|
||||||
return getPwDatabase().isRecycleBinEnabled();
|
return pwDatabase.isRecycleBinEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PwGroupInterface getRecycleBin() {
|
||||||
|
switch (pwDatabase.getVersion()) {
|
||||||
|
case V4:
|
||||||
|
return ((PwDatabaseV4) pwDatabase).getRecycleBin();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void undoRecycle(PwEntryInterface entry, PwGroupInterface parent) {
|
public void undoRecycle(PwEntryInterface entry, PwGroupInterface parent) {
|
||||||
try {
|
try {
|
||||||
getPwDatabase().undoRecycle(entry, parent);
|
pwDatabase.undoRecycle(entry, parent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "This version of database can't undo Recycle of this version of PwEntry", e);
|
Log.e(TAG, "This version of database can't undo Recycle of this version of PwEntry", e);
|
||||||
}
|
}
|
||||||
@@ -776,7 +802,7 @@ public class Database {
|
|||||||
|
|
||||||
public void undoRecycle(PwGroupInterface group, PwGroupInterface parent) {
|
public void undoRecycle(PwGroupInterface group, PwGroupInterface parent) {
|
||||||
try {
|
try {
|
||||||
getPwDatabase().undoRecycle(group, parent);
|
pwDatabase.undoRecycle(group, parent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "This version of database can't undo Recycle of this version of PwGroup", e);
|
Log.e(TAG, "This version of database can't undo Recycle of this version of PwGroup", e);
|
||||||
}
|
}
|
||||||
@@ -784,7 +810,7 @@ public class Database {
|
|||||||
|
|
||||||
public void undoDeleteEntry(PwEntryInterface entry, PwGroupInterface parent) {
|
public void undoDeleteEntry(PwEntryInterface entry, PwGroupInterface parent) {
|
||||||
try {
|
try {
|
||||||
getPwDatabase().undoDeleteEntryFrom(entry, parent);
|
pwDatabase.undoDeleteEntryFrom(entry, parent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "This version of database can't undo the deletion of this version of PwEntry", e);
|
Log.e(TAG, "This version of database can't undo the deletion of this version of PwEntry", e);
|
||||||
}
|
}
|
||||||
@@ -792,33 +818,39 @@ public class Database {
|
|||||||
|
|
||||||
public void undoDeleteGroup(PwGroupInterface group, PwGroupInterface parent) {
|
public void undoDeleteGroup(PwGroupInterface group, PwGroupInterface parent) {
|
||||||
try {
|
try {
|
||||||
getPwDatabase().undoDeleteGroup(group, parent);
|
pwDatabase.undoDeleteGroup(group, parent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "This version of database can't undo the deletion of this version of PwGroup", e);
|
Log.e(TAG, "This version of database can't undo the deletion of this version of PwGroup", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startManageEntry(PwEntryInterface entry) {
|
public void startManageEntry(PwEntryInterface entry) {
|
||||||
switch (getPwDatabase().getVersion()) {
|
if (pwDatabase != null) {
|
||||||
case V4:
|
switch (pwDatabase.getVersion()) {
|
||||||
((PwEntryV4) entry).startToManageFieldReferences((PwDatabaseV4) getPwDatabase());
|
case V4:
|
||||||
break;
|
((PwEntryV4) entry).startToManageFieldReferences((PwDatabaseV4) pwDatabase);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopManageEntry(PwEntryInterface entry) {
|
public void stopManageEntry(PwEntryInterface entry) {
|
||||||
switch (getPwDatabase().getVersion()) {
|
if (pwDatabase != null) {
|
||||||
case V4:
|
switch (pwDatabase.getVersion()) {
|
||||||
((PwEntryV4) entry).stopToManageFieldReferences();
|
case V4:
|
||||||
break;
|
((PwEntryV4) entry).stopToManageFieldReferences();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createBackupOf(PwEntryInterface entry) {
|
public void createBackupOf(PwEntryInterface entry) {
|
||||||
switch (getPwDatabase().getVersion()) {
|
if (pwDatabase != null) {
|
||||||
case V4:
|
switch (pwDatabase.getVersion()) {
|
||||||
((PwEntryV4) entry).createBackup((PwDatabaseV4) getPwDatabase());
|
case V4:
|
||||||
break;
|
((PwEntryV4) entry).createBackup((PwDatabaseV4) pwDatabase);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ public abstract class PwDatabase {
|
|||||||
return finalKey;
|
return finalKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract byte[] getMasterKey(String key, InputStream keyInputStream) throws InvalidKeyFileException, IOException;
|
protected abstract byte[] getMasterKey(String key, InputStream keyInputStream)
|
||||||
|
throws InvalidKeyFileException, IOException;
|
||||||
|
|
||||||
public void retrieveMasterKey(String key, InputStream keyInputStream)
|
public void retrieveMasterKey(String key, InputStream keyInputStream)
|
||||||
throws InvalidKeyFileException, IOException {
|
throws InvalidKeyFileException, IOException {
|
||||||
@@ -412,10 +413,6 @@ public abstract class PwDatabase {
|
|||||||
throw new RuntimeException("Call not valid for .kdb databases.");
|
throw new RuntimeException("Call not valid for .kdb databases.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public PwGroupInterface getRecycleBin() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isGroupSearchable(PwGroupInterface group, boolean omitBackup) {
|
public boolean isGroupSearchable(PwGroupInterface group, boolean omitBackup) {
|
||||||
return group != null;
|
return group != null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -659,7 +659,6 @@ public class PwDatabaseV4 extends PwDatabase {
|
|||||||
deletedObjects.remove(new PwDeletedObject((UUID) entry.getNodeId().getId()));
|
deletedObjects.remove(new PwDeletedObject((UUID) entry.getNodeId().getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PwGroupInterface getRecycleBin() { // TODO delete recycle bin preference
|
public PwGroupInterface getRecycleBin() { // TODO delete recycle bin preference
|
||||||
if (recycleBinUUID == null) {
|
if (recycleBinUUID == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public abstract class PwNode<IdType> implements PwNodeInterface, Parcelable, Clo
|
|||||||
// TODO better technique ?
|
// TODO better technique ?
|
||||||
try {
|
try {
|
||||||
PwNodeId pwGroupId = in.readParcelable(PwNodeId.class.getClassLoader());
|
PwNodeId pwGroupId = in.readParcelable(PwNodeId.class.getClassLoader());
|
||||||
parent = App.getDB().getPwDatabase().getGroupById(pwGroupId);
|
parent = App.getDB().getGroupById(pwGroupId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public class GroupEditDialogFragment extends DialogFragment
|
|||||||
database = App.getDB();
|
database = App.getDB();
|
||||||
editGroupDialogAction = EditGroupDialogAction.NONE;
|
editGroupDialogAction = EditGroupDialogAction.NONE;
|
||||||
nameGroup = "";
|
nameGroup = "";
|
||||||
iconGroup = database.getPwDatabase().getIconFactory().getFolderIcon();
|
iconGroup = database.getIconFactory().getFolderIcon();
|
||||||
|
|
||||||
if (savedInstanceState != null
|
if (savedInstanceState != null
|
||||||
&& savedInstanceState.containsKey(KEY_ACTION_ID)
|
&& savedInstanceState.containsKey(KEY_ACTION_ID)
|
||||||
|
|||||||
Reference in New Issue
Block a user