File indexing completed on 2024-12-22 05:05:25

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 #include "exportnotesjobinterfacetestimpl.h"
0007 #include "archivestorage.h"
0008 #include "resourceconvertertest.h"
0009 #include "saveresourceconfigtest.h"
0010 #include <KZip>
0011 
0012 ExportNotesJobInterfaceTestImpl::ExportNotesJobInterfaceTestImpl(QObject *parent,
0013                                                                  Utils::StoredTypes typeSelected,
0014                                                                  ArchiveStorage *archiveStorage,
0015                                                                  int numberOfStep)
0016     : ExportNotesJobInterface(parent, typeSelected, archiveStorage, numberOfStep)
0017 {
0018 }
0019 
0020 ExportNotesJobInterfaceTestImpl::~ExportNotesJobInterfaceTestImpl() = default;
0021 
0022 void ExportNotesJobInterfaceTestImpl::convertCollectionIdsToRealPath(KConfigGroup &selectFolderNoteGroup, const QString &selectFolderNoteGroupStr)
0023 {
0024     ResourceConverterTest resourceConverterTest;
0025     resourceConverterTest.setTestPath(mPathConfig);
0026     resourceConverterTest.convertCollectionIdsToRealPath(selectFolderNoteGroup, selectFolderNoteGroupStr);
0027 }
0028 
0029 QList<Utils::AkonadiInstanceInfo> ExportNotesJobInterfaceTestImpl::listOfResource()
0030 {
0031     return mListAkonadiInstanceInfo;
0032 }
0033 
0034 void ExportNotesJobInterfaceTestImpl::exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier)
0035 {
0036     SaveResourceConfigTest saveResourceConfig;
0037     saveResourceConfig.setArchive(mArchiveStorage->archive());
0038     saveResourceConfig.exportResourceToArchive(archivePath,
0039                                                url,
0040                                                identifier,
0041                                                Utils::resourceNoteArchiveName(),
0042                                                {QLatin1StringView("akonadi_akonotes_resource_")});
0043     slotNoteJobTerminated();
0044 }
0045 
0046 Akonadi::Collection::Id ExportNotesJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
0047 {
0048     ResourceConverterTest resourceConverterTest;
0049     resourceConverterTest.setTestPath(mPathConfig);
0050     return resourceConverterTest.convertFolderPathToCollectionId(path);
0051 }
0052 
0053 QString ExportNotesJobInterfaceTestImpl::resourcePath(const QString &identifier) const
0054 {
0055     ResourceConverterTest converter;
0056     converter.setTestPath(mPathConfig);
0057     const QString url = converter.resourcePath(identifier);
0058     return url;
0059 }
0060 
0061 QString ExportNotesJobInterfaceTestImpl::adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath)
0062 {
0063     ResourceConverterTest resourceConverterTest;
0064     resourceConverterTest.setTestPath(mPathConfig);
0065     return resourceConverterTest.adaptNewResourceUrl(overwriteResources, resourceConfig, storePath);
0066 }
0067 
0068 QString
0069 ExportNotesJobInterfaceTestImpl::createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings, bool synchronizeTree)
0070 {
0071     Q_UNUSED(resources);
0072     Q_UNUSED(settings);
0073     Q_UNUSED(name);
0074     Q_UNUSED(synchronizeTree);
0075     Q_UNREACHABLE();
0076     return {};
0077 }
0078 
0079 #include "moc_exportnotesjobinterfacetestimpl.cpp"