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

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