author | zautrix <zautrix> | 2004-09-18 19:07:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-18 19:07:00 (UTC) |
commit | 28f894fd2a0dfbd5f09f9e530f359981efe0198c (patch) (unidiff) | |
tree | 426565d2716916f48b0c3e68b41e963fd10a3463 | |
parent | ec8099bf369e5b8327ca6cfd78b34366353e3abf (diff) | |
download | kdepimpi-28f894fd2a0dfbd5f09f9e530f359981efe0198c.zip kdepimpi-28f894fd2a0dfbd5f09f9e530f359981efe0198c.tar.gz kdepimpi-28f894fd2a0dfbd5f09f9e530f359981efe0198c.tar.bz2 |
more AB sync
-rw-r--r-- | kabc/addresseeview.cpp | 15 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 29 |
2 files changed, 11 insertions, 33 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index 487e8a5..2dda968 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp | |||
@@ -319,149 +319,146 @@ void AddresseeView::setAddressee( const KABC::Addressee& addr ) | |||
319 | //US | 319 | //US |
320 | .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) | 320 | .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) |
321 | .arg( picString ) | 321 | .arg( picString ) |
322 | .arg( name ) | 322 | .arg( name ) |
323 | .arg( aRole ) | 323 | .arg( aRole ) |
324 | .arg( aOrga ) | 324 | .arg( aOrga ) |
325 | .arg( dynamicPart ) | 325 | .arg( dynamicPart ) |
326 | .arg( notes ); | 326 | .arg( notes ); |
327 | 327 | ||
328 | } else { // no picture! | 328 | } else { // no picture! |
329 | 329 | ||
330 | mText = "<table width=\"100%\">\n"; | 330 | mText = "<table width=\"100%\">\n"; |
331 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 331 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
332 | #ifdef DESKTOP_VERSION | 332 | #ifdef DESKTOP_VERSION |
333 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; | 333 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; |
334 | #else | 334 | #else |
335 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h2>"; | 335 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h2>"; |
336 | #endif | 336 | #endif |
337 | 337 | ||
338 | #ifdef DESKTOP_VERSION | 338 | #ifdef DESKTOP_VERSION |
339 | mText += "<font color=\"#FFFFFF\"> <em>" + name+"</em></font></h1>"; | 339 | mText += "<font color=\"#FFFFFF\"> <em>" + name+"</em></font></h1>"; |
340 | #else | 340 | #else |
341 | mText += "<font color=\"#FFFFFF\"> <em>" + name +"</em></font></h2>"; | 341 | mText += "<font color=\"#FFFFFF\"> <em>" + name +"</em></font></h2>"; |
342 | #endif | 342 | #endif |
343 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 343 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
344 | 344 | ||
345 | mText += "<table><td colspan=\"2\"> </td>"; | 345 | mText += "<table><td colspan=\"2\"> </td>"; |
346 | /* | 346 | /* |
347 | mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" | 347 | mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" |
348 | "<td align=\"left\"><b>%2</b></td></tr>" ) | 348 | "<td align=\"left\"><b>%2</b></td></tr>" ) |
349 | .arg( i18n(" ") ) | 349 | .arg( i18n(" ") ) |
350 | .arg( name ); | 350 | .arg( name ); |
351 | */ | 351 | */ |
352 | if ( ! mAddressee.role().isEmpty() ) | 352 | if ( ! mAddressee.role().isEmpty() ) |
353 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" | 353 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" |
354 | "<td align=\"left\">%2</td></tr>" ) | 354 | "<td align=\"left\">%2</td></tr>" ) |
355 | .arg( i18n(" ") ) | 355 | .arg( i18n(" ") ) |
356 | .arg( mAddressee.role()); | 356 | .arg( mAddressee.role()); |
357 | if ( ! mAddressee.organization().isEmpty() ) | 357 | if ( ! mAddressee.organization().isEmpty() ) |
358 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" | 358 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" |
359 | "<td align=\"left\">%2</td></tr>" ) | 359 | "<td align=\"left\">%2</td></tr>" ) |
360 | .arg( i18n(" ") ) | 360 | .arg( i18n(" ") ) |
361 | .arg( mAddressee.organization()); | 361 | .arg( mAddressee.organization()); |
362 | mText += dynamicPart; | 362 | mText += dynamicPart; |
363 | mText += notes; | 363 | mText += notes; |
364 | mText += "</table>"; | 364 | mText += "</table>"; |
365 | 365 | ||
366 | } | 366 | } |
367 | 367 | ||
368 | // at last display it... | 368 | // at last display it... |
369 | setText( mText ); | 369 | setText( mText ); |
370 | 370 | ||
371 | } | 371 | } |
372 | 372 | ||
373 | KABC::Addressee AddresseeView::addressee() const | 373 | KABC::Addressee AddresseeView::addressee() const |
374 | { | 374 | { |
375 | return mAddressee; | 375 | return mAddressee; |
376 | } | 376 | } |
377 | void AddresseeView::addTag(const QString & tag,const QString & text) | 377 | void AddresseeView::addTag(const QString & tag,const QString & text) |
378 | { | 378 | { |
379 | if ( text.isEmpty() ) | 379 | if ( text.isEmpty() ) |
380 | return; | 380 | return; |
381 | int number=text.contains("\n"); | 381 | int number=text.contains("\n"); |
382 | QString str = "<" + tag + ">"; | 382 | QString str = "<" + tag + ">"; |
383 | QString tmpText=text; | 383 | QString tmpText=text; |
384 | QString tmpStr=str; | 384 | QString tmpStr=str; |
385 | if(number !=-1) | 385 | if(number !=-1) |
386 | { | 386 | { |
387 | if (number > 0) { | 387 | if (number > 0) { |
388 | int pos=0; | 388 | int pos=0; |
389 | QString tmp; | 389 | QString tmp; |
390 | for(int i=0;i<=number;i++) { | 390 | for(int i=0;i<=number;i++) { |
391 | pos=tmpText.find("\n"); | 391 | pos=tmpText.find("\n"); |
392 | tmp=tmpText.left(pos); | 392 | tmp=tmpText.left(pos); |
393 | tmpText=tmpText.right(tmpText.length()-pos-1); | 393 | tmpText=tmpText.right(tmpText.length()-pos-1); |
394 | tmpStr+=tmp+"<br>"; | 394 | tmpStr+=tmp+"<br>"; |
395 | } | 395 | } |
396 | } | 396 | } |
397 | else tmpStr += tmpText; | 397 | else tmpStr += tmpText; |
398 | tmpStr+="</" + tag + ">"; | 398 | tmpStr+="</" + tag + ">"; |
399 | mText.append(tmpStr); | 399 | mText.append(tmpStr); |
400 | } | 400 | } |
401 | else | 401 | else |
402 | { | 402 | { |
403 | str += text + "</" + tag + ">"; | 403 | str += text + "</" + tag + ">"; |
404 | mText.append(str); | 404 | mText.append(str); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | 407 | ||
408 | AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, | 408 | AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, |
409 | true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) | 409 | true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) |
410 | { | 410 | { |
411 | findButton( Close )->setText( i18n("Cancel Sync")); | 411 | findButton( Close )->setText( i18n("Cancel Sync")); |
412 | findButton( Ok )->setText( i18n("Remote")); | 412 | findButton( Ok )->setText( i18n("Remote")); |
413 | findButton( User1 )->setText( i18n("Local")); | 413 | findButton( User1 )->setText( i18n("Local")); |
414 | QWidget* topframe = new QWidget( this ); | 414 | QWidget* topframe = new QWidget( this ); |
415 | //QVBox* topframe = new QVBox( this ); | ||
416 | setMainWidget( topframe ); | 415 | setMainWidget( topframe ); |
417 | QBoxLayout* bl; | 416 | QBoxLayout* bl; |
418 | if ( QApplication::desktop()->width() < 640 ) { | 417 | if ( QApplication::desktop()->width() < 640 ) { |
419 | bl = new QVBoxLayout( topframe ); | 418 | bl = new QVBoxLayout( topframe ); |
420 | |||
421 | } else { | 419 | } else { |
422 | bl = new QHBoxLayout( topframe ); | 420 | bl = new QHBoxLayout( topframe ); |
423 | |||
424 | } | 421 | } |
425 | QVBox* subframe = new QVBox( topframe ); | 422 | QVBox* subframe = new QVBox( topframe ); |
426 | bl->addWidget(subframe ); | 423 | bl->addWidget(subframe ); |
427 | QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); | 424 | QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); |
425 | if ( takeloc ) | ||
426 | lab->setBackgroundColor(Qt::green.light() ); | ||
428 | AddresseeView * av = new AddresseeView( subframe ); | 427 | AddresseeView * av = new AddresseeView( subframe ); |
429 | av->setAddressee( loc ); | 428 | av->setAddressee( loc ); |
430 | subframe = new QVBox( topframe ); | 429 | subframe = new QVBox( topframe ); |
431 | bl->addWidget(subframe ); | 430 | bl->addWidget(subframe ); |
432 | lab = new QLabel( i18n("Remote Addressee"), subframe ); | 431 | lab = new QLabel( i18n("Remote Addressee"), subframe ); |
432 | if ( !takeloc ) | ||
433 | lab->setBackgroundColor(Qt::green.light() ); | ||
433 | av = new AddresseeView( subframe ); | 434 | av = new AddresseeView( subframe ); |
434 | av->setAddressee( rem ); | 435 | av->setAddressee( rem ); |
435 | 436 | QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); | |
436 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), | 437 | QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); |
437 | SLOT(slot_remote())); | ||
438 | QObject::connect(this,SIGNAL(user1Clicked()), | ||
439 | SLOT(slot_local())); | ||
440 | #ifndef DESKTOP_VERSION | 438 | #ifndef DESKTOP_VERSION |
441 | showMaximized(); | 439 | showMaximized(); |
442 | #else | 440 | #else |
443 | resize ( 640, 400 ); | 441 | resize ( 640, 400 ); |
444 | #endif | 442 | #endif |
445 | } | 443 | } |
446 | 444 | ||
447 | int AddresseeChooser::executeD( bool local ) | 445 | int AddresseeChooser::executeD( bool local ) |
448 | { | 446 | { |
449 | mSyncResult = 3; | 447 | mSyncResult = 3; |
450 | if ( local ) | 448 | if ( local ) |
451 | findButton( User1 )->setFocus(); | 449 | findButton( User1 )->setFocus(); |
452 | else | 450 | else |
453 | findButton( Ok )->setFocus(); | 451 | findButton( Ok )->setFocus(); |
454 | exec(); | 452 | exec(); |
455 | qDebug("returning %d ",mSyncResult ); | ||
456 | return mSyncResult; | 453 | return mSyncResult; |
457 | } | 454 | } |
458 | void AddresseeChooser::slot_remote() | 455 | void AddresseeChooser::slot_remote() |
459 | { | 456 | { |
460 | mSyncResult = 2; | 457 | mSyncResult = 2; |
461 | accept(); | 458 | accept(); |
462 | } | 459 | } |
463 | void AddresseeChooser::slot_local() | 460 | void AddresseeChooser::slot_local() |
464 | { | 461 | { |
465 | mSyncResult = 1; | 462 | mSyncResult = 1; |
466 | accept(); | 463 | accept(); |
467 | } | 464 | } |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index b1a951c..cc8eb52 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2534,221 +2534,203 @@ KABC::Addressee KABCore::getLastSyncAddressee() | |||
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 | } else { | 2561 | } else { |
2562 | if ( locCh ) { | 2562 | if ( locCh ) { |
2563 | //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); | 2563 | //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); |
2564 | lastSync = local->revision().addDays( -1 ); | 2564 | lastSync = local->revision().addDays( -1 ); |
2565 | if ( !remCh ) | 2565 | if ( !remCh ) |
2566 | remote->setRevision( lastSync.addDays( -1 ) ); | 2566 | remote->setRevision( lastSync.addDays( -1 ) ); |
2567 | } else { | 2567 | } else { |
2568 | //qDebug(" not loc changed "); | 2568 | //qDebug(" not loc changed "); |
2569 | lastSync = local->revision().addDays( 1 ); | 2569 | lastSync = local->revision().addDays( 1 ); |
2570 | if ( remCh ) | 2570 | if ( remCh ) |
2571 | remote->setRevision( lastSync.addDays( 1 ) ); | 2571 | remote->setRevision( lastSync.addDays( 1 ) ); |
2572 | 2572 | ||
2573 | } | 2573 | } |
2574 | } | 2574 | } |
2575 | full = true; | 2575 | full = true; |
2576 | if ( mode < SYNC_PREF_ASK ) | 2576 | if ( mode < SYNC_PREF_ASK ) |
2577 | mode = SYNC_PREF_ASK; | 2577 | mode = SYNC_PREF_ASK; |
2578 | } else { | 2578 | } else { |
2579 | if ( local->revision() == remote->revision() ) | 2579 | if ( local->revision() == remote->revision() ) |
2580 | return 0; | 2580 | return 0; |
2581 | 2581 | ||
2582 | } | 2582 | } |
2583 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2583 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2584 | 2584 | ||
2585 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 2585 | //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() ); | 2586 | //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 | 2587 | //full = true; //debug only |
2588 | if ( full ) { | 2588 | if ( full ) { |
2589 | bool equ = ( (*local) == (*remote) ); | 2589 | bool equ = ( (*local) == (*remote) ); |
2590 | if ( equ ) { | 2590 | if ( equ ) { |
2591 | //qDebug("equal "); | 2591 | //qDebug("equal "); |
2592 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2592 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2593 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2593 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2594 | } | 2594 | } |
2595 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2595 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2596 | return 0; | 2596 | return 0; |
2597 | 2597 | ||
2598 | }//else //debug only | 2598 | }//else //debug only |
2599 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2599 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2600 | } | 2600 | } |
2601 | int result; | 2601 | int result; |
2602 | bool localIsNew; | 2602 | 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() ); | 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() ); |
2604 | 2604 | ||
2605 | if ( full && mode < SYNC_PREF_NEWEST ) | 2605 | if ( full && mode < SYNC_PREF_NEWEST ) |
2606 | mode = SYNC_PREF_ASK; | 2606 | mode = SYNC_PREF_ASK; |
2607 | 2607 | ||
2608 | switch( mode ) { | 2608 | switch( mode ) { |
2609 | case SYNC_PREF_LOCAL: | 2609 | case SYNC_PREF_LOCAL: |
2610 | if ( lastSync > remote->revision() ) | 2610 | if ( lastSync > remote->revision() ) |
2611 | return 1; | 2611 | return 1; |
2612 | if ( lastSync > local->revision() ) | 2612 | if ( lastSync > local->revision() ) |
2613 | return 2; | 2613 | return 2; |
2614 | return 1; | 2614 | return 1; |
2615 | break; | 2615 | break; |
2616 | case SYNC_PREF_REMOTE: | 2616 | case SYNC_PREF_REMOTE: |
2617 | if ( lastSync > remote->revision() ) | 2617 | if ( lastSync > remote->revision() ) |
2618 | return 1; | 2618 | return 1; |
2619 | if ( lastSync > local->revision() ) | 2619 | if ( lastSync > local->revision() ) |
2620 | return 2; | 2620 | return 2; |
2621 | return 2; | 2621 | return 2; |
2622 | break; | 2622 | break; |
2623 | case SYNC_PREF_NEWEST: | 2623 | case SYNC_PREF_NEWEST: |
2624 | if ( local->revision() > remote->revision() ) | 2624 | if ( local->revision() > remote->revision() ) |
2625 | return 1; | 2625 | return 1; |
2626 | else | 2626 | else |
2627 | return 2; | 2627 | return 2; |
2628 | break; | 2628 | break; |
2629 | case SYNC_PREF_ASK: | 2629 | case SYNC_PREF_ASK: |
2630 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); | 2630 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); |
2631 | if ( lastSync > remote->revision() ) | 2631 | if ( lastSync > remote->revision() ) |
2632 | return 1; | 2632 | return 1; |
2633 | if ( lastSync > local->revision() ) | 2633 | if ( lastSync > local->revision() ) |
2634 | return 2; | 2634 | return 2; |
2635 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); | ||
2636 | localIsNew = local->revision() >= remote->revision(); | 2635 | localIsNew = local->revision() >= remote->revision(); |
2637 | #if 0 | 2636 | //qDebug("conflict! ************************************** "); |
2638 | if ( localIsNew ) | ||
2639 | getEventViewerDialog()->setColorMode( 1 ); | ||
2640 | else | ||
2641 | getEventViewerDialog()->setColorMode( 2 ); | ||
2642 | getEventViewerDialog()->setIncidence(local); | ||
2643 | if ( localIsNew ) | ||
2644 | getEventViewerDialog()->setColorMode( 2 ); | ||
2645 | else | ||
2646 | getEventViewerDialog()->setColorMode( 1 ); | ||
2647 | getEventViewerDialog()->addIncidence(remote); | ||
2648 | getEventViewerDialog()->setColorMode( 0 ); | ||
2649 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | ||
2650 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | ||
2651 | getEventViewerDialog()->showMe(); | ||
2652 | result = getEventViewerDialog()->executeS( localIsNew ); | ||
2653 | #endif | ||
2654 | qDebug("conflict! ************************************** "); | ||
2655 | { | 2637 | { |
2656 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2638 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2657 | result = acd.executeD(localIsNew); | 2639 | result = acd.executeD(localIsNew); |
2658 | return result; | 2640 | return result; |
2659 | } | 2641 | } |
2660 | break; | 2642 | break; |
2661 | case SYNC_PREF_FORCE_LOCAL: | 2643 | case SYNC_PREF_FORCE_LOCAL: |
2662 | return 1; | 2644 | return 1; |
2663 | break; | 2645 | break; |
2664 | case SYNC_PREF_FORCE_REMOTE: | 2646 | case SYNC_PREF_FORCE_REMOTE: |
2665 | return 2; | 2647 | return 2; |
2666 | break; | 2648 | break; |
2667 | 2649 | ||
2668 | default: | 2650 | default: |
2669 | // SYNC_PREF_TAKE_BOTH not implemented | 2651 | // SYNC_PREF_TAKE_BOTH not implemented |
2670 | break; | 2652 | break; |
2671 | } | 2653 | } |
2672 | return 0; | 2654 | return 0; |
2673 | } | 2655 | } |
2674 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2656 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2675 | { | 2657 | { |
2676 | bool syncOK = true; | 2658 | bool syncOK = true; |
2677 | int addedAddressee = 0; | 2659 | int addedAddressee = 0; |
2678 | int addedAddresseeR = 0; | 2660 | int addedAddresseeR = 0; |
2679 | int deletedAddresseeR = 0; | 2661 | int deletedAddresseeR = 0; |
2680 | int deletedAddresseeL = 0; | 2662 | int deletedAddresseeL = 0; |
2681 | int changedLocal = 0; | 2663 | int changedLocal = 0; |
2682 | int changedRemote = 0; | 2664 | int changedRemote = 0; |
2683 | //QPtrList<Addressee> el = local->rawAddressees(); | 2665 | //QPtrList<Addressee> el = local->rawAddressees(); |
2684 | Addressee addresseeR; | 2666 | Addressee addresseeR; |
2685 | QString uid; | 2667 | QString uid; |
2686 | int take; | 2668 | int take; |
2687 | Addressee addresseeL; | 2669 | Addressee addresseeL; |
2688 | Addressee addresseeRSync; | 2670 | Addressee addresseeRSync; |
2689 | Addressee addresseeLSync; | 2671 | Addressee addresseeLSync; |
2690 | KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2672 | KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2691 | KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2673 | KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2692 | bool fullDateRange = false; | 2674 | bool fullDateRange = false; |
2693 | local->resetTempSyncStat(); | 2675 | local->resetTempSyncStat(); |
2694 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2676 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2695 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2677 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2696 | addresseeLSync = getLastSyncAddressee(); | 2678 | addresseeLSync = getLastSyncAddressee(); |
2697 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2679 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2698 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2680 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2699 | if ( !addresseeR.isEmpty() ) { | 2681 | if ( !addresseeR.isEmpty() ) { |
2700 | addresseeRSync = addresseeR; | 2682 | addresseeRSync = addresseeR; |
2701 | remote->removeAddressee(addresseeR ); | 2683 | remote->removeAddressee(addresseeR ); |
2702 | 2684 | ||
2703 | } else { | 2685 | } else { |
2704 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2686 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2705 | addresseeRSync = addresseeLSync ; | 2687 | addresseeRSync = addresseeLSync ; |
2706 | } else { | 2688 | } else { |
2707 | qDebug("FULLDATE 1"); | 2689 | qDebug("FULLDATE 1"); |
2708 | fullDateRange = true; | 2690 | fullDateRange = true; |
2709 | Addressee newAdd; | 2691 | Addressee newAdd; |
2710 | addresseeRSync = newAdd; | 2692 | addresseeRSync = newAdd; |
2711 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2693 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2712 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2694 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2713 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2695 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2714 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2696 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2715 | } | 2697 | } |
2716 | } | 2698 | } |
2717 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2699 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2718 | qDebug("FULLDATE 2"); | 2700 | qDebug("FULLDATE 2"); |
2719 | fullDateRange = true; | 2701 | fullDateRange = true; |
2720 | } | 2702 | } |
2721 | if ( ! fullDateRange ) { | 2703 | if ( ! fullDateRange ) { |
2722 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2704 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2723 | 2705 | ||
2724 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2706 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2725 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2707 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2726 | fullDateRange = true; | 2708 | fullDateRange = true; |
2727 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2709 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2728 | } | 2710 | } |
2729 | } | 2711 | } |
2730 | fullDateRange = true; // debug only! | 2712 | fullDateRange = true; // debug only! |
2731 | if ( fullDateRange ) | 2713 | if ( fullDateRange ) |
2732 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2714 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2733 | else | 2715 | else |
2734 | mLastAddressbookSync = addresseeLSync.revision(); | 2716 | mLastAddressbookSync = addresseeLSync.revision(); |
2735 | // for resyncing if own file has changed | 2717 | // for resyncing if own file has changed |
2736 | // PENDING fixme later when implemented | 2718 | // PENDING fixme later when implemented |
2737 | #if 0 | 2719 | #if 0 |
2738 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2720 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2739 | mLastAddressbookSync = loadedFileVersion; | 2721 | mLastAddressbookSync = loadedFileVersion; |
2740 | qDebug("setting mLastAddressbookSync "); | 2722 | qDebug("setting mLastAddressbookSync "); |
2741 | } | 2723 | } |
2742 | #endif | 2724 | #endif |
2743 | 2725 | ||
2744 | //qDebug("*************************** "); | 2726 | //qDebug("*************************** "); |
2745 | qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2727 | qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2746 | QStringList er = remote->uidList(); | 2728 | QStringList er = remote->uidList(); |
2747 | Addressee inR ;//= er.first(); | 2729 | Addressee inR ;//= er.first(); |
2748 | Addressee inL; | 2730 | Addressee inL; |
2749 | QProgressBar bar( er.count(),0 ); | 2731 | QProgressBar bar( er.count(),0 ); |
2750 | bar.setCaption (i18n("Syncing - close to abort!") ); | 2732 | bar.setCaption (i18n("Syncing - close to abort!") ); |
2751 | 2733 | ||
2752 | int w = 300; | 2734 | int w = 300; |
2753 | if ( QApplication::desktop()->width() < 320 ) | 2735 | if ( QApplication::desktop()->width() < 320 ) |
2754 | w = 220; | 2736 | w = 220; |
@@ -2881,132 +2863,131 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2881 | } | 2863 | } |
2882 | } else { | 2864 | } else { |
2883 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2865 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2884 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2866 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2885 | local->removeAddressee( inL ); | 2867 | local->removeAddressee( inL ); |
2886 | ++deletedAddresseeL; | 2868 | ++deletedAddresseeL; |
2887 | } else { | 2869 | } else { |
2888 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2870 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2889 | ++addedAddresseeR; | 2871 | ++addedAddresseeR; |
2890 | inL.setRevision( modifiedCalendar ); | 2872 | inL.setRevision( modifiedCalendar ); |
2891 | local->insertAddressee( inL, false ); | 2873 | local->insertAddressee( inL, false ); |
2892 | inR = inL; | 2874 | inR = inL; |
2893 | inR.setResource( 0 ); | 2875 | inR.setResource( 0 ); |
2894 | remote->insertAddressee( inR, false ); | 2876 | remote->insertAddressee( inR, false ); |
2895 | } | 2877 | } |
2896 | } | 2878 | } |
2897 | } | 2879 | } |
2898 | } | 2880 | } |
2899 | } | 2881 | } |
2900 | ++incCounter; | 2882 | ++incCounter; |
2901 | } | 2883 | } |
2902 | el.clear(); | 2884 | el.clear(); |
2903 | bar.hide(); | 2885 | bar.hide(); |
2904 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2886 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2905 | // get rid of micro seconds | 2887 | // get rid of micro seconds |
2906 | QTime t = mLastAddressbookSync.time(); | 2888 | QTime t = mLastAddressbookSync.time(); |
2907 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2889 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2908 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2890 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2909 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2891 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2910 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2892 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2911 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2893 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2912 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2894 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2913 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2895 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2914 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2896 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2915 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2897 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2916 | 2898 | ||
2917 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2899 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2918 | remote->insertAddressee( addresseeRSync, false ); | 2900 | remote->insertAddressee( addresseeRSync, false ); |
2919 | local->insertAddressee( addresseeLSync, false ); | 2901 | local->insertAddressee( addresseeLSync, false ); |
2920 | QString mes; | 2902 | QString mes; |
2921 | 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 ); |
2922 | if ( KABPrefs::instance()->mShowSyncSummary ) { | 2904 | if ( KABPrefs::instance()->mShowSyncSummary ) { |
2923 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2905 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2924 | } | 2906 | } |
2925 | qDebug( mes ); | 2907 | qDebug( mes ); |
2926 | return syncOK; | 2908 | return syncOK; |
2927 | } | 2909 | } |
2928 | 2910 | ||
2929 | bool KABCore::syncAB(QString filename, int mode) | 2911 | bool KABCore::syncAB(QString filename, int mode) |
2930 | { | 2912 | { |
2931 | 2913 | ||
2932 | //pending prepare addresseeview for output | 2914 | //pending prepare addresseeview for output |
2933 | //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 |
2934 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2935 | AddressBook abLocal(filename,"syncContact"); | 2917 | AddressBook abLocal(filename,"syncContact"); |
2936 | bool syncOK = false; | 2918 | bool syncOK = false; |
2937 | if ( abLocal.load() ) { | 2919 | if ( abLocal.load() ) { |
2938 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); | 2920 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); |
2939 | AddressBook::Iterator it; | 2921 | AddressBook::Iterator it; |
2940 | //QStringList vcards; | 2922 | //QStringList vcards; |
2941 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2923 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2942 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2924 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2943 | //} | 2925 | //} |
2944 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2926 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2945 | if ( syncOK ) { | 2927 | if ( syncOK ) { |
2946 | if ( KABPrefs::instance()->mWriteBackFile ) | 2928 | if ( KABPrefs::instance()->mWriteBackFile ) |
2947 | { | 2929 | { |
2948 | qDebug("saving remote AB "); | 2930 | qDebug("saving remote AB "); |
2949 | abLocal.saveAB(); | 2931 | abLocal.saveAB(); |
2950 | } | 2932 | } |
2951 | } | 2933 | } |
2952 | setModified(); | 2934 | setModified(); |
2953 | 2935 | ||
2954 | } | 2936 | } |
2955 | if ( syncOK ) | 2937 | if ( syncOK ) |
2956 | mViewManager->refreshView(); | 2938 | mViewManager->refreshView(); |
2957 | return syncOK; | 2939 | return syncOK; |
2958 | #if 0 | 2940 | #if 0 |
2959 | 2941 | ||
2960 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2942 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2961 | getEventViewerDialog()->setSyncMode( true ); | 2943 | getEventViewerDialog()->setSyncMode( true ); |
2962 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2944 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2963 | getEventViewerDialog()->setSyncMode( false ); | 2945 | getEventViewerDialog()->setSyncMode( false ); |
2964 | if ( syncOK ) { | 2946 | if ( syncOK ) { |
2965 | if ( KOPrefs::instance()->mWriteBackFile ) | 2947 | if ( KOPrefs::instance()->mWriteBackFile ) |
2966 | { | 2948 | { |
2967 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2949 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2968 | storage->save(); | 2950 | storage->save(); |
2969 | } | 2951 | } |
2970 | } | 2952 | } |
2971 | setModified(); | 2953 | setModified(); |
2972 | } | 2954 | } |
2973 | 2955 | ||
2974 | #endif | 2956 | #endif |
2975 | } | 2957 | } |
2976 | 2958 | ||
2977 | |||
2978 | void KABCore::confSync() | 2959 | void KABCore::confSync() |
2979 | { | 2960 | { |
2980 | static KSyncPrefsDialog* sp = 0; | 2961 | static KSyncPrefsDialog* sp = 0; |
2981 | if ( ! sp ) { | 2962 | if ( ! sp ) { |
2982 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 2963 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
2983 | } | 2964 | } |
2984 | sp->usrReadConfig(); | 2965 | sp->usrReadConfig(); |
2985 | #ifndef DESKTOP_VERSION | 2966 | #ifndef DESKTOP_VERSION |
2986 | sp->showMaximized(); | 2967 | sp->showMaximized(); |
2987 | #else | 2968 | #else |
2988 | sp->show(); | 2969 | sp->show(); |
2989 | #endif | 2970 | #endif |
2990 | sp->exec(); | 2971 | sp->exec(); |
2991 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 2972 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
2992 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 2973 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
2993 | fillSyncMenu(); | 2974 | fillSyncMenu(); |
2994 | } | 2975 | } |
2995 | void KABCore::syncSharp() | 2976 | void KABCore::syncSharp() |
2996 | { | 2977 | { |
2997 | if ( mModified ) | 2978 | if ( mModified ) |
2998 | save(); | 2979 | save(); |
2999 | qDebug("pending syncSharp() "); | 2980 | qDebug("pending syncSharp() "); |
3000 | //mView->syncSharp(); | 2981 | //mView->syncSharp(); |
3001 | setModified(); | 2982 | setModified(); |
3002 | 2983 | ||
3003 | } | 2984 | } |
3004 | void KABCore::syncPhone() | 2985 | void KABCore::syncPhone() |
3005 | { | 2986 | { |
3006 | if ( mModified ) | 2987 | if ( mModified ) |
3007 | save(); | 2988 | save(); |
3008 | qDebug("pending syncPhone(); "); | 2989 | qDebug("pending syncPhone(); "); |
3009 | //mView->syncPhone(); | 2990 | //mView->syncPhone(); |
3010 | setModified(); | 2991 | setModified(); |
3011 | 2992 | ||
3012 | } | 2993 | } |