summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-08 11:28:09 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-08 11:28:09 (GMT)
commitdbdd09a329d8c7082b7ef0d2ef23c9f589dd15fc (patch)
treef3a6caf025983a03b90ea2971b42f05d6199c435
parent3fdbbaf1072f08a66da11ee1996bd9bddd2aacb2 (diff)
Port to new api
-rw-r--r--CMakeLists.txt4
-rw-r--r--messagecomposer/src/plugineditor/plugineditormanager.cpp39
-rw-r--r--messagecomposer/src/plugineditor/plugineditormanager.h18
-rw-r--r--messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesendmanager.cpp67
-rw-r--r--messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesendmanager.h5
-rw-r--r--messageviewer/src/viewerplugins/viewerpluginmanager.cpp12
-rw-r--r--messageviewer/src/viewerplugins/viewerpluginmanager.h17
7 files changed, 110 insertions, 52 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f8ee71b..9fe067c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)
diff --git a/messagecomposer/src/plugineditor/plugineditormanager.cpp b/messagecomposer/src/plugineditor/plugineditormanager.cpp
index 7b53911..00e23dd 100644
--- a/messagecomposer/src/plugineditor/plugineditormanager.cpp
+++ b/messagecomposer/src/plugineditor/plugineditormanager.cpp
@@ -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();
+}
+
diff --git a/messagecomposer/src/plugineditor/plugineditormanager.h b/messagecomposer/src/plugineditor/plugineditormanager.h
index 5953329..cb5d341 100644
--- a/messagecomposer/src/plugineditor/plugineditormanager.h
+++ b/messagecomposer/src/plugineditor/plugineditormanager.h
@@ -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;
};
diff --git a/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesendmanager.cpp b/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesendmanager.cpp
index 33c5ff7..5a618a7 100644
--- a/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesendmanager.cpp
+++ b/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesendmanager.cpp
@@ -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();
+}
diff --git a/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesendmanager.h b/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesendmanager.h
index 55001bc..e8e9e5c 100644
--- a/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesendmanager.h
+++ b/messagecomposer/src/plugineditorcheckbeforesend/plugineditorcheckbeforesendmanager.h
@@ -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;
};
diff --git a/messageviewer/src/viewerplugins/viewerpluginmanager.cpp b/messageviewer/src/viewerplugins/viewerpluginmanager.cpp
index 8a4ec67..ca75e94 100644
--- a/messageviewer/src/viewerplugins/viewerpluginmanager.cpp
+++ b/messageviewer/src/viewerplugins/viewerpluginmanager.cpp
@@ -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();
}
diff --git a/messageviewer/src/viewerplugins/viewerpluginmanager.h b/messageviewer/src/viewerplugins/viewerpluginmanager.h
index 248eaa2..ea0548a 100644
--- a/messageviewer/src/viewerplugins/viewerpluginmanager.h
+++ b/messageviewer/src/viewerplugins/viewerpluginmanager.h
@@ -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;