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

List:       kde-commits
Subject:    KDE/kdepim/kpilot
From:       Adriaan de Groot <groot () kde ! org>
Date:       2007-05-09 14:34:10
Message-ID: 1178721250.420328.25160.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 662900 by adridg:

Bump the plugin API number for KDE4, handle plugin factory boilerplate through a \
macro, remove misleading documentation

 M  +1 -10     conduits/abbrowserconduit/abbrowser-factory.cc  
 M  +1 -6      conduits/docconduit/doc-factory.cc  
 M  +2 -14     conduits/malconduit/mal-factory.cc  
 M  +1 -11     conduits/memofileconduit/memofile-factory.cc  
 M  +3 -8      conduits/notepadconduit/notepad-factory.cc  
 M  +1 -11     conduits/null/null-factory.cc  
 M  +2 -8      conduits/popmail/popmail-factory.cc  
 M  +3 -9      conduits/sysinfoconduit/sysinfo-factory.cc  
 M  +1 -10     conduits/timeconduit/time-factory.cc  
 M  +1 -7      conduits/vcalconduit/todo-factory.cc  
 M  +1 -10     conduits/vcalconduit/vcal-factory.cc  
 M  +12 -3     kpilot/config_dialog.cc  
 M  +7 -1      lib/plugin.cc  
 M  +6 -67     lib/plugin.h  
 M  +6 -0      lib/pluginfactory.h  


--- trunk/KDE/kdepim/kpilot/conduits/abbrowserconduit/abbrowser-factory.cc \
#662899:662900 @@ -34,13 +34,4 @@
 #include "abbrowser-conduit.h"
 #include "abbrowser-setup.h"
 
-extern "C"
-{
-KPILOT_EXPORT unsigned long version_conduit_address = Pilot::PLUGIN_API;
-
-KPILOT_EXPORT void *init_libconduit_address()
-{
-	return new ConduitFactory<AbbrowserWidgetSetup,AbbrowserConduit>(0,"abbrowserconduit");
                
-}
-
-}
+DECLARE_KPILOT_PLUGIN(conduit_address,AbbrowserWidgetSetup,AbbrowserConduit)
--- trunk/KDE/kdepim/kpilot/conduits/docconduit/doc-factory.cc #662899:662900
@@ -34,13 +34,8 @@
 #include "doc-setup.h"
 
 
-extern "C" {
-KPILOT_EXPORT unsigned long version_conduit_doc = Pilot::PLUGIN_API;
+DECLARE_KPILOT_PLUGIN(conduit_doc,DOCWidgetConfig,DOCConduit)
 
-KPILOT_EXPORT void *init_libconduit_doc() {
-	return new ConduitFactory<DOCWidgetConfig,DOCConduit>(0,"docconduit");
-}
-}
 
 
 
--- trunk/KDE/kdepim/kpilot/conduits/malconduit/mal-factory.cc #662899:662900
@@ -1,4 +1,4 @@
-/* Time-factory.cc                      KPilot
+/* KPilot
 **
 ** Copyright (C) 2002 by Reinhold Kainhofer
 **
@@ -31,24 +31,12 @@
 */
 
 #include "options.h"
-#include "plugin.h"
 #include "pluginfactory.h"
 
 #include "mal-conduit.h"
 #include "mal-setup.h"
 
+DECLARE_KPILOT_PLUGIN(conduit_mal,MALWidgetSetup,MALConduit)
 
 
-extern "C"
-{
 
-void *init_conduit_mal()
-{
-	return new ConduitFactory<MALWidgetSetup,MALConduit>(0);
-}
-
-unsigned long version_conduit_mal = Pilot::PLUGIN_API;
-
-}
-
-
--- trunk/KDE/kdepim/kpilot/conduits/memofileconduit/memofile-factory.cc \
#662899:662900 @@ -112,16 +112,6 @@
 	unmodified();
 }
 
+DECLARE_KPILOT_PLUGIN(conduit_memofile,MemofileConduitConfig,MemofileConduit)
 
 
-extern "C"
-{
-KPILOT_EXPORT unsigned long version_conduit_memofile = Pilot::PLUGIN_API;
-
-KPILOT_EXPORT void *init_libconduit_memofile()
-{
-	return new ConduitFactory<MemofileConduitConfig,MemofileConduit>(0,"memofileconduit");
                
-}
-
-}
-
--- trunk/KDE/kdepim/kpilot/conduits/notepadconduit/notepad-factory.cc #662899:662900
@@ -112,14 +112,9 @@
 	fModified=false;
 }
 
-extern "C"
-{
-KPILOT_EXPORT unsigned long version_conduit_notepad = Pilot::PLUGIN_API;
 
-KPILOT_EXPORT void *init_libconduit_notepad()
-{
-	return new ConduitFactory<NotepadConduitConfig,NotepadConduit>(0);
-}
 
-}
 
