author | ulf69 <ulf69> | 2004-06-30 21:59:48 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-06-30 21:59:48 (UTC) |
commit | 2de4aeb0272fa7d96a55332196a11e52b2f27539 (patch) (side-by-side diff) | |
tree | d455673832ac53a085cd3f280f60c11d12d45f83 /kaddressbook | |
parent | e0e3d743a6b61eaac023c9f284362ab08337da05 (diff) | |
download | kdepimpi-2de4aeb0272fa7d96a55332196a11e52b2f27539.zip kdepimpi-2de4aeb0272fa7d96a55332196a11e52b2f27539.tar.gz kdepimpi-2de4aeb0272fa7d96a55332196a11e52b2f27539.tar.bz2 |
preparations for dynamic import/export module loading
-rw-r--r-- | kaddressbook/xxportmanager.cpp | 70 | ||||
-rw-r--r-- | kaddressbook/xxportobject.h | 20 |
2 files changed, 23 insertions, 67 deletions
diff --git a/kaddressbook/xxportmanager.cpp b/kaddressbook/xxportmanager.cpp index 6cfa9cb..20cde49 100644 --- a/kaddressbook/xxportmanager.cpp +++ b/kaddressbook/xxportmanager.cpp @@ -28,8 +28,9 @@ Copyright (c) 2004 Ulf Schenk $Id$ */ #include <qlayout.h> +#include <qlist.h> #include <kabc/addressbook.h> #include <kabc/resource.h> #include <kdebug.h> @@ -39,11 +40,14 @@ $Id$ #ifndef KAB_EMBEDDED #include <ktrader.h> #else //KAB_EMBEDDED -#include "xxport/csv_xxport.h" -#include "xxport/kde2_xxport.h" -#include "xxport/vcard_xxport.h" +extern "C" +{ + void* init_kaddrbk_csv_xxport(); + void* init_kaddrbk_kde2_xxport(); + void* init_kaddrbk_vcard_xxport(); +} #endif //KAB_EMBEDDED #include <libkdepim/addresseeview.h> @@ -185,65 +189,37 @@ void XXPortManager::loadPlugins() kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl; continue; } - XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); - if ( obj ) { - mCore->addGUIClient( obj ); - mXXPortObjects.insert( obj->identifier(), obj ); - connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ), - this, SLOT( slotExport( const QString&, const QString& ) ) ); - connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ), - this, SLOT( slotImport( const QString&, const QString& ) ) ); - } - } - #else //KAB_EMBEDDED -//lets load the export/import stubs directly. Is dynamic loading necessary for KA/Pi? - - // CVS import/export - XXPortFactory *xxportFactory = new CSVXXPortFactory(); - - XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); - if ( obj ) { - mCore->addGUIClient( obj ); - mXXPortObjects.insert( obj->identifier(), obj ); - connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ), - this, SLOT( slotExport( const QString&, const QString& ) ) ); - connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ), - this, SLOT( slotImport( const QString&, const QString& ) ) ); + QList<XXPortFactory> factorylist; + factorylist.append(static_cast<XXPortFactory*>(init_kaddrbk_csv_xxport())); + factorylist.append(static_cast<XXPortFactory*>(init_kaddrbk_kde2_xxport())); + factorylist.append(static_cast<XXPortFactory*>(init_kaddrbk_vcard_xxport())); + + //now add the opie import library dynamically + KLibFactory *factory = KLibLoader::self()->factory( "kaddrbk_opie_xxport" ); + if ( factory ) { + XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory ); + factorylist.append(xxportFactory); } + QListIterator<XXPortFactory> it(factorylist); + for ( ; it.current(); ++it ) + { + XXPortFactory *xxportFactory = it.current(); +#endif //KAB_EMBEDDED - - // KDE2 import/export - xxportFactory = new KDE2XXPortFactory(); - - obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); + XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); if ( obj ) { mCore->addGUIClient( obj ); mXXPortObjects.insert( obj->identifier(), obj ); connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ), this, SLOT( slotExport( const QString&, const QString& ) ) ); connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ), this, SLOT( slotImport( const QString&, const QString& ) ) ); } - - - - // VCARD import/export - xxportFactory = new VCardXXPortFactory(); - - obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); - if ( obj ) { - mCore->addGUIClient( obj ); - mXXPortObjects.insert( obj->identifier(), obj ); - connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ), - this, SLOT( slotExport( const QString&, const QString& ) ) ); - connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ), - this, SLOT( slotImport( const QString&, const QString& ) ) ); } -#endif //KAB_EMBEDDED } diff --git a/kaddressbook/xxportobject.h b/kaddressbook/xxportobject.h index d697700..fddc219 100644 --- a/kaddressbook/xxportobject.h +++ b/kaddressbook/xxportobject.h @@ -35,11 +35,9 @@ $Id$ #include <kabc/addressbook.h> #include <kabc/addresseelist.h> #include <kxmlguiclient.h> -#ifndef KAB_EMBEDDED #include <klibloader.h> -#endif //KAB_EMBEDDED class XXPortObject : public QObject, virtual public KXMLGUIClient { @@ -121,9 +119,8 @@ class XXPortObject : public QObject, virtual public KXMLGUIClient class XXPortObjectPrivate; XXPortObjectPrivate *d; }; -#ifndef KAB_EMBEDDED class XXPortFactory : public KLibFactory { public: virtual XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, @@ -136,22 +133,5 @@ class XXPortFactory : public KLibFactory return 0; } }; -#else //KAB_EMBEDDED -class XXPortFactory -{ - public: - virtual XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, - const char *name = 0 ) = 0; - - protected: - virtual QObject* createObject( QObject*, const char*, const char*, - const QStringList & ) - { - return 0; - } -}; -#endif //KAB_EMBEDDED - - #endif |