mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-25 07:19:42 -05:00
Implemented group sync
This commit is contained in:
parent
6f14becb8c
commit
3224460c6d
@ -62,6 +62,39 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void cloneIcon(Metadata* targetMetadata, const Database* sourceDb, const QUuid& iconUuid)
|
||||
{
|
||||
if (!iconUuid.isNull() && !targetMetadata->hasCustomIcon(iconUuid)) {
|
||||
targetMetadata->addCustomIcon(iconUuid, sourceDb->metadata()->customIcon(iconUuid));
|
||||
}
|
||||
}
|
||||
|
||||
void cloneEntries(Metadata* targetMetadata, const Group* sourceGroup, Group* targetGroup)
|
||||
{
|
||||
for (const Entry* sourceEntry : sourceGroup->entries()) {
|
||||
auto* targetEntry = sourceEntry->clone(Entry::CloneIncludeHistory);
|
||||
const bool updateTimeinfoEntry = targetEntry->canUpdateTimeinfo();
|
||||
targetEntry->setUpdateTimeinfo(false);
|
||||
targetEntry->setGroup(targetGroup);
|
||||
targetEntry->setUpdateTimeinfo(updateTimeinfoEntry);
|
||||
cloneIcon(targetMetadata, sourceEntry->database(), targetEntry->iconUuid());
|
||||
}
|
||||
}
|
||||
|
||||
void cloneChildren(Metadata* targetMetadata, const Group* sourceRoot, Group* targetRoot)
|
||||
{
|
||||
for (const Group* sourceGroup : sourceRoot->children()) {
|
||||
auto* targetGroup = sourceGroup->clone(Entry::CloneNoFlags, Group::CloneNoFlags);
|
||||
const bool updateTimeinfo = targetGroup->canUpdateTimeinfo();
|
||||
targetGroup->setUpdateTimeinfo(false);
|
||||
targetGroup->setParent(targetRoot);
|
||||
targetGroup->setUpdateTimeinfo(updateTimeinfo);
|
||||
cloneIcon(targetMetadata, sourceRoot->database(), targetGroup->iconUuid());
|
||||
cloneEntries(targetMetadata, sourceGroup, targetGroup);
|
||||
cloneChildren(targetMetadata, sourceGroup, targetGroup);
|
||||
}
|
||||
}
|
||||
|
||||
Database* extractIntoDatabase(const KeeShareSettings::Reference& reference, const Group* sourceRoot)
|
||||
{
|
||||
const auto* sourceDb = sourceRoot->database();
|
||||
@ -75,18 +108,9 @@ namespace
|
||||
targetRoot->setUpdateTimeinfo(false);
|
||||
KeeShare::setReferenceTo(targetRoot, KeeShareSettings::Reference());
|
||||
targetRoot->setUpdateTimeinfo(updateTimeinfo);
|
||||
const auto sourceEntries = sourceRoot->entriesRecursive(false);
|
||||
for (const Entry* sourceEntry : sourceEntries) {
|
||||
auto* targetEntry = sourceEntry->clone(Entry::CloneIncludeHistory);
|
||||
const bool updateTimeinfoEntry = targetEntry->canUpdateTimeinfo();
|
||||
targetEntry->setUpdateTimeinfo(false);
|
||||
targetEntry->setGroup(targetRoot);
|
||||
targetEntry->setUpdateTimeinfo(updateTimeinfoEntry);
|
||||
const auto iconUuid = targetEntry->iconUuid();
|
||||
if (!iconUuid.isNull() && !targetMetadata->hasCustomIcon(iconUuid)) {
|
||||
targetMetadata->addCustomIcon(iconUuid, sourceEntry->database()->metadata()->customIcon(iconUuid));
|
||||
}
|
||||
}
|
||||
cloneIcon(targetMetadata, sourceRoot->database(), targetRoot->iconUuid());
|
||||
cloneEntries(targetMetadata, sourceRoot, targetRoot);
|
||||
cloneChildren(targetMetadata, sourceRoot, targetRoot);
|
||||
|
||||
auto key = QSharedPointer<CompositeKey>::create();
|
||||
key->addKey(QSharedPointer<PasswordKey>::create(reference.password));
|
||||
|
Loading…
Reference in New Issue
Block a user