summaryrefslogtreecommitdiffabout
path: root/kabc/plugins
authorulf69 <ulf69>2004-08-02 18:32:08 (UTC)
committer ulf69 <ulf69>2004-08-02 18:32:08 (UTC)
commit863c4c3678e59ef125c08c00e9532ded5b540f67 (patch) (unidiff)
tree449428c45689ffe10ff1ce4caa18f959c4dfe402 /kabc/plugins
parent983127ce46c9ff6663d08dedd450da3fe7dd549b (diff)
downloadkdepimpi-863c4c3678e59ef125c08c00e9532ded5b540f67.zip
kdepimpi-863c4c3678e59ef125c08c00e9532ded5b540f67.tar.gz
kdepimpi-863c4c3678e59ef125c08c00e9532ded5b540f67.tar.bz2
added support for syncprofiles for resources and export/import capabilities
Diffstat (limited to 'kabc/plugins') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/dir/dir.pro2
-rw-r--r--kabc/plugins/dir/dirE.pro2
-rw-r--r--kabc/plugins/dir/resourcedir.cpp35
-rw-r--r--kabc/plugins/dir/resourcedir.h6
-rw-r--r--kabc/plugins/file/file.pro2
-rw-r--r--kabc/plugins/file/fileE.pro2
-rw-r--r--kabc/plugins/file/resourcefile.cpp74
-rw-r--r--kabc/plugins/file/resourcefile.h8
-rw-r--r--kabc/plugins/ldap/ldapE.pro2
-rw-r--r--kabc/plugins/ldap/resourceldap.cpp7
-rw-r--r--kabc/plugins/ldap/resourceldap.h2
-rw-r--r--kabc/plugins/opie/opieE.pro2
-rw-r--r--kabc/plugins/opie/resourceopie.cpp302
-rw-r--r--kabc/plugins/opie/resourceopie.h40
-rw-r--r--kabc/plugins/qtopia/qtopiaE.pro2
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp182
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.h35
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.cpp35
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.h32
-rw-r--r--kabc/plugins/sharpdtm/sharpdtmE.pro2
20 files changed, 419 insertions, 355 deletions
diff --git a/kabc/plugins/dir/dir.pro b/kabc/plugins/dir/dir.pro
index 0555484..a7c1503 100644
--- a/kabc/plugins/dir/dir.pro
+++ b/kabc/plugins/dir/dir.pro
@@ -5,3 +5,3 @@ CONFIG += qt warn_on release
5TARGET = microkabc_dir 5TARGET = microkabc_dir
6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat 6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat
7DESTDIR = ../../../bin 7DESTDIR = ../../../bin
diff --git a/kabc/plugins/dir/dirE.pro b/kabc/plugins/dir/dirE.pro
index 729f4ce..9066556 100644
--- a/kabc/plugins/dir/dirE.pro
+++ b/kabc/plugins/dir/dirE.pro
@@ -5,3 +5,3 @@ CONFIG += qt warn_on release
5TARGET = microkabc_dir 5TARGET = microkabc_dir
6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat 6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat
7OBJECTS_DIR = obj/$(PLATFORM) 7OBJECTS_DIR = obj/$(PLATFORM)
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp
index 52863d5..d978e61 100644
--- a/kabc/plugins/dir/resourcedir.cpp
+++ b/kabc/plugins/dir/resourcedir.cpp
@@ -59,2 +59,3 @@ $Id$
59#include "resourcedir.h" 59#include "resourcedir.h"
60#include "syncwidget.h"
60 61
@@ -64,3 +65,3 @@ extern "C"
64#ifdef _WIN32_ 65#ifdef _WIN32_
65__declspec(dllexport) 66__declspec(dllexport)
66#else 67#else
@@ -72,3 +73,3 @@ __declspec(dllexport)
72 { 73 {
73 return new KRES::PluginFactory<ResourceDir,ResourceDirConfig>(); 74 return new KRES::PluginFactory<ResourceDir,ResourceDirConfig, KRES::SyncWidget>();
74 } 75 }
@@ -78,4 +79,4 @@ __declspec(dllexport)
78 79
79ResourceDir::ResourceDir( const KConfig *config ) 80ResourceDir::ResourceDir( const KConfig *config, bool syncable )
80 : Resource( config ) 81 : Resource( config, syncable )
81{ 82{
@@ -103,3 +104,3 @@ ResourceDir::ResourceDir( const KConfig *config )
103 104
104/*US 105/*US
105//US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1()); 106//US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1());
@@ -112,3 +113,3 @@ ResourceDir::ResourceDir( const KConfig *config )
112*/ 113*/
113 114
114 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) ); 115 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) );
@@ -127,4 +128,4 @@ ResourceDir::~ResourceDir()
127void ResourceDir::writeConfig( KConfig *config ) 128void ResourceDir::writeConfig( KConfig *config )
128{ 129{
129 config->setGroup( "Resource_" + identifier() ); 130 config->setGroup( "Resource_" + identifier() );
130 Resource::writeConfig( config ); 131 Resource::writeConfig( config );
@@ -243,6 +244,6 @@ bool ResourceDir::lock( const QString &path )
243//US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" ); 244//US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" );
244 KURL url(p); 245 KURL url(p);
245 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 246 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
246 247
247 248
248 kdDebug(5700) << "-- lock name: " << lockName << endl; 249 kdDebug(5700) << "-- lock name: " << lockName << endl;
@@ -254,6 +255,6 @@ bool ResourceDir::lock( const QString &path )
254 255
255 url = lockUniqueName; 256 url = lockUniqueName;
256//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 257//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
257 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 258 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
258 259
259 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; 260 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
@@ -287,3 +288,3 @@ void ResourceDir::unlock( const QString &path )
287//US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" ); 288//US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" );
288 KURL url(p); 289 KURL url(p);
289 QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" ); 290 QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" );
@@ -299,3 +300,3 @@ void ResourceDir::setPath( const QString &path )
299 mDirWatch.removeDir( mPath ); 300 mDirWatch.removeDir( mPath );
300 301
301 mPath = path; 302 mPath = path;
@@ -305,3 +306,3 @@ void ResourceDir::setPath( const QString &path )
305 306
306//US simulate KDirWatch event 307//US simulate KDirWatch event
307//US pathChanged(); 308//US pathChanged();
@@ -324,3 +325,3 @@ void ResourceDir::setFormat( const QString &format )
324 mFormat = factory->format( mFormatName ); 325 mFormat = factory->format( mFormatName );
325/*US 326/*US
326qDebug("ResourceDir::setFormat initialized with format %s ", format.latin1()); 327qDebug("ResourceDir::setFormat initialized with format %s ", format.latin1());
diff --git a/kabc/plugins/dir/resourcedir.h b/kabc/plugins/dir/resourcedir.h
index 6e35695..c2aedad 100644
--- a/kabc/plugins/dir/resourcedir.h
+++ b/kabc/plugins/dir/resourcedir.h
@@ -51,3 +51,3 @@ class ResourceDir : public Resource
51public: 51public:
52 ResourceDir( const KConfig* ); 52 ResourceDir( const KConfig*, bool syncable );
53 ~ResourceDir(); 53 ~ResourceDir();
@@ -58,3 +58,3 @@ public:
58 virtual void doClose(); 58 virtual void doClose();
59 59
60 virtual Ticket *requestSaveTicket(); 60 virtual Ticket *requestSaveTicket();
@@ -83,3 +83,3 @@ public:
83 QString format() const; 83 QString format() const;
84 84
85 /** 85 /**
diff --git a/kabc/plugins/file/file.pro b/kabc/plugins/file/file.pro
index 32555a2..154ef2a 100644
--- a/kabc/plugins/file/file.pro
+++ b/kabc/plugins/file/file.pro
@@ -5,3 +5,3 @@ CONFIG += qt warn_on release
5TARGET = microkabc_file 5TARGET = microkabc_file
6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat 6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat
7 7
diff --git a/kabc/plugins/file/fileE.pro b/kabc/plugins/file/fileE.pro
index d19a26d..3015806 100644
--- a/kabc/plugins/file/fileE.pro
+++ b/kabc/plugins/file/fileE.pro
@@ -5,3 +5,3 @@ CONFIG += qt warn_on release
5TARGET = microkabc_file 5TARGET = microkabc_file
6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat 6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat
7OBJECTS_DIR = obj/$(PLATFORM) 7OBJECTS_DIR = obj/$(PLATFORM)
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index 1d3acec..361b36b 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -53,2 +53,4 @@ $Id$
53#include "resourcefile.h" 53#include "resourcefile.h"
54#include "syncwidget.h"
55
54 56
@@ -58,3 +60,3 @@ extern "C"
58#ifdef _WIN32_ 60#ifdef _WIN32_
59__declspec(dllexport) 61__declspec(dllexport)
60#else 62#else
@@ -66,3 +68,3 @@ __declspec(dllexport)
66 { 68 {
67 return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>(); 69 return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, KRES::SyncWidget>();
68 } 70 }
@@ -72,4 +74,4 @@ __declspec(dllexport)
72 74
73ResourceFile::ResourceFile( const KConfig *config ) 75ResourceFile::ResourceFile( const KConfig *config, bool syncable )
74 : Resource( config ) , mFormat( 0 ) 76 : Resource( config, syncable ) , mFormat( 0 )
75{ 77{
@@ -91,5 +93,5 @@ ResourceFile::ResourceFile( const KConfig *config )
91 93
92ResourceFile::ResourceFile( const QString &fileName, 94ResourceFile::ResourceFile( const QString &fileName, bool syncable ,
93 const QString &formatName ) 95 const QString &formatName )
94 : Resource( 0 ) 96 : Resource( 0, syncable )
95{ 97{
@@ -141,3 +143,3 @@ void ResourceFile::writeConfig( KConfig *config )
141 143
142 config->setGroup( "Resource_" + identifier() ); 144 config->setGroup( "Resource_" + identifier() );
143 Resource::writeConfig( config ); 145 Resource::writeConfig( config );
@@ -146,5 +148,5 @@ void ResourceFile::writeConfig( KConfig *config )
146 config->writeEntry( "FileFormat", mFormatName ); 148 config->writeEntry( "FileFormat", mFormatName );
147 149
148// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); 150// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
149 151
150} 152}
@@ -199,3 +201,3 @@ bool ResourceFile::load()
199{ 201{
200 202
201 203
@@ -208,3 +210,3 @@ bool ResourceFile::load()
208// qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); 210// qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1());
209 211
210 return mFormat->loadAll( addressBook(), this, &file ); 212 return mFormat->loadAll( addressBook(), this, &file );
@@ -215,3 +217,3 @@ bool ResourceFile::save( Ticket *ticket )
215// qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); 217// qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1());
216 218
217 219
@@ -219,5 +221,5 @@ bool ResourceFile::save( Ticket *ticket )
219 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); 221 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() );
220 222
221/*US we use a simpler method to create a backupfile 223/*US we use a simpler method to create a backupfile
222 224
223 (void) KSaveFile::backupFile( mFileName, QString::null 225 (void) KSaveFile::backupFile( mFileName, QString::null
@@ -234,3 +236,3 @@ bool ResourceFile::save( Ticket *ticket )
234 236
235//US ToDo: write backupfile 237//US ToDo: write backupfile
236 QFile info; 238 QFile info;
@@ -240,3 +242,3 @@ bool ResourceFile::save( Ticket *ticket )
240 mFormat->saveAll( addressBook(), this, &info ); 242 mFormat->saveAll( addressBook(), this, &info );
241 243
242 info.close(); 244 info.close();
@@ -245,11 +247,11 @@ bool ResourceFile::save( Ticket *ticket )
245 else { 247 else {
246 248
247 } 249 }
248 250
249 if ( !ok ) 251 if ( !ok )
250 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); 252 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) );
251 253
252 delete ticket; 254 delete ticket;
253 unlock( mFileName ); 255 unlock( mFileName );
254 256
255 return ok; 257 return ok;
@@ -262,3 +264,3 @@ bool ResourceFile::lock( const QString &fileName )
262{ 264{
263 265
264 266
@@ -269,7 +271,7 @@ bool ResourceFile::lock( const QString &fileName )
269//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); 271//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
270 272
271 KURL url(fn); 273 KURL url(fn);
272 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 274 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
273 275
274 276
275 277
@@ -279,4 +281,4 @@ bool ResourceFile::lock( const QString &fileName )
279 lockUniqueName = fn + KApplication::randomString( 8 ); 281 lockUniqueName = fn + KApplication::randomString( 8 );
280 282
281 url = lockUniqueName; 283 url = lockUniqueName;
282//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 284//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
@@ -313,5 +315,5 @@ void ResourceFile::unlock( const QString &fileName )
313//US QString lockName = fn + ".lock"; 315//US QString lockName = fn + ".lock";
314 KURL url(fn); 316 KURL url(fn);
315 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 317 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
316 318
317 QFile::remove( lockName ); 319 QFile::remove( lockName );
@@ -325,6 +327,6 @@ void ResourceFile::setFileName( const QString &fileName )
325 mDirWatch.removeFile( mFileName ); 327 mDirWatch.removeFile( mFileName );
326 328
327 mFileName = fileName; 329 mFileName = fileName;
328 330
329 331
330 mDirWatch.addFile( mFileName ); 332 mDirWatch.addFile( mFileName );
@@ -332,3 +334,3 @@ void ResourceFile::setFileName( const QString &fileName )
332 334
333//US simulate KDirWatch event 335//US simulate KDirWatch event
334//US fileChanged(); 336//US fileChanged();
@@ -348,3 +350,3 @@ void ResourceFile::setFormat( const QString &format )
348 mFormat = factory->format( mFormatName ); 350 mFormat = factory->format( mFormatName );
349/*US 351/*US
350//qDebug("ResourceFile::setFormat initialized with format %s ", format.latin1()); 352//qDebug("ResourceFile::setFormat initialized with format %s ", format.latin1());
@@ -361,3 +363,3 @@ void ResourceFile::setFormat( const QString &format )
361*/ 363*/
362 364
363} 365}
@@ -375,4 +377,4 @@ void ResourceFile::fileChanged()
375 return; 377 return;
376 378
377 379
378 QString text( i18n( "File resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) ); 380 QString text( i18n( "File resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) );
diff --git a/kabc/plugins/file/resourcefile.h b/kabc/plugins/file/resourcefile.h
index 4522d78..0a3027c 100644
--- a/kabc/plugins/file/resourcefile.h
+++ b/kabc/plugins/file/resourcefile.h
@@ -60,3 +60,3 @@ public:
60 */ 60 */
61 ResourceFile( const KConfig *cfg ); 61 ResourceFile( const KConfig *cfg, bool syncable );
62 62
@@ -65,3 +65,3 @@ public:
65 */ 65 */
66 ResourceFile( const QString &fileName, const QString &formatName = "vcard" ); 66 ResourceFile( const QString &fileName, bool syncable , const QString &formatName = "vcard" );
67 67
@@ -87,3 +87,3 @@ public:
87 virtual void doClose(); 87 virtual void doClose();
88 88
89 /** 89 /**
@@ -155,3 +155,3 @@ private:
155 QString mLockUniqueName; 155 QString mLockUniqueName;
156 156
157 KDirWatch mDirWatch; 157 KDirWatch mDirWatch;
diff --git a/kabc/plugins/ldap/ldapE.pro b/kabc/plugins/ldap/ldapE.pro
index f6ca586..2e79fc0 100644
--- a/kabc/plugins/ldap/ldapE.pro
+++ b/kabc/plugins/ldap/ldapE.pro
@@ -5,3 +5,3 @@ CONFIG += qt warn_on release
5TARGET = microkabc_ldap 5TARGET = microkabc_ldap
6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat $(QPEDIR)/include 6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kresources ../../../qtcompat $(QPEDIR)/include
7OBJECTS_DIR = obj/$(PLATFORM) 7OBJECTS_DIR = obj/$(PLATFORM)
diff --git a/kabc/plugins/ldap/resourceldap.cpp b/kabc/plugins/ldap/resourceldap.cpp
index 55c43af..4b9dede 100644
--- a/kabc/plugins/ldap/resourceldap.cpp
+++ b/kabc/plugins/ldap/resourceldap.cpp
@@ -38,2 +38,3 @@ $Id$
38#include "resourceldapconfig.h" 38#include "resourceldapconfig.h"
39#include "syncwidget.h"
39 40
@@ -46,3 +47,3 @@ extern "C"
46 { 47 {
47 return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig>(); 48 return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig, KRES::SyncWidget>();
48 } 49 }
@@ -53,4 +54,4 @@ void addModOp( LDAPMod ***pmods, const QString &attr, const QString &value );
53 54
54ResourceLDAP::ResourceLDAP( const KConfig *config ) 55ResourceLDAP::ResourceLDAP( const KConfig *config, bool syncable )
55 : Resource( config ), mPort( 389 ), mLdap( 0 ) 56 : Resource( config, syncable ), mPort( 389 ), mLdap( 0 )
56{ 57{
diff --git a/kabc/plugins/ldap/resourceldap.h b/kabc/plugins/ldap/resourceldap.h
index 0625f30..0aad3c1 100644
--- a/kabc/plugins/ldap/resourceldap.h
+++ b/kabc/plugins/ldap/resourceldap.h
@@ -45,3 +45,3 @@ public:
45 45
46 ResourceLDAP( const KConfig* ); 46 ResourceLDAP( const KConfig*, bool syncable );
47 47
diff --git a/kabc/plugins/opie/opieE.pro b/kabc/plugins/opie/opieE.pro
index 8d45c3d..912e596 100644
--- a/kabc/plugins/opie/opieE.pro
+++ b/kabc/plugins/opie/opieE.pro
@@ -5,3 +5,3 @@ TARGET = microkabc_opie
5 5
6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat $(QPEDIR)/include $(OPIEDIR)/include 6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat $(QPEDIR)/include $(OPIEDIR)/include
7 7
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp
index aaee801..1222242 100644
--- a/kabc/plugins/opie/resourceopie.cpp
+++ b/kabc/plugins/opie/resourceopie.cpp
@@ -52,2 +52,3 @@ $Id$
52#include "stdaddressbook.h" 52#include "stdaddressbook.h"
53#include "syncwidget.h"
53 54
@@ -62,3 +63,3 @@ extern "C"
62 { 63 {
63 return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig>(); 64 return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig, KRES::SyncWidget>();
64 } 65 }
@@ -66,4 +67,4 @@ extern "C"
66 67
67ResourceOpie::ResourceOpie( const KConfig *config ) 68ResourceOpie::ResourceOpie( const KConfig *config, bool syncable )
68 : Resource( config ), mConverter (0) 69 : Resource( config, syncable ), mAccess(0), mConverter (0)
69{ 70{
@@ -74,3 +75,3 @@ ResourceOpie::ResourceOpie( const KConfig *config )
74 fileName = cfg->readEntry( "FileName", fileName ); 75 fileName = cfg->readEntry( "FileName", fileName );
75 76
76 } 77 }
@@ -78,3 +79,3 @@ ResourceOpie::ResourceOpie( const KConfig *config )
78// qDebug("ResourceOpie::ResourceOpie : %s", fileName.latin1() ); 79// qDebug("ResourceOpie::ResourceOpie : %s", fileName.latin1() );
79 80
80 init( fileName ); 81 init( fileName );
@@ -82,4 +83,4 @@ ResourceOpie::ResourceOpie( const KConfig *config )
82 83
83ResourceOpie::ResourceOpie( const QString &fileName ) 84ResourceOpie::ResourceOpie( const QString &fileName, bool syncable )
84 : Resource( 0 ) 85 : Resource( 0, syncable )
85{ 86{
@@ -95,6 +96,6 @@ void ResourceOpie::init( const QString &fileName )
95 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 96 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
96 97
97 98
98 setFileName( fileName ); 99 setFileName( fileName );
99 100
100} 101}
@@ -105,2 +106,6 @@ ResourceOpie::~ResourceOpie()
105 delete mConverter; 106 delete mConverter;
107
108 if(mAccess != 0)
109 delete mAccess;
110
106} 111}
@@ -111,6 +116,3 @@ void ResourceOpie::writeConfig( KConfig *config )
111 116
112 config->writeEntry( "FileName", mFileName ); 117 config->writeEntry( "FileName", fileName() );
113
114// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
115
116} 118}
@@ -121,7 +123,9 @@ Ticket *ResourceOpie::requestSaveTicket()
121 123
124 qDebug("ResourceOpie::requestSaveTicket: %s", fileName().latin1());
125
122 if ( !addressBook() ) return 0; 126 if ( !addressBook() ) return 0;
123 127
124 if ( !lock( mFileName ) ) { 128 if ( !lock( fileName() ) ) {
125 kdDebug(5700) << "ResourceOpie::requestSaveTicket(): Unable to lock file '" 129 kdDebug(5700) << "ResourceOpie::requestSaveTicket(): Unable to lock file '"
126 << mFileName << "'" << endl; 130 << fileName() << "'" << endl;
127 return 0; 131 return 0;
@@ -134,58 +138,15 @@ bool ResourceOpie::doOpen()
134{ 138{
135// qDebug("ResourceOpie::doOpen() %s", mFileName.latin1()); 139 qDebug("ResourceOpie::doOpen: %s", fileName().latin1());
136/*US
137 QFile file( mFileName );
138
139 if ( !file.exists() ) {
140 // try to create the file
141 bool ok = file.open( IO_WriteOnly );
142 if ( ok )
143 file.close();
144
145 return ok;
146 } else {
147 if ( !file.open( IO_ReadWrite ) )
148 return false;
149
150 if ( file.size() == 0 ) {
151 file.close();
152 return true;
153 }
154 140
155//US bool ok = mFormat->checkFormat( &file ); 141 OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", fileName() );
156 bool ok = true; 142 mAccess = new OContactAccess("KDEPim/Pi", 0l, backend, false);
157
158 file.close();
159 143
160 return ok; 144 if ( !mAccess ) {
145 qDebug("Unable to load file() %s", fileName().latin1());
146 return false;
161 } 147 }
162*/
163 qDebug("ResourceOpie::doOpen() has to be fixed - %s", mFileName.latin1());
164 return true;
165}
166 148
167void ResourceOpie::doClose() 149 mAccess->setReadAhead( 32 ); // Use ReadAhead-Cache if available
168{
169// qDebug("ResourceOpie::doClose() %s", mFileName.latin1());
170}
171 150
172bool ResourceOpie::load()
173{
174// qDebug("ResourceOpie::load() %s", mFileName.latin1());
175 kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl;
176
177 qDebug("ResourceOpie::load: Try to load file() %s", mFileName.latin1());
178
179 OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", mFileName );
180 OContactAccess* access = new OContactAccess("KDEPim/Pi", 0l, backend, false);
181
182 if ( !access ) {
183 qDebug("Unable to load file() %s", mFileName.latin1());
184 addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) );
185 return false;
186 }
187
188 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available
189 151
190 bool res = false;
191 if (mConverter == 0) 152 if (mConverter == 0)
@@ -193,3 +154,3 @@ bool ResourceOpie::load()
193 mConverter = new OpieConverter(); 154 mConverter = new OpieConverter();
194 res = mConverter->init(); 155 bool res = mConverter->init();
195 if ( !res ) 156 if ( !res )
@@ -197,4 +158,4 @@ bool ResourceOpie::load()
197 qDebug("Unable to initialize opie converter. Most likely a problem with the category file"); 158 qDebug("Unable to initialize opie converter. Most likely a problem with the category file");
198 addressBook()->error( i18n( "Unable to initialize opie converter. Most likely a problem with the category file" ) ); 159 delete mAccess;
199 delete access; 160 mAccess = 0;
200 return false; 161 return false;
@@ -204,4 +165,31 @@ bool ResourceOpie::load()
204 165
205 OContactAccess::List::Iterator it; 166
206 OContactAccess::List allList = access->allRecords(); 167 return true;
168}
169
170void ResourceOpie::doClose()
171{
172 qDebug("ResourceOpie::doClose: %s", fileName().latin1());
173
174 if(mAccess)
175 {
176 delete mAccess;
177 mAccess = 0;
178 }
179 // it seems so, that deletion of access deletes backend as well
180 //delete backend;
181
182 return;
183
184}
185
186
187bool ResourceOpie::load()
188{
189 qDebug("ResourceOpie::load: %s", fileName().latin1());
190
191 bool res = false;
192
193 OContactAccess::List::Iterator it;
194 OContactAccess::List allList = mAccess->allRecords();
207 for ( it = allList.begin(); it != allList.end(); ++it ) 195 for ( it = allList.begin(); it != allList.end(); ++it )
@@ -209,7 +197,7 @@ bool ResourceOpie::load()
209 const OContact c = (*it); 197 const OContact c = (*it);
210 198
211 KABC::Addressee addressee; 199 KABC::Addressee addressee;
212 200
213 res = mConverter->opieToAddressee( c, addressee ); 201 res = mConverter->opieToAddressee( c, addressee );
214 202
215 if ( !addressee.isEmpty() && res ) 203 if ( !addressee.isEmpty() && res )
@@ -219,10 +207,6 @@ bool ResourceOpie::load()
219 } 207 }
220 208
221// qDebug("found %s", c.fullName().latin1());
222 } 209 }
223 210
224 delete access; 211
225 // it seems so, that deletion of access deletes backend as well
226 //delete backend;
227
228 return true; 212 return true;
@@ -232,55 +216,40 @@ bool ResourceOpie::save( Ticket *ticket )
232{ 216{
233 qDebug("ResourceOpie::save() has to be fixed - %s", mFileName.latin1()); 217 qDebug("ResourceOpie::save: %s", fileName().latin1());
234/*US 218
235 219
236 qDebug("ResourceOpie::save %s", mFileName.latin1()); 220
237 kdDebug(5700) << "ResourceOpie::save()" << endl; 221 KABC::AddressBook::Iterator it;
238 222 bool res;
239 // create backup file 223
240 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); 224 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
241*/ 225 OContact c;
242/*US we use a simpler method to create a backupfile 226 KABC::Addressee addressee = (*it);
243 227
244 (void) KSaveFile::backupFile( mFileName, QString::null 228 res = mConverter->addresseeToOpie( *it, c );
245 ,extension ); 229 if (res == true)
246 230 {
247 KSaveFile saveFile( mFileName ); 231 res = mAccess->add(c);
248 bool ok = false; 232 if (res == false)
249 if ( saveFile.status() == 0 && saveFile.file() ) 233 qDebug("Unable to append Contact %s", c.fullName().latin1());
250 { 234 }
251 mFormat->saveAll( addressBook(), this, saveFile.file() ); 235 else
252 ok = saveFile.close(); 236 {
253 } 237 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1());
254*/ 238 }
255/*US
256//US ToDo: write backupfile
257 QFile info;
258 info.setName( mFileName );
259 bool ok = info.open( IO_WriteOnly );
260 if ( ok ) {
261//US mFormat->saveAll( addressBook(), this, &info );
262
263 info.close();
264 ok = true;
265 }
266 else {
267
268 } 239 }
269 240
270 if ( !ok ) 241 mAccess->save();
271 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); 242
272
273 delete ticket; 243 delete ticket;
274 unlock( mFileName ); 244 unlock( fileName() );
275
276 return ok;
277 245
278 qDebug("ResourceOpie::save has to be changed");
279*/
280 return true; 246 return true;
281 247
282} 248}
283 249
284bool ResourceOpie::lock( const QString &fileName ) 250bool ResourceOpie::lock( const QString &lockfileName )
285{ 251{
252 qDebug("ResourceOpie::lock: %s", fileName().latin1());
253
254
286// qDebug("ResourceOpie::lock() %s", fileName.latin1()); 255// qDebug("ResourceOpie::lock() %s", fileName.latin1());
@@ -288,3 +257,3 @@ bool ResourceOpie::lock( const QString &fileName )
288 257
289 QString fn = fileName; 258 QString fn = lockfileName;
290 259
@@ -293,6 +262,6 @@ bool ResourceOpie::lock( const QString &fileName )
293//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); 262//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
294 263
295 KURL url(fn); 264 KURL url(fn);
296 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 265 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
297 266
298 kdDebug(5700) << "-- lock name: " << lockName << endl; 267 kdDebug(5700) << "-- lock name: " << lockName << endl;
@@ -303,4 +272,4 @@ bool ResourceOpie::lock( const QString &fileName )
303 lockUniqueName = fn + KApplication::randomString( 8 ); 272 lockUniqueName = fn + KApplication::randomString( 8 );
304 273
305 url = lockUniqueName; 274 url = lockUniqueName;
306//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 275//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
@@ -332,4 +301,4 @@ void ResourceOpie::unlock( const QString &fileName )
332{ 301{
333// qDebug("ResourceOpie::unlock() %s", fileName.latin1()); 302 qDebug("ResourceOpie::unlock() %s", fileName.latin1());
334 303
335 QString fn = fileName; 304 QString fn = fileName;
@@ -339,5 +308,5 @@ void ResourceOpie::unlock( const QString &fileName )
339//US QString lockName = fn + ".lock"; 308//US QString lockName = fn + ".lock";
340 KURL url(fn); 309 KURL url(fn);
341 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 310 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
342 311
343 QFile::remove( lockName ); 312 QFile::remove( lockName );
@@ -347,20 +316,14 @@ void ResourceOpie::unlock( const QString &fileName )
347 316
348void ResourceOpie::setFileName( const QString &fileName ) 317void ResourceOpie::setFileName( const QString &newFileName )
349{ 318{
350 mDirWatch.stopScan(); 319 mDirWatch.stopScan();
351 mDirWatch.removeFile( mFileName ); 320 mDirWatch.removeFile( fileName() );
352 321
353 mFileName = fileName; 322 Resource::setFileName( newFileName );
354 323
355 mDirWatch.addFile( mFileName ); 324 mDirWatch.addFile( fileName() );
356 mDirWatch.startScan(); 325 mDirWatch.startScan();
357 326
358//US simulate KDirWatch event
359//US fileChanged();
360} 327}
361 328
362QString ResourceOpie::fileName() const
363{
364 return mFileName;
365}
366 329
@@ -372,4 +335,4 @@ void ResourceOpie::fileChanged()
372 return; 335 return;
373 336
374 QString text( i18n( "Opie resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) ); 337 QString text( i18n( "Opie resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) );
375 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { 338 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) {
@@ -378,3 +341,3 @@ void ResourceOpie::fileChanged()
378 } 341 }
379 342
380 load(); 343 load();
@@ -391,5 +354,38 @@ void ResourceOpie::cleanUp()
391 354
392 unlock( mFileName ); 355 unlock( fileName() );
356}
357
358
359/**
360 * This method returns the number of elements that are currently in the resource.
361 */
362int ResourceOpie::count() const
363{
364 qDebug("ResourceOpie::count: %x", mAccess);
365
366 if (mAccess != 0)
367 {
368 OContactAccess::List contactList = mAccess->allRecords();
369 return contactList.count();
370 }
371 else
372 return 0;
373}
374
375
376/**
377 * This method removes all elements from the resource!! (Not from the addressbook)
378 */
379bool ResourceOpie::clear()
380{
381 if (mAccess != 0) {
382 mAccess->clear();
383 return true;
384 }
385 else
386 return false;
393} 387}
394 388
389
390
395//US #include "resourceopie.moc" 391//US #include "resourceopie.moc"
diff --git a/kabc/plugins/opie/resourceopie.h b/kabc/plugins/opie/resourceopie.h
index 9db9485..ca30fee 100644
--- a/kabc/plugins/opie/resourceopie.h
+++ b/kabc/plugins/opie/resourceopie.h
@@ -39,4 +39,3 @@ $Id$
39 39
40//class QTimer; 40class OContactAccess;
41//class FormatPlugin;
42 41
@@ -44,3 +43,2 @@ namespace KABC {
44 43
45//US class FormatPlugin;
46class ResourceConfigWidget; 44class ResourceConfigWidget;
@@ -61,3 +59,3 @@ public:
61 */ 59 */
62 ResourceOpie( const KConfig *cfg ); 60 ResourceOpie( const KConfig *cfg, bool syncable );
63 61
@@ -66,3 +64,3 @@ public:
66 */ 64 */
67 ResourceOpie( const QString &fileName ); 65 ResourceOpie( const QString &fileName, bool syncable );
68 66
@@ -88,3 +86,3 @@ public:
88 virtual void doClose(); 86 virtual void doClose();
89 87
90 /** 88 /**
@@ -108,11 +106,2 @@ public:
108 106
109 /**
110 * Set name of file to be used for saving.
111 */
112 void setFileName( const QString & );
113
114 /**
115 * Return name of file used for loading and saving the address book.
116 */
117 QString fileName() const;
118 107
@@ -125,2 +114,7 @@ public:
125 /** 114 /**
115 * Set name of file to be used for saving.
116 */
117 virtual void setFileName( const QString & );
118
119 /**
126 * This method is called by an error handler if the application 120 * This method is called by an error handler if the application
@@ -130,2 +124,13 @@ public:
130 124
125 /**
126 * This method returns the number of elements that are currently in the resource.
127 */
128 virtual int count() const;
129
130 /**
131 * This method removes all elements from the resource!! (Not from the addressbook)
132 */
133 virtual bool clear();
134
135
131protected slots: 136protected slots:
@@ -140,8 +145,7 @@ protected:
140private: 145private:
146 OContactAccess* mAccess;
141 OpieConverter* mConverter; 147 OpieConverter* mConverter;
142
143 QString mFileName;
144 148
145 QString mLockUniqueName; 149 QString mLockUniqueName;
146 150
147 KDirWatch mDirWatch; 151 KDirWatch mDirWatch;
diff --git a/kabc/plugins/qtopia/qtopiaE.pro b/kabc/plugins/qtopia/qtopiaE.pro
index 56eae87..d956519 100644
--- a/kabc/plugins/qtopia/qtopiaE.pro
+++ b/kabc/plugins/qtopia/qtopiaE.pro
@@ -5,3 +5,3 @@ TARGET = microkabc_qtopia
5 5
6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat $(QPEDIR)/include 6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat $(QPEDIR)/include
7 7
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index 7e10e46..dc88272 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -51,2 +51,3 @@ $Id$
51#include "qtopiaconverter.h" 51#include "qtopiaconverter.h"
52#include "syncwidget.h"
52 53
@@ -59,3 +60,3 @@ extern "C"
59 { 60 {
60 return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig>(); 61 return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, KRES::SyncWidget>();
61 } 62 }
@@ -63,4 +64,4 @@ extern "C"
63 64
64ResourceQtopia::ResourceQtopia( const KConfig *config ) 65ResourceQtopia::ResourceQtopia( const KConfig *config, bool syncable )
65 : Resource( config ), mConverter (0) 66 : Resource( config, syncable ), mConverter (0)
66{ 67{
@@ -72,4 +73,4 @@ ResourceQtopia::ResourceQtopia( const KConfig *config )
72 73
73ResourceQtopia::ResourceQtopia( const QString &fileName ) 74ResourceQtopia::ResourceQtopia( const QString &fileName, bool syncable )
74 : Resource( 0 ) 75 : Resource( 0, syncable )
75{ 76{
@@ -94,2 +95,4 @@ ResourceQtopia::~ResourceQtopia()
94 95
96 if(mAccess != 0)
97 delete mAccess;
95} 98}
@@ -107,5 +110,5 @@ Ticket *ResourceQtopia::requestSaveTicket()
107 110
108 if ( !lock( mFileName ) ) { 111 if ( !lock( fileName() ) ) {
109 kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '" 112 kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '"
110 << mFileName << "'" << endl; 113 << fileName() << "'" << endl;
111 return 0; 114 return 0;
@@ -118,47 +121,8 @@ bool ResourceQtopia::doOpen()
118{ 121{
119/*US 122 qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1());
120 QFile file( mFileName );
121
122 if ( !file.exists() ) {
123 // try to create the file
124 bool ok = file.open( IO_WriteOnly );
125 if ( ok )
126 file.close();
127
128 return ok;
129 } else {
130 if ( !file.open( IO_ReadWrite ) )
131 return false;
132
133 if ( file.size() == 0 ) {
134 file.close();
135 return true;
136 }
137
138//US bool ok = mFormat->checkFormat( &file );
139 bool ok = true;
140
141 file.close();
142
143 return ok;
144 }
145*/
146 return true;
147}
148
149void ResourceQtopia::doClose()
150{
151}
152 123
153bool ResourceQtopia::load() 124 mAccess = new AddressBookAccess();
154{
155 kdDebug(5700) << "ResourceQtopia::load(): '" << mFileName << "'" << endl;
156
157// qDebug("ResourceQtopia::load: Try to load file() %s", mFileName.latin1());
158 125
159 AddressBookAccess* access = new AddressBookAccess(); 126 if ( !mAccess ) {
160 127 qDebug("Unable to load file() %s", fileName().latin1());
161 if ( !access ) {
162 qDebug("Unable to load file() %s", mFileName.latin1());
163 addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) );
164 return false; 128 return false;
@@ -175,4 +139,4 @@ bool ResourceQtopia::load()
175 qDebug(msg); 139 qDebug(msg);
176 addressBook()->error( i18n( msg ) ); 140 delete mAccess;
177 delete access; 141 mAccess = 0;
178 return false; 142 return false;
@@ -181,18 +145,40 @@ bool ResourceQtopia::load()
181 145
182 { //create a new scope 146 return true;
183 AddressBookIterator it(*access); 147}
184 const PimContact* contact;
185 148
186 for (contact=it.toFirst(); it.current(); ++it) { 149void ResourceQtopia::doClose()
187 contact = it.current(); 150{
151 qDebug("ResourceQtopia::doClose: %s", fileName().latin1());
188 152
189 KABC::Addressee addressee; 153 if(mAccess)
154 {
155 delete mAccess;
156 mAccess = 0;
157 }
158 // it seems so, that deletion of access deletes backend as well
159 //delete backend;
160
161 return;
162}
163
164bool ResourceQtopia::load()
165{
166 qDebug("ResourceQtopia::load: %s", fileName().latin1());
190 167
191 res = mConverter->qtopiaToAddressee( (*contact), addressee ); 168 AddressBookIterator it(*mAccess);
169 const PimContact* contact;
170 bool res;
171
172 for (contact=it.toFirst(); it.current(); ++it)
173 {
174 contact = it.current();
192 175
193 if ( !addressee.isEmpty() && res ) 176 KABC::Addressee addressee;
194 { 177
195 addressee.setResource( this ); 178 res = mConverter->qtopiaToAddressee( (*contact), addressee );
196 addressBook()->insertAddressee( addressee ); 179
197 } 180 if ( !addressee.isEmpty() && res )
181 {
182 addressee.setResource( this );
183 addressBook()->insertAddressee( addressee );
198 } 184 }
@@ -200,3 +186,2 @@ bool ResourceQtopia::load()
200 186
201 delete access;
202 return true; 187 return true;
@@ -251,3 +236,8 @@ bool ResourceQtopia::save( Ticket *ticket )
251 qDebug("ResourceQtopia::save has to be changed"); 236 qDebug("ResourceQtopia::save has to be changed");
237
238
239 access->save();
240
252*/ 241*/
242
253 return true; 243 return true;
@@ -314,20 +304,13 @@ void ResourceQtopia::unlock( const QString &fileName )
314 304
315void ResourceQtopia::setFileName( const QString &fileName ) 305void ResourceQtopia::setFileName( const QString &newFileName )
316{ 306{
317 mDirWatch.stopScan(); 307 mDirWatch.stopScan();
318 mDirWatch.removeFile( mFileName ); 308 mDirWatch.removeFile( fileName() );
319 309
320 mFileName = fileName; 310 Resource::setFileName( newFileName );
321 311
322 mDirWatch.addFile( mFileName ); 312 mDirWatch.addFile( fileName() );
323 mDirWatch.startScan(); 313 mDirWatch.startScan();
324
325//US simulate KDirWatch event
326//US fileChanged();
327} 314}
328 315
329QString ResourceQtopia::fileName() const
330{
331 return mFileName;
332}
333 316
@@ -340,3 +323,3 @@ void ResourceQtopia::fileChanged()
340 323
341 QString text( i18n( "Qtopia resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) ); 324 QString text( i18n( "Qtopia resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) );
342 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { 325 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) {
@@ -353,5 +336,48 @@ void ResourceQtopia::cleanUp()
353{ 336{
354 unlock( mFileName ); 337 unlock( fileName() );
355} 338}
356 339
340
341
342/**
343 * This method returns the number of elements that are currently in the resource.
344 */
345int ResourceQtopia::count() const
346{
347 if (mAccess != 0)
348 {
349 int counter = 0;
350 AddressBookIterator it2(*mAccess);
351 for (it2.toFirst(); it2.current(); ++it2) {
352 counter++;
353 }
354
355 return counter;
356 }
357 else
358 return 0;
359}
360
361
362/**
363 * This method removes all elements from the resource!! (Not from the addressbook)
364 */
365bool ResourceQtopia::clear()
366{
367 if (mAccess != 0)
368 {
369 AddressBookIterator it2(*mAccess);
370 for (it2.toFirst(); it2.current(); ++it2) {
371 mAccess->removeContact(*it2.current());
372 }
373 return true;
374 }
375 else
376 return false;
377}
378
379
380
381
382
357//US #include "resourceqtopia.moc" 383//US #include "resourceqtopia.moc"
diff --git a/kabc/plugins/qtopia/resourceqtopia.h b/kabc/plugins/qtopia/resourceqtopia.h
index bf9dd45..90ab1f4 100644
--- a/kabc/plugins/qtopia/resourceqtopia.h
+++ b/kabc/plugins/qtopia/resourceqtopia.h
@@ -38,2 +38,3 @@ $Id$
38 38
39class AddressBookAccess;
39 40
@@ -59,3 +60,3 @@ public:
59 */ 60 */
60 ResourceQtopia( const KConfig *cfg ); 61 ResourceQtopia( const KConfig *cfg, bool syncable );
61 62
@@ -64,3 +65,3 @@ public:
64 */ 65 */
65 ResourceQtopia( const QString &fileName ); 66 ResourceQtopia( const QString &fileName, bool syncable );
66 67
@@ -86,3 +87,3 @@ public:
86 virtual void doClose(); 87 virtual void doClose();
87 88
88 /** 89 /**
@@ -107,22 +108,27 @@ public:
107 /** 108 /**
109 * Remove a addressee from its source.
110 * This method is mainly called by KABC::AddressBook.
111 */
112 virtual void removeAddressee( const Addressee& addr );
113
114 /**
108 * Set name of file to be used for saving. 115 * Set name of file to be used for saving.
109 */ 116 */
110 void setFileName( const QString & ); 117 virtual void setFileName( const QString & );
111 118
112 /** 119 /**
113 * Return name of file used for loading and saving the address book. 120 * This method is called by an error handler if the application
121 * crashed
114 */ 122 */
115 QString fileName() const; 123 virtual void cleanUp();
116 124
117 /** 125 /**
118 * Remove a addressee from its source. 126 * This method returns the number of elements that are currently in the resource.
119 * This method is mainly called by KABC::AddressBook.
120 */ 127 */
121 virtual void removeAddressee( const Addressee& addr ); 128 virtual int count() const;
122 129
123 /** 130 /**
124 * This method is called by an error handler if the application 131 * This method removes all elements from the resource!! (Not from the addressbook)
125 * crashed
126 */ 132 */
127 virtual void cleanUp(); 133 virtual bool clear();
128 134
@@ -138,8 +144,7 @@ protected:
138private: 144private:
145 AddressBookAccess* mAccess;
139 QtopiaConverter* mConverter; 146 QtopiaConverter* mConverter;
140
141 QString mFileName;
142 147
143 QString mLockUniqueName; 148 QString mLockUniqueName;
144 149
145 KDirWatch mDirWatch; 150 KDirWatch mDirWatch;
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
index 31b99ca..7b909de 100644
--- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
+++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
@@ -2,3 +2,3 @@
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2004 Ulf Schenk
4 4
@@ -64,4 +64,4 @@ extern "C"
64 64
65ResourceSharpDTM::ResourceSharpDTM( const KConfig *config ) 65ResourceSharpDTM::ResourceSharpDTM( const KConfig *config, bool syncable )
66 : Resource( config ), mConverter (0) 66 : Resource( config, syncable ), mConverter (0)
67{ 67{
@@ -73,4 +73,4 @@ ResourceSharpDTM::ResourceSharpDTM( const KConfig *config )
73 73
74ResourceSharpDTM::ResourceSharpDTM( const QString &fileName ) 74ResourceSharpDTM::ResourceSharpDTM( const QString &fileName, bool syncable )
75 : Resource( 0 ) 75 : Resource( 0, syncable )
76{ 76{
@@ -357 +357,26 @@ void ResourceSharpDTM::cleanUp()
357 357
358/**
359 * This method returns the number of elements that are currently in the resource.
360 */
361int ResourceSharpDTM::count() const
362{
363 if (mAccess != 0)
364 return mAccess->count();
365 else
366 return 0;
367}
368
369
370/**
371 * This method removes all elements from the resource!! (Not from the addressbook)
372 */
373bool ResourceSharpDTM::clear()
374{
375 if (mAccess != 0)
376 return mAccess->deleteCard(0, SlZDataBase::AllCard );
377 else
378 return false;
379}
380
381
382
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.h b/kabc/plugins/sharpdtm/resourcesharpdtm.h
index d2e2a52..f495e9d 100644
--- a/kabc/plugins/sharpdtm/resourcesharpdtm.h
+++ b/kabc/plugins/sharpdtm/resourcesharpdtm.h
@@ -2,3 +2,3 @@
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2004 Ulf Schenk
4 4
@@ -58,3 +58,3 @@ public:
58 */ 58 */
59 ResourceSharpDTM( const KConfig *cfg ); 59 ResourceSharpDTM( const KConfig *cfg, bool syncable );
60 60
@@ -63,3 +63,3 @@ public:
63 */ 63 */
64 ResourceSharpDTM( const QString &fileName ); 64 ResourceSharpDTM( const QString &fileName, bool syncable );
65 65
@@ -106,22 +106,28 @@ public:
106 /** 106 /**
107 * Remove a addressee from its source.
108 * This method is mainly called by KABC::AddressBook.
109 */
110 virtual void removeAddressee( const Addressee& addr );
111
112 /**
107 * Set name of file to be used for saving. 113 * Set name of file to be used for saving.
108 */ 114 */
109 void setFileName( const QString & ); 115 virtual void setFileName( const QString & );
110 116
111 /** 117 /**
112 * Return name of file used for loading and saving the address book. 118 * This method is called by an error handler if the application
119 * crashed
113 */ 120 */
114 QString fileName() const; 121 virtual void cleanUp();
115 122
116 /** 123 /**
117 * Remove a addressee from its source. 124 * This method returns the number of elements that are currently in the resource.
118 * This method is mainly called by KABC::AddressBook.
119 */ 125 */
120 virtual void removeAddressee( const Addressee& addr ); 126 virtual int count() const;
121 127
122 /** 128 /**
123 * This method is called by an error handler if the application 129 * This method removes all elements from the resource!! (Not from the addressbook)
124 * crashed
125 */ 130 */
126 virtual void cleanUp(); 131 virtual bool clear();
132
127 133
@@ -139,4 +145,2 @@ private:
139 145
140 QString mFileName;
141
142 QString mLockUniqueName; 146 QString mLockUniqueName;
diff --git a/kabc/plugins/sharpdtm/sharpdtmE.pro b/kabc/plugins/sharpdtm/sharpdtmE.pro
index 54ef083..52bc10f 100644
--- a/kabc/plugins/sharpdtm/sharpdtmE.pro
+++ b/kabc/plugins/sharpdtm/sharpdtmE.pro
@@ -4,3 +4,3 @@ TARGET = microkabc_sharpdtm
4 4
5INCLUDEPATH += ../.. $(SHARPDTMSDK)/include ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat $(QPEDIR)/include 5INCLUDEPATH += ../.. $(SHARPDTMSDK)/include ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat $(QPEDIR)/include
6 6