[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/runtime/knotify
From:       Jeffery MacEachern <j.maceachern () gmail ! com>
Date:       2010-11-10 11:19:07
Message-ID: 20101110111908.0475CAC89E () svn ! kde ! org
[Download RAW message or body]

SVN commit 1195100 by jmaceachern:

Adds plugin loading support to KNotify.
- Splits knotifyplugin.cpp and knotifyconfig.cpp off into a library \
                (libknotifyplugin) for plugins to link to.
- No UI support yet.


 M  +21 -8     CMakeLists.txt  
 M  +19 -0     knotify.cpp  
 M  +2 -2      knotifyconfig.h  
 A             knotifynotifymethod.desktop  
 M  +19 -1     knotifyplugin.cpp  
 M  +18 -11    knotifyplugin.h  
 M  +1 -2      notifybyexecute.cpp  
 M  +1 -1      notifybyktts.cpp  
 M  +1 -1      notifybylogfile.cpp  
 M  +1 -1      notifybypopup.cpp  
 M  +1 -2      notifybysound.cpp  
 M  +1 -1      notifybytaskbar.cpp  


--- trunk/KDE/kdebase/runtime/knotify/CMakeLists.txt #1195099:1195100
@@ -4,8 +4,6 @@
 set(knotify_SRCS
 main.cpp
 knotify.cpp
-knotifyplugin.cpp
-knotifyconfig.cpp
 notifybysound.cpp
 notifybypopup.cpp
 notifybypopupgrowl.cpp
@@ -17,6 +15,16 @@
 ksolidnotify.cpp
 )
 
+set(knotifyplugin_SRCS
+knotifyplugin.cpp
+knotifyconfig.cpp
+)
+
+set(knotifyplugin_HEADERS
+knotifyplugin.h
+knotifyconfig.h
+)
+
 qt4_add_dbus_interfaces(knotify_SRCS \
${KDE4_DBUS_INTERFACES_DIR}/org.kde.KSpeech.xml)  
 kde4_add_app_icon(knotify_SRCS \
"${CMAKE_SOURCE_DIR}/pics/oxygen/*/apps/preferences-desktop-notification.png") @@ \
-24,23 +32,32 @@  set (knotify_OUTPUT_NAME knotify4)
 kde4_add_executable( knotify ${knotify_SRCS})
 
+kde4_add_library( knotifyplugin SHARED ${knotifyplugin_SRCS})
+
+
 if (Q_WS_MAC)
     set_target_properties(knotify PROPERTIES MACOSX_BUNDLE_INFO_PLIST \
                ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.template)
     set_target_properties(knotify PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER \
                "org.kde.knotify4")
     set_target_properties(knotify PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "KDE Notify")
 endif (Q_WS_MAC)
 
-target_link_libraries( knotify ${KDE4_KDEUI_LIBS} ${KDE4_PHONON_LIBS} \
${KDE4_SOLID_LIBS}) +target_link_libraries( knotify ${KDE4_KDEUI_LIBS} \
${KDE4_PHONON_LIBS} ${KDE4_SOLID_LIBS} knotifyplugin)  
+target_link_libraries( knotifyplugin ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS})
+
+
 set_target_properties(knotify PROPERTIES OUTPUT_NAME knotify4 )
 install(TARGETS knotify ${INSTALL_TARGETS_DEFAULT_ARGS} )
-
 ########### install files ###############
 
 install( FILES kde.notifyrc  DESTINATION  ${DATA_INSTALL_DIR}/kde )
 install( FILES hardwarenotifications.notifyrc DESTINATION \
${DATA_INSTALL_DIR}/hardwarenotifications )  install( FILES knotify4.desktop  \
DESTINATION  ${SERVICES_INSTALL_DIR} )  
+install( FILES knotifynotifymethod.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} )
+install( TARGETS knotifyplugin ${INSTALL_TARGETS_DEFAULT_ARGS} )
+install( FILES ${knotifyplugin_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR} )
+
 ########### D-Bus Autostart Services #########
 
 
@@ -48,7 +65,3 @@
 	  ${CMAKE_CURRENT_BINARY_DIR}/org.kde.knotify.service)
 
 install( FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.knotify.service DESTINATION \
                ${DBUS_SERVICES_INSTALL_DIR} )
