Commit 8e9885f4 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Continue to implement autotest

parent 16aaee40
......@@ -375,7 +375,8 @@ QStringList AbstractImportExportJob::restoreResourceFile(const QString &resource
ResourceConverterImpl converter;
QString newUrl;
if (overwriteResources) {
newUrl = converter.resourcePath(resourceConfig);
//TODO fix me too
newUrl = converter.ResourceConverterBase::resourcePath(resourceConfig);
} else {
newUrl = converter.adaptResourcePath(resourceConfig, storePath);
}
......
......@@ -90,8 +90,7 @@ void ExportAddressbookJobInterface::slotWriteNextArchiveResource()
if (identifier.contains(QLatin1String("akonadi_vcarddir_resource_")) || identifier.contains(QLatin1String("akonadi_contacts_resource_"))) {
const QString archivePath = Utils::addressbookPath() + identifier + QLatin1Char('/');
ResourceConverterImpl converter;
const QString url = converter.resourcePath(identifier, QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/contacts/"));
const QString url = resourcePath(identifier, QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/contacts/"));
if (!mAgentPaths.contains(url)) {
if (!url.isEmpty()) {
mAgentPaths << url;
......
......@@ -42,6 +42,7 @@ protected:
void slotCheckBackupConfig();
virtual void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) = 0;
virtual Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() = 0;
virtual Q_REQUIRED_RESULT QString resourcePath(const QString &agentIdentifier, const QString &defaultPath) const = 0;
private:
void slotCheckBackupResource();
......
......@@ -82,3 +82,10 @@ void ExportAddressbookJobInterfaceImpl::exportResourceToArchive(const QString &a
connect(resourceJob, &ExportResourceArchiveJob::terminated, this, &ExportAddressbookJobInterfaceImpl::slotAddressbookJobTerminated);
resourceJob->start();
}
QString ExportAddressbookJobInterfaceImpl::resourcePath(const QString &agentIdentifier, const QString &defaultPath) const
{
ResourceConverterImpl converter;
const QString url = converter.resourcePath(agentIdentifier, defaultPath);
return url;
}
......@@ -38,6 +38,7 @@ protected:
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString resourcePath(const QString &agentIdentifier, const QString &defaultPath) const override;
};
#endif // EXPORTADDRESSBOOKINTERFACEIMPL_H
......@@ -71,8 +71,7 @@ void ExportAlarmJobInterface::slotWriteNextArchiveResource()
if (identifier.contains(QLatin1String("akonadi_kalarm_dir_resource_"))) {
const QString archivePath = Utils::alarmPath() + identifier + QLatin1Char('/');
ResourceConverterImpl converter;
const QString url = converter.resourcePath(identifier);
const QString url = resourcePath(identifier);
if (!mAgentPaths.contains(url)) {
if (!url.isEmpty()) {
mAgentPaths << url;
......
......@@ -39,6 +39,7 @@ protected:
void slotCheckBackupConfig();
virtual void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) = 0;
virtual Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() = 0;
virtual Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const = 0;
private:
void slotCheckBackupResource();
......
......@@ -70,3 +70,11 @@ void ExportAlarmJobInterfaceImpl::exportResourceToArchive(const QString &archive
connect(resourceJob, &ExportResourceArchiveJob::terminated, this, &ExportAlarmJobInterfaceImpl::slotAlarmJobTerminated);
resourceJob->start();
}
QString ExportAlarmJobInterfaceImpl::resourcePath(const QString &identifier) const
{
ResourceConverterImpl converter;
const QString url = converter.resourcePath(identifier);
return url;
}
......@@ -37,6 +37,7 @@ protected:
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const override;
};
#endif // EXPORTALARMJOBINTERFACEIMPL_H
......@@ -74,6 +74,13 @@ void ExportAddressbookJobInterfaceTestImpl::convertCollectionListToRealPath(KCon
resourceConverter.convertCollectionListToRealPath(group, currentKey);
}
QString ExportAddressbookJobInterfaceTestImpl::resourcePath(const QString &agentIdentifier, const QString &defaultPath) const
{
ResourceConverterTest converter;
const QString url = converter.resourcePath(agentIdentifier, defaultPath);
return url;
}
ExportAddressbookJobInterfaceTest::ExportAddressbookJobInterfaceTest(QObject *parent)
: QObject(parent)
{
......@@ -97,3 +104,5 @@ void ExportAddressbookJobInterfaceTest::exportAddressBookConfig()
file->start();
delete exportNote;
}
......@@ -41,6 +41,7 @@ protected:
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString resourcePath(const QString &agentIdentifier, const QString &defaultPath = QString()) const override;
private:
QVector<Utils::AkonadiInstanceInfo> mListAkonadiInstanceInfo;
};
......
......@@ -63,6 +63,13 @@ void ExportAlarmJobInterfaceTestImpl::exportResourceToArchive(const QString &arc
//TODO implement me
}
QString ExportAlarmJobInterfaceTestImpl::resourcePath(const QString &identifier) const
{
ResourceConverterTest converter;
const QString url = converter.resourcePath(identifier);
return url;
}
ExportAlarmJobInterfaceTest::ExportAlarmJobInterfaceTest(QObject *parent)
: QObject(parent)
{
......
......@@ -36,6 +36,7 @@ protected:
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const override;
private:
QVector<Utils::AkonadiInstanceInfo> mListAkonadiInstanceInfo;
};
......
......@@ -96,3 +96,10 @@ void ExportCalendarsJobInterfaceTest::exportCalendarConfig()
file->start();
delete exportNote;
}
QString ExportCalendarsJobInterfaceTestImpl::resourcePath(const QString &identifier) const
{
ResourceConverterTest converter;
const QString url = converter.resourcePath(identifier);
return url;
}
......@@ -39,6 +39,7 @@ protected:
void convertCollectionListToRealPath(KConfigGroup &group, const QString &currentKey) override;
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const override;
private:
QVector<Utils::AkonadiInstanceInfo> mListAkonadiInstanceInfo;
};
......
......@@ -117,3 +117,11 @@ QString ExportMailJobInterfaceTestImpl::convertToFullCollectionPath(const qlongl
ResourceConverterTest converter;
return converter.convertToFullCollectionPath(collectionValue);
}
QString ExportMailJobInterfaceTestImpl::resourcePath(const QString &identifier) const
{
ResourceConverterTest converter;
const QString url = converter.resourcePath(identifier);
return url;
}
......@@ -48,6 +48,7 @@ protected:
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString storeResources(KZip *archive, const QString &identifier, const QString &path) override;
Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const override;
};
class ExportMailJobInterfaceTest : public QObject
......
......@@ -120,3 +120,10 @@ void ExportNotesJobInterfaceTest::exportNoteConfigAndResource()
file->start();
delete exportNote;
}
QString ExportNotesJobInterfaceTestImpl::resourcePath(const QString &identifier) const
{
ResourceConverterTest converter;
const QString url = converter.resourcePath(identifier);
return url;
}
......@@ -39,6 +39,7 @@ protected:
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const override;
private:
QVector<Utils::AkonadiInstanceInfo> mListAkonadiInstanceInfo;
};
......
......@@ -43,3 +43,17 @@ Akonadi::Collection::Id ResourceConverterTest::convertFolderPathToCollectionId(c
}
return result;
}
QString ResourceConverterTest::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);
//TODO fix me path
const QString url = ResourceConverterBase::resourcePath(resourceConfig, defaultPath);
qDebug() << " resourcePath " << url;
return url;
}
......@@ -30,6 +30,8 @@ public:
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;
};
#endif // RESOURCECONVERTERTEST_H
......@@ -59,8 +59,7 @@ void ExportCalendarJobInterface::slotWriteNextArchiveResource()
if (identifier.contains(QLatin1String("akonadi_icaldir_resource_"))) {
const QString archivePath = Utils::calendarPath() + identifier + QLatin1Char('/');
ResourceConverterImpl converter;
const QString url = converter.resourcePath(identifier);
const QString url = resourcePath(identifier);
if (!mAgentPaths.contains(url)) {
if (!url.isEmpty()) {
mAgentPaths << url;
......
......@@ -42,6 +42,7 @@ protected:
virtual void convertCollectionListToRealPath(KConfigGroup &group, const QString &currentKey) = 0;
virtual void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) = 0;
virtual Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() = 0;
virtual Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const = 0;
private:
void slotCheckBackupResource();
......
......@@ -84,3 +84,10 @@ void ExportCalendarJobInterfaceImpl::exportResourceToArchive(const QString &arch
connect(resourceJob, &ExportResourceArchiveJob::terminated, this, &ExportCalendarJobInterfaceImpl::slotCalendarJobTerminated);
resourceJob->start();
}
QString ExportCalendarJobInterfaceImpl::resourcePath(const QString &identifier) const
{
ResourceConverterImpl converter;
const QString url = converter.resourcePath(identifier);
return url;
}
......@@ -38,6 +38,7 @@ protected:
void convertCollectionListToRealPath(KConfigGroup &group, const QString &currentKey) override;
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const override;
};
#endif // EXPORTCALENDARJOBINTERFACEIMPL_H
......@@ -605,8 +605,7 @@ void ExportMailJobInterface::slotWriteNextArchiveResource()
if (identifier.contains(QLatin1String("akonadi_maildir_resource_"))
|| identifier.contains(QLatin1String("akonadi_mixedmaildir_resource_"))) {
const QString archivePath = Utils::mailsPath() + identifier + QLatin1Char('/');
ResourceConverterImpl converter;
const QString url = converter.resourcePath(identifier);
const QString url = resourcePath(identifier);
if (!mAgentPaths.contains(url)) {
if (!url.isEmpty()) {
mAgentPaths << url;
......
......@@ -56,6 +56,7 @@ protected:
virtual void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) = 0;
virtual Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() = 0;
virtual Q_REQUIRED_RESULT QString storeResources(KZip *archive, const QString &identifier, const QString &path) = 0;
virtual Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const = 0;
private:
void slotCheckBackupIdentity();
void slotCheckBackupMailTransport();
......
......@@ -119,3 +119,10 @@ QString ExportMailJobInterfaceImpl::storeResources(KZip *archive, const QString
{
return Utils::storeResources(archive, identifier, path);
}
QString ExportMailJobInterfaceImpl::resourcePath(const QString &identifier) const
{
ResourceConverterImpl converter;
const QString url = converter.resourcePath(identifier);
return url;
}
......@@ -45,6 +45,7 @@ protected:
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString storeResources(KZip *archive, const QString &identifier, const QString &path) override;
Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const override;
};
#endif // ExportMailJob_H
......@@ -141,8 +141,7 @@ void ExportNotesJobInterface::slotWriteNextArchiveResource()
if (identifier.contains(QLatin1String("akonadi_akonotes_resource_"))) {
const QString archivePath = Utils::notePath() + identifier + QLatin1Char('/');
ResourceConverterImpl converter;
const QString url = converter.resourcePath(identifier);
const QString url = resourcePath(identifier);
if (!mAgentPaths.contains(url) && QDir(url).exists()) {
if (!url.isEmpty()) {
mAgentPaths << url;
......@@ -162,3 +161,4 @@ void ExportNotesJobInterface::slotWriteNextArchiveResource()
QTimer::singleShot(0, this, &ExportNotesJobInterface::slotCheckBackupConfig);
}
}
......@@ -42,6 +42,7 @@ protected:
virtual void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) = 0;
virtual Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() = 0;
void slotNoteJobTerminated();
virtual Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const = 0;
private:
void slotCheckBackupResource();
......
......@@ -75,3 +75,11 @@ void ExportNotesJobInterfaceImpl::exportResourceToArchive(const QString &archive
connect(resourceJob, &ExportResourceArchiveJob::terminated, this, &ExportNotesJobInterfaceImpl::slotNoteJobTerminated);
resourceJob->start();
}
QString ExportNotesJobInterfaceImpl::resourcePath(const QString &identifier) const
{
ResourceConverterImpl converter;
const QString url = converter.resourcePath(identifier);
return url;
}
......@@ -37,6 +37,7 @@ protected:
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
Q_REQUIRED_RESULT QString resourcePath(const QString &identifier) const override;
};
#endif // EXPORTNOTESJOBINTERFACE_H
......@@ -145,17 +145,6 @@ void ResourceConverterBase::convertCollectionToRealPath(KConfigGroup &group, con
}
}
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 = ResourceConverterBase::resourcePath(resourceConfig, defaultPath);
return url;
}
QString ResourceConverterBase::agentFileName(const QString &filename)
{
QString agentFileConfigName = filename;
......
......@@ -30,14 +30,14 @@ public:
ResourceConverterBase();
virtual ~ResourceConverterBase();
Q_REQUIRED_RESULT QString agentFileName(const QString &filename);
Q_REQUIRED_RESULT QString resourcePath(const QString &agentIdentifier, const QString &defaultPath = QString());
Q_REQUIRED_RESULT QString resourcePath(const KSharedConfigPtr &resourceConfig, const QString &defaultPath = QString());
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 KSharedConfigPtr &resourceConfig, const QString &defaultPath = QString());
Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData);
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;
};
#endif // RESOURCECONVERTER_H
......@@ -37,3 +37,15 @@ 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 = ResourceConverterBase::resourcePath(resourceConfig, defaultPath);
qDebug() << " resourcePath " << url;
return url;
}
......@@ -29,6 +29,7 @@ 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;
};
#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