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

Allow to define directory when we install resource

parent c67b0e13
......@@ -19,6 +19,7 @@
#include "resourceconvertertest.h"
#include <QDebug>
#include <QDir>
ResourceConverterTest::ResourceConverterTest()
{
......@@ -65,3 +66,9 @@ void ResourceConverterTest::setTestPath(const QString &testPath)
{
mTestPath = testPath;
}
//TODO use another one ?
QString ResourceConverterTest::installDefaultDirectory()
{
return QDir::tempPath();
}
......@@ -35,6 +35,7 @@ public:
void setTestPath(const QString &testPath);
Q_REQUIRED_RESULT QString installDefaultDirectory() override;
private:
Q_REQUIRED_RESULT QString prefixStr() const;
QString mTestPath;
......
......@@ -39,11 +39,11 @@ ResourceConverterBase::~ResourceConverterBase()
QString ResourceConverterBase::adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData)
{
QString newUrl = ResourceConverterBase::resourcePath(resourceConfig);
if (!newUrl.contains(QDir::homePath())) {
if (!newUrl.contains(installDefaultDirectory())) {
QFileInfo fileInfo(newUrl);
fileInfo.fileName();
//qCDebug(PIMDATAEXPORTERCORE_LOG)<<" url "<<url.path();
QString currentPath = QDir::homePath() + QLatin1Char('/') + storedData;
QString currentPath = installDefaultDirectory() + QLatin1Char('/') + storedData;
newUrl = (currentPath + QLatin1Char('/') + fileInfo.fileName());
if (!QDir(currentPath).exists()) {
QDir().mkdir(currentPath);
......
......@@ -42,6 +42,7 @@ public:
virtual Q_REQUIRED_RESULT QString convertToFullCollectionPath(const qlonglong collectionValue) = 0;
virtual Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) = 0;
Q_REQUIRED_RESULT QString storeResources(KZip *archive, const QString &identifier, const QString &path);
virtual Q_REQUIRED_RESULT QString installDefaultDirectory() = 0;
};
#endif // RESOURCECONVERTER_H
......@@ -19,6 +19,7 @@
#include "resourceconverterimpl.h"
#include <MailCommon/MailUtil>
#include <QDir>
ResourceConverterImpl::ResourceConverterImpl()
{
......@@ -37,3 +38,9 @@ Akonadi::Collection::Id ResourceConverterImpl::convertFolderPathToCollectionId(c
{
return MailCommon::Util::convertFolderPathToCollectionId(path);
}
QString ResourceConverterImpl::installDefaultDirectory()
{
return QDir::homePath();
}
......@@ -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 installDefaultDirectory() 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