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

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 "exportcalendarsjobinterfacetestimpl.h"
0008 #include "archivestorage.h"
0009 #include "resourceconvertertest.h"
0010 #include "saveresourceconfigtest.h"
0011 #include "testbackupresourcefilejob.h"
0012 #include <QDebug>
0013 
0014 ExportCalendarsJobInterfaceTestImpl::ExportCalendarsJobInterfaceTestImpl(QObject *parent,
0015                                                                          Utils::StoredTypes typeSelected,
0016                                                                          ArchiveStorage *archiveStorage,
0017                                                                          int numberOfStep)
0018     : ExportCalendarJobInterface(parent, typeSelected, archiveStorage, numberOfStep)
0019 {
0020 }
0021 
0022 ExportCalendarsJobInterfaceTestImpl::~ExportCalendarsJobInterfaceTestImpl() = default;
0023 
0024 Akonadi::Collection::Id ExportCalendarsJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
0025 {
0026     ResourceConverterTest resourceConverterTest;
0027     resourceConverterTest.setTestPath(mPathConfig);
0028     return resourceConverterTest.convertFolderPathToCollectionId(path);
0029 }
0030 
0031 QString ExportCalendarsJobInterfaceTestImpl::convertToFullCollectionPath(const qlonglong collectionValue)
0032 {
0033     ResourceConverterTest resourceConverterTest;
0034     resourceConverterTest.setTestPath(mPathConfig);
0035     return resourceConverterTest.convertToFullCollectionPath(collectionValue);
0036 }
0037 
0038 void ExportCalendarsJobInterfaceTestImpl::exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier)
0039 {
0040     qDebug() << " void ExportCalendarsJobInterfaceTestImpl::exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier)"
0041              << identifier;
0042     SaveResourceConfigTest saveResourceConfig;
0043     saveResourceConfig.setArchive(mArchiveStorage->archive());
0044     saveResourceConfig.exportResourceToArchive(archivePath,
0045                                                url,
0046                                                identifier,
0047                                                Utils::resourceCalendarArchiveName(),
0048                                                {QLatin1StringView("akonadi_icaldir_resource_")});
0049     slotCalendarJobTerminated();
0050 }
0051 
0052 QList<Utils::AkonadiInstanceInfo> ExportCalendarsJobInterfaceTestImpl::listOfResource()
0053 {
0054     return mListAkonadiInstanceInfo;
0055 }
0056 
0057 void ExportCalendarsJobInterfaceTestImpl::convertCollectionListToRealPath(KConfigGroup &group, const QString &currentKey)
0058 {
0059     ResourceConverterTest converter;
0060     converter.setTestPath(mPathConfig);
0061     converter.convertCollectionListToRealPath(group, currentKey);
0062 }
0063 
0064 QString ExportCalendarsJobInterfaceTestImpl::resourcePath(const QString &identifier) const
0065 {
0066     ResourceConverterTest converter;
0067     converter.setTestPath(mPathConfig);
0068     const QString url = converter.resourcePath(identifier);
0069     return url;
0070 }
0071 
0072 void ExportCalendarsJobInterfaceTestImpl::backupCalendarResourceFile(const QString &agentIdentifier, const QString &defaultPath)
0073 {
0074     auto job = new TestBackupResourceFileJob(this);
0075     job->setDefaultPath(defaultPath);
0076     job->setIdentifier(agentIdentifier);
0077     job->setTestPath(mPathConfig);
0078     job->setZip(archive());
0079     connect(job, &TestBackupResourceFileJob::error, this, &ExportCalendarsJobInterfaceTestImpl::error);
0080     connect(job, &TestBackupResourceFileJob::info, this, &ExportCalendarsJobInterfaceTestImpl::info);
0081     job->start();
0082 }
0083 
0084 QString ExportCalendarsJobInterfaceTestImpl::adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath)
0085 {
0086     ResourceConverterTest resourceConverterTest;
0087     resourceConverterTest.setTestPath(mPathConfig);
0088     return resourceConverterTest.adaptNewResourceUrl(overwriteResources, resourceConfig, storePath);
0089 }
0090 
0091 QString ExportCalendarsJobInterfaceTestImpl::createResource(const QString &resources,
0092                                                             const QString &name,
0093                                                             const QMap<QString, QVariant> &settings,
0094                                                             bool synchronizeTree)
0095 {
0096     Q_UNUSED(resources);
0097     Q_UNUSED(settings);
0098     Q_UNUSED(name);
0099     Q_UNUSED(synchronizeTree);
0100     Q_UNREACHABLE();
0101     return {};
0102 }
0103 
0104 #include "moc_exportcalendarsjobinterfacetestimpl.cpp"