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

Port to new api

parent 3fdbbaf1
......@@ -18,7 +18,7 @@ include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(ECMQtDeclareLoggingCategory)
include(ECMAddTests)
set(PIM_VERSION "5.3.52")
set(PIM_VERSION "5.3.53")
set(MESSAGELIB_LIB_VERSION ${PIM_VERSION})
set(AKONADIMIME_LIB_VERSION "5.3.40")
......@@ -39,7 +39,7 @@ set(KMIME_LIB_VERSION "5.3.40")
set(KPIMTEXTEDIT_LIB_VERSION "5.3.43")
set(LIBKDEPIM_LIB_VERSION "5.3.42")
set(LIBKLEO_LIB_VERSION "5.3.40")
set(PIMCOMMON_LIB_VERSION "5.3.45")
set(PIMCOMMON_LIB_VERSION "5.3.46")
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test Network PrintSupport WebEngine WebEngineWidgets WebKitWidgets)
......
......@@ -20,6 +20,7 @@
#include "plugineditor.h"
#include "messagecomposer_debug.h"
#include "plugineditormanager.h"
#include <PimCommon/PluginUtil>
#include <QFileInfo>
#include <QSet>
......@@ -79,12 +80,14 @@ public:
}
void loadPlugin(PluginEditorInfo *item);
QVector<PluginEditor *> pluginsList() const;
QVector<MessageComposer::PluginEditorManager::PluginEditorData> pluginDataList() const;
QVector<PimCommon::PluginUtilData> pluginDataList() const;
bool initializePlugins();
QString configGroupName() const;
QString configPrefixSettingKey() const;
private:
QVector<PluginEditorInfo> mPluginList;
QVector<MessageComposer::PluginEditorManager::PluginEditorData> mPluginDataList;
QVector<PimCommon::PluginUtilData> mPluginDataList;
PluginEditorManager *q;
};
......@@ -94,6 +97,8 @@ bool PluginEditorManagerPrivate::initializePlugins()
return md.serviceTypes().contains(QStringLiteral("KMailEditor/Plugin"));
});
const QPair<QStringList, QStringList> pair = PimCommon::PluginUtil::loadPluginSetting(configGroupName(), configPrefixSettingKey());
QVectorIterator<KPluginMetaData> i(plugins);
i.toBack();
QSet<QString> unique;
......@@ -102,14 +107,15 @@ bool PluginEditorManagerPrivate::initializePlugins()
info.metaData = i.previous();
//Store plugin info
MessageComposer::PluginEditorManager::PluginEditorData pluginData;
PimCommon::PluginUtilData pluginData;
pluginData.mDescription = info.metaData.description();
pluginData.mName = info.metaData.name();
pluginData.mIdentifier = info.metaData.pluginId();
pluginData.mEnableByDefault = info.metaData.isEnabledByDefault();
mPluginDataList.append(pluginData);
if (pluginData.mEnableByDefault) {
const bool isPluginActivated = PimCommon::PluginUtil::isPluginActivated(pair.first, pair.second, pluginData.mEnableByDefault, pluginData.mIdentifier);
if (isPluginActivated) {
const QVariant p = info.metaData.rawData().value(QStringLiteral("X-KDE-KMailEditor-Order")).toVariant();
int order = -1;
if (p.isValid()) {
......@@ -157,11 +163,21 @@ QVector<PluginEditor *> PluginEditorManagerPrivate::pluginsList() const
return lst;
}
QVector<MessageComposer::PluginEditorManager::PluginEditorData> PluginEditorManagerPrivate::pluginDataList() const
QVector<PimCommon::PluginUtilData> PluginEditorManagerPrivate::pluginDataList() const
{
return mPluginDataList;
}
QString PluginEditorManagerPrivate::configGroupName() const
{
return QStringLiteral("KMailPluginEditor");
}
QString PluginEditorManagerPrivate::configPrefixSettingKey() const
{
return QStringLiteral("KMailEditorPlugin");
}
PluginEditorManager::PluginEditorManager(QObject *parent)
: QObject(parent),
d(new MessageComposer::PluginEditorManagerPrivate(this))
......@@ -188,7 +204,18 @@ QVector<PluginEditor *> PluginEditorManager::pluginsList() const
return d->pluginsList();
}
QVector<MessageComposer::PluginEditorManager::PluginEditorData> PluginEditorManager::pluginsDataList() const
QVector<PimCommon::PluginUtilData> PluginEditorManager::pluginsDataList() const
{
return d->pluginDataList();
}
QString PluginEditorManager::configGroupName() const
{
return d->configGroupName();
}
QString PluginEditorManager::configPrefixSettingKey() const
{
return d->configPrefixSettingKey();
}
......@@ -22,6 +22,7 @@
#include <QObject>
#include "messagecomposer_export.h"
#include <PimCommon/PluginUtil>
namespace MessageComposer
{
class PluginEditorManagerPrivate;
......@@ -30,19 +31,6 @@ class MESSAGECOMPOSER_EXPORT PluginEditorManager : public QObject
{
Q_OBJECT
public:
class PluginEditorData
{
public:
PluginEditorData()
: mEnableByDefault(false)
{
}
QString mDescription;
QString mIdentifier;
QString mName;
bool mEnableByDefault;
};
explicit PluginEditorManager(QObject *parent = Q_NULLPTR);
~PluginEditorManager();
......@@ -51,8 +39,10 @@ public:
QVector<PluginEditor *> pluginsList() const;
QVector<PluginEditorManager::PluginEditorData> pluginsDataList() const;
QVector<PimCommon::PluginUtilData> pluginsDataList() const;
QString configGroupName() const;
QString configPrefixSettingKey() const;
private:
PluginEditorManagerPrivate *const d;
};
......
......@@ -79,31 +79,65 @@ public:
QVector<PluginEditorCheckBeforeSend *> pluginsList() const;
bool initializePlugins();
QVector<PluginEditorCheckBeforeSendInfo> mPluginList;
QString configPrefixSettingKey() const;
QString configGroupName() const;
QVector<PimCommon::PluginUtilData> pluginsDataList() const;
private:
QVector<PimCommon::PluginUtilData> mPluginDataList;
PluginEditorCheckBeforeSendManager *q;
};
QString PluginEditorCheckBeforeSendManagerPrivate::configGroupName() const
{
return QStringLiteral("KMailPluginCheckBefore");
}
QString PluginEditorCheckBeforeSendManagerPrivate::configPrefixSettingKey() const
{
return QStringLiteral("PluginCheckBefore");
}
QVector<PimCommon::PluginUtilData> PluginEditorCheckBeforeSendManagerPrivate::pluginsDataList() const
{
return mPluginDataList;
}
bool PluginEditorCheckBeforeSendManagerPrivate::initializePlugins()
{
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("kmail"), [](const KPluginMetaData & md) {
return md.serviceTypes().contains(QStringLiteral("KMailEditor/PluginCheckBeforeSend"));
});
const QPair<QStringList, QStringList> pair = PimCommon::PluginUtil::loadPluginSetting(configGroupName(), configPrefixSettingKey());
QVectorIterator<KPluginMetaData> i(plugins);
i.toBack();
QSet<QString> unique;
while (i.hasPrevious()) {
PluginEditorCheckBeforeSendInfo info;
info.metaData = i.previous();
if (pluginVersion() == info.metaData.version()) {
// only load plugins once, even if found multiple times!
if (unique.contains(info.saveName())) {
continue;
//Store plugin info
PimCommon::PluginUtilData pluginData;
pluginData.mDescription = info.metaData.description();
pluginData.mName = info.metaData.name();
pluginData.mIdentifier = info.metaData.pluginId();
pluginData.mEnableByDefault = info.metaData.isEnabledByDefault();
mPluginDataList.append(pluginData);
const bool isPluginActivated = PimCommon::PluginUtil::isPluginActivated(pair.first, pair.second, pluginData.mEnableByDefault, pluginData.mIdentifier);
if (isPluginActivated) {
if (pluginVersion() == info.metaData.version()) {
// only load plugins once, even if found multiple times!
if (unique.contains(info.saveName())) {
continue;
}
info.plugin = Q_NULLPTR;
mPluginList.push_back(info);
unique.insert(info.saveName());
} else {
qCWarning(MESSAGECOMPOSER_LOG) << "Plugin " << info.metaData.name() << " doesn't have correction plugin version. It will not be loaded.";
}
info.plugin = Q_NULLPTR;
mPluginList.push_back(info);
unique.insert(info.saveName());
} else {
qCWarning(MESSAGECOMPOSER_LOG) << "Plugin " << info.metaData.name() << " doesn't have correction plugin version. It will not be loaded.";
}
}
QVector<PluginEditorCheckBeforeSendInfo>::iterator end(mPluginList.end());
......@@ -158,3 +192,18 @@ QVector<PluginEditorCheckBeforeSend *> PluginEditorCheckBeforeSendManager::plugi
{
return d->pluginsList();
}
QString PluginEditorCheckBeforeSendManager::configGroupName() const
{
return d->configGroupName();
}
QString PluginEditorCheckBeforeSendManager::configPrefixSettingKey() const
{
return d->configPrefixSettingKey();
}
QVector<PimCommon::PluginUtilData> PluginEditorCheckBeforeSendManager::pluginsDataList() const
{
return d->pluginsDataList();
}
......@@ -22,6 +22,7 @@
#include <QObject>
#include "messagecomposer_export.h"
#include <PimCommon/PluginUtil>
namespace MessageComposer
{
class PluginEditorCheckBeforeSendManagerPrivate;
......@@ -36,6 +37,10 @@ public:
static PluginEditorCheckBeforeSendManager *self();
QVector<PluginEditorCheckBeforeSend *> pluginsList() const;
QString configGroupName() const;
QString configPrefixSettingKey() const;
QVector<PimCommon::PluginUtilData> pluginsDataList() const;
private:
PluginEditorCheckBeforeSendManagerPrivate *const d;
};
......
......@@ -20,7 +20,7 @@
#include "viewerpluginmanager.h"
#include "viewerplugin.h"
#include "messageviewer_debug.h"
#include <PimCommon/PluginUtil>
#include <KSharedConfig>
#include <kpluginmetadata.h>
......@@ -80,7 +80,7 @@ public:
bool initializePluginList();
void loadPlugin(ViewerPluginInfo *item);
QVector<MessageViewer::ViewerPlugin *> pluginsList() const;
QVector<MessageViewer::ViewerPluginManager::ViewerPluginData> pluginDataList() const;
QVector<PimCommon::PluginUtilData> pluginDataList() const;
QString serviceTypeName;
QString pluginName;
......@@ -88,7 +88,7 @@ public:
QString configPrefixSettingKey() const;
private:
QVector<ViewerPluginInfo> mPluginList;
QVector<MessageViewer::ViewerPluginManager::ViewerPluginData> mPluginDataList;
QVector<PimCommon::PluginUtilData> mPluginDataList;
ViewerPluginManager *q;
};
......@@ -136,7 +136,7 @@ bool ViewerPluginManagerPrivate::initializePluginList()
while (i.hasPrevious()) {
ViewerPluginInfo info;
info.metaData = i.previous();
MessageViewer::ViewerPluginManager::ViewerPluginData pluginData;
PimCommon::PluginUtilData pluginData;
pluginData.mDescription = info.metaData.description();
pluginData.mName = info.metaData.name();
pluginData.mIdentifier = info.metaData.pluginId();
......@@ -186,7 +186,7 @@ QVector<ViewerPlugin *> ViewerPluginManagerPrivate::pluginsList() const
return lst;
}
QVector<MessageViewer::ViewerPluginManager::ViewerPluginData> ViewerPluginManagerPrivate::pluginDataList() const
QVector<PimCommon::PluginUtilData> ViewerPluginManagerPrivate::pluginDataList() const
{
return mPluginDataList;
}
......@@ -238,7 +238,7 @@ QString ViewerPluginManager::pluginName() const
return d->pluginName;
}
QVector<MessageViewer::ViewerPluginManager::ViewerPluginData> ViewerPluginManager::pluginsDataList() const
QVector<PimCommon::PluginUtilData> ViewerPluginManager::pluginsDataList() const
{
return d->pluginDataList();
}
......
......@@ -22,7 +22,7 @@
#include <QObject>
#include "messageviewer_export.h"
#include <PimCommon/PluginUtil>
namespace MessageViewer
{
class ViewerPluginManagerPrivate;
......@@ -31,26 +31,13 @@ class MESSAGEVIEWER_EXPORT ViewerPluginManager : public QObject
{
Q_OBJECT
public:
class ViewerPluginData
{
public:
ViewerPluginData()
: mEnableByDefault(false)
{
}
QString mDescription;
QString mName;
QString mIdentifier;
bool mEnableByDefault;
};
explicit ViewerPluginManager(QObject *parent = Q_NULLPTR);
~ViewerPluginManager();
static ViewerPluginManager *self();
QVector<MessageViewer::ViewerPlugin *> pluginsList() const;
QVector<MessageViewer::ViewerPluginManager::ViewerPluginData> pluginsDataList() const;
QVector<PimCommon::PluginUtilData> pluginsDataList() const;
void setServiceTypeName(const QString &serviceName);
QString serviceTypeName() const;
......
Supports Markdown
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