-rw-r--r-- | kabc/plugins/dir/resourcedir.cpp | 3 | ||||
-rw-r--r-- | kabc/plugins/file/resourcefile.cpp | 9 | ||||
-rw-r--r-- | kabc/plugins/opie/resourceopie.cpp | 4 | ||||
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.cpp | 3 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 2 |
5 files changed, 16 insertions, 5 deletions
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp index eccd482..fac06a1 100644 --- a/kabc/plugins/dir/resourcedir.cpp +++ b/kabc/plugins/dir/resourcedir.cpp | |||
@@ -197,49 +197,52 @@ bool ResourceDir::load() | |||
197 | if ( !mFormat->loadAll( addressBook(), this, &file ) ) | 197 | if ( !mFormat->loadAll( addressBook(), this, &file ) ) |
198 | ok = false; | 198 | ok = false; |
199 | 199 | ||
200 | file.close(); | 200 | file.close(); |
201 | } | 201 | } |
202 | 202 | ||
203 | return ok; | 203 | return ok; |
204 | } | 204 | } |
205 | 205 | ||
206 | bool ResourceDir::save( Ticket *ticket ) | 206 | bool ResourceDir::save( Ticket *ticket ) |
207 | { | 207 | { |
208 | kdDebug(5700) << "ResourceDir::save(): '" << mPath << "'" << endl; | 208 | kdDebug(5700) << "ResourceDir::save(): '" << mPath << "'" << endl; |
209 | 209 | ||
210 | AddressBook::Iterator it; | 210 | AddressBook::Iterator it; |
211 | bool ok = true; | 211 | bool ok = true; |
212 | 212 | ||
213 | mDirWatch.stopScan(); | ||
214 | |||
213 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { | 215 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { |
214 | if ( (*it).resource() != this || !(*it).changed() ) | 216 | if ( (*it).resource() != this || !(*it).changed() ) |
215 | continue; | 217 | continue; |
216 | 218 | ||
217 | QFile file( mPath + "/" + (*it).uid() ); | 219 | QFile file( mPath + "/" + (*it).uid() ); |
218 | if ( !file.open( IO_WriteOnly ) ) { | 220 | if ( !file.open( IO_WriteOnly ) ) { |
219 | addressBook()->error( i18n( "Unable to open file '%1' for writing" ).arg( file.name() ) ); | 221 | addressBook()->error( i18n( "Unable to open file '%1' for writing" ).arg( file.name() ) ); |
220 | continue; | 222 | continue; |
221 | } | 223 | } |
222 | 224 | ||
223 | mFormat->save( *it, &file ); | 225 | mFormat->save( *it, &file ); |
224 | 226 | ||
225 | // mark as unchanged | 227 | // mark as unchanged |
226 | (*it).setChanged( false ); | 228 | (*it).setChanged( false ); |
227 | 229 | ||
228 | file.close(); | 230 | file.close(); |
229 | } | 231 | } |
232 | mDirWatch.startScan(); | ||
230 | 233 | ||
231 | delete ticket; | 234 | delete ticket; |
232 | unlock( mPath ); | 235 | unlock( mPath ); |
233 | 236 | ||
234 | return ok; | 237 | return ok; |
235 | } | 238 | } |
236 | 239 | ||
237 | bool ResourceDir::lock( const QString &path ) | 240 | bool ResourceDir::lock( const QString &path ) |
238 | { | 241 | { |
239 | kdDebug(5700) << "ResourceDir::lock()" << endl; | 242 | kdDebug(5700) << "ResourceDir::lock()" << endl; |
240 | 243 | ||
241 | QString p = path; | 244 | QString p = path; |
242 | //US change the implementation how the lockfilename is getting created | 245 | //US change the implementation how the lockfilename is getting created |
243 | //US p.replace( QRegExp("/"), "_" ); | 246 | //US p.replace( QRegExp("/"), "_" ); |
244 | //US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" ); | 247 | //US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" ); |
245 | KURL url(p); | 248 | KURL url(p); |
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp index da2e4d7..fa6bc49 100644 --- a/kabc/plugins/file/resourcefile.cpp +++ b/kabc/plugins/file/resourcefile.cpp | |||
@@ -191,76 +191,77 @@ bool ResourceFile::load() | |||
191 | { | 191 | { |
192 | 192 | ||
193 | 193 | ||
194 | QFile file( mFileName ); | 194 | QFile file( mFileName ); |
195 | if ( !file.open( IO_ReadOnly ) ) { | 195 | if ( !file.open( IO_ReadOnly ) ) { |
196 | addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) ); | 196 | addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) ); |
197 | return false; | 197 | return false; |
198 | } | 198 | } |
199 | 199 | ||
200 | // qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); | 200 | // qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); |
201 | 201 | ||
202 | return mFormat->loadAll( addressBook(), this, &file ); | 202 | return mFormat->loadAll( addressBook(), this, &file ); |
203 | } | 203 | } |
204 | 204 | ||
205 | bool ResourceFile::save( Ticket *ticket ) | 205 | bool ResourceFile::save( Ticket *ticket ) |
206 | { | 206 | { |
207 | // qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); | 207 | // qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); |
208 | 208 | ||
209 | 209 | ||
210 | // create backup file | 210 | // create backup file |
211 | QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); | 211 | QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); |
212 | 212 | ||
213 | /*US we use a simpler method to create a backupfile | 213 | /*US we use a simpler method to create a backupfile |
214 | 214 | ||
215 | (void) KSaveFile::backupFile( mFileName, QString::null | 215 | (void) KSaveFile::backupFile( mFileName, QString::null |
216 | ,extension ); | 216 | ,extension ); |
217 | 217 | ||
218 | KSaveFile saveFile( mFileName ); | 218 | KSaveFile saveFile( mFileName ); |
219 | bool ok = false; | 219 | bool ok = false; |
220 | if ( saveFile.status() == 0 && saveFile.file() ) | 220 | if ( saveFile.status() == 0 && saveFile.file() ) |
221 | { | 221 | { |
222 | mFormat->saveAll( addressBook(), this, saveFile.file() ); | 222 | mFormat->saveAll( addressBook(), this, saveFile.file() ); |
223 | ok = saveFile.close(); | 223 | ok = saveFile.close(); |
224 | } | 224 | } |
225 | */ | 225 | */ |
226 | 226 | ||
227 | //US ToDo: write backupfile | 227 | //US ToDo: write backupfile |
228 | mDirWatch.stopScan(); | ||
229 | |||
228 | QFile info; | 230 | QFile info; |
229 | info.setName( mFileName ); | 231 | info.setName( mFileName ); |
230 | bool ok = info.open( IO_WriteOnly ); | 232 | bool ok = info.open( IO_WriteOnly ); |
231 | if ( ok ) { | 233 | if ( ok ) { |
232 | mFormat->saveAll( addressBook(), this, &info ); | 234 | mFormat->saveAll( addressBook(), this, &info ); |
233 | 235 | ||
234 | info.close(); | 236 | info.close(); |
235 | ok = true; | 237 | ok = true; |
236 | } | 238 | } |
237 | else { | 239 | else { |
238 | 240 | ||
239 | } | 241 | } |
240 | 242 | ||
241 | if ( !ok ) | 243 | if ( !ok ) |
242 | addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); | 244 | addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); |
243 | 245 | ||
246 | mDirWatch.startScan(); | ||
247 | |||
244 | delete ticket; | 248 | delete ticket; |
245 | unlock( mFileName ); | 249 | unlock( mFileName ); |
246 | 250 | ||
247 | return ok; | 251 | return ok; |
248 | |||
249 | qDebug("ResourceFile::save has to be changed"); | ||
250 | return true; | ||
251 | } | 252 | } |
252 | 253 | ||
253 | bool ResourceFile::lock( const QString &fileName ) | 254 | bool ResourceFile::lock( const QString &fileName ) |
254 | { | 255 | { |
255 | 256 | ||
256 | 257 | ||
257 | QString fn = fileName; | 258 | QString fn = fileName; |
258 | 259 | ||
259 | //US change the implementation how the lockfilename is getting created | 260 | //US change the implementation how the lockfilename is getting created |
260 | //US fn.replace( QRegExp("/"), "_" ); | 261 | //US fn.replace( QRegExp("/"), "_" ); |
261 | //US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); | 262 | //US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); |
262 | 263 | ||
263 | KURL url(fn); | 264 | KURL url(fn); |
264 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 265 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
265 | 266 | ||
266 | 267 | ||
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp index 4b811e9..22237dc 100644 --- a/kabc/plugins/opie/resourceopie.cpp +++ b/kabc/plugins/opie/resourceopie.cpp | |||
@@ -198,56 +198,58 @@ bool ResourceOpie::load() | |||
198 | if ( !addressee.isEmpty() && res ) | 198 | if ( !addressee.isEmpty() && res ) |
199 | { | 199 | { |
200 | addressee.setResource( this ); | 200 | addressee.setResource( this ); |
201 | addressBook()->insertAddressee( addressee ); | 201 | addressBook()->insertAddressee( addressee ); |
202 | } | 202 | } |
203 | 203 | ||
204 | } | 204 | } |
205 | 205 | ||
206 | 206 | ||
207 | return true; | 207 | return true; |
208 | } | 208 | } |
209 | 209 | ||
210 | bool ResourceOpie::save( Ticket *ticket ) | 210 | bool ResourceOpie::save( Ticket *ticket ) |
211 | { | 211 | { |
212 | qDebug("ResourceOpie::save: %s", fileName().latin1()); | 212 | qDebug("ResourceOpie::save: %s", fileName().latin1()); |
213 | 213 | ||
214 | 214 | mDirWatch.stopScan(); | |
215 | 215 | ||
216 | KABC::AddressBook::Iterator it; | 216 | KABC::AddressBook::Iterator it; |
217 | bool res; | 217 | bool res; |
218 | 218 | ||
219 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { | 219 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { |
220 | OContact c; | 220 | OContact c; |
221 | KABC::Addressee addressee = (*it); | 221 | KABC::Addressee addressee = (*it); |
222 | 222 | ||
223 | res = mConverter->addresseeToOpie( *it, c ); | 223 | res = mConverter->addresseeToOpie( *it, c ); |
224 | if (res == true) | 224 | if (res == true) |
225 | { | 225 | { |
226 | res = mAccess->add(c); | 226 | res = mAccess->add(c); |
227 | if (res == false) | 227 | if (res == false) |
228 | qDebug("Unable to append Contact %s", c.fullName().latin1()); | 228 | qDebug("Unable to append Contact %s", c.fullName().latin1()); |
229 | } | 229 | } |
230 | else | 230 | else |
231 | { | 231 | { |
232 | qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); | 232 | qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); |
233 | } | 233 | } |
234 | } | 234 | } |
235 | 235 | ||
236 | mAccess->save(); | 236 | mAccess->save(); |
237 | 237 | ||
238 | mDirWatch.startScan(); | ||
239 | |||
238 | delete ticket; | 240 | delete ticket; |
239 | unlock( fileName() ); | 241 | unlock( fileName() ); |
240 | 242 | ||
241 | return true; | 243 | return true; |
242 | 244 | ||
243 | } | 245 | } |
244 | 246 | ||
245 | bool ResourceOpie::lock( const QString &lockfileName ) | 247 | bool ResourceOpie::lock( const QString &lockfileName ) |
246 | { | 248 | { |
247 | qDebug("ResourceOpie::lock: %s", fileName().latin1()); | 249 | qDebug("ResourceOpie::lock: %s", fileName().latin1()); |
248 | 250 | ||
249 | kdDebug(5700) << "ResourceOpie::lock()" << endl; | 251 | kdDebug(5700) << "ResourceOpie::lock()" << endl; |
250 | 252 | ||
251 | QString fn = lockfileName; | 253 | QString fn = lockfileName; |
252 | 254 | ||
253 | KURL url(fn); | 255 | KURL url(fn); |
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp index 93a4d33..48a9f22 100644 --- a/kabc/plugins/qtopia/resourceqtopia.cpp +++ b/kabc/plugins/qtopia/resourceqtopia.cpp | |||
@@ -178,55 +178,58 @@ bool ResourceQtopia::load() | |||
178 | res = mConverter->qtopiaToAddressee( (*contact), addressee ); | 178 | res = mConverter->qtopiaToAddressee( (*contact), addressee ); |
179 | 179 | ||
180 | if ( !addressee.isEmpty() && res ) | 180 | if ( !addressee.isEmpty() && res ) |
181 | { | 181 | { |
182 | addressee.setResource( this ); | 182 | addressee.setResource( this ); |
183 | addressBook()->insertAddressee( addressee ); | 183 | addressBook()->insertAddressee( addressee ); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | return true; | 187 | return true; |
188 | } | 188 | } |
189 | 189 | ||
190 | bool ResourceQtopia::save( Ticket *ticket ) | 190 | bool ResourceQtopia::save( Ticket *ticket ) |
191 | { | 191 | { |
192 | qDebug("ResourceQtopia::save: %s", fileName().latin1()); | 192 | qDebug("ResourceQtopia::save: %s", fileName().latin1()); |
193 | 193 | ||
194 | mDirWatch.stopScan(); | ||
194 | 195 | ||
195 | KABC::AddressBook::Iterator it; | 196 | KABC::AddressBook::Iterator it; |
196 | bool res; | 197 | bool res; |
197 | 198 | ||
198 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { | 199 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { |
199 | PimContact c; | 200 | PimContact c; |
200 | KABC::Addressee addressee = (*it); | 201 | KABC::Addressee addressee = (*it); |
201 | 202 | ||
202 | res = mConverter->addresseeToQtopia( *it, c ); | 203 | res = mConverter->addresseeToQtopia( *it, c ); |
203 | if (res == true) | 204 | if (res == true) |
204 | { | 205 | { |
205 | mAccess->addContact(c); | 206 | mAccess->addContact(c); |
206 | // if (res == false) | 207 | // if (res == false) |
207 | // qDebug("Unable to append Contact %s", c.fullName().latin1()); | 208 | // qDebug("Unable to append Contact %s", c.fullName().latin1()); |
208 | } | 209 | } |
209 | else | 210 | else |
210 | { | 211 | { |
211 | qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); | 212 | qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); |
212 | } | 213 | } |
213 | } | 214 | } |
214 | 215 | ||
215 | // mAccess->addressBookUpdated(); | 216 | // mAccess->addressBookUpdated(); |
216 | 217 | ||
218 | mDirWatch.startScan(); | ||
219 | |||
217 | delete ticket; | 220 | delete ticket; |
218 | unlock( fileName() ); | 221 | unlock( fileName() ); |
219 | 222 | ||
220 | return true; | 223 | return true; |
221 | } | 224 | } |
222 | 225 | ||
223 | bool ResourceQtopia::lock( const QString &lockfileName ) | 226 | bool ResourceQtopia::lock( const QString &lockfileName ) |
224 | { | 227 | { |
225 | qDebug("ResourceQtopia::lock: %s", fileName().latin1()); | 228 | qDebug("ResourceQtopia::lock: %s", fileName().latin1()); |
226 | 229 | ||
227 | kdDebug(5700) << "ResourceQtopia::lock()" << endl; | 230 | kdDebug(5700) << "ResourceQtopia::lock()" << endl; |
228 | 231 | ||
229 | QString fn = lockfileName; | 232 | QString fn = lockfileName; |
230 | 233 | ||
231 | KURL url(fn); | 234 | KURL url(fn); |
232 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 235 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index b63df0c..8a795e9 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp | |||
@@ -184,32 +184,33 @@ bool ResourceSharpDTM::load() | |||
184 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | 184 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); |
185 | 185 | ||
186 | if ( !addressee.isEmpty() && res ) | 186 | if ( !addressee.isEmpty() && res ) |
187 | { | 187 | { |
188 | addressee.setResource( this ); | 188 | addressee.setResource( this ); |
189 | addressBook()->insertAddressee( addressee ); | 189 | addressBook()->insertAddressee( addressee ); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | return true; | 193 | return true; |
194 | } | 194 | } |
195 | 195 | ||
196 | bool ResourceSharpDTM::save( Ticket *ticket ) | 196 | bool ResourceSharpDTM::save( Ticket *ticket ) |
197 | { | 197 | { |
198 | qDebug("ResourceSharpDTM::save: %s", fileName().latin1()); | 198 | qDebug("ResourceSharpDTM::save: %s", fileName().latin1()); |
199 | 199 | ||
200 | mDirWatch.stopScan(); | ||
200 | 201 | ||
201 | KABC::AddressBook::Iterator it; | 202 | KABC::AddressBook::Iterator it; |
202 | bool res; | 203 | bool res; |
203 | 204 | ||
204 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { | 205 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { |
205 | CardId id = 0;// 0 means new card | 206 | CardId id = 0;// 0 means new card |
206 | KABC::Addressee addressee = (*it); | 207 | KABC::Addressee addressee = (*it); |
207 | 208 | ||
208 | res = mAccess->startEditCard(id); | 209 | res = mAccess->startEditCard(id); |
209 | if (res == true) | 210 | if (res == true) |
210 | { | 211 | { |
211 | res = mConverter->addresseeToSharp( *it, mAccess, id ); | 212 | res = mConverter->addresseeToSharp( *it, mAccess, id ); |
212 | if (res == true) | 213 | if (res == true) |
213 | { | 214 | { |
214 | res = mAccess->finishEditCard(&id); | 215 | res = mAccess->finishEditCard(&id); |
215 | if (res == false) | 216 | if (res == false) |
@@ -217,32 +218,33 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
217 | } | 218 | } |
218 | else | 219 | else |
219 | { | 220 | { |
220 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); | 221 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); |
221 | mAccess->cancelEditCard(); | 222 | mAccess->cancelEditCard(); |
222 | } | 223 | } |
223 | } | 224 | } |
224 | else | 225 | else |
225 | { | 226 | { |
226 | qDebug("Unable to add new card. Addressee: %s", addressee.formattedName().latin1()); | 227 | qDebug("Unable to add new card. Addressee: %s", addressee.formattedName().latin1()); |
227 | } | 228 | } |
228 | 229 | ||
229 | } | 230 | } |
230 | 231 | ||
231 | //US mAccess->save(); | 232 | //US mAccess->save(); |
232 | 233 | ||
234 | mDirWatch.startScan(); | ||
233 | delete ticket; | 235 | delete ticket; |
234 | unlock( fileName() ); | 236 | unlock( fileName() ); |
235 | 237 | ||
236 | return true; | 238 | return true; |
237 | } | 239 | } |
238 | 240 | ||
239 | bool ResourceSharpDTM::lock( const QString &lockfileName ) | 241 | bool ResourceSharpDTM::lock( const QString &lockfileName ) |
240 | { | 242 | { |
241 | qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); | 243 | qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); |
242 | 244 | ||
243 | kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; | 245 | kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; |
244 | 246 | ||
245 | QString fn = lockfileName; | 247 | QString fn = lockfileName; |
246 | 248 | ||
247 | KURL url(fn); | 249 | KURL url(fn); |
248 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 250 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |