Skip to content

Commit

Permalink
Browser connection keys and rules are stored in custom data instead o…
Browse files Browse the repository at this point in the history
…f attributes
  • Loading branch information
varjolintu committed Feb 21, 2018
1 parent f15088f commit 06fadb4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/browser/BrowserEntryConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void BrowserEntryConfig::setRealm(const QString& realm)

bool BrowserEntryConfig::load(const Entry* entry)
{
QString s = entry->attributes()->value(KEEPASSBROWSER_NAME);
QString s = entry->customData()->value(KEEPASSBROWSER_NAME);
if (s.isEmpty()) {
return false;
}
Expand All @@ -105,5 +105,5 @@ void BrowserEntryConfig::save(Entry* entry)
QVariantMap v = qo2qv(this);
QJsonObject o = QJsonObject::fromVariantMap(v);
QByteArray json = QJsonDocument(o).toJson(QJsonDocument::Compact);
entry->attributes()->set(KEEPASSBROWSER_NAME, json);
entry->customData()->set(KEEPASSBROWSER_NAME, json);
}
24 changes: 12 additions & 12 deletions src/browser/BrowserService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ QString BrowserService::getDatabaseRootUuid()
{
Database* db = getDatabase();
if (!db) {
return QString();
return {};
}

Group* rootGroup = db->rootGroup();
if (!rootGroup) {
return QString();
return {};
}

return rootGroup->uuid().toHex();
Expand All @@ -122,12 +122,12 @@ QString BrowserService::getDatabaseRecycleBinUuid()
{
Database* db = getDatabase();
if (!db) {
return QString();
return {};
}

Group* recycleBin = db->metadata()->recycleBin();
if (!recycleBin) {
return QString();
return {};
}
return recycleBin->uuid().toHex();
}
Expand Down Expand Up @@ -200,7 +200,7 @@ QString BrowserService::storeKey(const QString& key)
return {};
}

contains = config->attributes()->contains(QLatin1String(ASSOCIATE_KEY_PREFIX) + id);
contains = config->customData()->contains(QLatin1String(ASSOCIATE_KEY_PREFIX) + id);
if (contains) {
dialogResult = QMessageBox::warning(nullptr, tr("KeePassXC: Overwrite existing key?"),
tr("A shared encryption key with the name \"%1\" "
Expand All @@ -210,18 +210,18 @@ QString BrowserService::storeKey(const QString& key)
}
} while (contains && dialogResult == QMessageBox::No);

config->attributes()->set(QLatin1String(ASSOCIATE_KEY_PREFIX) + id, key, true);
config->customData()->set(QLatin1String(ASSOCIATE_KEY_PREFIX) + id, key);
return id;
}

QString BrowserService::getKey(const QString& id)
{
Entry* config = getConfigEntry();
if (!config) {
return QString();
return {};
}

return config->attributes()->value(QLatin1String(ASSOCIATE_KEY_PREFIX) + id);
return config->customData()->value(QLatin1String(ASSOCIATE_KEY_PREFIX) + id);
}

QJsonArray BrowserService::findMatchingEntries(const QString& id, const QString& url, const QString& submitUrl, const QString& realm)
Expand Down Expand Up @@ -429,7 +429,7 @@ void BrowserService::removeSharedEncryptionKeys()
}

QStringList keysToRemove;
for (const QString& key : entry->attributes()->keys()) {
for (const QString& key : entry->customData()->keys()) {
if (key.startsWith(ASSOCIATE_KEY_PREFIX)) {
keysToRemove << key;
}
Expand All @@ -444,7 +444,7 @@ void BrowserService::removeSharedEncryptionKeys()

entry->beginUpdate();
for (const QString& key : keysToRemove) {
entry->attributes()->remove(key);
entry->customData()->remove(key);
}
entry->endUpdate();

Expand Down Expand Up @@ -481,9 +481,9 @@ void BrowserService::removeStoredPermissions()
return;
}

if (entry->attributes()->contains(KEEPASSXCBROWSER_NAME)) {
if (entry->customData()->contains(KEEPASSXCBROWSER_NAME)) {
entry->beginUpdate();
entry->attributes()->remove(KEEPASSXCBROWSER_NAME);
entry->customData()->remove(KEEPASSXCBROWSER_NAME);
entry->endUpdate();
++counter;
}
Expand Down

0 comments on commit 06fadb4

Please sign in to comment.