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
|
||||
}
|
||||
|
||||
override val isSearchingEnabled: Boolean
|
||||
get() = pwEntryV3?.isSearchingEnabled ?: pwEntryV4?.isSearchingEnabled ?: false
|
||||
|
||||
override var creationTime: PwDate
|
||||
get() = pwEntryV3?.creationTime ?: pwEntryV4?.creationTime ?: PwDate()
|
||||
set(value) {
|
||||
|
||||
@@ -130,9 +130,6 @@ class GroupVersioned : NodeVersioned, PwGroupInterface<GroupVersioned, EntryVers
|
||||
return contained ?: false
|
||||
}
|
||||
|
||||
override val isSearchingEnabled: Boolean
|
||||
get() = pwGroupV3?.isSearchingEnabled ?: pwGroupV4?.isSearchingEnabled ?: false
|
||||
|
||||
override var creationTime: PwDate
|
||||
get() = pwGroupV3?.creationTime ?: pwGroupV4?.creationTime ?: PwDate()
|
||||
set(value) {
|
||||
|
||||
@@ -323,8 +323,12 @@ abstract class PwDatabase<Group : PwGroup<*, Group, Entry>, Entry : PwEntry<Grou
|
||||
|
||||
abstract fun isBackup(group: Group): Boolean
|
||||
|
||||
open fun isGroupSearchable(group: Group?, omitBackup: Boolean): Boolean {
|
||||
return group != null
|
||||
fun isGroupSearchable(group: Group?, omitBackup: Boolean): Boolean {
|
||||
if (group == null)
|
||||
return false
|
||||
if (omitBackup && isBackup(group))
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -207,12 +207,6 @@ class PwDatabaseV3 : PwDatabase<PwGroupV3, PwEntryV3>() {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun isGroupSearchable(group: PwGroupV3?, omitBackup: Boolean): Boolean {
|
||||
return if (!super.isGroupSearchable(group, omitBackup)) {
|
||||
false
|
||||
} else !(omitBackup && isBackup(group!!))
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
private const val DEFAULT_ENCRYPTION_ROUNDS = 300
|
||||
|
||||
@@ -407,12 +407,6 @@ class PwDatabaseV4 : PwDatabase<PwGroupV4, PwEntryV4> {
|
||||
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 {
|
||||
if (key == null)
|
||||
return true
|
||||
|
||||
@@ -167,10 +167,6 @@ class PwEntryV3 : PwEntry<PwGroupV3, PwEntryV3> {
|
||||
override val type: Type
|
||||
get() = Type.ENTRY
|
||||
|
||||
override val isSearchingEnabled: Boolean
|
||||
get() = false
|
||||
|
||||
|
||||
fun setBinaryData(buf: ByteArray, offset: Int, len: Int) {
|
||||
/** Securely erase old data before copying new. */
|
||||
fill(binaryData, 0.toByte())
|
||||
|
||||
@@ -204,9 +204,6 @@ class PwEntryV4 : PwEntry<PwGroupV4, PwEntryV4>, NodeV4Interface {
|
||||
override val type: Type
|
||||
get() = Type.ENTRY
|
||||
|
||||
override val isSearchingEnabled: Boolean
|
||||
get() = parent?.isSearchingEnabled ?: true
|
||||
|
||||
override var username: String
|
||||
get() = decodeRefKey(mDecodeRef, STR_USERNAME)
|
||||
set(value) {
|
||||
|
||||
@@ -25,15 +25,21 @@ interface PwGroupInterface<Group: PwGroupInterface<Group, Entry>, Entry> : PwNod
|
||||
}
|
||||
|
||||
fun doForEachChild(entryHandler: NodeHandler<Entry>,
|
||||
groupHandler: NodeHandler<Group>?): Boolean {
|
||||
groupHandler: NodeHandler<Group>?,
|
||||
stopIterationWhenGroupHandlerFails: Boolean = true): Boolean {
|
||||
for (entry in this.getChildEntries()) {
|
||||
if (!entryHandler.operate(entry))
|
||||
return false
|
||||
}
|
||||
for (group in this.getChildGroups()) {
|
||||
if (groupHandler != null && !groupHandler.operate(group))
|
||||
return false
|
||||
group.doForEachChild(entryHandler, groupHandler)
|
||||
var doActionForChild = true
|
||||
if (groupHandler != null && !groupHandler.operate(group)) {
|
||||
doActionForChild = false
|
||||
if (stopIterationWhenGroupHandlerFails)
|
||||
return false
|
||||
}
|
||||
if (doActionForChild)
|
||||
group.doForEachChild(entryHandler, groupHandler)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -59,9 +59,6 @@ class PwGroupV3 : PwGroup<Int, PwGroupV3, PwEntryV3> {
|
||||
override val type: Type
|
||||
get() = Type.GROUP
|
||||
|
||||
override val isSearchingEnabled: Boolean
|
||||
get() = false
|
||||
|
||||
override fun initNodeId(): PwNodeId<Int> {
|
||||
return PwNodeIdInt()
|
||||
}
|
||||
|
||||
@@ -52,9 +52,6 @@ class PwGroupV4 : PwGroup<UUID, PwGroupV4, PwEntryV4>, NodeV4Interface {
|
||||
override val type: Type
|
||||
get() = Type.GROUP
|
||||
|
||||
override val isSearchingEnabled: Boolean
|
||||
get() = parent?.isSearchingEnabled ?: true
|
||||
|
||||
override fun initNodeId(): PwNodeId<UUID> {
|
||||
return PwNodeIdUUID()
|
||||
}
|
||||
|
||||
@@ -107,6 +107,8 @@ abstract class PwNode<IdType, Parent : PwGroupInterface<Parent, Entry>, Entry :
|
||||
override fun afterAssignNewParent() {}
|
||||
|
||||
override fun isContainedIn(container: Parent): Boolean {
|
||||
if (this == container)
|
||||
return true
|
||||
var cur = this.parent
|
||||
while (cur != null) {
|
||||
if (cur == container) {
|
||||
|
||||
@@ -21,8 +21,6 @@ interface PwNodeInterface<ParentGroup> : NodeTimeInterface, Parcelable {
|
||||
*/
|
||||
var parent: ParentGroup?
|
||||
|
||||
val isSearchingEnabled: Boolean
|
||||
|
||||
fun containsParent(): Boolean
|
||||
|
||||
fun afterAssignNewParent()
|
||||
|
||||
@@ -32,9 +32,6 @@ class EntrySearchHandlerV4(private val mSearchParametersV4: SearchParametersV4,
|
||||
private var now: Date = Date()
|
||||
|
||||
override fun operate(node: PwEntryV4): Boolean {
|
||||
if (mSearchParametersV4.respectEntrySearchingDisabled && !node.isSearchingEnabled) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (mSearchParametersV4.excludeExpired && node.isExpires && now.after(node.expiryTime.date)) {
|
||||
return true
|
||||
|
||||
@@ -64,10 +64,11 @@ class SearchDbHelper(private val isOmitBackup: Boolean) {
|
||||
return when {
|
||||
incrementEntry >= max -> false
|
||||
database.isGroupSearchable(node, isOmitBackup) -> true
|
||||
else -> incrementEntry < max
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
false)
|
||||
|
||||
return searchGroup
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ open class SearchParameters {
|
||||
var searchInNotes = true
|
||||
var ignoreCase = true
|
||||
var ignoreExpired = false
|
||||
var respectEntrySearchingDisabled = true
|
||||
var excludeExpired = false
|
||||
|
||||
constructor()
|
||||
@@ -54,7 +53,6 @@ open class SearchParameters {
|
||||
searchInNotes = source.searchInNotes
|
||||
ignoreCase = source.ignoreCase
|
||||
ignoreExpired = source.ignoreExpired
|
||||
respectEntrySearchingDisabled = source.respectEntrySearchingDisabled
|
||||
excludeExpired = source.excludeExpired
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
<string name="create_keepass_file">Create new database</string>
|
||||
<string name="open_recent">Recent databases</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_title">Working…</string>
|
||||
<string name="protection">Protection</string>
|
||||
|
||||
Reference in New Issue
Block a user