summaryrefslogtreecommitdiffabout
Side-by-side diff
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
@@ -8,62 +8,66 @@
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#include <qlayout.h>
+#include <qlist.h>
#include <kabc/addressbook.h>
#include <kabc/resource.h>
#include <kdebug.h>
#include <kdialogbase.h>
#include <klocale.h>
#include <kmessagebox.h>
#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>
#include "kabcore.h"
#include "undocmds.h"
#include "xxportselectdialog.h"
#include "xxportmanager.h"
KURL XXPortManager::importURL = KURL();
QString XXPortManager::importData = QString::null;
class PreviewDialog : public KDialogBase
{
public:
PreviewDialog( const KABC::Addressee &addr,
QWidget *parent, const char *name = 0 );
};
XXPortManager::XXPortManager( KABCore *core, QObject *parent, const char *name )
: QObject( parent, name ), mCore( core ), mShowPreview( false )
{
loadPlugins();
@@ -165,105 +169,77 @@ void XXPortManager::slotExport( const QString &identifier, const QString &data )
void XXPortManager::loadPlugins()
{
mXXPortObjects.clear();
#ifndef KAB_EMBEDDED
KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/XXPort" );
KTrader::OfferList::ConstIterator it;
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;
continue;
}
XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory );
if ( !xxportFactory ) {
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
}
PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent,
const char *name )
: KDialogBase( Plain, i18n( "Contact Preview" ), Ok | Cancel, Ok, parent,
name, true, true )
{
QWidget *page = plainPage();
QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() );
KPIM::AddresseeView *view = new KPIM::AddresseeView( page );
view->setAddressee( addr );
layout->addWidget( view );
resize( 400, 300 );
}
#ifndef KAB_EMBEDDED
#include "xxportmanager.moc"
#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
@@ -15,51 +15,49 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#ifndef XXPORTOBJECT_H
#define XXPORTOBJECT_H
#include <qobject.h>
#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
{
Q_OBJECT
public:
XXPortObject( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 );
~XXPortObject();
/**
Returns the unique identifier of this xxport modul, it should
be the lowercase name of the import/export format e.g. 'vcard'
*/
virtual QString identifier() const = 0;
/**
Reimplement this method if the XXPortManager shall
pass a sorted list to @ref exportContacts().
*/
virtual bool requiresSorting() const { return false; }
public slots:
/**
@@ -101,57 +99,39 @@ class XXPortObject : public QObject, virtual public KXMLGUIClient
/**
Returns a pointer to the address book object.
*/
KABC::AddressBook *addressBook() const;
/**
Returns a pointer to the parent widget. It can be used as parent for
message boxes.
*/
QWidget *parentWidget() const;
private slots:
void slotImportActivated( const QString& );
void slotExportActivated( const QString& );
private:
KABC::AddressBook *mAddressBook;
QWidget *mParentWidget;
class XXPortObjectPrivate;
XXPortObjectPrivate *d;
};
-#ifndef KAB_EMBEDDED
class XXPortFactory : public KLibFactory
{
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;
}
};
-#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