author | ulf69 <ulf69> | 2004-07-17 00:39:36 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-07-17 00:39:36 (UTC) |
commit | cb3782d17ea98a15acb158ea6dd18aa2600b08f8 (patch) (side-by-side diff) | |
tree | 36fa94a526fb3afb73fe2bd1ba511af0c2174aab | |
parent | 01570860c92be8977a1ba558ae7c5f15d4635851 (diff) | |
download | kdepimpi-cb3782d17ea98a15acb158ea6dd18aa2600b08f8.zip kdepimpi-cb3782d17ea98a15acb158ea6dd18aa2600b08f8.tar.gz kdepimpi-cb3782d17ea98a15acb158ea6dd18aa2600b08f8.tar.bz2 |
implementation of the sharp resource module
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index 347d51c..31b99ca 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp @@ -26,53 +26,53 @@ $Id$ */ #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <qdir.h> #include <qfile.h> #include <qfileinfo.h> #include <qregexp.h> //US #include <qtimer.h> #include <kapplication.h> #include <kconfig.h> #include <kdebug.h> #include <klocale.h> //US #include <ksavefile.h> #include <kstandarddirs.h> #include <kmessagebox.h> #include <sl/slzdb.h> #include "resourcesharpdtmconfig.h" +#include "resourcesharpdtm.h" + #include "stdaddressbook.h" -//#include "qtopiaconverter.h" - -#include "resourcesharpdtm.h" +#include "sharpdtmconverter.h" using namespace KABC; extern "C" { void *init_microkabc_sharpdtm() { return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig>(); } } ResourceSharpDTM::ResourceSharpDTM( const KConfig *config ) : Resource( config ), mConverter (0) { // we can not choose the filename. Therefore use the default to display QString fileName = SlZDataBase::addressbookFileName(); init( fileName ); } ResourceSharpDTM::ResourceSharpDTM( const QString &fileName ) : Resource( 0 ) { // qDebug("ResourceFile::ResourceSharpDTM : 3 %s, %s", fileName.latin1(), formatName.latin1()); init( fileName ); @@ -136,90 +136,92 @@ bool ResourceSharpDTM::doOpen() return true; } //US bool ok = mFormat->checkFormat( &file ); bool ok = true; file.close(); return ok; } */ return true; } void ResourceSharpDTM::doClose() { } bool ResourceSharpDTM::load() { kdDebug(5700) << "ResourcSharpDTM::load(): '" << mFileName << "'" << endl; // qDebug("ResourceSharpDTM::load: Try to load file() %s", mFileName.latin1()); + // the last parameter in the SlZDataBase constructor means "readonly" SlZDataBase* access = new SlZDataBase(mFileName, - SlZDataBase::addressbookItems()); + SlZDataBase::addressbookItems(), + NULL, true); if ( !access ) { qDebug("Unable to load file() %s", mFileName.latin1()); addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) ); return false; } bool res = false; if (mConverter == 0) { -// mConverter = new QtopiaConverter(); -// res = mConverter->init(); - res = true; + mConverter = new SharpDTMConverter(); + res = mConverter->init(); if ( !res ) { - qDebug("Unable to initialize qtopia converter. Most likely a problem with the category file"); - addressBook()->error( i18n( "Unable to initialize qtopia converter. Most likely a problem with the category file" ) ); + QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); + + qDebug(msg); + addressBook()->error( i18n( msg ) ); delete access; return false; } } - /* + { //create a new scope - AddressBookIterator it(*access); - const PimContact* contact; + CardId id; - for (contact=it.toFirst(); it.current(); ++it) { - contact = it.current(); + for (bool res=access->first(); res == true; res=access->next()) { + id = access->cardId(); KABC::Addressee addressee; - res = mConverter->qtopiaToAddressee( (*contact), addressee ); + res = mConverter->sharpToAddressee( id, access, addressee ); if ( !addressee.isEmpty() && res ) { addressee.setResource( this ); addressBook()->insertAddressee( addressee ); } } } -*/ + delete access; return true; } bool ResourceSharpDTM::save( Ticket *ticket ) { /*US // qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); kdDebug(5700) << "ResourceQtopia::save()" << endl; // create backup file QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); /*US we use a simpler method to create a backupfile (void) KSaveFile::backupFile( mFileName, QString::null ,extension ); KSaveFile saveFile( mFileName ); bool ok = false; if ( saveFile.status() == 0 && saveFile.file() ) { mFormat->saveAll( addressBook(), this, saveFile.file() ); ok = saveFile.close(); |