[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9

Maximiliano Curia maxy at moszumanska.debian.org
Mon May 9 09:05:24 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=35e1400

The following commit has been merged in the master branch:
commit 35e1400483e5456a95f988babf345e4c085ab8c3
Author: Lasath Fernando <kde at lasath.org>
Date:   Fri Jul 13 00:42:27 2012 +1000

    Make MessageProcessor only load enabled filters
    
    Reads the config from "ktelepathyrc". Very unhappy about that. I would
    like it to either be passed in at runtime, or, at the very least, be
    defined in a global constant accross the whole library.
---
 KTp/message-processor.cpp | 37 +++++++++++++++++++++++++------------
 KTp/message-processor.h   |  5 ++---
 2 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/KTp/message-processor.cpp b/KTp/message-processor.cpp
index 926bef7..58a9998 100644
--- a/KTp/message-processor.cpp
+++ b/KTp/message-processor.cpp
@@ -28,6 +28,7 @@
 #include <KPluginFactory>
 
 MessageProcessor* MessageProcessor::s_instance = 0;
+static const QString serviceType = QLatin1String("KTpTextUi/MessageFilter");
 
 MessageProcessor* MessageProcessor::instance()
 {
@@ -81,21 +82,33 @@ Message MessageProcessor::processOutgoingMessage(const Tp::Message &sentMessage)
 void MessageProcessor::loadAllPlugins() {
     kDebug() << "Starting loading filters...";
 
-    KService::List offers = KServiceTypeTrader::self()->query(QLatin1String("KTpTextUi/MessageFilter"));
-    Q_FOREACH (KService::Ptr service, offers) {
-        kDebug() << "loaded service :" << service;
-        KPluginFactory *factory = KPluginLoader(service->library()).factory();
+    Q_FOREACH (const KPluginInfo &plugin, pluginList()) {
+        kDebug() << "found filter :" << plugin.pluginName();
 
-        if(factory) {
-            kDebug() << "loaded factory :" << factory;
-            AbstractMessageFilter *filter = factory->create<AbstractMessageFilter>(this);
+        if (plugin.isPluginEnabled()) {
+            kDebug() << "it is enabled";
+            KService::Ptr service = plugin.service();
 
-            if(filter) {
-                kDebug() << "loaded message filter : " << filter;
-                m_filters.append(filter);
+            KPluginFactory *factory = KPluginLoader(service->library()).factory();
+            if(factory) {
+                kDebug() << "loaded factory :" << factory;
+                AbstractMessageFilter *filter = factory->create<AbstractMessageFilter>(this);
+
+                if(filter) {
+                    kDebug() << "loaded message filter : " << filter;
+                    m_filters.append(filter);
+                }
+            } else {
+                kError() << "error loading plugin :" << service->library();
             }
-        } else {
-            kError() << "error loading plugin :" << service->library();
         }
     }
 }
+
+KPluginInfo::List MessageProcessor::pluginList()
+{
+    KService::List offers = KServiceTypeTrader::self()->query(serviceType);
+    KConfigGroup config = KConfig(QLatin1String("ktelepathyrc")).group("Filters");
+
+    return KPluginInfo::fromServices(offers, config);
+}
diff --git a/KTp/message-processor.h b/KTp/message-processor.h
index 08cc386..f07a13e 100644
--- a/KTp/message-processor.h
+++ b/KTp/message-processor.h
@@ -22,6 +22,7 @@
 
 #include <QObject>
 #include <QList>
+#include <KPluginInfo>
 
 #include <message.h>
 #include <ktpchat_export.h>
@@ -41,19 +42,17 @@ Q_OBJECT
 
 public:
     static MessageProcessor* instance();
-
     ~MessageProcessor();
 
     //text-ui will call this somewhere in handleIncommingMessage just before displaying it
     Message processIncomingMessage(const Tp::ReceivedMessage &message);
     Message processOutgoingMessage(const Tp::Message &message);
 
-
+    static KPluginInfo::List pluginList();
 
 protected:
     explicit MessageProcessor();
 
-
 private:
     void loadAllPlugins();
     static MessageProcessor* s_instance;

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list