author | ulf69 <ulf69> | 2004-06-30 21:59:48 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-06-30 21:59:48 (UTC) |
commit | 2de4aeb0272fa7d96a55332196a11e52b2f27539 (patch) (unidiff) | |
tree | d455673832ac53a085cd3f280f60c11d12d45f83 | |
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 | 78 | ||||
-rw-r--r-- | kaddressbook/xxportobject.h | 20 |
2 files changed, 27 insertions, 71 deletions
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$ | |||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | #include <qlist.h> | ||
32 | 33 | ||
33 | #include <kabc/addressbook.h> | 34 | #include <kabc/addressbook.h> |
34 | #include <kabc/resource.h> | 35 | #include <kabc/resource.h> |
@@ -40,9 +41,12 @@ $Id$ | |||
40 | #ifndef KAB_EMBEDDED | 41 | #ifndef KAB_EMBEDDED |
41 | #include <ktrader.h> | 42 | #include <ktrader.h> |
42 | #else //KAB_EMBEDDED | 43 | #else //KAB_EMBEDDED |
43 | #include "xxport/csv_xxport.h" | 44 | extern "C" |
44 | #include "xxport/kde2_xxport.h" | 45 | { |
45 | #include "xxport/vcard_xxport.h" | 46 | void* init_kaddrbk_csv_xxport(); |
47 | void* init_kaddrbk_kde2_xxport(); | ||
48 | void* init_kaddrbk_vcard_xxport(); | ||
49 | } | ||
46 | #endif //KAB_EMBEDDED | 50 | #endif //KAB_EMBEDDED |
47 | 51 | ||
48 | #include <libkdepim/addresseeview.h> | 52 | #include <libkdepim/addresseeview.h> |
@@ -172,7 +176,7 @@ void XXPortManager::loadPlugins() | |||
172 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 176 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
173 | if ( !(*it)->hasServiceType( "KAddressBook/XXPort" ) ) | 177 | if ( !(*it)->hasServiceType( "KAddressBook/XXPort" ) ) |
174 | continue; | 178 | continue; |
175 | 179 | ||
176 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); | 180 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); |
177 | if ( !factory ) { | 181 | if ( !factory ) { |
178 | kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl; | 182 | kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl; |
@@ -185,6 +189,25 @@ void XXPortManager::loadPlugins() | |||
185 | kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl; | 189 | kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl; |
186 | continue; | 190 | continue; |
187 | } | 191 | } |
192 | |||
193 | #else //KAB_EMBEDDED | ||
194 | QList<XXPortFactory> factorylist; | ||
195 | factorylist.append(static_cast<XXPortFactory*>(init_kaddrbk_csv_xxport())); | ||
196 | factorylist.append(static_cast<XXPortFactory*>(init_kaddrbk_kde2_xxport())); | ||
197 | factorylist.append(static_cast<XXPortFactory*>(init_kaddrbk_vcard_xxport())); | ||
198 | |||
199 | //now add the opie import library dynamically | ||
200 | KLibFactory *factory = KLibLoader::self()->factory( "kaddrbk_opie_xxport" ); | ||
201 | if ( factory ) { | ||
202 | XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory ); | ||
203 | factorylist.append(xxportFactory); | ||
204 | } | ||
205 | |||
206 | QListIterator<XXPortFactory> it(factorylist); | ||
207 | for ( ; it.current(); ++it ) | ||
208 | { | ||
209 | XXPortFactory *xxportFactory = it.current(); | ||
210 | #endif //KAB_EMBEDDED | ||
188 | 211 | ||
189 | XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); | 212 | XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); |
190 | if ( obj ) { | 213 | if ( obj ) { |
@@ -197,53 +220,6 @@ void XXPortManager::loadPlugins() | |||
197 | } | 220 | } |
198 | } | 221 | } |
199 | 222 | ||
200 | #else //KAB_EMBEDDED | ||
201 | //lets load the export/import stubs directly. Is dynamic loading necessary for KA/Pi? | ||
202 | |||
203 | // CVS import/export | ||
204 | XXPortFactory *xxportFactory = new CSVXXPortFactory(); | ||
205 | |||
206 | XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); | ||
207 | if ( obj ) { | ||
208 | mCore->addGUIClient( obj ); | ||
209 | mXXPortObjects.insert( obj->identifier(), obj ); | ||
210 | connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ), | ||
211 | this, SLOT( slotExport( const QString&, const QString& ) ) ); | ||
212 | connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ), | ||
213 | this, SLOT( slotImport( const QString&, const QString& ) ) ); | ||
214 | } | ||
215 | |||
216 | |||
217 | |||
218 | // KDE2 import/export | ||
219 | xxportFactory = new KDE2XXPortFactory(); | ||
220 | |||
221 | obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); | ||
222 | if ( obj ) { | ||
223 | mCore->addGUIClient( obj ); | ||
224 | mXXPortObjects.insert( obj->identifier(), obj ); | ||
225 | connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ), | ||
226 | this, SLOT( slotExport( const QString&, const QString& ) ) ); | ||
227 | connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ), | ||
228 | this, SLOT( slotImport( const QString&, const QString& ) ) ); | ||
229 | } | ||
230 | |||
231 | |||
232 | |||
233 | // VCARD import/export | ||
234 | xxportFactory = new VCardXXPortFactory(); | ||
235 | |||
236 | obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); | ||
237 | if ( obj ) { | ||
238 | mCore->addGUIClient( obj ); | ||
239 | mXXPortObjects.insert( obj->identifier(), obj ); | ||
240 | connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ), | ||
241 | this, SLOT( slotExport( const QString&, const QString& ) ) ); | ||
242 | connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ), | ||
243 | this, SLOT( slotImport( const QString&, const QString& ) ) ); | ||
244 | } | ||
245 | #endif //KAB_EMBEDDED | ||
246 | |||
247 | } | 223 | } |
248 | 224 | ||
249 | 225 | ||
diff --git a/kaddressbook/xxportobject.h b/kaddressbook/xxportobject.h index d697700..fddc219 100644 --- a/kaddressbook/xxportobject.h +++ b/kaddressbook/xxportobject.h | |||
@@ -36,9 +36,7 @@ $Id$ | |||
36 | #include <kabc/addressbook.h> | 36 | #include <kabc/addressbook.h> |
37 | #include <kabc/addresseelist.h> | 37 | #include <kabc/addresseelist.h> |
38 | #include <kxmlguiclient.h> | 38 | #include <kxmlguiclient.h> |
39 | #ifndef KAB_EMBEDDED | ||
40 | #include <klibloader.h> | 39 | #include <klibloader.h> |
41 | #endif //KAB_EMBEDDED | ||
42 | 40 | ||
43 | 41 | ||
44 | class XXPortObject : public QObject, virtual public KXMLGUIClient | 42 | class XXPortObject : public QObject, virtual public KXMLGUIClient |
@@ -122,7 +120,6 @@ class XXPortObject : public QObject, virtual public KXMLGUIClient | |||
122 | XXPortObjectPrivate *d; | 120 | XXPortObjectPrivate *d; |
123 | }; | 121 | }; |
124 | 122 | ||
125 | #ifndef KAB_EMBEDDED | ||
126 | class XXPortFactory : public KLibFactory | 123 | class XXPortFactory : public KLibFactory |
127 | { | 124 | { |
128 | public: | 125 | public: |
@@ -137,21 +134,4 @@ class XXPortFactory : public KLibFactory | |||
137 | } | 134 | } |
138 | }; | 135 | }; |
139 | 136 | ||
140 | #else //KAB_EMBEDDED | ||
141 | class XXPortFactory | ||
142 | { | ||
143 | public: | ||
144 | virtual XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, | ||
145 | const char *name = 0 ) = 0; | ||
146 | |||
147 | protected: | ||
148 | virtual QObject* createObject( QObject*, const char*, const char*, | ||
149 | const QStringList & ) | ||
150 | { | ||
151 | return 0; | ||
152 | } | ||
153 | }; | ||
154 | #endif //KAB_EMBEDDED | ||
155 | |||
156 | |||
157 | #endif | 137 | #endif |