mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix entries search
This commit is contained in:
@@ -126,9 +126,6 @@ class EntryVersioned : NodeVersioned, PwEntryInterface<GroupVersioned> {
|
|||||||
return contained ?: false
|
return contained ?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
override val isSearchingEnabled: Boolean
|
|
||||||
get() = pwEntryV3?.isSearchingEnabled ?: pwEntryV4?.isSearchingEnabled ?: false
|
|
||||||
|
|
||||||
override var creationTime: PwDate
|
override var creationTime: PwDate
|
||||||
get() = pwEntryV3?.creationTime ?: pwEntryV4?.creationTime ?: PwDate()
|
get() = pwEntryV3?.creationTime ?: pwEntryV4?.creationTime ?: PwDate()
|
||||||
set(value) {
|
set(value) {
|
||||||
|
|||||||
@@ -130,9 +130,6 @@ class GroupVersioned : NodeVersioned, PwGroupInterface<GroupVersioned, EntryVers
|
|||||||
return contained ?: false
|
return contained ?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
override val isSearchingEnabled: Boolean
|
|
||||||
get() = pwGroupV3?.isSearchingEnabled ?: pwGroupV4?.isSearchingEnabled ?: false
|
|
||||||
|
|
||||||
override var creationTime: PwDate
|
override var creationTime: PwDate
|
||||||
get() = pwGroupV3?.creationTime ?: pwGroupV4?.creationTime ?: PwDate()
|
get() = pwGroupV3?.creationTime ?: pwGroupV4?.creationTime ?: PwDate()
|
||||||
set(value) {
|
set(value) {
|
||||||
|
|||||||
@@ -323,8 +323,12 @@ abstract class PwDatabase<Group : PwGroup<*, Group, Entry>, Entry : PwEntry<Grou
|
|||||||
|
|
||||||
abstract fun isBackup(group: Group): Boolean
|
abstract fun isBackup(group: Group): Boolean
|
||||||
|
|
||||||
open fun isGroupSearchable(group: Group?, omitBackup: Boolean): Boolean {
|
fun isGroupSearchable(group: Group?, omitBackup: Boolean): Boolean {
|
||||||
return group != null
|
if (group == null)
|
||||||
|
return false
|
||||||
|
if (omitBackup && isBackup(group))
|
||||||
|
return false
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@@ -207,12 +207,6 @@ class PwDatabaseV3 : PwDatabase<PwGroupV3, PwEntryV3>() {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isGroupSearchable(group: PwGroupV3?, omitBackup: Boolean): Boolean {
|
|
||||||
return if (!super.isGroupSearchable(group, omitBackup)) {
|
|
||||||
false
|
|
||||||
} else !(omitBackup && isBackup(group!!))
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val DEFAULT_ENCRYPTION_ROUNDS = 300
|
private const val DEFAULT_ENCRYPTION_ROUNDS = 300
|
||||||
|
|||||||
@@ -407,12 +407,6 @@ class PwDatabaseV4 : PwDatabase<PwGroupV4, PwEntryV4> {
|
|||||||
return publicCustomData.size() > 0
|
return publicCustomData.size() > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isGroupSearchable(group: PwGroupV4?, omitBackup: Boolean): Boolean {
|
|
||||||
return if (!super.isGroupSearchable(group, omitBackup)) {
|
|
||||||
false
|
|
||||||
} else group!!.isSearchingEnabled
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun validatePasswordEncoding(key: String?): Boolean {
|
override fun validatePasswordEncoding(key: String?): Boolean {
|
||||||
if (key == null)
|
if (key == null)
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -167,10 +167,6 @@ class PwEntryV3 : PwEntry<PwGroupV3, PwEntryV3> {
|
|||||||
override val type: Type
|
override val type: Type
|
||||||
get() = Type.ENTRY
|
get() = Type.ENTRY
|
||||||
|
|
||||||
override val isSearchingEnabled: Boolean
|
|
||||||
get() = false
|
|
||||||
|
|
||||||
|
|
||||||
fun setBinaryData(buf: ByteArray, offset: Int, len: Int) {
|
fun setBinaryData(buf: ByteArray, offset: Int, len: Int) {
|
||||||
/** Securely erase old data before copying new. */
|
/** Securely erase old data before copying new. */
|
||||||
fill(binaryData, 0.toByte())
|
fill(binaryData, 0.toByte())
|
||||||
|
|||||||
@@ -204,9 +204,6 @@ class PwEntryV4 : PwEntry<PwGroupV4, PwEntryV4>, NodeV4Interface {
|
|||||||
override val type: Type
|
override val type: Type
|
||||||
get() = Type.ENTRY
|
get() = Type.ENTRY
|
||||||
|
|
||||||
override val isSearchingEnabled: Boolean
|
|
||||||
get() = parent?.isSearchingEnabled ?: true
|
|
||||||
|
|
||||||
override var username: String
|
override var username: String
|
||||||
get() = decodeRefKey(mDecodeRef, STR_USERNAME)
|
get() = decodeRefKey(mDecodeRef, STR_USERNAME)
|
||||||
set(value) {
|
set(value) {
|
||||||
|
|||||||
@@ -25,15 +25,21 @@ interface PwGroupInterface<Group: PwGroupInterface<Group, Entry>, Entry> : PwNod
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun doForEachChild(entryHandler: NodeHandler<Entry>,
|
fun doForEachChild(entryHandler: NodeHandler<Entry>,
|
||||||
groupHandler: NodeHandler<Group>?): Boolean {
|
groupHandler: NodeHandler<Group>?,
|
||||||
|
stopIterationWhenGroupHandlerFails: Boolean = true): Boolean {
|
||||||
for (entry in this.getChildEntries()) {
|
for (entry in this.getChildEntries()) {
|
||||||
if (!entryHandler.operate(entry))
|
if (!entryHandler.operate(entry))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for (group in this.getChildGroups()) {
|
for (group in this.getChildGroups()) {
|
||||||
if (groupHandler != null && !groupHandler.operate(group))
|
var doActionForChild = true
|
||||||
return false
|
if (groupHandler != null && !groupHandler.operate(group)) {
|
||||||
group.doForEachChild(entryHandler, groupHandler)
|
doActionForChild = false
|
||||||
|
if (stopIterationWhenGroupHandlerFails)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (doActionForChild)
|
||||||
|
group.doForEachChild(entryHandler, groupHandler)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,9 +59,6 @@ class PwGroupV3 : PwGroup<Int, PwGroupV3, PwEntryV3> {
|
|||||||
override val type: Type
|
override val type: Type
|
||||||
get() = Type.GROUP
|
get() = Type.GROUP
|
||||||
|
|
||||||
override val isSearchingEnabled: Boolean
|
|
||||||
get() = false
|
|
||||||
|
|
||||||
override fun initNodeId(): PwNodeId<Int> {
|
override fun initNodeId(): PwNodeId<Int> {
|
||||||
return PwNodeIdInt()
|
return PwNodeIdInt()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,9 +52,6 @@ class PwGroupV4 : PwGroup<UUID, PwGroupV4, PwEntryV4>, NodeV4Interface {
|
|||||||
override val type: Type
|
override val type: Type
|
||||||
get() = Type.GROUP
|
get() = Type.GROUP
|
||||||
|
|
||||||
override val isSearchingEnabled: Boolean
|
|
||||||
get() = parent?.isSearchingEnabled ?: true
|
|
||||||
|
|
||||||
override fun initNodeId(): PwNodeId<UUID> {
|
override fun initNodeId(): PwNodeId<UUID> {
|
||||||
return PwNodeIdUUID()
|
return PwNodeIdUUID()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ abstract class PwNode<IdType, Parent : PwGroupInterface<Parent, Entry>, Entry :
|
|||||||
override fun afterAssignNewParent() {}
|
override fun afterAssignNewParent() {}
|
||||||
|
|
||||||
override fun isContainedIn(container: Parent): Boolean {
|
override fun isContainedIn(container: Parent): Boolean {
|
||||||
|
if (this == container)
|
||||||
|
return true
|
||||||
var cur = this.parent
|
var cur = this.parent
|
||||||
while (cur != null) {
|
while (cur != null) {
|
||||||
if (cur == container) {
|
if (cur == container) {
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ interface PwNodeInterface<ParentGroup> : NodeTimeInterface, Parcelable {
|
|||||||
*/
|
*/
|
||||||
var parent: ParentGroup?
|
var parent: ParentGroup?
|
||||||
|
|
||||||
val isSearchingEnabled: Boolean
|
|
||||||
|
|
||||||
fun containsParent(): Boolean
|
fun containsParent(): Boolean
|
||||||
|
|
||||||
fun afterAssignNewParent()
|
fun afterAssignNewParent()
|
||||||
|
|||||||
@@ -32,9 +32,6 @@ class EntrySearchHandlerV4(private val mSearchParametersV4: SearchParametersV4,
|
|||||||
private var now: Date = Date()
|
private var now: Date = Date()
|
||||||
|
|
||||||
override fun operate(node: PwEntryV4): Boolean {
|
override fun operate(node: PwEntryV4): Boolean {
|
||||||
if (mSearchParametersV4.respectEntrySearchingDisabled && !node.isSearchingEnabled) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mSearchParametersV4.excludeExpired && node.isExpires && now.after(node.expiryTime.date)) {
|
if (mSearchParametersV4.excludeExpired && node.isExpires && now.after(node.expiryTime.date)) {
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -64,10 +64,11 @@ class SearchDbHelper(private val isOmitBackup: Boolean) {
|
|||||||
return when {
|
return when {
|
||||||
incrementEntry >= max -> false
|
incrementEntry >= max -> false
|
||||||
database.isGroupSearchable(node, isOmitBackup) -> true
|
database.isGroupSearchable(node, isOmitBackup) -> true
|
||||||
else -> incrementEntry < max
|
else -> false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
|
false)
|
||||||
|
|
||||||
return searchGroup
|
return searchGroup
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ open class SearchParameters {
|
|||||||
var searchInNotes = true
|
var searchInNotes = true
|
||||||
var ignoreCase = true
|
var ignoreCase = true
|
||||||
var ignoreExpired = false
|
var ignoreExpired = false
|
||||||
var respectEntrySearchingDisabled = true
|
|
||||||
var excludeExpired = false
|
var excludeExpired = false
|
||||||
|
|
||||||
constructor()
|
constructor()
|
||||||
@@ -54,7 +53,6 @@ open class SearchParameters {
|
|||||||
searchInNotes = source.searchInNotes
|
searchInNotes = source.searchInNotes
|
||||||
ignoreCase = source.ignoreCase
|
ignoreCase = source.ignoreCase
|
||||||
ignoreExpired = source.ignoreExpired
|
ignoreExpired = source.ignoreExpired
|
||||||
respectEntrySearchingDisabled = source.respectEntrySearchingDisabled
|
|
||||||
excludeExpired = source.excludeExpired
|
excludeExpired = source.excludeExpired
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -150,7 +150,7 @@
|
|||||||
<string name="create_keepass_file">Create new database</string>
|
<string name="create_keepass_file">Create new database</string>
|
||||||
<string name="open_recent">Recent databases</string>
|
<string name="open_recent">Recent databases</string>
|
||||||
<string name="omitbackup_title">Don\'t search through backup entries</string>
|
<string name="omitbackup_title">Don\'t search through backup entries</string>
|
||||||
<string name="omitbackup_summary">Omits \"Backup\" group from search results (only applies to .kdb files)</string>
|
<string name="omitbackup_summary">Omits \"Backup\" and \"Recycle Bin\" groups from search results</string>
|
||||||
<string name="progress_create">Creating new database…</string>
|
<string name="progress_create">Creating new database…</string>
|
||||||
<string name="progress_title">Working…</string>
|
<string name="progress_title">Working…</string>
|
||||||
<string name="protection">Protection</string>
|
<string name="protection">Protection</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user