mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-06 14:07:38 +03:00
Add hasKey property to database and also make it accessible via the DatabaseWidget.
This commit is contained in:
parent
af8e21f125
commit
eb4f82a7ed
4 changed files with 17 additions and 1 deletions
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
Database::Database()
|
Database::Database()
|
||||||
{
|
{
|
||||||
|
m_hasKey = false;
|
||||||
m_metadata = new Metadata(this);
|
m_metadata = new Metadata(this);
|
||||||
setRootGroup(new Group());
|
setRootGroup(new Group());
|
||||||
rootGroup()->setUuid(Uuid::random());
|
rootGroup()->setUuid(Uuid::random());
|
||||||
|
@ -164,6 +165,7 @@ void Database::setKey(const CompositeKey& key, const QByteArray& transformSeed,
|
||||||
{
|
{
|
||||||
m_transformSeed = transformSeed;
|
m_transformSeed = transformSeed;
|
||||||
m_transformedMasterKey = key.transform(transformSeed, transformRounds());
|
m_transformedMasterKey = key.transform(transformSeed, transformRounds());
|
||||||
|
m_hasKey = true;
|
||||||
if (updateChangedTime) {
|
if (updateChangedTime) {
|
||||||
m_metadata->setMasterKeyChanged(QDateTime::currentDateTime());
|
m_metadata->setMasterKeyChanged(QDateTime::currentDateTime());
|
||||||
}
|
}
|
||||||
|
@ -174,3 +176,8 @@ void Database::setKey(const CompositeKey& key)
|
||||||
{
|
{
|
||||||
setKey(key, Random::randomArray(32));
|
setKey(key, Random::randomArray(32));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Database::hasKey()
|
||||||
|
{
|
||||||
|
return m_hasKey;
|
||||||
|
}
|
||||||
|
|
|
@ -81,6 +81,7 @@ public:
|
||||||
* Sets the database key and generates a random transform seed.
|
* Sets the database key and generates a random transform seed.
|
||||||
*/
|
*/
|
||||||
void setKey(const CompositeKey& key);
|
void setKey(const CompositeKey& key);
|
||||||
|
bool hasKey();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void groupDataChanged(Group* group);
|
void groupDataChanged(Group* group);
|
||||||
|
@ -103,6 +104,8 @@ private:
|
||||||
QByteArray m_transformSeed;
|
QByteArray m_transformSeed;
|
||||||
quint64 m_transformRounds;
|
quint64 m_transformRounds;
|
||||||
QByteArray m_transformedMasterKey;
|
QByteArray m_transformedMasterKey;
|
||||||
|
|
||||||
|
bool m_hasKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_DATABASE_H
|
#endif // KEEPASSX_DATABASE_H
|
||||||
|
|
|
@ -161,7 +161,7 @@ void DatabaseWidget::updateMasterKey(bool accepted)
|
||||||
m_db->setKey(m_changeMasterKeyWidget->newMasterKey());
|
m_db->setKey(m_changeMasterKeyWidget->newMasterKey());
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (m_db->transformedMasterKey().isEmpty()) { // TODO other test?
|
else if (m_db->hasKey()) {
|
||||||
Q_EMIT closeRequest();
|
Q_EMIT closeRequest();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -184,3 +184,8 @@ void DatabaseWidget::switchToMasterKeyChange()
|
||||||
m_changeMasterKeyWidget->clearForms();
|
m_changeMasterKeyWidget->clearForms();
|
||||||
setCurrentIndex(3);
|
setCurrentIndex(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DatabaseWidget::dbHasKey()
|
||||||
|
{
|
||||||
|
return m_db->hasKey();
|
||||||
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
explicit DatabaseWidget(Database* db, QWidget* parent = 0);
|
explicit DatabaseWidget(Database* db, QWidget* parent = 0);
|
||||||
GroupView* groupView();
|
GroupView* groupView();
|
||||||
EntryView* entryView();
|
EntryView* entryView();
|
||||||
|
bool dbHasKey();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void closeRequest();
|
void closeRequest();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue