mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-12 15:59:58 -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)
|
Database* extractIntoDatabase(const KeeShareSettings::Reference& reference, const Group* sourceRoot)
|
||||||
{
|
{
|
||||||
const auto* sourceDb = sourceRoot->database();
|
const auto* sourceDb = sourceRoot->database();
|
||||||
@ -75,18 +108,9 @@ namespace
|
|||||||
targetRoot->setUpdateTimeinfo(false);
|
targetRoot->setUpdateTimeinfo(false);
|
||||||
KeeShare::setReferenceTo(targetRoot, KeeShareSettings::Reference());
|
KeeShare::setReferenceTo(targetRoot, KeeShareSettings::Reference());
|
||||||
targetRoot->setUpdateTimeinfo(updateTimeinfo);
|
targetRoot->setUpdateTimeinfo(updateTimeinfo);
|
||||||
const auto sourceEntries = sourceRoot->entriesRecursive(false);
|
cloneIcon(targetMetadata, sourceRoot->database(), targetRoot->iconUuid());
|
||||||
for (const Entry* sourceEntry : sourceEntries) {
|
cloneEntries(targetMetadata, sourceRoot, targetRoot);
|
||||||
auto* targetEntry = sourceEntry->clone(Entry::CloneIncludeHistory);
|
cloneChildren(targetMetadata, sourceRoot, targetRoot);
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto key = QSharedPointer<CompositeKey>::create();
|
auto key = QSharedPointer<CompositeKey>::create();
|
||||||
key->addKey(QSharedPointer<PasswordKey>::create(reference.password));
|
key->addKey(QSharedPointer<PasswordKey>::create(reference.password));
|
||||||
|
Loading…
Reference in New Issue
Block a user