author | zautrix <zautrix> | 2004-10-28 11:37:28 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-28 11:37:28 (UTC) |
commit | af21c3d45173ece8492850b8c2c5019e7c25d59c (patch) (unidiff) | |
tree | 52e60b226372bbe37987df07495b02de321410fe | |
parent | 01cd4ef94b8604532181c390e9abd560aebaf372 (diff) | |
download | kdepimpi-af21c3d45173ece8492850b8c2c5019e7c25d59c.zip kdepimpi-af21c3d45173ece8492850b8c2c5019e7c25d59c.tar.gz kdepimpi-af21c3d45173ece8492850b8c2c5019e7c25d59c.tar.bz2 |
dtm sync fixes
-rw-r--r-- | kaddressbook/kabcore.cpp | 14 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 10 |
2 files changed, 15 insertions, 9 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index bdc5bd8..c75b4bc 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2511,381 +2511,385 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2511 | case SYNC_PREF_FORCE_REMOTE: | 2511 | case SYNC_PREF_FORCE_REMOTE: |
2512 | return 2; | 2512 | return 2; |
2513 | break; | 2513 | break; |
2514 | 2514 | ||
2515 | default: | 2515 | default: |
2516 | // SYNC_PREF_TAKE_BOTH not implemented | 2516 | // SYNC_PREF_TAKE_BOTH not implemented |
2517 | break; | 2517 | break; |
2518 | } | 2518 | } |
2519 | return 0; | 2519 | return 0; |
2520 | } | 2520 | } |
2521 | 2521 | ||
2522 | 2522 | ||
2523 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2523 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2524 | { | 2524 | { |
2525 | bool syncOK = true; | 2525 | bool syncOK = true; |
2526 | int addedAddressee = 0; | 2526 | int addedAddressee = 0; |
2527 | int addedAddresseeR = 0; | 2527 | int addedAddresseeR = 0; |
2528 | int deletedAddresseeR = 0; | 2528 | int deletedAddresseeR = 0; |
2529 | int deletedAddresseeL = 0; | 2529 | int deletedAddresseeL = 0; |
2530 | int changedLocal = 0; | 2530 | int changedLocal = 0; |
2531 | int changedRemote = 0; | 2531 | int changedRemote = 0; |
2532 | 2532 | ||
2533 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2533 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2534 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2534 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2535 | 2535 | ||
2536 | //QPtrList<Addressee> el = local->rawAddressees(); | 2536 | //QPtrList<Addressee> el = local->rawAddressees(); |
2537 | Addressee addresseeR; | 2537 | Addressee addresseeR; |
2538 | QString uid; | 2538 | QString uid; |
2539 | int take; | 2539 | int take; |
2540 | Addressee addresseeL; | 2540 | Addressee addresseeL; |
2541 | Addressee addresseeRSync; | 2541 | Addressee addresseeRSync; |
2542 | Addressee addresseeLSync; | 2542 | Addressee addresseeLSync; |
2543 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2543 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2544 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2544 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2545 | bool fullDateRange = false; | 2545 | bool fullDateRange = false; |
2546 | local->resetTempSyncStat(); | 2546 | local->resetTempSyncStat(); |
2547 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2547 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2548 | if ( syncManager->syncWithDesktop() ) { | 2548 | if ( syncManager->syncWithDesktop() ) { |
2549 | // remote->removeSyncInfo( QString());//remove all info | 2549 | // remote->removeSyncInfo( QString());//remove all info |
2550 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2550 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2551 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2551 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2552 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2552 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2553 | } else { | 2553 | } else { |
2554 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2554 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2555 | } | 2555 | } |
2556 | } | 2556 | } |
2557 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2557 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2558 | addresseeLSync = getLastSyncAddressee(); | 2558 | addresseeLSync = getLastSyncAddressee(); |
2559 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2559 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2560 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2560 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2561 | if ( !addresseeR.isEmpty() ) { | 2561 | if ( !addresseeR.isEmpty() ) { |
2562 | addresseeRSync = addresseeR; | 2562 | addresseeRSync = addresseeR; |
2563 | remote->removeAddressee(addresseeR ); | 2563 | remote->removeAddressee(addresseeR ); |
2564 | 2564 | ||
2565 | } else { | 2565 | } else { |
2566 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2566 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2567 | addresseeRSync = addresseeLSync ; | 2567 | addresseeRSync = addresseeLSync ; |
2568 | } else { | 2568 | } else { |
2569 | qDebug("FULLDATE 1"); | 2569 | qDebug("FULLDATE 1"); |
2570 | fullDateRange = true; | 2570 | fullDateRange = true; |
2571 | Addressee newAdd; | 2571 | Addressee newAdd; |
2572 | addresseeRSync = newAdd; | 2572 | addresseeRSync = newAdd; |
2573 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2573 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2574 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2574 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2575 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2575 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2576 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2576 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2577 | } | 2577 | } |
2578 | } | 2578 | } |
2579 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2579 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2580 | qDebug("FULLDATE 2"); | 2580 | qDebug("FULLDATE 2"); |
2581 | fullDateRange = true; | 2581 | fullDateRange = true; |
2582 | } | 2582 | } |
2583 | if ( ! fullDateRange ) { | 2583 | if ( ! fullDateRange ) { |
2584 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2584 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2585 | 2585 | ||
2586 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2586 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2587 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2587 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2588 | fullDateRange = true; | 2588 | fullDateRange = true; |
2589 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2589 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2590 | } | 2590 | } |
2591 | } | 2591 | } |
2592 | // fullDateRange = true; // debug only! | 2592 | // fullDateRange = true; // debug only! |
2593 | if ( fullDateRange ) | 2593 | if ( fullDateRange ) |
2594 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2594 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2595 | else | 2595 | else |
2596 | mLastAddressbookSync = addresseeLSync.revision(); | 2596 | mLastAddressbookSync = addresseeLSync.revision(); |
2597 | // for resyncing if own file has changed | 2597 | // for resyncing if own file has changed |
2598 | // PENDING fixme later when implemented | 2598 | // PENDING fixme later when implemented |
2599 | #if 0 | 2599 | #if 0 |
2600 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2600 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2601 | mLastAddressbookSync = loadedFileVersion; | 2601 | mLastAddressbookSync = loadedFileVersion; |
2602 | qDebug("setting mLastAddressbookSync "); | 2602 | qDebug("setting mLastAddressbookSync "); |
2603 | } | 2603 | } |
2604 | #endif | 2604 | #endif |
2605 | 2605 | ||
2606 | //qDebug("*************************** "); | 2606 | //qDebug("*************************** "); |
2607 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2607 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2608 | QStringList er = remote->uidList(); | 2608 | QStringList er = remote->uidList(); |
2609 | Addressee inR ;//= er.first(); | 2609 | Addressee inR ;//= er.first(); |
2610 | Addressee inL; | 2610 | Addressee inL; |
2611 | 2611 | ||
2612 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2612 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2613 | 2613 | ||
2614 | int modulo = (er.count()/10)+1; | 2614 | int modulo = (er.count()/10)+1; |
2615 | int incCounter = 0; | 2615 | int incCounter = 0; |
2616 | while ( incCounter < er.count()) { | 2616 | while ( incCounter < er.count()) { |
2617 | if (syncManager->isProgressBarCanceled()) | 2617 | if (syncManager->isProgressBarCanceled()) |
2618 | return false; | 2618 | return false; |
2619 | if ( incCounter % modulo == 0 ) | 2619 | if ( incCounter % modulo == 0 ) |
2620 | syncManager->showProgressBar(incCounter); | 2620 | syncManager->showProgressBar(incCounter); |
2621 | 2621 | ||
2622 | uid = er[ incCounter ]; | 2622 | uid = er[ incCounter ]; |
2623 | bool skipIncidence = false; | 2623 | bool skipIncidence = false; |
2624 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2624 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2625 | skipIncidence = true; | 2625 | skipIncidence = true; |
2626 | QString idS,OidS; | 2626 | QString idS,OidS; |
2627 | qApp->processEvents(); | 2627 | qApp->processEvents(); |
2628 | if ( !skipIncidence ) { | 2628 | if ( !skipIncidence ) { |
2629 | inL = local->findByUid( uid ); | 2629 | inL = local->findByUid( uid ); |
2630 | inR = remote->findByUid( uid ); | 2630 | inR = remote->findByUid( uid ); |
2631 | //inL.setResource( 0 ); | 2631 | //inL.setResource( 0 ); |
2632 | //inR.setResource( 0 ); | 2632 | //inR.setResource( 0 ); |
2633 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2633 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2634 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2634 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2635 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2635 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2636 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2636 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2637 | if ( take == 3 ) | 2637 | if ( take == 3 ) |
2638 | return false; | 2638 | return false; |
2639 | if ( take == 1 ) {// take local | 2639 | if ( take == 1 ) {// take local ********************** |
2640 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2640 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2641 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2641 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2642 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2642 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2643 | local->insertAddressee( inL, false ); | 2643 | local->insertAddressee( inL, false ); |
2644 | idS = inR.externalUID(); | 2644 | idS = inR.externalUID(); |
2645 | OidS = inR.originalExternalUID(); | 2645 | OidS = inR.originalExternalUID(); |
2646 | } | 2646 | } |
2647 | else | 2647 | else |
2648 | idS = inR.IDStr(); | 2648 | idS = inR.IDStr(); |
2649 | remote->removeAddressee( inR ); | 2649 | remote->removeAddressee( inR ); |
2650 | inR = inL; | 2650 | inR = inL; |
2651 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2651 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2652 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2652 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2653 | inR.setOriginalExternalUID( OidS ); | 2653 | inR.setOriginalExternalUID( OidS ); |
2654 | inR.setExternalUID( idS ); | 2654 | inR.setExternalUID( idS ); |
2655 | if ( syncManager->syncWithDesktop() ) | 2655 | if ( syncManager->syncWithDesktop() ) |
2656 | inR.setIDStr("changed" ); | 2656 | inR.setIDStr("changed" ); |
2657 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 2657 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
2658 | } else { | 2658 | } else { |
2659 | inR.setIDStr( idS ); | 2659 | inR.setIDStr( idS ); |
2660 | } | 2660 | } |
2661 | inR.setResource( 0 ); | 2661 | inR.setResource( 0 ); |
2662 | remote->insertAddressee( inR , false); | 2662 | remote->insertAddressee( inR , false); |
2663 | ++changedRemote; | 2663 | ++changedRemote; |
2664 | } else { // take == 2 take remote | 2664 | } else { // take == 2 take remote ********************** |
2665 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2665 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2666 | if ( inR.revision().date().year() < 2004 ) | 2666 | if ( inR.revision().date().year() < 2004 ) |
2667 | inR.setRevision( modifiedCalendar ); | 2667 | inR.setRevision( modifiedCalendar ); |
2668 | } | 2668 | } |
2669 | idS = inL.IDStr(); | 2669 | idS = inL.IDStr(); |
2670 | local->removeAddressee( inL ); | 2670 | local->removeAddressee( inL ); |
2671 | inL = inR; | 2671 | inL = inR; |
2672 | inL.setIDStr( idS ); | 2672 | inL.setIDStr( idS ); |
2673 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2673 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2674 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2674 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2675 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2675 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2676 | } | 2676 | } |
2677 | inL.setResource( 0 ); | 2677 | inL.setResource( 0 ); |
2678 | local->insertAddressee( inL , false ); | 2678 | local->insertAddressee( inL , false ); |
2679 | ++changedLocal; | 2679 | ++changedLocal; |
2680 | } | 2680 | } |
2681 | } | 2681 | } |
2682 | } | 2682 | } |
2683 | } else { // no conflict | 2683 | } else { // no conflict ********** add or delete remote |
2684 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2684 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2685 | QString des = addresseeLSync.note(); | 2685 | QString des = addresseeLSync.note(); |
2686 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2686 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2687 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2687 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2688 | remote->insertAddressee( inR, false ); | 2688 | remote->insertAddressee( inR, false ); |
2689 | ++deletedAddresseeR; | 2689 | ++deletedAddresseeR; |
2690 | } else { | 2690 | } else { |
2691 | inR.setRevision( modifiedCalendar ); | 2691 | inR.setRevision( modifiedCalendar ); |
2692 | remote->insertAddressee( inR, false ); | 2692 | remote->insertAddressee( inR, false ); |
2693 | inL = inR; | 2693 | inL = inR; |
2694 | inL.setIDStr( ":" ); | ||
2695 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | ||
2696 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | ||
2694 | inL.setResource( 0 ); | 2697 | inL.setResource( 0 ); |
2695 | local->insertAddressee( inL , false); | 2698 | local->insertAddressee( inL , false); |
2696 | ++addedAddressee; | 2699 | ++addedAddressee; |
2697 | } | 2700 | } |
2698 | } else { | 2701 | } else { |
2699 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2702 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2700 | inR.setRevision( modifiedCalendar ); | 2703 | inR.setRevision( modifiedCalendar ); |
2701 | remote->insertAddressee( inR, false ); | 2704 | remote->insertAddressee( inR, false ); |
2702 | inR.setResource( 0 ); | 2705 | inR.setResource( 0 ); |
2703 | local->insertAddressee( inR, false ); | 2706 | local->insertAddressee( inR, false ); |
2704 | ++addedAddressee; | 2707 | ++addedAddressee; |
2705 | } else { | 2708 | } else { |
2706 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2709 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2707 | remote->removeAddressee( inR ); | 2710 | remote->removeAddressee( inR ); |
2708 | ++deletedAddresseeR; | 2711 | ++deletedAddresseeR; |
2709 | } | 2712 | } |
2710 | } | 2713 | } |
2711 | } | 2714 | } |
2712 | } | 2715 | } |
2713 | ++incCounter; | 2716 | ++incCounter; |
2714 | } | 2717 | } |
2715 | er.clear(); | 2718 | er.clear(); |
2716 | QStringList el = local->uidList(); | 2719 | QStringList el = local->uidList(); |
2717 | modulo = (el.count()/10)+1; | 2720 | modulo = (el.count()/10)+1; |
2718 | 2721 | ||
2719 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2722 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2720 | incCounter = 0; | 2723 | incCounter = 0; |
2721 | while ( incCounter < el.count()) { | 2724 | while ( incCounter < el.count()) { |
2722 | qApp->processEvents(); | 2725 | qApp->processEvents(); |
2723 | if (syncManager->isProgressBarCanceled()) | 2726 | if (syncManager->isProgressBarCanceled()) |
2724 | return false; | 2727 | return false; |
2725 | if ( incCounter % modulo == 0 ) | 2728 | if ( incCounter % modulo == 0 ) |
2726 | syncManager->showProgressBar(incCounter); | 2729 | syncManager->showProgressBar(incCounter); |
2727 | uid = el[ incCounter ]; | 2730 | uid = el[ incCounter ]; |
2728 | bool skipIncidence = false; | 2731 | bool skipIncidence = false; |
2729 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2732 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2730 | skipIncidence = true; | 2733 | skipIncidence = true; |
2731 | if ( !skipIncidence ) { | 2734 | if ( !skipIncidence ) { |
2732 | inL = local->findByUid( uid ); | 2735 | inL = local->findByUid( uid ); |
2733 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2736 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2734 | inR = remote->findByUid( uid ); | 2737 | inR = remote->findByUid( uid ); |
2735 | if ( inR.isEmpty() ) { | 2738 | if ( inR.isEmpty() ) { / no conflict ********** add or delete local |
2736 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2739 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2737 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2740 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2738 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2741 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2739 | local->removeAddressee( inL ); | 2742 | local->removeAddressee( inL ); |
2740 | ++deletedAddresseeL; | 2743 | ++deletedAddresseeL; |
2741 | } else { | 2744 | } else { |
2742 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2745 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2743 | inL.removeID(mCurrentSyncDevice ); | 2746 | inL.removeID(mCurrentSyncDevice ); |
2744 | ++addedAddresseeR; | 2747 | ++addedAddresseeR; |
2745 | inL.setRevision( modifiedCalendar ); | 2748 | inL.setRevision( modifiedCalendar ); |
2746 | local->insertAddressee( inL, false ); | 2749 | local->insertAddressee( inL, false ); |
2747 | inR = inL; | 2750 | inR = inL; |
2748 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2751 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2749 | inR.setResource( 0 ); | 2752 | inR.setResource( 0 ); |
2750 | remote->insertAddressee( inR, false ); | 2753 | remote->insertAddressee( inR, false ); |
2751 | } | 2754 | } |
2752 | } | 2755 | } |
2753 | } else { | 2756 | } else { |
2754 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2757 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2755 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2758 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2756 | local->removeAddressee( inL ); | 2759 | local->removeAddressee( inL ); |
2757 | ++deletedAddresseeL; | 2760 | ++deletedAddresseeL; |
2758 | } else { | 2761 | } else { |
2759 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2762 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2760 | ++addedAddresseeR; | 2763 | ++addedAddresseeR; |
2761 | inL.setRevision( modifiedCalendar ); | 2764 | inL.setRevision( modifiedCalendar ); |
2762 | local->insertAddressee( inL, false ); | 2765 | local->insertAddressee( inL, false ); |
2763 | inR = inL; | 2766 | inR = inL; |
2767 | inR.setIDStr( ":" ); | ||
2764 | inR.setResource( 0 ); | 2768 | inR.setResource( 0 ); |
2765 | remote->insertAddressee( inR, false ); | 2769 | remote->insertAddressee( inR, false ); |
2766 | } | 2770 | } |
2767 | } | 2771 | } |
2768 | } | 2772 | } |
2769 | } | 2773 | } |
2770 | } | 2774 | } |
2771 | } | 2775 | } |
2772 | ++incCounter; | 2776 | ++incCounter; |
2773 | } | 2777 | } |
2774 | el.clear(); | 2778 | el.clear(); |
2775 | syncManager->hideProgressBar(); | 2779 | syncManager->hideProgressBar(); |
2776 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2780 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2777 | // get rid of micro seconds | 2781 | // get rid of micro seconds |
2778 | QTime t = mLastAddressbookSync.time(); | 2782 | QTime t = mLastAddressbookSync.time(); |
2779 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2783 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2780 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2784 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2781 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2785 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2782 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2786 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2783 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2787 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2784 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2788 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2785 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2789 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2786 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2790 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2787 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2791 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2788 | addresseeRSync.setNote( "" ) ; | 2792 | addresseeRSync.setNote( "" ) ; |
2789 | addresseeLSync.setNote( "" ); | 2793 | addresseeLSync.setNote( "" ); |
2790 | 2794 | ||
2791 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2795 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2792 | remote->insertAddressee( addresseeRSync, false ); | 2796 | remote->insertAddressee( addresseeRSync, false ); |
2793 | local->insertAddressee( addresseeLSync, false ); | 2797 | local->insertAddressee( addresseeLSync, false ); |
2794 | QString mes; | 2798 | QString mes; |
2795 | 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 ); | 2799 | 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 ); |
2796 | qDebug( mes ); | 2800 | qDebug( mes ); |
2797 | if ( syncManager->mShowSyncSummary ) { | 2801 | if ( syncManager->mShowSyncSummary ) { |
2798 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 2802 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
2799 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 2803 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
2800 | qDebug("cancelled "); | 2804 | qDebug("cancelled "); |
2801 | return false; | 2805 | return false; |
2802 | } | 2806 | } |
2803 | } | 2807 | } |
2804 | return syncOK; | 2808 | return syncOK; |
2805 | } | 2809 | } |
2806 | 2810 | ||
2807 | 2811 | ||
2808 | //this is a overwritten callbackmethods from the syncinterface | 2812 | //this is a overwritten callbackmethods from the syncinterface |
2809 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2813 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2810 | { | 2814 | { |
2811 | 2815 | ||
2812 | //pending prepare addresseeview for output | 2816 | //pending prepare addresseeview for output |
2813 | //pending detect, if remote file has REV field. if not switch to external sync | 2817 | //pending detect, if remote file has REV field. if not switch to external sync |
2814 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2818 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2815 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2819 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2816 | 2820 | ||
2817 | AddressBook abLocal(filename,"syncContact"); | 2821 | AddressBook abLocal(filename,"syncContact"); |
2818 | bool syncOK = false; | 2822 | bool syncOK = false; |
2819 | if ( abLocal.load() ) { | 2823 | if ( abLocal.load() ) { |
2820 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2824 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2821 | bool external = false; | 2825 | bool external = false; |
2822 | bool isXML = false; | 2826 | bool isXML = false; |
2823 | if ( filename.right(4) == ".xml") { | 2827 | if ( filename.right(4) == ".xml") { |
2824 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2828 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2825 | isXML = true; | 2829 | isXML = true; |
2826 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2830 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2827 | } else { | 2831 | } else { |
2828 | external = !manager->mIsKapiFile; | 2832 | external = !manager->mIsKapiFile; |
2829 | if ( external ) { | 2833 | if ( external ) { |
2830 | qDebug("Setting vcf mode to external "); | 2834 | qDebug("Setting vcf mode to external "); |
2831 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2835 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2832 | AddressBook::Iterator it; | 2836 | AddressBook::Iterator it; |
2833 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2837 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2834 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2838 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2835 | (*it).computeCsum( mCurrentSyncDevice ); | 2839 | (*it).computeCsum( mCurrentSyncDevice ); |
2836 | } | 2840 | } |
2837 | } | 2841 | } |
2838 | } | 2842 | } |
2839 | //AddressBook::Iterator it; | 2843 | //AddressBook::Iterator it; |
2840 | //QStringList vcards; | 2844 | //QStringList vcards; |
2841 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2845 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2842 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2846 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2843 | //} | 2847 | //} |
2844 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2848 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2845 | if ( syncOK ) { | 2849 | if ( syncOK ) { |
2846 | if ( syncManager->mWriteBackFile ) | 2850 | if ( syncManager->mWriteBackFile ) |
2847 | { | 2851 | { |
2848 | if ( external ) | 2852 | if ( external ) |
2849 | abLocal.removeSyncAddressees( !isXML); | 2853 | abLocal.removeSyncAddressees( !isXML); |
2850 | qDebug("Saving remote AB "); | 2854 | qDebug("Saving remote AB "); |
2851 | if ( ! abLocal.saveAB()) | 2855 | if ( ! abLocal.saveAB()) |
2852 | qDebug("Error writing back AB to file "); | 2856 | qDebug("Error writing back AB to file "); |
2853 | if ( external ) { | 2857 | if ( external ) { |
2854 | // afterwrite processing | 2858 | // afterwrite processing |
2855 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 2859 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
2856 | } | 2860 | } |
2857 | } | 2861 | } |
2858 | } | 2862 | } |
2859 | setModified(); | 2863 | setModified(); |
2860 | 2864 | ||
2861 | } | 2865 | } |
2862 | if ( syncOK ) | 2866 | if ( syncOK ) |
2863 | mViewManager->refreshView(); | 2867 | mViewManager->refreshView(); |
2864 | return syncOK; | 2868 | return syncOK; |
2865 | 2869 | ||
2866 | } | 2870 | } |
2867 | void KABCore::removeSyncInfo( QString syncProfile) | 2871 | void KABCore::removeSyncInfo( QString syncProfile) |
2868 | { | 2872 | { |
2869 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 2873 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
2870 | mAddressBook->removeSyncInfo( syncProfile ); | 2874 | mAddressBook->removeSyncInfo( syncProfile ); |
2871 | setModified(); | 2875 | setModified(); |
2872 | } | 2876 | } |
2873 | 2877 | ||
2874 | 2878 | ||
2875 | //this is a overwritten callbackmethods from the syncinterface | 2879 | //this is a overwritten callbackmethods from the syncinterface |
2876 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2880 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2877 | { | 2881 | { |
2878 | if ( resource == "phone" ) | 2882 | if ( resource == "phone" ) |
2879 | return syncPhone(); | 2883 | return syncPhone(); |
2880 | disableBR( true ); | 2884 | disableBR( true ); |
2881 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2885 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2882 | 2886 | ||
2883 | AddressBook abLocal( resource,"syncContact"); | 2887 | AddressBook abLocal( resource,"syncContact"); |
2884 | bool syncOK = false; | 2888 | bool syncOK = false; |
2885 | if ( abLocal.load() ) { | 2889 | if ( abLocal.load() ) { |
2886 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2890 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2887 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2891 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2888 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 2892 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
2889 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2893 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2890 | if ( syncOK ) { | 2894 | if ( syncOK ) { |
2891 | if ( syncManager->mWriteBackFile ) { | 2895 | if ( syncManager->mWriteBackFile ) { |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 4667918..4e29d6f 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -891,345 +891,347 @@ void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* t | |||
891 | if ( toDelete->type() == "Todo" ) | 891 | if ( toDelete->type() == "Todo" ) |
892 | pref = "t"; | 892 | pref = "t"; |
893 | des += pref+ id + ","; | 893 | des += pref+ id + ","; |
894 | eve->setReadOnly( false ); | 894 | eve->setReadOnly( false ); |
895 | eve->setDescription( des ); | 895 | eve->setDescription( des ); |
896 | //qDebug("setdes %s ", des.latin1()); | 896 | //qDebug("setdes %s ", des.latin1()); |
897 | eve->setReadOnly( true ); | 897 | eve->setReadOnly( true ); |
898 | } | 898 | } |
899 | eve = lastSync.next(); | 899 | eve = lastSync.next(); |
900 | } | 900 | } |
901 | 901 | ||
902 | } | 902 | } |
903 | void CalendarView::checkExternalId( Incidence * inc ) | 903 | void CalendarView::checkExternalId( Incidence * inc ) |
904 | { | 904 | { |
905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
906 | checkExternSyncEvent( lastSync, inc ); | 906 | checkExternSyncEvent( lastSync, inc ); |
907 | 907 | ||
908 | } | 908 | } |
909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
910 | { | 910 | { |
911 | bool syncOK = true; | 911 | bool syncOK = true; |
912 | int addedEvent = 0; | 912 | int addedEvent = 0; |
913 | int addedEventR = 0; | 913 | int addedEventR = 0; |
914 | int deletedEventR = 0; | 914 | int deletedEventR = 0; |
915 | int deletedEventL = 0; | 915 | int deletedEventL = 0; |
916 | int changedLocal = 0; | 916 | int changedLocal = 0; |
917 | int changedRemote = 0; | 917 | int changedRemote = 0; |
918 | //QPtrList<Event> el = local->rawEvents(); | 918 | //QPtrList<Event> el = local->rawEvents(); |
919 | Event* eventR; | 919 | Event* eventR; |
920 | QString uid; | 920 | QString uid; |
921 | int take; | 921 | int take; |
922 | Event* eventL; | 922 | Event* eventL; |
923 | Event* eventRSync; | 923 | Event* eventRSync; |
924 | Event* eventLSync; | 924 | Event* eventLSync; |
925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
927 | bool fullDateRange = false; | 927 | bool fullDateRange = false; |
928 | local->resetTempSyncStat(); | 928 | local->resetTempSyncStat(); |
929 | mLastCalendarSync = QDateTime::currentDateTime(); | 929 | mLastCalendarSync = QDateTime::currentDateTime(); |
930 | if ( mSyncManager->syncWithDesktop() ) { | 930 | if ( mSyncManager->syncWithDesktop() ) { |
931 | remote->resetPilotStat(1); | 931 | remote->resetPilotStat(1); |
932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
934 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 934 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
935 | } else { | 935 | } else { |
936 | qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); | 936 | qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); |
937 | } | 937 | } |
938 | } | 938 | } |
939 | QDateTime modifiedCalendar = mLastCalendarSync;; | 939 | QDateTime modifiedCalendar = mLastCalendarSync;; |
940 | eventLSync = getLastSyncEvent(); | 940 | eventLSync = getLastSyncEvent(); |
941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
942 | if ( eventR ) { | 942 | if ( eventR ) { |
943 | eventRSync = (Event*) eventR->clone(); | 943 | eventRSync = (Event*) eventR->clone(); |
944 | remote->deleteEvent(eventR ); | 944 | remote->deleteEvent(eventR ); |
945 | 945 | ||
946 | } else { | 946 | } else { |
947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
948 | eventRSync = (Event*)eventLSync->clone(); | 948 | eventRSync = (Event*)eventLSync->clone(); |
949 | } else { | 949 | } else { |
950 | fullDateRange = true; | 950 | fullDateRange = true; |
951 | eventRSync = new Event(); | 951 | eventRSync = new Event(); |
952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
954 | eventRSync->setDtStart( mLastCalendarSync ); | 954 | eventRSync->setDtStart( mLastCalendarSync ); |
955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
956 | eventRSync->setCategories( i18n("SyncEvent") ); | 956 | eventRSync->setCategories( i18n("SyncEvent") ); |
957 | } | 957 | } |
958 | } | 958 | } |
959 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 959 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
960 | fullDateRange = true; | 960 | fullDateRange = true; |
961 | 961 | ||
962 | if ( ! fullDateRange ) { | 962 | if ( ! fullDateRange ) { |
963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
964 | 964 | ||
965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
967 | fullDateRange = true; | 967 | fullDateRange = true; |
968 | } | 968 | } |
969 | } | 969 | } |
970 | if ( mSyncManager->syncWithDesktop() ) { | 970 | if ( mSyncManager->syncWithDesktop() ) { |
971 | fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); | 971 | fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); |
972 | } | 972 | } |
973 | if ( fullDateRange ) | 973 | if ( fullDateRange ) |
974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
975 | else | 975 | else |
976 | mLastCalendarSync = eventLSync->dtStart(); | 976 | mLastCalendarSync = eventLSync->dtStart(); |
977 | // for resyncing if own file has changed | 977 | // for resyncing if own file has changed |
978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
979 | mLastCalendarSync = loadedFileVersion; | 979 | mLastCalendarSync = loadedFileVersion; |
980 | //qDebug("setting mLastCalendarSync "); | 980 | //qDebug("setting mLastCalendarSync "); |
981 | } | 981 | } |
982 | //qDebug("*************************** "); | 982 | //qDebug("*************************** "); |
983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
984 | QPtrList<Incidence> er = remote->rawIncidences(); | 984 | QPtrList<Incidence> er = remote->rawIncidences(); |
985 | Incidence* inR = er.first(); | 985 | Incidence* inR = er.first(); |
986 | Incidence* inL; | 986 | Incidence* inL; |
987 | QProgressBar bar( er.count(),0 ); | 987 | QProgressBar bar( er.count(),0 ); |
988 | bar.setCaption (i18n("Syncing - close to abort!") ); | 988 | bar.setCaption (i18n("Syncing - close to abort!") ); |
989 | 989 | ||
990 | int w = 300; | 990 | int w = 300; |
991 | if ( QApplication::desktop()->width() < 320 ) | 991 | if ( QApplication::desktop()->width() < 320 ) |
992 | w = 220; | 992 | w = 220; |
993 | int h = bar.sizeHint().height() ; | 993 | int h = bar.sizeHint().height() ; |
994 | int dw = QApplication::desktop()->width(); | 994 | int dw = QApplication::desktop()->width(); |
995 | int dh = QApplication::desktop()->height(); | 995 | int dh = QApplication::desktop()->height(); |
996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
997 | bar.show(); | 997 | bar.show(); |
998 | int modulo = (er.count()/10)+1; | 998 | int modulo = (er.count()/10)+1; |
999 | int incCounter = 0; | 999 | int incCounter = 0; |
1000 | while ( inR ) { | 1000 | while ( inR ) { |
1001 | if ( ! bar.isVisible() ) | 1001 | if ( ! bar.isVisible() ) |
1002 | return false; | 1002 | return false; |
1003 | if ( incCounter % modulo == 0 ) | 1003 | if ( incCounter % modulo == 0 ) |
1004 | bar.setProgress( incCounter ); | 1004 | bar.setProgress( incCounter ); |
1005 | ++incCounter; | 1005 | ++incCounter; |
1006 | uid = inR->uid(); | 1006 | uid = inR->uid(); |
1007 | bool skipIncidence = false; | 1007 | bool skipIncidence = false; |
1008 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1008 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1009 | skipIncidence = true; | 1009 | skipIncidence = true; |
1010 | QString idS; | 1010 | QString idS; |
1011 | qApp->processEvents(); | 1011 | qApp->processEvents(); |
1012 | if ( !skipIncidence ) { | 1012 | if ( !skipIncidence ) { |
1013 | inL = local->incidence( uid ); | 1013 | inL = local->incidence( uid ); |
1014 | if ( inL ) { // maybe conflict - same uid in both calendars | 1014 | if ( inL ) { // maybe conflict - same uid in both calendars |
1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1017 | if ( take == 3 ) | 1017 | if ( take == 3 ) |
1018 | return false; | 1018 | return false; |
1019 | if ( take == 1 ) {// take local | 1019 | if ( take == 1 ) {// take local ********************** |
1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1022 | else | 1022 | else |
1023 | idS = inR->IDStr(); | 1023 | idS = inR->IDStr(); |
1024 | remote->deleteIncidence( inR ); | 1024 | remote->deleteIncidence( inR ); |
1025 | inR = inL->clone(); | 1025 | inR = inL->clone(); |
1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1028 | inR->setIDStr( idS ); | 1028 | inR->setIDStr( idS ); |
1029 | remote->addIncidence( inR ); | 1029 | remote->addIncidence( inR ); |
1030 | if ( mSyncManager->syncWithDesktop() ) | 1030 | if ( mSyncManager->syncWithDesktop() ) |
1031 | inR->setPilotId( 2 ); | 1031 | inR->setPilotId( 2 ); |
1032 | ++changedRemote; | 1032 | ++changedRemote; |
1033 | } else { | 1033 | } else {// take remote ********************** |
1034 | idS = inL->IDStr(); | 1034 | idS = inL->IDStr(); |
1035 | int pid = inL->pilotId(); | 1035 | int pid = inL->pilotId(); |
1036 | local->deleteIncidence( inL ); | 1036 | local->deleteIncidence( inL ); |
1037 | inL = inR->clone(); | 1037 | inL = inR->clone(); |
1038 | if ( mSyncManager->syncWithDesktop() ) | 1038 | if ( mSyncManager->syncWithDesktop() ) |
1039 | inL->setPilotId( pid ); | 1039 | inL->setPilotId( pid ); |
1040 | inL->setIDStr( idS ); | 1040 | inL->setIDStr( idS ); |
1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1044 | } | 1044 | } |
1045 | local->addIncidence( inL ); | 1045 | local->addIncidence( inL ); |
1046 | ++changedLocal; | 1046 | ++changedLocal; |
1047 | } | 1047 | } |
1048 | } | 1048 | } |
1049 | } else { // no conflict | 1049 | } else { // no conflict ********** add or delete remote |
1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1051 | QString des = eventLSync->description(); | 1051 | QString des = eventLSync->description(); |
1052 | QString pref = "e"; | 1052 | QString pref = "e"; |
1053 | if ( inR->type() == "Todo" ) | 1053 | if ( inR->type() == "Todo" ) |
1054 | pref = "t"; | 1054 | pref = "t"; |
1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1057 | //remote->deleteIncidence( inR ); | 1057 | //remote->deleteIncidence( inR ); |
1058 | ++deletedEventR; | 1058 | ++deletedEventR; |
1059 | } else { | 1059 | } else { |
1060 | inR->setLastModified( modifiedCalendar ); | 1060 | inR->setLastModified( modifiedCalendar ); |
1061 | inL = inR->clone(); | 1061 | inL = inR->clone(); |
1062 | inL->setIDStr( ":" ); | 1062 | inL->setIDStr( ":" ); |
1063 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | ||
1064 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | ||
1063 | local->addIncidence( inL ); | 1065 | local->addIncidence( inL ); |
1064 | ++addedEvent; | 1066 | ++addedEvent; |
1065 | } | 1067 | } |
1066 | } else { | 1068 | } else { |
1067 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1069 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1068 | inR->setLastModified( modifiedCalendar ); | 1070 | inR->setLastModified( modifiedCalendar ); |
1069 | inL = inR->clone(); | 1071 | inL = inR->clone(); |
1070 | inL->setIDStr( ":" ); | 1072 | inL->setIDStr( ":" ); |
1071 | local->addIncidence( inL ); | 1073 | local->addIncidence( inL ); |
1072 | ++addedEvent; | 1074 | ++addedEvent; |
1073 | } else { | 1075 | } else { |
1074 | checkExternSyncEvent(eventRSyncSharp, inR); | 1076 | checkExternSyncEvent(eventRSyncSharp, inR); |
1075 | remote->deleteIncidence( inR ); | 1077 | remote->deleteIncidence( inR ); |
1076 | ++deletedEventR; | 1078 | ++deletedEventR; |
1077 | } | 1079 | } |
1078 | } | 1080 | } |
1079 | } | 1081 | } |
1080 | } | 1082 | } |
1081 | inR = er.next(); | 1083 | inR = er.next(); |
1082 | } | 1084 | } |
1083 | QPtrList<Incidence> el = local->rawIncidences(); | 1085 | QPtrList<Incidence> el = local->rawIncidences(); |
1084 | inL = el.first(); | 1086 | inL = el.first(); |
1085 | modulo = (el.count()/10)+1; | 1087 | modulo = (el.count()/10)+1; |
1086 | bar.setCaption (i18n("Add / remove events") ); | 1088 | bar.setCaption (i18n("Add / remove events") ); |
1087 | bar.setTotalSteps ( el.count() ) ; | 1089 | bar.setTotalSteps ( el.count() ) ; |
1088 | bar.show(); | 1090 | bar.show(); |
1089 | incCounter = 0; | 1091 | incCounter = 0; |
1090 | 1092 | ||
1091 | while ( inL ) { | 1093 | while ( inL ) { |
1092 | 1094 | ||
1093 | qApp->processEvents(); | 1095 | qApp->processEvents(); |
1094 | if ( ! bar.isVisible() ) | 1096 | if ( ! bar.isVisible() ) |
1095 | return false; | 1097 | return false; |
1096 | if ( incCounter % modulo == 0 ) | 1098 | if ( incCounter % modulo == 0 ) |
1097 | bar.setProgress( incCounter ); | 1099 | bar.setProgress( incCounter ); |
1098 | ++incCounter; | 1100 | ++incCounter; |
1099 | uid = inL->uid(); | 1101 | uid = inL->uid(); |
1100 | bool skipIncidence = false; | 1102 | bool skipIncidence = false; |
1101 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1103 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1102 | skipIncidence = true; | 1104 | skipIncidence = true; |
1103 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1105 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1104 | skipIncidence = true; | 1106 | skipIncidence = true; |
1105 | if ( !skipIncidence ) { | 1107 | if ( !skipIncidence ) { |
1106 | inR = remote->incidence( uid ); | 1108 | inR = remote->incidence( uid ); |
1107 | if ( ! inR ) { | 1109 | if ( ! inR ) { // no conflict ********** add or delete local |
1108 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1110 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1109 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1111 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1110 | checkExternSyncEvent(eventLSyncSharp, inL); | 1112 | checkExternSyncEvent(eventLSyncSharp, inL); |
1111 | local->deleteIncidence( inL ); | 1113 | local->deleteIncidence( inL ); |
1112 | ++deletedEventL; | 1114 | ++deletedEventL; |
1113 | } else { | 1115 | } else { |
1114 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1116 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1115 | inL->removeID(mCurrentSyncDevice ); | 1117 | inL->removeID(mCurrentSyncDevice ); |
1116 | ++addedEventR; | 1118 | ++addedEventR; |
1117 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1119 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1118 | inL->setLastModified( modifiedCalendar ); | 1120 | inL->setLastModified( modifiedCalendar ); |
1119 | inR = inL->clone(); | 1121 | inR = inL->clone(); |
1120 | inR->setIDStr( ":" ); | 1122 | inR->setIDStr( ":" ); |
1121 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1123 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1122 | remote->addIncidence( inR ); | 1124 | remote->addIncidence( inR ); |
1123 | } | 1125 | } |
1124 | } | 1126 | } |
1125 | } else { | 1127 | } else { |
1126 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1128 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1127 | checkExternSyncEvent(eventLSyncSharp, inL); | 1129 | checkExternSyncEvent(eventLSyncSharp, inL); |
1128 | local->deleteIncidence( inL ); | 1130 | local->deleteIncidence( inL ); |
1129 | ++deletedEventL; | 1131 | ++deletedEventL; |
1130 | } else { | 1132 | } else { |
1131 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1133 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1132 | ++addedEventR; | 1134 | ++addedEventR; |
1133 | inL->setLastModified( modifiedCalendar ); | 1135 | inL->setLastModified( modifiedCalendar ); |
1134 | inR = inL->clone(); | 1136 | inR = inL->clone(); |
1135 | inR->setIDStr( ":" ); | 1137 | inR->setIDStr( ":" ); |
1136 | remote->addIncidence( inR ); | 1138 | remote->addIncidence( inR ); |
1137 | } | 1139 | } |
1138 | } | 1140 | } |
1139 | } | 1141 | } |
1140 | } | 1142 | } |
1141 | } | 1143 | } |
1142 | inL = el.next(); | 1144 | inL = el.next(); |
1143 | } | 1145 | } |
1144 | int delFut = 0; | 1146 | int delFut = 0; |
1145 | int remRem = 0; | 1147 | int remRem = 0; |
1146 | if ( mSyncManager->mWriteBackInFuture ) { | 1148 | if ( mSyncManager->mWriteBackInFuture ) { |
1147 | er = remote->rawIncidences(); | 1149 | er = remote->rawIncidences(); |
1148 | remRem = er.count(); | 1150 | remRem = er.count(); |
1149 | inR = er.first(); | 1151 | inR = er.first(); |
1150 | QDateTime dt; | 1152 | QDateTime dt; |
1151 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1153 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1152 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1154 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1153 | while ( inR ) { | 1155 | while ( inR ) { |
1154 | if ( inR->type() == "Todo" ) { | 1156 | if ( inR->type() == "Todo" ) { |
1155 | Todo * t = (Todo*)inR; | 1157 | Todo * t = (Todo*)inR; |
1156 | if ( t->hasDueDate() ) | 1158 | if ( t->hasDueDate() ) |
1157 | dt = t->dtDue(); | 1159 | dt = t->dtDue(); |
1158 | else | 1160 | else |
1159 | dt = cur.addSecs( 62 ); | 1161 | dt = cur.addSecs( 62 ); |
1160 | } | 1162 | } |
1161 | else if (inR->type() == "Event" ) { | 1163 | else if (inR->type() == "Event" ) { |
1162 | bool ok; | 1164 | bool ok; |
1163 | dt = inR->getNextOccurence( cur, &ok ); | 1165 | dt = inR->getNextOccurence( cur, &ok ); |
1164 | if ( !ok ) | 1166 | if ( !ok ) |
1165 | dt = cur.addSecs( -62 ); | 1167 | dt = cur.addSecs( -62 ); |
1166 | } | 1168 | } |
1167 | else | 1169 | else |
1168 | dt = inR->dtStart(); | 1170 | dt = inR->dtStart(); |
1169 | if ( dt < cur || dt > end ) { | 1171 | if ( dt < cur || dt > end ) { |
1170 | remote->deleteIncidence( inR ); | 1172 | remote->deleteIncidence( inR ); |
1171 | ++delFut; | 1173 | ++delFut; |
1172 | } | 1174 | } |
1173 | inR = er.next(); | 1175 | inR = er.next(); |
1174 | } | 1176 | } |
1175 | } | 1177 | } |
1176 | bar.hide(); | 1178 | bar.hide(); |
1177 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1179 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1178 | eventLSync->setReadOnly( false ); | 1180 | eventLSync->setReadOnly( false ); |
1179 | eventLSync->setDtStart( mLastCalendarSync ); | 1181 | eventLSync->setDtStart( mLastCalendarSync ); |
1180 | eventRSync->setDtStart( mLastCalendarSync ); | 1182 | eventRSync->setDtStart( mLastCalendarSync ); |
1181 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1183 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1182 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1184 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1183 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1185 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1184 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1186 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1185 | eventLSync->setReadOnly( true ); | 1187 | eventLSync->setReadOnly( true ); |
1186 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1188 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1187 | remote->addEvent( eventRSync ); | 1189 | remote->addEvent( eventRSync ); |
1188 | else | 1190 | else |
1189 | delete eventRSync; | 1191 | delete eventRSync; |
1190 | QString mes; | 1192 | QString mes; |
1191 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1193 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1192 | QString delmess; | 1194 | QString delmess; |
1193 | if ( delFut ) { | 1195 | if ( delFut ) { |
1194 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1196 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1195 | mes += delmess; | 1197 | mes += delmess; |
1196 | } | 1198 | } |
1197 | mCalendar->checkAlarmForIncidence( 0, true ); | 1199 | mCalendar->checkAlarmForIncidence( 0, true ); |
1198 | qDebug( mes ); | 1200 | qDebug( mes ); |
1199 | if ( mSyncManager->mShowSyncSummary ) { | 1201 | if ( mSyncManager->mShowSyncSummary ) { |
1200 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1202 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1201 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1203 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1202 | qDebug("cancelled "); | 1204 | qDebug("cancelled "); |
1203 | return false; | 1205 | return false; |
1204 | } | 1206 | } |
1205 | } | 1207 | } |
1206 | return syncOK; | 1208 | return syncOK; |
1207 | } | 1209 | } |
1208 | 1210 | ||
1209 | void CalendarView::setSyncDevice( QString s ) | 1211 | void CalendarView::setSyncDevice( QString s ) |
1210 | { | 1212 | { |
1211 | mCurrentSyncDevice= s; | 1213 | mCurrentSyncDevice= s; |
1212 | } | 1214 | } |
1213 | void CalendarView::setSyncName( QString s ) | 1215 | void CalendarView::setSyncName( QString s ) |
1214 | { | 1216 | { |
1215 | mCurrentSyncName= s; | 1217 | mCurrentSyncName= s; |
1216 | } | 1218 | } |
1217 | bool CalendarView::syncCalendar(QString filename, int mode) | 1219 | bool CalendarView::syncCalendar(QString filename, int mode) |
1218 | { | 1220 | { |
1219 | //qDebug("syncCalendar %s ", filename.latin1()); | 1221 | //qDebug("syncCalendar %s ", filename.latin1()); |
1220 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1222 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1221 | CalendarLocal* calendar = new CalendarLocal(); | 1223 | CalendarLocal* calendar = new CalendarLocal(); |
1222 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1224 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1223 | FileStorage* storage = new FileStorage( calendar ); | 1225 | FileStorage* storage = new FileStorage( calendar ); |
1224 | bool syncOK = false; | 1226 | bool syncOK = false; |
1225 | storage->setFileName( filename ); | 1227 | storage->setFileName( filename ); |
1226 | // qDebug("loading ... "); | 1228 | // qDebug("loading ... "); |
1227 | if ( storage->load() ) { | 1229 | if ( storage->load() ) { |
1228 | getEventViewerDialog()->setSyncMode( true ); | 1230 | getEventViewerDialog()->setSyncMode( true ); |
1229 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1231 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1230 | getEventViewerDialog()->setSyncMode( false ); | 1232 | getEventViewerDialog()->setSyncMode( false ); |
1231 | if ( syncOK ) { | 1233 | if ( syncOK ) { |
1232 | if ( mSyncManager->mWriteBackFile ) | 1234 | if ( mSyncManager->mWriteBackFile ) |
1233 | { | 1235 | { |
1234 | storage->setSaveFormat( new ICalFormat() ); | 1236 | storage->setSaveFormat( new ICalFormat() ); |
1235 | storage->save(); | 1237 | storage->save(); |