-rw-r--r-- | kabc/plugins/opie/resourceopie.cpp | 9 | ||||
-rw-r--r-- | kaddressbook/xxport/opie/opie_xxport.cpp | 12 |
2 files changed, 16 insertions, 5 deletions
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp index f992301..a4f8d8a 100644 --- a/kabc/plugins/opie/resourceopie.cpp +++ b/kabc/plugins/opie/resourceopie.cpp @@ -33,32 +33,33 @@ $Id$ #include <qfile.h> #include <qfileinfo.h> #include <qregexp.h> #include <qtimer.h> #include <kapplication.h> #include <kconfig.h> #include <kdebug.h> #include <klocale.h> //US #include <ksavefile.h> #include <kstandarddirs.h> //US #include "formatfactory.h" //US #include <qpe/qpeapplication.h> #include <opie/ocontactaccess.h> +#include <opie/ocontactaccessbackend_xml.h> #include "resource.h" #include "resourceopieconfig.h" #include "stdaddressbook.h" #include "opieconverter.h" #include "resourceopie.h" using namespace KABC; extern "C" { void *init_microkabc_opie() { return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig>(); } @@ -166,34 +167,37 @@ bool ResourceOpie::doOpen() return ok; } */ qDebug("ResourceOpie::doOpen() has to be fixed - %s", mFileName.latin1()); return true; } void ResourceOpie::doClose() { // qDebug("ResourceOpie::doClose() %s", mFileName.latin1()); } bool ResourceOpie::load() { // qDebug("ResourceOpie::load() %s", mFileName.latin1()); kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl; - - OContactAccess* access = new OContactAccess("KDEPim/Pi", mFileName, 0l, false); + + qDebug("ResourceOpie::load: Try to load file() %s", mFileName.latin1()); + + OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", mFileName ); + OContactAccess* access = new OContactAccess("KDEPim/Pi", 0l, backend, false); if ( !access ) { qDebug("Unable to load file() %s", mFileName.latin1()); addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) ); return false; } access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available if (mConverter == 0) mConverter = new OpieConverter(); OContactAccess::List::Iterator it; OContactAccess::List allList = access->allRecords(); bool res = false; @@ -202,32 +206,33 @@ bool ResourceOpie::load() OContact c = (*it); KABC::Addressee addressee; res = mConverter->opieToAddressee( c, addressee ); if ( !addressee.isEmpty() && res ) { addressee.setResource( this ); addressBook()->insertAddressee( addressee ); } // qDebug("found %s", c.fullName().latin1()); } delete access; + delete backend; return true; } bool ResourceOpie::save( Ticket *ticket ) { qDebug("ResourceOpie::save() has to be fixed - %s", mFileName.latin1()); /*US qDebug("ResourceOpie::save %s", mFileName.latin1()); kdDebug(5700) << "ResourceOpie::save()" << endl; // create backup file QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); */ /*US we use a simpler method to create a backupfile diff --git a/kaddressbook/xxport/opie/opie_xxport.cpp b/kaddressbook/xxport/opie/opie_xxport.cpp index 90d05cd..f30a205 100644 --- a/kaddressbook/xxport/opie/opie_xxport.cpp +++ b/kaddressbook/xxport/opie/opie_xxport.cpp @@ -21,32 +21,34 @@ 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 <qdir.h> #include <kfiledialog.h> #include <kmessagebox.h> #include <opie/ocontactaccess.h> +#include <opie/ocontactaccessbackend_xml.h> + #include "stdaddressbook.h" /*US #include <qfile.h> #include <qtextstream.h> #include <kabc/vcardconverter.h> #ifndef KAB_EMBEDDED #include <kio/netaccess.h> #endif //KAB_EMBEDDED #include <klocale.h> #include <kmessagebox.h> #include <ktempfile.h> #include <kurl.h> */ @@ -83,33 +85,34 @@ OpieXXPort::OpieXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name createExportAction( i18n( "Export Opie..." ) ); } bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) { QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; #ifndef KAB_EMBEDDED QString fileName = KFileDialog::getSaveFileName( name ); #else //KAB_EMBEDDED QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); #endif //KAB_EMBEDDED if ( fileName.isEmpty() ) return true; - OContactAccess* access = new OContactAccess("KA/Pi", fileName, 0l, false); + OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); + OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); if ( !access ) { qDebug("Unable to access file() %s", fileName.latin1()); addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); return false; } //Now check if the file has already entries, and ask the user if he wants to delete them first. OContactAccess::List contactList = access->allRecords(); if (contactList.count() > 0) { QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { // Clean the database.. access->clear(); } @@ -126,71 +129,74 @@ bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString res = mConverter.addresseeToOpie( *it, c ); if (res == true) { res = access->add(c); if (res == false) qDebug("Unable to append Contact %s", c.fullName().latin1()); } else { qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); } } access->save(); delete access; - + delete backend; + return true; } KABC::AddresseeList OpieXXPort::importContacts( const QString& ) const { KABC::AddresseeList adrlst; QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; #ifndef KAB_EMBEDDED QString fileName = KFileDialog::getOpenFileName( name ); #else //KAB_EMBEDDED QString fileName = KFileDialog::getOpenFileName( name, i18n("Load file"), parentWidget() ); #endif //KAB_EMBEDDED if ( fileName.isEmpty() ) return KABC::AddresseeList(); - OContactAccess* access = new OContactAccess("KA/Pi", fileName, 0l, false); + OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); + OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); if ( !access ) { qDebug("Unable to access file() %s", fileName.latin1()); addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); return KABC::AddresseeList(); } access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available KABC::OpieConverter mConverter; bool res = false; OContactAccess::List::Iterator it; OContactAccess::List allList = access->allRecords(); for ( it = allList.begin(); it != allList.end(); ++it ) { OContact c = (*it); KABC::Addressee addressee; res = mConverter.opieToAddressee( c, addressee ); if ( !addressee.isEmpty() && res ) { adrlst.append( addressee ); } // qDebug("found %s", c.fullName().latin1()); } delete access; + delete backend; return adrlst; } |