Warning, file /pim/pim-data-exporter/core/addressbook/exportaddressbookjobinterfaceimpl.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002    SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "exportaddressbookjobinterfaceimpl.h"
0008 #include "exportresourcearchivejob.h"
0009 
0010 #include <Akonadi/AgentManager>
0011 #include <MailCommon/MailUtil>
0012 
0013 #include <KConfigGroup>
0014 
0015 #include "resourceconverterimpl.h"
0016 #include <QStandardPaths>
0017 
0018 ExportAddressbookJobInterfaceImpl::ExportAddressbookJobInterfaceImpl(QObject *parent,
0019                                                                      Utils::StoredTypes typeSelected,
0020                                                                      ArchiveStorage *archiveStorage,
0021                                                                      int numberOfStep)
0022     : ExportAddressbookJobInterface(parent, typeSelected, archiveStorage, numberOfStep)
0023 {
0024 }
0025 
0026 ExportAddressbookJobInterfaceImpl::~ExportAddressbookJobInterfaceImpl() = default;
0027 
0028 QList<Utils::AkonadiInstanceInfo> ExportAddressbookJobInterfaceImpl::listOfResource()
0029 {
0030     return Utils::listOfResource();
0031 }
0032 
0033 void ExportAddressbookJobInterfaceImpl::convertCollectionToRealPath(KConfigGroup &group, const QString &currentKey)
0034 {
0035     ResourceConverterImpl converter;
0036     converter.convertCollectionToRealPath(group, currentKey);
0037 }
0038 
0039 void ExportAddressbookJobInterfaceImpl::convertCollectionListToRealPath(KConfigGroup &group, const QString &currentKey)
0040 {
0041     ResourceConverterImpl converter;
0042     converter.convertCollectionListToRealPath(group, currentKey);
0043 }
0044 
0045 Akonadi::Collection::Id ExportAddressbookJobInterfaceImpl::convertFolderPathToCollectionId(const QString &path)
0046 {
0047     ResourceConverterImpl converter;
0048     return converter.convertFolderPathToCollectionId(path);
0049 }
0050 
0051 void ExportAddressbookJobInterfaceImpl::exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier)
0052 {
0053     auto resourceJob = new ExportResourceArchiveJob(this);
0054     resourceJob->setArchivePath(archivePath);
0055     resourceJob->setUrl(url);
0056     resourceJob->setIdentifier(identifier);
0057     resourceJob->setArchive(archive());
0058     resourceJob->setArchiveName(Utils::resourceAddressbookArchiveName());
0059     connect(resourceJob, &ExportResourceArchiveJob::error, this, &ExportAddressbookJobInterfaceImpl::emitError);
0060     connect(resourceJob, &ExportResourceArchiveJob::info, this, &ExportAddressbookJobInterfaceImpl::emitInfo);
0061     connect(resourceJob, &ExportResourceArchiveJob::terminated, this, &ExportAddressbookJobInterfaceImpl::slotAddressbookJobTerminated);
0062     resourceJob->start();
0063 }
0064 
0065 QString ExportAddressbookJobInterfaceImpl::resourcePath(const QString &agentIdentifier, const QString &defaultPath) const
0066 {
0067     ResourceConverterImpl converter;
0068     const QString url = converter.resourcePath(agentIdentifier, defaultPath);
0069     return url;
0070 }
0071 
0072 void ExportAddressbookJobInterfaceImpl::backupAddressBookResourceFile(const QString &agentIdentifier, const QString &defaultPath)
0073 {
0074     backupResourceFile(agentIdentifier, defaultPath);
0075 }
0076 
0077 QString ExportAddressbookJobInterfaceImpl::adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath)
0078 {
0079     ResourceConverterImpl converter;
0080     return converter.adaptNewResourceUrl(overwriteResources, resourceConfig, storePath);
0081 }
0082 
0083 QString
0084 ExportAddressbookJobInterfaceImpl::createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings, bool synchronizeTree)
0085 {
0086     Q_UNUSED(resources);
0087     Q_UNUSED(name);
0088     Q_UNUSED(settings);
0089     Q_UNUSED(synchronizeTree);
0090     Q_UNREACHABLE();
0091     return {};
0092 }
0093 
0094 #include "moc_exportaddressbookjobinterfaceimpl.cpp"