summaryrefslogtreecommitdiffabout
path: root/kabc/plugins
Unidiff
Diffstat (limited to 'kabc/plugins') (more/less context) (show 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.cpp7
-rw-r--r--kabc/plugins/dir/resourcedir.h2
-rw-r--r--kabc/plugins/file/file.pro2
-rw-r--r--kabc/plugins/file/fileE.pro2
-rw-r--r--kabc/plugins/file/resourcefile.cpp12
-rw-r--r--kabc/plugins/file/resourcefile.h4
-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.cpp224
-rw-r--r--kabc/plugins/opie/resourceopie.h36
-rw-r--r--kabc/plugins/qtopia/qtopiaE.pro2
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp166
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.h31
-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, 319 insertions, 255 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
@@ -3,7 +3,7 @@ CONFIG += qt warn_on release
3#release debug 3#release debug
4 4
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
8#LIBS += -lmicrokde -lmicrokabc 8#LIBS += -lmicrokde -lmicrokabc
9#LIBS += -L$(QPEDIR)/lib 9#LIBS += -L$(QPEDIR)/lib
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
@@ -3,7 +3,7 @@ CONFIG += qt warn_on release
3#release debug 3#release debug
4 4
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)
8MOC_DIR = moc/$(PLATFORM) 8MOC_DIR = moc/$(PLATFORM)
9DESTDIR = $(QPEDIR)/lib 9DESTDIR = $(QPEDIR)/lib
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
@@ -57,6 +57,7 @@ $Id$
57#include <qdir.h> 57#include <qdir.h>
58 58
59#include "resourcedir.h" 59#include "resourcedir.h"
60#include "syncwidget.h"
60 61
61using namespace KABC; 62using namespace KABC;
62 63
@@ -70,14 +71,14 @@ __declspec(dllexport)
70//US void *init_kabc_dir() 71//US void *init_kabc_dir()
71 void *init_microkabc_dir() 72 void *init_microkabc_dir()
72 { 73 {
73 return new KRES::PluginFactory<ResourceDir,ResourceDirConfig>(); 74 return new KRES::PluginFactory<ResourceDir,ResourceDirConfig, KRES::SyncWidget>();
74 } 75 }
75#ifndef _WIN32_ 76#ifndef _WIN32_
76} 77}
77#endif 78#endif
78 79
79ResourceDir::ResourceDir( const KConfig *config ) 80ResourceDir::ResourceDir( const KConfig *config, bool syncable )
80 : Resource( config ) 81 : Resource( config, syncable )
81{ 82{
82 QString path; 83 QString path;
83 84
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
@@ -49,7 +49,7 @@ class ResourceDir : public Resource
49 Q_OBJECT 49 Q_OBJECT
50 50
51public: 51public:
52 ResourceDir( const KConfig* ); 52 ResourceDir( const KConfig*, bool syncable );
53 ~ResourceDir(); 53 ~ResourceDir();
54 54
55 virtual void writeConfig( KConfig* ); 55 virtual void writeConfig( KConfig* );
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
@@ -3,7 +3,7 @@ CONFIG += qt warn_on release
3#release debug 3#release debug
4 4
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
8DESTDIR = ../../../bin 8DESTDIR = ../../../bin
9#LIBS += -lmicrokde -lmicrokabc 9#LIBS += -lmicrokde -lmicrokabc
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
@@ -3,7 +3,7 @@ CONFIG += qt warn_on release
3#release debug 3#release debug
4 4
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)
8MOC_DIR = moc/$(PLATFORM) 8MOC_DIR = moc/$(PLATFORM)
9DESTDIR = $(QPEDIR)/lib 9DESTDIR = $(QPEDIR)/lib
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
@@ -51,6 +51,8 @@ $Id$
51#include "stdaddressbook.h" 51#include "stdaddressbook.h"
52 52
53#include "resourcefile.h" 53#include "resourcefile.h"
54#include "syncwidget.h"
55
54 56
55using namespace KABC; 57using namespace KABC;
56 58
@@ -64,14 +66,14 @@ __declspec(dllexport)
64//US void *init_kabc_file() 66//US void *init_kabc_file()
65 void *init_microkabc_file() 67 void *init_microkabc_file()
66 { 68 {
67 return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>(); 69 return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, KRES::SyncWidget>();
68 } 70 }
69#ifndef _WIN32_ 71#ifndef _WIN32_
70} 72}
71#endif 73#endif
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{
76 QString fileName, formatName; 78 QString fileName, formatName;
77 79
@@ -89,9 +91,9 @@ ResourceFile::ResourceFile( const KConfig *config )
89 init( fileName, formatName ); 91 init( fileName, formatName );
90} 92}
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{
96// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); 98// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1());
97 init( fileName, formatName ); 99 init( fileName, formatName );
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
@@ -58,12 +58,12 @@ public:
58 58
59 @param cfg The config object where custom resource settings are stored. 59 @param cfg The config object where custom resource settings are stored.
60 */ 60 */
61 ResourceFile( const KConfig *cfg ); 61 ResourceFile( const KConfig *cfg, bool syncable );
62 62
63 /** 63 /**
64 Construct file resource on file @arg fileName using format @arg formatName. 64 Construct file resource on file @arg fileName using format @arg formatName.
65 */ 65 */
66 ResourceFile( const QString &fileName, const QString &formatName = "vcard" ); 66 ResourceFile( const QString &fileName, bool syncable , const QString &formatName = "vcard" );
67 67
68 /** 68 /**
69 * Destructor. 69 * Destructor.
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
@@ -3,7 +3,7 @@ CONFIG += qt warn_on release
3#release debug 3#release debug
4 4
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)
8MOC_DIR = moc/$(PLATFORM) 8MOC_DIR = moc/$(PLATFORM)
9DESTDIR = $(QPEDIR)/lib 9DESTDIR = $(QPEDIR)/lib
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
@@ -36,6 +36,7 @@ $Id$
36 36
37#include "resourceldap.h" 37#include "resourceldap.h"
38#include "resourceldapconfig.h" 38#include "resourceldapconfig.h"
39#include "syncwidget.h"
39 40
40using namespace KABC; 41using namespace KABC;
41 42
@@ -44,15 +45,15 @@ extern "C"
44//US void *init_kabc_ldap() 45//US void *init_kabc_ldap()
45 void *init_microkabc_ldap() 46 void *init_microkabc_ldap()
46 { 47 {
47 return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig>(); 48 return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig, KRES::SyncWidget>();
48 } 49 }
49} 50}
50 51
51void addModOp( LDAPMod ***pmods, const QString &attr, const QString &value ); 52void addModOp( LDAPMod ***pmods, const QString &attr, const QString &value );
52 53
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{
57 KConfig *cfg = (KConfig *)config; 58 KConfig *cfg = (KConfig *)config;
58 if ( cfg ) { 59 if ( cfg ) {
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
@@ -43,7 +43,7 @@ class ResourceLDAP : public Resource
43{ 43{
44public: 44public:
45 45
46 ResourceLDAP( const KConfig* ); 46 ResourceLDAP( const KConfig*, bool syncable );
47 47
48 virtual void writeConfig( KConfig* ); 48 virtual void writeConfig( KConfig* );
49 49
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
@@ -3,7 +3,7 @@ CONFIG += qt warn_on
3#release debug 3#release debug
4TARGET = microkabc_opie 4TARGET = 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
8 8
9OBJECTS_DIR = obj/$(PLATFORM) 9OBJECTS_DIR = obj/$(PLATFORM)
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
@@ -50,6 +50,7 @@ $Id$
50 50
51#include "resourceopieconfig.h" 51#include "resourceopieconfig.h"
52#include "stdaddressbook.h" 52#include "stdaddressbook.h"
53#include "syncwidget.h"
53 54
54#include "opieconverter.h" 55#include "opieconverter.h"
55 56
@@ -60,12 +61,12 @@ extern "C"
60{ 61{
61 void *init_microkabc_opie() 62 void *init_microkabc_opie()
62 { 63 {
63 return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig>(); 64 return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig, KRES::SyncWidget>();
64 } 65 }
65} 66}
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{
70 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 71 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
71 72
@@ -80,8 +81,8 @@ ResourceOpie::ResourceOpie( const KConfig *config )
80 init( fileName ); 81 init( fileName );
81} 82}
82 83
83ResourceOpie::ResourceOpie( const QString &fileName ) 84ResourceOpie::ResourceOpie( const QString &fileName, bool syncable )
84 : Resource( 0 ) 85 : Resource( 0, syncable )
85{ 86{
86// qDebug("ResourceOpie::ResourceOpie : 3 %s", fileName.latin1()); 87// qDebug("ResourceOpie::ResourceOpie : 3 %s", fileName.latin1());
87 init( fileName ); 88 init( fileName );
@@ -103,27 +104,30 @@ ResourceOpie::~ResourceOpie()
103{ 104{
104 if (mConverter != 0) 105 if (mConverter != 0)
105 delete mConverter; 106 delete mConverter;
107
108 if(mAccess != 0)
109 delete mAccess;
110
106} 111}
107 112
108void ResourceOpie::writeConfig( KConfig *config ) 113void ResourceOpie::writeConfig( KConfig *config )
109{ 114{
110 Resource::writeConfig( config ); 115 Resource::writeConfig( 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}
117 119
118Ticket *ResourceOpie::requestSaveTicket() 120Ticket *ResourceOpie::requestSaveTicket()
119{ 121{
120 kdDebug(5700) << "ResourceOpie::requestSaveTicket()" << endl; 122 kdDebug(5700) << "ResourceOpie::requestSaveTicket()" << endl;
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;
128 } 132 }
129 return createTicket( this ); 133 return createTicket( this );
@@ -132,78 +136,62 @@ Ticket *ResourceOpie::requestSaveTicket()
132 136
133bool ResourceOpie::doOpen() 137bool 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 140
145 return ok; 141 OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", fileName() );
146 } else { 142 mAccess = new OContactAccess("KDEPim/Pi", 0l, backend, false);
147 if ( !file.open( IO_ReadWrite ) )
148 return false;
149 143
150 if ( file.size() == 0 ) { 144 if ( !mAccess ) {
151 file.close(); 145 qDebug("Unable to load file() %s", fileName().latin1());
152 return true; 146 return false;
153 } 147 }
154 148
155//US bool ok = mFormat->checkFormat( &file ); 149 mAccess->setReadAhead( 32 ); // Use ReadAhead-Cache if available
156 bool ok = true;
157 150
158 file.close();
159 151
160 return ok; 152 if (mConverter == 0)
153 {
154 mConverter = new OpieConverter();
155 bool res = mConverter->init();
156 if ( !res )
157 {
158 qDebug("Unable to initialize opie converter. Most likely a problem with the category file");
159 delete mAccess;
160 mAccess = 0;
161 return false;
161 } 162 }
162*/ 163 }
163 qDebug("ResourceOpie::doOpen() has to be fixed - %s", mFileName.latin1()); 164
165
166
164 return true; 167 return true;
165} 168}
166 169
167void ResourceOpie::doClose() 170void ResourceOpie::doClose()
168{ 171{
169// qDebug("ResourceOpie::doClose() %s", mFileName.latin1()); 172 qDebug("ResourceOpie::doClose: %s", fileName().latin1());
170}
171 173
172bool ResourceOpie::load() 174 if(mAccess)
173{ 175{
174// qDebug("ResourceOpie::load() %s", mFileName.latin1()); 176 delete mAccess;
175 kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl; 177 mAccess = 0;
176 178 }
177 qDebug("ResourceOpie::load: Try to load file() %s", mFileName.latin1()); 179 // it seems so, that deletion of access deletes backend as well
180 //delete backend;
178 181
179 OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", mFileName ); 182 return;
180 OContactAccess* access = new OContactAccess("KDEPim/Pi", 0l, backend, false);
181 183
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 } 184 }
187 185
188 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available
189 186
190 bool res = false; 187bool ResourceOpie::load()
191 if (mConverter == 0)
192 {
193 mConverter = new OpieConverter();
194 res = mConverter->init();
195 if ( !res )
196 { 188 {
197 qDebug("Unable to initialize opie converter. Most likely a problem with the category file"); 189 qDebug("ResourceOpie::load: %s", fileName().latin1());
198 addressBook()->error( i18n( "Unable to initialize opie converter. Most likely a problem with the category file" ) );
199 delete access;
200 return false;
201 }
202 }
203 190
191 bool res = false;
204 192
205 OContactAccess::List::Iterator it; 193 OContactAccess::List::Iterator it;
206 OContactAccess::List allList = access->allRecords(); 194 OContactAccess::List allList = mAccess->allRecords();
207 for ( it = allList.begin(); it != allList.end(); ++it ) 195 for ( it = allList.begin(); it != allList.end(); ++it )
208 { 196 {
209 const OContact c = (*it); 197 const OContact c = (*it);
@@ -218,75 +206,56 @@ bool ResourceOpie::load()
218 addressBook()->insertAddressee( addressee ); 206 addressBook()->insertAddressee( addressee );
219 } 207 }
220 208
221// qDebug("found %s", c.fullName().latin1());
222 } 209 }
223 210
224 delete access;
225 // it seems so, that deletion of access deletes backend as well
226 //delete backend;
227 211
228 return true; 212 return true;
229} 213}
230 214
231bool ResourceOpie::save( Ticket *ticket ) 215bool 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
235 218
236 qDebug("ResourceOpie::save %s", mFileName.latin1());
237 kdDebug(5700) << "ResourceOpie::save()" << endl;
238 219
239 // create backup file
240 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() );
241*/
242/*US we use a simpler method to create a backupfile
243 220
244 (void) KSaveFile::backupFile( mFileName, QString::null 221 KABC::AddressBook::Iterator it;
245 ,extension ); 222 bool res;
223
224 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
225 OContact c;
226 KABC::Addressee addressee = (*it);
246 227
247 KSaveFile saveFile( mFileName ); 228 res = mConverter->addresseeToOpie( *it, c );
248 bool ok = false; 229 if (res == true)
249 if ( saveFile.status() == 0 && saveFile.file() )
250 { 230 {
251 mFormat->saveAll( addressBook(), this, saveFile.file() ); 231 res = mAccess->add(c);
252 ok = saveFile.close(); 232 if (res == false)
233 qDebug("Unable to append Contact %s", c.fullName().latin1());
253 } 234 }
254*/ 235 else
255/*US 236 {
256//US ToDo: write backupfile 237 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1());
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 } 238 }
266 else {
267
268 } 239 }
269 240
270 if ( !ok ) 241 mAccess->save();
271 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) );
272 242
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());
287 kdDebug(5700) << "ResourceOpie::lock()" << endl; 256 kdDebug(5700) << "ResourceOpie::lock()" << endl;
288 257
289 QString fn = fileName; 258 QString fn = lockfileName;
290 259
291//US change the implementation how the lockfilename is getting created 260//US change the implementation how the lockfilename is getting created
292//US fn.replace( QRegExp("/"), "_" ); 261//US fn.replace( QRegExp("/"), "_" );
@@ -330,7 +299,7 @@ bool ResourceOpie::lock( const QString &fileName )
330 299
331void ResourceOpie::unlock( const QString &fileName ) 300void 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;
336//US change the implementation how the lockfilename is getting created 305//US change the implementation how the lockfilename is getting created
@@ -345,24 +314,18 @@ void ResourceOpie::unlock( const QString &fileName )
345 addressBook()->emitAddressBookUnlocked(); 314 addressBook()->emitAddressBookUnlocked();
346} 315}
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
367void ResourceOpie::fileChanged() 330void ResourceOpie::fileChanged()
368{ 331{
@@ -371,7 +334,7 @@ void ResourceOpie::fileChanged()
371 if (!addressBook()) 334 if (!addressBook())
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 ) {
376 load(); 339 load();
377 addressBook()->emitAddressBookChanged(); 340 addressBook()->emitAddressBookChanged();
@@ -389,7 +352,40 @@ void ResourceOpie::cleanUp()
389{ 352{
390// qDebug("ResourceOpie::cleanup() %s", mFileName.latin1()); 353// qDebug("ResourceOpie::cleanup() %s", mFileName.latin1());
391 354
392 unlock( mFileName ); 355 unlock( fileName() );
393} 356}
394 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;
387}
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
@@ -37,12 +37,10 @@ $Id$
37#include "resource.h" 37#include "resource.h"
38 38
39 39
40//class QTimer; 40class OContactAccess;
41//class FormatPlugin;
42 41
43namespace KABC { 42namespace KABC {
44 43
45//US class FormatPlugin;
46class ResourceConfigWidget; 44class ResourceConfigWidget;
47class OpieConverter; 45class OpieConverter;
48/** 46/**
@@ -59,12 +57,12 @@ public:
59 57
60 @param cfg The config object where custom resource settings are stored. 58 @param cfg The config object where custom resource settings are stored.
61 */ 59 */
62 ResourceOpie( const KConfig *cfg ); 60 ResourceOpie( const KConfig *cfg, bool syncable );
63 61
64 /** 62 /**
65 Construct file resource on file @arg fileName using format @arg formatName. 63 Construct file resource on file @arg fileName using format @arg formatName.
66 */ 64 */
67 ResourceOpie( const QString &fileName ); 65 ResourceOpie( const QString &fileName, bool syncable );
68 66
69 /** 67 /**
70 * Destructor. 68 * Destructor.
@@ -106,15 +104,6 @@ public:
106 */ 104 */
107 virtual bool save( Ticket *ticket ); 105 virtual bool save( Ticket *ticket );
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
119 /** 108 /**
120 * Remove a addressee from its source. 109 * Remove a addressee from its source.
@@ -123,11 +112,27 @@ public:
123 virtual void removeAddressee( const Addressee& addr ); 112 virtual void removeAddressee( const Addressee& addr );
124 113
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
127 * crashed 121 * crashed
128 */ 122 */
129 virtual void cleanUp(); 123 virtual void cleanUp();
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:
132 void fileChanged(); 137 void fileChanged();
133 138
@@ -138,10 +143,9 @@ protected:
138 void unlock( const QString &fileName ); 143 void unlock( const QString &fileName );
139 144
140private: 145private:
146 OContactAccess* mAccess;
141 OpieConverter* mConverter; 147 OpieConverter* mConverter;
142 148
143 QString mFileName;
144
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
@@ -3,7 +3,7 @@ CONFIG += qt warn_on
3 3
4TARGET = microkabc_qtopia 4TARGET = 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
8OBJECTS_DIR = obj/$(PLATFORM) 8OBJECTS_DIR = obj/$(PLATFORM)
9MOC_DIR = moc/$(PLATFORM) 9MOC_DIR = moc/$(PLATFORM)
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
@@ -49,6 +49,7 @@ $Id$
49#include "stdaddressbook.h" 49#include "stdaddressbook.h"
50 50
51#include "qtopiaconverter.h" 51#include "qtopiaconverter.h"
52#include "syncwidget.h"
52 53
53#include "resourceqtopia.h" 54#include "resourceqtopia.h"
54 55
@@ -57,12 +58,12 @@ extern "C"
57{ 58{
58 void *init_microkabc_qtopia() 59 void *init_microkabc_qtopia()
59 { 60 {
60 return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig>(); 61 return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, KRES::SyncWidget>();
61 } 62 }
62} 63}
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{
67 // we can not choose the filename. Therefore use the default to display 68 // we can not choose the filename. Therefore use the default to display
68 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 69 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
@@ -70,8 +71,8 @@ ResourceQtopia::ResourceQtopia( const KConfig *config )
70 init( fileName ); 71 init( fileName );
71} 72}
72 73
73ResourceQtopia::ResourceQtopia( const QString &fileName ) 74ResourceQtopia::ResourceQtopia( const QString &fileName, bool syncable )
74 : Resource( 0 ) 75 : Resource( 0, syncable )
75{ 76{
76// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); 77// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1());
77 init( fileName ); 78 init( fileName );
@@ -92,6 +93,8 @@ ResourceQtopia::~ResourceQtopia()
92 if (mConverter != 0) 93 if (mConverter != 0)
93 delete mConverter; 94 delete mConverter;
94 95
96 if(mAccess != 0)
97 delete mAccess;
95} 98}
96 99
97void ResourceQtopia::writeConfig( KConfig *config ) 100void ResourceQtopia::writeConfig( KConfig *config )
@@ -105,9 +108,9 @@ Ticket *ResourceQtopia::requestSaveTicket()
105 108
106 if ( !addressBook() ) return 0; 109 if ( !addressBook() ) return 0;
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;
112 } 115 }
113 return createTicket( this ); 116 return createTicket( this );
@@ -116,51 +119,12 @@ Ticket *ResourceQtopia::requestSaveTicket()
116 119
117bool ResourceQtopia::doOpen() 120bool ResourceQtopia::doOpen()
118{ 121{
119/*US 122 qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1());
120 QFile file( mFileName );
121 123
122 if ( !file.exists() ) { 124 mAccess = new AddressBookAccess();
123 // try to create the file
124 bool ok = file.open( IO_WriteOnly );
125 if ( ok )
126 file.close();
127 125
128 return ok; 126 if ( !mAccess ) {
129 } else { 127 qDebug("Unable to load file() %s", fileName().latin1());
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
153bool ResourceQtopia::load()
154{
155 kdDebug(5700) << "ResourceQtopia::load(): '" << mFileName << "'" << endl;
156
157// qDebug("ResourceQtopia::load: Try to load file() %s", mFileName.latin1());
158
159 AddressBookAccess* access = new AddressBookAccess();
160
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;
165 } 129 }
166 130
@@ -173,17 +137,40 @@ bool ResourceQtopia::load()
173 { 137 {
174 QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file"); 138 QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file");
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;
179 } 143 }
180 } 144 }
181 145
182 { //create a new scope 146 return true;
183 AddressBookIterator it(*access); 147}
148
149void ResourceQtopia::doClose()
150{
151 qDebug("ResourceQtopia::doClose: %s", fileName().latin1());
152
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());
167
168 AddressBookIterator it(*mAccess);
184 const PimContact* contact; 169 const PimContact* contact;
170 bool res;
185 171
186 for (contact=it.toFirst(); it.current(); ++it) { 172 for (contact=it.toFirst(); it.current(); ++it)
173 {
187 contact = it.current(); 174 contact = it.current();
188 175
189 KABC::Addressee addressee; 176 KABC::Addressee addressee;
@@ -196,9 +183,7 @@ bool ResourceQtopia::load()
196 addressBook()->insertAddressee( addressee ); 183 addressBook()->insertAddressee( addressee );
197 } 184 }
198 } 185 }
199 }
200 186
201 delete access;
202 return true; 187 return true;
203} 188}
204 189
@@ -249,7 +234,12 @@ bool ResourceQtopia::save( Ticket *ticket )
249 return ok; 234 return ok;
250 235
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;
254} 244}
255 245
@@ -312,24 +302,17 @@ void ResourceQtopia::unlock( const QString &fileName )
312 addressBook()->emitAddressBookUnlocked(); 302 addressBook()->emitAddressBookUnlocked();
313} 303}
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
334void ResourceQtopia::fileChanged() 317void ResourceQtopia::fileChanged()
335{ 318{
@@ -338,7 +321,7 @@ void ResourceQtopia::fileChanged()
338 if (!addressBook()) 321 if (!addressBook())
339 return; 322 return;
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 ) {
343 load(); 326 load();
344 addressBook()->emitAddressBookChanged(); 327 addressBook()->emitAddressBookChanged();
@@ -351,7 +334,50 @@ void ResourceQtopia::removeAddressee( const Addressee &addr )
351 334
352void ResourceQtopia::cleanUp() 335void ResourceQtopia::cleanUp()
353{ 336{
354 unlock( mFileName ); 337 unlock( fileName() );
338}
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;
355} 359}
356 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
@@ -36,6 +36,7 @@ $Id$
36 36
37#include "resource.h" 37#include "resource.h"
38 38
39class AddressBookAccess;
39 40
40namespace KABC { 41namespace KABC {
41 42
@@ -57,12 +58,12 @@ public:
57 58
58 @param cfg The config object where custom resource settings are stored. 59 @param cfg The config object where custom resource settings are stored.
59 */ 60 */
60 ResourceQtopia( const KConfig *cfg ); 61 ResourceQtopia( const KConfig *cfg, bool syncable );
61 62
62 /** 63 /**
63 Construct file resource on file @arg fileName using format @arg formatName. 64 Construct file resource on file @arg fileName using format @arg formatName.
64 */ 65 */
65 ResourceQtopia( const QString &fileName ); 66 ResourceQtopia( const QString &fileName, bool syncable );
66 67
67 /** 68 /**
68 * Destructor. 69 * Destructor.
@@ -105,26 +106,31 @@ public:
105 virtual bool save( Ticket *ticket ); 106 virtual bool save( Ticket *ticket );
106 107
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
129protected slots: 135protected slots:
130 void fileChanged(); 136 void fileChanged();
@@ -136,10 +142,9 @@ protected:
136 void unlock( const QString &fileName ); 142 void unlock( const QString &fileName );
137 143
138private: 144private:
145 AddressBookAccess* mAccess;
139 QtopiaConverter* mConverter; 146 QtopiaConverter* mConverter;
140 147
141 QString mFileName;
142
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
@@ -1,6 +1,6 @@
1/* 1/*
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
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
@@ -62,8 +62,8 @@ extern "C"
62 } 62 }
63} 63}
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{
68 // we can not choose the filename. Therefore use the default to display 68 // we can not choose the filename. Therefore use the default to display
69 69
@@ -71,8 +71,8 @@ ResourceSharpDTM::ResourceSharpDTM( const KConfig *config )
71 init( fileName ); 71 init( fileName );
72} 72}
73 73
74ResourceSharpDTM::ResourceSharpDTM( const QString &fileName ) 74ResourceSharpDTM::ResourceSharpDTM( const QString &fileName, bool syncable )
75 : Resource( 0 ) 75 : Resource( 0, syncable )
76{ 76{
77// qDebug("ResourceFile::ResourceSharpDTM : 3 %s, %s", fileName.latin1(), formatName.latin1()); 77// qDebug("ResourceFile::ResourceSharpDTM : 3 %s, %s", fileName.latin1(), formatName.latin1());
78 init( fileName ); 78 init( fileName );
@@ -355,3 +355,28 @@ void ResourceSharpDTM::cleanUp()
355 unlock( mFileName ); 355 unlock( mFileName );
356} 356}
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
@@ -1,6 +1,6 @@
1/* 1/*
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
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
@@ -56,12 +56,12 @@ public:
56 56
57 @param cfg The config object where custom resource settings are stored. 57 @param cfg The config object where custom resource settings are stored.
58 */ 58 */
59 ResourceSharpDTM( const KConfig *cfg ); 59 ResourceSharpDTM( const KConfig *cfg, bool syncable );
60 60
61 /** 61 /**
62 Construct file resource on file @arg fileName using format @arg formatName. 62 Construct file resource on file @arg fileName using format @arg formatName.
63 */ 63 */
64 ResourceSharpDTM( const QString &fileName ); 64 ResourceSharpDTM( const QString &fileName, bool syncable );
65 65
66 /** 66 /**
67 * Destructor. 67 * Destructor.
@@ -104,26 +104,32 @@ public:
104 virtual bool save( Ticket *ticket ); 104 virtual bool save( Ticket *ticket );
105 105
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
128protected slots: 134protected slots:
129 void fileChanged(); 135 void fileChanged();
@@ -137,8 +143,6 @@ protected:
137private: 143private:
138 SharpDTMConverter* mConverter; 144 SharpDTMConverter* mConverter;
139 145
140 QString mFileName;
141
142 QString mLockUniqueName; 146 QString mLockUniqueName;
143 147
144 KDirWatch mDirWatch; 148 KDirWatch mDirWatch;
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
@@ -2,7 +2,7 @@ TEMPLATE = lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3TARGET = microkabc_sharpdtm 3TARGET = 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
7 7
8OBJECTS_DIR = obj/$(PLATFORM) 8OBJECTS_DIR = obj/$(PLATFORM)