-
-
-
-
--- trunk/KDE/kdebase/runtime/knotify/knotify.cpp #1195099:1195100
@@ -26,6 +26,7 @@
 #include <kdebug.h>
 #include <kglobal.h>
 #include <klocale.h>
+#include <kservicetypetrader.h>
 
 #include <config-runtime.h>
 
@@ -70,7 +71,25 @@
 	addPlugin(new NotifyByTaskbar(this));
 #endif
 	addPlugin(new NotifyByKTTS(this));
+
+	KService::List offers = KServiceTypeTrader::self()->query("KNotify/NotifyMethod");
+
+	QVariantList args;
+	QString error;
+	
+	foreach (const KService::Ptr service, offers)
+	{
+		KNotifyPlugin *plugin = service->createInstance<KNotifyPlugin>(this, args, \
&error); +		if (plugin)
+		{
+			addPlugin(plugin);
 }
+		else
+		{
+			kDebug() << "Could not load plugin" << service->name() << "due to:" << error;
+		}
+	}
+}
 
 void KNotify::addPlugin( KNotifyPlugin * p )
 {
--- trunk/KDE/kdebase/runtime/knotify/knotifyconfig.h #1195099:1195100
@@ -32,7 +32,7 @@
 /**
  * An image with lazy loading from the byte array
  */
-class KNotifyImage
+class KDE_EXPORT KNotifyImage
 {
 	public:
 		KNotifyImage() : dirty(false) {}
@@ -55,7 +55,7 @@
  * Represent the configuration for an event
  * @author Olivier Goffart <ogoffart@kde.org>
 */
-class KNotifyConfig
+class KDE_EXPORT KNotifyConfig
 {
 	public:
 		KNotifyConfig(const QString &appname, const ContextList &_contexts , const QString \
                &_eventid);
--- trunk/KDE/kdebase/runtime/knotify/knotifyplugin.cpp #1195099:1195100
@@ -18,10 +18,13 @@
 
  */
 
+#include <KPluginFactory>
 
 #include "knotifyplugin.h"
 
-KNotifyPlugin::KNotifyPlugin(QObject *parent) : QObject(parent)
+KNotifyPlugin::KNotifyPlugin(QObject *parent, const QVariantList &args)
+    : QObject(parent),
+      d(0)
 {
 }
 
@@ -30,5 +33,20 @@
 {
 }
 
+
+void KNotifyPlugin::update(int id, KNotifyConfig * config)
+{
+}
+
+void KNotifyPlugin::close(int id)
+{
+	emit finished(id);
+}
+
+void KNotifyPlugin::finish(int id)
+{
+	emit finished(id);
+}
+
 #include "knotifyplugin.moc"
 
--- trunk/KDE/kdebase/runtime/knotify/knotifyplugin.h #1195099:1195100
@@ -24,7 +24,9 @@
 #define KNOTIFYPLUGIN_H
 
 #include <QtCore/QObject>
+#include <KPluginFactory>
 
+class KNotifyPluginPrivate;
 class KNotifyConfig;
 
 
@@ -35,22 +37,19 @@
  * 
  * You should reimplement the KNotifyPlugin::notify method to display the \
                notification.
  *
- * Dynamic plugin support is not yet implemented in KNotify.
- * In order to load your plugin you need to add a line to KNotify::loadConfig() in \
                knotify.cpp
- *
  * @author Olivier Goffart <ogoffart at kde.org>
 */
-class KNotifyPlugin : public QObject
+class KDE_EXPORT KNotifyPlugin : public QObject
 { Q_OBJECT
 	public:
-		KNotifyPlugin(QObject *parent=0l);
+	        KNotifyPlugin(QObject *parent=0l, const QVariantList &args=QVariantList());
 		virtual ~KNotifyPlugin();
 
 		/**
 		 * @brief return the name of this plugin.
 		 *
-		 * this is the name that should appears in the .knotifyrc file, 
-		 * in the field Action=... if a notification
+		 * this is the name that should appear in the .knotifyrc file,
+		 * in the field Action=... if a notification is set to use this plugin
 		 */
 		virtual QString optionName() =0;
 		/**
@@ -68,12 +67,12 @@
 		/**
 		 * This function is called when the notification has changed (such as the text or \
                the icon)
 		 */
-		virtual void update(int /*id*/, KNotifyConfig * /*config*/) {}
+		virtual void update(int id, KNotifyConfig *config);
 		
 		/**
 		 * This function is called when the notification has been closed
 		 */
-		virtual void close(int id) { emit finished(id);}
+		virtual void close(int id);
 	
 	protected:
 		/**
@@ -82,9 +81,9 @@
 		 *
 		 * call it when the presentation is finished (because the user closed the popup or \
                the sound is finished)
 		 * 
-		 * If your presentation is syncronious, you can even call this function from the \
notify() call itself +		 * If your presentation is syncronous, you can even call this \
                function from the notify() call itself
 		 */
-		void finish(int id) { emit finished(id); }
+		void finish(int id);
 	
 	Q_SIGNALS:
 		/**
@@ -97,6 +96,14 @@
 		 * @param action is the action number.  zero for the default action
 		 */
 		void actionInvoked(int id , int action);
+
+	private:
+		KNotifyPluginPrivate *const d;
+
 };
 
+#define K_EXPORT_KNOTIFY_METHOD(libname,classname) \
+K_PLUGIN_FACTORY(KNotifyMethodPluginFactory, registerPlugin<classname>();) \
+K_EXPORT_PLUGIN(KNotifyMethodPluginFactory("knotify_method_" #libname))
+
 #endif
--- trunk/KDE/kdebase/runtime/knotify/notifybyexecute.cpp #1195099:1195100
@@ -22,9 +22,8 @@
 
 #include <QHash>
 #include <KProcess>
+#include <knotifyconfig.h>
 
-#include "knotifyconfig.h"
-
 #include <kdebug.h>
 #include <kmacroexpander.h>
 
--- trunk/KDE/kdebase/runtime/knotify/notifybyktts.cpp #1195099:1195100
@@ -25,7 +25,7 @@
 #include <kmessagebox.h>
 #include <kmacroexpander.h>
 #include <klocale.h>
-#include "knotifyconfig.h"
+#include <knotifyconfig.h>
 
 NotifyByKTTS::NotifyByKTTS(QObject *parent) : KNotifyPlugin(parent),m_kspeech(0), \
tryToStartKttsd( false )  {
--- trunk/KDE/kdebase/runtime/knotify/notifybylogfile.cpp #1195099:1195100
@@ -20,9 +20,9 @@
 
 
 #include "notifybylogfile.h"
-#include "knotifyconfig.h"
 
 #include <kdebug.h>
+#include <knotifyconfig.h>
 #include <KUrl>
 #include <QDateTime>
 #include <QFile>
--- trunk/KDE/kdebase/runtime/knotify/notifybypopup.cpp #1195099:1195100
@@ -19,7 +19,6 @@
  */
 
 #include "notifybypopup.h"
-#include "knotifyconfig.h"
 #include "imageconverter.h"
 #include "notifybypopupgrowl.h"
 
@@ -30,6 +29,7 @@
 #include <khbox.h>
 #include <kvbox.h>
 #include <kcharsets.h>
+#include <knotifyconfig.h>
 
 #include <QBuffer>
 #include <QImage>
--- trunk/KDE/kdebase/runtime/knotify/notifybysound.cpp #1195099:1195100
@@ -25,9 +25,7 @@
 
 
 #include "notifybysound.h"
-#include "knotifyconfig.h"
 
-
 // QT headers
 #include <QHash>
 #include <QtCore/QBasicTimer>
@@ -46,6 +44,7 @@
 #include <kurl.h>
 #include <config-runtime.h>
 #include <kcomponentdata.h>
+#include <knotifyconfig.h>
 
 // Phonon headers
 #include <phonon/mediaobject.h>
--- trunk/KDE/kdebase/runtime/knotify/notifybytaskbar.cpp #1195099:1195100
@@ -20,10 +20,10 @@
 
 
 #include "notifybytaskbar.h"
-#include "knotifyconfig.h"
 
 #include <kdebug.h>
 #include <kwindowsystem.h>
+#include <knotifyconfig.h>
 
 NotifyByTaskbar::NotifyByTaskbar(QObject *parent) : KNotifyPlugin(parent)
 {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic