Commit 073ac0e1 authored by Laurent Montel's avatar Laurent Montel 😁

Adapt to new mailimporter api

parent 170f3091
......@@ -45,7 +45,7 @@ set(KDEPIM_LIB_SOVERSION "5")
set(QT_REQUIRED_VERSION "5.6.0")
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Gui)
set(MAILIMPORTER_VERSION_LIB "5.4.41")
set(MAILIMPORTER_VERSION_LIB "5.4.81")
set(MAILCOMMON_LIB_VERSION_LIB "5.4.40")
set(MESSAGELIB_LIB_VERSION_LIB "5.4.40")
set(PIMCOMMON_LIB_VERSION_LIB "5.4.48")
......
......@@ -27,6 +27,7 @@
#include "mailimporter/filterinfo.h"
#include "MailCommon/FilterManager"
#include <MailImporter/FilterImporterAkonadi>
#include <QFile>
......@@ -64,14 +65,16 @@ bool AbstractImporter::importCalendar()
return false;
}
MailImporter::FilterInfo *AbstractImporter::initializeInfo()
void AbstractImporter::initializeFilter(MailImporter::Filter &filter)
{
MailImporter::FilterInfo *info = new MailImporter::FilterInfo();
ImportFilterInfoGui *infoGui = new ImportFilterInfoGui(mImportWizard->importMailPage());
info->setFilterInfoGui(infoGui);
info->setRootCollection(mImportWizard->importMailPage()->selectedCollection());
info->clear(); // Clear info from last time
return info;
MailImporter::FilterImporterAkonadi *filterImporter = new MailImporter::FilterImporterAkonadi(info);
filterImporter->setRootCollection(mImportWizard->importMailPage()->selectedCollection());
filter.setFilterImporter(filterImporter);
filter.setFilterInfo(info);
}
bool AbstractImporter::addFilters(const QString &filterPath, MailCommon::FilterImporterExporter::FilterType type)
......
......@@ -26,6 +26,7 @@ class ImportWizard;
namespace MailImporter
{
class FilterInfo;
class Filter;
}
namespace MailCommon
......@@ -73,7 +74,7 @@ public:
protected:
void appendFilters(const QList<MailCommon::MailFilter *> &filters);
MailImporter::FilterInfo *initializeInfo();
void initializeFilter(MailImporter::Filter &filter);
void addImportFilterInfo(const QString &log) const;
void addImportFilterError(const QString &log) const;
bool addFilters(const QString &filterPath, MailCommon::FilterImporterExporter::FilterType type);
......
......@@ -22,6 +22,7 @@
#include "balsa/balsaaddressbook.h"
#include "mailimporter/filterbalsa.h"
#include "mailimporter/filterinfo.h"
#include <MailImporter/FilterImporterAkonadi>
#include "MailCommon/FilterImporterBalsa"
#include "importfilterinfogui.h"
#include "importwizard.h"
......@@ -56,20 +57,16 @@ QString BalsaImportData::name() const
bool BalsaImportData::importMails()
{
MailImporter::FilterInfo *info = initializeInfo();
MailImporter::FilterBalsa balsa;
balsa.setFilterInfo(info);
info->setStatusMessage(i18n("Import in progress"));
initializeFilter(balsa);
balsa.filterInfo()->setStatusMessage(i18n("Import in progress"));
QDir directory(balsa.localMailDirPath());
if (directory.exists()) {
balsa.importMails(directory.absolutePath());
} else {
balsa.import();
}
info->setStatusMessage(i18n("Import finished"));
delete info;
balsa.filterInfo()->setStatusMessage(i18n("Import finished"));
return true;
}
......
......@@ -56,11 +56,9 @@ QString ClawsMailImportData::name() const
bool ClawsMailImportData::importMails()
{
MailImporter::FilterInfo *info = initializeInfo();
MailImporter::FilterClawsMail clawsMail;
clawsMail.setFilterInfo(info);
info->setStatusMessage(i18n("Import in progress"));
initializeFilter(clawsMail);
clawsMail.filterInfo()->setStatusMessage(i18n("Import in progress"));
const QString mailsPath = clawsMail.localMailDirPath();
QDir directory(mailsPath);
if (directory.exists()) {
......@@ -68,9 +66,7 @@ bool ClawsMailImportData::importMails()
} else {
clawsMail.import();
}
info->setStatusMessage(i18n("Import finished"));
delete info;
clawsMail.filterInfo()->setStatusMessage(i18n("Import finished"));
return true;
}
......
......@@ -52,10 +52,9 @@ QString Evolutionv1ImportData::name() const
bool Evolutionv1ImportData::importMails()
{
MailImporter::FilterInfo *info = initializeInfo();
MailImporter::FilterEvolution evolution;
evolution.setFilterInfo(info);
info->setStatusMessage(i18n("Import in progress"));
initializeFilter(evolution);
evolution.filterInfo()->setStatusMessage(i18n("Import in progress"));
const QString mailsPath = mPath;
QDir directory(mailsPath);
if (directory.exists()) {
......@@ -63,9 +62,7 @@ bool Evolutionv1ImportData::importMails()
} else {
evolution.import();
}
info->setStatusMessage(i18n("Import finished"));
delete info;
evolution.filterInfo()->setStatusMessage(i18n("Import finished"));
return true;
}
......
......@@ -52,11 +52,9 @@ QString Evolutionv2ImportData::name() const
bool Evolutionv2ImportData::importMails()
{
MailImporter::FilterInfo *info = initializeInfo();
MailImporter::FilterEvolution_v2 evolution;
evolution.setFilterInfo(info);
info->setStatusMessage(i18n("Import in progress"));
initializeFilter(evolution);
evolution.filterInfo()->setStatusMessage(i18n("Import in progress"));
const QString mailsPath = mPath;
QDir directory(mailsPath);
if (directory.exists()) {
......@@ -64,9 +62,7 @@ bool Evolutionv2ImportData::importMails()
} else {
evolution.import();
}
info->setStatusMessage(i18n("Import finished"));
delete info;
evolution.filterInfo()->setStatusMessage(i18n("Import finished"));
return true;
}
......
......@@ -74,11 +74,9 @@ bool Evolutionv3ImportData::importSettings()
bool Evolutionv3ImportData::importMails()
{
MailImporter::FilterInfo *info = initializeInfo();
MailImporter::FilterEvolution_v3 evolution;
evolution.setFilterInfo(info);
info->setStatusMessage(i18n("Import in progress"));
initializeFilter(evolution);
evolution.filterInfo()->setStatusMessage(i18n("Import in progress"));
const QString mailsPath = mPath;
QDir directory(mailsPath);
if (directory.exists()) {
......@@ -86,9 +84,7 @@ bool Evolutionv3ImportData::importMails()
} else {
evolution.import();
}
info->setStatusMessage(i18n("Import finished"));
delete info;
evolution.filterInfo()->setStatusMessage(i18n("Import finished"));
return true;
}
......
......@@ -85,12 +85,9 @@ bool IcedoveImportData::importSettings()
bool IcedoveImportData::importMails()
{
//* This should be usually ~/.icedove/xxxx.default/Mail/Local Folders/
MailImporter::FilterInfo *info = initializeInfo();
MailImporter::FilterThunderbird thunderbird;
thunderbird.setFilterInfo(info);
info->clear();
info->setStatusMessage(i18n("Import in progress"));
initializeFilter(thunderbird);
thunderbird.filterInfo()->setStatusMessage(i18n("Import in progress"));
const QString mailsPath = mPath + defaultProfile() + QLatin1String("/Mail/Local Folders/");
QDir directory(mailsPath);
if (directory.exists()) {
......@@ -98,9 +95,7 @@ bool IcedoveImportData::importMails()
} else {
thunderbird.import();
}
info->setStatusMessage(i18n("Import finished"));
delete info;
thunderbird.filterInfo()->setStatusMessage(i18n("Import finished"));
return true;
}
......
......@@ -56,20 +56,16 @@ QString MailAppImportData::name() const
bool MailAppImportData::importMails()
{
MailImporter::FilterInfo *info = initializeInfo();
MailImporter::FilterMailApp mailapp;
mailapp.setFilterInfo(info);
info->setStatusMessage(i18n("Import in progress"));
initializeFilter(mailapp);
mailapp.filterInfo()->setStatusMessage(i18n("Import in progress"));
QDir directory(mPath);
if (directory.exists()) {
mailapp.importMails(mPath);
} else {
mailapp.import();
}
info->setStatusMessage(i18n("Import finished"));
delete info;
mailapp.filterInfo()->setStatusMessage(i18n("Import finished"));
return true;
}
......
......@@ -56,20 +56,16 @@ QString OeImportData::name() const
bool OeImportData::importMails()
{
MailImporter::FilterInfo *info = initializeInfo();
MailImporter::FilterOE opera;
opera.setFilterInfo(info);
info->setStatusMessage(i18n("Import in progress"));
initializeFilter(opera);
opera.filterInfo()->setStatusMessage(i18n("Import in progress"));
QDir directory(mPath);
if (directory.exists()) {
opera.importMails(mPath);
} else {
opera.import();
}
info->setStatusMessage(i18n("Import finished"));
delete info;
opera.filterInfo()->setStatusMessage(i18n("Import finished"));
return true;
}
......
......@@ -55,11 +55,9 @@ QString OperaImportData::name() const
bool OperaImportData::importMails()
{
MailImporter::FilterInfo *info = initializeInfo();
MailImporter::FilterOpera opera;
opera.setFilterInfo(info);
info->setStatusMessage(i18n("Import in progress"));
initializeFilter(opera);
opera.filterInfo()->setStatusMessage(i18n("Import in progress"));
const QString mailPath(mPath + QLatin1String("mail/store/"));
QDir directory(mailPath);
if (directory.exists()) {
......@@ -67,9 +65,7 @@ bool OperaImportData::importMails()
} else {
opera.import();
}
info->setStatusMessage(i18n("Import finished"));
delete info;
opera.filterInfo()->setStatusMessage(i18n("Import finished"));
return true;
}
......
......@@ -57,19 +57,16 @@ QString PMailImportData::name() const
bool PMailImportData::importMails()
{
MailImporter::FilterInfo *info = initializeInfo();
MailImporter::FilterPMail pmail;
pmail.setFilterInfo(info);
info->setStatusMessage(i18n("Import in progress"));
initializeFilter(pmail);
pmail.filterInfo()->setStatusMessage(i18n("Import in progress"));
QDir directory(mPath);
if (directory.exists()) {
pmail.importMails(mPath);
} else {
pmail.import();
}
info->setStatusMessage(i18n("Import finished"));
delete info;
pmail.filterInfo()->setStatusMessage(i18n("Import finished"));
return true;
}
......
......@@ -68,11 +68,9 @@ bool SylpheedImportData::importSettings()
bool SylpheedImportData::importMails()
{
MailImporter::FilterInfo *info = initializeInfo();
MailImporter::FilterSylpheed sylpheed;
sylpheed.setFilterInfo(info);
info->setStatusMessage(i18n("Import in progress"));
initializeFilter(sylpheed);
sylpheed.filterInfo()->setStatusMessage(i18n("Import in progress"));
const QString mailsPath = sylpheed.localMailDirPath();
QDir directory(mailsPath);
if (directory.exists()) {
......@@ -80,9 +78,7 @@ bool SylpheedImportData::importMails()
} else {
sylpheed.import();
}
info->setStatusMessage(i18n("Import finished"));
delete info;
sylpheed.filterInfo()->setStatusMessage(i18n("Import finished"));
return true;
}
......
......@@ -54,20 +54,16 @@ QString TheBatImportData::name() const
bool TheBatImportData::importMails()
{
MailImporter::FilterInfo *info = initializeInfo();
MailImporter::FilterTheBat thebat;
thebat.setFilterInfo(info);
info->setStatusMessage(i18n("Import in progress"));
initializeFilter(thebat);
thebat.filterInfo()->setStatusMessage(i18n("Import in progress"));
QDir directory(mPath);
if (directory.exists()) {
thebat.importMails(mPath);
} else {
thebat.import();
}
info->setStatusMessage(i18n("Import finished"));
delete info;
thebat.filterInfo()->setStatusMessage(i18n("Import finished"));
return true;
}
......
......@@ -84,12 +84,9 @@ bool ThunderbirdImportData::importSettings()
bool ThunderbirdImportData::importMails()
{
//* This should be usually ~/.thunderbird/xxxx.default/Mail/Local Folders/
MailImporter::FilterInfo *info = initializeInfo();
MailImporter::FilterThunderbird thunderbird;
thunderbird.setFilterInfo(info);
info->clear();
info->setStatusMessage(i18n("Import in progress"));
initializeFilter(thunderbird);
thunderbird.filterInfo()->setStatusMessage(i18n("Import in progress"));
const QString mailsPath = mPath + defaultProfile() + QLatin1String("/Mail/Local Folders/");
QDir directory(mailsPath);
if (directory.exists()) {
......@@ -97,9 +94,7 @@ bool ThunderbirdImportData::importMails()
} else {
thunderbird.import();
}
info->setStatusMessage(i18n("Import finished"));
delete info;
thunderbird.filterInfo()->setStatusMessage(i18n("Import finished"));
return true;
}
......
......@@ -47,6 +47,7 @@
#include "manual/importwizardfilterinfogui.h"
#include "mailimporter/filterinfo.h"
#include <MailImporter/FilterImporterAkonadi>
#include <QAction>
#include <KAboutData>
......@@ -369,16 +370,19 @@ void ImportWizard::next()
finishButton()->setEnabled(false);
MailImporter::FilterInfo *info = new MailImporter::FilterInfo();
MailImporter::FilterImporterAkonadi *filterImporter = new MailImporter::FilterImporterAkonadi(info);
ImportWizardFilterInfoGui *infoGui = new ImportWizardFilterInfoGui(mImportpage, this);
info->setFilterInfoGui(infoGui);
info->setStatusMessage(i18n("Import in progress"));
info->setRemoveDupMessage(mSelfilterpage->removeDupMsg_checked());
info->clear(); // Clear info from last time
info->setRootCollection(selectedCollection);
filterImporter->setRootCollection(selectedCollection);
selectedFilter->setFilterImporter(filterImporter);
selectedFilter->setFilterInfo(info);
selectedFilter->import();
info->setStatusMessage(i18n("Import finished"));
// Cleanup
delete filterImporter;
delete info;
// Enable finish & back buttons
setValid(currentPage(), true);
......
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