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

Fix adapt path in config file

parent cd7a41cd
......@@ -43,6 +43,7 @@ void ExportAddressbookJobInterfaceTestImpl::exportArchiveResource()
Akonadi::Collection::Id ExportAddressbookJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return resourceConverterTest.convertFolderPathToCollectionId(path);
}
......@@ -65,18 +66,21 @@ void ExportAddressbookJobInterfaceTestImpl::setListOfResource(const QVector<Util
void ExportAddressbookJobInterfaceTestImpl::convertCollectionToRealPath(KConfigGroup &group, const QString &currentKey)
{
ResourceConverterTest resourceConverter;
resourceConverter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
resourceConverter.convertCollectionToRealPath(group, currentKey);
}
void ExportAddressbookJobInterfaceTestImpl::convertCollectionListToRealPath(KConfigGroup &group, const QString &currentKey)
{
ResourceConverterTest resourceConverter;
resourceConverter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
resourceConverter.convertCollectionListToRealPath(group, currentKey);
}
QString ExportAddressbookJobInterfaceTestImpl::resourcePath(const QString &agentIdentifier, const QString &defaultPath) const
{
ResourceConverterTest converter;
converter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
const QString url = converter.resourcePath(agentIdentifier, defaultPath);
return url;
}
......
......@@ -37,6 +37,7 @@ ImportAddressbookJobInterfaceTestImpl::~ImportAddressbookJobInterfaceTestImpl()
Akonadi::Collection::Id ImportAddressbookJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return resourceConverterTest.convertFolderPathToCollectionId(path);
}
......
......@@ -37,6 +37,7 @@ ImportAkregatorJobInterfaceTestImpl::~ImportAkregatorJobInterfaceTestImpl()
Akonadi::Collection::Id ImportAkregatorJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return resourceConverterTest.convertFolderPathToCollectionId(path);
}
......
......@@ -55,6 +55,7 @@ void ExportAlarmJobInterfaceTestImpl::setListOfResource(const QVector<Utils::Ako
Akonadi::Collection::Id ExportAlarmJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return resourceConverterTest.convertFolderPathToCollectionId(path);
}
......@@ -66,6 +67,7 @@ void ExportAlarmJobInterfaceTestImpl::exportResourceToArchive(const QString &arc
QString ExportAlarmJobInterfaceTestImpl::resourcePath(const QString &identifier) const
{
ResourceConverterTest converter;
converter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
const QString url = converter.resourcePath(identifier);
return url;
}
......
......@@ -37,6 +37,7 @@ ImportAlarmJobInterfaceTestImpl::~ImportAlarmJobInterfaceTestImpl()
Akonadi::Collection::Id ImportAlarmJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return resourceConverterTest.convertFolderPathToCollectionId(path);
}
......
......@@ -43,12 +43,14 @@ void ExportCalendarsJobInterfaceTestImpl::exportArchiveResource()
Akonadi::Collection::Id ExportCalendarsJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return resourceConverterTest.convertFolderPathToCollectionId(path);
}
QString ExportCalendarsJobInterfaceTestImpl::convertToFullCollectionPath(const qlonglong collectionValue)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return resourceConverterTest.convertToFullCollectionPath(collectionValue);
}
......@@ -71,6 +73,7 @@ void ExportCalendarsJobInterfaceTestImpl::setListOfResource(const QVector<Utils:
void ExportCalendarsJobInterfaceTestImpl::convertCollectionListToRealPath(KConfigGroup &group, const QString &currentKey)
{
ResourceConverterTest converter;
converter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
converter.convertCollectionListToRealPath(group, currentKey);
}
......@@ -100,6 +103,7 @@ void ExportCalendarsJobInterfaceTest::exportCalendarConfig()
QString ExportCalendarsJobInterfaceTestImpl::resourcePath(const QString &identifier) const
{
ResourceConverterTest converter;
converter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
const QString url = converter.resourcePath(identifier);
return url;
}
......@@ -37,6 +37,7 @@ ImportCalendarJobInterfaceTestImpl::~ImportCalendarJobInterfaceTestImpl()
Akonadi::Collection::Id ImportCalendarJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return resourceConverterTest.convertFolderPathToCollectionId(path);
}
......
......@@ -43,24 +43,28 @@ void ExportMailJobInterfaceTestImpl::exportArchiveResource()
void ExportMailJobInterfaceTestImpl::convertCollectionToRealPath(KConfigGroup &group, const QString &currentKey)
{
ResourceConverterTest resourceConverter;
resourceConverter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
resourceConverter.convertCollectionToRealPath(group, currentKey);
}
void ExportMailJobInterfaceTestImpl::convertCollectionListToRealPath(KConfigGroup &group, const QString &currentKey)
{
ResourceConverterTest resourceConverter;
resourceConverter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
resourceConverter.convertCollectionListToRealPath(group, currentKey);
}
void ExportMailJobInterfaceTestImpl::convertCollectionIdsToRealPath(KConfigGroup &group, const QString &currentKey, const QString &prefixCollection)
{
ResourceConverterTest resourceConverter;
resourceConverter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
resourceConverter.convertCollectionIdsToRealPath(group, currentKey, prefixCollection);
}
Akonadi::Collection::Id ExportMailJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return resourceConverterTest.convertFolderPathToCollectionId(path);
}
......@@ -115,6 +119,7 @@ void ExportMailJobInterfaceTest::exportMailConfig()
QString ExportMailJobInterfaceTestImpl::convertToFullCollectionPath(const qlonglong collectionValue)
{
ResourceConverterTest converter;
converter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return converter.convertToFullCollectionPath(collectionValue);
}
......@@ -122,6 +127,7 @@ QString ExportMailJobInterfaceTestImpl::convertToFullCollectionPath(const qlongl
QString ExportMailJobInterfaceTestImpl::resourcePath(const QString &identifier) const
{
ResourceConverterTest converter;
converter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
const QString url = converter.resourcePath(identifier);
return url;
}
......@@ -37,6 +37,7 @@ ImportMailJobInterfaceTestImpl::~ImportMailJobInterfaceTestImpl()
Akonadi::Collection::Id ImportMailJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return resourceConverterTest.convertFolderPathToCollectionId(path);
}
......
[General]
Path[$e]=$HOME/.local/notes/akonadi_akonotes_resource_5
TopLevelIsContainer=true
......@@ -38,6 +38,7 @@ ExportNotesJobInterfaceTestImpl::~ExportNotesJobInterfaceTestImpl()
void ExportNotesJobInterfaceTestImpl::convertCollectionIdsToRealPath(KConfigGroup &selectFolderNoteGroup, const QString &selectFolderNoteGroupStr)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
resourceConverterTest.convertCollectionIdsToRealPath(selectFolderNoteGroup, selectFolderNoteGroupStr);
}
......@@ -67,6 +68,7 @@ void ExportNotesJobInterfaceTestImpl::exportResourceToArchive(const QString &arc
Akonadi::Collection::Id ExportNotesJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return resourceConverterTest.convertFolderPathToCollectionId(path);
}
......@@ -124,6 +126,7 @@ void ExportNotesJobInterfaceTest::exportNoteConfigAndResource()
QString ExportNotesJobInterfaceTestImpl::resourcePath(const QString &identifier) const
{
ResourceConverterTest converter;
converter.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
const QString url = converter.resourcePath(identifier);
return url;
}
......@@ -38,6 +38,7 @@ ImportNotesJobInterfaceTestImpl::~ImportNotesJobInterfaceTestImpl()
Akonadi::Collection::Id ImportNotesJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
resourceConverterTest.setTestPath(QLatin1String(PIMDATAEXPORTER_DIR));
return resourceConverterTest.convertFolderPathToCollectionId(path);
}
......
......@@ -44,16 +44,18 @@ Akonadi::Collection::Id ResourceConverterTest::convertFolderPathToCollectionId(c
return result;
}
QString ResourceConverterTest::resourcePath(const QString &agentIdentifier, const QString &defaultPath)
QString ResourceConverterTest::changeResourcePath(QString url) const
{
const QString agentFileName = agentIdentifier + QStringLiteral("rc");
const QString configFileName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1Char('/') + agentFileName;
qDebug() << "configFileName " << configFileName;
KSharedConfigPtr resourceConfig = KSharedConfig::openConfig(configFileName);
//TODO fix me path
const QString url = ResourceConverterBase::resourcePath(resourceConfig, defaultPath);
qDebug() << " resourcePath " << url;
qDebug() << " need to fix " << url;
if (!url.isEmpty()) {
url.replace(QLatin1String("[TEST_PATH]"), mTestPath);
}
qDebug() <<" FIXED " << url;
//TODO FIXME
return url;
}
void ResourceConverterTest::setTestPath(const QString &testPath)
{
mTestPath = testPath;
}
......@@ -31,7 +31,12 @@ public:
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
Q_REQUIRED_RESULT QString resourcePath(const QString &agentIdentifier, const QString &defaultPath = QString()) override;
Q_REQUIRED_RESULT QString changeResourcePath(QString url) const override;
void setTestPath(const QString &testPath);
private:
QString mTestPath;
};
#endif // RESOURCECONVERTERTEST_H
......@@ -67,6 +67,25 @@ QString ResourceConverterBase::resourcePath(const KSharedConfigPtr &resourceConf
if (!url.isEmpty()) {
url.replace(QLatin1String("$HOME"), QDir::homePath());
}
url = changeResourcePath(url);
return url;
}
QString ResourceConverterBase::resourcePath(const QString &agentIdentifier, const QString &defaultPath)
{
const QString agentFileName = agentIdentifier + QStringLiteral("rc");
const QString configFileName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1Char('/') + agentFileName;
qDebug() << "configFileName " << configFileName;
KSharedConfigPtr resourceConfig = KSharedConfig::openConfig(configFileName);
const QString url = resourcePath(resourceConfig, defaultPath);
qDebug() << " resourcePath " << url;
return url;
}
QString ResourceConverterBase::changeResourcePath(QString url) const
{
return url;
}
......
......@@ -33,11 +33,13 @@ public:
void convertCollectionToRealPath(KConfigGroup &group, const QString &currentKey);
void convertCollectionListToRealPath(KConfigGroup &group, const QString &currentKey);
void convertCollectionIdsToRealPath(KConfigGroup &group, const QString &currentKey, const QString &prefixCollection = QString());
Q_REQUIRED_RESULT QString resourcePath(const QString &agentIdentifier, const QString &defaultPath = QString());
Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData);
virtual Q_REQUIRED_RESULT QString resourcePath(const KSharedConfigPtr &resourceConfig, const QString &defaultPath = QString());
virtual Q_REQUIRED_RESULT QString changeResourcePath(QString url) const;
virtual Q_REQUIRED_RESULT QString convertToFullCollectionPath(const qlonglong collectionValue) = 0;
virtual Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) = 0;
virtual Q_REQUIRED_RESULT QString resourcePath(const QString &agentIdentifier, const QString &defaultPath = QString()) = 0;
virtual Q_REQUIRED_RESULT QString resourcePath(const KSharedConfigPtr &resourceConfig, const QString &defaultPath = QString());
};
#endif // RESOURCECONVERTER_H
......@@ -37,22 +37,3 @@ Akonadi::Collection::Id ResourceConverterImpl::convertFolderPathToCollectionId(c
{
return MailCommon::Util::convertFolderPathToCollectionId(path);
}
QString ResourceConverterImpl::resourcePath(const QString &agentIdentifier, const QString &defaultPath)
{
const QString agentFileName = agentIdentifier + QStringLiteral("rc");
const QString configFileName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1Char('/') + agentFileName;
qDebug() << "configFileName " << configFileName;
KSharedConfigPtr resourceConfig = KSharedConfig::openConfig(configFileName);
const QString url = resourcePath(resourceConfig, defaultPath);
qDebug() << " resourcePath " << url;
return url;
}
QString ResourceConverterImpl::resourcePath(const KSharedConfigPtr &resourceConfig, const QString &defaultPath)
{
QString url = ResourceConverterBase::resourcePath(resourceConfig, defaultPath);
//TODO adapt path for test
return url;
}
......@@ -29,9 +29,6 @@ public:
~ResourceConverterImpl() override;
Q_REQUIRED_RESULT QString convertToFullCollectionPath(const qlonglong collectionValue) override;
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
Q_REQUIRED_RESULT QString resourcePath(const QString &agentIdentifier, const QString &defaultPath = QString()) override;
Q_REQUIRED_RESULT QString resourcePath(const KSharedConfigPtr &resourceConfig, const QString &defaultPath = QString()) override;
protected:
};
#endif // RESOURCECONVERTERIMPL_H
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