author | zautrix <zautrix> | 2004-09-19 09:00:55 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-19 09:00:55 (UTC) |
commit | 787181d34f0d195ad72c9cf6aedbc317b6dd713e (patch) (unidiff) | |
tree | ac49d2b1d7887f96f3834458071b89e77b59218b | |
parent | f370d0f89bcaeeb68bd60152a9812a9cd55e5d8a (diff) | |
download | kdepimpi-787181d34f0d195ad72c9cf6aedbc317b6dd713e.zip kdepimpi-787181d34f0d195ad72c9cf6aedbc317b6dd713e.tar.gz kdepimpi-787181d34f0d195ad72c9cf6aedbc317b6dd713e.tar.bz2 |
more AB sync
-rw-r--r-- | kabc/addressbook.cpp | 31 | ||||
-rw-r--r-- | kabc/addressee.cpp | 19 | ||||
-rw-r--r-- | kabc/addressee.h | 1 | ||||
-rw-r--r-- | kabc/stdaddressbook.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 27 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 2 |
6 files changed, 59 insertions, 28 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index ec9f893..46a9cf4 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -218,464 +218,481 @@ bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | |||
218 | AddressBook::AddressBook() | 218 | AddressBook::AddressBook() |
219 | { | 219 | { |
220 | init(0, "contact"); | 220 | init(0, "contact"); |
221 | } | 221 | } |
222 | 222 | ||
223 | AddressBook::AddressBook( const QString &config ) | 223 | AddressBook::AddressBook( const QString &config ) |
224 | { | 224 | { |
225 | init(config, "contact"); | 225 | init(config, "contact"); |
226 | } | 226 | } |
227 | 227 | ||
228 | AddressBook::AddressBook( const QString &config, const QString &family ) | 228 | AddressBook::AddressBook( const QString &config, const QString &family ) |
229 | { | 229 | { |
230 | init(config, family); | 230 | init(config, family); |
231 | 231 | ||
232 | } | 232 | } |
233 | 233 | ||
234 | // the default family is "contact" | 234 | // the default family is "contact" |
235 | void AddressBook::init(const QString &config, const QString &family ) | 235 | void AddressBook::init(const QString &config, const QString &family ) |
236 | { | 236 | { |
237 | blockLSEchange = false; | 237 | blockLSEchange = false; |
238 | d = new AddressBookData; | 238 | d = new AddressBookData; |
239 | QString fami = family; | 239 | QString fami = family; |
240 | qDebug("new ab "); | 240 | qDebug("new ab "); |
241 | if (config != 0) { | 241 | if (config != 0) { |
242 | qDebug("config != 0 "); | 242 | qDebug("config != 0 "); |
243 | if ( family == "syncContact" ) { | 243 | if ( family == "syncContact" ) { |
244 | qDebug("creating sync config "); | 244 | qDebug("creating sync config "); |
245 | fami = "contact"; | 245 | fami = "contact"; |
246 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 246 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
247 | con->setGroup( "General" ); | 247 | con->setGroup( "General" ); |
248 | con->writeEntry( "ResourceKeys", QString("sync") ); | 248 | con->writeEntry( "ResourceKeys", QString("sync") ); |
249 | con->writeEntry( "Standard", QString("sync") ); | 249 | con->writeEntry( "Standard", QString("sync") ); |
250 | con->setGroup( "Resource_sync" ); | 250 | con->setGroup( "Resource_sync" ); |
251 | con->writeEntry( "FileFormat", QString("vcard") ); | 251 | con->writeEntry( "FileFormat", QString("vcard") ); |
252 | con->writeEntry( "FileName", config ); | 252 | con->writeEntry( "FileName", config ); |
253 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 253 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
254 | con->writeEntry( "ResourceName", QString("sync_res") ); | 254 | con->writeEntry( "ResourceName", QString("sync_res") ); |
255 | con->writeEntry( "ResourceType", QString("file") ); | 255 | con->writeEntry( "ResourceType", QString("file") ); |
256 | //con->sync(); | 256 | //con->sync(); |
257 | d->mConfig = con; | 257 | d->mConfig = con; |
258 | } | 258 | } |
259 | else | 259 | else |
260 | d->mConfig = new KConfig( locateLocal("config", config) ); | 260 | d->mConfig = new KConfig( locateLocal("config", config) ); |
261 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 261 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
262 | } | 262 | } |
263 | else { | 263 | else { |
264 | d->mConfig = 0; | 264 | d->mConfig = 0; |
265 | // qDebug("AddressBook::init 1 config=0"); | 265 | // qDebug("AddressBook::init 1 config=0"); |
266 | } | 266 | } |
267 | 267 | ||
268 | //US d->mErrorHandler = 0; | 268 | //US d->mErrorHandler = 0; |
269 | d->mManager = new KRES::Manager<Resource>( fami, false ); | 269 | d->mManager = new KRES::Manager<Resource>( fami, false ); |
270 | d->mManager->readConfig( d->mConfig ); | 270 | d->mManager->readConfig( d->mConfig ); |
271 | if ( family == "syncContact" ) { | 271 | if ( family == "syncContact" ) { |
272 | KRES::Manager<Resource> *manager = d->mManager; | 272 | KRES::Manager<Resource> *manager = d->mManager; |
273 | KRES::Manager<Resource>::ActiveIterator it; | 273 | KRES::Manager<Resource>::ActiveIterator it; |
274 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 274 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
275 | (*it)->setAddressBook( this ); | 275 | (*it)->setAddressBook( this ); |
276 | if ( !(*it)->open() ) | 276 | if ( !(*it)->open() ) |
277 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 277 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
278 | } | 278 | } |
279 | Resource *res = standardResource(); | 279 | Resource *res = standardResource(); |
280 | if ( !res ) { | 280 | if ( !res ) { |
281 | qDebug("ERROR: no standard resource"); | 281 | qDebug("ERROR: no standard resource"); |
282 | res = manager->createResource( "file" ); | 282 | res = manager->createResource( "file" ); |
283 | if ( res ) | 283 | if ( res ) |
284 | { | 284 | { |
285 | addResource( res ); | 285 | addResource( res ); |
286 | } | 286 | } |
287 | else | 287 | else |
288 | qDebug(" No resource available!!!"); | 288 | qDebug(" No resource available!!!"); |
289 | } | 289 | } |
290 | setStandardResource( res ); | 290 | setStandardResource( res ); |
291 | manager->writeConfig(); | 291 | manager->writeConfig(); |
292 | } | 292 | } |
293 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 293 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
294 | "X-Department", "KADDRESSBOOK" ); | 294 | "X-Department", "KADDRESSBOOK" ); |
295 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 295 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
296 | "X-Profession", "KADDRESSBOOK" ); | 296 | "X-Profession", "KADDRESSBOOK" ); |
297 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 297 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
298 | "X-AssistantsName", "KADDRESSBOOK" ); | 298 | "X-AssistantsName", "KADDRESSBOOK" ); |
299 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 299 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
300 | "X-ManagersName", "KADDRESSBOOK" ); | 300 | "X-ManagersName", "KADDRESSBOOK" ); |
301 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 301 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
302 | "X-SpousesName", "KADDRESSBOOK" ); | 302 | "X-SpousesName", "KADDRESSBOOK" ); |
303 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 303 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
304 | "X-Office", "KADDRESSBOOK" ); | 304 | "X-Office", "KADDRESSBOOK" ); |
305 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 305 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
306 | "X-IMAddress", "KADDRESSBOOK" ); | 306 | "X-IMAddress", "KADDRESSBOOK" ); |
307 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 307 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
308 | "X-Anniversary", "KADDRESSBOOK" ); | 308 | "X-Anniversary", "KADDRESSBOOK" ); |
309 | 309 | ||
310 | //US added this field to become compatible with Opie/qtopia addressbook | 310 | //US added this field to become compatible with Opie/qtopia addressbook |
311 | // values can be "female" or "male" or "". An empty field represents undefined. | 311 | // values can be "female" or "male" or "". An empty field represents undefined. |
312 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 312 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
313 | "X-Gender", "KADDRESSBOOK" ); | 313 | "X-Gender", "KADDRESSBOOK" ); |
314 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 314 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
315 | "X-Children", "KADDRESSBOOK" ); | 315 | "X-Children", "KADDRESSBOOK" ); |
316 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 316 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
317 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 317 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
318 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 318 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
319 | "X-ExternalID", "KADDRESSBOOK" ); | 319 | "X-ExternalID", "KADDRESSBOOK" ); |
320 | } | 320 | } |
321 | 321 | ||
322 | AddressBook::~AddressBook() | 322 | AddressBook::~AddressBook() |
323 | { | 323 | { |
324 | delete d->mConfig; d->mConfig = 0; | 324 | delete d->mConfig; d->mConfig = 0; |
325 | delete d->mManager; d->mManager = 0; | 325 | delete d->mManager; d->mManager = 0; |
326 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 326 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
327 | delete d; d = 0; | 327 | delete d; d = 0; |
328 | } | 328 | } |
329 | 329 | ||
330 | bool AddressBook::load() | 330 | bool AddressBook::load() |
331 | { | 331 | { |
332 | 332 | ||
333 | 333 | ||
334 | clear(); | 334 | clear(); |
335 | 335 | ||
336 | KRES::Manager<Resource>::ActiveIterator it; | 336 | KRES::Manager<Resource>::ActiveIterator it; |
337 | bool ok = true; | 337 | bool ok = true; |
338 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 338 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
339 | if ( !(*it)->load() ) { | 339 | if ( !(*it)->load() ) { |
340 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 340 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
341 | ok = false; | 341 | ok = false; |
342 | } | 342 | } |
343 | 343 | ||
344 | // mark all addressees as unchanged | 344 | // mark all addressees as unchanged |
345 | Addressee::List::Iterator addrIt; | 345 | Addressee::List::Iterator addrIt; |
346 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) | 346 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
347 | (*addrIt).setChanged( false ); | 347 | (*addrIt).setChanged( false ); |
348 | 348 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | |
349 | if ( !id.isEmpty() ) { | ||
350 | //qDebug("setId aa %s ", id.latin1()); | ||
351 | (*addrIt).setIDStr(id ); | ||
352 | } | ||
353 | } | ||
349 | blockLSEchange = true; | 354 | blockLSEchange = true; |
350 | return ok; | 355 | return ok; |
351 | } | 356 | } |
352 | 357 | ||
353 | bool AddressBook::save( Ticket *ticket ) | 358 | bool AddressBook::save( Ticket *ticket ) |
354 | { | 359 | { |
355 | kdDebug(5700) << "AddressBook::save()"<< endl; | 360 | kdDebug(5700) << "AddressBook::save()"<< endl; |
356 | 361 | ||
357 | if ( ticket->resource() ) { | 362 | if ( ticket->resource() ) { |
358 | deleteRemovedAddressees(); | 363 | deleteRemovedAddressees(); |
359 | return ticket->resource()->save( ticket ); | 364 | return ticket->resource()->save( ticket ); |
360 | } | 365 | } |
361 | 366 | ||
362 | return false; | 367 | return false; |
363 | } | 368 | } |
364 | bool AddressBook::saveAB() | 369 | bool AddressBook::saveAB() |
365 | { | 370 | { |
366 | bool ok = true; | 371 | bool ok = true; |
367 | 372 | ||
368 | deleteRemovedAddressees(); | 373 | deleteRemovedAddressees(); |
369 | 374 | Iterator ait; | |
375 | for ( ait = begin(); ait != end(); ++ait ) { | ||
376 | if ( !(*ait).IDStr().isEmpty() ) { | ||
377 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | ||
378 | } | ||
379 | } | ||
370 | KRES::Manager<Resource>::ActiveIterator it; | 380 | KRES::Manager<Resource>::ActiveIterator it; |
371 | KRES::Manager<Resource> *manager = d->mManager; | 381 | KRES::Manager<Resource> *manager = d->mManager; |
372 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 382 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
373 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 383 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
374 | Ticket *ticket = requestSaveTicket( *it ); | 384 | Ticket *ticket = requestSaveTicket( *it ); |
375 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 385 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
376 | if ( !ticket ) { | 386 | if ( !ticket ) { |
377 | error( i18n( "Unable to save to resource '%1'. It is locked." ) | 387 | error( i18n( "Unable to save to resource '%1'. It is locked." ) |
378 | .arg( (*it)->resourceName() ) ); | 388 | .arg( (*it)->resourceName() ) ); |
379 | return false; | 389 | return false; |
380 | } | 390 | } |
381 | 391 | ||
382 | //if ( !save( ticket ) ) | 392 | //if ( !save( ticket ) ) |
383 | if ( ticket->resource() ) { | 393 | if ( ticket->resource() ) { |
384 | if ( ! ticket->resource()->save( ticket ) ) | 394 | if ( ! ticket->resource()->save( ticket ) ) |
385 | ok = false; | 395 | ok = false; |
386 | } else | 396 | } else |
387 | ok = false; | 397 | ok = false; |
388 | 398 | ||
389 | } | 399 | } |
390 | } | 400 | } |
391 | return ok; | 401 | return ok; |
392 | } | 402 | } |
393 | 403 | ||
394 | AddressBook::Iterator AddressBook::begin() | 404 | AddressBook::Iterator AddressBook::begin() |
395 | { | 405 | { |
396 | Iterator it = Iterator(); | 406 | Iterator it = Iterator(); |
397 | it.d->mIt = d->mAddressees.begin(); | 407 | it.d->mIt = d->mAddressees.begin(); |
398 | return it; | 408 | return it; |
399 | } | 409 | } |
400 | 410 | ||
401 | AddressBook::ConstIterator AddressBook::begin() const | 411 | AddressBook::ConstIterator AddressBook::begin() const |
402 | { | 412 | { |
403 | ConstIterator it = ConstIterator(); | 413 | ConstIterator it = ConstIterator(); |
404 | it.d->mIt = d->mAddressees.begin(); | 414 | it.d->mIt = d->mAddressees.begin(); |
405 | return it; | 415 | return it; |
406 | } | 416 | } |
407 | 417 | ||
408 | AddressBook::Iterator AddressBook::end() | 418 | AddressBook::Iterator AddressBook::end() |
409 | { | 419 | { |
410 | Iterator it = Iterator(); | 420 | Iterator it = Iterator(); |
411 | it.d->mIt = d->mAddressees.end(); | 421 | it.d->mIt = d->mAddressees.end(); |
412 | return it; | 422 | return it; |
413 | } | 423 | } |
414 | 424 | ||
415 | AddressBook::ConstIterator AddressBook::end() const | 425 | AddressBook::ConstIterator AddressBook::end() const |
416 | { | 426 | { |
417 | ConstIterator it = ConstIterator(); | 427 | ConstIterator it = ConstIterator(); |
418 | it.d->mIt = d->mAddressees.end(); | 428 | it.d->mIt = d->mAddressees.end(); |
419 | return it; | 429 | return it; |
420 | } | 430 | } |
421 | 431 | ||
422 | void AddressBook::clear() | 432 | void AddressBook::clear() |
423 | { | 433 | { |
424 | d->mAddressees.clear(); | 434 | d->mAddressees.clear(); |
425 | } | 435 | } |
426 | 436 | ||
427 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 437 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
428 | { | 438 | { |
429 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 439 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
430 | 440 | ||
431 | if ( !resource ) | 441 | if ( !resource ) |
432 | { | 442 | { |
433 | qDebug("AddressBook::requestSaveTicket no resource" ); | 443 | qDebug("AddressBook::requestSaveTicket no resource" ); |
434 | resource = standardResource(); | 444 | resource = standardResource(); |
435 | } | 445 | } |
436 | 446 | ||
437 | KRES::Manager<Resource>::ActiveIterator it; | 447 | KRES::Manager<Resource>::ActiveIterator it; |
438 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 448 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
439 | if ( (*it) == resource ) { | 449 | if ( (*it) == resource ) { |
440 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 450 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
441 | return 0; | 451 | return 0; |
442 | else | 452 | else |
443 | return (*it)->requestSaveTicket(); | 453 | return (*it)->requestSaveTicket(); |
444 | } | 454 | } |
445 | } | 455 | } |
446 | 456 | ||
447 | return 0; | 457 | return 0; |
448 | } | 458 | } |
449 | 459 | ||
450 | void AddressBook::insertAddressee( const Addressee &a, bool setRev ) | 460 | void AddressBook::insertAddressee( const Addressee &a, bool setRev ) |
451 | { | 461 | { |
452 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { | 462 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { |
463 | //qDebug("block insert "); | ||
453 | return; | 464 | return; |
454 | } | 465 | } |
466 | //qDebug("inserting.... %s ",a.uid().latin1() ); | ||
455 | bool found = false; | 467 | bool found = false; |
456 | Addressee::List::Iterator it; | 468 | Addressee::List::Iterator it; |
457 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 469 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
458 | if ( a.uid() == (*it).uid() ) { | 470 | if ( a.uid() == (*it).uid() ) { |
459 | 471 | ||
460 | bool changed = false; | 472 | bool changed = false; |
461 | Addressee addr = a; | 473 | Addressee addr = a; |
462 | if ( addr != (*it) ) | 474 | if ( addr != (*it) ) |
463 | changed = true; | 475 | changed = true; |
464 | 476 | ||
465 | (*it) = a; | 477 | (*it) = a; |
466 | if ( (*it).resource() == 0 ) | 478 | if ( (*it).resource() == 0 ) |
467 | (*it).setResource( standardResource() ); | 479 | (*it).setResource( standardResource() ); |
468 | 480 | ||
469 | if ( changed ) { | 481 | if ( changed ) { |
470 | if ( setRev ) { | 482 | if ( setRev ) { |
471 | 483 | ||
472 | // get rid of micro seconds | 484 | // get rid of micro seconds |
473 | QDateTime dt = QDateTime::currentDateTime(); | 485 | QDateTime dt = QDateTime::currentDateTime(); |
474 | QTime t = dt.time(); | 486 | QTime t = dt.time(); |
475 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 487 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
476 | (*it).setRevision( dt ); | 488 | (*it).setRevision( dt ); |
477 | } | 489 | } |
478 | (*it).setChanged( true ); | 490 | (*it).setChanged( true ); |
479 | } | 491 | } |
480 | 492 | ||
481 | found = true; | 493 | found = true; |
482 | } else { | 494 | } else { |
483 | if ( (*it).uid() == QString("last-syncAddressee-") ) { | 495 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
484 | QString name = (*it).uid().mid( 19 ); | 496 | QString name = (*it).uid().mid( 19 ); |
485 | Addressee b = a; | 497 | Addressee b = a; |
486 | QString id = b.getID( name ); | 498 | QString id = b.getID( name ); |
487 | if ( ! id.isEmpty() ) { | 499 | if ( ! id.isEmpty() ) { |
488 | QString des = (*it).note(); | 500 | QString des = (*it).note(); |
489 | int startN; | 501 | int startN; |
490 | if( (startN = des.find( id ) ) >= 0 ) { | 502 | if( (startN = des.find( id ) ) >= 0 ) { |
491 | int endN = des.find( ",", startN+1 ); | 503 | int endN = des.find( ",", startN+1 ); |
492 | des = des.left( startN ) + des.mid( endN+1 ); | 504 | des = des.left( startN ) + des.mid( endN+1 ); |
493 | (*it).setNote( des ); | 505 | (*it).setNote( des ); |
494 | } | 506 | } |
495 | } | 507 | } |
496 | } | 508 | } |
497 | } | 509 | } |
498 | } | 510 | } |
499 | if ( found ) | 511 | if ( found ) |
500 | return; | 512 | return; |
501 | d->mAddressees.append( a ); | 513 | d->mAddressees.append( a ); |
502 | Addressee& addr = d->mAddressees.last(); | 514 | Addressee& addr = d->mAddressees.last(); |
503 | if ( addr.resource() == 0 ) | 515 | if ( addr.resource() == 0 ) |
504 | addr.setResource( standardResource() ); | 516 | addr.setResource( standardResource() ); |
505 | 517 | ||
506 | addr.setChanged( true ); | 518 | addr.setChanged( true ); |
507 | } | 519 | } |
508 | 520 | ||
509 | void AddressBook::removeAddressee( const Addressee &a ) | 521 | void AddressBook::removeAddressee( const Addressee &a ) |
510 | { | 522 | { |
511 | Iterator it; | 523 | Iterator it; |
512 | Iterator it2; | 524 | Iterator it2; |
513 | bool found = false; | 525 | bool found = false; |
514 | for ( it = begin(); it != end(); ++it ) { | 526 | for ( it = begin(); it != end(); ++it ) { |
515 | if ( a.uid() == (*it).uid() ) { | 527 | if ( a.uid() == (*it).uid() ) { |
516 | found = true; | 528 | found = true; |
517 | it2 = it; | 529 | it2 = it; |
518 | } else { | 530 | } else { |
519 | if ( (*it).uid() == QString("last-syncAddressee-") ) { | 531 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
520 | QString name = (*it).uid().mid( 19 ); | 532 | QString name = (*it).uid().mid( 19 ); |
521 | Addressee b = a; | 533 | Addressee b = a; |
522 | QString id = b.getID( name ); | 534 | QString id = b.getID( name ); |
523 | if ( ! id.isEmpty() ) { | 535 | if ( ! id.isEmpty() ) { |
524 | QString des = (*it).note(); | 536 | QString des = (*it).note(); |
525 | if( des.find( id ) < 0 ) { | 537 | if( des.find( id ) < 0 ) { |
526 | des += id + ","; | 538 | des += id + ","; |
527 | (*it).setNote( des ); | 539 | (*it).setNote( des ); |
528 | } | 540 | } |
529 | } | 541 | } |
530 | } | 542 | } |
531 | 543 | ||
532 | } | 544 | } |
533 | } | 545 | } |
534 | 546 | ||
535 | if ( found ) | 547 | if ( found ) |
536 | removeAddressee( it2 ); | 548 | removeAddressee( it2 ); |
537 | 549 | ||
538 | } | 550 | } |
539 | 551 | ||
540 | void AddressBook::removeDeletedAddressees() | 552 | void AddressBook::removeDeletedAddressees() |
541 | { | 553 | { |
542 | deleteRemovedAddressees(); | 554 | deleteRemovedAddressees(); |
543 | Iterator it = begin(); | 555 | Iterator it = begin(); |
544 | Iterator it2 ; | 556 | Iterator it2 ; |
545 | QDateTime dt ( QDate( 2004,1,1) ); | 557 | QDateTime dt ( QDate( 2004,1,1) ); |
546 | while ( it != end() ) { | 558 | while ( it != end() ) { |
547 | (*it).setRevision( dt ); | 559 | (*it).setRevision( dt ); |
548 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 560 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
561 | (*it).setIDStr(""); | ||
562 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE || (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | ||
549 | it2 = it; | 563 | it2 = it; |
564 | //qDebug("removing %s ",(*it).uid().latin1() ); | ||
550 | ++it; | 565 | ++it; |
551 | removeAddressee( it2 ); | 566 | removeAddressee( it2 ); |
552 | } else | 567 | } else { |
568 | //qDebug("skipping %s ",(*it).uid().latin1() ); | ||
553 | ++it; | 569 | ++it; |
570 | } | ||
554 | } | 571 | } |
555 | deleteRemovedAddressees(); | 572 | deleteRemovedAddressees(); |
556 | } | 573 | } |
557 | 574 | ||
558 | void AddressBook::removeAddressee( const Iterator &it ) | 575 | void AddressBook::removeAddressee( const Iterator &it ) |
559 | { | 576 | { |
560 | d->mRemovedAddressees.append( (*it) ); | 577 | d->mRemovedAddressees.append( (*it) ); |
561 | d->mAddressees.remove( it.d->mIt ); | 578 | d->mAddressees.remove( it.d->mIt ); |
562 | } | 579 | } |
563 | 580 | ||
564 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 581 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
565 | { | 582 | { |
566 | Iterator it; | 583 | Iterator it; |
567 | for ( it = begin(); it != end(); ++it ) { | 584 | for ( it = begin(); it != end(); ++it ) { |
568 | if ( a.uid() == (*it).uid() ) { | 585 | if ( a.uid() == (*it).uid() ) { |
569 | return it; | 586 | return it; |
570 | } | 587 | } |
571 | } | 588 | } |
572 | return end(); | 589 | return end(); |
573 | } | 590 | } |
574 | 591 | ||
575 | Addressee AddressBook::findByUid( const QString &uid ) | 592 | Addressee AddressBook::findByUid( const QString &uid ) |
576 | { | 593 | { |
577 | Iterator it; | 594 | Iterator it; |
578 | for ( it = begin(); it != end(); ++it ) { | 595 | for ( it = begin(); it != end(); ++it ) { |
579 | if ( uid == (*it).uid() ) { | 596 | if ( uid == (*it).uid() ) { |
580 | return *it; | 597 | return *it; |
581 | } | 598 | } |
582 | } | 599 | } |
583 | return Addressee(); | 600 | return Addressee(); |
584 | } | 601 | } |
585 | #if 0 | 602 | #if 0 |
586 | Addressee::List AddressBook::getExternLastSyncAddressees() | 603 | Addressee::List AddressBook::getExternLastSyncAddressees() |
587 | { | 604 | { |
588 | Addressee::List results; | 605 | Addressee::List results; |
589 | 606 | ||
590 | Iterator it; | 607 | Iterator it; |
591 | for ( it = begin(); it != end(); ++it ) { | 608 | for ( it = begin(); it != end(); ++it ) { |
592 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 609 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
593 | if ( (*it).familyName().left(4) == "!E: " ) | 610 | if ( (*it).familyName().left(4) == "!E: " ) |
594 | results.append( *it ); | 611 | results.append( *it ); |
595 | } | 612 | } |
596 | } | 613 | } |
597 | 614 | ||
598 | return results; | 615 | return results; |
599 | } | 616 | } |
600 | #endif | 617 | #endif |
601 | void AddressBook::resetTempSyncStat() | 618 | void AddressBook::resetTempSyncStat() |
602 | { | 619 | { |
603 | Iterator it; | 620 | Iterator it; |
604 | for ( it = begin(); it != end(); ++it ) { | 621 | for ( it = begin(); it != end(); ++it ) { |
605 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 622 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
606 | } | 623 | } |
607 | 624 | ||
608 | } | 625 | } |
609 | 626 | ||
610 | QStringList AddressBook:: uidList() | 627 | QStringList AddressBook:: uidList() |
611 | { | 628 | { |
612 | QStringList results; | 629 | QStringList results; |
613 | Iterator it; | 630 | Iterator it; |
614 | for ( it = begin(); it != end(); ++it ) { | 631 | for ( it = begin(); it != end(); ++it ) { |
615 | results.append( (*it).uid() ); | 632 | results.append( (*it).uid() ); |
616 | } | 633 | } |
617 | return results; | 634 | return results; |
618 | } | 635 | } |
619 | 636 | ||
620 | 637 | ||
621 | Addressee::List AddressBook::allAddressees() | 638 | Addressee::List AddressBook::allAddressees() |
622 | { | 639 | { |
623 | return d->mAddressees; | 640 | return d->mAddressees; |
624 | 641 | ||
625 | } | 642 | } |
626 | 643 | ||
627 | Addressee::List AddressBook::findByName( const QString &name ) | 644 | Addressee::List AddressBook::findByName( const QString &name ) |
628 | { | 645 | { |
629 | Addressee::List results; | 646 | Addressee::List results; |
630 | 647 | ||
631 | Iterator it; | 648 | Iterator it; |
632 | for ( it = begin(); it != end(); ++it ) { | 649 | for ( it = begin(); it != end(); ++it ) { |
633 | if ( name == (*it).realName() ) { | 650 | if ( name == (*it).realName() ) { |
634 | results.append( *it ); | 651 | results.append( *it ); |
635 | } | 652 | } |
636 | } | 653 | } |
637 | 654 | ||
638 | return results; | 655 | return results; |
639 | } | 656 | } |
640 | 657 | ||
641 | Addressee::List AddressBook::findByEmail( const QString &email ) | 658 | Addressee::List AddressBook::findByEmail( const QString &email ) |
642 | { | 659 | { |
643 | Addressee::List results; | 660 | Addressee::List results; |
644 | QStringList mailList; | 661 | QStringList mailList; |
645 | 662 | ||
646 | Iterator it; | 663 | Iterator it; |
647 | for ( it = begin(); it != end(); ++it ) { | 664 | for ( it = begin(); it != end(); ++it ) { |
648 | mailList = (*it).emails(); | 665 | mailList = (*it).emails(); |
649 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 666 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
650 | if ( email == (*ite) ) { | 667 | if ( email == (*ite) ) { |
651 | results.append( *it ); | 668 | results.append( *it ); |
652 | } | 669 | } |
653 | } | 670 | } |
654 | } | 671 | } |
655 | 672 | ||
656 | return results; | 673 | return results; |
657 | } | 674 | } |
658 | 675 | ||
659 | Addressee::List AddressBook::findByCategory( const QString &category ) | 676 | Addressee::List AddressBook::findByCategory( const QString &category ) |
660 | { | 677 | { |
661 | Addressee::List results; | 678 | Addressee::List results; |
662 | 679 | ||
663 | Iterator it; | 680 | Iterator it; |
664 | for ( it = begin(); it != end(); ++it ) { | 681 | for ( it = begin(); it != end(); ++it ) { |
665 | if ( (*it).hasCategory( category) ) { | 682 | if ( (*it).hasCategory( category) ) { |
666 | results.append( *it ); | 683 | results.append( *it ); |
667 | } | 684 | } |
668 | } | 685 | } |
669 | 686 | ||
670 | return results; | 687 | return results; |
671 | } | 688 | } |
672 | 689 | ||
673 | void AddressBook::dump() const | 690 | void AddressBook::dump() const |
674 | { | 691 | { |
675 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 692 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
676 | 693 | ||
677 | ConstIterator it; | 694 | ConstIterator it; |
678 | for( it = begin(); it != end(); ++it ) { | 695 | for( it = begin(); it != end(); ++it ) { |
679 | (*it).dump(); | 696 | (*it).dump(); |
680 | } | 697 | } |
681 | 698 | ||
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 0f5d605..d6b70c4 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,429 +1,436 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kidmanager.h> | 35 | #include <kidmanager.h> |
36 | //US | 36 | //US |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | //US #include "resource.h" | 40 | //US #include "resource.h" |
41 | #include "addressee.h" | 41 | #include "addressee.h" |
42 | 42 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | 46 | ||
47 | struct Addressee::AddresseeData : public KShared | 47 | struct Addressee::AddresseeData : public KShared |
48 | { | 48 | { |
49 | QString uid; | 49 | QString uid; |
50 | QString name; | 50 | QString name; |
51 | QString formattedName; | 51 | QString formattedName; |
52 | QString familyName; | 52 | QString familyName; |
53 | QString givenName; | 53 | QString givenName; |
54 | QString additionalName; | 54 | QString additionalName; |
55 | QString prefix; | 55 | QString prefix; |
56 | QString suffix; | 56 | QString suffix; |
57 | QString nickName; | 57 | QString nickName; |
58 | QDateTime birthday; | 58 | QDateTime birthday; |
59 | QString mailer; | 59 | QString mailer; |
60 | TimeZone timeZone; | 60 | TimeZone timeZone; |
61 | Geo geo; | 61 | Geo geo; |
62 | QString title; | 62 | QString title; |
63 | QString role; | 63 | QString role; |
64 | QString organization; | 64 | QString organization; |
65 | QString note; | 65 | QString note; |
66 | QString productId; | 66 | QString productId; |
67 | QDateTime revision; | 67 | QDateTime revision; |
68 | QString sortString; | 68 | QString sortString; |
69 | KURL url; | 69 | KURL url; |
70 | Secrecy secrecy; | 70 | Secrecy secrecy; |
71 | Picture logo; | 71 | Picture logo; |
72 | Picture photo; | 72 | Picture photo; |
73 | Sound sound; | 73 | Sound sound; |
74 | Agent agent; | 74 | Agent agent; |
75 | QString mExternalId; | 75 | QString mExternalId; |
76 | PhoneNumber::List phoneNumbers; | 76 | PhoneNumber::List phoneNumbers; |
77 | Address::List addresses; | 77 | Address::List addresses; |
78 | Key::List keys; | 78 | Key::List keys; |
79 | QStringList emails; | 79 | QStringList emails; |
80 | QStringList categories; | 80 | QStringList categories; |
81 | QStringList custom; | 81 | QStringList custom; |
82 | 82 | int mTempSyncStat; | |
83 | Resource *resource; | 83 | Resource *resource; |
84 | 84 | ||
85 | bool empty :1; | 85 | bool empty :1; |
86 | bool changed :1; | 86 | bool changed :1; |
87 | }; | 87 | }; |
88 | 88 | ||
89 | Addressee::Addressee() | 89 | Addressee::Addressee() |
90 | { | 90 | { |
91 | mData = new AddresseeData; | 91 | mData = new AddresseeData; |
92 | mData->empty = true; | 92 | mData->empty = true; |
93 | mData->changed = false; | 93 | mData->changed = false; |
94 | mData->resource = 0; | 94 | mData->resource = 0; |
95 | mData->mExternalId = ":"; | 95 | mData->mExternalId = ":"; |
96 | mData->revision = QDateTime ( QDate( 2004,1,1)); | 96 | mData->revision = QDateTime ( QDate( 2004,1,1)); |
97 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 97 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
98 | } | 98 | } |
99 | 99 | ||
100 | Addressee::~Addressee() | 100 | Addressee::~Addressee() |
101 | { | 101 | { |
102 | } | 102 | } |
103 | 103 | ||
104 | Addressee::Addressee( const Addressee &a ) | 104 | Addressee::Addressee( const Addressee &a ) |
105 | { | 105 | { |
106 | mData = a.mData; | 106 | mData = a.mData; |
107 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | ||
108 | } | 107 | } |
109 | 108 | ||
110 | Addressee &Addressee::operator=( const Addressee &a ) | 109 | Addressee &Addressee::operator=( const Addressee &a ) |
111 | { | 110 | { |
112 | mData = a.mData; | 111 | mData = a.mData; |
113 | return (*this); | 112 | return (*this); |
114 | } | 113 | } |
115 | 114 | ||
116 | Addressee Addressee::copy() | 115 | Addressee Addressee::copy() |
117 | { | 116 | { |
118 | Addressee a; | 117 | Addressee a; |
119 | *(a.mData) = *mData; | 118 | *(a.mData) = *mData; |
120 | return a; | 119 | return a; |
121 | } | 120 | } |
122 | 121 | ||
123 | void Addressee::detach() | 122 | void Addressee::detach() |
124 | { | 123 | { |
125 | if ( mData.count() == 1 ) return; | 124 | if ( mData.count() == 1 ) return; |
126 | *this = copy(); | 125 | *this = copy(); |
127 | } | 126 | } |
128 | 127 | ||
129 | bool Addressee::operator==( const Addressee &a ) const | 128 | bool Addressee::operator==( const Addressee &a ) const |
130 | { | 129 | { |
131 | if ( uid() != a.uid() ) return false; | 130 | if ( uid() != a.uid() ) return false; |
132 | if ( mData->name != a.mData->name ) return false; | 131 | if ( mData->name != a.mData->name ) return false; |
133 | if ( mData->formattedName != a.mData->formattedName ) return false; | 132 | if ( mData->formattedName != a.mData->formattedName ) return false; |
134 | if ( mData->familyName != a.mData->familyName ) return false; | 133 | if ( mData->familyName != a.mData->familyName ) return false; |
135 | if ( mData->givenName != a.mData->givenName ) return false; | 134 | if ( mData->givenName != a.mData->givenName ) return false; |
136 | if ( mData->additionalName != a.mData->additionalName ) return false; | 135 | if ( mData->additionalName != a.mData->additionalName ) return false; |
137 | if ( mData->prefix != a.mData->prefix ) return false; | 136 | if ( mData->prefix != a.mData->prefix ) return false; |
138 | if ( mData->suffix != a.mData->suffix ) return false; | 137 | if ( mData->suffix != a.mData->suffix ) return false; |
139 | if ( mData->nickName != a.mData->nickName ) return false; | 138 | if ( mData->nickName != a.mData->nickName ) return false; |
140 | if ( mData->birthday != a.mData->birthday ) return false; | 139 | if ( mData->birthday != a.mData->birthday ) return false; |
141 | if ( mData->mailer != a.mData->mailer ) return false; | 140 | if ( mData->mailer != a.mData->mailer ) return false; |
142 | if ( mData->timeZone != a.mData->timeZone ) return false; | 141 | if ( mData->timeZone != a.mData->timeZone ) return false; |
143 | if ( mData->geo != a.mData->geo ) return false; | 142 | if ( mData->geo != a.mData->geo ) return false; |
144 | if ( mData->title != a.mData->title ) return false; | 143 | if ( mData->title != a.mData->title ) return false; |
145 | if ( mData->role != a.mData->role ) return false; | 144 | if ( mData->role != a.mData->role ) return false; |
146 | if ( mData->organization != a.mData->organization ) return false; | 145 | if ( mData->organization != a.mData->organization ) return false; |
147 | if ( mData->note != a.mData->note ) return false; | 146 | if ( mData->note != a.mData->note ) return false; |
148 | if ( mData->productId != a.mData->productId ) return false; | 147 | if ( mData->productId != a.mData->productId ) return false; |
149 | if ( mData->revision != a.mData->revision ) return false; | 148 | if ( mData->revision != a.mData->revision ) return false; |
150 | if ( mData->sortString != a.mData->sortString ) return false; | 149 | if ( mData->sortString != a.mData->sortString ) return false; |
151 | if ( mData->secrecy != a.mData->secrecy ) return false; | 150 | if ( mData->secrecy != a.mData->secrecy ) return false; |
152 | if ( mData->logo != a.mData->logo ) return false; | 151 | if ( mData->logo != a.mData->logo ) return false; |
153 | if ( mData->photo != a.mData->photo ) return false; | 152 | if ( mData->photo != a.mData->photo ) return false; |
154 | if ( mData->sound != a.mData->sound ) return false; | 153 | if ( mData->sound != a.mData->sound ) return false; |
155 | if ( mData->agent != a.mData->agent ) return false; | 154 | if ( mData->agent != a.mData->agent ) return false; |
156 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 155 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
157 | ( mData->url != a.mData->url ) ) return false; | 156 | ( mData->url != a.mData->url ) ) return false; |
158 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 157 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
159 | if ( mData->addresses != a.mData->addresses ) return false; | 158 | if ( mData->addresses != a.mData->addresses ) return false; |
160 | if ( mData->keys != a.mData->keys ) return false; | 159 | if ( mData->keys != a.mData->keys ) return false; |
161 | if ( mData->emails != a.mData->emails ) return false; | 160 | if ( mData->emails != a.mData->emails ) return false; |
162 | if ( mData->categories != a.mData->categories ) return false; | 161 | if ( mData->categories != a.mData->categories ) return false; |
163 | if ( mData->custom != a.mData->custom ) return false; | 162 | if ( mData->custom != a.mData->custom ) return false; |
164 | 163 | ||
165 | return true; | 164 | return true; |
166 | } | 165 | } |
167 | 166 | ||
168 | bool Addressee::operator!=( const Addressee &a ) const | 167 | bool Addressee::operator!=( const Addressee &a ) const |
169 | { | 168 | { |
170 | return !( a == *this ); | 169 | return !( a == *this ); |
171 | } | 170 | } |
172 | 171 | ||
173 | bool Addressee::isEmpty() const | 172 | bool Addressee::isEmpty() const |
174 | { | 173 | { |
175 | return mData->empty; | 174 | return mData->empty; |
176 | } | 175 | } |
177 | ulong Addressee::getCsum4List( const QStringList & attList) | 176 | ulong Addressee::getCsum4List( const QStringList & attList) |
178 | { | 177 | { |
179 | int max = attList.count(); | 178 | int max = attList.count(); |
180 | ulong cSum = 0; | 179 | ulong cSum = 0; |
181 | int j,k,i; | 180 | int j,k,i; |
182 | int add; | 181 | int add; |
183 | for ( i = 0; i < max ; ++i ) { | 182 | for ( i = 0; i < max ; ++i ) { |
184 | QString s = attList[i]; | 183 | QString s = attList[i]; |
185 | if ( ! s.isEmpty() ){ | 184 | if ( ! s.isEmpty() ){ |
186 | j = s.length(); | 185 | j = s.length(); |
187 | for ( k = 0; k < j; ++k ) { | 186 | for ( k = 0; k < j; ++k ) { |
188 | int mul = k +1; | 187 | int mul = k +1; |
189 | add = s[k].unicode (); | 188 | add = s[k].unicode (); |
190 | if ( k < 16 ) | 189 | if ( k < 16 ) |
191 | mul = mul * mul; | 190 | mul = mul * mul; |
192 | int ii = i+1; | 191 | int ii = i+1; |
193 | add = add * mul *ii*ii*ii; | 192 | add = add * mul *ii*ii*ii; |
194 | cSum += add; | 193 | cSum += add; |
195 | } | 194 | } |
196 | } | 195 | } |
197 | 196 | ||
198 | } | 197 | } |
199 | //QString dump = attList.join(","); | 198 | //QString dump = attList.join(","); |
200 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 199 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
201 | 200 | ||
202 | return cSum; | 201 | return cSum; |
203 | 202 | ||
204 | } | 203 | } |
205 | void Addressee::computeCsum(const QString &dev) | 204 | void Addressee::computeCsum(const QString &dev) |
206 | { | 205 | { |
207 | QStringList l; | 206 | QStringList l; |
208 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 207 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
209 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 208 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
210 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 209 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
211 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 210 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
212 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 211 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
213 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 212 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
214 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 213 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
215 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 214 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
216 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 215 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
217 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 216 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
218 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 217 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
219 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 218 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
220 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 219 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
221 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 220 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
222 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 221 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
223 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 222 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
224 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 223 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
225 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 224 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
226 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 225 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
227 | // if ( !mData->logo.isEmpty() ) l.append( ); | 226 | // if ( !mData->logo.isEmpty() ) l.append( ); |
228 | //if ( !mData->photo.isEmpty() ) l.append( ); | 227 | //if ( !mData->photo.isEmpty() ) l.append( ); |
229 | //if ( !mData->sound.isEmpty() ) l.append( ); | 228 | //if ( !mData->sound.isEmpty() ) l.append( ); |
230 | //if ( !mData->agent.isEmpty() ) l.append( ); | 229 | //if ( !mData->agent.isEmpty() ) l.append( ); |
231 | //if ( mData->url.isValid() ) l.append( ); | 230 | //if ( mData->url.isValid() ) l.append( ); |
232 | #if 0 | 231 | #if 0 |
233 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); | 232 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); |
234 | if ( !mData->addresses.isEmpty() ) l.append( ); | 233 | if ( !mData->addresses.isEmpty() ) l.append( ); |
235 | //if ( !mData->keys.isEmpty() ) l.append( ); | 234 | //if ( !mData->keys.isEmpty() ) l.append( ); |
236 | if ( !mData->emails.isEmpty() ) l.append( ); | 235 | if ( !mData->emails.isEmpty() ) l.append( ); |
237 | if ( !mData->categories .isEmpty() ) l.append( ); | 236 | if ( !mData->categories .isEmpty() ) l.append( ); |
238 | if ( !mData->custom.isEmpty() ) l.append( ); | 237 | if ( !mData->custom.isEmpty() ) l.append( ); |
239 | #endif | 238 | #endif |
240 | KABC::PhoneNumber::List phoneNumbers; | 239 | KABC::PhoneNumber::List phoneNumbers; |
241 | KABC::PhoneNumber::List::Iterator phoneIter; | 240 | KABC::PhoneNumber::List::Iterator phoneIter; |
242 | 241 | ||
243 | QStringList t; | 242 | QStringList t; |
244 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 243 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
245 | ++phoneIter ) | 244 | ++phoneIter ) |
246 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 245 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
247 | t.sort(); | 246 | t.sort(); |
248 | uint iii; | 247 | uint iii; |
249 | for ( iii = 0; iii < t.count(); ++iii) | 248 | for ( iii = 0; iii < t.count(); ++iii) |
250 | l.append( t[iii] ); | 249 | l.append( t[iii] ); |
251 | t = mData->emails; | 250 | t = mData->emails; |
252 | t.sort(); | 251 | t.sort(); |
253 | for ( iii = 0; iii < t.count(); ++iii) | 252 | for ( iii = 0; iii < t.count(); ++iii) |
254 | l.append( t[iii] ); | 253 | l.append( t[iii] ); |
255 | t = mData->categories; | 254 | t = mData->categories; |
256 | t.sort(); | 255 | t.sort(); |
257 | for ( iii = 0; iii < t.count(); ++iii) | 256 | for ( iii = 0; iii < t.count(); ++iii) |
258 | l.append( t[iii] ); | 257 | l.append( t[iii] ); |
259 | t = mData->custom; | 258 | t = mData->custom; |
260 | t.sort(); | 259 | t.sort(); |
261 | for ( iii = 0; iii < t.count(); ++iii) | 260 | for ( iii = 0; iii < t.count(); ++iii) |
262 | l.append( t[iii] ); | 261 | l.append( t[iii] ); |
263 | KABC::Address::List::Iterator addressIter; | 262 | KABC::Address::List::Iterator addressIter; |
264 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 263 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
265 | ++addressIter ) { | 264 | ++addressIter ) { |
266 | t = (*addressIter).asList(); | 265 | t = (*addressIter).asList(); |
267 | t.sort(); | 266 | t.sort(); |
268 | for ( iii = 0; iii < t.count(); ++iii) | 267 | for ( iii = 0; iii < t.count(); ++iii) |
269 | l.append( t[iii] ); | 268 | l.append( t[iii] ); |
270 | } | 269 | } |
271 | setCsum( dev, QString::number (getCsum4List(l)) ); | 270 | uint cs = getCsum4List(l); |
271 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | ||
272 | setCsum( dev, QString::number (cs )); | ||
272 | } | 273 | } |
273 | void Addressee::removeID(const QString &prof) | 274 | void Addressee::removeID(const QString &prof) |
274 | { | 275 | { |
275 | detach(); | 276 | detach(); |
276 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 277 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
277 | 278 | ||
278 | } | 279 | } |
279 | void Addressee::setID( const QString & prof , const QString & id ) | 280 | void Addressee::setID( const QString & prof , const QString & id ) |
280 | { | 281 | { |
281 | detach(); | 282 | detach(); |
283 | qDebug("setID1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | ||
282 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 284 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
285 | qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | ||
283 | } | 286 | } |
284 | void Addressee::setTempSyncStat( int id ) | 287 | void Addressee::setTempSyncStat( int id ) |
285 | { | 288 | { |
286 | mTempSyncStat = id; | 289 | if ( mData->mTempSyncStat == id ) return; |
290 | detach(); | ||
291 | mData->mTempSyncStat = id; | ||
287 | } | 292 | } |
288 | int Addressee::tempSyncStat() const | 293 | int Addressee::tempSyncStat() const |
289 | { | 294 | { |
290 | return mTempSyncStat; | 295 | return mData->mTempSyncStat; |
291 | } | 296 | } |
292 | 297 | ||
293 | QString Addressee::getID( const QString & prof) | 298 | QString Addressee::getID( const QString & prof) |
294 | { | 299 | { |
295 | return KIdManager::getId ( mData->mExternalId, prof ); | 300 | return KIdManager::getId ( mData->mExternalId, prof ); |
296 | } | 301 | } |
297 | 302 | ||
298 | void Addressee::setCsum( const QString & prof , const QString & id ) | 303 | void Addressee::setCsum( const QString & prof , const QString & id ) |
299 | { | 304 | { |
300 | detach(); | 305 | detach(); |
306 | qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | ||
301 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 307 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
308 | qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | ||
302 | } | 309 | } |
303 | 310 | ||
304 | QString Addressee::getCsum( const QString & prof) | 311 | QString Addressee::getCsum( const QString & prof) |
305 | { | 312 | { |
306 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 313 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
307 | } | 314 | } |
308 | 315 | ||
309 | void Addressee::setIDStr( const QString & s ) | 316 | void Addressee::setIDStr( const QString & s ) |
310 | { | 317 | { |
311 | detach(); | 318 | detach(); |
312 | mData->mExternalId = s; | 319 | mData->mExternalId = s; |
313 | } | 320 | } |
314 | 321 | ||
315 | QString Addressee::IDStr() const | 322 | QString Addressee::IDStr() const |
316 | { | 323 | { |
317 | return mData->mExternalId; | 324 | return mData->mExternalId; |
318 | } | 325 | } |
319 | 326 | ||
320 | 327 | ||
321 | void Addressee::setUid( const QString &id ) | 328 | void Addressee::setUid( const QString &id ) |
322 | { | 329 | { |
323 | if ( id == mData->uid ) return; | 330 | if ( id == mData->uid ) return; |
324 | detach(); | 331 | detach(); |
325 | mData->empty = false; | 332 | mData->empty = false; |
326 | mData->uid = id; | 333 | mData->uid = id; |
327 | } | 334 | } |
328 | 335 | ||
329 | QString Addressee::uid() const | 336 | QString Addressee::uid() const |
330 | { | 337 | { |
331 | if ( mData->uid.isEmpty() ) | 338 | if ( mData->uid.isEmpty() ) |
332 | mData->uid = KApplication::randomString( 10 ); | 339 | mData->uid = KApplication::randomString( 10 ); |
333 | 340 | ||
334 | return mData->uid; | 341 | return mData->uid; |
335 | } | 342 | } |
336 | 343 | ||
337 | QString Addressee::uidLabel() | 344 | QString Addressee::uidLabel() |
338 | { | 345 | { |
339 | return i18n("Unique Identifier"); | 346 | return i18n("Unique Identifier"); |
340 | } | 347 | } |
341 | 348 | ||
342 | void Addressee::setName( const QString &name ) | 349 | void Addressee::setName( const QString &name ) |
343 | { | 350 | { |
344 | if ( name == mData->name ) return; | 351 | if ( name == mData->name ) return; |
345 | detach(); | 352 | detach(); |
346 | mData->empty = false; | 353 | mData->empty = false; |
347 | mData->name = name; | 354 | mData->name = name; |
348 | } | 355 | } |
349 | 356 | ||
350 | QString Addressee::name() const | 357 | QString Addressee::name() const |
351 | { | 358 | { |
352 | return mData->name; | 359 | return mData->name; |
353 | } | 360 | } |
354 | 361 | ||
355 | QString Addressee::nameLabel() | 362 | QString Addressee::nameLabel() |
356 | { | 363 | { |
357 | return i18n("Name"); | 364 | return i18n("Name"); |
358 | } | 365 | } |
359 | 366 | ||
360 | 367 | ||
361 | void Addressee::setFormattedName( const QString &formattedName ) | 368 | void Addressee::setFormattedName( const QString &formattedName ) |
362 | { | 369 | { |
363 | if ( formattedName == mData->formattedName ) return; | 370 | if ( formattedName == mData->formattedName ) return; |
364 | detach(); | 371 | detach(); |
365 | mData->empty = false; | 372 | mData->empty = false; |
366 | mData->formattedName = formattedName; | 373 | mData->formattedName = formattedName; |
367 | } | 374 | } |
368 | 375 | ||
369 | QString Addressee::formattedName() const | 376 | QString Addressee::formattedName() const |
370 | { | 377 | { |
371 | return mData->formattedName; | 378 | return mData->formattedName; |
372 | } | 379 | } |
373 | 380 | ||
374 | QString Addressee::formattedNameLabel() | 381 | QString Addressee::formattedNameLabel() |
375 | { | 382 | { |
376 | return i18n("Formatted Name"); | 383 | return i18n("Formatted Name"); |
377 | } | 384 | } |
378 | 385 | ||
379 | 386 | ||
380 | void Addressee::setFamilyName( const QString &familyName ) | 387 | void Addressee::setFamilyName( const QString &familyName ) |
381 | { | 388 | { |
382 | if ( familyName == mData->familyName ) return; | 389 | if ( familyName == mData->familyName ) return; |
383 | detach(); | 390 | detach(); |
384 | mData->empty = false; | 391 | mData->empty = false; |
385 | mData->familyName = familyName; | 392 | mData->familyName = familyName; |
386 | } | 393 | } |
387 | 394 | ||
388 | QString Addressee::familyName() const | 395 | QString Addressee::familyName() const |
389 | { | 396 | { |
390 | return mData->familyName; | 397 | return mData->familyName; |
391 | } | 398 | } |
392 | 399 | ||
393 | QString Addressee::familyNameLabel() | 400 | QString Addressee::familyNameLabel() |
394 | { | 401 | { |
395 | return i18n("Family Name"); | 402 | return i18n("Family Name"); |
396 | } | 403 | } |
397 | 404 | ||
398 | 405 | ||
399 | void Addressee::setGivenName( const QString &givenName ) | 406 | void Addressee::setGivenName( const QString &givenName ) |
400 | { | 407 | { |
401 | if ( givenName == mData->givenName ) return; | 408 | if ( givenName == mData->givenName ) return; |
402 | detach(); | 409 | detach(); |
403 | mData->empty = false; | 410 | mData->empty = false; |
404 | mData->givenName = givenName; | 411 | mData->givenName = givenName; |
405 | } | 412 | } |
406 | 413 | ||
407 | QString Addressee::givenName() const | 414 | QString Addressee::givenName() const |
408 | { | 415 | { |
409 | return mData->givenName; | 416 | return mData->givenName; |
410 | } | 417 | } |
411 | 418 | ||
412 | QString Addressee::givenNameLabel() | 419 | QString Addressee::givenNameLabel() |
413 | { | 420 | { |
414 | return i18n("Given Name"); | 421 | return i18n("Given Name"); |
415 | } | 422 | } |
416 | 423 | ||
417 | 424 | ||
418 | void Addressee::setAdditionalName( const QString &additionalName ) | 425 | void Addressee::setAdditionalName( const QString &additionalName ) |
419 | { | 426 | { |
420 | if ( additionalName == mData->additionalName ) return; | 427 | if ( additionalName == mData->additionalName ) return; |
421 | detach(); | 428 | detach(); |
422 | mData->empty = false; | 429 | mData->empty = false; |
423 | mData->additionalName = additionalName; | 430 | mData->additionalName = additionalName; |
424 | } | 431 | } |
425 | 432 | ||
426 | QString Addressee::additionalName() const | 433 | QString Addressee::additionalName() const |
427 | { | 434 | { |
428 | return mData->additionalName; | 435 | return mData->additionalName; |
429 | } | 436 | } |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 0805458..bfb0840 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -701,140 +701,139 @@ class Addressee | |||
701 | in this addressee it is not duplicated. | 701 | in this addressee it is not duplicated. |
702 | */ | 702 | */ |
703 | void insertAddress( const Address &address ); | 703 | void insertAddress( const Address &address ); |
704 | 704 | ||
705 | /** | 705 | /** |
706 | Remove address. If no address with the given id exists for this | 706 | Remove address. If no address with the given id exists for this |
707 | addresse nothing happens. | 707 | addresse nothing happens. |
708 | */ | 708 | */ |
709 | void removeAddress( const Address &address ); | 709 | void removeAddress( const Address &address ); |
710 | 710 | ||
711 | /** | 711 | /** |
712 | Return address, which matches the given type. | 712 | Return address, which matches the given type. |
713 | */ | 713 | */ |
714 | Address address( int type ) const; | 714 | Address address( int type ) const; |
715 | 715 | ||
716 | /** | 716 | /** |
717 | Return list of all addresses. | 717 | Return list of all addresses. |
718 | */ | 718 | */ |
719 | Address::List addresses() const; | 719 | Address::List addresses() const; |
720 | 720 | ||
721 | /** | 721 | /** |
722 | Return list of addresses with a special type. | 722 | Return list of addresses with a special type. |
723 | */ | 723 | */ |
724 | Address::List addresses( int type ) const; | 724 | Address::List addresses( int type ) const; |
725 | 725 | ||
726 | /** | 726 | /** |
727 | Return address with the given id. | 727 | Return address with the given id. |
728 | */ | 728 | */ |
729 | Address findAddress( const QString &id ) const; | 729 | Address findAddress( const QString &id ) const; |
730 | 730 | ||
731 | /** | 731 | /** |
732 | Insert category. If the category already exists it is not duplicated. | 732 | Insert category. If the category already exists it is not duplicated. |
733 | */ | 733 | */ |
734 | void insertCategory( const QString & ); | 734 | void insertCategory( const QString & ); |
735 | 735 | ||
736 | /** | 736 | /** |
737 | Remove category. | 737 | Remove category. |
738 | */ | 738 | */ |
739 | void removeCategory( const QString & ); | 739 | void removeCategory( const QString & ); |
740 | 740 | ||
741 | /** | 741 | /** |
742 | Return, if addressee has the given category. | 742 | Return, if addressee has the given category. |
743 | */ | 743 | */ |
744 | bool hasCategory( const QString & ) const; | 744 | bool hasCategory( const QString & ) const; |
745 | 745 | ||
746 | /** | 746 | /** |
747 | Set categories to given value. | 747 | Set categories to given value. |
748 | */ | 748 | */ |
749 | void setCategories( const QStringList & ); | 749 | void setCategories( const QStringList & ); |
750 | 750 | ||
751 | /** | 751 | /** |
752 | Return list of all set categories. | 752 | Return list of all set categories. |
753 | */ | 753 | */ |
754 | QStringList categories() const; | 754 | QStringList categories() const; |
755 | 755 | ||
756 | /** | 756 | /** |
757 | Insert custom entry. The entry is identified by the name of the inserting | 757 | Insert custom entry. The entry is identified by the name of the inserting |
758 | application and a unique name. If an entry with the given app and name | 758 | application and a unique name. If an entry with the given app and name |
759 | already exists its value is replaced with the new given value. | 759 | already exists its value is replaced with the new given value. |
760 | */ | 760 | */ |
761 | void insertCustom( const QString &app, const QString &name, | 761 | void insertCustom( const QString &app, const QString &name, |
762 | const QString &value ); | 762 | const QString &value ); |
763 | 763 | ||
764 | /** | 764 | /** |
765 | Remove custom entry. | 765 | Remove custom entry. |
766 | */ | 766 | */ |
767 | void removeCustom( const QString &app, const QString &name ); | 767 | void removeCustom( const QString &app, const QString &name ); |
768 | 768 | ||
769 | /** | 769 | /** |
770 | Return value of custom entry, identified by app and entry name. | 770 | Return value of custom entry, identified by app and entry name. |
771 | */ | 771 | */ |
772 | QString custom( const QString &app, const QString &name ) const; | 772 | QString custom( const QString &app, const QString &name ) const; |
773 | 773 | ||
774 | /** | 774 | /** |
775 | Set all custom entries. | 775 | Set all custom entries. |
776 | */ | 776 | */ |
777 | void setCustoms( const QStringList & ); | 777 | void setCustoms( const QStringList & ); |
778 | 778 | ||
779 | /** | 779 | /** |
780 | Return list of all custom entries. | 780 | Return list of all custom entries. |
781 | */ | 781 | */ |
782 | QStringList customs() const; | 782 | QStringList customs() const; |
783 | 783 | ||
784 | /** | 784 | /** |
785 | Parse full email address. The result is given back in fullName and email. | 785 | Parse full email address. The result is given back in fullName and email. |
786 | */ | 786 | */ |
787 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, | 787 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, |
788 | QString &email ); | 788 | QString &email ); |
789 | 789 | ||
790 | /** | 790 | /** |
791 | Debug output. | 791 | Debug output. |
792 | */ | 792 | */ |
793 | void dump() const; | 793 | void dump() const; |
794 | 794 | ||
795 | /** | 795 | /** |
796 | Returns string representation of the addressee. | 796 | Returns string representation of the addressee. |
797 | */ | 797 | */ |
798 | QString asString() const; | 798 | QString asString() const; |
799 | 799 | ||
800 | /** | 800 | /** |
801 | Set resource where the addressee is from. | 801 | Set resource where the addressee is from. |
802 | */ | 802 | */ |
803 | void setResource( Resource *resource ); | 803 | void setResource( Resource *resource ); |
804 | 804 | ||
805 | /** | 805 | /** |
806 | Return pointer to resource. | 806 | Return pointer to resource. |
807 | */ | 807 | */ |
808 | Resource *resource() const; | 808 | Resource *resource() const; |
809 | 809 | ||
810 | /** | 810 | /** |
811 | Return resourcelabel. | 811 | Return resourcelabel. |
812 | */ | 812 | */ |
813 | //US | 813 | //US |
814 | static QString resourceLabel(); | 814 | static QString resourceLabel(); |
815 | 815 | ||
816 | /** | 816 | /** |
817 | Mark addressee as changed. | 817 | Mark addressee as changed. |
818 | */ | 818 | */ |
819 | void setChanged( bool value ); | 819 | void setChanged( bool value ); |
820 | 820 | ||
821 | /** | 821 | /** |
822 | Return whether the addressee is changed. | 822 | Return whether the addressee is changed. |
823 | */ | 823 | */ |
824 | bool changed() const; | 824 | bool changed() const; |
825 | 825 | ||
826 | private: | 826 | private: |
827 | Addressee copy(); | 827 | Addressee copy(); |
828 | void detach(); | 828 | void detach(); |
829 | int mTempSyncStat; | ||
830 | 829 | ||
831 | struct AddresseeData; | 830 | struct AddresseeData; |
832 | mutable KSharedPtr<AddresseeData> mData; | 831 | mutable KSharedPtr<AddresseeData> mData; |
833 | }; | 832 | }; |
834 | 833 | ||
835 | QDataStream &operator<<( QDataStream &, const Addressee & ); | 834 | QDataStream &operator<<( QDataStream &, const Addressee & ); |
836 | QDataStream &operator>>( QDataStream &, Addressee & ); | 835 | QDataStream &operator>>( QDataStream &, Addressee & ); |
837 | 836 | ||
838 | } | 837 | } |
839 | 838 | ||
840 | #endif | 839 | #endif |
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp index ec47a4e..181a09e 100644 --- a/kabc/stdaddressbook.cpp +++ b/kabc/stdaddressbook.cpp | |||
@@ -40,185 +40,190 @@ using namespace KABC; | |||
40 | StdAddressBook *StdAddressBook::mSelf = 0; | 40 | StdAddressBook *StdAddressBook::mSelf = 0; |
41 | bool StdAddressBook::mAutomaticSave = true; | 41 | bool StdAddressBook::mAutomaticSave = true; |
42 | 42 | ||
43 | static KStaticDeleter<StdAddressBook> addressBookDeleter; | 43 | static KStaticDeleter<StdAddressBook> addressBookDeleter; |
44 | 44 | ||
45 | QString StdAddressBook::fileName() | 45 | QString StdAddressBook::fileName() |
46 | { | 46 | { |
47 | return locateLocal( "data", "kabc/std.vcf" ); | 47 | return locateLocal( "data", "kabc/std.vcf" ); |
48 | } | 48 | } |
49 | 49 | ||
50 | QString StdAddressBook::directoryName() | 50 | QString StdAddressBook::directoryName() |
51 | { | 51 | { |
52 | return locateLocal( "data", "kabc/stdvcf" ); | 52 | return locateLocal( "data", "kabc/stdvcf" ); |
53 | } | 53 | } |
54 | 54 | ||
55 | void StdAddressBook::handleCrash() | 55 | void StdAddressBook::handleCrash() |
56 | { | 56 | { |
57 | StdAddressBook::self()->cleanUp(); | 57 | StdAddressBook::self()->cleanUp(); |
58 | } | 58 | } |
59 | 59 | ||
60 | StdAddressBook *StdAddressBook::self() | 60 | StdAddressBook *StdAddressBook::self() |
61 | { | 61 | { |
62 | 62 | ||
63 | if ( !mSelf ) | 63 | if ( !mSelf ) |
64 | { | 64 | { |
65 | QString appdir = StdAddressBook::setTempAppDir(); | 65 | QString appdir = StdAddressBook::setTempAppDir(); |
66 | // US im am not sure why I have to use the other format here?? | 66 | // US im am not sure why I have to use the other format here?? |
67 | #ifdef KAB_EMBEDDED | 67 | #ifdef KAB_EMBEDDED |
68 | mSelf = addressBookDeleter.setObject( new StdAddressBook ); | 68 | mSelf = addressBookDeleter.setObject( new StdAddressBook ); |
69 | #else //KAB_EMBEDDED | 69 | #else //KAB_EMBEDDED |
70 | addressBookDeleter.setObject( mSelf, new StdAddressBook ); | 70 | addressBookDeleter.setObject( mSelf, new StdAddressBook ); |
71 | #endif //KAB_EMBEDDED | 71 | #endif //KAB_EMBEDDED |
72 | KStandardDirs::setAppDir( appdir ); | 72 | KStandardDirs::setAppDir( appdir ); |
73 | } | 73 | } |
74 | 74 | ||
75 | return mSelf; | 75 | return mSelf; |
76 | } | 76 | } |
77 | 77 | ||
78 | QString StdAddressBook::setTempAppDir() | 78 | QString StdAddressBook::setTempAppDir() |
79 | { | 79 | { |
80 | QString appDIR = KStandardDirs::appDir(); | 80 | QString appDIR = KStandardDirs::appDir(); |
81 | #ifdef DESKTOP_VERSION | 81 | #ifdef DESKTOP_VERSION |
82 | QString appdir = QDir::homeDirPath(); | 82 | QString appdir = QDir::homeDirPath(); |
83 | if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) | 83 | if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) |
84 | appdir += "kaddressbook/"; | 84 | appdir += "kaddressbook/"; |
85 | else | 85 | else |
86 | appdir += "/kaddressbook/"; | 86 | appdir += "/kaddressbook/"; |
87 | KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); | 87 | KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); |
88 | #else | 88 | #else |
89 | QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook"; | 89 | QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook"; |
90 | 90 | ||
91 | KStandardDirs::setAppDir( appdir ); | 91 | KStandardDirs::setAppDir( appdir ); |
92 | #endif | 92 | #endif |
93 | 93 | ||
94 | return appDIR; | 94 | return appDIR; |
95 | } | 95 | } |
96 | StdAddressBook *StdAddressBook::self( bool onlyFastResources ) | 96 | StdAddressBook *StdAddressBook::self( bool onlyFastResources ) |
97 | { | 97 | { |
98 | 98 | ||
99 | if ( !mSelf ) | 99 | if ( !mSelf ) |
100 | { | 100 | { |
101 | QString appdir =StdAddressBook::setTempAppDir(); | 101 | QString appdir =StdAddressBook::setTempAppDir(); |
102 | #ifdef KAB_EMBEDDED | 102 | #ifdef KAB_EMBEDDED |
103 | mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); | 103 | mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); |
104 | #else //KAB_EMBEDDED | 104 | #else //KAB_EMBEDDED |
105 | addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); | 105 | addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); |
106 | #endif //KAB_EMBEDDED | 106 | #endif //KAB_EMBEDDED |
107 | KStandardDirs::setAppDir( appdir ); | 107 | KStandardDirs::setAppDir( appdir ); |
108 | } | 108 | } |
109 | return mSelf; | 109 | return mSelf; |
110 | } | 110 | } |
111 | 111 | ||
112 | StdAddressBook::StdAddressBook() | 112 | StdAddressBook::StdAddressBook() |
113 | : AddressBook( "kabcrc" ) | 113 | : AddressBook( "kabcrc" ) |
114 | { | 114 | { |
115 | 115 | ||
116 | init( false ); | 116 | init( false ); |
117 | } | 117 | } |
118 | 118 | ||
119 | StdAddressBook::StdAddressBook( bool onlyFastResources ) | 119 | StdAddressBook::StdAddressBook( bool onlyFastResources ) |
120 | : AddressBook( "kabcrc" ) | 120 | : AddressBook( "kabcrc" ) |
121 | { | 121 | { |
122 | 122 | ||
123 | init( onlyFastResources ); | 123 | init( onlyFastResources ); |
124 | } | 124 | } |
125 | 125 | ||
126 | StdAddressBook::~StdAddressBook() | 126 | StdAddressBook::~StdAddressBook() |
127 | { | 127 | { |
128 | if ( mAutomaticSave ) | 128 | if ( mAutomaticSave ) |
129 | save(); | 129 | save(); |
130 | } | 130 | } |
131 | 131 | ||
132 | void StdAddressBook::init( bool ) | 132 | void StdAddressBook::init( bool ) |
133 | { | 133 | { |
134 | KRES::Manager<Resource> *manager = resourceManager(); | 134 | KRES::Manager<Resource> *manager = resourceManager(); |
135 | KRES::Manager<Resource>::ActiveIterator it; | 135 | KRES::Manager<Resource>::ActiveIterator it; |
136 | 136 | ||
137 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 137 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
138 | (*it)->setAddressBook( this ); | 138 | (*it)->setAddressBook( this ); |
139 | if ( !(*it)->open() ) | 139 | if ( !(*it)->open() ) |
140 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 140 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
141 | } | 141 | } |
142 | 142 | ||
143 | Resource *res = standardResource(); | 143 | Resource *res = standardResource(); |
144 | if ( !res ) { | 144 | if ( !res ) { |
145 | res = manager->createResource( "file" ); | 145 | res = manager->createResource( "file" ); |
146 | if ( res ) | 146 | if ( res ) |
147 | { | 147 | { |
148 | addResource( res ); | 148 | addResource( res ); |
149 | } | 149 | } |
150 | else | 150 | else |
151 | qDebug(" No resource available!!!"); | 151 | qDebug(" No resource available!!!"); |
152 | } | 152 | } |
153 | 153 | ||
154 | setStandardResource( res ); | 154 | setStandardResource( res ); |
155 | manager->writeConfig(); | 155 | manager->writeConfig(); |
156 | 156 | ||
157 | load(); | 157 | load(); |
158 | } | 158 | } |
159 | 159 | ||
160 | bool StdAddressBook::save() | 160 | bool StdAddressBook::save() |
161 | { | 161 | { |
162 | kdDebug(5700) << "StdAddressBook::save()" << endl; | 162 | kdDebug(5700) << "StdAddressBook::save()" << endl; |
163 | 163 | ||
164 | bool ok = true; | 164 | bool ok = true; |
165 | AddressBook *ab = self(); | 165 | AddressBook *ab = self(); |
166 | 166 | ||
167 | ab->deleteRemovedAddressees(); | 167 | ab->deleteRemovedAddressees(); |
168 | 168 | Iterator ait; | |
169 | for ( ait = ab->begin(); ait != ab->end(); ++ait ) { | ||
170 | if ( !(*ait).IDStr().isEmpty() ) { | ||
171 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | ||
172 | } | ||
173 | } | ||
169 | KRES::Manager<Resource>::ActiveIterator it; | 174 | KRES::Manager<Resource>::ActiveIterator it; |
170 | KRES::Manager<Resource> *manager = ab->resourceManager(); | 175 | KRES::Manager<Resource> *manager = ab->resourceManager(); |
171 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 176 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
172 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 177 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
173 | Ticket *ticket = ab->requestSaveTicket( *it ); | 178 | Ticket *ticket = ab->requestSaveTicket( *it ); |
174 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 179 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
175 | if ( !ticket ) { | 180 | if ( !ticket ) { |
176 | ab->error( i18n( "Unable to save to resource '%1'. It is locked." ) | 181 | ab->error( i18n( "Unable to save to resource '%1'. It is locked." ) |
177 | .arg( (*it)->resourceName() ) ); | 182 | .arg( (*it)->resourceName() ) ); |
178 | return false; | 183 | return false; |
179 | } | 184 | } |
180 | 185 | ||
181 | if ( !ab->save( ticket ) ) | 186 | if ( !ab->save( ticket ) ) |
182 | ok = false; | 187 | ok = false; |
183 | } | 188 | } |
184 | } | 189 | } |
185 | 190 | ||
186 | return ok; | 191 | return ok; |
187 | } | 192 | } |
188 | 193 | ||
189 | void StdAddressBook::close() | 194 | void StdAddressBook::close() |
190 | { | 195 | { |
191 | //US destructObject is not defined on my system???. Is setObject(0) the same ??? | 196 | //US destructObject is not defined on my system???. Is setObject(0) the same ??? |
192 | //US addressBookDeleter.destructObject(); | 197 | //US addressBookDeleter.destructObject(); |
193 | addressBookDeleter.setObject(0); | 198 | addressBookDeleter.setObject(0); |
194 | 199 | ||
195 | } | 200 | } |
196 | 201 | ||
197 | void StdAddressBook::setAutomaticSave( bool enable ) | 202 | void StdAddressBook::setAutomaticSave( bool enable ) |
198 | { | 203 | { |
199 | mAutomaticSave = enable; | 204 | mAutomaticSave = enable; |
200 | } | 205 | } |
201 | 206 | ||
202 | bool StdAddressBook::automaticSave() | 207 | bool StdAddressBook::automaticSave() |
203 | { | 208 | { |
204 | return mAutomaticSave; | 209 | return mAutomaticSave; |
205 | } | 210 | } |
206 | 211 | ||
207 | // should get const for 4.X | 212 | // should get const for 4.X |
208 | Addressee StdAddressBook::whoAmI() | 213 | Addressee StdAddressBook::whoAmI() |
209 | { | 214 | { |
210 | //US KConfig config( "kabcrc" ); | 215 | //US KConfig config( "kabcrc" ); |
211 | KConfig config( locateLocal("config", "kabcrc") ); | 216 | KConfig config( locateLocal("config", "kabcrc") ); |
212 | config.setGroup( "General" ); | 217 | config.setGroup( "General" ); |
213 | 218 | ||
214 | return findByUid( config.readEntry( "WhoAmI" ) ); | 219 | return findByUid( config.readEntry( "WhoAmI" ) ); |
215 | } | 220 | } |
216 | 221 | ||
217 | void StdAddressBook::setWhoAmI( const Addressee &addr ) | 222 | void StdAddressBook::setWhoAmI( const Addressee &addr ) |
218 | { | 223 | { |
219 | //US KConfig config( "kabcrc" ); | 224 | //US KConfig config( "kabcrc" ); |
220 | KConfig config( locateLocal("config", "kabcrc") ); | 225 | KConfig config( locateLocal("config", "kabcrc") ); |
221 | config.setGroup( "General" ); | 226 | config.setGroup( "General" ); |
222 | 227 | ||
223 | config.writeEntry( "WhoAmI", addr.uid() ); | 228 | config.writeEntry( "WhoAmI", addr.uid() ); |
224 | } | 229 | } |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 8776b53..56f6af2 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2401,621 +2401,622 @@ void KABCore::syncRemote( KSyncProfile* prof, bool ask) | |||
2401 | command.insert( len , "\n" ); | 2401 | command.insert( len , "\n" ); |
2402 | len += maxlen +2; | 2402 | len += maxlen +2; |
2403 | } | 2403 | } |
2404 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | 2404 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; |
2405 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2405 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2406 | question, | 2406 | question, |
2407 | i18n("Okay!")) ; | 2407 | i18n("Okay!")) ; |
2408 | setCaption ("KO/Pi"); | 2408 | setCaption ("KO/Pi"); |
2409 | return; | 2409 | return; |
2410 | } | 2410 | } |
2411 | setCaption ( i18n( "Copying succeed." ) ); | 2411 | setCaption ( i18n( "Copying succeed." ) ); |
2412 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 2412 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
2413 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { | 2413 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { |
2414 | // Event* e = mView->getLastSyncEvent(); | 2414 | // Event* e = mView->getLastSyncEvent(); |
2415 | // e->setReadOnly( false ); | 2415 | // e->setReadOnly( false ); |
2416 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2416 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2417 | // e->setReadOnly( true ); | 2417 | // e->setReadOnly( true ); |
2418 | if ( KABPrefs::instance()->mWriteBackFile ) { | 2418 | if ( KABPrefs::instance()->mWriteBackFile ) { |
2419 | command = prof->getPostSyncCommandAB(); | 2419 | command = prof->getPostSyncCommandAB(); |
2420 | int fi; | 2420 | int fi; |
2421 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2421 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2422 | QString pwd = getPassword(); | 2422 | QString pwd = getPassword(); |
2423 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2423 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2424 | 2424 | ||
2425 | } | 2425 | } |
2426 | setCaption ( i18n( "Writing back file ..." ) ); | 2426 | setCaption ( i18n( "Writing back file ..." ) ); |
2427 | result = system ( command ); | 2427 | result = system ( command ); |
2428 | qDebug("KO: Writing back file result: %d ", result); | 2428 | qDebug("KO: Writing back file result: %d ", result); |
2429 | if ( result != 0 ) { | 2429 | if ( result != 0 ) { |
2430 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 2430 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
2431 | return; | 2431 | return; |
2432 | } else { | 2432 | } else { |
2433 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2433 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2434 | } | 2434 | } |
2435 | } | 2435 | } |
2436 | } | 2436 | } |
2437 | return; | 2437 | return; |
2438 | } | 2438 | } |
2439 | #include <qpushbutton.h> | 2439 | #include <qpushbutton.h> |
2440 | #include <qradiobutton.h> | 2440 | #include <qradiobutton.h> |
2441 | #include <qbuttongroup.h> | 2441 | #include <qbuttongroup.h> |
2442 | void KABCore::edit_sync_options() | 2442 | void KABCore::edit_sync_options() |
2443 | { | 2443 | { |
2444 | //mDialogManager->showSyncOptions(); | 2444 | //mDialogManager->showSyncOptions(); |
2445 | //KABPrefs::instance()->mSyncAlgoPrefs | 2445 | //KABPrefs::instance()->mSyncAlgoPrefs |
2446 | QDialog dia( this, "dia", true ); | 2446 | QDialog dia( this, "dia", true ); |
2447 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 2447 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
2448 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 2448 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
2449 | QVBoxLayout lay ( &dia ); | 2449 | QVBoxLayout lay ( &dia ); |
2450 | lay.setSpacing( 2 ); | 2450 | lay.setSpacing( 2 ); |
2451 | lay.setMargin( 3 ); | 2451 | lay.setMargin( 3 ); |
2452 | lay.addWidget(&gr); | 2452 | lay.addWidget(&gr); |
2453 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 2453 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
2454 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 2454 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
2455 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 2455 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
2456 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 2456 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
2457 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 2457 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
2458 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 2458 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
2459 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 2459 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
2460 | QPushButton pb ( "OK", &dia); | 2460 | QPushButton pb ( "OK", &dia); |
2461 | lay.addWidget( &pb ); | 2461 | lay.addWidget( &pb ); |
2462 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2462 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2463 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { | 2463 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { |
2464 | case 0: | 2464 | case 0: |
2465 | loc.setChecked( true); | 2465 | loc.setChecked( true); |
2466 | break; | 2466 | break; |
2467 | case 1: | 2467 | case 1: |
2468 | rem.setChecked( true ); | 2468 | rem.setChecked( true ); |
2469 | break; | 2469 | break; |
2470 | case 2: | 2470 | case 2: |
2471 | newest.setChecked( true); | 2471 | newest.setChecked( true); |
2472 | break; | 2472 | break; |
2473 | case 3: | 2473 | case 3: |
2474 | ask.setChecked( true); | 2474 | ask.setChecked( true); |
2475 | break; | 2475 | break; |
2476 | case 4: | 2476 | case 4: |
2477 | f_loc.setChecked( true); | 2477 | f_loc.setChecked( true); |
2478 | break; | 2478 | break; |
2479 | case 5: | 2479 | case 5: |
2480 | f_rem.setChecked( true); | 2480 | f_rem.setChecked( true); |
2481 | break; | 2481 | break; |
2482 | case 6: | 2482 | case 6: |
2483 | // both.setChecked( true); | 2483 | // both.setChecked( true); |
2484 | break; | 2484 | break; |
2485 | default: | 2485 | default: |
2486 | break; | 2486 | break; |
2487 | } | 2487 | } |
2488 | if ( dia.exec() ) { | 2488 | if ( dia.exec() ) { |
2489 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 2489 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
2490 | } | 2490 | } |
2491 | 2491 | ||
2492 | 2492 | ||
2493 | } | 2493 | } |
2494 | QString KABCore::getPassword( ) | 2494 | QString KABCore::getPassword( ) |
2495 | { | 2495 | { |
2496 | QString retfile = ""; | 2496 | QString retfile = ""; |
2497 | QDialog dia ( this, "input-dialog", true ); | 2497 | QDialog dia ( this, "input-dialog", true ); |
2498 | QLineEdit lab ( &dia ); | 2498 | QLineEdit lab ( &dia ); |
2499 | lab.setEchoMode( QLineEdit::Password ); | 2499 | lab.setEchoMode( QLineEdit::Password ); |
2500 | QVBoxLayout lay( &dia ); | 2500 | QVBoxLayout lay( &dia ); |
2501 | lay.setMargin(7); | 2501 | lay.setMargin(7); |
2502 | lay.setSpacing(7); | 2502 | lay.setSpacing(7); |
2503 | lay.addWidget( &lab); | 2503 | lay.addWidget( &lab); |
2504 | dia.setFixedSize( 230,50 ); | 2504 | dia.setFixedSize( 230,50 ); |
2505 | dia.setCaption( i18n("Enter password") ); | 2505 | dia.setCaption( i18n("Enter password") ); |
2506 | QPushButton pb ( "OK", &dia); | 2506 | QPushButton pb ( "OK", &dia); |
2507 | lay.addWidget( &pb ); | 2507 | lay.addWidget( &pb ); |
2508 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2508 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2509 | dia.show(); | 2509 | dia.show(); |
2510 | int res = dia.exec(); | 2510 | int res = dia.exec(); |
2511 | if ( res ) | 2511 | if ( res ) |
2512 | retfile = lab.text(); | 2512 | retfile = lab.text(); |
2513 | dia.hide(); | 2513 | dia.hide(); |
2514 | qApp->processEvents(); | 2514 | qApp->processEvents(); |
2515 | return retfile; | 2515 | return retfile; |
2516 | 2516 | ||
2517 | } | 2517 | } |
2518 | #include <libkcal/syncdefines.h> | 2518 | #include <libkcal/syncdefines.h> |
2519 | 2519 | ||
2520 | KABC::Addressee KABCore::getLastSyncAddressee() | 2520 | KABC::Addressee KABCore::getLastSyncAddressee() |
2521 | { | 2521 | { |
2522 | Addressee lse; | 2522 | Addressee lse; |
2523 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2523 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2524 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2524 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2525 | if (lse.isEmpty()) { | 2525 | if (lse.isEmpty()) { |
2526 | qDebug("Creating new last-syncAddressee "); | 2526 | qDebug("Creating new last-syncAddressee "); |
2527 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2527 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2528 | QString sum = ""; | 2528 | QString sum = ""; |
2529 | if ( KABPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 2529 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2530 | sum = "E: "; | 2530 | sum = "E: "; |
2531 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2531 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2532 | lse.setRevision( mLastAddressbookSync ); | 2532 | lse.setRevision( mLastAddressbookSync ); |
2533 | lse.setCategories( i18n("SyncEvent") ); | 2533 | lse.setCategories( i18n("SyncEvent") ); |
2534 | mAddressBook->insertAddressee( lse ); | 2534 | mAddressBook->insertAddressee( lse ); |
2535 | } | 2535 | } |
2536 | return lse; | 2536 | return lse; |
2537 | } | 2537 | } |
2538 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2538 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2539 | { | 2539 | { |
2540 | 2540 | ||
2541 | //void setZaurusId(int id); | 2541 | //void setZaurusId(int id); |
2542 | // int zaurusId() const; | 2542 | // int zaurusId() const; |
2543 | // void setZaurusUid(int id); | 2543 | // void setZaurusUid(int id); |
2544 | // int zaurusUid() const; | 2544 | // int zaurusUid() const; |
2545 | // void setZaurusStat(int id); | 2545 | // void setZaurusStat(int id); |
2546 | // int zaurusStat() const; | 2546 | // int zaurusStat() const; |
2547 | // 0 equal | 2547 | // 0 equal |
2548 | // 1 take local | 2548 | // 1 take local |
2549 | // 2 take remote | 2549 | // 2 take remote |
2550 | // 3 cancel | 2550 | // 3 cancel |
2551 | QDateTime lastSync = mLastAddressbookSync; | 2551 | QDateTime lastSync = mLastAddressbookSync; |
2552 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2552 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2553 | bool remCh, locCh; | 2553 | bool remCh, locCh; |
2554 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2554 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2555 | //if ( remCh ) | 2555 | if ( remCh ) |
2556 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2556 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2557 | locCh = ( local->revision() > mLastAddressbookSync ); | 2557 | locCh = ( local->revision() > mLastAddressbookSync ); |
2558 | if ( !remCh && ! locCh ) { | 2558 | if ( !remCh && ! locCh ) { |
2559 | //qDebug("both not changed "); | 2559 | qDebug("both not changed "); |
2560 | lastSync = local->revision().addDays(1); | 2560 | lastSync = local->revision().addDays(1); |
2561 | if ( mode <= SYNC_PREF_ASK ) | ||
2562 | return 0; | ||
2561 | } else { | 2563 | } else { |
2562 | if ( locCh ) { | 2564 | if ( locCh ) { |
2563 | //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); | 2565 | qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2564 | lastSync = local->revision().addDays( -1 ); | 2566 | lastSync = local->revision().addDays( -1 ); |
2565 | if ( !remCh ) | 2567 | if ( !remCh ) |
2566 | remote->setRevision( lastSync.addDays( -1 ) ); | 2568 | remote->setRevision( lastSync.addDays( -1 ) ); |
2567 | } else { | 2569 | } else { |
2568 | //qDebug(" not loc changed "); | 2570 | //qDebug(" not loc changed "); |
2569 | lastSync = local->revision().addDays( 1 ); | 2571 | lastSync = local->revision().addDays( 1 ); |
2570 | if ( remCh ) | 2572 | if ( remCh ) |
2571 | remote->setRevision( lastSync.addDays( 1 ) ); | 2573 | remote->setRevision( lastSync.addDays( 1 ) ); |
2572 | 2574 | ||
2573 | } | 2575 | } |
2574 | } | 2576 | } |
2575 | full = true; | 2577 | full = true; |
2576 | if ( mode < SYNC_PREF_ASK ) | 2578 | if ( mode < SYNC_PREF_ASK ) |
2577 | mode = SYNC_PREF_ASK; | 2579 | mode = SYNC_PREF_ASK; |
2578 | } else { | 2580 | } else { |
2579 | if ( local->revision() == remote->revision() ) | 2581 | if ( local->revision() == remote->revision() ) |
2580 | return 0; | 2582 | return 0; |
2581 | 2583 | ||
2582 | } | 2584 | } |
2583 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2585 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2584 | 2586 | ||
2585 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 2587 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); |
2586 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2588 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2587 | //full = true; //debug only | 2589 | //full = true; //debug only |
2588 | if ( full ) { | 2590 | if ( full ) { |
2589 | bool equ = ( (*local) == (*remote) ); | 2591 | bool equ = ( (*local) == (*remote) ); |
2590 | if ( equ ) { | 2592 | if ( equ ) { |
2591 | //qDebug("equal "); | 2593 | //qDebug("equal "); |
2592 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2594 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2593 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2595 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2594 | } | 2596 | } |
2595 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2597 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2596 | return 0; | 2598 | return 0; |
2597 | 2599 | ||
2598 | }//else //debug only | 2600 | }//else //debug only |
2599 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2601 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2600 | } | 2602 | } |
2601 | int result; | 2603 | int result; |
2602 | bool localIsNew; | 2604 | bool localIsNew; |
2603 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2605 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
2604 | 2606 | ||
2605 | if ( full && mode < SYNC_PREF_NEWEST ) | 2607 | if ( full && mode < SYNC_PREF_NEWEST ) |
2606 | mode = SYNC_PREF_ASK; | 2608 | mode = SYNC_PREF_ASK; |
2607 | 2609 | ||
2608 | switch( mode ) { | 2610 | switch( mode ) { |
2609 | case SYNC_PREF_LOCAL: | 2611 | case SYNC_PREF_LOCAL: |
2610 | if ( lastSync > remote->revision() ) | 2612 | if ( lastSync > remote->revision() ) |
2611 | return 1; | 2613 | return 1; |
2612 | if ( lastSync > local->revision() ) | 2614 | if ( lastSync > local->revision() ) |
2613 | return 2; | 2615 | return 2; |
2614 | return 1; | 2616 | return 1; |
2615 | break; | 2617 | break; |
2616 | case SYNC_PREF_REMOTE: | 2618 | case SYNC_PREF_REMOTE: |
2617 | if ( lastSync > remote->revision() ) | 2619 | if ( lastSync > remote->revision() ) |
2618 | return 1; | 2620 | return 1; |
2619 | if ( lastSync > local->revision() ) | 2621 | if ( lastSync > local->revision() ) |
2620 | return 2; | 2622 | return 2; |
2621 | return 2; | 2623 | return 2; |
2622 | break; | 2624 | break; |
2623 | case SYNC_PREF_NEWEST: | 2625 | case SYNC_PREF_NEWEST: |
2624 | if ( local->revision() > remote->revision() ) | 2626 | if ( local->revision() > remote->revision() ) |
2625 | return 1; | 2627 | return 1; |
2626 | else | 2628 | else |
2627 | return 2; | 2629 | return 2; |
2628 | break; | 2630 | break; |
2629 | case SYNC_PREF_ASK: | 2631 | case SYNC_PREF_ASK: |
2630 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); | 2632 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); |
2631 | if ( lastSync > remote->revision() ) | 2633 | if ( lastSync > remote->revision() ) |
2632 | return 1; | 2634 | return 1; |
2633 | if ( lastSync > local->revision() ) | 2635 | if ( lastSync > local->revision() ) |
2634 | return 2; | 2636 | return 2; |
2635 | localIsNew = local->revision() >= remote->revision(); | 2637 | localIsNew = local->revision() >= remote->revision(); |
2636 | //qDebug("conflict! ************************************** "); | 2638 | //qDebug("conflict! ************************************** "); |
2637 | { | 2639 | { |
2638 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2640 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2639 | result = acd.executeD(localIsNew); | 2641 | result = acd.executeD(localIsNew); |
2640 | return result; | 2642 | return result; |
2641 | } | 2643 | } |
2642 | break; | 2644 | break; |
2643 | case SYNC_PREF_FORCE_LOCAL: | 2645 | case SYNC_PREF_FORCE_LOCAL: |
2644 | return 1; | 2646 | return 1; |
2645 | break; | 2647 | break; |
2646 | case SYNC_PREF_FORCE_REMOTE: | 2648 | case SYNC_PREF_FORCE_REMOTE: |
2647 | return 2; | 2649 | return 2; |
2648 | break; | 2650 | break; |
2649 | 2651 | ||
2650 | default: | 2652 | default: |
2651 | // SYNC_PREF_TAKE_BOTH not implemented | 2653 | // SYNC_PREF_TAKE_BOTH not implemented |
2652 | break; | 2654 | break; |
2653 | } | 2655 | } |
2654 | return 0; | 2656 | return 0; |
2655 | } | 2657 | } |
2656 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2658 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2657 | { | 2659 | { |
2658 | bool syncOK = true; | 2660 | bool syncOK = true; |
2659 | int addedAddressee = 0; | 2661 | int addedAddressee = 0; |
2660 | int addedAddresseeR = 0; | 2662 | int addedAddresseeR = 0; |
2661 | int deletedAddresseeR = 0; | 2663 | int deletedAddresseeR = 0; |
2662 | int deletedAddresseeL = 0; | 2664 | int deletedAddresseeL = 0; |
2663 | int changedLocal = 0; | 2665 | int changedLocal = 0; |
2664 | int changedRemote = 0; | 2666 | int changedRemote = 0; |
2665 | //QPtrList<Addressee> el = local->rawAddressees(); | 2667 | //QPtrList<Addressee> el = local->rawAddressees(); |
2666 | Addressee addresseeR; | 2668 | Addressee addresseeR; |
2667 | QString uid; | 2669 | QString uid; |
2668 | int take; | 2670 | int take; |
2669 | Addressee addresseeL; | 2671 | Addressee addresseeL; |
2670 | Addressee addresseeRSync; | 2672 | Addressee addresseeRSync; |
2671 | Addressee addresseeLSync; | 2673 | Addressee addresseeLSync; |
2672 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2674 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2673 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2675 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2674 | bool fullDateRange = false; | 2676 | bool fullDateRange = false; |
2675 | local->resetTempSyncStat(); | 2677 | local->resetTempSyncStat(); |
2676 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2678 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2677 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2679 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2678 | addresseeLSync = getLastSyncAddressee(); | 2680 | addresseeLSync = getLastSyncAddressee(); |
2679 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2681 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2680 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2682 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2681 | if ( !addresseeR.isEmpty() ) { | 2683 | if ( !addresseeR.isEmpty() ) { |
2682 | addresseeRSync = addresseeR; | 2684 | addresseeRSync = addresseeR; |
2683 | remote->removeAddressee(addresseeR ); | 2685 | remote->removeAddressee(addresseeR ); |
2684 | 2686 | ||
2685 | } else { | 2687 | } else { |
2686 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2688 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2687 | addresseeRSync = addresseeLSync ; | 2689 | addresseeRSync = addresseeLSync ; |
2688 | } else { | 2690 | } else { |
2689 | qDebug("FULLDATE 1"); | 2691 | qDebug("FULLDATE 1"); |
2690 | fullDateRange = true; | 2692 | fullDateRange = true; |
2691 | Addressee newAdd; | 2693 | Addressee newAdd; |
2692 | addresseeRSync = newAdd; | 2694 | addresseeRSync = newAdd; |
2693 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2695 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2694 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2696 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2695 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2697 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2696 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2698 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2697 | } | 2699 | } |
2698 | } | 2700 | } |
2699 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2701 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2700 | qDebug("FULLDATE 2"); | 2702 | qDebug("FULLDATE 2"); |
2701 | fullDateRange = true; | 2703 | fullDateRange = true; |
2702 | } | 2704 | } |
2703 | if ( ! fullDateRange ) { | 2705 | if ( ! fullDateRange ) { |
2704 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2706 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2705 | 2707 | ||
2706 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2708 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2707 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2709 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2708 | fullDateRange = true; | 2710 | fullDateRange = true; |
2709 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2711 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2710 | } | 2712 | } |
2711 | } | 2713 | } |
2712 | // fullDateRange = true; // debug only! | 2714 | // fullDateRange = true; // debug only! |
2713 | if ( fullDateRange ) | 2715 | if ( fullDateRange ) |
2714 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2716 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2715 | else | 2717 | else |
2716 | mLastAddressbookSync = addresseeLSync.revision(); | 2718 | mLastAddressbookSync = addresseeLSync.revision(); |
2717 | // for resyncing if own file has changed | 2719 | // for resyncing if own file has changed |
2718 | // PENDING fixme later when implemented | 2720 | // PENDING fixme later when implemented |
2719 | #if 0 | 2721 | #if 0 |
2720 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2722 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2721 | mLastAddressbookSync = loadedFileVersion; | 2723 | mLastAddressbookSync = loadedFileVersion; |
2722 | qDebug("setting mLastAddressbookSync "); | 2724 | qDebug("setting mLastAddressbookSync "); |
2723 | } | 2725 | } |
2724 | #endif | 2726 | #endif |
2725 | 2727 | ||
2726 | //qDebug("*************************** "); | 2728 | //qDebug("*************************** "); |
2727 | qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2729 | qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2728 | QStringList er = remote->uidList(); | 2730 | QStringList er = remote->uidList(); |
2729 | Addressee inR ;//= er.first(); | 2731 | Addressee inR ;//= er.first(); |
2730 | Addressee inL; | 2732 | Addressee inL; |
2731 | QProgressBar bar( er.count(),0 ); | 2733 | QProgressBar bar( er.count(),0 ); |
2732 | bar.setCaption (i18n("Syncing - close to abort!") ); | 2734 | bar.setCaption (i18n("Syncing - close to abort!") ); |
2733 | 2735 | ||
2734 | int w = 300; | 2736 | int w = 300; |
2735 | if ( QApplication::desktop()->width() < 320 ) | 2737 | if ( QApplication::desktop()->width() < 320 ) |
2736 | w = 220; | 2738 | w = 220; |
2737 | int h = bar.sizeHint().height() ; | 2739 | int h = bar.sizeHint().height() ; |
2738 | int dw = QApplication::desktop()->width(); | 2740 | int dw = QApplication::desktop()->width(); |
2739 | int dh = QApplication::desktop()->height(); | 2741 | int dh = QApplication::desktop()->height(); |
2740 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2742 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2741 | bar.show(); | 2743 | bar.show(); |
2742 | int modulo = (er.count()/10)+1; | 2744 | int modulo = (er.count()/10)+1; |
2743 | int incCounter = 0; | 2745 | int incCounter = 0; |
2744 | while ( incCounter < er.count()) { | 2746 | while ( incCounter < er.count()) { |
2745 | if ( ! bar.isVisible() ) | 2747 | if ( ! bar.isVisible() ) |
2746 | return false; | 2748 | return false; |
2747 | if ( incCounter % modulo == 0 ) | 2749 | if ( incCounter % modulo == 0 ) |
2748 | bar.setProgress( incCounter ); | 2750 | bar.setProgress( incCounter ); |
2749 | uid = er[ incCounter ]; | 2751 | uid = er[ incCounter ]; |
2750 | bool skipIncidence = false; | 2752 | bool skipIncidence = false; |
2751 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2753 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2752 | skipIncidence = true; | 2754 | skipIncidence = true; |
2753 | QString idS; | 2755 | QString idS; |
2754 | qApp->processEvents(); | 2756 | qApp->processEvents(); |
2755 | if ( !skipIncidence ) { | 2757 | if ( !skipIncidence ) { |
2756 | inL = local->findByUid( uid ); | 2758 | inL = local->findByUid( uid ); |
2757 | inR = remote->findByUid( uid ); | 2759 | inR = remote->findByUid( uid ); |
2758 | //inL.setResource( 0 ); | 2760 | //inL.setResource( 0 ); |
2759 | //inR.setResource( 0 ); | 2761 | //inR.setResource( 0 ); |
2760 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2762 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2761 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2763 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2762 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2764 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2763 | if ( take == 3 ) | 2765 | if ( take == 3 ) |
2764 | return false; | 2766 | return false; |
2765 | if ( take == 1 ) {// take local | 2767 | if ( take == 1 ) {// take local |
2766 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2768 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2767 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2769 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2768 | local->insertAddressee( inL, false ); | 2770 | local->insertAddressee( inL, false ); |
2769 | } | 2771 | } |
2770 | else | 2772 | else |
2771 | idS = inR.IDStr(); | 2773 | idS = inR.IDStr(); |
2772 | remote->removeAddressee( inR ); | 2774 | remote->removeAddressee( inR ); |
2773 | inR = inL; | 2775 | inR = inL; |
2774 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2776 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2775 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 2777 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
2776 | inR.setIDStr( idS ); | 2778 | inR.setIDStr( idS ); |
2777 | inR.setResource( 0 ); | 2779 | inR.setResource( 0 ); |
2778 | remote->insertAddressee( inR , false); | 2780 | remote->insertAddressee( inR , false); |
2779 | ++changedRemote; | 2781 | ++changedRemote; |
2780 | } else { | 2782 | } else { |
2781 | idS = inL.IDStr(); | 2783 | idS = inL.IDStr(); |
2782 | local->removeAddressee( inL ); | 2784 | local->removeAddressee( inL ); |
2783 | inL = inR; | 2785 | inL = inR; |
2784 | inL.setIDStr( idS ); | 2786 | inL.setIDStr( idS ); |
2785 | inL.setResource( 0 ); | 2787 | inL.setResource( 0 ); |
2786 | local->insertAddressee( inL , false ); | 2788 | local->insertAddressee( inL , false ); |
2787 | ++changedLocal; | 2789 | ++changedLocal; |
2788 | } | 2790 | } |
2789 | } | 2791 | } |
2790 | } else { // no conflict | 2792 | } else { // no conflict |
2791 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2793 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2792 | QString des = addresseeLSync.note(); | 2794 | QString des = addresseeLSync.note(); |
2793 | QString pref = "a"; | 2795 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2794 | if ( des.find(pref+ inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | ||
2795 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2796 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2797 | remote->insertAddressee( inR, false ); | ||
2796 | ++deletedAddresseeR; | 2798 | ++deletedAddresseeR; |
2797 | } else { | 2799 | } else { |
2798 | inR.setRevision( modifiedCalendar ); | 2800 | inR.setRevision( modifiedCalendar ); |
2799 | remote->insertAddressee( inR, false ); | 2801 | remote->insertAddressee( inR, false ); |
2800 | inL = inR; | 2802 | inL = inR; |
2801 | inL.setResource( 0 ); | 2803 | inL.setResource( 0 ); |
2802 | local->insertAddressee( inL , false); | 2804 | local->insertAddressee( inL , false); |
2803 | ++addedAddressee; | 2805 | ++addedAddressee; |
2804 | } | 2806 | } |
2805 | } else { | 2807 | } else { |
2806 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2808 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2807 | inR.setRevision( modifiedCalendar ); | 2809 | inR.setRevision( modifiedCalendar ); |
2808 | remote->insertAddressee( inR, false ); | 2810 | remote->insertAddressee( inR, false ); |
2809 | inR.setResource( 0 ); | 2811 | inR.setResource( 0 ); |
2810 | local->insertAddressee( inR, false ); | 2812 | local->insertAddressee( inR, false ); |
2811 | ++addedAddressee; | 2813 | ++addedAddressee; |
2812 | } else { | 2814 | } else { |
2813 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2815 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2814 | remote->removeAddressee( inR ); | 2816 | remote->removeAddressee( inR ); |
2815 | ++deletedAddresseeR; | 2817 | ++deletedAddresseeR; |
2816 | } | 2818 | } |
2817 | } | 2819 | } |
2818 | } | 2820 | } |
2819 | } | 2821 | } |
2820 | ++incCounter; | 2822 | ++incCounter; |
2821 | } | 2823 | } |
2822 | er.clear(); | 2824 | er.clear(); |
2823 | QStringList el = remote->uidList(); | 2825 | QStringList el = local->uidList(); |
2824 | modulo = (el.count()/10)+1; | 2826 | modulo = (el.count()/10)+1; |
2825 | bar.setCaption (i18n("Add / remove addressees") ); | 2827 | bar.setCaption (i18n("Add / remove addressees") ); |
2826 | bar.setTotalSteps ( el.count() ) ; | 2828 | bar.setTotalSteps ( el.count() ) ; |
2827 | bar.show(); | 2829 | bar.show(); |
2828 | incCounter = 0; | 2830 | incCounter = 0; |
2829 | while ( incCounter < el.count()) { | 2831 | while ( incCounter < el.count()) { |
2830 | |||
2831 | qApp->processEvents(); | 2832 | qApp->processEvents(); |
2832 | if ( ! bar.isVisible() ) | 2833 | if ( ! bar.isVisible() ) |
2833 | return false; | 2834 | return false; |
2834 | if ( incCounter % modulo == 0 ) | 2835 | if ( incCounter % modulo == 0 ) |
2835 | bar.setProgress( incCounter ); | 2836 | bar.setProgress( incCounter ); |
2836 | uid = el[ incCounter ]; | 2837 | uid = el[ incCounter ]; |
2837 | bool skipIncidence = false; | 2838 | bool skipIncidence = false; |
2838 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2839 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2839 | skipIncidence = true; | 2840 | skipIncidence = true; |
2840 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | ||
2841 | skipIncidence = true; | ||
2842 | if ( !skipIncidence ) { | 2841 | if ( !skipIncidence ) { |
2843 | inL = local->findByUid( uid ); | 2842 | inL = local->findByUid( uid ); |
2844 | inR = remote->findByUid( uid ); | 2843 | inR = remote->findByUid( uid ); |
2845 | if ( inR.isEmpty() ) { | 2844 | if ( inR.isEmpty() ) { |
2846 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2845 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2847 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2846 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2848 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2847 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2849 | local->removeAddressee( inL ); | 2848 | local->removeAddressee( inL ); |
2850 | ++deletedAddresseeL; | 2849 | ++deletedAddresseeL; |
2851 | } else { | 2850 | } else { |
2852 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2851 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2853 | inL.removeID(mCurrentSyncDevice ); | 2852 | inL.removeID(mCurrentSyncDevice ); |
2854 | ++addedAddresseeR; | 2853 | ++addedAddresseeR; |
2855 | //qDebug("remote added Incidence %s ", inL.summary().latin1()); | ||
2856 | inL.setRevision( modifiedCalendar ); | 2854 | inL.setRevision( modifiedCalendar ); |
2857 | local->insertAddressee( inL, false ); | 2855 | local->insertAddressee( inL, false ); |
2858 | inR = inL; | 2856 | inR = inL; |
2859 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2857 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2860 | inR.setResource( 0 ); | 2858 | inR.setResource( 0 ); |
2861 | remote->insertAddressee( inR, false ); | 2859 | remote->insertAddressee( inR, false ); |
2862 | } | 2860 | } |
2863 | } | 2861 | } |
2864 | } else { | 2862 | } else { |
2865 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2863 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2866 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2864 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2867 | local->removeAddressee( inL ); | 2865 | local->removeAddressee( inL ); |
2868 | ++deletedAddresseeL; | 2866 | ++deletedAddresseeL; |
2869 | } else { | 2867 | } else { |
2870 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2868 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2871 | ++addedAddresseeR; | 2869 | ++addedAddresseeR; |
2872 | inL.setRevision( modifiedCalendar ); | 2870 | inL.setRevision( modifiedCalendar ); |
2873 | local->insertAddressee( inL, false ); | 2871 | local->insertAddressee( inL, false ); |
2874 | inR = inL; | 2872 | inR = inL; |
2875 | inR.setResource( 0 ); | 2873 | inR.setResource( 0 ); |
2876 | remote->insertAddressee( inR, false ); | 2874 | remote->insertAddressee( inR, false ); |
2877 | } | 2875 | } |
2878 | } | 2876 | } |
2879 | } | 2877 | } |
2880 | } | 2878 | } |
2881 | } | 2879 | } |
2882 | ++incCounter; | 2880 | ++incCounter; |
2883 | } | 2881 | } |
2884 | el.clear(); | 2882 | el.clear(); |
2885 | bar.hide(); | 2883 | bar.hide(); |
2886 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2884 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2887 | // get rid of micro seconds | 2885 | // get rid of micro seconds |
2888 | QTime t = mLastAddressbookSync.time(); | 2886 | QTime t = mLastAddressbookSync.time(); |
2889 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2887 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2890 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2888 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2891 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2889 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2892 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2890 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2893 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2891 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2894 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2892 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2895 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2893 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2896 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2894 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2897 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2895 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2896 | addresseeRSync.setNote( "" ) ; | ||
2897 | addresseeLSync.setNote( "" ); | ||
2898 | 2898 | ||
2899 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2899 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2900 | remote->insertAddressee( addresseeRSync, false ); | 2900 | remote->insertAddressee( addresseeRSync, false ); |
2901 | local->insertAddressee( addresseeLSync, false ); | 2901 | local->insertAddressee( addresseeLSync, false ); |
2902 | QString mes; | 2902 | QString mes; |
2903 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2903 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2904 | if ( KABPrefs::instance()->mShowSyncSummary ) { | 2904 | if ( KABPrefs::instance()->mShowSyncSummary ) { |
2905 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2905 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2906 | } | 2906 | } |
2907 | qDebug( mes ); | 2907 | qDebug( mes ); |
2908 | return syncOK; | 2908 | return syncOK; |
2909 | } | 2909 | } |
2910 | 2910 | ||
2911 | bool KABCore::syncAB(QString filename, int mode) | 2911 | bool KABCore::syncAB(QString filename, int mode) |
2912 | { | 2912 | { |
2913 | 2913 | ||
2914 | //pending prepare addresseeview for output | 2914 | //pending prepare addresseeview for output |
2915 | //pending detect, if remote file has REV field. if not switch to external sync | 2915 | //pending detect, if remote file has REV field. if not switch to external sync |
2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2917 | AddressBook abLocal(filename,"syncContact"); | 2917 | AddressBook abLocal(filename,"syncContact"); |
2918 | bool syncOK = false; | 2918 | bool syncOK = false; |
2919 | if ( abLocal.load() ) { | 2919 | if ( abLocal.load() ) { |
2920 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); | 2920 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); |
2921 | bool external = false; | 2921 | bool external = false; |
2922 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2922 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2923 | if ( ! lse.isEmpty() ) { | 2923 | if ( ! lse.isEmpty() ) { |
2924 | if ( lse.familyName().left(4) == "!E: " ) | 2924 | if ( lse.familyName().left(4) == "!E: " ) |
2925 | external = true; | 2925 | external = true; |
2926 | } else { | 2926 | } else { |
2927 | bool found = false; | 2927 | bool found = false; |
2928 | QDateTime dt( QDate( 2004,1,1)); | 2928 | QDateTime dt( QDate( 2004,1,1)); |
2929 | AddressBook::Iterator it; | 2929 | AddressBook::Iterator it; |
2930 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2930 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2931 | if ( (*it).revision() != dt ) { | 2931 | if ( (*it).revision() != dt ) { |
2932 | found = true; | 2932 | found = true; |
2933 | break; | 2933 | break; |
2934 | } | 2934 | } |
2935 | } | 2935 | } |
2936 | external = ! found; | 2936 | external = ! found; |
2937 | } | 2937 | } |
2938 | 2938 | ||
2939 | if ( external ) { | 2939 | if ( external ) { |
2940 | qDebug("**********Setting vcf mode to external "); | ||
2940 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2941 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2941 | AddressBook::Iterator it; | 2942 | AddressBook::Iterator it; |
2942 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2943 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2943 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2944 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2944 | (*it).computeCsum( mCurrentSyncDevice ); | 2945 | (*it).computeCsum( mCurrentSyncDevice ); |
2945 | } | 2946 | } |
2946 | } | 2947 | } |
2947 | //AddressBook::Iterator it; | 2948 | //AddressBook::Iterator it; |
2948 | //QStringList vcards; | 2949 | //QStringList vcards; |
2949 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2950 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2950 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2951 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2951 | //} | 2952 | //} |
2952 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2953 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2953 | if ( syncOK ) { | 2954 | if ( syncOK ) { |
2954 | if ( KABPrefs::instance()->mWriteBackFile ) | 2955 | if ( KABPrefs::instance()->mWriteBackFile ) |
2955 | { | 2956 | { |
2956 | if ( external ) | 2957 | if ( external ) |
2957 | abLocal.removeDeletedAddressees(); | 2958 | abLocal.removeDeletedAddressees(); |
2958 | qDebug("saving remote AB "); | 2959 | qDebug("saving remote AB "); |
2959 | abLocal.saveAB(); | 2960 | abLocal.saveAB(); |
2960 | } | 2961 | } |
2961 | } | 2962 | } |
2962 | setModified(); | 2963 | setModified(); |
2963 | 2964 | ||
2964 | } | 2965 | } |
2965 | if ( syncOK ) | 2966 | if ( syncOK ) |
2966 | mViewManager->refreshView(); | 2967 | mViewManager->refreshView(); |
2967 | return syncOK; | 2968 | return syncOK; |
2968 | #if 0 | 2969 | #if 0 |
2969 | 2970 | ||
2970 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2971 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2971 | getEventViewerDialog()->setSyncMode( true ); | 2972 | getEventViewerDialog()->setSyncMode( true ); |
2972 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2973 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2973 | getEventViewerDialog()->setSyncMode( false ); | 2974 | getEventViewerDialog()->setSyncMode( false ); |
2974 | if ( syncOK ) { | 2975 | if ( syncOK ) { |
2975 | if ( KOPrefs::instance()->mWriteBackFile ) | 2976 | if ( KOPrefs::instance()->mWriteBackFile ) |
2976 | { | 2977 | { |
2977 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2978 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2978 | storage->save(); | 2979 | storage->save(); |
2979 | } | 2980 | } |
2980 | } | 2981 | } |
2981 | setModified(); | 2982 | setModified(); |
2982 | } | 2983 | } |
2983 | 2984 | ||
2984 | #endif | 2985 | #endif |
2985 | } | 2986 | } |
2986 | 2987 | ||
2987 | void KABCore::confSync() | 2988 | void KABCore::confSync() |
2988 | { | 2989 | { |
2989 | static KSyncPrefsDialog* sp = 0; | 2990 | static KSyncPrefsDialog* sp = 0; |
2990 | if ( ! sp ) { | 2991 | if ( ! sp ) { |
2991 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 2992 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
2992 | } | 2993 | } |
2993 | sp->usrReadConfig(); | 2994 | sp->usrReadConfig(); |
2994 | #ifndef DESKTOP_VERSION | 2995 | #ifndef DESKTOP_VERSION |
2995 | sp->showMaximized(); | 2996 | sp->showMaximized(); |
2996 | #else | 2997 | #else |
2997 | sp->show(); | 2998 | sp->show(); |
2998 | #endif | 2999 | #endif |
2999 | sp->exec(); | 3000 | sp->exec(); |
3000 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 3001 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
3001 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 3002 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
3002 | fillSyncMenu(); | 3003 | fillSyncMenu(); |
3003 | } | 3004 | } |
3004 | void KABCore::syncSharp() | 3005 | void KABCore::syncSharp() |
3005 | { | 3006 | { |
3006 | if ( mModified ) | 3007 | if ( mModified ) |
3007 | save(); | 3008 | save(); |
3008 | qDebug("pending syncSharp() "); | 3009 | qDebug("pending syncSharp() "); |
3009 | //mView->syncSharp(); | 3010 | //mView->syncSharp(); |
3010 | setModified(); | 3011 | setModified(); |
3011 | 3012 | ||
3012 | } | 3013 | } |
3013 | void KABCore::syncPhone() | 3014 | void KABCore::syncPhone() |
3014 | { | 3015 | { |
3015 | if ( mModified ) | 3016 | if ( mModified ) |
3016 | save(); | 3017 | save(); |
3017 | qDebug("pending syncPhone(); "); | 3018 | qDebug("pending syncPhone(); "); |
3018 | //mView->syncPhone(); | 3019 | //mView->syncPhone(); |
3019 | setModified(); | 3020 | setModified(); |
3020 | 3021 | ||
3021 | } | 3022 | } |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 56b3fb0..0c75632 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -610,256 +610,258 @@ void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | |||
610 | return; | 610 | return; |
611 | } | 611 | } |
612 | int maxSec; | 612 | int maxSec; |
613 | //maxSec = 5; //testing only | 613 | //maxSec = 5; //testing only |
614 | maxSec = 86400+3600; // one day+1hour | 614 | maxSec = 86400+3600; // one day+1hour |
615 | mAlarmNotification = noti; | 615 | mAlarmNotification = noti; |
616 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 616 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
617 | if ( sec > maxSec ) { | 617 | if ( sec > maxSec ) { |
618 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 618 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
619 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 619 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
620 | return; | 620 | return; |
621 | } else { | 621 | } else { |
622 | mRecheckAlarmTimer->stop(); | 622 | mRecheckAlarmTimer->stop(); |
623 | } | 623 | } |
624 | //qDebug("Alarm timer started with secs: %d ", sec); | 624 | //qDebug("Alarm timer started with secs: %d ", sec); |
625 | mAlarmTimer->start( sec *1000 , true ); | 625 | mAlarmTimer->start( sec *1000 , true ); |
626 | 626 | ||
627 | } | 627 | } |
628 | // called by mRecheckAlarmTimer to get next alarm | 628 | // called by mRecheckAlarmTimer to get next alarm |
629 | // we need this, because a QTimer has only a max range of 25 days | 629 | // we need this, because a QTimer has only a max range of 25 days |
630 | void CalendarView::recheckTimerAlarm() | 630 | void CalendarView::recheckTimerAlarm() |
631 | { | 631 | { |
632 | mAlarmTimer->stop(); | 632 | mAlarmTimer->stop(); |
633 | mRecheckAlarmTimer->stop(); | 633 | mRecheckAlarmTimer->stop(); |
634 | mCalendar->checkAlarmForIncidence( 0, true ); | 634 | mCalendar->checkAlarmForIncidence( 0, true ); |
635 | } | 635 | } |
636 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 636 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
637 | { | 637 | { |
638 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 638 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
639 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 639 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
640 | #ifndef DESKTOP_VERSION | 640 | #ifndef DESKTOP_VERSION |
641 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 641 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
642 | #endif | 642 | #endif |
643 | return; | 643 | return; |
644 | } | 644 | } |
645 | mAlarmTimer->stop(); | 645 | mAlarmTimer->stop(); |
646 | } | 646 | } |
647 | void CalendarView::selectWeekNum ( int num ) | 647 | void CalendarView::selectWeekNum ( int num ) |
648 | { | 648 | { |
649 | dateNavigator()->selectWeek( num ); | 649 | dateNavigator()->selectWeek( num ); |
650 | mViewManager->showWeekView(); | 650 | mViewManager->showWeekView(); |
651 | } | 651 | } |
652 | KOViewManager *CalendarView::viewManager() | 652 | KOViewManager *CalendarView::viewManager() |
653 | { | 653 | { |
654 | return mViewManager; | 654 | return mViewManager; |
655 | } | 655 | } |
656 | 656 | ||
657 | KODialogManager *CalendarView::dialogManager() | 657 | KODialogManager *CalendarView::dialogManager() |
658 | { | 658 | { |
659 | return mDialogManager; | 659 | return mDialogManager; |
660 | } | 660 | } |
661 | 661 | ||
662 | QDate CalendarView::startDate() | 662 | QDate CalendarView::startDate() |
663 | { | 663 | { |
664 | DateList dates = mNavigator->selectedDates(); | 664 | DateList dates = mNavigator->selectedDates(); |
665 | 665 | ||
666 | return dates.first(); | 666 | return dates.first(); |
667 | } | 667 | } |
668 | 668 | ||
669 | QDate CalendarView::endDate() | 669 | QDate CalendarView::endDate() |
670 | { | 670 | { |
671 | DateList dates = mNavigator->selectedDates(); | 671 | DateList dates = mNavigator->selectedDates(); |
672 | 672 | ||
673 | return dates.last(); | 673 | return dates.last(); |
674 | } | 674 | } |
675 | 675 | ||
676 | 676 | ||
677 | void CalendarView::createPrinter() | 677 | void CalendarView::createPrinter() |
678 | { | 678 | { |
679 | #ifndef KORG_NOPRINTER | 679 | #ifndef KORG_NOPRINTER |
680 | if (!mCalPrinter) { | 680 | if (!mCalPrinter) { |
681 | mCalPrinter = new CalPrinter(this, mCalendar); | 681 | mCalPrinter = new CalPrinter(this, mCalendar); |
682 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 682 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
683 | } | 683 | } |
684 | #endif | 684 | #endif |
685 | } | 685 | } |
686 | 686 | ||
687 | void CalendarView::confSync() | 687 | void CalendarView::confSync() |
688 | { | 688 | { |
689 | static KSyncPrefsDialog* sp = 0; | 689 | static KSyncPrefsDialog* sp = 0; |
690 | if ( ! sp ) { | 690 | if ( ! sp ) { |
691 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 691 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
692 | } | 692 | } |
693 | sp->usrReadConfig(); | 693 | sp->usrReadConfig(); |
694 | #ifndef DESKTOP_VERSION | 694 | #ifndef DESKTOP_VERSION |
695 | sp->showMaximized(); | 695 | sp->showMaximized(); |
696 | #else | 696 | #else |
697 | sp->show(); | 697 | sp->show(); |
698 | #endif | 698 | #endif |
699 | sp->exec(); | 699 | sp->exec(); |
700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
702 | } | 702 | } |
703 | 703 | ||
704 | 704 | ||
705 | //KOPrefs::instance()->mWriteBackFile | 705 | //KOPrefs::instance()->mWriteBackFile |
706 | //KOPrefs::instance()->mWriteBackExistingOnly | 706 | //KOPrefs::instance()->mWriteBackExistingOnly |
707 | 707 | ||
708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
714 | 714 | ||
715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
716 | { | 716 | { |
717 | 717 | ||
718 | //void setZaurusId(int id); | 718 | //void setZaurusId(int id); |
719 | // int zaurusId() const; | 719 | // int zaurusId() const; |
720 | // void setZaurusUid(int id); | 720 | // void setZaurusUid(int id); |
721 | // int zaurusUid() const; | 721 | // int zaurusUid() const; |
722 | // void setZaurusStat(int id); | 722 | // void setZaurusStat(int id); |
723 | // int zaurusStat() const; | 723 | // int zaurusStat() const; |
724 | // 0 equal | 724 | // 0 equal |
725 | // 1 take local | 725 | // 1 take local |
726 | // 2 take remote | 726 | // 2 take remote |
727 | // 3 cancel | 727 | // 3 cancel |
728 | QDateTime lastSync = mLastCalendarSync; | 728 | QDateTime lastSync = mLastCalendarSync; |
729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
730 | bool remCh, locCh; | 730 | bool remCh, locCh; |
731 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 731 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
732 | //if ( remCh ) | 732 | //if ( remCh ) |
733 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 733 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
734 | locCh = ( local->lastModified() > mLastCalendarSync ); | 734 | locCh = ( local->lastModified() > mLastCalendarSync ); |
735 | if ( !remCh && ! locCh ) { | 735 | if ( !remCh && ! locCh ) { |
736 | //qDebug("both not changed "); | 736 | //qDebug("both not changed "); |
737 | lastSync = local->lastModified().addDays(1); | 737 | lastSync = local->lastModified().addDays(1); |
738 | if ( mode <= SYNC_PREF_ASK ) | ||
739 | return 0; | ||
738 | } else { | 740 | } else { |
739 | if ( locCh ) { | 741 | if ( locCh ) { |
740 | //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); | 742 | //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); |
741 | lastSync = local->lastModified().addDays( -1 ); | 743 | lastSync = local->lastModified().addDays( -1 ); |
742 | if ( !remCh ) | 744 | if ( !remCh ) |
743 | remote->setLastModified( lastSync.addDays( -1 ) ); | 745 | remote->setLastModified( lastSync.addDays( -1 ) ); |
744 | } else { | 746 | } else { |
745 | //qDebug(" not loc changed "); | 747 | //qDebug(" not loc changed "); |
746 | lastSync = local->lastModified().addDays( 1 ); | 748 | lastSync = local->lastModified().addDays( 1 ); |
747 | if ( remCh ) | 749 | if ( remCh ) |
748 | remote->setLastModified( lastSync.addDays( 1 ) ); | 750 | remote->setLastModified( lastSync.addDays( 1 ) ); |
749 | 751 | ||
750 | } | 752 | } |
751 | } | 753 | } |
752 | full = true; | 754 | full = true; |
753 | if ( mode < SYNC_PREF_ASK ) | 755 | if ( mode < SYNC_PREF_ASK ) |
754 | mode = SYNC_PREF_ASK; | 756 | mode = SYNC_PREF_ASK; |
755 | } else { | 757 | } else { |
756 | if ( local->lastModified() == remote->lastModified() ) | 758 | if ( local->lastModified() == remote->lastModified() ) |
757 | if ( local->revision() == remote->revision() ) | 759 | if ( local->revision() == remote->revision() ) |
758 | return 0; | 760 | return 0; |
759 | 761 | ||
760 | } | 762 | } |
761 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 763 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
762 | 764 | ||
763 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 765 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); |
764 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 766 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
765 | //full = true; //debug only | 767 | //full = true; //debug only |
766 | if ( full ) { | 768 | if ( full ) { |
767 | bool equ = false; | 769 | bool equ = false; |
768 | if ( local->type() == "Event" ) { | 770 | if ( local->type() == "Event" ) { |
769 | equ = (*((Event*) local) == *((Event*) remote)); | 771 | equ = (*((Event*) local) == *((Event*) remote)); |
770 | } | 772 | } |
771 | else if ( local->type() =="Todo" ) | 773 | else if ( local->type() =="Todo" ) |
772 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 774 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
773 | else if ( local->type() =="Journal" ) | 775 | else if ( local->type() =="Journal" ) |
774 | equ = (*((Journal*) local) == *((Journal*) remote)); | 776 | equ = (*((Journal*) local) == *((Journal*) remote)); |
775 | if ( equ ) { | 777 | if ( equ ) { |
776 | //qDebug("equal "); | 778 | //qDebug("equal "); |
777 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 779 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
778 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 780 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
779 | } | 781 | } |
780 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 782 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
781 | return 0; | 783 | return 0; |
782 | 784 | ||
783 | }//else //debug only | 785 | }//else //debug only |
784 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 786 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
785 | } | 787 | } |
786 | int result; | 788 | int result; |
787 | bool localIsNew; | 789 | bool localIsNew; |
788 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 790 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
789 | 791 | ||
790 | if ( full && mode < SYNC_PREF_NEWEST ) | 792 | if ( full && mode < SYNC_PREF_NEWEST ) |
791 | mode = SYNC_PREF_ASK; | 793 | mode = SYNC_PREF_ASK; |
792 | 794 | ||
793 | switch( mode ) { | 795 | switch( mode ) { |
794 | case SYNC_PREF_LOCAL: | 796 | case SYNC_PREF_LOCAL: |
795 | if ( lastSync > remote->lastModified() ) | 797 | if ( lastSync > remote->lastModified() ) |
796 | return 1; | 798 | return 1; |
797 | if ( lastSync > local->lastModified() ) | 799 | if ( lastSync > local->lastModified() ) |
798 | return 2; | 800 | return 2; |
799 | return 1; | 801 | return 1; |
800 | break; | 802 | break; |
801 | case SYNC_PREF_REMOTE: | 803 | case SYNC_PREF_REMOTE: |
802 | if ( lastSync > remote->lastModified() ) | 804 | if ( lastSync > remote->lastModified() ) |
803 | return 1; | 805 | return 1; |
804 | if ( lastSync > local->lastModified() ) | 806 | if ( lastSync > local->lastModified() ) |
805 | return 2; | 807 | return 2; |
806 | return 2; | 808 | return 2; |
807 | break; | 809 | break; |
808 | case SYNC_PREF_NEWEST: | 810 | case SYNC_PREF_NEWEST: |
809 | if ( local->lastModified() > remote->lastModified() ) | 811 | if ( local->lastModified() > remote->lastModified() ) |
810 | return 1; | 812 | return 1; |
811 | else | 813 | else |
812 | return 2; | 814 | return 2; |
813 | break; | 815 | break; |
814 | case SYNC_PREF_ASK: | 816 | case SYNC_PREF_ASK: |
815 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
816 | if ( lastSync > remote->lastModified() ) | 818 | if ( lastSync > remote->lastModified() ) |
817 | return 1; | 819 | return 1; |
818 | if ( lastSync > local->lastModified() ) | 820 | if ( lastSync > local->lastModified() ) |
819 | return 2; | 821 | return 2; |
820 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 822 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
821 | localIsNew = local->lastModified() >= remote->lastModified(); | 823 | localIsNew = local->lastModified() >= remote->lastModified(); |
822 | if ( localIsNew ) | 824 | if ( localIsNew ) |
823 | getEventViewerDialog()->setColorMode( 1 ); | 825 | getEventViewerDialog()->setColorMode( 1 ); |
824 | else | 826 | else |
825 | getEventViewerDialog()->setColorMode( 2 ); | 827 | getEventViewerDialog()->setColorMode( 2 ); |
826 | getEventViewerDialog()->setIncidence(local); | 828 | getEventViewerDialog()->setIncidence(local); |
827 | if ( localIsNew ) | 829 | if ( localIsNew ) |
828 | getEventViewerDialog()->setColorMode( 2 ); | 830 | getEventViewerDialog()->setColorMode( 2 ); |
829 | else | 831 | else |
830 | getEventViewerDialog()->setColorMode( 1 ); | 832 | getEventViewerDialog()->setColorMode( 1 ); |
831 | getEventViewerDialog()->addIncidence(remote); | 833 | getEventViewerDialog()->addIncidence(remote); |
832 | getEventViewerDialog()->setColorMode( 0 ); | 834 | getEventViewerDialog()->setColorMode( 0 ); |
833 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 835 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
834 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 836 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
835 | getEventViewerDialog()->showMe(); | 837 | getEventViewerDialog()->showMe(); |
836 | result = getEventViewerDialog()->executeS( localIsNew ); | 838 | result = getEventViewerDialog()->executeS( localIsNew ); |
837 | return result; | 839 | return result; |
838 | 840 | ||
839 | break; | 841 | break; |
840 | case SYNC_PREF_FORCE_LOCAL: | 842 | case SYNC_PREF_FORCE_LOCAL: |
841 | return 1; | 843 | return 1; |
842 | break; | 844 | break; |
843 | case SYNC_PREF_FORCE_REMOTE: | 845 | case SYNC_PREF_FORCE_REMOTE: |
844 | return 2; | 846 | return 2; |
845 | break; | 847 | break; |
846 | 848 | ||
847 | default: | 849 | default: |
848 | // SYNC_PREF_TAKE_BOTH not implemented | 850 | // SYNC_PREF_TAKE_BOTH not implemented |
849 | break; | 851 | break; |
850 | } | 852 | } |
851 | return 0; | 853 | return 0; |
852 | } | 854 | } |
853 | Event* CalendarView::getLastSyncEvent() | 855 | Event* CalendarView::getLastSyncEvent() |
854 | { | 856 | { |
855 | Event* lse; | 857 | Event* lse; |
856 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 858 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
857 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 859 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
858 | if (!lse) { | 860 | if (!lse) { |
859 | lse = new Event(); | 861 | lse = new Event(); |
860 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 862 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
861 | QString sum = ""; | 863 | QString sum = ""; |
862 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 864 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
863 | sum = "E: "; | 865 | sum = "E: "; |
864 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 866 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
865 | lse->setDtStart( mLastCalendarSync ); | 867 | lse->setDtStart( mLastCalendarSync ); |