-rw-r--r-- | kaddressbook/kaddressbook.pro | 8 | ||||
-rw-r--r-- | kaddressbook/kaddressbookE.pro | 8 | ||||
-rw-r--r-- | kaddressbook/xxportmanager.cpp | 15 | ||||
-rw-r--r-- | kaddressbook/xxportobject.cpp | 21 | ||||
-rw-r--r-- | kaddressbook/xxportobject.h | 33 |
5 files changed, 77 insertions, 8 deletions
diff --git a/kaddressbook/kaddressbook.pro b/kaddressbook/kaddressbook.pro index 77fce1b..0da5842 100644 --- a/kaddressbook/kaddressbook.pro +++ b/kaddressbook/kaddressbook.pro @@ -1,177 +1,183 @@ TEMPLATE = app CONFIG = qt warn_on TARGET = kapi DESTDIR= ../bin include( ../variables.pri ) -INCLUDEPATH += . ./details ./features ./kcmconfigs ./xxport ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kio/kio ../microkde/kdeui ../kabc ../ interfaces +INCLUDEPATH += . ./details ./features ./kcmconfigs ./xxport ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kio/kio ../microkde/kdeui ../microkde/kresources ../kabc ../ interfaces DEFINES += KAB_EMBEDDED KAB_NOSPLITTER DESKTOP_VERSION unix : { LIBS += ../bin/libmicrokdepim.so LIBS += ../bin/libmicrokde.so LIBS += ../bin/libmicrokabc.so LIBS += ../bin/libmicrokcal.so LIBS += -lldap OBJECTS_DIR = obj/unix MOC_DIR = moc/unix } win32: { DEFINES += _WIN32_ LIBS += ../bin/microkdepim.lib LIBS += ../bin/microkcal.lib LIBS += ../bin/microkde.lib LIBS += ../bin/microkabc.lib QMAKE_LINK += /NODEFAULTLIB:LIBC OBJECTS_DIR = obj/win MOC_DIR = moc/win LIBS += mfc71u.lib } INTERFACES = \ # filteredit_base.ui \ # kofilterview_base.ui \ HEADERS = \ features/mergewidget.h \ features/distributionlistwidget.h \ kcmconfigs/addresseewidget.h \ kcmconfigs/extensionconfigdialog.h \ kcmconfigs/kcmkabconfig.h \ kcmconfigs/kabconfigwidget.h \ addresseeeditordialog.h \ addresseeeditorwidget.h \ addresseditwidget.h \ addresseeconfig.h \ addresseeutil.h \ emaileditwidget.h \ filtereditdialog.h \ kaddressbookmain.h \ kabprefs.h \ kabcore.h \ viewmanager.h \ extensionmanager.h \ extensionwidget.h \ kaddressbookview.h \ geowidget.h \ imagewidget.h \ incsearchwidget.h \ jumpbuttonbar.h \ phoneeditwidget.h \ secrecywidget.h \ keywidget.h \ nameeditdialog.h \ filter.h \ addviewdialog.h \ configurewidget.h \ viewconfigurewidget.h \ viewconfigurefieldspage.h \ viewconfigurefilterpage.h \ typecombo.h \ undo.h \ undocmds.h \ xxportmanager.h \ xxportobject.h \ xxportselectdialog.h \ details/detailsviewcontainer.h \ details/look_basic.h \ details/look_html.h \ views/kaddressbookiconview.h \ views/kaddressbooktableview.h \ views/kaddressbookcardview.h \ views/configuretableviewdialog.h \ views/configurecardviewdialog.h \ views/cardview.h \ views/colorlistbox.h \ views/contactlistview.h \ xxport/vcard_xxport.h \ xxport/kde2_xxport.h \ xxport/csv_xxport.h \ xxport/csvimportdialog.h \ +xxport/opie_xxport.h \ +xxport/qtopia_xxport.h \ +xxport/sharpdtm_xxport.h \ #details/look_details.h \ #mainwindoiw.h \ # alarmclient.h \ # calendarview.h \ # customlistviewitem.h \ # datenavigator.h SOURCES = \ addresseeeditordialog.cpp \ addresseeeditorwidget.cpp \ addresseditwidget.cpp \ addresseeconfig.cpp \ addresseeutil.cpp \ extensionmanager.cpp \ features/mergewidget.cpp \ features/distributionlistwidget.cpp \ kcmconfigs/addresseewidget.cpp \ kcmconfigs/extensionconfigdialog.cpp \ kcmconfigs/kcmkabconfig.cpp \ kcmconfigs/kabconfigwidget.cpp \ emaileditwidget.cpp \ filtereditdialog.cpp \ mainembedded.cpp \ kaddressbookmain.cpp \ kabcore.cpp \ kabprefs.cpp \ viewmanager.cpp \ kaddressbookview.cpp \ extensionwidget.cpp \ geowidget.cpp \ imagewidget.cpp \ incsearchwidget.cpp \ jumpbuttonbar.cpp \ phoneeditwidget.cpp \ secrecywidget.cpp \ keywidget.cpp \ nameeditdialog.cpp \ filter.cpp \ addviewdialog.cpp \ configurewidget.cpp \ viewconfigurewidget.cpp \ viewconfigurefieldspage.cpp \ viewconfigurefilterpage.cpp \ undo.cpp \ undocmds.cpp \ xxportmanager.cpp \ xxportobject.cpp \ xxportselectdialog.cpp \ details/detailsviewcontainer.cpp \ details/look_basic.cpp \ details/look_html.cpp \ views/kaddressbookiconview.cpp \ views/kaddressbooktableview.cpp \ views/kaddressbookcardview.cpp \ views/configuretableviewdialog.cpp \ views/configurecardviewdialog.cpp \ views/cardview.cpp \ views/contactlistview.cpp \ views/colorlistbox.cpp \ xxport/vcard_xxport.cpp \ xxport/kde2_xxport.cpp \ xxport/csv_xxport.cpp \ xxport/csvimportdialog.cpp \ +xxport/opie_xxport.cpp \ +xxport/qtopia_xxport.cpp \ +xxport/sharpdtm_xxport.cpp \ #details/look_details.cpp \ #mainwindow.cpp \ # calendarview.cpp \ # timespanview.cpp win32: { HEADERS += ../outport/msoutl9.h \ kaimportoldialog.h SOURCES += ../outport/msoutl9.cpp \ kaimportoldialog.cpp } diff --git a/kaddressbook/kaddressbookE.pro b/kaddressbook/kaddressbookE.pro index dc4a2f2..95e6641 100644 --- a/kaddressbook/kaddressbookE.pro +++ b/kaddressbook/kaddressbookE.pro @@ -1,157 +1,163 @@ TEMPLATE = app CONFIG += qt warn_on TARGET = kapi OBJECTS_DIR = obj/$(PLATFORM) MOC_DIR = moc/$(PLATFORM) DESTDIR=$(QPEDIR)/bin #LFLAGS += -Wl,-export-dynamic -INCLUDEPATH += . ./details ./features ./kcmconfigs ./xxport ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kio/kio ../microkde/kdeui ../kabc ../qtcompat ../ interfaces $(QPEDIR)/include +INCLUDEPATH += . ./details ./features ./kcmconfigs ./xxport ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kio/kio ../microkde/kdeui ../microkde/kresources ../kabc ../qtcompat ../ interfaces $(QPEDIR)/include DEFINES += KAB_EMBEDDED KAB_NOSPLITTER #DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOKABC KORG_NOARCHIVE KORG_NOMAIL #DEFINES += KORG_NOPRINTER KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER #DEFINES += KORG_NOLVALTERNATION LIBS += -lmicrokdepim #LIBS += -lmicrokcal LIBS += -lmicrokde LIBS += -lmicrokcal LIBS += -lmicroqtcompat LIBS += -lmicrokabc LIBS += -lqpe LIBS += -ljpeg LIBS += $(QTOPIALIB) LIBS += -L$(QPEDIR)/lib LIBS += -Wl,-export-dynamic INTERFACES = \ # filteredit_base.ui \ # kofilterview_base.ui \ HEADERS = \ features/mergewidget.h \ features/distributionlistwidget.h \ kcmconfigs/addresseewidget.h \ kcmconfigs/extensionconfigdialog.h \ kcmconfigs/kcmkabconfig.h \ kcmconfigs/kabconfigwidget.h \ addresseeeditordialog.h \ addresseeeditorwidget.h \ addresseditwidget.h \ addresseeconfig.h \ addresseeutil.h \ emaileditwidget.h \ filtereditdialog.h \ kaddressbookmain.h \ kabprefs.h \ kabcore.h \ viewmanager.h \ extensionmanager.h \ extensionwidget.h \ kaddressbookview.h \ geowidget.h \ imagewidget.h \ incsearchwidget.h \ jumpbuttonbar.h \ phoneeditwidget.h \ secrecywidget.h \ keywidget.h \ nameeditdialog.h \ filter.h \ addviewdialog.h \ configurewidget.h \ viewconfigurewidget.h \ viewconfigurefieldspage.h \ viewconfigurefilterpage.h \ typecombo.h \ undo.h \ undocmds.h \ xxportmanager.h \ xxportobject.h \ xxportselectdialog.h \ details/detailsviewcontainer.h \ details/look_basic.h \ details/look_html.h \ views/kaddressbookiconview.h \ views/kaddressbooktableview.h \ views/kaddressbookcardview.h \ views/configuretableviewdialog.h \ views/configurecardviewdialog.h \ views/cardview.h \ views/colorlistbox.h \ views/contactlistview.h \ xxport/vcard_xxport.h \ xxport/kde2_xxport.h \ xxport/csv_xxport.h \ xxport/csvimportdialog.h \ +xxport/opie_xxport.h \ +xxport/qtopia_xxport.h \ +xxport/sharpdtm_xxport.h \ #details/look_details.h \ #mainwindoiw.h \ # alarmclient.h \ # calendarview.h \ # customlistviewitem.h \ # datenavigator.h SOURCES = \ addresseeeditordialog.cpp \ addresseeeditorwidget.cpp \ addresseditwidget.cpp \ addresseeconfig.cpp \ addresseeutil.cpp \ extensionmanager.cpp \ features/mergewidget.cpp \ features/distributionlistwidget.cpp \ kcmconfigs/addresseewidget.cpp \ kcmconfigs/extensionconfigdialog.cpp \ kcmconfigs/kcmkabconfig.cpp \ kcmconfigs/kabconfigwidget.cpp \ emaileditwidget.cpp \ filtereditdialog.cpp \ mainembedded.cpp \ kaddressbookmain.cpp \ kabcore.cpp \ kabprefs.cpp \ viewmanager.cpp \ kaddressbookview.cpp \ extensionwidget.cpp \ geowidget.cpp \ imagewidget.cpp \ incsearchwidget.cpp \ jumpbuttonbar.cpp \ phoneeditwidget.cpp \ secrecywidget.cpp \ keywidget.cpp \ nameeditdialog.cpp \ filter.cpp \ addviewdialog.cpp \ configurewidget.cpp \ viewconfigurewidget.cpp \ viewconfigurefieldspage.cpp \ viewconfigurefilterpage.cpp \ undo.cpp \ undocmds.cpp \ xxportmanager.cpp \ xxportobject.cpp \ xxportselectdialog.cpp \ details/detailsviewcontainer.cpp \ details/look_basic.cpp \ details/look_html.cpp \ views/kaddressbookiconview.cpp \ views/kaddressbooktableview.cpp \ views/kaddressbookcardview.cpp \ views/configuretableviewdialog.cpp \ views/configurecardviewdialog.cpp \ views/cardview.cpp \ views/contactlistview.cpp \ views/colorlistbox.cpp \ xxport/vcard_xxport.cpp \ xxport/kde2_xxport.cpp \ xxport/csv_xxport.cpp \ xxport/csvimportdialog.cpp \ +xxport/opie_xxport.cpp \ +xxport/qtopia_xxport.cpp \ +xxport/sharpdtm_xxport.cpp \ #details/look_details.cpp \ #mainwindow.cpp \ # calendarview.cpp \ # timespanview.cpp diff --git a/kaddressbook/xxportmanager.cpp b/kaddressbook/xxportmanager.cpp index 2962951..a6797c9 100644 --- a/kaddressbook/xxportmanager.cpp +++ b/kaddressbook/xxportmanager.cpp @@ -1,258 +1,261 @@ /* This file is part of KAddressbook. Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (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 extern "C" { - void* init_kaddrbk_csv_xxport(); - void* init_kaddrbk_kde2_xxport(); - void* init_kaddrbk_vcard_xxport(); + void* init_microkaddrbk_csv_xxport(); + void* init_microkaddrbk_kde2_xxport(); + void* init_microkaddrbk_vcard_xxport(); + void* init_microkaddrbk_opie_xxport(); + void* init_microkaddrbk_qtopia_xxport(); + void* init_microkaddrbk_sharpdtm_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(); } XXPortManager::~XXPortManager() { } void XXPortManager::restoreSettings() { } void XXPortManager::saveSettings() { } void XXPortManager::importVCard( const KURL &url ) { importVCard( url, false ); } void XXPortManager::importVCard( const KURL &url, bool showPreview ) { importURL = url; mShowPreview = showPreview; slotImport( "vcard", "<empty>" ); mShowPreview = false; importURL = KURL(); } void XXPortManager::importVCard( const QString &vCard, bool showPreview ) { importData = vCard; mShowPreview = showPreview; slotImport( "vcard", "<empty>" ); mShowPreview = false; importData = ""; } void XXPortManager::slotImport( const QString &identifier, const QString &data ) { XXPortObject *obj = mXXPortObjects[ identifier ]; if ( !obj ) { KMessageBox::error( mCore, i18n( "<qt>No import plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); return; } KABC::Resource *resource = mCore->requestResource( mCore ); if ( !resource ) return; KABC::AddresseeList list = obj->importContacts( data ); KABC::AddresseeList::Iterator it; bool imported = false; for ( it = list.begin(); it != list.end(); ++it ) { if ( mShowPreview ) { PreviewDialog dlg( *it, mCore ); if ( !dlg.exec() ) continue; } (*it).setResource( resource ); // We use a PwNewCommand so the user can undo it. PwNewCommand *command = new PwNewCommand( mCore->addressBook(), *it ); UndoStack::instance()->push( command ); RedoStack::instance()->clear(); imported = true; } if ( imported ) { KMessageBox::information( mCore, i18n( "contacts successfully imported." ) ); emit modified(); } } void XXPortManager::slotExport( const QString &identifier, const QString &data ) { XXPortObject *obj = mXXPortObjects[ identifier ]; if ( !obj ) { KMessageBox::error( mCore, i18n( "<qt>No export plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); return; } KABC::AddresseeList addrList; XXPortSelectDialog dlg( mCore, obj->requiresSorting(), mCore ); if ( dlg.exec() ) addrList = dlg.contacts(); else return; if ( !obj->exportContacts( addrList, data ) ) KMessageBox::error( mCore, i18n( "Unable to export contacts." ) ); else KMessageBox::information( mCore, i18n( "contacts successfully exported." ) ); } 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; } #else //KAB_EMBEDDED 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())); + factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_csv_xxport())); + factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_kde2_xxport())); + factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_vcard_xxport())); //add the opie import library dynamically KLibFactory *factory = KLibLoader::self()->factory( "microkaddrbk_opie_xxport" ); if ( factory ) { XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory ); factorylist.append(xxportFactory); } //add the qtopia import library dynamically factory = KLibLoader::self()->factory( "microkaddrbk_qtopia_xxport" ); if ( factory ) { XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory ); factorylist.append(xxportFactory); } //add the sharp import library dynamically factory = KLibLoader::self()->factory( "microkaddrbk_sharpdtm_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 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& ) ) ); } } } 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.cpp b/kaddressbook/xxportobject.cpp index 42ab0fb..bb985a6 100644 --- a/kaddressbook/xxportobject.cpp +++ b/kaddressbook/xxportobject.cpp @@ -22,131 +22,152 @@ */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <qmap.h> #include <qsignalmapper.h> #include <kaction.h> #include <kmessagebox.h> #include "kabcore.h" #include "xxportobject.h" class XXPortObject::XXPortObjectPrivate { public: QSignalMapper *mExportMapper; QSignalMapper *mImportMapper; }; XXPortObject::XXPortObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) : QObject( parent, name ), mAddressBook( ab ), mParentWidget( parent ), d( new XXPortObjectPrivate ) { d->mExportMapper = new QSignalMapper( this ); d->mImportMapper = new QSignalMapper( this ); connect( d->mExportMapper, SIGNAL( mapped( const QString& ) ), SLOT( slotExportActivated( const QString& ) ) ); connect( d->mImportMapper, SIGNAL( mapped( const QString& ) ), SLOT( slotImportActivated( const QString& ) ) ); } XXPortObject::~XXPortObject() { delete d; d = 0; } bool XXPortObject::exportContacts( const KABC::AddresseeList&, const QString& ) { // do nothing return false; } KABC::AddresseeList XXPortObject::importContacts( const QString& ) const { // do nothing return KABC::AddresseeList(); } void XXPortObject::createImportAction( const QString &label, const QString &data ) { #ifdef KAB_EMBEDDED KABCore* kabcore = (KABCore*)mParentWidget; #endif //KAB_EMBEDDED QString id = "file_import_" + identifier() + ( data.isEmpty() ? QString( "" ) : "_" + data ); #ifndef KAB_EMBEDDED KAction *action = new KAction( label, 0, d->mImportMapper, SLOT( map() ), actionCollection(), id.latin1() ); #else //KAB_EMBEDDED KAction *action = new KAction( label, 0, d->mImportMapper, SLOT( map() ), kabcore->actionCollection(), id.latin1() ); #endif //KAB_EMBEDDED d->mImportMapper->setMapping( action, ( data.isEmpty() ? QString( "<empty>" ) : data ) ); #ifndef KAB_EMBEDDED setXMLFile( identifier() + "_xxportui.rc" ); #endif //KAB_EMBEDDED #ifdef KAB_EMBEDDED action->plug((QWidget*)kabcore->getImportMenu()); #endif //KAB_EMBEDDED } void XXPortObject::createExportAction( const QString &label, const QString &data ) { #ifdef KAB_EMBEDDED KABCore* kabcore = (KABCore*)mParentWidget; #endif //KAB_EMBEDDED QString id = "file_export_" + identifier() + ( data.isEmpty() ? QString( "" ) : "_" + data ); #ifndef KAB_EMBEDDED KAction *action = new KAction( label, 0, d->mExportMapper, SLOT( map() ), actionCollection(), id.latin1() ); #else //KAB_EMBEDDED KAction *action = new KAction( label, 0, d->mExportMapper, SLOT( map() ), kabcore->actionCollection(), id.latin1() ); #endif //KAB_EMBEDDED d->mExportMapper->setMapping( action, ( data.isEmpty() ? QString( "<empty>" ) : data ) ); #ifndef KAB_EMBEDDED setXMLFile( identifier() + "_xxportui.rc" ); #endif //KAB_EMBEDDED #ifdef KAB_EMBEDDED action->plug((QWidget*)kabcore->getExportMenu()); #endif //KAB_EMBEDDED } KABC::AddressBook *XXPortObject::addressBook() const { return mAddressBook; } QWidget *XXPortObject::parentWidget() const { return mParentWidget; } void XXPortObject::slotExportActivated( const QString &data ) { emit exportActivated( identifier(), ( data == "<empty>" ? QString::null : data ) ); } void XXPortObject::slotImportActivated( const QString &data ) { emit importActivated( identifier(), ( data == "<empty>" ? QString::null : data ) ); } +/******************************************************************** + * + *******************************************************************/ + + +XXPortResourceObject::XXPortResourceObject( KABC::AddressBook *ab, QWidget *parent, + const char *name ) + : XXPortObject( ab, parent, name ), mResource(0) +{ +} + +XXPortResourceObject::~XXPortResourceObject() +{ +} + +bool XXPortResourceObject::isAvailable() +{ + return (mResource != 0); +} + + #ifndef KAB_EMBEDDED #include "xxportobject.moc" #endif //KAB_EMBEDDED diff --git a/kaddressbook/xxportobject.h b/kaddressbook/xxportobject.h index fddc219..d547855 100644 --- a/kaddressbook/xxportobject.h +++ b/kaddressbook/xxportobject.h @@ -1,137 +1,170 @@ /* This file is part of KAddressbook. Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (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$ */ #ifndef XXPORTOBJECT_H #define XXPORTOBJECT_H #include <qobject.h> #include <kabc/addressbook.h> #include <kabc/addresseelist.h> +#include <kabc/resource.h> #include <kxmlguiclient.h> #include <klibloader.h> + + + 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; } + /** + Returns true if the XXPortObject can be used. + One case it can not be used is for example if a needed lib could not be loaded. + */ + virtual bool isAvailable() const { return true; }; + + public slots: /** Reimplement this method for exporting the contacts. */ virtual bool exportContacts( const KABC::AddresseeList &list, const QString& identifier ); /** Reimplement this method for importing the contacts. */ virtual KABC::AddresseeList importContacts( const QString& identifier ) const; signals: /** Emitted whenever the export action is activated. The parameter contains the @ref identifier() for unique identification. */ void exportActivated( const QString&, const QString& ); /** Emitted whenever the import action is activated. The parameter contains the @ref identifier() for unique identification. */ void importActivated( const QString&, const QString& ); protected: /** Create the import action. The identifier is passed in the import slot. */ void createImportAction( const QString &label, const QString &identifier = QString::null ); /** Create the export action. The identifier is passed in the export slot. */ void createExportAction( const QString &label, const QString &identifier = QString::null ); /** 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; }; + + +class XXPortResourceObject : public XXPortObject +{ + Q_OBJECT + + public: + XXPortResourceObject( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 ); + ~XXPortResourceObject(); + + /** + Returns true if the XXPortObject can be used. + One case it can not be used is for example if a needed lib could not be loaded. + */ + virtual bool isAvailable(); + protected: + KABC::Resource* mResource; +}; + + + + 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; } }; #endif |