From 2de4aeb0272fa7d96a55332196a11e52b2f27539 Mon Sep 17 00:00:00 2001 From: ulf69 Date: Wed, 30 Jun 2004 21:59:48 +0000 Subject: preparations for dynamic import/export module loading --- (limited to 'kaddressbook/xxportmanager.cpp') diff --git a/kaddressbook/xxportmanager.cpp b/kaddressbook/xxportmanager.cpp index 6cfa9cb..20cde49 100644 --- a/kaddressbook/xxportmanager.cpp +++ b/kaddressbook/xxportmanager.cpp @@ -29,6 +29,7 @@ $Id$ */ #include +#include #include #include @@ -40,9 +41,12 @@ $Id$ #ifndef KAB_EMBEDDED #include #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 @@ -172,7 +176,7 @@ void XXPortManager::loadPlugins() for ( it = plugins.begin(); it != plugins.end(); ++it ) { if ( !(*it)->hasServiceType( "KAddressBook/XXPort" ) ) continue; - + KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); if ( !factory ) { kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl; @@ -185,6 +189,25 @@ void XXPortManager::loadPlugins() kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl; continue; } + +#else //KAB_EMBEDDED + QList factorylist; + factorylist.append(static_cast(init_kaddrbk_csv_xxport())); + factorylist.append(static_cast(init_kaddrbk_kde2_xxport())); + factorylist.append(static_cast(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( factory ); + factorylist.append(xxportFactory); + } + + QListIterator it(factorylist); + for ( ; it.current(); ++it ) + { + XXPortFactory *xxportFactory = it.current(); +#endif //KAB_EMBEDDED XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); if ( obj ) { @@ -197,53 +220,6 @@ void XXPortManager::loadPlugins() } } -#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& ) ) ); - } - - - - // KDE2 import/export - xxportFactory = new KDE2XXPortFactory(); - - 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 - } -- cgit v0.9.0.2