author | zautrix <zautrix> | 2004-10-06 20:51:01 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-06 20:51:01 (UTC) |
commit | 0afcfa29ace7bc5e42a11fae44301e1e8230a376 (patch) (unidiff) | |
tree | b54f85b19ace24219be1b845469444089cacc94f | |
parent | ed4675de07d947f55d2672c721599e3a0af1e24b (diff) | |
download | kdepimpi-0afcfa29ace7bc5e42a11fae44301e1e8230a376.zip kdepimpi-0afcfa29ace7bc5e42a11fae44301e1e8230a376.tar.gz kdepimpi-0afcfa29ace7bc5e42a11fae44301e1e8230a376.tar.bz2 |
some prefs cleanups
-rw-r--r-- | kaddressbook/kabcore.cpp | 14 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 14 | ||||
-rw-r--r-- | korganizer/calendarview.h | 2 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 1 | ||||
-rw-r--r-- | libkdepim/kpimprefs.h | 18 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 100 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 20 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 6 |
8 files changed, 79 insertions, 96 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index b014cba..9041e45 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2584,112 +2584,112 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2584 | modulo = (el.count()/10)+1; | 2584 | modulo = (el.count()/10)+1; |
2585 | 2585 | ||
2586 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2586 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2587 | incCounter = 0; | 2587 | incCounter = 0; |
2588 | while ( incCounter < el.count()) { | 2588 | while ( incCounter < el.count()) { |
2589 | qApp->processEvents(); | 2589 | qApp->processEvents(); |
2590 | if (syncManager->isProgressBarCanceled()) | 2590 | if (syncManager->isProgressBarCanceled()) |
2591 | return false; | 2591 | return false; |
2592 | if ( incCounter % modulo == 0 ) | 2592 | if ( incCounter % modulo == 0 ) |
2593 | syncManager->showProgressBar(incCounter); | 2593 | syncManager->showProgressBar(incCounter); |
2594 | uid = el[ incCounter ]; | 2594 | uid = el[ incCounter ]; |
2595 | bool skipIncidence = false; | 2595 | bool skipIncidence = false; |
2596 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2596 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2597 | skipIncidence = true; | 2597 | skipIncidence = true; |
2598 | if ( !skipIncidence ) { | 2598 | if ( !skipIncidence ) { |
2599 | inL = local->findByUid( uid ); | 2599 | inL = local->findByUid( uid ); |
2600 | inR = remote->findByUid( uid ); | 2600 | inR = remote->findByUid( uid ); |
2601 | if ( inR.isEmpty() ) { | 2601 | if ( inR.isEmpty() ) { |
2602 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2602 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2603 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2603 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2604 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2604 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2605 | local->removeAddressee( inL ); | 2605 | local->removeAddressee( inL ); |
2606 | ++deletedAddresseeL; | 2606 | ++deletedAddresseeL; |
2607 | } else { | 2607 | } else { |
2608 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2608 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2609 | inL.removeID(mCurrentSyncDevice ); | 2609 | inL.removeID(mCurrentSyncDevice ); |
2610 | ++addedAddresseeR; | 2610 | ++addedAddresseeR; |
2611 | inL.setRevision( modifiedCalendar ); | 2611 | inL.setRevision( modifiedCalendar ); |
2612 | local->insertAddressee( inL, false ); | 2612 | local->insertAddressee( inL, false ); |
2613 | inR = inL; | 2613 | inR = inL; |
2614 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2614 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2615 | inR.setResource( 0 ); | 2615 | inR.setResource( 0 ); |
2616 | remote->insertAddressee( inR, false ); | 2616 | remote->insertAddressee( inR, false ); |
2617 | } | 2617 | } |
2618 | } | 2618 | } |
2619 | } else { | 2619 | } else { |
2620 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2620 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2621 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2621 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2622 | local->removeAddressee( inL ); | 2622 | local->removeAddressee( inL ); |
2623 | ++deletedAddresseeL; | 2623 | ++deletedAddresseeL; |
2624 | } else { | 2624 | } else { |
2625 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2625 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2626 | ++addedAddresseeR; | 2626 | ++addedAddresseeR; |
2627 | inL.setRevision( modifiedCalendar ); | 2627 | inL.setRevision( modifiedCalendar ); |
2628 | local->insertAddressee( inL, false ); | 2628 | local->insertAddressee( inL, false ); |
2629 | inR = inL; | 2629 | inR = inL; |
2630 | inR.setResource( 0 ); | 2630 | inR.setResource( 0 ); |
2631 | remote->insertAddressee( inR, false ); | 2631 | remote->insertAddressee( inR, false ); |
2632 | } | 2632 | } |
2633 | } | 2633 | } |
2634 | } | 2634 | } |
2635 | } | 2635 | } |
2636 | } | 2636 | } |
2637 | ++incCounter; | 2637 | ++incCounter; |
2638 | } | 2638 | } |
2639 | el.clear(); | 2639 | el.clear(); |
2640 | syncManager->hideProgressBar(); | 2640 | syncManager->hideProgressBar(); |
2641 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2641 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2642 | // get rid of micro seconds | 2642 | // get rid of micro seconds |
2643 | QTime t = mLastAddressbookSync.time(); | 2643 | QTime t = mLastAddressbookSync.time(); |
2644 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2644 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2645 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2645 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2646 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2646 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2647 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2647 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2648 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2648 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2649 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2649 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2650 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2650 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2651 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2651 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2652 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2652 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2653 | addresseeRSync.setNote( "" ) ; | 2653 | addresseeRSync.setNote( "" ) ; |
2654 | addresseeLSync.setNote( "" ); | 2654 | addresseeLSync.setNote( "" ); |
2655 | 2655 | ||
2656 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2656 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2657 | remote->insertAddressee( addresseeRSync, false ); | 2657 | remote->insertAddressee( addresseeRSync, false ); |
2658 | local->insertAddressee( addresseeLSync, false ); | 2658 | local->insertAddressee( addresseeLSync, false ); |
2659 | QString mes; | 2659 | QString mes; |
2660 | 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 ); | 2660 | 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 ); |
2661 | if ( KABPrefs::instance()->mShowSyncSummary ) { | 2661 | if ( syncManager->mShowSyncSummary ) { |
2662 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2662 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2663 | } | 2663 | } |
2664 | qDebug( mes ); | 2664 | qDebug( mes ); |
2665 | return syncOK; | 2665 | return syncOK; |
2666 | } | 2666 | } |
2667 | 2667 | ||
2668 | 2668 | ||
2669 | //this is a overwritten callbackmethods from the syncinterface | 2669 | //this is a overwritten callbackmethods from the syncinterface |
2670 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2670 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2671 | { | 2671 | { |
2672 | 2672 | ||
2673 | //pending prepare addresseeview for output | 2673 | //pending prepare addresseeview for output |
2674 | //pending detect, if remote file has REV field. if not switch to external sync | 2674 | //pending detect, if remote file has REV field. if not switch to external sync |
2675 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2675 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2676 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2676 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2677 | 2677 | ||
2678 | AddressBook abLocal(filename,"syncContact"); | 2678 | AddressBook abLocal(filename,"syncContact"); |
2679 | bool syncOK = false; | 2679 | bool syncOK = false; |
2680 | if ( abLocal.load() ) { | 2680 | if ( abLocal.load() ) { |
2681 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2681 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2682 | bool external = false; | 2682 | bool external = false; |
2683 | bool isXML = false; | 2683 | bool isXML = false; |
2684 | if ( filename.right(4) == ".xml") { | 2684 | if ( filename.right(4) == ".xml") { |
2685 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2685 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2686 | isXML = true; | 2686 | isXML = true; |
2687 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2687 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2688 | } else { | 2688 | } else { |
2689 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2689 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2690 | if ( ! lse.isEmpty() ) { | 2690 | if ( ! lse.isEmpty() ) { |
2691 | if ( lse.familyName().left(4) == "!E: " ) | 2691 | if ( lse.familyName().left(4) == "!E: " ) |
2692 | external = true; | 2692 | external = true; |
2693 | } else { | 2693 | } else { |
2694 | bool found = false; | 2694 | bool found = false; |
2695 | AddressBook::Iterator it; | 2695 | AddressBook::Iterator it; |
@@ -2698,49 +2698,49 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | |||
2698 | found = true; | 2698 | found = true; |
2699 | break; | 2699 | break; |
2700 | } | 2700 | } |
2701 | } | 2701 | } |
2702 | external = ! found; | 2702 | external = ! found; |
2703 | } | 2703 | } |
2704 | 2704 | ||
2705 | if ( external ) { | 2705 | if ( external ) { |
2706 | qDebug("Setting vcf mode to external "); | 2706 | qDebug("Setting vcf mode to external "); |
2707 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2707 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2708 | AddressBook::Iterator it; | 2708 | AddressBook::Iterator it; |
2709 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2709 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2710 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2710 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2711 | (*it).computeCsum( mCurrentSyncDevice ); | 2711 | (*it).computeCsum( mCurrentSyncDevice ); |
2712 | } | 2712 | } |
2713 | } | 2713 | } |
2714 | } | 2714 | } |
2715 | //AddressBook::Iterator it; | 2715 | //AddressBook::Iterator it; |
2716 | //QStringList vcards; | 2716 | //QStringList vcards; |
2717 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2717 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2718 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2718 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2719 | //} | 2719 | //} |
2720 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2720 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2721 | if ( syncOK ) { | 2721 | if ( syncOK ) { |
2722 | if ( KABPrefs::instance()->mWriteBackFile ) | 2722 | if ( syncManager->mWriteBackFile ) |
2723 | { | 2723 | { |
2724 | if ( external ) | 2724 | if ( external ) |
2725 | abLocal.removeSyncAddressees( !isXML); | 2725 | abLocal.removeSyncAddressees( !isXML); |
2726 | qDebug("Saving remote AB "); | 2726 | qDebug("Saving remote AB "); |
2727 | abLocal.saveAB(); | 2727 | abLocal.saveAB(); |
2728 | if ( isXML ) { | 2728 | if ( isXML ) { |
2729 | // afterwrite processing | 2729 | // afterwrite processing |
2730 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2730 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2731 | } | 2731 | } |
2732 | } | 2732 | } |
2733 | } | 2733 | } |
2734 | setModified(); | 2734 | setModified(); |
2735 | 2735 | ||
2736 | } | 2736 | } |
2737 | if ( syncOK ) | 2737 | if ( syncOK ) |
2738 | mViewManager->refreshView(); | 2738 | mViewManager->refreshView(); |
2739 | return syncOK; | 2739 | return syncOK; |
2740 | #if 0 | 2740 | #if 0 |
2741 | 2741 | ||
2742 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2742 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2743 | getEventViewerDialog()->setSyncMode( true ); | 2743 | getEventViewerDialog()->setSyncMode( true ); |
2744 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2744 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2745 | getEventViewerDialog()->setSyncMode( false ); | 2745 | getEventViewerDialog()->setSyncMode( false ); |
2746 | if ( syncOK ) { | 2746 | if ( syncOK ) { |
@@ -2748,51 +2748,51 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | |||
2748 | { | 2748 | { |
2749 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2749 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2750 | storage->save(); | 2750 | storage->save(); |
2751 | } | 2751 | } |
2752 | } | 2752 | } |
2753 | setModified(); | 2753 | setModified(); |
2754 | } | 2754 | } |
2755 | 2755 | ||
2756 | #endif | 2756 | #endif |
2757 | } | 2757 | } |
2758 | 2758 | ||
2759 | 2759 | ||
2760 | //this is a overwritten callbackmethods from the syncinterface | 2760 | //this is a overwritten callbackmethods from the syncinterface |
2761 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2761 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2762 | { | 2762 | { |
2763 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2763 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2764 | 2764 | ||
2765 | AddressBook abLocal( resource,"syncContact"); | 2765 | AddressBook abLocal( resource,"syncContact"); |
2766 | bool syncOK = false; | 2766 | bool syncOK = false; |
2767 | if ( abLocal.load() ) { | 2767 | if ( abLocal.load() ) { |
2768 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2768 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2769 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2769 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2770 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2770 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2771 | qDebug("KABCore::syncExternal: why do we acces here KABPrefs and not somehow KSyncProfile? "); | 2771 | qDebug("KABCore::syncExternal: why do we acces here KABPrefs and not somehow KSyncProfile? "); |
2772 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs ); | 2772 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2773 | if ( syncOK ) { | 2773 | if ( syncOK ) { |
2774 | if ( KABPrefs::instance()->mWriteBackFile ) { | 2774 | if ( syncManager->mWriteBackFile ) { |
2775 | abLocal.saveAB(); | 2775 | abLocal.saveAB(); |
2776 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2776 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2777 | } | 2777 | } |
2778 | } | 2778 | } |
2779 | setModified(); | 2779 | setModified(); |
2780 | } | 2780 | } |
2781 | if ( syncOK ) | 2781 | if ( syncOK ) |
2782 | mViewManager->refreshView(); | 2782 | mViewManager->refreshView(); |
2783 | return syncOK; | 2783 | return syncOK; |
2784 | 2784 | ||
2785 | } | 2785 | } |
2786 | 2786 | ||
2787 | //called by the syncmanager to indicate that the work has to marked as dirty. | 2787 | //called by the syncmanager to indicate that the work has to marked as dirty. |
2788 | void KABCore::sync_setModified() | 2788 | void KABCore::sync_setModified() |
2789 | { | 2789 | { |
2790 | setModified(); | 2790 | setModified(); |
2791 | } | 2791 | } |
2792 | 2792 | ||
2793 | //called by the syncmanager to ask if the dirty flag is set. | 2793 | //called by the syncmanager to ask if the dirty flag is set. |
2794 | bool KABCore::sync_isModified() | 2794 | bool KABCore::sync_isModified() |
2795 | { | 2795 | { |
2796 | return mModified; | 2796 | return mModified; |
2797 | } | 2797 | } |
2798 | 2798 | ||
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 38b55f7..1de2759 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -856,63 +856,49 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
856 | return 0; | 856 | return 0; |
857 | } | 857 | } |
858 | Event* CalendarView::getLastSyncEvent() | 858 | Event* CalendarView::getLastSyncEvent() |
859 | { | 859 | { |
860 | Event* lse; | 860 | Event* lse; |
861 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 861 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
862 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 862 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
863 | if (!lse) { | 863 | if (!lse) { |
864 | lse = new Event(); | 864 | lse = new Event(); |
865 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 865 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
866 | QString sum = ""; | 866 | QString sum = ""; |
867 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 867 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
868 | sum = "E: "; | 868 | sum = "E: "; |
869 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 869 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
870 | lse->setDtStart( mLastCalendarSync ); | 870 | lse->setDtStart( mLastCalendarSync ); |
871 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 871 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
872 | lse->setCategories( i18n("SyncEvent") ); | 872 | lse->setCategories( i18n("SyncEvent") ); |
873 | lse->setReadOnly( true ); | 873 | lse->setReadOnly( true ); |
874 | mCalendar->addEvent( lse ); | 874 | mCalendar->addEvent( lse ); |
875 | } | 875 | } |
876 | 876 | ||
877 | return lse; | 877 | return lse; |
878 | 878 | ||
879 | } | 879 | } |
880 | // probaly useless | ||
881 | void CalendarView::setupExternSyncProfiles() | ||
882 | { | ||
883 | Event* lse; | ||
884 | mExternLastSyncEvent.clear(); | ||
885 | int i; | ||
886 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { | ||
887 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); | ||
888 | if ( lse ) | ||
889 | mExternLastSyncEvent.append( lse ); | ||
890 | else | ||
891 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); | ||
892 | } | ||
893 | 880 | ||
894 | } | ||
895 | // we check, if the to delete event has a id for a profile | 881 | // we check, if the to delete event has a id for a profile |
896 | // if yes, we set this id in the profile to delete | 882 | // if yes, we set this id in the profile to delete |
897 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 883 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
898 | { | 884 | { |
899 | if ( lastSync.count() == 0 ) { | 885 | if ( lastSync.count() == 0 ) { |
900 | //qDebug(" lastSync.count() == 0"); | 886 | //qDebug(" lastSync.count() == 0"); |
901 | return; | 887 | return; |
902 | } | 888 | } |
903 | if ( toDelete->type() == "Journal" ) | 889 | if ( toDelete->type() == "Journal" ) |
904 | return; | 890 | return; |
905 | 891 | ||
906 | Event* eve = lastSync.first(); | 892 | Event* eve = lastSync.first(); |
907 | 893 | ||
908 | while ( eve ) { | 894 | while ( eve ) { |
909 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 895 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
910 | if ( !id.isEmpty() ) { | 896 | if ( !id.isEmpty() ) { |
911 | QString des = eve->description(); | 897 | QString des = eve->description(); |
912 | QString pref = "e"; | 898 | QString pref = "e"; |
913 | if ( toDelete->type() == "Todo" ) | 899 | if ( toDelete->type() == "Todo" ) |
914 | pref = "t"; | 900 | pref = "t"; |
915 | des += pref+ id + ","; | 901 | des += pref+ id + ","; |
916 | eve->setReadOnly( false ); | 902 | eve->setReadOnly( false ); |
917 | eve->setDescription( des ); | 903 | eve->setDescription( des ); |
918 | //qDebug("setdes %s ", des.latin1()); | 904 | //qDebug("setdes %s ", des.latin1()); |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index a713c91..0f7e696 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -92,49 +92,48 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
92 | const char *name = 0 ); | 92 | const char *name = 0 ); |
93 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 93 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
94 | const char *name = 0 ); | 94 | const char *name = 0 ); |
95 | virtual ~CalendarView(); | 95 | virtual ~CalendarView(); |
96 | 96 | ||
97 | Calendar *calendar() { return mCalendar; } | 97 | Calendar *calendar() { return mCalendar; } |
98 | 98 | ||
99 | KOViewManager *viewManager(); | 99 | KOViewManager *viewManager(); |
100 | KODialogManager *dialogManager(); | 100 | KODialogManager *dialogManager(); |
101 | 101 | ||
102 | QDate startDate(); | 102 | QDate startDate(); |
103 | QDate endDate(); | 103 | QDate endDate(); |
104 | 104 | ||
105 | QWidgetStack *viewStack(); | 105 | QWidgetStack *viewStack(); |
106 | QWidget *leftFrame(); | 106 | QWidget *leftFrame(); |
107 | NavigatorBar *navigatorBar(); | 107 | NavigatorBar *navigatorBar(); |
108 | 108 | ||
109 | DateNavigator *dateNavigator(); | 109 | DateNavigator *dateNavigator(); |
110 | KDateNavigator *dateNavigatorWidget(); | 110 | KDateNavigator *dateNavigatorWidget(); |
111 | 111 | ||
112 | void addView(KOrg::BaseView *); | 112 | void addView(KOrg::BaseView *); |
113 | void showView(KOrg::BaseView *); | 113 | void showView(KOrg::BaseView *); |
114 | KOEventViewerDialog* getEventViewerDialog(); | 114 | KOEventViewerDialog* getEventViewerDialog(); |
115 | Incidence *currentSelection(); | 115 | Incidence *currentSelection(); |
116 | void setupExternSyncProfiles(); | ||
117 | 116 | ||
118 | signals: | 117 | signals: |
119 | /** This todo has been modified */ | 118 | /** This todo has been modified */ |
120 | void todoModified(Todo *, int); | 119 | void todoModified(Todo *, int); |
121 | 120 | ||
122 | /** when change is made to options dialog, the topwidget will catch this | 121 | /** when change is made to options dialog, the topwidget will catch this |
123 | * and emit this signal which notifies all widgets which have registered | 122 | * and emit this signal which notifies all widgets which have registered |
124 | * for notification to update their settings. */ | 123 | * for notification to update their settings. */ |
125 | void configChanged(); | 124 | void configChanged(); |
126 | /** emitted when the topwidget is closing down, so that any attached | 125 | /** emitted when the topwidget is closing down, so that any attached |
127 | child windows can also close. */ | 126 | child windows can also close. */ |
128 | void closingDown(); | 127 | void closingDown(); |
129 | /** emitted right before we die */ | 128 | /** emitted right before we die */ |
130 | void closed(QWidget *); | 129 | void closed(QWidget *); |
131 | 130 | ||
132 | /** Emitted when state of modified flag changes */ | 131 | /** Emitted when state of modified flag changes */ |
133 | void modifiedChanged(bool); | 132 | void modifiedChanged(bool); |
134 | void signalmodified(); | 133 | void signalmodified(); |
135 | 134 | ||
136 | /** Emitted when state of read-only flag changes */ | 135 | /** Emitted when state of read-only flag changes */ |
137 | void readOnlyChanged(bool); | 136 | void readOnlyChanged(bool); |
138 | 137 | ||
139 | /** Emitted when the unit of navigation changes */ | 138 | /** Emitted when the unit of navigation changes */ |
140 | void changeNavStringPrev(const QString &); | 139 | void changeNavStringPrev(const QString &); |
@@ -523,49 +522,48 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
523 | ResourceView *mResourceView; | 522 | ResourceView *mResourceView; |
524 | 523 | ||
525 | // calendar object for this viewing instance | 524 | // calendar object for this viewing instance |
526 | Calendar *mCalendar; | 525 | Calendar *mCalendar; |
527 | 526 | ||
528 | CalendarResourceManager *mResourceManager; | 527 | CalendarResourceManager *mResourceManager; |
529 | 528 | ||
530 | FileStorage *mStorage; | 529 | FileStorage *mStorage; |
531 | 530 | ||
532 | DateNavigator *mNavigator; | 531 | DateNavigator *mNavigator; |
533 | 532 | ||
534 | KOViewManager *mViewManager; | 533 | KOViewManager *mViewManager; |
535 | KODialogManager *mDialogManager; | 534 | KODialogManager *mDialogManager; |
536 | 535 | ||
537 | // Calendar filters | 536 | // Calendar filters |
538 | QPtrList<CalFilter> mFilters; | 537 | QPtrList<CalFilter> mFilters; |
539 | 538 | ||
540 | // various housekeeping variables. | 539 | // various housekeeping variables. |
541 | bool mModified; // flag indicating if calendar is modified | 540 | bool mModified; // flag indicating if calendar is modified |
542 | bool mReadOnly; // flag indicating if calendar is read-only | 541 | bool mReadOnly; // flag indicating if calendar is read-only |
543 | QDate mSaveSingleDate; | 542 | QDate mSaveSingleDate; |
544 | 543 | ||
545 | Incidence *mSelectedIncidence; | 544 | Incidence *mSelectedIncidence; |
546 | Incidence *mMoveIncidence; | 545 | Incidence *mMoveIncidence; |
547 | QPtrList<Event> mExternLastSyncEvent; | ||
548 | KOTodoView *mTodoList; | 546 | KOTodoView *mTodoList; |
549 | KOEventEditor * mEventEditor; | 547 | KOEventEditor * mEventEditor; |
550 | KOTodoEditor * mTodoEditor; | 548 | KOTodoEditor * mTodoEditor; |
551 | KOEventViewerDialog * mEventViewerDialog; | 549 | KOEventViewerDialog * mEventViewerDialog; |
552 | void keyPressEvent ( QKeyEvent *e) ; | 550 | void keyPressEvent ( QKeyEvent *e) ; |
553 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 551 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
554 | }; | 552 | }; |
555 | 553 | ||
556 | 554 | ||
557 | class CalendarViewVisitor : public Incidence::Visitor | 555 | class CalendarViewVisitor : public Incidence::Visitor |
558 | { | 556 | { |
559 | public: | 557 | public: |
560 | CalendarViewVisitor() : mView( 0 ) {} | 558 | CalendarViewVisitor() : mView( 0 ) {} |
561 | 559 | ||
562 | bool act( Incidence *incidence, CalendarView *view ) | 560 | bool act( Incidence *incidence, CalendarView *view ) |
563 | { | 561 | { |
564 | mView = view; | 562 | mView = view; |
565 | return incidence->accept( *this ); | 563 | return incidence->accept( *this ); |
566 | } | 564 | } |
567 | 565 | ||
568 | protected: | 566 | protected: |
569 | CalendarView *mView; | 567 | CalendarView *mView; |
570 | }; | 568 | }; |
571 | 569 | ||
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index ec69b11..9104347 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -969,49 +969,48 @@ void MainWindow::fillSyncMenu() | |||
969 | temp->writeConfig(&config); | 969 | temp->writeConfig(&config); |
970 | temp->setName( prof[1] ); | 970 | temp->setName( prof[1] ); |
971 | temp->writeConfig(&config); | 971 | temp->writeConfig(&config); |
972 | temp->setName( prof[2] ); | 972 | temp->setName( prof[2] ); |
973 | temp->writeConfig(&config); | 973 | temp->writeConfig(&config); |
974 | config.setGroup("General"); | 974 | config.setGroup("General"); |
975 | config.writeEntry("SyncProfileNames",prof); | 975 | config.writeEntry("SyncProfileNames",prof); |
976 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 976 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
977 | config.sync(); | 977 | config.sync(); |
978 | delete temp; | 978 | delete temp; |
979 | } | 979 | } |
980 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 980 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
981 | KOPrefs::instance()->mSyncProfileNames = prof; | 981 | KOPrefs::instance()->mSyncProfileNames = prof; |
982 | int i; | 982 | int i; |
983 | for ( i = 0; i < prof.count(); ++i ) { | 983 | for ( i = 0; i < prof.count(); ++i ) { |
984 | 984 | ||
985 | syncMenu->insertItem( prof[i], 1000+i ); | 985 | syncMenu->insertItem( prof[i], 1000+i ); |
986 | if ( i == 2 ) | 986 | if ( i == 2 ) |
987 | syncMenu->insertSeparator(); | 987 | syncMenu->insertSeparator(); |
988 | } | 988 | } |
989 | QDir app_dir; | 989 | QDir app_dir; |
990 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 990 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
991 | syncMenu->setItemEnabled( false , 1000 ); | 991 | syncMenu->setItemEnabled( false , 1000 ); |
992 | } | 992 | } |
993 | mView->setupExternSyncProfiles(); | ||
994 | } | 993 | } |
995 | 994 | ||
996 | int MainWindow::ringSync() | 995 | int MainWindow::ringSync() |
997 | { | 996 | { |
998 | int syncedProfiles = 0; | 997 | int syncedProfiles = 0; |
999 | int i; | 998 | int i; |
1000 | QTime timer; | 999 | QTime timer; |
1001 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 1000 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
1002 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; | 1001 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; |
1003 | KSyncProfile* temp = new KSyncProfile (); | 1002 | KSyncProfile* temp = new KSyncProfile (); |
1004 | KOPrefs::instance()->mAskForPreferences = false; | 1003 | KOPrefs::instance()->mAskForPreferences = false; |
1005 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 1004 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
1006 | mCurrentSyncProfile = i; | 1005 | mCurrentSyncProfile = i; |
1007 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 1006 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
1008 | temp->readConfig(&config); | 1007 | temp->readConfig(&config); |
1009 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { | 1008 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { |
1010 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 1009 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
1011 | ++syncedProfiles; | 1010 | ++syncedProfiles; |
1012 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 1011 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
1013 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 1012 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
1014 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 1013 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
1015 | KOPrefs::instance()->mWriteBackInFuture = 0; | 1014 | KOPrefs::instance()->mWriteBackInFuture = 0; |
1016 | if ( temp->getWriteBackFuture() ) | 1015 | if ( temp->getWriteBackFuture() ) |
1017 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 1016 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h index 01c57a3..6f92919 100644 --- a/libkdepim/kpimprefs.h +++ b/libkdepim/kpimprefs.h | |||
@@ -35,51 +35,35 @@ $Id$ | |||
35 | 35 | ||
36 | #include "kprefs.h" | 36 | #include "kprefs.h" |
37 | 37 | ||
38 | class KPimPrefs : public KPrefs | 38 | class KPimPrefs : public KPrefs |
39 | { | 39 | { |
40 | public: | 40 | public: |
41 | 41 | ||
42 | KPimPrefs( const QString &name = QString::null ); | 42 | KPimPrefs( const QString &name = QString::null ); |
43 | 43 | ||
44 | virtual ~KPimPrefs(); | 44 | virtual ~KPimPrefs(); |
45 | 45 | ||
46 | /** Set preferences to default values */ | 46 | /** Set preferences to default values */ |
47 | void usrSetDefaults(); | 47 | void usrSetDefaults(); |
48 | 48 | ||
49 | /** Read preferences from config file */ | 49 | /** Read preferences from config file */ |
50 | void usrReadConfig(); | 50 | void usrReadConfig(); |
51 | 51 | ||
52 | /** Write preferences to config file */ | 52 | /** Write preferences to config file */ |
53 | void usrWriteConfig(); | 53 | void usrWriteConfig(); |
54 | 54 | ||
55 | 55 | ||
56 | public: | 56 | public: |
57 | QStringList mCustomCategories; | 57 | QStringList mCustomCategories; |
58 | 58 | ||
59 | // sync stuff | 59 | |
60 | QString mLocalMachineName; | ||
61 | QStringList mExternSyncProfiles; | ||
62 | QStringList mSyncProfileNames; | ||
63 | bool mAskForPreferences; | ||
64 | bool mShowSyncSummary; | ||
65 | bool mShowSyncEvents; | ||
66 | bool mShowTodoInAgenda; | ||
67 | bool mWriteBackExistingOnly; | ||
68 | int mSyncAlgoPrefs; | ||
69 | int mRingSyncAlgoPrefs; | ||
70 | bool mWriteBackFile; | ||
71 | int mWriteBackInFuture; | ||
72 | QString mPhoneDevice; | ||
73 | QString mPhoneConnection; | ||
74 | QString mPhoneModel; | ||
75 | QString mLastSyncedLocalFile; // save! | ||
76 | 60 | ||
77 | 61 | ||
78 | protected: | 62 | protected: |
79 | virtual void setCategoryDefaults(); | 63 | virtual void setCategoryDefaults(); |
80 | 64 | ||
81 | 65 | ||
82 | 66 | ||
83 | }; | 67 | }; |
84 | 68 | ||
85 | #endif | 69 | #endif |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 07e6761..c0cc840 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -31,209 +31,207 @@ | |||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
35 | 35 | ||
36 | #include <qdir.h> | 36 | #include <qdir.h> |
37 | #include <qprogressbar.h> | 37 | #include <qprogressbar.h> |
38 | #include <qpopupmenu.h> | 38 | #include <qpopupmenu.h> |
39 | #include <qpushbutton.h> | 39 | #include <qpushbutton.h> |
40 | #include <qradiobutton.h> | 40 | #include <qradiobutton.h> |
41 | #include <qbuttongroup.h> | 41 | #include <qbuttongroup.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
44 | #include <qapplication.h> | 44 | #include <qapplication.h> |
45 | #include <qlineedit.h> | 45 | #include <qlineedit.h> |
46 | #include <qdialog.h> | 46 | #include <qdialog.h> |
47 | #include <qlayout.h> | 47 | #include <qlayout.h> |
48 | 48 | ||
49 | #include <klocale.h> | 49 | #include <klocale.h> |
50 | #include <kglobal.h> | 50 | #include <kglobal.h> |
51 | #include <kconfig.h> | 51 | #include <kconfig.h> |
52 | #include <kfiledialog.h> | 52 | #include <kfiledialog.h> |
53 | 53 | ||
54 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 54 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
55 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs), mSyncMenu(syncmenu) | 55 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) |
56 | { | 56 | { |
57 | bar = new QProgressBar ( 1, 0 ); | 57 | bar = new QProgressBar ( 1, 0 ); |
58 | bar->setCaption (""); | 58 | bar->setCaption (""); |
59 | 59 | ||
60 | int w = 300; | 60 | int w = 300; |
61 | if ( QApplication::desktop()->width() < 320 ) | 61 | if ( QApplication::desktop()->width() < 320 ) |
62 | w = 220; | 62 | w = 220; |
63 | int h = bar->sizeHint().height() ; | 63 | int h = bar->sizeHint().height() ; |
64 | int dw = QApplication::desktop()->width(); | 64 | int dw = QApplication::desktop()->width(); |
65 | int dh = QApplication::desktop()->height(); | 65 | int dh = QApplication::desktop()->height(); |
66 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 66 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
67 | 67 | ||
68 | } | 68 | } |
69 | 69 | ||
70 | KSyncManager::~KSyncManager() | 70 | KSyncManager::~KSyncManager() |
71 | { | 71 | { |
72 | delete bar; | 72 | delete bar; |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
76 | void KSyncManager::fillSyncMenu() | 76 | void KSyncManager::fillSyncMenu() |
77 | { | 77 | { |
78 | if ( mSyncMenu->count() ) | 78 | if ( mSyncMenu->count() ) |
79 | mSyncMenu->clear(); | 79 | mSyncMenu->clear(); |
80 | 80 | ||
81 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 81 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
82 | mSyncMenu->insertSeparator(); | 82 | mSyncMenu->insertSeparator(); |
83 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 83 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
84 | mSyncMenu->insertSeparator(); | 84 | mSyncMenu->insertSeparator(); |
85 | 85 | ||
86 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 86 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
87 | config.setGroup("General"); | 87 | config.setGroup("General"); |
88 | QStringList prof = config.readListEntry("SyncProfileNames"); | 88 | QStringList prof = config.readListEntry("SyncProfileNames"); |
89 | mPrefs->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 89 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
90 | if ( prof.count() < 3 ) { | 90 | if ( prof.count() < 3 ) { |
91 | prof.clear(); | 91 | prof.clear(); |
92 | prof << i18n("Sharp_DTM"); | 92 | prof << i18n("Sharp_DTM"); |
93 | prof << i18n("Local_file"); | 93 | prof << i18n("Local_file"); |
94 | prof << i18n("Last_file"); | 94 | prof << i18n("Last_file"); |
95 | KSyncProfile* temp = new KSyncProfile (); | 95 | KSyncProfile* temp = new KSyncProfile (); |
96 | temp->setName( prof[0] ); | 96 | temp->setName( prof[0] ); |
97 | temp->writeConfig(&config); | 97 | temp->writeConfig(&config); |
98 | temp->setName( prof[1] ); | 98 | temp->setName( prof[1] ); |
99 | temp->writeConfig(&config); | 99 | temp->writeConfig(&config); |
100 | temp->setName( prof[2] ); | 100 | temp->setName( prof[2] ); |
101 | temp->writeConfig(&config); | 101 | temp->writeConfig(&config); |
102 | config.setGroup("General"); | 102 | config.setGroup("General"); |
103 | config.writeEntry("SyncProfileNames",prof); | 103 | config.writeEntry("SyncProfileNames",prof); |
104 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 104 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
105 | config.sync(); | 105 | config.sync(); |
106 | delete temp; | 106 | delete temp; |
107 | } | 107 | } |
108 | mPrefs->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 108 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
109 | mPrefs->mSyncProfileNames = prof; | 109 | mSyncProfileNames = prof; |
110 | unsigned int i; | 110 | unsigned int i; |
111 | for ( i = 0; i < prof.count(); ++i ) { | 111 | for ( i = 0; i < prof.count(); ++i ) { |
112 | mSyncMenu->insertItem( prof[i], 1000+i ); | 112 | mSyncMenu->insertItem( prof[i], 1000+i ); |
113 | if ( i == 2 ) | 113 | if ( i == 2 ) |
114 | mSyncMenu->insertSeparator(); | 114 | mSyncMenu->insertSeparator(); |
115 | } | 115 | } |
116 | QDir app_dir; | 116 | QDir app_dir; |
117 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 117 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
118 | if ( mTargetApp == PWMPI) { | 118 | if ( mTargetApp == PWMPI) { |
119 | mSyncMenu->removeItem( 1000 ); | 119 | mSyncMenu->removeItem( 1000 ); |
120 | } | 120 | } |
121 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 121 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
122 | mSyncMenu->setItemEnabled( 1000, false ); | 122 | mSyncMenu->setItemEnabled( 1000, false ); |
123 | } | 123 | } |
124 | //probaly useless | ||
125 | //mView->setupExternSyncProfiles(); | ||
126 | } | 124 | } |
127 | 125 | ||
128 | void KSyncManager::slotSyncMenu( int action ) | 126 | void KSyncManager::slotSyncMenu( int action ) |
129 | { | 127 | { |
130 | //qDebug("syncaction %d ", action); | 128 | //qDebug("syncaction %d ", action); |
131 | if ( action == 0 ) { | 129 | if ( action == 0 ) { |
132 | 130 | ||
133 | // seems to be a Qt2 event handling bug | 131 | // seems to be a Qt2 event handling bug |
134 | // syncmenu.clear causes a segfault at first time | 132 | // syncmenu.clear causes a segfault at first time |
135 | // when we call it after the main event loop, it is ok | 133 | // when we call it after the main event loop, it is ok |
136 | // same behaviour when calling OM/Pi via QCOP for the first time | 134 | // same behaviour when calling OM/Pi via QCOP for the first time |
137 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 135 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
138 | //confSync(); | 136 | //confSync(); |
139 | 137 | ||
140 | return; | 138 | return; |
141 | } | 139 | } |
142 | if ( action == 1 ) { | 140 | if ( action == 1 ) { |
143 | multiSync( true ); | 141 | multiSync( true ); |
144 | return; | 142 | return; |
145 | } | 143 | } |
146 | 144 | ||
147 | if (blockSave()) | 145 | if (blockSave()) |
148 | return; | 146 | return; |
149 | 147 | ||
150 | setBlockSave(true); | 148 | setBlockSave(true); |
151 | 149 | ||
152 | mCurrentSyncProfile = action - 1000 ; | 150 | mCurrentSyncProfile = action - 1000 ; |
153 | mCurrentSyncDevice = mPrefs->mSyncProfileNames[mCurrentSyncProfile] ; | 151 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
154 | mCurrentSyncName = mPrefs->mLocalMachineName ; | 152 | mCurrentSyncName = mLocalMachineName ; |
155 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 153 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
156 | KSyncProfile* temp = new KSyncProfile (); | 154 | KSyncProfile* temp = new KSyncProfile (); |
157 | temp->setName(mPrefs->mSyncProfileNames[mCurrentSyncProfile]); | 155 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
158 | temp->readConfig(&config); | 156 | temp->readConfig(&config); |
159 | mPrefs->mAskForPreferences = temp->getAskForPreferences(); | 157 | mAskForPreferences = temp->getAskForPreferences(); |
160 | mPrefs->mSyncAlgoPrefs = temp->getSyncPrefs(); | 158 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
161 | mPrefs->mWriteBackFile = temp->getWriteBackFile(); | 159 | mWriteBackFile = temp->getWriteBackFile(); |
162 | mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 160 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
163 | mPrefs->mWriteBackInFuture = 0; | 161 | mWriteBackInFuture = 0; |
164 | if ( temp->getWriteBackFuture() ) | 162 | if ( temp->getWriteBackFuture() ) |
165 | mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 163 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
166 | mPrefs->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 164 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
167 | if ( action == 1000 ) { | 165 | if ( action == 1000 ) { |
168 | syncSharp(); | 166 | syncSharp(); |
169 | 167 | ||
170 | } else if ( action == 1001 ) { | 168 | } else if ( action == 1001 ) { |
171 | syncLocalFile(); | 169 | syncLocalFile(); |
172 | 170 | ||
173 | } else if ( action == 1002 ) { | 171 | } else if ( action == 1002 ) { |
174 | quickSyncLocalFile(); | 172 | quickSyncLocalFile(); |
175 | 173 | ||
176 | } else if ( action >= 1003 ) { | 174 | } else if ( action >= 1003 ) { |
177 | if ( temp->getIsLocalFileSync() ) { | 175 | if ( temp->getIsLocalFileSync() ) { |
178 | switch(mTargetApp) | 176 | switch(mTargetApp) |
179 | { | 177 | { |
180 | case (KAPI): | 178 | case (KAPI): |
181 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 179 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
182 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 180 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
183 | break; | 181 | break; |
184 | case (KOPI): | 182 | case (KOPI): |
185 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 183 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
186 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 184 | mLastSyncedLocalFile = temp->getRemoteFileName(); |
187 | break; | 185 | break; |
188 | case (PWMPI): | 186 | case (PWMPI): |
189 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 187 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
190 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 188 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
191 | break; | 189 | break; |
192 | default: | 190 | default: |
193 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 191 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
194 | break; | 192 | break; |
195 | 193 | ||
196 | } | 194 | } |
197 | } else { | 195 | } else { |
198 | if ( temp->getIsPhoneSync() ) { | 196 | if ( temp->getIsPhoneSync() ) { |
199 | mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ; | 197 | mPhoneDevice = temp->getPhoneDevice( ) ; |
200 | mPrefs->mPhoneConnection = temp->getPhoneConnection( ); | 198 | mPhoneConnection = temp->getPhoneConnection( ); |
201 | mPrefs->mPhoneModel = temp->getPhoneModel( ); | 199 | mPhoneModel = temp->getPhoneModel( ); |
202 | syncPhone(); | 200 | syncPhone(); |
203 | } else | 201 | } else |
204 | syncRemote( temp ); | 202 | syncRemote( temp ); |
205 | 203 | ||
206 | } | 204 | } |
207 | } | 205 | } |
208 | delete temp; | 206 | delete temp; |
209 | setBlockSave(false); | 207 | setBlockSave(false); |
210 | } | 208 | } |
211 | 209 | ||
212 | void KSyncManager::syncLocalFile() | 210 | void KSyncManager::syncLocalFile() |
213 | { | 211 | { |
214 | 212 | ||
215 | QString fn =mPrefs->mLastSyncedLocalFile; | 213 | QString fn =mLastSyncedLocalFile; |
216 | QString ext; | 214 | QString ext; |
217 | 215 | ||
218 | switch(mTargetApp) | 216 | switch(mTargetApp) |
219 | { | 217 | { |
220 | case (KAPI): | 218 | case (KAPI): |
221 | ext = "(*.vcf)"; | 219 | ext = "(*.vcf)"; |
222 | break; | 220 | break; |
223 | case (KOPI): | 221 | case (KOPI): |
224 | ext = "(*.ics/*.vcs)"; | 222 | ext = "(*.ics/*.vcs)"; |
225 | break; | 223 | break; |
226 | case (PWMPI): | 224 | case (PWMPI): |
227 | ext = "(*.pwm)"; | 225 | ext = "(*.pwm)"; |
228 | break; | 226 | break; |
229 | default: | 227 | default: |
230 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); | 228 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); |
231 | break; | 229 | break; |
232 | 230 | ||
233 | } | 231 | } |
234 | 232 | ||
235 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 233 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
236 | if ( fn == "" ) | 234 | if ( fn == "" ) |
237 | return; | 235 | return; |
238 | if ( syncWithFile( fn, false ) ) { | 236 | if ( syncWithFile( fn, false ) ) { |
239 | qDebug("syncLocalFile() successful "); | 237 | qDebug("syncLocalFile() successful "); |
@@ -242,176 +240,176 @@ void KSyncManager::syncLocalFile() | |||
242 | } | 240 | } |
243 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 241 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
244 | { | 242 | { |
245 | bool ret = false; | 243 | bool ret = false; |
246 | QFileInfo info; | 244 | QFileInfo info; |
247 | info.setFile( fn ); | 245 | info.setFile( fn ); |
248 | QString mess; | 246 | QString mess; |
249 | bool loadbup = true; | 247 | bool loadbup = true; |
250 | if ( !info. exists() ) { | 248 | if ( !info. exists() ) { |
251 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 249 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
252 | int result = QMessageBox::warning( mParent, i18n("Warning!"), | 250 | int result = QMessageBox::warning( mParent, i18n("Warning!"), |
253 | mess ); | 251 | mess ); |
254 | return ret; | 252 | return ret; |
255 | } | 253 | } |
256 | int result = 0; | 254 | int result = 0; |
257 | if ( !quick ) { | 255 | if ( !quick ) { |
258 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 256 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
259 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 257 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
260 | mess, | 258 | mess, |
261 | i18n("Sync"), i18n("Cancel"), 0, | 259 | i18n("Sync"), i18n("Cancel"), 0, |
262 | 0, 1 ); | 260 | 0, 1 ); |
263 | if ( result ) | 261 | if ( result ) |
264 | return false; | 262 | return false; |
265 | } | 263 | } |
266 | if ( mPrefs->mAskForPreferences ) | 264 | if ( mAskForPreferences ) |
267 | edit_sync_options(); | 265 | edit_sync_options(); |
268 | if ( result == 0 ) { | 266 | if ( result == 0 ) { |
269 | //qDebug("Now sycing ... "); | 267 | //qDebug("Now sycing ... "); |
270 | if ( ret = mImplementation->sync( this, fn, mPrefs->mSyncAlgoPrefs ) ) | 268 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
271 | mParent->setCaption( i18n("Synchronization successful") ); | 269 | mParent->setCaption( i18n("Synchronization successful") ); |
272 | else | 270 | else |
273 | mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 271 | mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
274 | if ( ! quick ) | 272 | if ( ! quick ) |
275 | mPrefs->mLastSyncedLocalFile = fn; | 273 | mLastSyncedLocalFile = fn; |
276 | mImplementation->sync_setModified(); | 274 | mImplementation->sync_setModified(); |
277 | } | 275 | } |
278 | return ret; | 276 | return ret; |
279 | } | 277 | } |
280 | void KSyncManager::quickSyncLocalFile() | 278 | void KSyncManager::quickSyncLocalFile() |
281 | { | 279 | { |
282 | 280 | ||
283 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) { | 281 | if ( syncWithFile( mLastSyncedLocalFile, false ) ) { |
284 | qDebug("quick syncLocalFile() successful "); | 282 | qDebug("quick syncLocalFile() successful "); |
285 | 283 | ||
286 | } | 284 | } |
287 | } | 285 | } |
288 | void KSyncManager::multiSync( bool askforPrefs ) | 286 | void KSyncManager::multiSync( bool askforPrefs ) |
289 | { | 287 | { |
290 | if (blockSave()) | 288 | if (blockSave()) |
291 | return; | 289 | return; |
292 | setBlockSave(true); | 290 | setBlockSave(true); |
293 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 291 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
294 | if ( QMessageBox::information( mParent, i18n("Sync"), | 292 | if ( QMessageBox::information( mParent, i18n("Sync"), |
295 | question, | 293 | question, |
296 | i18n("Yes"), i18n("No"), | 294 | i18n("Yes"), i18n("No"), |
297 | 0, 0 ) != 0 ) { | 295 | 0, 0 ) != 0 ) { |
298 | setBlockSave(false); | 296 | setBlockSave(false); |
299 | mParent->setCaption(i18n("Aborted! Nothing synced!")); | 297 | mParent->setCaption(i18n("Aborted! Nothing synced!")); |
300 | return; | 298 | return; |
301 | } | 299 | } |
302 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 300 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
303 | mPrefs->mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 301 | mSyncAlgoPrefs = mRingSyncAlgoPrefs; |
304 | if ( askforPrefs ) { | 302 | if ( askforPrefs ) { |
305 | edit_sync_options(); | 303 | edit_sync_options(); |
306 | mPrefs->mRingSyncAlgoPrefs = mPrefs->mSyncAlgoPrefs; | 304 | mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
307 | } | 305 | } |
308 | mParent->setCaption(i18n("Multiple sync started.") ); | 306 | mParent->setCaption(i18n("Multiple sync started.") ); |
309 | qApp->processEvents(); | 307 | qApp->processEvents(); |
310 | int num = ringSync() ; | 308 | int num = ringSync() ; |
311 | if ( num > 1 ) | 309 | if ( num > 1 ) |
312 | ringSync(); | 310 | ringSync(); |
313 | setBlockSave(false); | 311 | setBlockSave(false); |
314 | if ( num ) | 312 | if ( num ) |
315 | mImplementation->sync_save(); | 313 | mImplementation->sync_save(); |
316 | if ( num ) | 314 | if ( num ) |
317 | mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 315 | mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
318 | else | 316 | else |
319 | mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 317 | mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
320 | return; | 318 | return; |
321 | } | 319 | } |
322 | int KSyncManager::ringSync() | 320 | int KSyncManager::ringSync() |
323 | { | 321 | { |
324 | int syncedProfiles = 0; | 322 | int syncedProfiles = 0; |
325 | unsigned int i; | 323 | unsigned int i; |
326 | QTime timer; | 324 | QTime timer; |
327 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 325 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
328 | QStringList syncProfileNames = mPrefs->mSyncProfileNames; | 326 | QStringList syncProfileNames = mSyncProfileNames; |
329 | KSyncProfile* temp = new KSyncProfile (); | 327 | KSyncProfile* temp = new KSyncProfile (); |
330 | mPrefs->mAskForPreferences = false; | 328 | mAskForPreferences = false; |
331 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 329 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
332 | mCurrentSyncProfile = i; | 330 | mCurrentSyncProfile = i; |
333 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 331 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
334 | temp->readConfig(&config); | 332 | temp->readConfig(&config); |
335 | 333 | ||
336 | QString includeInRingSync; | 334 | QString includeInRingSync; |
337 | switch(mTargetApp) | 335 | switch(mTargetApp) |
338 | { | 336 | { |
339 | case (KAPI): | 337 | case (KAPI): |
340 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 338 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
341 | break; | 339 | break; |
342 | case (KOPI): | 340 | case (KOPI): |
343 | includeInRingSync = temp->getIncludeInRingSync(); | 341 | includeInRingSync = temp->getIncludeInRingSync(); |
344 | break; | 342 | break; |
345 | case (PWMPI): | 343 | case (PWMPI): |
346 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 344 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
347 | break; | 345 | break; |
348 | default: | 346 | default: |
349 | qDebug("KSyncManager::ringSync: invalid apptype selected"); | 347 | qDebug("KSyncManager::ringSync: invalid apptype selected"); |
350 | break; | 348 | break; |
351 | 349 | ||
352 | } | 350 | } |
353 | 351 | ||
354 | 352 | ||
355 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 353 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
356 | mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 354 | mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
357 | ++syncedProfiles; | 355 | ++syncedProfiles; |
358 | // mPrefs->mAskForPreferences = temp->getAskForPreferences(); | 356 | // mAskForPreferences = temp->getAskForPreferences(); |
359 | mPrefs->mWriteBackFile = temp->getWriteBackFile(); | 357 | mWriteBackFile = temp->getWriteBackFile(); |
360 | mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 358 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
361 | mPrefs->mWriteBackInFuture = 0; | 359 | mWriteBackInFuture = 0; |
362 | if ( temp->getWriteBackFuture() ) | 360 | if ( temp->getWriteBackFuture() ) |
363 | mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 361 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
364 | mPrefs->mShowSyncSummary = false; | 362 | mShowSyncSummary = false; |
365 | mCurrentSyncDevice = syncProfileNames[i] ; | 363 | mCurrentSyncDevice = syncProfileNames[i] ; |
366 | mCurrentSyncName = mPrefs->mLocalMachineName; | 364 | mCurrentSyncName = mLocalMachineName; |
367 | if ( i == 0 ) { | 365 | if ( i == 0 ) { |
368 | syncSharp(); | 366 | syncSharp(); |
369 | } else { | 367 | } else { |
370 | if ( temp->getIsLocalFileSync() ) { | 368 | if ( temp->getIsLocalFileSync() ) { |
371 | switch(mTargetApp) | 369 | switch(mTargetApp) |
372 | { | 370 | { |
373 | case (KAPI): | 371 | case (KAPI): |
374 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 372 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
375 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 373 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
376 | break; | 374 | break; |
377 | case (KOPI): | 375 | case (KOPI): |
378 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 376 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
379 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 377 | mLastSyncedLocalFile = temp->getRemoteFileName(); |
380 | break; | 378 | break; |
381 | case (PWMPI): | 379 | case (PWMPI): |
382 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 380 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
383 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 381 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
384 | break; | 382 | break; |
385 | default: | 383 | default: |
386 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 384 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
387 | break; | 385 | break; |
388 | } | 386 | } |
389 | } else { | 387 | } else { |
390 | if ( temp->getIsPhoneSync() ) { | 388 | if ( temp->getIsPhoneSync() ) { |
391 | mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ; | 389 | mPhoneDevice = temp->getPhoneDevice( ) ; |
392 | mPrefs->mPhoneConnection = temp->getPhoneConnection( ); | 390 | mPhoneConnection = temp->getPhoneConnection( ); |
393 | mPrefs->mPhoneModel = temp->getPhoneModel( ); | 391 | mPhoneModel = temp->getPhoneModel( ); |
394 | syncPhone(); | 392 | syncPhone(); |
395 | } else | 393 | } else |
396 | syncRemote( temp, false ); | 394 | syncRemote( temp, false ); |
397 | 395 | ||
398 | } | 396 | } |
399 | } | 397 | } |
400 | timer.start(); | 398 | timer.start(); |
401 | mParent->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 399 | mParent->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
402 | while ( timer.elapsed () < 2000 ) { | 400 | while ( timer.elapsed () < 2000 ) { |
403 | qApp->processEvents(); | 401 | qApp->processEvents(); |
404 | #ifndef _WIN32_ | 402 | #ifndef _WIN32_ |
405 | sleep (1); | 403 | sleep (1); |
406 | #endif | 404 | #endif |
407 | } | 405 | } |
408 | 406 | ||
409 | } | 407 | } |
410 | 408 | ||
411 | } | 409 | } |
412 | delete temp; | 410 | delete temp; |
413 | return syncedProfiles; | 411 | return syncedProfiles; |
414 | } | 412 | } |
415 | 413 | ||
416 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 414 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
417 | { | 415 | { |
@@ -470,177 +468,177 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | |||
470 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 468 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
471 | if ( result != 0 ) { | 469 | if ( result != 0 ) { |
472 | unsigned int len = maxlen; | 470 | unsigned int len = maxlen; |
473 | while ( len < preCommand.length() ) { | 471 | while ( len < preCommand.length() ) { |
474 | preCommand.insert( len , "\n" ); | 472 | preCommand.insert( len , "\n" ); |
475 | len += maxlen +2; | 473 | len += maxlen +2; |
476 | } | 474 | } |
477 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; | 475 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; |
478 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 476 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
479 | question, | 477 | question, |
480 | i18n("Okay!")) ; | 478 | i18n("Okay!")) ; |
481 | mParent->setCaption (""); | 479 | mParent->setCaption (""); |
482 | return; | 480 | return; |
483 | } | 481 | } |
484 | mParent->setCaption ( i18n( "Copying succeed." ) ); | 482 | mParent->setCaption ( i18n( "Copying succeed." ) ); |
485 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 483 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
486 | 484 | ||
487 | 485 | ||
488 | 486 | ||
489 | if ( syncWithFile( localTempFile, true ) ) { | 487 | if ( syncWithFile( localTempFile, true ) ) { |
490 | // Event* e = mView->getLastSyncEvent(); | 488 | // Event* e = mView->getLastSyncEvent(); |
491 | // e->setReadOnly( false ); | 489 | // e->setReadOnly( false ); |
492 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 490 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
493 | // e->setReadOnly( true ); | 491 | // e->setReadOnly( true ); |
494 | if ( mPrefs->mWriteBackFile ) { | 492 | if ( mWriteBackFile ) { |
495 | int fi; | 493 | int fi; |
496 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 494 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
497 | QString pwd = getPassword(); | 495 | QString pwd = getPassword(); |
498 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 496 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
499 | 497 | ||
500 | } | 498 | } |
501 | mParent->setCaption ( i18n( "Writing back file ..." ) ); | 499 | mParent->setCaption ( i18n( "Writing back file ..." ) ); |
502 | result = system ( postCommand ); | 500 | result = system ( postCommand ); |
503 | qDebug("Writing back file result: %d ", result); | 501 | qDebug("Writing back file result: %d ", result); |
504 | if ( result != 0 ) { | 502 | if ( result != 0 ) { |
505 | mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 503 | mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
506 | return; | 504 | return; |
507 | } else { | 505 | } else { |
508 | mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 506 | mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
509 | } | 507 | } |
510 | } | 508 | } |
511 | } | 509 | } |
512 | return; | 510 | return; |
513 | } | 511 | } |
514 | 512 | ||
515 | void KSyncManager::edit_sync_options() | 513 | void KSyncManager::edit_sync_options() |
516 | { | 514 | { |
517 | //mDialogManager->showSyncOptions(); | 515 | //mDialogManager->showSyncOptions(); |
518 | //mPrefs->mSyncAlgoPrefs | 516 | //mSyncAlgoPrefs |
519 | QDialog dia( mParent, "dia", true ); | 517 | QDialog dia( mParent, "dia", true ); |
520 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 518 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
521 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 519 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
522 | QVBoxLayout lay ( &dia ); | 520 | QVBoxLayout lay ( &dia ); |
523 | lay.setSpacing( 2 ); | 521 | lay.setSpacing( 2 ); |
524 | lay.setMargin( 3 ); | 522 | lay.setMargin( 3 ); |
525 | lay.addWidget(&gr); | 523 | lay.addWidget(&gr); |
526 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 524 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
527 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 525 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
528 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 526 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
529 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 527 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
530 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 528 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
531 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 529 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
532 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 530 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
533 | QPushButton pb ( "OK", &dia); | 531 | QPushButton pb ( "OK", &dia); |
534 | lay.addWidget( &pb ); | 532 | lay.addWidget( &pb ); |
535 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 533 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
536 | switch ( mPrefs->mSyncAlgoPrefs ) { | 534 | switch ( mSyncAlgoPrefs ) { |
537 | case 0: | 535 | case 0: |
538 | loc.setChecked( true); | 536 | loc.setChecked( true); |
539 | break; | 537 | break; |
540 | case 1: | 538 | case 1: |
541 | rem.setChecked( true ); | 539 | rem.setChecked( true ); |
542 | break; | 540 | break; |
543 | case 2: | 541 | case 2: |
544 | newest.setChecked( true); | 542 | newest.setChecked( true); |
545 | break; | 543 | break; |
546 | case 3: | 544 | case 3: |
547 | ask.setChecked( true); | 545 | ask.setChecked( true); |
548 | break; | 546 | break; |
549 | case 4: | 547 | case 4: |
550 | f_loc.setChecked( true); | 548 | f_loc.setChecked( true); |
551 | break; | 549 | break; |
552 | case 5: | 550 | case 5: |
553 | f_rem.setChecked( true); | 551 | f_rem.setChecked( true); |
554 | break; | 552 | break; |
555 | case 6: | 553 | case 6: |
556 | // both.setChecked( true); | 554 | // both.setChecked( true); |
557 | break; | 555 | break; |
558 | default: | 556 | default: |
559 | break; | 557 | break; |
560 | } | 558 | } |
561 | if ( dia.exec() ) { | 559 | if ( dia.exec() ) { |
562 | mPrefs->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 560 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
563 | } | 561 | } |
564 | 562 | ||
565 | 563 | ||
566 | } | 564 | } |
567 | QString KSyncManager::getPassword( ) | 565 | QString KSyncManager::getPassword( ) |
568 | { | 566 | { |
569 | QString retfile = ""; | 567 | QString retfile = ""; |
570 | QDialog dia ( mParent, "input-dialog", true ); | 568 | QDialog dia ( mParent, "input-dialog", true ); |
571 | QLineEdit lab ( &dia ); | 569 | QLineEdit lab ( &dia ); |
572 | lab.setEchoMode( QLineEdit::Password ); | 570 | lab.setEchoMode( QLineEdit::Password ); |
573 | QVBoxLayout lay( &dia ); | 571 | QVBoxLayout lay( &dia ); |
574 | lay.setMargin(7); | 572 | lay.setMargin(7); |
575 | lay.setSpacing(7); | 573 | lay.setSpacing(7); |
576 | lay.addWidget( &lab); | 574 | lay.addWidget( &lab); |
577 | dia.setFixedSize( 230,50 ); | 575 | dia.setFixedSize( 230,50 ); |
578 | dia.setCaption( i18n("Enter password") ); | 576 | dia.setCaption( i18n("Enter password") ); |
579 | QPushButton pb ( "OK", &dia); | 577 | QPushButton pb ( "OK", &dia); |
580 | lay.addWidget( &pb ); | 578 | lay.addWidget( &pb ); |
581 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 579 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
582 | dia.show(); | 580 | dia.show(); |
583 | int res = dia.exec(); | 581 | int res = dia.exec(); |
584 | if ( res ) | 582 | if ( res ) |
585 | retfile = lab.text(); | 583 | retfile = lab.text(); |
586 | dia.hide(); | 584 | dia.hide(); |
587 | qApp->processEvents(); | 585 | qApp->processEvents(); |
588 | return retfile; | 586 | return retfile; |
589 | 587 | ||
590 | } | 588 | } |
591 | 589 | ||
592 | 590 | ||
593 | void KSyncManager::confSync() | 591 | void KSyncManager::confSync() |
594 | { | 592 | { |
595 | static KSyncPrefsDialog* sp = 0; | 593 | static KSyncPrefsDialog* sp = 0; |
596 | if ( ! sp ) { | 594 | if ( ! sp ) { |
597 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 595 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
598 | } | 596 | } |
599 | sp->usrReadConfig(); | 597 | sp->usrReadConfig(); |
600 | #ifndef DESKTOP_VERSION | 598 | #ifndef DESKTOP_VERSION |
601 | sp->showMaximized(); | 599 | sp->showMaximized(); |
602 | #else | 600 | #else |
603 | sp->show(); | 601 | sp->show(); |
604 | #endif | 602 | #endif |
605 | sp->exec(); | 603 | sp->exec(); |
606 | mPrefs->mSyncProfileNames = sp->getSyncProfileNames(); | 604 | mSyncProfileNames = sp->getSyncProfileNames(); |
607 | mPrefs->mLocalMachineName = sp->getLocalMachineName (); | 605 | mLocalMachineName = sp->getLocalMachineName (); |
608 | fillSyncMenu(); | 606 | fillSyncMenu(); |
609 | } | 607 | } |
610 | 608 | ||
611 | void KSyncManager::syncSharp() | 609 | void KSyncManager::syncSharp() |
612 | { | 610 | { |
613 | if ( ! syncExternalApplication("sharp") ) | 611 | if ( ! syncExternalApplication("sharp") ) |
614 | qDebug("ERROR sync sharp ");; | 612 | qDebug("ERROR sync sharp ");; |
615 | } | 613 | } |
616 | 614 | ||
617 | bool KSyncManager::syncExternalApplication(QString resource) | 615 | bool KSyncManager::syncExternalApplication(QString resource) |
618 | { | 616 | { |
619 | if ( mImplementation->sync_isModified() ) | 617 | if ( mImplementation->sync_isModified() ) |
620 | mImplementation->sync_save(); | 618 | mImplementation->sync_save(); |
621 | 619 | ||
622 | if ( mPrefs->mAskForPreferences ) | 620 | if ( mAskForPreferences ) |
623 | edit_sync_options(); | 621 | edit_sync_options(); |
624 | 622 | ||
625 | qDebug("sync %s", resource.latin1()); | 623 | qDebug("sync %s", resource.latin1()); |
626 | 624 | ||
627 | bool syncOK = mImplementation->syncExternal(this, resource); | 625 | bool syncOK = mImplementation->syncExternal(this, resource); |
628 | 626 | ||
629 | return syncOK; | 627 | return syncOK; |
630 | 628 | ||
631 | } | 629 | } |
632 | 630 | ||
633 | void KSyncManager::syncPhone() | 631 | void KSyncManager::syncPhone() |
634 | { | 632 | { |
635 | if ( mImplementation->sync_isModified() ) | 633 | if ( mImplementation->sync_isModified() ) |
636 | mImplementation->sync_save(); | 634 | mImplementation->sync_save(); |
637 | 635 | ||
638 | qDebug("pending syncPhone(); "); | 636 | qDebug("pending syncPhone(); "); |
639 | //mView->syncPhone(); | 637 | //mView->syncPhone(); |
640 | mImplementation->sync_setModified(); | 638 | mImplementation->sync_setModified(); |
641 | 639 | ||
642 | } | 640 | } |
643 | 641 | ||
644 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 642 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
645 | { | 643 | { |
646 | if (!bar->isVisible()) | 644 | if (!bar->isVisible()) |
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 9761107..6b10016 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -38,82 +38,100 @@ class KSyncManager : public QObject | |||
38 | Q_OBJECT | 38 | Q_OBJECT |
39 | 39 | ||
40 | public: | 40 | public: |
41 | enum TargetApp { | 41 | enum TargetApp { |
42 | KOPI = 0, | 42 | KOPI = 0, |
43 | KAPI = 1, | 43 | KAPI = 1, |
44 | PWMPI = 2 }; | 44 | PWMPI = 2 }; |
45 | 45 | ||
46 | 46 | ||
47 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 47 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); |
48 | ~KSyncManager() ; | 48 | ~KSyncManager() ; |
49 | 49 | ||
50 | bool blockSave() { return mBlockSaveFlag; } | 50 | bool blockSave() { return mBlockSaveFlag; } |
51 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 51 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
52 | 52 | ||
53 | void fillSyncMenu(); | 53 | void fillSyncMenu(); |
54 | 54 | ||
55 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 55 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
56 | QString getCurrentSyncName() { return mCurrentSyncName; } | 56 | QString getCurrentSyncName() { return mCurrentSyncName; } |
57 | 57 | ||
58 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 58 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
59 | void hideProgressBar(); | 59 | void hideProgressBar(); |
60 | bool isProgressBarCanceled(); | 60 | bool isProgressBarCanceled(); |
61 | 61 | ||
62 | // sync stuff | ||
63 | QString mLocalMachineName; | ||
64 | QStringList mExternSyncProfiles; | ||
65 | QStringList mSyncProfileNames; | ||
66 | bool mAskForPreferences; | ||
67 | bool mShowSyncSummary; | ||
68 | bool mShowSyncEvents; | ||
69 | bool mShowTodoInAgenda; | ||
70 | bool mWriteBackExistingOnly; | ||
71 | int mSyncAlgoPrefs; | ||
72 | int mRingSyncAlgoPrefs; | ||
73 | bool mWriteBackFile; | ||
74 | int mWriteBackInFuture; | ||
75 | QString mPhoneDevice; | ||
76 | QString mPhoneConnection; | ||
77 | QString mPhoneModel; | ||
78 | QString mLastSyncedLocalFile; // save! | ||
79 | |||
80 | |||
62 | 81 | ||
63 | public slots: | 82 | public slots: |
64 | void slotSyncMenu( int ); | 83 | void slotSyncMenu( int ); |
65 | 84 | ||
66 | private: | 85 | private: |
67 | // LR ******************************* | 86 | // LR ******************************* |
68 | // sync stuff! | 87 | // sync stuff! |
69 | QString mCurrentSyncDevice; | 88 | QString mCurrentSyncDevice; |
70 | QString mCurrentSyncName; | 89 | QString mCurrentSyncName; |
71 | void quickSyncLocalFile(); | 90 | void quickSyncLocalFile(); |
72 | bool syncWithFile( QString fn , bool quick ); | 91 | bool syncWithFile( QString fn , bool quick ); |
73 | void syncLocalFile(); | 92 | void syncLocalFile(); |
74 | void syncPhone(); | 93 | void syncPhone(); |
75 | void syncSharp(); | 94 | void syncSharp(); |
76 | bool syncExternalApplication(QString); | 95 | bool syncExternalApplication(QString); |
77 | void multiSync( bool askforPrefs ); | 96 | void multiSync( bool askforPrefs ); |
78 | int mCurrentSyncProfile ; | 97 | int mCurrentSyncProfile ; |
79 | void syncRemote( KSyncProfile* prof, bool ask = true); | 98 | void syncRemote( KSyncProfile* prof, bool ask = true); |
80 | void edit_sync_options(); | 99 | void edit_sync_options(); |
81 | int ringSync(); | 100 | int ringSync(); |
82 | QString getPassword( ); | 101 | QString getPassword( ); |
83 | 102 | ||
84 | private slots: | 103 | private slots: |
85 | void confSync(); | 104 | void confSync(); |
86 | // ********************* | 105 | // ********************* |
87 | 106 | ||
88 | private: | 107 | private: |
89 | bool mBlockSaveFlag; | 108 | bool mBlockSaveFlag; |
90 | 109 | ||
91 | 110 | ||
92 | QWidget* mParent; | 111 | QWidget* mParent; |
93 | KSyncInterface* mImplementation; | 112 | KSyncInterface* mImplementation; |
94 | TargetApp mTargetApp; | 113 | TargetApp mTargetApp; |
95 | KPimPrefs* mPrefs; | ||
96 | QPopupMenu* mSyncMenu; | 114 | QPopupMenu* mSyncMenu; |
97 | 115 | ||
98 | QProgressBar* bar; | 116 | QProgressBar* bar; |
99 | 117 | ||
100 | 118 | ||
101 | 119 | ||
102 | 120 | ||
103 | 121 | ||
104 | }; | 122 | }; |
105 | 123 | ||
106 | 124 | ||
107 | class KSyncInterface | 125 | class KSyncInterface |
108 | { | 126 | { |
109 | public: | 127 | public: |
110 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; | 128 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; |
111 | 129 | ||
112 | virtual bool syncExternal(KSyncManager* manager, QString resource) | 130 | virtual bool syncExternal(KSyncManager* manager, QString resource) |
113 | { | 131 | { |
114 | // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. | 132 | // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. |
115 | return false; | 133 | return false; |
116 | } | 134 | } |
117 | 135 | ||
118 | //called by the syncmanager to indicate that the work has to be marked as dirty. | 136 | //called by the syncmanager to indicate that the work has to be marked as dirty. |
119 | virtual void sync_setModified() = 0; | 137 | virtual void sync_setModified() = 0; |
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index 6c1a9c0..76a45f4 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp | |||
@@ -2939,84 +2939,84 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s | |||
2939 | 2939 | ||
2940 | er.clear(); | 2940 | er.clear(); |
2941 | QStringList el = syncLocal->getIDEntryList(); | 2941 | QStringList el = syncLocal->getIDEntryList(); |
2942 | modulo = (el.count()/10)+1; | 2942 | modulo = (el.count()/10)+1; |
2943 | 2943 | ||
2944 | manager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2944 | manager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2945 | incCounter = 0; | 2945 | incCounter = 0; |
2946 | while ( incCounter < el.count()) { | 2946 | while ( incCounter < el.count()) { |
2947 | qApp->processEvents(); | 2947 | qApp->processEvents(); |
2948 | if (manager->isProgressBarCanceled()) | 2948 | if (manager->isProgressBarCanceled()) |
2949 | return e_syncError; | 2949 | return e_syncError; |
2950 | if ( incCounter % modulo == 0 ) | 2950 | if ( incCounter % modulo == 0 ) |
2951 | manager->showProgressBar(incCounter); | 2951 | manager->showProgressBar(incCounter); |
2952 | uid = el[ incCounter ]; | 2952 | uid = el[ incCounter ]; |
2953 | 2953 | ||
2954 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); | 2954 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); |
2955 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); | 2955 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); |
2956 | if ( inRemote == 0 ) { | 2956 | if ( inRemote == 0 ) { |
2957 | if ( inLocal->meta.update < mLastSync && mode != 4 ) { | 2957 | if ( inLocal->meta.update < mLastSync && mode != 4 ) { |
2958 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2958 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2959 | syncLocal->delEntry(catLocal, indexLocal, true); | 2959 | syncLocal->delEntry(catLocal, indexLocal, true); |
2960 | //USsyncLocal->removeAddressee( inLocal ); | 2960 | //USsyncLocal->removeAddressee( inLocal ); |
2961 | ++deletedPasswordsLocal; | 2961 | ++deletedPasswordsLocal; |
2962 | } else { | 2962 | } else { |
2963 | if ( ! PWMPrefs::instance()->mWriteBackExistingOnly ) { | 2963 | if ( ! manager->mWriteBackExistingOnly ) { |
2964 | ++addedPasswordsRemote; | 2964 | ++addedPasswordsRemote; |
2965 | inLocal->meta.update = modifiedSync; | 2965 | inLocal->meta.update = modifiedSync; |
2966 | //USsyncLocal->insertAddressee( inLocal, false ); | 2966 | //USsyncLocal->insertAddressee( inLocal, false ); |
2967 | (*inRemote) = (*inLocal); | 2967 | (*inRemote) = (*inLocal); |
2968 | //USsyncRemote->insertAddressee( inRemote, false ); | 2968 | //USsyncRemote->insertAddressee( inRemote, false ); |
2969 | syncRemote->addEntry("newcategory", inRemote, true, false); | 2969 | syncRemote->addEntry("newcategory", inRemote, true, false); |
2970 | 2970 | ||
2971 | } | 2971 | } |
2972 | } | 2972 | } |
2973 | 2973 | ||
2974 | } | 2974 | } |
2975 | ++incCounter; | 2975 | ++incCounter; |
2976 | } | 2976 | } |
2977 | el.clear(); | 2977 | el.clear(); |
2978 | manager->hideProgressBar(); | 2978 | manager->hideProgressBar(); |
2979 | 2979 | ||
2980 | // Now write the info back into the sync data space of the files | 2980 | // Now write the info back into the sync data space of the files |
2981 | 2981 | ||
2982 | mLastSync = QDateTime::currentDateTime().addSecs( 1 ); | 2982 | mLastSync = QDateTime::currentDateTime().addSecs( 1 ); |
2983 | // get rid of micro seconds | 2983 | // get rid of micro seconds |
2984 | QTime t = mLastSync.time(); | 2984 | QTime t = mLastSync.time(); |
2985 | mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2985 | mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2986 | 2986 | ||
2987 | 2987 | ||
2988 | syncItemLocal->lastSyncDate = mLastSync; | 2988 | syncItemLocal->lastSyncDate = mLastSync; |
2989 | syncItemRemote->lastSyncDate = mLastSync; | 2989 | syncItemRemote->lastSyncDate = mLastSync; |
2990 | 2990 | ||
2991 | // addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2991 | // addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2992 | // addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2992 | // addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2993 | 2993 | ||
2994 | syncRemote->addSyncDataEntry( syncItemRemote, false ); | 2994 | syncRemote->addSyncDataEntry( syncItemRemote, false ); |
2995 | syncLocal->addSyncDataEntry( syncItemLocal, false ); | 2995 | syncLocal->addSyncDataEntry( syncItemLocal, false ); |
2996 | QString mes; | 2996 | QString mes; |
2997 | 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"),addedPasswordsLocal, addedPasswordsRemote, changedLocal, changedRemote, deletedPasswordsLocal, deletedPasswordsRemote ); | 2997 | 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"),addedPasswordsLocal, addedPasswordsRemote, changedLocal, changedRemote, deletedPasswordsLocal, deletedPasswordsRemote ); |
2998 | if ( PWMPrefs::instance()->mShowSyncSummary ) { | 2998 | if ( manager->mShowSyncSummary ) { |
2999 | KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") ); | 2999 | KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") ); |
3000 | } | 3000 | } |
3001 | qDebug( mes ); | 3001 | qDebug( mes ); |
3002 | return e_success; | 3002 | return e_success; |
3003 | } | 3003 | } |
3004 | 3004 | ||
3005 | 3005 | ||
3006 | int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ) | 3006 | int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ) |
3007 | { | 3007 | { |
3008 | // 0 equal | 3008 | // 0 equal |
3009 | // 1 take local | 3009 | // 1 take local |
3010 | // 2 take remote | 3010 | // 2 take remote |
3011 | // 3 cancel | 3011 | // 3 cancel |
3012 | QDateTime localMod = local->meta.update; | 3012 | QDateTime localMod = local->meta.update; |
3013 | QDateTime remoteMod = remote->meta.update; | 3013 | QDateTime remoteMod = remote->meta.update; |
3014 | 3014 | ||
3015 | //US QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3015 | //US QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3016 | 3016 | ||
3017 | if ( localMod == remoteMod ) | 3017 | if ( localMod == remoteMod ) |
3018 | return 0; | 3018 | return 0; |
3019 | 3019 | ||
3020 | qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() ); | 3020 | qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() ); |
3021 | 3021 | ||
3022 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 3022 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
@@ -3118,49 +3118,49 @@ bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode) | |||
3118 | else { | 3118 | else { |
3119 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); | 3119 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); |
3120 | return false; | 3120 | return false; |
3121 | } | 3121 | } |
3122 | } | 3122 | } |
3123 | else if (err != e_success) { | 3123 | else if (err != e_success) { |
3124 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); | 3124 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); |
3125 | return false; | 3125 | return false; |
3126 | } | 3126 | } |
3127 | 3127 | ||
3128 | qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode ); | 3128 | qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode ); |
3129 | 3129 | ||
3130 | 3130 | ||
3131 | //3) unlock remote file first if necessary (ask for password) | 3131 | //3) unlock remote file first if necessary (ask for password) |
3132 | if (pSyncTarget->isDeepLocked()) { | 3132 | if (pSyncTarget->isDeepLocked()) { |
3133 | PwMerror ret = pSyncTarget->deepLock(false); | 3133 | PwMerror ret = pSyncTarget->deepLock(false); |
3134 | if (ret != e_success) | 3134 | if (ret != e_success) |
3135 | return false; | 3135 | return false; |
3136 | } | 3136 | } |
3137 | 3137 | ||
3138 | 3138 | ||
3139 | err = syncronize(manager, this, pSyncTarget, mode ); | 3139 | err = syncronize(manager, this, pSyncTarget, mode ); |
3140 | 3140 | ||
3141 | if (err == e_success) { | 3141 | if (err == e_success) { |
3142 | if ( PWMPrefs::instance()->mWriteBackFile ){ | 3142 | if ( manager->mWriteBackFile ){ |
3143 | qDebug("Saving remote PWManager file"); | 3143 | qDebug("Saving remote PWManager file"); |
3144 | err = pSyncTarget->saveDoc(conf()->confGlobCompression()); | 3144 | err = pSyncTarget->saveDoc(conf()->confGlobCompression()); |
3145 | if (err != e_success) { | 3145 | if (err != e_success) { |
3146 | qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1()); | 3146 | qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1()); |
3147 | return false; | 3147 | return false; |
3148 | } | 3148 | } |
3149 | } | 3149 | } |
3150 | 3150 | ||
3151 | flagDirty(); | 3151 | flagDirty(); |
3152 | return true; | 3152 | return true; |
3153 | } | 3153 | } |
3154 | else { | 3154 | else { |
3155 | return false; | 3155 | return false; |
3156 | } | 3156 | } |
3157 | } | 3157 | } |
3158 | 3158 | ||
3159 | //called by the syncmanager to indicate that the work has to marked as dirty. | 3159 | //called by the syncmanager to indicate that the work has to marked as dirty. |
3160 | void PwMDoc::sync_setModified() | 3160 | void PwMDoc::sync_setModified() |
3161 | { | 3161 | { |
3162 | flagDirty(); | 3162 | flagDirty(); |
3163 | } | 3163 | } |
3164 | 3164 | ||
3165 | //called by the syncmanager to ask if the dirty flag is set. | 3165 | //called by the syncmanager to ask if the dirty flag is set. |
3166 | bool PwMDoc::sync_isModified() | 3166 | bool PwMDoc::sync_isModified() |