summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/xxportmanager.cpp70
-rw-r--r--kaddressbook/xxportobject.h20
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
@@ -20,38 +20,42 @@
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$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>
35#include <kdebug.h> 36#include <kdebug.h>
36#include <kdialogbase.h> 37#include <kdialogbase.h>
37#include <klocale.h> 38#include <klocale.h>
38#include <kmessagebox.h> 39#include <kmessagebox.h>
39 40
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" 44extern "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>
49 53
50#include "kabcore.h" 54#include "kabcore.h"
51#include "undocmds.h" 55#include "undocmds.h"
52#include "xxportselectdialog.h" 56#include "xxportselectdialog.h"
53 57
54#include "xxportmanager.h" 58#include "xxportmanager.h"
55 59
56KURL XXPortManager::importURL = KURL(); 60KURL XXPortManager::importURL = KURL();
57QString XXPortManager::importData = QString::null; 61QString XXPortManager::importData = QString::null;
@@ -177,81 +181,53 @@ void XXPortManager::loadPlugins()
177 if ( !factory ) { 181 if ( !factory ) {
178 kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl; 182 kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl;
179 continue; 183 continue;
180 } 184 }
181 185
182 XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory ); 186 XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory );
183 187
184 if ( !xxportFactory ) { 188 if ( !xxportFactory ) {
185 kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl; 189 kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl;
186 continue; 190 continue;
187 } 191 }
188 192
189 XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore );
190 if ( obj ) {
191 mCore->addGUIClient( obj );
192 mXXPortObjects.insert( obj->identifier(), obj );
193 connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ),
194 this, SLOT( slotExport( const QString&, const QString& ) ) );
195 connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ),
196 this, SLOT( slotImport( const QString&, const QString& ) ) );
197 }
198 }
199
200#else //KAB_EMBEDDED 193#else //KAB_EMBEDDED
201//lets load the export/import stubs directly. Is dynamic loading necessary for KA/Pi? 194 QList<XXPortFactory> factorylist;
202 195 factorylist.append(static_cast<XXPortFactory*>(init_kaddrbk_csv_xxport()));
203 // CVS import/export 196 factorylist.append(static_cast<XXPortFactory*>(init_kaddrbk_kde2_xxport()));
204 XXPortFactory *xxportFactory = new CSVXXPortFactory(); 197 factorylist.append(static_cast<XXPortFactory*>(init_kaddrbk_vcard_xxport()));
205 198
206 XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); 199 //now add the opie import library dynamically
207 if ( obj ) { 200 KLibFactory *factory = KLibLoader::self()->factory( "kaddrbk_opie_xxport" );
208 mCore->addGUIClient( obj ); 201 if ( factory ) {
209 mXXPortObjects.insert( obj->identifier(), obj ); 202 XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory );
210 connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ), 203 factorylist.append(xxportFactory);
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 } 204 }
215 205
206 QListIterator<XXPortFactory> it(factorylist);
207 for ( ; it.current(); ++it )
208 {
209 XXPortFactory *xxportFactory = it.current();
210#endif //KAB_EMBEDDED
216 211
217 212 XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore );
218 // KDE2 import/export
219 xxportFactory = new KDE2XXPortFactory();
220
221 obj = xxportFactory->xxportObject( mCore->addressBook(), mCore );
222 if ( obj ) { 213 if ( obj ) {
223 mCore->addGUIClient( obj ); 214 mCore->addGUIClient( obj );
224 mXXPortObjects.insert( obj->identifier(), obj ); 215 mXXPortObjects.insert( obj->identifier(), obj );
225 connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ), 216 connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ),
226 this, SLOT( slotExport( const QString&, const QString& ) ) ); 217 this, SLOT( slotExport( const QString&, const QString& ) ) );
227 connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ), 218 connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ),
228 this, SLOT( slotImport( const QString&, const QString& ) ) ); 219 this, SLOT( slotImport( const QString&, const QString& ) ) );
229 } 220 }
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 } 221 }
245#endif //KAB_EMBEDDED
246 222
247} 223}
248 224
249 225
250PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent, 226PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent,
251 const char *name ) 227 const char *name )
252 : KDialogBase( Plain, i18n( "Contact Preview" ), Ok | Cancel, Ok, parent, 228 : KDialogBase( Plain, i18n( "Contact Preview" ), Ok | Cancel, Ok, parent,
253 name, true, true ) 229 name, true, true )
254{ 230{
255 QWidget *page = plainPage(); 231 QWidget *page = plainPage();
256 QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() ); 232 QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() );
257 233
diff --git a/kaddressbook/xxportobject.h b/kaddressbook/xxportobject.h
index d697700..fddc219 100644
--- a/kaddressbook/xxportobject.h
+++ b/kaddressbook/xxportobject.h
@@ -27,27 +27,25 @@ Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#ifndef XXPORTOBJECT_H 31#ifndef XXPORTOBJECT_H
32#define XXPORTOBJECT_H 32#define XXPORTOBJECT_H
33 33
34#include <qobject.h> 34#include <qobject.h>
35 35
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
44class XXPortObject : public QObject, virtual public KXMLGUIClient 42class XXPortObject : public QObject, virtual public KXMLGUIClient
45{ 43{
46 Q_OBJECT 44 Q_OBJECT
47 45
48 public: 46 public:
49 XXPortObject( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 ); 47 XXPortObject( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 );
50 ~XXPortObject(); 48 ~XXPortObject();
51 49
52 /** 50 /**
53 Returns the unique identifier of this xxport modul, it should 51 Returns the unique identifier of this xxport modul, it should
@@ -113,45 +111,27 @@ class XXPortObject : public QObject, virtual public KXMLGUIClient
113 private slots: 111 private slots:
114 void slotImportActivated( const QString& ); 112 void slotImportActivated( const QString& );
115 void slotExportActivated( const QString& ); 113 void slotExportActivated( const QString& );
116 114
117 private: 115 private:
118 KABC::AddressBook *mAddressBook; 116 KABC::AddressBook *mAddressBook;
119 QWidget *mParentWidget; 117 QWidget *mParentWidget;
120 118
121 class XXPortObjectPrivate; 119 class XXPortObjectPrivate;
122 XXPortObjectPrivate *d; 120 XXPortObjectPrivate *d;
123}; 121};
124 122
125#ifndef KAB_EMBEDDED
126class XXPortFactory : public KLibFactory 123class XXPortFactory : public KLibFactory
127{ 124{
128 public: 125 public:
129 virtual XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, 126 virtual XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent,
130 const char *name = 0 ) = 0; 127 const char *name = 0 ) = 0;
131 128
132 protected: 129 protected:
133 virtual QObject* createObject( QObject*, const char*, const char*, 130 virtual QObject* createObject( QObject*, const char*, const char*,
134 const QStringList & ) 131 const QStringList & )
135 { 132 {
136 return 0; 133 return 0;
137 } 134 }
138}; 135};
139 136
140#else //KAB_EMBEDDED
141class 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