+DECLARE_KPILOT_PLUGIN(conduit_notepad,NotepadConduitConfig,NotepadConduit)
+
+
--- trunk/KDE/kdepim/kpilot/conduits/null/null-factory.cc #662899:662900
@@ -109,15 +109,5 @@
 }
 
 
+DECLARE_KPILOT_PLUGIN(conduit_null,NullConduitConfig,NullConduit)
 
-extern "C"
-{
-
-KPILOT_EXPORT unsigned long version_conduit_null = Pilot::PLUGIN_API;
-KPILOT_EXPORT void *init_libconduit_null()
-{
-	return new ConduitFactory<NullConduitConfig,NullConduit>(0,"nullconduit");
-}
-
-}
-
--- trunk/KDE/kdepim/kpilot/conduits/popmail/popmail-factory.cc #662899:662900
@@ -35,14 +35,8 @@
 #include "pluginfactory.h"
 
 
-extern "C"
-{
-KPILOT_EXPORT unsigned long version_conduit_popmail = Pilot::PLUGIN_API;
 
-KPILOT_EXPORT void *init_libconduit_popmail()
-{
-	return new ConduitFactory<PopMailWidgetConfig,PopMailConduit>;
-}
 
-}
+DECLARE_KPILOT_PLUGIN(conduit_popmail,PopMailWidgetConfig,PopMailConduit)
 
+
--- trunk/KDE/kdepim/kpilot/conduits/sysinfoconduit/sysinfo-factory.cc #662899:662900
@@ -1,4 +1,4 @@
-/* SysInfo-factory.cc                      KPilot
+/* KPilot
 **
 ** Copyright (C) 2003 by Reinhold Kainhofer
 **
@@ -32,13 +32,7 @@
 #include "sysinfo-conduit.h"
 #include "sysinfo-setup.h"
 
-extern "C"
-{
-KPILOT_EXPORT unsigned long version_conduit_sysinfo = Pilot::PLUGIN_API;
 
-KPILOT_EXPORT void *init_libconduit_sysinfo()
-{
-	return new ConduitFactory<SysInfoWidgetConfig,SysInfoConduit>;
-}
 
-}
+DECLARE_KPILOT_PLUGIN(conduit_sysinfo,SysInfoWidgetConfig,SysInfoConduit)
+
--- trunk/KDE/kdepim/kpilot/conduits/timeconduit/time-factory.cc #662899:662900
@@ -32,16 +32,7 @@
 #include "time-conduit.h"
 #include "time-setup.h"
 
+DECLARE_KPILOT_PLUGIN(conduit_time,TimeWidgetConfig,TimeConduit)
 
-extern "C"
-{
-KPILOT_EXPORT unsigned long version_conduit_time = Pilot::PLUGIN_API ;
 
-KPILOT_EXPORT void *init_libconduit_time()
-{
-	return new ConduitFactory<TimeWidgetConfig,TimeConduit>(0,"Timeconduit");
-}
 
-}
-
-
--- trunk/KDE/kdepim/kpilot/conduits/vcalconduit/todo-factory.cc #662899:662900
@@ -34,13 +34,7 @@
 #include "todo-setup.h"
 #include "todo-conduit.h"
 
-extern "C"
-{
 
-void *init_conduit_todo()
-{
-	return new ConduitFactory<ToDoWidgetSetup,TodoConduit>;
-}
+DECLARE_KPILOT_PLUGIN(conduit_todo,ToDoWidgetSetup,TodoConduit)
 
-}
 
--- trunk/KDE/kdepim/kpilot/conduits/vcalconduit/vcal-factory.cc #662899:662900
@@ -29,22 +29,13 @@
 
 #include "options.h"
 
-#include <kaboutdata.h>
-
 #include "pluginfactory.h"
 
 #include "vcal-setup.h"
 #include "vcal-conduit.h"
 
-extern "C"
-{
 
-void *init_conduit_vcal()
-{
-	return new ConduitFactory<VCalWidgetSetup,VCalConduit>;
-}
 
-}
+DECLARE_KPILOT_PLUGIN(conduit_vcal,VCalWidgetSetup,VCalConduit)
 
 
-
--- trunk/KDE/kdepim/kpilot/kpilot/config_dialog.cc #662899:662900
@@ -87,7 +87,7 @@
 #define CONDUIT_EXPLN    (2)
 #define GENERAL_EXPLN    (3)
 #define GENERAL_ABOUT    (4)
-#define NEW_CONDUIT    (5)
+#define NEW_CONDUIT      (5)
 
 /*
 ** Create a page in the widget stack @p parent on page @p pageno,
@@ -470,7 +470,7 @@
 		KLibFactory *f = KLibLoader::self()->factory(library);
 		if (!f)
 		{
-			DEBUGKPILOT << fname
+			WARNINGKPILOT << fname
 				<< ": No conduit library "
 				<< libraryName
 				<< " found."
@@ -480,7 +480,16 @@
 			return;
 		}
 
-		dumpConduitInfo(KLibLoader::self()->library(library));
+		KLibrary *lib = KLibLoader::self()->library(library);
+		dumpConduitInfo(lib);
+		if ( Pilot::PLUGIN_API > PluginUtility::pluginVersion(lib) )
+		{
+			WARNINGKPILOT << fname
+				<< ": Old conduit library found." << endl;
+			fStack->setCurrentIndex(BROKEN_CONDUIT);
+			warnNoLibrary(p);
+			return;
+		}
 
 		QStringList a;
 		a.append(CSL1("modal"));
--- trunk/KDE/kdepim/kpilot/lib/plugin.cc #662899:662900
@@ -685,11 +685,17 @@
 
 /* static */ unsigned long pluginVersion(const KLibrary *lib)
 {
+	FUNCTIONSETUP;
 	QString symbol = CSL1("version_");
 	symbol.append(lib->name());
 
-	if (!lib->resolveSymbol(symbol.toLatin1())) return 0;
+	DEBUGKPILOT << fname << ": Symbol <" << symbol << '>' << endl;
 
+	if (!lib->resolveSymbol(symbol.toLatin1()))
+	{
+		return 0;
+	}
+
 	unsigned long *p = (unsigned long *)(lib->resolveSymbol(symbol.toLatin1()));
 	return *p;
 }
