Commit 8a8c4215 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port to new api

parent eb6be669
Pipeline #75640 passed with stage
in 43 minutes and 5 seconds
......@@ -5,9 +5,9 @@
*/
#include "plugineditormanager.h"
#include "kcoreaddons_version.h"
#include "messagecomposer_debug.h"
#include "plugineditor.h"
#include <KPluginFactory>
#include <KPluginLoader>
#include <KPluginMetaData>
......@@ -22,6 +22,7 @@ public:
{
}
KPluginMetaData data;
PimCommon::PluginUtilData pluginData;
QString metaDataFileNameBaseName;
QString metaDataFileName;
......@@ -64,7 +65,11 @@ private:
void PluginEditorManagerPrivate::initializePlugins()
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("kmail/plugineditor"));
#else
const QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(QStringLiteral("kmail/plugineditor"));
#endif
const QPair<QStringList, QStringList> pair = PimCommon::PluginUtil::loadPluginSetting(configGroupName(), configPrefixSettingKey());
......@@ -82,6 +87,7 @@ void PluginEditorManagerPrivate::initializePlugins()
info.isEnabled = isPluginActivated;
info.metaDataFileNameBaseName = QFileInfo(data.fileName()).baseName();
info.metaDataFileName = data.fileName();
info.data = data;
const QVariant p = data.rawData().value(QStringLiteral("X-KDE-KMailEditor-Order")).toVariant();
int order = -1;
if (p.isValid()) {
......@@ -103,6 +109,7 @@ void PluginEditorManagerPrivate::initializePlugins()
void PluginEditorManagerPrivate::loadPlugin(PluginEditorInfo *item)
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
KPluginLoader pluginLoader(item->metaDataFileName);
if (pluginLoader.factory()) {
item->plugin = pluginLoader.factory()->create<PluginEditor>(q, QVariantList() << item->metaDataFileNameBaseName);
......@@ -111,6 +118,15 @@ void PluginEditorManagerPrivate::loadPlugin(PluginEditorInfo *item)
item->plugin->setOrder(item->order);
mPluginDataList.append(item->pluginData);
}
#else
if (auto plugin = KPluginFactory::instantiatePlugin<PluginEditor>(item->data, q, QVariantList() << item->metaDataFileName).plugin) {
item->plugin = plugin;
item->plugin->setIsEnabled(item->isEnabled);
item->pluginData.mHasConfigureDialog = item->plugin->hasConfigureDialog();
item->plugin->setOrder(item->order);
mPluginDataList.append(item->pluginData);
}
#endif
}
QVector<PluginEditor *> PluginEditorManagerPrivate::pluginsList() const
......
......@@ -5,6 +5,7 @@
*/
#include "plugineditorcheckbeforesendmanager.h"
#include "kcoreaddons_version.h"
#include "messagecomposer_debug.h"
#include "plugineditorcheckbeforesend.h"
#include <KPluginFactory>
......@@ -22,6 +23,7 @@ public:
{
}
KPluginMetaData data;
PimCommon::PluginUtilData pluginData;
QString metaDataFileNameBaseName;
QString metaDataFileName;
......@@ -77,7 +79,11 @@ QVector<PimCommon::PluginUtilData> PluginEditorCheckBeforeSendManagerPrivate::pl
void PluginEditorCheckBeforeSendManagerPrivate::initializePlugins()
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("kmail/plugincheckbeforesend"));
#else
const QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(QStringLiteral("kmail/plugincheckbeforesend"));
#endif
const QPair<QStringList, QStringList> pair = PimCommon::PluginUtil::loadPluginSetting(configGroupName(), configPrefixSettingKey());
......@@ -95,6 +101,7 @@ void PluginEditorCheckBeforeSendManagerPrivate::initializePlugins()
info.isEnabled = isPluginActivated;
info.metaDataFileNameBaseName = QFileInfo(data.fileName()).baseName();
info.metaDataFileName = data.fileName();
info.data = data;
if (pluginVersion() == data.version()) {
info.plugin = nullptr;
mPluginList.push_back(info);
......@@ -110,6 +117,7 @@ void PluginEditorCheckBeforeSendManagerPrivate::initializePlugins()
void PluginEditorCheckBeforeSendManagerPrivate::loadPlugin(PluginEditorCheckBeforeSendInfo *item)
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
KPluginLoader pluginLoader(item->metaDataFileName);
if (pluginLoader.factory()) {
item->plugin = pluginLoader.factory()->create<PluginEditorCheckBeforeSend>(q, QVariantList() << item->metaDataFileNameBaseName);
......@@ -117,6 +125,14 @@ void PluginEditorCheckBeforeSendManagerPrivate::loadPlugin(PluginEditorCheckBefo
item->pluginData.mHasConfigureDialog = item->plugin->hasConfigureDialog();
mPluginDataList.append(item->pluginData);
}
#else
if (auto plugin = KPluginFactory::instantiatePlugin<PluginEditorCheckBeforeSend>(item->data, q, QVariantList() << item->metaDataFileName).plugin) {
item->plugin = plugin;
item->plugin->setIsEnabled(item->isEnabled);
item->pluginData.mHasConfigureDialog = item->plugin->hasConfigureDialog();
mPluginDataList.append(item->pluginData);
}
#endif
}
QVector<PluginEditorCheckBeforeSend *> PluginEditorCheckBeforeSendManagerPrivate::pluginsList() const
......
......@@ -5,6 +5,7 @@
*/
#include "plugineditorconverttextmanager.h"
#include "kcoreaddons_version.h"
#include "messagecomposer_debug.h"
#include "plugineditorconverttext.h"
#include <KPluginFactory>
......@@ -25,6 +26,7 @@ public:
PimCommon::PluginUtilData pluginData;
QString metaDataFileNameBaseName;
QString metaDataFileName;
KPluginMetaData data;
PluginEditorConvertText *plugin = nullptr;
bool isEnabled = true;
};
......@@ -77,7 +79,11 @@ QVector<PimCommon::PluginUtilData> PluginEditorConvertTextManagerPrivate::plugin
void PluginEditorConvertTextManagerPrivate::initializePlugins()
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("kmail/plugineditorconverttext"));
#else
const QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(QStringLiteral("kmail/plugineditorconverttext"));
#endif
const QPair<QStringList, QStringList> pair = PimCommon::PluginUtil::loadPluginSetting(configGroupName(), configPrefixSettingKey());
......@@ -95,6 +101,7 @@ void PluginEditorConvertTextManagerPrivate::initializePlugins()
info.isEnabled = isPluginActivated;
info.metaDataFileNameBaseName = QFileInfo(data.fileName()).baseName();
info.metaDataFileName = data.fileName();
info.data = data;
if (pluginVersion() == data.version()) {
info.plugin = nullptr;
mPluginList.push_back(info);
......@@ -110,6 +117,7 @@ void PluginEditorConvertTextManagerPrivate::initializePlugins()
void PluginEditorConvertTextManagerPrivate::loadPlugin(PluginEditorConvertTextInfo *item)
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
KPluginLoader pluginLoader(item->metaDataFileName);
if (pluginLoader.factory()) {
item->plugin = pluginLoader.factory()->create<PluginEditorConvertText>(q, QVariantList() << item->metaDataFileNameBaseName);
......@@ -117,6 +125,14 @@ void PluginEditorConvertTextManagerPrivate::loadPlugin(PluginEditorConvertTextIn
item->pluginData.mHasConfigureDialog = item->plugin->hasConfigureDialog();
mPluginDataList.append(item->pluginData);
}
#else
if (auto plugin = KPluginFactory::instantiatePlugin<PluginEditorConvertText>(item->data, q, QVariantList() << item->metaDataFileName).plugin) {
item->plugin = plugin;
item->plugin->setIsEnabled(item->isEnabled);
item->pluginData.mHasConfigureDialog = item->plugin->hasConfigureDialog();
mPluginDataList.append(item->pluginData);
}
#endif
}
QVector<PluginEditorConvertText *> PluginEditorConvertTextManagerPrivate::pluginsList() const
......
......@@ -5,6 +5,7 @@
*/
#include "plugineditorgrammarmanager.h"
#include "kcoreaddons_version.h"
#include "messagecomposer_debug.h"
#include "plugineditorgrammarcustomtoolsviewinterface.h"
#include <KPluginFactory>
......@@ -26,6 +27,7 @@ public:
PimCommon::PluginUtilData pluginData;
QString metaDataFileNameBaseName;
QString metaDataFileName;
KPluginMetaData data;
PimCommon::CustomToolsPlugin *plugin = nullptr;
bool isEnabled = true;
};
......@@ -78,7 +80,11 @@ QVector<PimCommon::PluginUtilData> PluginEditorGrammarManagerPrivate::pluginsDat
void PluginEditorGrammarManagerPrivate::initializePlugins()
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("kmail/plugineditorgrammar"));
#else
const QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(QStringLiteral("kmail/plugineditorgrammar"));
#endif
const QPair<QStringList, QStringList> pair = PimCommon::PluginUtil::loadPluginSetting(configGroupName(), configPrefixSettingKey());
......@@ -96,6 +102,7 @@ void PluginEditorGrammarManagerPrivate::initializePlugins()
info.isEnabled = isPluginActivated;
info.metaDataFileNameBaseName = QFileInfo(data.fileName()).baseName();
info.metaDataFileName = data.fileName();
info.data = data;
if (pluginEditorGrammarVersion() == data.version()) {
info.plugin = nullptr;
mPluginList.push_back(info);
......@@ -111,6 +118,7 @@ void PluginEditorGrammarManagerPrivate::initializePlugins()
void PluginEditorGrammarManagerPrivate::loadPlugin(PluginEditorGrammarInfo *item)
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
KPluginLoader pluginLoader(item->metaDataFileName);
if (pluginLoader.factory()) {
item->plugin = pluginLoader.factory()->create<PimCommon::CustomToolsPlugin>(q, QVariantList() << item->metaDataFileNameBaseName);
......@@ -118,6 +126,14 @@ void PluginEditorGrammarManagerPrivate::loadPlugin(PluginEditorGrammarInfo *item
item->pluginData.mHasConfigureDialog = item->plugin->hasConfigureDialog();
mPluginDataList.append(item->pluginData);
}
#else
if (auto plugin = KPluginFactory::instantiatePlugin<PimCommon::CustomToolsPlugin>(item->data, q, QVariantList() << item->metaDataFileName).plugin) {
item->plugin = plugin;
item->plugin->setIsEnabled(item->isEnabled);
item->pluginData.mHasConfigureDialog = item->plugin->hasConfigureDialog();
mPluginDataList.append(item->pluginData);
}
#endif
}
QVector<PimCommon::CustomToolsPlugin *> PluginEditorGrammarManagerPrivate::pluginsList() const
......
......@@ -5,6 +5,7 @@
*/
#include "plugineditorinitmanager.h"
#include "kcoreaddons_version.h"
#include "messagecomposer_debug.h"
#include "plugineditorinit.h"
#include <KPluginFactory>
......@@ -25,6 +26,7 @@ public:
PimCommon::PluginUtilData pluginData;
QString metaDataFileNameBaseName;
QString metaDataFileName;
KPluginMetaData data;
PluginEditorInit *plugin = nullptr;
bool isEnabled = true;
};
......@@ -77,7 +79,11 @@ QVector<PimCommon::PluginUtilData> PluginEditorInitManagerPrivate::pluginsDataLi
void PluginEditorInitManagerPrivate::initializePlugins()
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("kmail/plugineditorinit"));
#else
const QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(QStringLiteral("kmail/plugineditorinit"));
#endif
const QPair<QStringList, QStringList> pair = PimCommon::PluginUtil::loadPluginSetting(configGroupName(), configPrefixSettingKey());
......@@ -95,6 +101,7 @@ void PluginEditorInitManagerPrivate::initializePlugins()
info.isEnabled = isPluginActivated;
info.metaDataFileNameBaseName = QFileInfo(data.fileName()).baseName();
info.metaDataFileName = data.fileName();
info.data = data;
if (pluginVersion() == data.version()) {
info.plugin = nullptr;
mPluginList.push_back(info);
......@@ -110,6 +117,7 @@ void PluginEditorInitManagerPrivate::initializePlugins()
void PluginEditorInitManagerPrivate::loadPlugin(PluginEditorInitInfo *item)
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
KPluginLoader pluginLoader(item->metaDataFileName);
if (pluginLoader.factory()) {
item->plugin = pluginLoader.factory()->create<PluginEditorInit>(q, QVariantList() << item->metaDataFileNameBaseName);
......@@ -117,6 +125,14 @@ void PluginEditorInitManagerPrivate::loadPlugin(PluginEditorInitInfo *item)
item->pluginData.mHasConfigureDialog = item->plugin->hasConfigureDialog();
mPluginDataList.append(item->pluginData);
}
#else
if (auto plugin = KPluginFactory::instantiatePlugin<PluginEditorInit>(item->data, q, QVariantList() << item->metaDataFileName).plugin) {
item->plugin = plugin;
item->plugin->setIsEnabled(item->isEnabled);
item->pluginData.mHasConfigureDialog = item->plugin->hasConfigureDialog();
mPluginDataList.append(item->pluginData);
}
#endif
}
QVector<PluginEditorInit *> PluginEditorInitManagerPrivate::pluginsList() const
......
......@@ -6,6 +6,7 @@
#include "headerstylepluginmanager.h"
#include "headerstyleplugin.h"
#include "kcoreaddons_version.h"
#include "messageviewer_debug.h"
#include <KPluginFactory>
#include <KPluginLoader>
......@@ -25,6 +26,7 @@ public:
PimCommon::PluginUtilData pluginData;
QString metaDataFileNameBaseName;
QString metaDataFileName;
KPluginMetaData data;
MessageViewer::HeaderStylePlugin *plugin = nullptr;
bool isEnabled = false;
};
......@@ -76,7 +78,11 @@ QString HeaderStylePluginManagerPrivate::configPrefixSettingKey() const
void HeaderStylePluginManagerPrivate::initializePluginList()
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("messageviewer/headerstyle"));
#else
const QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(QStringLiteral("messageviewer/headerstyle"));
#endif
QVectorIterator<KPluginMetaData> i(plugins);
i.toBack();
......@@ -95,6 +101,7 @@ void HeaderStylePluginManagerPrivate::initializePluginList()
info.isEnabled = isPluginActivated;
info.metaDataFileNameBaseName = QFileInfo(data.fileName()).baseName();
info.metaDataFileName = data.fileName();
info.data = data;
const QString version = data.version();
if (pluginVersion() == version) {
const QVariant p = data.rawData().value(QStringLiteral("X-KDE-MessageViewer-Header-Order")).toVariant();
......@@ -137,6 +144,7 @@ QVector<MessageViewer::HeaderStylePlugin *> HeaderStylePluginManagerPrivate::plu
void HeaderStylePluginManagerPrivate::loadPlugin(HeaderStylePluginInfo *item)
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
KPluginLoader pluginLoader(item->metaDataFileName);
if (pluginLoader.factory()) {
item->plugin = pluginLoader.factory()->create<MessageViewer::HeaderStylePlugin>(q, QVariantList() << item->metaDataFileNameBaseName);
......@@ -144,6 +152,14 @@ void HeaderStylePluginManagerPrivate::loadPlugin(HeaderStylePluginInfo *item)
item->pluginData.mHasConfigureDialog = false;
mPluginDataList.append(item->pluginData);
}
#else
if (auto plugin = KPluginFactory::instantiatePlugin<MessageViewer::HeaderStylePlugin>(item->data, q, QVariantList() << item->metaDataFileName).plugin) {
item->plugin = plugin;
item->plugin->setIsEnabled(item->isEnabled);
item->pluginData.mHasConfigureDialog = false;
mPluginDataList.append(item->pluginData);
}
#endif
}
MessageViewer::HeaderStylePlugin *HeaderStylePluginManagerPrivate::pluginFromIdentifier(const QString &id)
......
......@@ -6,12 +6,12 @@
*/
#include "messagepartrendererfactory.h"
#include "kcoreaddons_version.h"
#include "messagepartrendererbase.h"
#include "messagepartrendererfactory_p.h"
#include "messagepartrenderplugin.h"
#include "viewer/urlhandlermanager.h"
#include "messagepartrendererbase.h"
#include "messageviewer_debug.h"
#include "viewer/urlhandlermanager.h"
#include "plugins/attachmentmessagepartrenderer.h"
#include "plugins/messagepartrenderer.h"
......@@ -19,8 +19,10 @@
#include <KPluginLoader>
#include <KPluginMetaData>
#include <QJsonArray>
#include <QMimeDatabase>
#include <QPluginLoader>
#include <algorithm>
using namespace MessageViewer;
......@@ -49,7 +51,7 @@ void MessagePartRendererFactoryPrivate::loadPlugins()
if (m_pluginSubdir.isEmpty()) {
return;
}
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
KPluginLoader::forEachPlugin(m_pluginSubdir, [this](const QString &path) {
QPluginLoader loader(path);
const auto pluginData = loader.metaData().value(QLatin1String("MetaData")).toObject().value(QLatin1String("renderer")).toArray();
......@@ -86,6 +88,44 @@ void MessagePartRendererFactoryPrivate::loadPlugins()
URLHandlerManager::instance()->registerHandler(handler, mimeType);
}
});
#else
const QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(m_pluginSubdir);
for (const auto &md : plugins) {
const auto pluginData = md.rawData().value(QLatin1String("MetaData")).toObject().value(QLatin1String("renderer")).toArray();
if (pluginData.isEmpty()) {
qCWarning(MESSAGEVIEWER_LOG) << "Plugin" << md.fileName() << "has no meta data.";
return;
}
QPluginLoader loader(md.fileName());
auto plugin = qobject_cast<MessagePartRenderPlugin *>(loader.instance());
if (!plugin) {
qCWarning(MESSAGEVIEWER_LOG) << md.fileName() << "is not a MessagePartRendererPlugin";
return;
}
MessagePartRendererBase *renderer = nullptr;
for (int i = 0; (renderer = plugin->renderer(i)) && i < pluginData.size(); ++i) {
const auto metaData = pluginData.at(i).toObject();
const auto type = metaData.value(QLatin1String("type")).toString().toUtf8();
if (type.isEmpty()) {
qCWarning(MESSAGEVIEWER_LOG) << md.fileName() << "returned empty type specification for index" << i;
break;
}
const auto mimetype = metaData.value(QLatin1String("mimetype")).toString().toLower();
// priority should always be higher than the built-in ones, otherwise what's the point?
const auto priority = metaData.value(QLatin1String("priority")).toInt() + 100;
qCDebug(MESSAGEVIEWER_LOG) << "renderer plugin for " << type << mimetype << priority;
insert(type, renderer, mimetype, priority);
}
const Interface::BodyPartURLHandler *handler = nullptr;
for (int i = 0; (handler = plugin->urlHandler(i)); ++i) {
const auto metaData = pluginData.at(i).toObject();
const auto mimeType = metaData.value(QLatin1String("mimetype")).toString().toLower();
URLHandlerManager::instance()->registerHandler(handler, mimeType);
}
}
#endif
}
void MessagePartRendererFactoryPrivate::initialize_builtin_renderers()
......
......@@ -5,6 +5,7 @@
*/
#include "messageviewercheckbeforedeletingpluginmanager.h"
#include "kcoreaddons_version.h"
#include "messageviewer_debug.h"
#include "messageviewercheckbeforedeletingplugin.h"
#include <KPluginFactory>
......@@ -22,6 +23,7 @@ public:
{
}
KPluginMetaData data;
PimCommon::PluginUtilData pluginData;
QString metaDataFileNameBaseName;
QString metaDataFileName;
......@@ -76,7 +78,11 @@ QString MessageViewerCheckBeforeDeletingPluginManagerPrivate::configPrefixSettin
void MessageViewerCheckBeforeDeletingPluginManagerPrivate::initializePluginList()
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("messageviewer/checkbeforedeleting"));
#else
const QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(QStringLiteral("messageviewer/checkbeforedeleting"));
#endif
QVectorIterator<KPluginMetaData> i(plugins);
i.toBack();
const QPair<QStringList, QStringList> pair = PimCommon::PluginUtil::loadPluginSetting(configGroupName(), configPrefixSettingKey());
......@@ -92,6 +98,7 @@ void MessageViewerCheckBeforeDeletingPluginManagerPrivate::initializePluginList(
const bool isPluginActivated =
PimCommon::PluginUtil::isPluginActivated(pair.first, pair.second, info.pluginData.mEnableByDefault, info.pluginData.mIdentifier);
info.isEnabled = isPluginActivated;
info.data = data;
info.metaDataFileNameBaseName = QFileInfo(data.fileName()).baseName();
info.metaDataFileName = data.fileName();
......@@ -137,6 +144,7 @@ QVector<MessageViewer::MessageViewerCheckBeforeDeletingPlugin *> MessageViewerCh
void MessageViewerCheckBeforeDeletingPluginManagerPrivate::loadPlugin(CheckBeforeDeletingPluginInfo *item)
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
KPluginLoader pluginLoader(item->metaDataFileName);
if (pluginLoader.factory()) {
item->plugin =
......@@ -146,6 +154,17 @@ void MessageViewerCheckBeforeDeletingPluginManagerPrivate::loadPlugin(CheckBefor
item->plugin->setIsEnabled(item->isEnabled);
mPluginDataList.append(item->pluginData);
}
#else
if (auto plugin =
KPluginFactory::instantiatePlugin<MessageViewer::MessageViewerCheckBeforeDeletingPlugin>(item->data, q, QVariantList() << item->metaDataFileName)
.plugin) {
item->plugin = plugin;
// By default it's true
item->pluginData.mHasConfigureDialog = true;
item->plugin->setIsEnabled(item->isEnabled);
mPluginDataList.append(item->pluginData);
}
#endif
}
MessageViewerCheckBeforeDeletingPlugin *MessageViewerCheckBeforeDeletingPluginManagerPrivate::pluginFromIdentifier(const QString &id)
......
......@@ -5,6 +5,7 @@
*/
#include "messageviewerconfiguresettingspluginmanager.h"
#include "kcoreaddons_version.h"
#include "messageviewer_debug.h"
#include "messageviewerconfiguresettingsplugin.h"
#include <KPluginFactory>
......@@ -22,6 +23,7 @@ public:
{
}
KPluginMetaData data;
PimCommon::PluginUtilData pluginData;
QString metaDataFileNameBaseName;
QString metaDataFileName;
......@@ -75,7 +77,11 @@ QString MessageViewerConfigureSettingsPluginManagerPrivate::configPrefixSettingK
void MessageViewerConfigureSettingsPluginManagerPrivate::initializePluginList()
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("messageviewer/configuresettings"));
#else
const QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(QStringLiteral("messageviewer/configuresettings"));
#endif
QVectorIterator<KPluginMetaData> i(plugins);
i.toBack();
......@@ -91,6 +97,7 @@ void MessageViewerConfigureSettingsPluginManagerPrivate::initializePluginList()
// 2) look at if plugin is activated
info.metaDataFileNameBaseName = QFileInfo(data.fileName()).baseName();
info.metaDataFileName = data.fileName();
info.data = data;
const QString version = data.version();
if (configurePluginVersion() == version) {
const QVariant p = data.rawData().value(QStringLiteral("X-KDE-MessageViewer-Configure-Order")).toVariant();
......@@ -133,6 +140,7 @@ QVector<MessageViewer::MessageViewerConfigureSettingsPlugin *> MessageViewerConf
void MessageViewerConfigureSettingsPluginManagerPrivate::loadPlugin(ConfigureSettingsPluginInfo *item)
{
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
KPluginLoader pluginLoader(item->metaDataFileName);
if (pluginLoader.factory()) {
item->plugin = pluginLoader.factory()->create<MessageViewer::MessageViewerConfigureSettingsPlugin>(q, QVariantList() << item->metaDataFileNameBaseName);
......@@ -140,6 +148,16 @@ void MessageViewerConfigureSettingsPluginManagerPrivate::loadPlugin(ConfigureSet
item->pluginData.mHasConfigureDialog = true;
mPluginDataList.append(item->pluginData);
}
#else
if (auto plugin =
KPluginFactory::instantiatePlugin<MessageViewer::MessageViewerConfigureSettingsPlugin>(item->data, q, QVariantList() << item->metaDataFileName)
.plugin) {
item->plugin = plugin;
// By default it's true
item->pluginData.mHasConfigureDialog = true;
mPluginDataList.append(item->pluginData);
}
#endif
}
MessageViewerConfigureSettingsPlugin *MessageViewerConfigureSettingsPluginManagerPrivate::pluginFromIdentifier(const QString &id)
......
......@@ -5,6 +5,7 @@
*/
#include "viewerpluginmanager.h"
#include "kcoreaddons_version.h"
#include "messageviewer_debug.h"
#include "viewerplugin.h"
......@@ -24,6 +25,7 @@ public:
{
}
KPluginMetaData data;
QString metaDataFileNameBaseName;
QString metaDataFileName;
PimCommon::PluginUtilData pluginData;
......@@ -84,10 +86,17 @@ bool ViewerPluginManagerPrivate::initializePluginList()
return false;
}
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(pluginDirectory);
// We need common plugin to avoid to duplicate code between akregator/kmail
plugins += KPluginLoader::findPlugins(QStringLiteral("messageviewer/viewercommonplugin"));
#else
QVector<KPluginMetaData> plugins = KPluginMetaData::findPlugins(pluginDirectory);
// We need common plugin to avoid to duplicate code between akregator/kmail
plugins += KPluginMetaData::findPlugins(QStringLiteral("messageviewer/viewercommonplugin"));
#endif
const QPair<QStringList, QStringList> pair = PimCommon::PluginUtil::loadPluginSetting(configGroupName(), configPrefixSettingKey());
QVectorIterator<KPluginMetaData> i(plugins);
......@@ -105,6 +114,7 @@ bool ViewerPluginManagerPrivate::initializePluginList()
info.isEnabled = isPluginActivated;
info.metaDataFileNameBaseName = QFileInfo(data.fileName()).baseName();
info.metaDataFileName = data.fileName();
info.data = data;