Commit d6090985 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Remove duplicate code

parent 5293d14a
......@@ -29,12 +29,7 @@
#include <QFile>
#include <QDir>
#include <QStandardPaths>
namespace {
inline const QString storeAddressbook()
{
return QStringLiteral("backupaddressbook/");
}
}
ImportAddressbookJobInterface::ImportAddressbookJobInterface(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep)
: AbstractImportExportJob(parent, archiveStorage, typeSelected, numberOfStep)
{
......@@ -192,7 +187,7 @@ void ImportAddressbookJobInterface::restoreResources()
QString filename(resourceName);
KSharedConfig::Ptr resourceConfig = KSharedConfig::openConfig(copyToDirName + QLatin1Char('/') + resourceName);
//TODO fix default path
//TODO fix default path ????? backupaddressbook ???
const QString newUrl = adaptResourcePath(resourceConfig, QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/contacts"));
QFileInfo newUrlInfo(newUrl);
const QString dataFile = value.akonadiResources;
......
......@@ -33,13 +33,6 @@
#include <QStandardPaths>
#include <QTimer>
namespace {
inline const QString storeAlarm()
{
return QStringLiteral("backupalarm/");
}
}
ImportAlarmJobInterface::ImportAlarmJobInterface(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep)
: AbstractImportExportJob(parent, archiveStorage, typeSelected, numberOfStep)
{
......@@ -122,7 +115,7 @@ void ImportAlarmJobInterface::restoreResources()
setProgressDialogLabel(i18n("Restore resources..."));
increaseProgressDialog();
QStringList listResource;
listResource << restoreResourceFile(QStringLiteral("akonadi_kalarm_resource"), Utils::alarmPath(), storeAlarm(), false);
listResource << restoreResourceFile(QStringLiteral("akonadi_kalarm_resource"), Utils::alarmPath(), Utils::storeAlarm(), false);
if (!mListResourceFile.isEmpty()) {
QDir dir(mTempDirName);
dir.mkdir(Utils::alarmPath());
......@@ -146,7 +139,7 @@ void ImportAlarmJobInterface::restoreResources()
KSharedConfig::Ptr resourceConfig = KSharedConfig::openConfig(copyToDirName + QLatin1Char('/') + resourceName);
const QString newUrl = adaptResourcePath(resourceConfig, storeAlarm());
const QString newUrl = adaptResourcePath(resourceConfig, Utils::storeAlarm());
QFileInfo newUrlInfo(newUrl);
const QString dataFile = value.akonadiResources;
const KArchiveEntry *dataResouceEntry = mArchiveDirectory->entry(dataFile);
......
......@@ -34,7 +34,7 @@ ImportNotesJobInterfaceTestImpl::ImportNotesJobInterfaceTestImpl(QObject *parent
ImportNotesJobInterfaceTestImpl::~ImportNotesJobInterfaceTestImpl()
{
//Clean up temp repo
QVERIFY(QDir(QDir::tempPath() + QStringLiteral("/backupnote/")).removeRecursively());
QVERIFY(QDir(QDir::tempPath() + QLatin1Char('/') + Utils::backupnote()).removeRecursively());
}
Akonadi::Collection::Id ImportNotesJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
......
......@@ -35,13 +35,6 @@
#include <QTimer>
#include <QColor>
namespace {
inline const QString storeCalendar()
{
return QStringLiteral("backupcalendar/");
}
}
ImportCalendarJobInterface::ImportCalendarJobInterface(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep)
: AbstractImportExportJob(parent, archiveStorage, typeSelected, numberOfStep)
{
......@@ -259,7 +252,7 @@ void ImportCalendarJobInterface::restoreResources()
setProgressDialogLabel(i18n("Restore resources..."));
increaseProgressDialog();
QStringList listResource;
listResource << restoreResourceFile(QStringLiteral("akonadi_ical_resource"), Utils::calendarPath(), storeCalendar());
listResource << restoreResourceFile(QStringLiteral("akonadi_ical_resource"), Utils::calendarPath(), Utils::storeCalendar());
if (!mListResourceFile.isEmpty()) {
QDir dir(mTempDirName);
......@@ -284,7 +277,7 @@ void ImportCalendarJobInterface::restoreResources()
KSharedConfig::Ptr resourceConfig = KSharedConfig::openConfig(copyToDirName + QLatin1Char('/') + resourceName);
const QString newUrl = adaptResourcePath(resourceConfig, storeCalendar());
const QString newUrl = adaptResourcePath(resourceConfig, Utils::storeCalendar());
QFileInfo newUrlInfo(newUrl);
const QString dataFile = value.akonadiResources;
......
......@@ -45,12 +45,6 @@
#include <QRegularExpression>
using namespace Akonadi;
namespace {
inline const QString storeMails()
{
return QStringLiteral("backupmail/");
}
}
ImportMailJobInterface::ImportMailJobInterface(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep)
: AbstractImportExportJob(parent, archiveStorage, typeSelected, numberOfStep)
......@@ -547,7 +541,7 @@ void ImportMailJobInterface::restoreMails()
//qCDebug(PIMDATAEXPORTERCORE_LOG)<<" filename "<<filename<<" resourceName"<<resourceName;
KSharedConfig::Ptr resourceConfig = KSharedConfig::openConfig(copyToDirName + QLatin1Char('/') + resourceName);
const QString newUrl = adaptResourcePath(resourceConfig, storeMails());
const QString newUrl = adaptResourcePath(resourceConfig, Utils::storeMails());
const QString agentConfigFile = value.akonadiAgentConfigFile;
if (!agentConfigFile.isEmpty()) {
......
......@@ -30,12 +30,7 @@
#include <QStandardPaths>
#include <QDir>
#include <QTimer>
namespace {
inline const QString backupnote()
{
return QStringLiteral("backupnote/");
}
}
ImportNotesJobInterface::ImportNotesJobInterface(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep)
: AbstractImportExportJob(parent, archiveStorage, typeSelected, numberOfStep)
......@@ -173,7 +168,7 @@ void ImportNotesJobInterface::restoreResources()
KSharedConfig::Ptr resourceConfig = KSharedConfig::openConfig(copyToDirName + QLatin1Char('/') + resourceName);
const QString newUrl = adaptResourcePath(resourceConfig, backupnote());
const QString newUrl = adaptResourcePath(resourceConfig, Utils::backupnote());
QFileInfo newUrlInfo(newUrl);
const QString dataFile = value.akonadiResources;
const KArchiveEntry *dataResouceEntry = mArchiveDirectory->entry(dataFile);
......
......@@ -34,6 +34,31 @@
#include <QDir>
#include <QStandardPaths>
QString Utils::storeAddressbook()
{
return QStringLiteral("backupaddressbook/");
}
QString Utils::storeAlarm()
{
return QStringLiteral("backupalarm/");
}
QString Utils::storeCalendar()
{
return QStringLiteral("backupcalendar/");
}
QString Utils::backupnote()
{
return QStringLiteral("backupnote/");
}
QString Utils::storeMails()
{
return QStringLiteral("backupmail/");
}
QString Utils::exportDataTypeFileName()
{
return QStringLiteral("exportdatatype.xml");
......
......@@ -92,6 +92,13 @@ PIMDATAEXPORTER_EXPORT Q_REQUIRED_RESULT QString alarmPath();
PIMDATAEXPORTER_EXPORT Q_REQUIRED_RESULT QString infoPath();
PIMDATAEXPORTER_EXPORT Q_REQUIRED_RESULT QString notePath();
PIMDATAEXPORTER_EXPORT Q_REQUIRED_RESULT QString storeMails();
PIMDATAEXPORTER_EXPORT Q_REQUIRED_RESULT QString backupnote();
PIMDATAEXPORTER_EXPORT Q_REQUIRED_RESULT QString storeCalendar();
PIMDATAEXPORTER_EXPORT Q_REQUIRED_RESULT QString storeAlarm();
PIMDATAEXPORTER_EXPORT Q_REQUIRED_RESULT QString storeAddressbook();
PIMDATAEXPORTER_EXPORT Q_REQUIRED_RESULT QString resourceNoteArchiveName();
PIMDATAEXPORTER_EXPORT Q_REQUIRED_RESULT QString resourceAddressbookArchiveName();
PIMDATAEXPORTER_EXPORT Q_REQUIRED_RESULT QString resourceAlarmArchiveName();
......
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