--- trunk/KDE/kdepim/kpilot/lib/plugin.h #662899:662900
@@ -56,7 +56,7 @@
 	* Bump this number every release to the current YYYYMMDD
 	* value.
 	*/
-	static const unsigned int PLUGIN_API = 20070508;
+	static const unsigned int PLUGIN_API = 20071023;
 }
 
 /**
@@ -386,8 +386,11 @@
 /** A namespace containing only static helper methods. */
 namespace PluginUtility
 {
-	/** Searches the argument list for --foo=bar and returns bar, QString::null if not \
                found.
-	* Don't include the -- in the argname. */
+	/** 
+	 * Searches the argument list for --foo=bar and returns bar, 
+	 * QString::null if not found.
+	 * Don't include the -- in the argname.
+	 */
 	KPILOT_EXPORT QString findArgument(const QStringList &a, const QString argname);
 
 	/**
@@ -397,68 +400,4 @@
 	KPILOT_EXPORT unsigned long pluginVersion(const KLibrary *);
 }
 
-/**
-* All KPilot conduits should subclass KLibFactory like this.
-*
-* Boilerplate for inheritance:
-*
-* <pre>
-* class KPilotPlugin : public KLibFactory
-* {
-* Q_OBJECT
-*
-* public:
-* 	KPilotPlugin(QObject * = 0L,const char * = 0L) ;
-* 	virtual ~KPilotPlugin();
-* </pre>
-*
-* You don't @em have to provide about information for the plugin,
-* but it's useful, particularly for the about box in a conduit.
-*
-*
-* <pre>
-* 	static KAboutData *about() { return fAbout; } ;
-* </pre>
-*
-*
-* This is what it's all about: creating objects for the plugin.
-* One classname that @em must be supported is ConduitConfig,
-* which is defined above. The other is SyncAction.
-*
-*
-* <pre>
-* protected:
-* 	virtual QObject* createObject( QObject* parent = 0,
-* 		const char* name = 0,
-* 		const char* classname = "QObject",
-* 		const QStringList &args = QStringList() );
-* </pre>
-*
-* More boilerplate, and support for an instance and about data, used
-* by about() above.
-*
-* <pre>
-* 	KComponentData fInstance;
-* 	static KAboutData *fAbout;
-* } ;
-* </pre>
-*
-*
-*
-* The implementation of a conduit needs an init_conduit_name() function,
-* just like any KLibLoader library that uses factories.
-*
-* The createObject() function needs to support at least two creation
-* calls: "ConduitConfigBase" and "SyncAction".
-* "ConduitConfigBase" should return a subclass of ConduitConfigBase,
-* "SyncAction" a subclass of SyncAction.
-*
-* Finally, a conduit should have a symbol version_conduit_name,
-* that returns a long; much like the init_conduit_name() function. This
-* should return the version of the plugin API (KPILOT_PLUGIN_VERSION)
-* the conduit was compiled against. Additionally, a plugin may have a
-* id_conduit_name, which should be a const char *.
-*
-*/
-
 #endif
--- trunk/KDE/kdepim/kpilot/lib/pluginfactory.h #662899:662900
@@ -94,5 +94,11 @@
 	//KComponentData fInstance;
 } ;
 
+#define DECLARE_KPILOT_PLUGIN(a,b,c) \
+	extern "C" { \
+	KPILOT_EXPORT unsigned long version_lib##a = Pilot::PLUGIN_API; \
+	KPILOT_EXPORT void *init_lib##a() \
+	{ return new ConduitFactory<b,c>(0, #a); } }
+
 #endif
 


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

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