summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/sharpdtm
authorulf69 <ulf69>2004-07-17 00:39:36 (UTC)
committer ulf69 <ulf69>2004-07-17 00:39:36 (UTC)
commitcb3782d17ea98a15acb158ea6dd18aa2600b08f8 (patch) (side-by-side diff)
tree36fa94a526fb3afb73fe2bd1ba511af0c2174aab /kabc/plugins/sharpdtm
parent01570860c92be8977a1ba558ae7c5f15d4635851 (diff)
downloadkdepimpi-cb3782d17ea98a15acb158ea6dd18aa2600b08f8.zip
kdepimpi-cb3782d17ea98a15acb158ea6dd18aa2600b08f8.tar.gz
kdepimpi-cb3782d17ea98a15acb158ea6dd18aa2600b08f8.tar.bz2
implementation of the sharp resource module
Diffstat (limited to 'kabc/plugins/sharpdtm') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.cpp90
1 files changed, 46 insertions, 44 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
@@ -49,7 +49,7 @@ $Id$
#include "resourcesharpdtmconfig.h"
-#include "stdaddressbook.h"
+#include "resourcesharpdtm.h"
-//#include "qtopiaconverter.h"
+#include "stdaddressbook.h"
-#include "resourcesharpdtm.h"
+#include "sharpdtmconverter.h"
@@ -69,3 +69,3 @@ ResourceSharpDTM::ResourceSharpDTM( const KConfig *config )
- QString fileName = SlZDataBase::addressbookFileName();
+ QString fileName = SlZDataBase::addressbookFileName();
init( fileName );
@@ -140,3 +140,3 @@ bool ResourceSharpDTM::doOpen()
bool ok = true;
-
+
file.close();
@@ -146,3 +146,3 @@ bool ResourceSharpDTM::doOpen()
*/
- return true;
+ return true;
}
@@ -158,5 +158,7 @@ bool ResourceSharpDTM::load()
// 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 ) {
@@ -166,3 +168,3 @@ bool ResourceSharpDTM::load()
}
-
+
bool res = false;
@@ -170,9 +172,10 @@ bool ResourceSharpDTM::load()
{
-// 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;
@@ -181,14 +184,13 @@ bool ResourceSharpDTM::load()
}
- /*
- { //create a new scope
- AddressBookIterator it(*access);
- const PimContact* contact;
-
- for (contact=it.toFirst(); it.current(); ++it) {
- contact = it.current();
-
+
+ { //create a new scope
+ CardId id;
+
+ 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 )
@@ -200,3 +202,3 @@ bool ResourceSharpDTM::load()
}
-*/
+
delete access;
@@ -213,5 +215,5 @@ bool ResourceSharpDTM::save( Ticket *ticket )
QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() );
-
+
/*US we use a simpler method to create a backupfile
-
+
(void) KSaveFile::backupFile( mFileName, QString::null
@@ -229,3 +231,3 @@ bool ResourceSharpDTM::save( Ticket *ticket )
/*US
-//US ToDo: write backupfile
+//US ToDo: write backupfile
QFile info;
@@ -235,3 +237,3 @@ bool ResourceSharpDTM::save( Ticket *ticket )
//US mFormat->saveAll( addressBook(), this, &info );
-
+
info.close();
@@ -240,11 +242,11 @@ bool ResourceSharpDTM::save( Ticket *ticket )
else {
-
+
}
-
+
if ( !ok )
addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) );
-
+
delete ticket;
unlock( mFileName );
-
+
return ok;
@@ -252,3 +254,3 @@ bool ResourceSharpDTM::save( Ticket *ticket )
qDebug("ResourceQtopia::save has to be changed");
-*/
+*/
return true;
@@ -265,6 +267,6 @@ bool ResourceSharpDTM::lock( const QString &fileName )
//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
-
- KURL url(fn);
+
+ KURL url(fn);
QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
-
+
kdDebug(5700) << "-- lock name: " << lockName << endl;
@@ -275,4 +277,4 @@ bool ResourceSharpDTM::lock( const QString &fileName )
lockUniqueName = fn + KApplication::randomString( 8 );
-
- url = lockUniqueName;
+
+ url = lockUniqueName;
//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
@@ -307,5 +309,5 @@ void ResourceSharpDTM::unlock( const QString &fileName )
//US QString lockName = fn + ".lock";
- KURL url(fn);
+ KURL url(fn);
QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
-
+
QFile::remove( lockName );
@@ -319,3 +321,3 @@ void ResourceSharpDTM::setFileName( const QString &fileName )
mDirWatch.removeFile( mFileName );
-
+
mFileName = fileName;
@@ -338,3 +340,3 @@ void ResourceSharpDTM::fileChanged()
return;
-
+
QString text( i18n( "Sharp DTM resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) );