Commit d0462996 authored by Laurent Montel's avatar Laurent Montel 😁

Continue to implement plugin support

parent 4b8d6c72
......@@ -118,12 +118,16 @@ void AbstractAddressBook::addImportError(const QString &log)
void AbstractAddressBook::addAddressBookImportInfo(const QString &log)
{
mImportWizard->importAddressBookPage()->addImportInfo(log);
if (mImportWizard) {
mImportWizard->importAddressBookPage()->addImportInfo(log);
}
}
void AbstractAddressBook::addAddressBookImportError(const QString &log)
{
mImportWizard->importAddressBookPage()->addImportError(log);
if (mImportWizard) {
mImportWizard->importAddressBookPage()->addImportError(log);
}
}
void AbstractAddressBook::cleanUp()
......
......@@ -22,6 +22,7 @@
#include <AkonadiCore/Collection>
#include "abstractbase.h"
#include "libimportwizard_export.h"
class ImportWizard;
......@@ -33,7 +34,7 @@ class ContactGroup;
class KJob;
class AbstractAddressBook: public AbstractBase
class LIBIMPORTWIZARD_EXPORT AbstractAddressBook: public AbstractBase
{
Q_OBJECT
public:
......
......@@ -22,10 +22,10 @@
class ImportWizard;
#include "abstractbase.h"
#include "libimportwizard_export.h"
#include <QString>
class AbstractCalendar : public AbstractBase
class LIBIMPORTWIZARD_EXPORT AbstractCalendar : public AbstractBase
{
Q_OBJECT
public:
......
......@@ -31,9 +31,9 @@
#include <QFile>
AbstractImporter::AbstractImporter(ImportWizard *parent)
: QObject(),
mImportWizard(parent)
AbstractImporter::AbstractImporter(QObject *parent)
: QObject(parent),
mImportWizard(nullptr)
{
}
......@@ -106,20 +106,33 @@ void AbstractImporter::appendFilters(const QList<MailCommon::MailFilter *> &filt
void AbstractImporter::addImportFilterInfo(const QString &log) const
{
mImportWizard->importFilterPage()->addImportInfo(log);
if (mImportWizard) {
mImportWizard->importFilterPage()->addImportInfo(log);
}
}
void AbstractImporter::addImportFilterError(const QString &log) const
{
mImportWizard->importFilterPage()->addImportError(log);
if (mImportWizard) {
mImportWizard->importFilterPage()->addImportError(log);
}
}
void AbstractImporter::addImportSettingsInfo(const QString &log) const
{
mImportWizard->importSettingPage()->addImportError(log);
if (mImportWizard) {
mImportWizard->importSettingPage()->addImportError(log);
}
}
void AbstractImporter::addImportCalendarInfo(const QString &log) const
{
mImportWizard->importCalendarPage()->addImportError(log);
if (mImportWizard) {
mImportWizard->importCalendarPage()->addImportError(log);
}
}
void AbstractImporter::setImportWizard(ImportWizard *importWizard)
{
mImportWizard = importWizard;
}
......@@ -20,6 +20,7 @@
#ifndef AbstractImporter_H
#define AbstractImporter_H
#include "MailCommon/FilterImporterExporter"
#include "libimportwizard_export.h"
class ImportWizard;
......@@ -35,7 +36,7 @@ class MailFilter;
class FilterImporterExporter;
}
class AbstractImporter : public QObject
class LIBIMPORTWIZARD_EXPORT AbstractImporter : public QObject
{
Q_OBJECT
public:
......@@ -50,7 +51,7 @@ public:
Q_DECLARE_FLAGS(TypeSupportedOptions, TypeSupportedOption)
explicit AbstractImporter(ImportWizard *parent);
explicit AbstractImporter(QObject *parent);
virtual ~AbstractImporter();
/**
......@@ -73,6 +74,8 @@ public:
virtual bool importAddressBook();
virtual bool importCalendar();
void setImportWizard(ImportWizard *importWizard);
protected:
//TODO we need to redefine it.
virtual void initializeFilter(MailImporter::Filter &filter);
......
......@@ -93,12 +93,16 @@ void AbstractSettings::storeTransport(MailTransport::Transport *mt, bool isDefau
void AbstractSettings::addImportInfo(const QString &log)
{
mImportWizard->importSettingPage()->addImportInfo(log);
if (mImportWizard) {
mImportWizard->importSettingPage()->addImportInfo(log);
}
}
void AbstractSettings::addImportError(const QString &log)
{
mImportWizard->importSettingPage()->addImportError(log);
if (mImportWizard) {
mImportWizard->importSettingPage()->addImportError(log);
}
}
void AbstractSettings::addCheckMailOnStartup(const QString &agentIdentifyName, bool loginAtStartup)
......
......@@ -21,6 +21,7 @@
#define ABSTRACTSETTINGS_H
#include "abstractbase.h"
#include "libimportwizard_export.h"
#include <KSharedConfig>
#include <QMap>
......@@ -37,7 +38,7 @@ namespace MailTransport
class Transport;
}
class AbstractSettings : public AbstractBase
class LIBIMPORTWIZARD_EXPORT AbstractSettings : public AbstractBase
{
Q_OBJECT
public:
......
......@@ -27,10 +27,12 @@
#include "importwizard.h"
#include <KLocalizedString>
#include <kpluginfactory.h>
#include <QDir>
BalsaImportData::BalsaImportData(ImportWizard *parent)
//K_PLUGIN_FACTORY_WITH_JSON(BalsaImporterFactory, "balsaimporter.json", registerPlugin<BalsaImportData>();)
BalsaImportData::BalsaImportData(QObject *parent, const QList<QVariant> &)
: AbstractImporter(parent)
{
mPath = MailImporter::FilterBalsa::defaultSettingsPath();
......@@ -100,3 +102,5 @@ AbstractImporter::TypeSupportedOptions BalsaImportData::supportedOption()
options |= AbstractImporter::Filters;
return options;
}
#include "balsaimportdata.moc"
......@@ -25,7 +25,7 @@ class ImportWizard;
class BalsaImportData : public AbstractImporter
{
public:
explicit BalsaImportData(ImportWizard *parent);
explicit BalsaImportData(QObject *parent, const QList<QVariant> & = QList<QVariant>());
~BalsaImportData();
TypeSupportedOptions supportedOption() Q_DECL_OVERRIDE;
......
{
"KPlugin": {
"Id": "balsaimporter",
"Name": "Balsa Importer",
"ServiceTypes": [
"ImportWizard/PluginMailImporter"
],
"Version": "1.0"
}
}
......@@ -26,11 +26,14 @@
#include "importfilterinfogui.h"
#include "importwizard.h"
#include <kpluginfactory.h>
#include <KLocalizedString>
#include <QDir>
ClawsMailImportData::ClawsMailImportData(ImportWizard *parent)
//K_PLUGIN_FACTORY_WITH_JSON(ClawsMailImporterFactory, "clawsmailimporter.json", registerPlugin<ClawsMailImportData>();)
ClawsMailImportData::ClawsMailImportData(QObject *parent, const QList<QVariant> &)
: AbstractImporter(parent)
{
mPath = MailImporter::FilterClawsMail::defaultSettingsPath();
......@@ -105,3 +108,5 @@ AbstractImporter::TypeSupportedOptions ClawsMailImportData::supportedOption()
options |= AbstractImporter::Filters;
return options;
}
#include "clawsmailimportdata.moc"
......@@ -25,7 +25,7 @@ class ImportWizard;
class ClawsMailImportData : public AbstractImporter
{
public:
explicit ClawsMailImportData(ImportWizard *parent);
explicit ClawsMailImportData(QObject *parent, const QList<QVariant> & = QList<QVariant>());
~ClawsMailImportData();
TypeSupportedOptions supportedOption() Q_DECL_OVERRIDE;
......
{
"KPlugin": {
"Id": "clawsmailimporter",
"Name": "ClawsMail Importer",
"ServiceTypes": [
"ImportWizard/PluginMailImporter"
],
"Version": "1.0"
}
}
......@@ -23,10 +23,11 @@
#include "importfilterinfogui.h"
#include <KLocalizedString>
#include <kpluginfactory.h>
#include <QDir>
Evolutionv1ImportData::Evolutionv1ImportData(ImportWizard *parent)
Evolutionv1ImportData::Evolutionv1ImportData(QObject *parent, const QList<QVariant> &)
: AbstractImporter(parent)
{
mPath = MailImporter::FilterEvolution::defaultSettingsPath();
......
......@@ -25,7 +25,7 @@ class ImportWizard;
class Evolutionv1ImportData : public AbstractImporter
{
public:
explicit Evolutionv1ImportData(ImportWizard *parent);
explicit Evolutionv1ImportData(QObject *parent, const QList<QVariant> & = QList<QVariant>());
~Evolutionv1ImportData();
TypeSupportedOptions supportedOption() Q_DECL_OVERRIDE;
......
......@@ -23,10 +23,11 @@
#include "importfilterinfogui.h"
#include <KLocalizedString>
#include <kpluginfactory.h>
#include <QDir>
Evolutionv2ImportData::Evolutionv2ImportData(ImportWizard *parent)
Evolutionv2ImportData::Evolutionv2ImportData(QObject *parent, const QList<QVariant> &)
: AbstractImporter(parent)
{
mPath = MailImporter::FilterEvolution_v2::defaultSettingsPath();
......
......@@ -25,7 +25,7 @@ class ImportWizard;
class Evolutionv2ImportData : public AbstractImporter
{
public:
explicit Evolutionv2ImportData(ImportWizard *parent);
explicit Evolutionv2ImportData(QObject *parent, const QList<QVariant> & = QList<QVariant>());
~Evolutionv2ImportData();
TypeSupportedOptions supportedOption() Q_DECL_OVERRIDE;
......
......@@ -32,7 +32,7 @@
#include <QDir>
Evolutionv3ImportData::Evolutionv3ImportData(ImportWizard *parent)
Evolutionv3ImportData::Evolutionv3ImportData(QObject *parent, const QList<QVariant> &)
: AbstractImporter(parent)
{
mPath = MailImporter::FilterEvolution_v3::defaultSettingsPath();
......
......@@ -25,7 +25,7 @@ class ImportWizard;
class Evolutionv3ImportData : public AbstractImporter
{
public:
explicit Evolutionv3ImportData(ImportWizard *parent);
explicit Evolutionv3ImportData(QObject *parent, const QList<QVariant> & = QList<QVariant>());
~Evolutionv3ImportData();
TypeSupportedOptions supportedOption() Q_DECL_OVERRIDE;
......
......@@ -25,10 +25,12 @@
#include "importfilterinfogui.h"
#include "importwizard.h"
#include "importwizard_debug.h"
#include <kpluginfactory.h>
#include <QDir>
GearyImportData::GearyImportData(ImportWizard *parent)
K_PLUGIN_FACTORY_WITH_JSON(GearyImporterFactory, "gearyimporter.json", registerPlugin<GearyImportData>();)
GearyImportData::GearyImportData(QObject *parent, const QList<QVariant> &)
: AbstractImporter(parent)
{
mPath = MailImporter::OtherMailerUtil::gearyDefaultPath();
......@@ -86,3 +88,5 @@ AbstractImporter::TypeSupportedOptions GearyImportData::supportedOption()
//options |= AbstractImporter::AddressBooks;
return options;
}
#include "gearyimportdata.moc"
......@@ -25,7 +25,7 @@ class ImportWizard;
class GearyImportData : public AbstractImporter
{
public:
explicit GearyImportData(ImportWizard *parent);
explicit GearyImportData(QObject *parent, const QList<QVariant> & = QList<QVariant>());
~GearyImportData();
TypeSupportedOptions supportedOption() Q_DECL_OVERRIDE;
......
{
"KPlugin": {
"Id": "gearyimporter",
"Name": "Geary Importer",
"ServiceTypes": [
"ImportWizard/PluginMailImporter"
],
"Version": "1.0"
}
}
......@@ -28,11 +28,12 @@
#include "importwizard.h"
#include <KLocalizedString>
#include <kpluginfactory.h>
#include <KConfig>
#include <QDir>
IcedoveImportData::IcedoveImportData(ImportWizard *parent)
IcedoveImportData::IcedoveImportData(QObject *parent, const QList<QVariant> &)
: AbstractImporter(parent)
{
mPath = MailImporter::FilterIcedove::defaultSettingsPath();
......
......@@ -25,7 +25,7 @@ class ImportWizard;
class IcedoveImportData : public AbstractImporter
{
public:
explicit IcedoveImportData(ImportWizard *parent);
explicit IcedoveImportData(QObject *parent, const QList<QVariant> & = QList<QVariant>());
~IcedoveImportData();
TypeSupportedOptions supportedOption() Q_DECL_OVERRIDE;
......
......@@ -24,10 +24,10 @@
#include "importwizard.h"
#include <KLocalizedString>
#include <kpluginfactory.h>
#include <QDir>
MailAppImportData::MailAppImportData(ImportWizard *parent)
MailAppImportData::MailAppImportData(QObject *parent, const QList<QVariant> &)
: AbstractImporter(parent)
{
mPath = QDir::homePath();
......
......@@ -25,7 +25,7 @@ class ImportWizard;
class MailAppImportData : public AbstractImporter
{
public:
explicit MailAppImportData(ImportWizard *parent);
explicit MailAppImportData(QObject *parent, const QList<QVariant> & = QList<QVariant>());
~MailAppImportData();
TypeSupportedOptions supportedOption() Q_DECL_OVERRIDE;
......
......@@ -24,10 +24,11 @@
#include "importwizard.h"
#include <KLocalizedString>
#include <kpluginfactory.h>
#include <QDir>
OeImportData::OeImportData(ImportWizard *parent)
OeImportData::OeImportData(QObject *parent, const QList<QVariant> &)
: AbstractImporter(parent)
{
mPath = QDir::homePath();
......
......@@ -25,7 +25,7 @@ class ImportWizard;
class OeImportData : public AbstractImporter
{
public:
explicit OeImportData(ImportWizard *parent);
explicit OeImportData(QObject *parent, const QList<QVariant> & = QList<QVariant>());
~OeImportData();
TypeSupportedOptions supportedOption() Q_DECL_OVERRIDE;
......
......@@ -26,10 +26,10 @@
#include "importwizard.h"
#include <KLocalizedString>
#include <kpluginfactory.h>
#include <QDir>
OperaImportData::OperaImportData(ImportWizard *parent)
OperaImportData::OperaImportData(QObject *parent, const QList<QVariant> &)
: AbstractImporter(parent)
{
mPath = MailImporter::FilterOpera::defaultSettingsPath();
......
......@@ -26,7 +26,7 @@ class ImportWizard;
class OperaImportData : public AbstractImporter
{
public:
explicit OperaImportData(ImportWizard *parent);
explicit OperaImportData(QObject *parent, const QList<QVariant> & = QList<QVariant>());
~OperaImportData();
TypeSupportedOptions supportedOption() Q_DECL_OVERRIDE;
......
......@@ -25,10 +25,10 @@
#include "importwizard.h"
#include <KLocalizedString>
#include <kpluginfactory.h>
#include <QDir>
PMailImportData::PMailImportData(ImportWizard *parent)
PMailImportData::PMailImportData(QObject *parent, const QList<QVariant> &)
: AbstractImporter(parent)
{
mPath = QDir::homePath();
......
......@@ -26,7 +26,7 @@ class ImportWizard;
class PMailImportData : public AbstractImporter
{
public:
explicit PMailImportData(ImportWizard *parent);
explicit PMailImportData(QObject *parent, const QList<QVariant> & = QList<QVariant>());
~PMailImportData();
TypeSupportedOptions supportedOption() Q_DECL_OVERRIDE;
......
......@@ -27,10 +27,10 @@
#include "sylpheed/sylpheedaddressbook.h"
#include <KLocalizedString>
#include <kpluginfactory.h>
#include <QDir>
SylpheedImportData::SylpheedImportData(ImportWizard *parent)
SylpheedImportData::SylpheedImportData(QObject *parent, const QList<QVariant> &)
: AbstractImporter(parent)
{
mPath = MailImporter::FilterSylpheed::defaultSettingsPath();
......
......@@ -25,7 +25,7 @@ class ImportWizard;
class SylpheedImportData : public AbstractImporter
{
public:
explicit SylpheedImportData(ImportWizard *parent);
explicit SylpheedImportData(QObject *parent, const QList<QVariant> & = QList<QVariant>());
~SylpheedImportData();
TypeSupportedOptions supportedOption() Q_DECL_OVERRIDE;
......
......@@ -24,10 +24,11 @@
#include "importwizard.h"
#include <KLocalizedString>
#include <kpluginfactory.h>
#include <QDir>
TheBatImportData::TheBatImportData(ImportWizard *parent)
TheBatImportData::TheBatImportData(QObject *parent, const QList<QVariant> &)
: AbstractImporter(parent)
{
//TODO fix it
......
......@@ -25,7 +25,7 @@ class ImportWizard;
class TheBatImportData : public AbstractImporter
{
public:
explicit TheBatImportData(ImportWizard *parent);
explicit TheBatImportData(QObject *parent, const QList<QVariant> & = QList<QVariant>());
~TheBatImportData();
TypeSupportedOptions supportedOption() Q_DECL_OVERRIDE;
......
......@@ -28,10 +28,11 @@
#include "importwizard.h"
#include <KLocalizedString>
#include <kpluginfactory.h>
#include <QDir>
ThunderbirdImportData::ThunderbirdImportData(ImportWizard *parent)
ThunderbirdImportData::ThunderbirdImportData(QObject *parent, const QList<QVariant> &)
: AbstractImporter(parent)
{
mPath = MailImporter::FilterThunderbird::defaultSettingsPath();
......
......@@ -25,7 +25,7 @@ class ImportWizard;
class ThunderbirdImportData : public AbstractImporter
{
public:
explicit ThunderbirdImportData(ImportWizard *parent);
explicit ThunderbirdImportData(QObject *parent, const QList<QVariant> & = QList<QVariant>());
~ThunderbirdImportData();
TypeSupportedOptions supportedOption() Q_DECL_OVERRIDE;
......
......@@ -24,10 +24,11 @@
#include "mailimporter/othermailerutil.h"
#include "importfilterinfogui.h"
#include "importwizard.h"
#include <kpluginfactory.h>
#include <QDir>
TrojitaImportData::TrojitaImportData(ImportWizard *parent)
TrojitaImportData::TrojitaImportData(QObject *parent, const QList<QVariant> &)
: AbstractImporter(parent)
{
mPath = MailImporter::OtherMailerUtil::trojitaDefaultPath();
......
......@@ -25,7 +25,7 @@ class ImportWizard;
class TrojitaImportData : public AbstractImporter
{
public:
explicit TrojitaImportData(ImportWizard *parent);
explicit TrojitaImportData(QObject *parent, const QList<QVariant> & = QList<QVariant>());
~TrojitaImportData();
TypeSupportedOptions supportedOption() Q_DECL_OVERRIDE;
......
......@@ -21,11 +21,14 @@
#include "importmailpluginmanager.h"
#include "importwizard_debug.h"
#include "abstractimporter.h"
#include <QVector>
#include <KPluginMetaData>
#include <KPluginLoader>
#include <KPluginFactory>
#include <QFileInfo>
#include <QVector>
Q_GLOBAL_STATIC(ImportMailPluginManager, s_instance)
......@@ -60,7 +63,6 @@ bool ImportMailPluginManager::initializePluginList()
return md.serviceTypes().contains(QStringLiteral("ImportWizard/PluginMailImporter"));
});
#if 0
QVectorIterator<KPluginMetaData> i(plugins);
i.toBack();
QSet<QString> unique;
......@@ -69,7 +71,7 @@ bool ImportMailPluginManager::initializePluginList()
const KPluginMetaData data = i.previous();
//1) get plugin data => name/description etc.
info.pluginData = PimCommon::PluginUtil::createPluginMetaData(data);
info.pluginData = createPluginMetaData(data);
//2) look at if plugin is activated
info.metaDataFileNameBaseName = QFileInfo(data.fileName()).baseName();
info.metaDataFileName = data.fileName();
......@@ -86,13 +88,10 @@ bool ImportMailPluginManager::initializePluginList()
}
}
QVector<ImportMailPluginManagerInfo>::iterator end(mPluginList.end());
for (QVector<PluginEditorCheckBeforeSendInfo>::iterator it = mPluginList.begin(); it != end; ++it) {
for (QVector<ImportMailPluginManagerInfo>::iterator it = mPluginList.begin(); it != end; ++it) {
loadPlugin(&(*it));
}
return true;
//TODO
#endif
return false;
}