From 7286b1847dc0d53bf235f80d81dce953eb53ea00 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Fri, 12 Oct 2012 12:10:41 +0200 Subject: [PATCH] Add Database::verifyKey(). And make Database::hasKey() const. --- src/core/Database.cpp | 9 ++++++++- src/core/Database.h | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/core/Database.cpp b/src/core/Database.cpp index 23aa5ab62..3e656873b 100644 --- a/src/core/Database.cpp +++ b/src/core/Database.cpp @@ -215,11 +215,18 @@ void Database::setKey(const CompositeKey& key) setKey(key, Random::randomArray(32)); } -bool Database::hasKey() +bool Database::hasKey() const { return m_hasKey; } +bool Database::verifyKey(const CompositeKey& key) const +{ + Q_ASSERT(hasKey()); + + return (m_key.rawKey() == key.rawKey()); +} + void Database::createRecycleBin() { Group* recycleBin = Group::createRecycleBin(); diff --git a/src/core/Database.h b/src/core/Database.h index aa68df7fb..f4173441f 100644 --- a/src/core/Database.h +++ b/src/core/Database.h @@ -86,7 +86,8 @@ public: * Sets the database key and generates a random transform seed. */ void setKey(const CompositeKey& key); - bool hasKey(); + bool hasKey() const; + bool verifyKey(const CompositeKey& key) const; void recycleEntry(Entry* entry); void recycleGroup(Group* group); void setEmitModified(bool value);