Commit 0ed2c012 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Allow to export filter in autotest

parent 1fab06c4
......@@ -107,6 +107,11 @@ QString ExportMailJobInterfaceTestImpl::resourcePath(const QString &identifier)
return url;
}
void ExportMailJobInterfaceTestImpl::exportFilters()
{
qDebug() << " void ExportMailJobInterfaceTestImpl::exportFilters() not implemented yet";
}
void ExportMailJobInterfaceTestImpl::backupMailResourceFile(const QString &agentIdentifier, const QString &defaultPath)
{
TestBackupResourceFileJob *job = new TestBackupResourceFileJob(this);
......@@ -178,3 +183,5 @@ void ExportMailJobInterfaceTest::exportMail()
file->start();
delete exportNote;
}
......@@ -50,6 +50,8 @@ protected:
void backupMailResourceFile(const QString &agentIdentifier, const QString &defaultPath) override;
Q_REQUIRED_RESULT QString adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath) override;
Q_REQUIRED_RESULT QString createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings, bool synchronizeTree) override;
void exportFilters() override;
};
class ExportMailJobInterfaceTest : public QObject
......
......@@ -168,21 +168,7 @@ void ExportMailJobInterface::backupConfig()
{
setProgressDialogLabel(i18n("Backing up config..."));
QVector<MailCommon::MailFilter *> lstFilter = filters();
if (!lstFilter.isEmpty()) {
QTemporaryFile tmp;
tmp.open();
QUrl url = QUrl::fromLocalFile(tmp.fileName());
MailCommon::FilterImporterExporter exportFilters;
exportFilters.exportFilters(lstFilter, url, true);
tmp.close();
const bool fileAdded = archive()->addLocalFile(tmp.fileName(), Utils::configsPath() + QStringLiteral("filters"));
if (fileAdded) {
Q_EMIT info(i18n("Filters backup done."));
} else {
Q_EMIT error(i18n("Filters cannot be exported."));
}
}
exportFilters();
backupUiRcFile(QStringLiteral("sieveeditorui.rc"), QStringLiteral("sieveeditor"));
backupUiRcFile(QStringLiteral("kmreadermainwin.rc"), QStringLiteral("kmail2"));
......
......@@ -57,6 +57,7 @@ protected:
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;
virtual void backupMailResourceFile(const QString &agentIdentifier, const QString &defaultPath) = 0;
virtual void exportFilters() = 0;
private:
void slotCheckBackupIdentity();
void slotCheckBackupMailTransport();
......
......@@ -22,6 +22,7 @@
#include <MailCommon/MailUtil>
#include <MailCommon/FilterManager>
#include <MailCommon/FilterImporterExporter>
#include <KMime/Message>
#include "importexportprogressindicatorbase.h"
......@@ -31,6 +32,7 @@
#include <KZip>
#include <KLocalizedString>
#include <QTemporaryFile>
#include "pimdataexportcore_debug.h"
......@@ -138,3 +140,23 @@ QString ExportMailJobInterfaceImpl::createResource(const QString &resources, con
Q_UNREACHABLE();
return {};
}
void ExportMailJobInterfaceImpl::exportFilters()
{
const QVector<MailCommon::MailFilter *> lstFilter = filters();
if (!lstFilter.isEmpty()) {
QTemporaryFile tmp;
tmp.open();
const QUrl url = QUrl::fromLocalFile(tmp.fileName());
MailCommon::FilterImporterExporter exportFilters;
exportFilters.exportFilters(lstFilter, url, true);
tmp.close();
const bool fileAdded = archive()->addLocalFile(tmp.fileName(), Utils::configsPath() + QStringLiteral("filters"));
if (fileAdded) {
Q_EMIT info(i18n("Filters backup done."));
} else {
Q_EMIT error(i18n("Filters cannot be exported."));
}
}
}
......@@ -48,6 +48,7 @@ protected:
void backupMailResourceFile(const QString &agentIdentifier, const QString &defaultPath) override;
Q_REQUIRED_RESULT QString adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath) override;
Q_REQUIRED_RESULT QString createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings, bool synchronizeTree) override;
void exportFilters() override;
};
#endif // ExportMailJob_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