Commit 7d40ca4c authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Move method in importmailjobinterface directly

parent 8602b015
......@@ -242,31 +242,6 @@ qint64 AbstractImportExportJob::convertRealPathToCollection(KConfigGroup &group,
return colId;
}
void AbstractImportExportJob::convertRealPathToCollectionList(KConfigGroup &group, const QString &currentKey, bool addCollectionPrefix)
{
if (group.hasKey(currentKey)) {
const QStringList listExpension = group.readEntry(currentKey, QStringList());
QStringList result;
if (!listExpension.isEmpty()) {
for (const QString &collection : listExpension) {
const Akonadi::Collection::Id id = convertPathToId(collection);
if (id != -1) {
if (addCollectionPrefix) {
result << QStringLiteral("c%1").arg(id);
} else {
result << QStringLiteral("%1").arg(id);
}
}
}
if (result.isEmpty()) {
group.deleteEntry(currentKey);
} else {
group.writeEntry(currentKey, result);
}
}
}
}
Akonadi::Collection::Id AbstractImportExportJob::convertPathToId(const QString &path)
{
if (path.isEmpty()) {
......@@ -638,18 +613,35 @@ void AbstractImportExportJob::importDataSubdirectory(const QString &subdirectory
}
}
void AbstractImportExportJob::convertCollectionStrToAkonadiId(const KSharedConfig::Ptr &config, const QString &groupName, const QString &key)
void AbstractImportExportJob::convertCollectionListStrToAkonadiId(const KSharedConfig::Ptr &config, const QString &groupName, const QString &key, bool addCollectionPrefix)
{
if (config->hasGroup(groupName)) {
KConfigGroup eventGroup = config->group(groupName);
(void)convertRealPathToCollection(eventGroup, key, false);
KConfigGroup group = config->group(groupName);
convertRealPathToCollectionList(group, key, addCollectionPrefix);
}
}
void AbstractImportExportJob::convertCollectionListStrToAkonadiId(const KSharedConfig::Ptr &config, const QString &groupName, const QString &key, bool addCollectionPrefix)
void AbstractImportExportJob::convertRealPathToCollectionList(KConfigGroup &group, const QString &currentKey, bool addCollectionPrefix)
{
if (config->hasGroup(groupName)) {
KConfigGroup group = config->group(groupName);
convertRealPathToCollectionList(group, key, addCollectionPrefix);
if (group.hasKey(currentKey)) {
const QStringList listExpension = group.readEntry(currentKey, QStringList());
QStringList result;
if (!listExpension.isEmpty()) {
for (const QString &collection : listExpension) {
const Akonadi::Collection::Id id = convertPathToId(collection);
if (id != -1) {
if (addCollectionPrefix) {
result << QStringLiteral("c%1").arg(id);
} else {
result << QStringLiteral("%1").arg(id);
}
}
}
if (result.isEmpty()) {
group.deleteEntry(currentKey);
} else {
group.writeEntry(currentKey, result);
}
}
}
}
......@@ -80,7 +80,6 @@ protected:
void extractZipFile(const KArchiveFile *file, const QString &source, const QString &destination, bool isStoredAsZippedArchive = true);
Q_REQUIRED_RESULT qint64 convertRealPathToCollection(KConfigGroup &group, const QString &currentKey, bool addCollectionPrefix = false);
void convertRealPathToCollectionList(KConfigGroup &group, const QString &currentKey, bool addCollectionPrefix = true);
void copyToFile(const KArchiveFile *archivefile, const QString &dest, const QString &filename, const QString &prefix);
void initializeImportJob();
void backupFile(const QString &filename, const QString &path, const QString &storedName);
......@@ -126,8 +125,9 @@ protected:
int mIndex = -1;
static int sArchiveVersion;
void convertCollectionStrToAkonadiId(const KSharedConfig::Ptr &config, const QString &groupName, const QString &key);
void convertCollectionListStrToAkonadiId(const KSharedConfig::Ptr &config, const QString &groupName, const QString &key, bool addCollectionPrefix);
void convertRealPathToCollectionList(KConfigGroup &group, const QString &currentKey, bool addCollectionPrefix = true);
private:
void slotAllResourceSynchronized();
void slotSynchronizeInstanceDone(const QString &, const QString &identifier);
......
......@@ -20,6 +20,7 @@
#include "importmailjobinterface.h"
#include "archivestorage.h"
#include "importexportmailutil.h"
#include "resourceconverterimpl.h"
#include <MailCommon/FilterManager>
#include <MailCommon/FilterImporterExporter>
......@@ -46,7 +47,6 @@
#include <QStandardPaths>
#include <QTimer>
#include <QRegularExpression>
#include "resourceconverterimpl.h"
using namespace Akonadi;
namespace {
......@@ -1250,7 +1250,7 @@ void ImportMailJobInterface::importKmailConfig(const KArchiveFile *kmailsnippet,
(void)convertRealPathToCollection(favoriteGroup, currentKey, true);
const QString expensionKey(QStringLiteral("Expansion"));
(void)convertRealPathToCollectionList(favoriteGroup, expensionKey);
convertRealPathToCollectionList(favoriteGroup, expensionKey);
}
convertCollectionListStrToAkonadiId(kmailConfig, QStringLiteral("FavoriteCollections"), QStringLiteral("FavoriteCollectionIds"), false);
......@@ -1465,3 +1465,12 @@ void ImportMailJobInterface::mergeSieveTemplate(const KArchiveFile *archivefile,
grpExisting.writeEntry(QStringLiteral("templateCount"), numberOfExistingTemplate);
grpExisting.sync();
}
void ImportMailJobInterface::convertCollectionStrToAkonadiId(const KSharedConfig::Ptr &config, const QString &groupName, const QString &key)
{
if (config->hasGroup(groupName)) {
KConfigGroup eventGroup = config->group(groupName);
(void)convertRealPathToCollection(eventGroup, key, false);
}
}
......@@ -47,6 +47,7 @@ public:
protected:
void slotNextStep() override;
void convertCollectionStrToAkonadiId(const KSharedConfig::Ptr &config, const QString &groupName, const QString &key);
private:
void registerSpecialCollection(Akonadi::SpecialMailCollections::Type type, qint64 colId);
void restoreTransports();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment