summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp6
-rw-r--r--korganizer/calendarview.cpp16
2 files changed, 17 insertions, 5 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index eba74a6..20b107e 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2679,398 +2679,400 @@ void KABCore::requestForDetails(const QString& sourceChannel, const QString& ses
2679 Addressee::List emaillist; 2679 Addressee::List emaillist;
2680 2680
2681 if (!name.isEmpty()) 2681 if (!name.isEmpty())
2682 namelist = mAddressBook->findByName( name ); 2682 namelist = mAddressBook->findByName( name );
2683 2683
2684 if (!email.isEmpty()) 2684 if (!email.isEmpty())
2685 emaillist = mAddressBook->findByEmail( email ); 2685 emaillist = mAddressBook->findByEmail( email );
2686 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2686 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2687 //check if we have a match in Namelist and Emaillist 2687 //check if we have a match in Namelist and Emaillist
2688 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2688 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2689 foundUid = emaillist[0].uid(); 2689 foundUid = emaillist[0].uid();
2690 } 2690 }
2691 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2691 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2692 foundUid = namelist[0].uid(); 2692 foundUid = namelist[0].uid();
2693 else 2693 else
2694 { 2694 {
2695 for (int i = 0; i < namelist.count(); i++) 2695 for (int i = 0; i < namelist.count(); i++)
2696 { 2696 {
2697 for (int j = 0; j < emaillist.count(); j++) 2697 for (int j = 0; j < emaillist.count(); j++)
2698 { 2698 {
2699 if (namelist[i] == emaillist[j]) 2699 if (namelist[i] == emaillist[j])
2700 { 2700 {
2701 foundUid = namelist[i].uid(); 2701 foundUid = namelist[i].uid();
2702 } 2702 }
2703 } 2703 }
2704 } 2704 }
2705 } 2705 }
2706 } 2706 }
2707 else 2707 else
2708 { 2708 {
2709 foundUid = uid; 2709 foundUid = uid;
2710 } 2710 }
2711 2711
2712 if (!foundUid.isEmpty()) 2712 if (!foundUid.isEmpty())
2713 { 2713 {
2714 2714
2715 // raise Ka/Pi if it is in the background 2715 // raise Ka/Pi if it is in the background
2716#ifndef DESKTOP_VERSION 2716#ifndef DESKTOP_VERSION
2717#ifndef KORG_NODCOP 2717#ifndef KORG_NODCOP
2718 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2718 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2719#endif 2719#endif
2720#endif 2720#endif
2721 2721
2722 mMainWindow->showMaximized(); 2722 mMainWindow->showMaximized();
2723 mMainWindow-> raise(); 2723 mMainWindow-> raise();
2724 2724
2725 mViewManager->setSelected( "", false); 2725 mViewManager->setSelected( "", false);
2726 mViewManager->refreshView( "" ); 2726 mViewManager->refreshView( "" );
2727 mViewManager->setSelected( foundUid, true ); 2727 mViewManager->setSelected( foundUid, true );
2728 mViewManager->refreshView( foundUid ); 2728 mViewManager->refreshView( foundUid );
2729 2729
2730 if ( !mMultipleViewsAtOnce ) 2730 if ( !mMultipleViewsAtOnce )
2731 { 2731 {
2732 setDetailsVisible( true ); 2732 setDetailsVisible( true );
2733 mActionDetails->setChecked(true); 2733 mActionDetails->setChecked(true);
2734 } 2734 }
2735 } 2735 }
2736} 2736}
2737void KABCore::storagehowto() 2737void KABCore::storagehowto()
2738{ 2738{
2739 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 2739 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
2740} 2740}
2741void KABCore::whatsnew() 2741void KABCore::whatsnew()
2742{ 2742{
2743 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2743 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2744} 2744}
2745void KABCore::synchowto() 2745void KABCore::synchowto()
2746{ 2746{
2747 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2747 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2748} 2748}
2749void KABCore::kdesynchowto() 2749void KABCore::kdesynchowto()
2750{ 2750{
2751 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2751 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2752} 2752}
2753void KABCore::multisynchowto() 2753void KABCore::multisynchowto()
2754{ 2754{
2755 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2755 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2756} 2756}
2757void KABCore::faq() 2757void KABCore::faq()
2758{ 2758{
2759 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2759 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2760} 2760}
2761 2761
2762#include <libkcal/syncdefines.h> 2762#include <libkcal/syncdefines.h>
2763 2763
2764KABC::Addressee KABCore::getLastSyncAddressee() 2764KABC::Addressee KABCore::getLastSyncAddressee()
2765{ 2765{
2766 Addressee lse; 2766 Addressee lse;
2767 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2767 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2768 2768
2769 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2769 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2770 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2770 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2771 if (lse.isEmpty()) { 2771 if (lse.isEmpty()) {
2772 qDebug("KA: Creating new last-syncAddressee "); 2772 qDebug("KA: Creating new last-syncAddressee ");
2773 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2773 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2774 QString sum = ""; 2774 QString sum = "";
2775 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2775 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2776 sum = "E: "; 2776 sum = "E: ";
2777 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2777 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2778 lse.setRevision( mLastAddressbookSync ); 2778 lse.setRevision( mLastAddressbookSync );
2779 lse.setCategories( i18n("SyncEvent") ); 2779 lse.setCategories( i18n("SyncEvent") );
2780 mAddressBook->insertAddressee( lse ); 2780 mAddressBook->insertAddressee( lse );
2781 } 2781 }
2782 return lse; 2782 return lse;
2783} 2783}
2784int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2784int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2785{ 2785{
2786 2786
2787 //void setZaurusId(int id); 2787 //void setZaurusId(int id);
2788 // int zaurusId() const; 2788 // int zaurusId() const;
2789 // void setZaurusUid(int id); 2789 // void setZaurusUid(int id);
2790 // int zaurusUid() const; 2790 // int zaurusUid() const;
2791 // void setZaurusStat(int id); 2791 // void setZaurusStat(int id);
2792 // int zaurusStat() const; 2792 // int zaurusStat() const;
2793 // 0 equal 2793 // 0 equal
2794 // 1 take local 2794 // 1 take local
2795 // 2 take remote 2795 // 2 take remote
2796 // 3 cancel 2796 // 3 cancel
2797 QDateTime lastSync = mLastAddressbookSync; 2797 QDateTime lastSync = mLastAddressbookSync;
2798 QDateTime localMod = local->revision(); 2798 QDateTime localMod = local->revision();
2799 QDateTime remoteMod = remote->revision(); 2799 QDateTime remoteMod = remote->revision();
2800 2800
2801 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2801 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2802 2802
2803 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2803 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2804 bool remCh, locCh; 2804 bool remCh, locCh;
2805 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2805 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2806 //if ( remCh ) 2806 //if ( remCh )
2807 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2807 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2808 locCh = ( localMod > mLastAddressbookSync ); 2808 locCh = ( localMod > mLastAddressbookSync );
2809 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2809 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2810 if ( !remCh && ! locCh ) { 2810 if ( !remCh && ! locCh ) {
2811 //qDebug("both not changed "); 2811 //qDebug("both not changed ");
2812 lastSync = localMod.addDays(1); 2812 lastSync = localMod.addDays(1);
2813 if ( mode <= SYNC_PREF_ASK ) 2813 if ( mode <= SYNC_PREF_ASK )
2814 return 0; 2814 return 0;
2815 } else { 2815 } else {
2816 if ( locCh ) { 2816 if ( locCh ) {
2817 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2817 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2818 lastSync = localMod.addDays( -1 ); 2818 lastSync = localMod.addDays( -1 );
2819 if ( !remCh ) 2819 if ( !remCh )
2820 remoteMod =( lastSync.addDays( -1 ) ); 2820 remoteMod =( lastSync.addDays( -1 ) );
2821 } else { 2821 } else {
2822 //qDebug(" not loc changed "); 2822 //qDebug(" not loc changed ");
2823 lastSync = localMod.addDays( 1 ); 2823 lastSync = localMod.addDays( 1 );
2824 if ( remCh ) { 2824 if ( remCh ) {
2825 //qDebug("rem changed "); 2825 //qDebug("rem changed ");
2826 remoteMod =( lastSync.addDays( 1 ) ); 2826 remoteMod =( lastSync.addDays( 1 ) );
2827 } 2827 }
2828 2828
2829 } 2829 }
2830 } 2830 }
2831 full = true; 2831 full = true;
2832 if ( mode < SYNC_PREF_ASK ) 2832 if ( mode < SYNC_PREF_ASK )
2833 mode = SYNC_PREF_ASK; 2833 mode = SYNC_PREF_ASK;
2834 } else { 2834 } else {
2835 if ( localMod == remoteMod ) 2835 if ( localMod == remoteMod )
2836 return 0; 2836 return 0;
2837 2837
2838 } 2838 }
2839 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2839 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2840 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2840 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2841 //full = true; //debug only 2841 //full = true; //debug only
2842 if ( full ) { 2842 if ( full ) {
2843 bool equ = ( (*local) == (*remote) ); 2843 bool equ = ( (*local) == (*remote) );
2844 if ( equ ) { 2844 if ( equ ) {
2845 //qDebug("equal "); 2845 //qDebug("equal ");
2846 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2846 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2847 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2847 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2848 } 2848 }
2849 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2849 if ( mode < SYNC_PREF_FORCE_LOCAL )
2850 return 0; 2850 return 0;
2851 2851
2852 }//else //debug only 2852 }//else //debug only
2853 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2853 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2854 } 2854 }
2855 int result; 2855 int result;
2856 bool localIsNew; 2856 bool localIsNew;
2857 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2857 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2858 2858
2859 if ( full && mode < SYNC_PREF_NEWEST ) 2859 if ( full && mode < SYNC_PREF_NEWEST )
2860 mode = SYNC_PREF_ASK; 2860 mode = SYNC_PREF_ASK;
2861 2861
2862 switch( mode ) { 2862 switch( mode ) {
2863 case SYNC_PREF_LOCAL: 2863 case SYNC_PREF_LOCAL:
2864 if ( lastSync > remoteMod ) 2864 if ( lastSync > remoteMod )
2865 return 1; 2865 return 1;
2866 if ( lastSync > localMod ) 2866 if ( lastSync > localMod )
2867 return 2; 2867 return 2;
2868 return 1; 2868 return 1;
2869 break; 2869 break;
2870 case SYNC_PREF_REMOTE: 2870 case SYNC_PREF_REMOTE:
2871 if ( lastSync > remoteMod )
2872 return 1;
2873 if ( lastSync > localMod ) 2871 if ( lastSync > localMod )
2874 return 2; 2872 return 2;
2873 if ( lastSync > remoteMod )
2874 return 1;
2875 return 2; 2875 return 2;
2876 break; 2876 break;
2877 case SYNC_PREF_NEWEST: 2877 case SYNC_PREF_NEWEST:
2878 if ( localMod > remoteMod ) 2878 if ( localMod > remoteMod )
2879 return 1; 2879 return 1;
2880 else 2880 else
2881 return 2; 2881 return 2;
2882 break; 2882 break;
2883 case SYNC_PREF_ASK: 2883 case SYNC_PREF_ASK:
2884 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2884 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2885 if ( lastSync > remoteMod && lastSync > localMod)
2886 return 0;
2885 if ( lastSync > remoteMod ) 2887 if ( lastSync > remoteMod )
2886 return 1; 2888 return 1;
2887 if ( lastSync > localMod ) { 2889 if ( lastSync > localMod ) {
2888 return 2; 2890 return 2;
2889 } 2891 }
2890 localIsNew = localMod >= remoteMod; 2892 localIsNew = localMod >= remoteMod;
2891 //qDebug("conflict! ************************************** "); 2893 //qDebug("conflict! ************************************** ");
2892 { 2894 {
2893 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2895 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2894 result = acd.executeD(localIsNew); 2896 result = acd.executeD(localIsNew);
2895 return result; 2897 return result;
2896 } 2898 }
2897 break; 2899 break;
2898 case SYNC_PREF_FORCE_LOCAL: 2900 case SYNC_PREF_FORCE_LOCAL:
2899 return 1; 2901 return 1;
2900 break; 2902 break;
2901 case SYNC_PREF_FORCE_REMOTE: 2903 case SYNC_PREF_FORCE_REMOTE:
2902 return 2; 2904 return 2;
2903 break; 2905 break;
2904 2906
2905 default: 2907 default:
2906 // SYNC_PREF_TAKE_BOTH not implemented 2908 // SYNC_PREF_TAKE_BOTH not implemented
2907 break; 2909 break;
2908 } 2910 }
2909 return 0; 2911 return 0;
2910} 2912}
2911 2913
2912 2914
2913bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2915bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2914{ 2916{
2915 bool syncOK = true; 2917 bool syncOK = true;
2916 int addedAddressee = 0; 2918 int addedAddressee = 0;
2917 int addedAddresseeR = 0; 2919 int addedAddresseeR = 0;
2918 int deletedAddresseeR = 0; 2920 int deletedAddresseeR = 0;
2919 int deletedAddresseeL = 0; 2921 int deletedAddresseeL = 0;
2920 int changedLocal = 0; 2922 int changedLocal = 0;
2921 int changedRemote = 0; 2923 int changedRemote = 0;
2922 int filteredIN = 0; 2924 int filteredIN = 0;
2923 int filteredOUT = 0; 2925 int filteredOUT = 0;
2924 2926
2925 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2927 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2926 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2928 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2927 2929
2928 //QPtrList<Addressee> el = local->rawAddressees(); 2930 //QPtrList<Addressee> el = local->rawAddressees();
2929 Addressee addresseeR; 2931 Addressee addresseeR;
2930 QString uid; 2932 QString uid;
2931 int take; 2933 int take;
2932 Addressee addresseeL; 2934 Addressee addresseeL;
2933 Addressee addresseeRSync; 2935 Addressee addresseeRSync;
2934 Addressee addresseeLSync; 2936 Addressee addresseeLSync;
2935 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2937 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2936 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2938 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2937 bool fullDateRange = false; 2939 bool fullDateRange = false;
2938 local->resetTempSyncStat(); 2940 local->resetTempSyncStat();
2939 mLastAddressbookSync = QDateTime::currentDateTime(); 2941 mLastAddressbookSync = QDateTime::currentDateTime();
2940 if ( syncManager->syncWithDesktop() ) { 2942 if ( syncManager->syncWithDesktop() ) {
2941 // remote->removeSyncInfo( QString());//remove all info 2943 // remote->removeSyncInfo( QString());//remove all info
2942 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2944 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2943 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2945 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2944 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2946 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2945 } else { 2947 } else {
2946 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); 2948 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime ");
2947 } 2949 }
2948 } 2950 }
2949 QDateTime modifiedCalendar = mLastAddressbookSync; 2951 QDateTime modifiedCalendar = mLastAddressbookSync;
2950 addresseeLSync = getLastSyncAddressee(); 2952 addresseeLSync = getLastSyncAddressee();
2951 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2953 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1());
2952 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2954 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2953 if ( !addresseeR.isEmpty() ) { 2955 if ( !addresseeR.isEmpty() ) {
2954 addresseeRSync = addresseeR; 2956 addresseeRSync = addresseeR;
2955 remote->removeAddressee(addresseeR ); 2957 remote->removeAddressee(addresseeR );
2956 2958
2957 } else { 2959 } else {
2958 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2960 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2959 addresseeRSync = addresseeLSync ; 2961 addresseeRSync = addresseeLSync ;
2960 } else { 2962 } else {
2961 //qDebug("FULLDATE 1"); 2963 //qDebug("FULLDATE 1");
2962 fullDateRange = true; 2964 fullDateRange = true;
2963 Addressee newAdd; 2965 Addressee newAdd;
2964 addresseeRSync = newAdd; 2966 addresseeRSync = newAdd;
2965 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2967 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2966 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2968 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2967 addresseeRSync.setRevision( mLastAddressbookSync ); 2969 addresseeRSync.setRevision( mLastAddressbookSync );
2968 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2970 addresseeRSync.setCategories( i18n("SyncAddressee") );
2969 } 2971 }
2970 } 2972 }
2971 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2973 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2972 // qDebug("FULLDATE 2"); 2974 // qDebug("FULLDATE 2");
2973 fullDateRange = true; 2975 fullDateRange = true;
2974 } 2976 }
2975 if ( ! fullDateRange ) { 2977 if ( ! fullDateRange ) {
2976 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2978 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2977 2979
2978 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2980 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2979 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2981 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2980 fullDateRange = true; 2982 fullDateRange = true;
2981 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2983 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2982 } 2984 }
2983 } 2985 }
2984 // fullDateRange = true; // debug only! 2986 // fullDateRange = true; // debug only!
2985 if ( fullDateRange ) 2987 if ( fullDateRange )
2986 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2988 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2987 else 2989 else
2988 mLastAddressbookSync = addresseeLSync.revision(); 2990 mLastAddressbookSync = addresseeLSync.revision();
2989 // for resyncing if own file has changed 2991 // for resyncing if own file has changed
2990 // PENDING fixme later when implemented 2992 // PENDING fixme later when implemented
2991#if 0 2993#if 0
2992 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2994 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2993 mLastAddressbookSync = loadedFileVersion; 2995 mLastAddressbookSync = loadedFileVersion;
2994 qDebug("setting mLastAddressbookSync "); 2996 qDebug("setting mLastAddressbookSync ");
2995 } 2997 }
2996#endif 2998#endif
2997 2999
2998 3000
2999 // ********** setting filters **************** 3001 // ********** setting filters ****************
3000 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 3002 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
3001 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 3003 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
3002 3004
3003 //qDebug("*************************** "); 3005 //qDebug("*************************** ");
3004 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 3006 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
3005 QStringList er = remote->uidList(); 3007 QStringList er = remote->uidList();
3006 Addressee inR ;//= er.first(); 3008 Addressee inR ;//= er.first();
3007 Addressee inL; 3009 Addressee inL;
3008 3010
3009 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 3011 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
3010 3012
3011 int modulo = (er.count()/10)+1; 3013 int modulo = (er.count()/10)+1;
3012 int incCounter = 0; 3014 int incCounter = 0;
3013 while ( incCounter < er.count()) { 3015 while ( incCounter < er.count()) {
3014 if (syncManager->isProgressBarCanceled()) 3016 if (syncManager->isProgressBarCanceled())
3015 return false; 3017 return false;
3016 if ( incCounter % modulo == 0 ) 3018 if ( incCounter % modulo == 0 )
3017 syncManager->showProgressBar(incCounter); 3019 syncManager->showProgressBar(incCounter);
3018 3020
3019 uid = er[ incCounter ]; 3021 uid = er[ incCounter ];
3020 bool skipIncidence = false; 3022 bool skipIncidence = false;
3021 if ( uid.left(19) == QString("last-syncAddressee-") ) 3023 if ( uid.left(19) == QString("last-syncAddressee-") )
3022 skipIncidence = true; 3024 skipIncidence = true;
3023 QString idS,OidS; 3025 QString idS,OidS;
3024 qApp->processEvents(); 3026 qApp->processEvents();
3025 if ( !skipIncidence ) { 3027 if ( !skipIncidence ) {
3026 inL = local->findByUid( uid ); 3028 inL = local->findByUid( uid );
3027 inR = remote->findByUid( uid ); 3029 inR = remote->findByUid( uid );
3028 //inL.setResource( 0 ); 3030 //inL.setResource( 0 );
3029 //inR.setResource( 0 ); 3031 //inR.setResource( 0 );
3030 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 3032 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
3031 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3033 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3032 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 3034 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
3033 //qDebug("take %d %s ", take, inL.summary().latin1()); 3035 //qDebug("take %d %s ", take, inL.summary().latin1());
3034 if ( take == 3 ) 3036 if ( take == 3 )
3035 return false; 3037 return false;
3036 if ( take == 1 ) {// take local ********************** 3038 if ( take == 1 ) {// take local **********************
3037 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3039 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3038 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3040 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3039 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3041 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3040 local->insertAddressee( inL, false ); 3042 local->insertAddressee( inL, false );
3041 idS = inR.externalUID(); 3043 idS = inR.externalUID();
3042 OidS = inR.originalExternalUID(); 3044 OidS = inR.originalExternalUID();
3043 } 3045 }
3044 else 3046 else
3045 idS = inR.IDStr(); 3047 idS = inR.IDStr();
3046 remote->removeAddressee( inR ); 3048 remote->removeAddressee( inR );
3047 inR = inL; 3049 inR = inL;
3048 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 3050 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
3049 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3051 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3050 inR.setOriginalExternalUID( OidS ); 3052 inR.setOriginalExternalUID( OidS );
3051 inR.setExternalUID( idS ); 3053 inR.setExternalUID( idS );
3052 if ( syncManager->syncWithDesktop() ) { 3054 if ( syncManager->syncWithDesktop() ) {
3053 inR.setIDStr("changed" ); 3055 inR.setIDStr("changed" );
3054 } 3056 }
3055 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 3057 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
3056 } else { 3058 } else {
3057 inR.setIDStr( idS ); 3059 inR.setIDStr( idS );
3058 } 3060 }
3059 inR.setResource( 0 ); 3061 inR.setResource( 0 );
3060 remote->insertAddressee( inR , false); 3062 remote->insertAddressee( inR , false);
3061 ++changedRemote; 3063 ++changedRemote;
3062 } else { // take == 2 take remote ********************** 3064 } else { // take == 2 take remote **********************
3063 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3065 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3064 if ( inR.revision().date().year() < 2004 ) 3066 if ( inR.revision().date().year() < 2004 )
3065 inR.setRevision( modifiedCalendar ); 3067 inR.setRevision( modifiedCalendar );
3066 } 3068 }
3067 idS = inL.IDStr(); 3069 idS = inL.IDStr();
3068 local->removeAddressee( inL ); 3070 local->removeAddressee( inL );
3069 inL = inR; 3071 inL = inR;
3070 inL.setIDStr( idS ); 3072 inL.setIDStr( idS );
3071 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3073 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3072 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3074 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3073 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3075 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3074 } 3076 }
3075 inL.setResource( 0 ); 3077 inL.setResource( 0 );
3076 local->insertAddressee( inL , false ); 3078 local->insertAddressee( inL , false );
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 76cce26..00ef145 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -627,410 +627,420 @@ void CalendarView::computeAlarm( QString msg )
627 } 627 }
628 if ( mess.left( 9 ) == "cal_alarm") { 628 if ( mess.left( 9 ) == "cal_alarm") {
629 mAlarmMessage = mess.mid( 9 ) ; 629 mAlarmMessage = mess.mid( 9 ) ;
630 } 630 }
631 631
632 startAlarm( mAlarmMessage, filename ); 632 startAlarm( mAlarmMessage, filename );
633 633
634 634
635} 635}
636 636
637void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 637void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
638{ 638{
639 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 639 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
640 640
641 mSuspendAlarmNotification = noti; 641 mSuspendAlarmNotification = noti;
642 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 642 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
643 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 643 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
644 mSuspendTimer->start( ms , true ); 644 mSuspendTimer->start( ms , true );
645 645
646} 646}
647 647
648void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 648void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
649{ 649{
650 mNextAlarmDateTime = qdt; 650 mNextAlarmDateTime = qdt;
651 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 651 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
652 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 652 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
653#ifndef DESKTOP_VERSION 653#ifndef DESKTOP_VERSION
654 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 654 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
655#endif 655#endif
656 return; 656 return;
657 } 657 }
658 int maxSec; 658 int maxSec;
659 //maxSec = 5; //testing only 659 //maxSec = 5; //testing only
660 maxSec = 86400+3600; // one day+1hour 660 maxSec = 86400+3600; // one day+1hour
661 mAlarmNotification = noti; 661 mAlarmNotification = noti;
662 int sec = QDateTime::currentDateTime().secsTo( qdt ); 662 int sec = QDateTime::currentDateTime().secsTo( qdt );
663 if ( sec > maxSec ) { 663 if ( sec > maxSec ) {
664 mRecheckAlarmTimer->start( maxSec * 1000 ); 664 mRecheckAlarmTimer->start( maxSec * 1000 );
665 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 665 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
666 return; 666 return;
667 } else { 667 } else {
668 mRecheckAlarmTimer->stop(); 668 mRecheckAlarmTimer->stop();
669 } 669 }
670 //qDebug("Alarm timer started with secs: %d ", sec); 670 //qDebug("Alarm timer started with secs: %d ", sec);
671 mAlarmTimer->start( sec *1000 , true ); 671 mAlarmTimer->start( sec *1000 , true );
672 672
673} 673}
674// called by mRecheckAlarmTimer to get next alarm 674// called by mRecheckAlarmTimer to get next alarm
675// we need this, because a QTimer has only a max range of 25 days 675// we need this, because a QTimer has only a max range of 25 days
676void CalendarView::recheckTimerAlarm() 676void CalendarView::recheckTimerAlarm()
677{ 677{
678 mAlarmTimer->stop(); 678 mAlarmTimer->stop();
679 mRecheckAlarmTimer->stop(); 679 mRecheckAlarmTimer->stop();
680 mCalendar->checkAlarmForIncidence( 0, true ); 680 mCalendar->checkAlarmForIncidence( 0, true );
681} 681}
682void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 682void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
683{ 683{
684 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 684 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
685 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 685 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
686#ifndef DESKTOP_VERSION 686#ifndef DESKTOP_VERSION
687 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 687 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
688#endif 688#endif
689 return; 689 return;
690 } 690 }
691 mAlarmTimer->stop(); 691 mAlarmTimer->stop();
692} 692}
693void CalendarView::selectWeekNum ( int num ) 693void CalendarView::selectWeekNum ( int num )
694{ 694{
695 dateNavigator()->blockSignals( true ); 695 dateNavigator()->blockSignals( true );
696 dateNavigator()->selectWeek( num ); 696 dateNavigator()->selectWeek( num );
697 dateNavigator()->blockSignals( false ); 697 dateNavigator()->blockSignals( false );
698 mViewManager->showWeekView(); 698 mViewManager->showWeekView();
699} 699}
700KOViewManager *CalendarView::viewManager() 700KOViewManager *CalendarView::viewManager()
701{ 701{
702 return mViewManager; 702 return mViewManager;
703} 703}
704 704
705KODialogManager *CalendarView::dialogManager() 705KODialogManager *CalendarView::dialogManager()
706{ 706{
707 return mDialogManager; 707 return mDialogManager;
708} 708}
709 709
710QDate CalendarView::startDate() 710QDate CalendarView::startDate()
711{ 711{
712 DateList dates = mNavigator->selectedDates(); 712 DateList dates = mNavigator->selectedDates();
713 713
714 return dates.first(); 714 return dates.first();
715} 715}
716 716
717QDate CalendarView::endDate() 717QDate CalendarView::endDate()
718{ 718{
719 DateList dates = mNavigator->selectedDates(); 719 DateList dates = mNavigator->selectedDates();
720 720
721 return dates.last(); 721 return dates.last();
722} 722}
723 723
724 724
725void CalendarView::createPrinter() 725void CalendarView::createPrinter()
726{ 726{
727#ifndef KORG_NOPRINTER 727#ifndef KORG_NOPRINTER
728 if (!mCalPrinter) { 728 if (!mCalPrinter) {
729 mCalPrinter = new CalPrinter(this, mCalendar); 729 mCalPrinter = new CalPrinter(this, mCalendar);
730 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 730 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
731 } 731 }
732#endif 732#endif
733} 733}
734 734
735 735
736//KOPrefs::instance()->mWriteBackFile 736//KOPrefs::instance()->mWriteBackFile
737//KOPrefs::instance()->mWriteBackExistingOnly 737//KOPrefs::instance()->mWriteBackExistingOnly
738 738
739// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 739// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
740// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 740// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
741// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 741// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
742// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 742// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
743// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 743// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
744// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 744// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
745 745
746int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 746int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
747{ 747{
748 748
749 // 0 equal 749 // 0 equal
750 // 1 take local 750 // 1 take local
751 // 2 take remote 751 // 2 take remote
752 // 3 cancel 752 // 3 cancel
753 QDateTime lastSync = mLastCalendarSync; 753 QDateTime lastSync = mLastCalendarSync;
754 QDateTime localMod = local->lastModified(); 754 QDateTime localMod = local->lastModified();
755 QDateTime remoteMod = remote->lastModified(); 755 QDateTime remoteMod = remote->lastModified();
756 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 756 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
757 bool remCh, locCh; 757 bool remCh, locCh;
758 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 758 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
759 //if ( remCh ) 759 //if ( remCh )
760 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 760 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
761 locCh = ( localMod > mLastCalendarSync ); 761 locCh = ( localMod > mLastCalendarSync );
762 if ( !remCh && ! locCh ) { 762 if ( !remCh && ! locCh ) {
763 //qDebug("both not changed "); 763 //qDebug("both not changed ");
764 lastSync = localMod.addDays(1); 764 lastSync = localMod.addDays(1);
765 if ( mode <= SYNC_PREF_ASK ) 765 if ( mode <= SYNC_PREF_ASK )
766 return 0; 766 return 0;
767 } else { 767 } else {
768 if ( locCh ) { 768 if ( locCh ) {
769 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 769 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
770 lastSync = localMod.addDays( -1 ); 770 lastSync = localMod.addDays( -1 );
771 if ( !remCh ) 771 if ( !remCh )
772 remoteMod = ( lastSync.addDays( -1 ) ); 772 remoteMod = ( lastSync.addDays( -1 ) );
773 } else { 773 } else {
774 //qDebug(" not loc changed "); 774 //qDebug(" not loc changed ");
775 lastSync = localMod.addDays( 1 ); 775 lastSync = localMod.addDays( 1 );
776 if ( remCh ) 776 if ( remCh )
777 remoteMod =( lastSync.addDays( 1 ) ); 777 remoteMod =( lastSync.addDays( 1 ) );
778 778
779 } 779 }
780 } 780 }
781 full = true; 781 full = true;
782 if ( mode < SYNC_PREF_ASK ) 782 if ( mode < SYNC_PREF_ASK )
783 mode = SYNC_PREF_ASK; 783 mode = SYNC_PREF_ASK;
784 } else { 784 } else {
785 if ( localMod == remoteMod ) 785 if ( localMod == remoteMod )
786 // if ( local->revision() == remote->revision() ) 786 // if ( local->revision() == remote->revision() )
787 return 0; 787 return 0;
788 788
789 } 789 }
790 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 790 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
791 791
792 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 792 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
793 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 793 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
794 //full = true; //debug only 794 //full = true; //debug only
795 if ( full ) { 795 if ( full ) {
796 bool equ = false; 796 bool equ = false;
797 if ( local->type() == "Event" ) { 797 if ( local->type() == "Event" ) {
798 equ = (*((Event*) local) == *((Event*) remote)); 798 equ = (*((Event*) local) == *((Event*) remote));
799 } 799 }
800 else if ( local->type() =="Todo" ) 800 else if ( local->type() =="Todo" )
801 equ = (*((Todo*) local) == (*(Todo*) remote)); 801 equ = (*((Todo*) local) == (*(Todo*) remote));
802 else if ( local->type() =="Journal" ) 802 else if ( local->type() =="Journal" )
803 equ = (*((Journal*) local) == *((Journal*) remote)); 803 equ = (*((Journal*) local) == *((Journal*) remote));
804 if ( equ ) { 804 if ( equ ) {
805 //qDebug("equal "); 805 //qDebug("equal ");
806 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 806 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
807 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 807 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
808 } 808 }
809 if ( mode < SYNC_PREF_FORCE_LOCAL ) 809 if ( mode < SYNC_PREF_FORCE_LOCAL )
810 return 0; 810 return 0;
811 811
812 }//else //debug only 812 }//else //debug only
813 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 813 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
814 } 814 }
815 int result; 815 int result;
816 bool localIsNew; 816 bool localIsNew;
817 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 817 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
818 818
819
820 // ************************************************
821 // ************************************************
822 // ************************************************
823 // We may have that lastSync > remoteMod AND lastSync > localMod
824 // BUT remoteMod != localMod
825
826
819 if ( full && mode < SYNC_PREF_NEWEST ) 827 if ( full && mode < SYNC_PREF_NEWEST )
820 mode = SYNC_PREF_ASK; 828 mode = SYNC_PREF_ASK;
821 829
822 switch( mode ) { 830 switch( mode ) {
823 case SYNC_PREF_LOCAL: 831 case SYNC_PREF_LOCAL:
824 if ( lastSync > remoteMod ) 832 if ( lastSync > remoteMod )
825 return 1; 833 return 1;
826 if ( lastSync > localMod ) 834 if ( lastSync > localMod )
827 return 2; 835 return 2;
828 return 1; 836 return 1;
829 break; 837 break;
830 case SYNC_PREF_REMOTE: 838 case SYNC_PREF_REMOTE:
831 if ( lastSync > remoteMod )
832 return 1;
833 if ( lastSync > localMod ) 839 if ( lastSync > localMod )
834 return 2; 840 return 2;
841 if ( lastSync > remoteMod )
842 return 1;
835 return 2; 843 return 2;
836 break; 844 break;
837 case SYNC_PREF_NEWEST: 845 case SYNC_PREF_NEWEST:
838 if ( localMod > remoteMod ) 846 if ( localMod >= remoteMod )
839 return 1; 847 return 1;
840 else 848 else
841 return 2; 849 return 2;
842 break; 850 break;
843 case SYNC_PREF_ASK: 851 case SYNC_PREF_ASK:
844 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 852 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
853 if ( lastSync > remoteMod && lastSync > localMod)
854 return 0;
845 if ( lastSync > remoteMod ) 855 if ( lastSync > remoteMod )
846 return 1; 856 return 1;
847 if ( lastSync > localMod ) 857 if ( lastSync > localMod )
848 return 2; 858 return 2;
849 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 859 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
850 localIsNew = localMod >= remoteMod; 860 localIsNew = localMod >= remoteMod;
851 if ( localIsNew ) 861 if ( localIsNew )
852 getEventViewerDialog()->setColorMode( 1 ); 862 getEventViewerDialog()->setColorMode( 1 );
853 else 863 else
854 getEventViewerDialog()->setColorMode( 2 ); 864 getEventViewerDialog()->setColorMode( 2 );
855 getEventViewerDialog()->setIncidence(local); 865 getEventViewerDialog()->setIncidence(local);
856 if ( localIsNew ) 866 if ( localIsNew )
857 getEventViewerDialog()->setColorMode( 2 ); 867 getEventViewerDialog()->setColorMode( 2 );
858 else 868 else
859 getEventViewerDialog()->setColorMode( 1 ); 869 getEventViewerDialog()->setColorMode( 1 );
860 getEventViewerDialog()->addIncidence(remote); 870 getEventViewerDialog()->addIncidence(remote);
861 getEventViewerDialog()->setColorMode( 0 ); 871 getEventViewerDialog()->setColorMode( 0 );
862 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 872 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
863 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 873 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
864 getEventViewerDialog()->showMe(); 874 getEventViewerDialog()->showMe();
865 result = getEventViewerDialog()->executeS( localIsNew ); 875 result = getEventViewerDialog()->executeS( localIsNew );
866 return result; 876 return result;
867 877
868 break; 878 break;
869 case SYNC_PREF_FORCE_LOCAL: 879 case SYNC_PREF_FORCE_LOCAL:
870 return 1; 880 return 1;
871 break; 881 break;
872 case SYNC_PREF_FORCE_REMOTE: 882 case SYNC_PREF_FORCE_REMOTE:
873 return 2; 883 return 2;
874 break; 884 break;
875 885
876 default: 886 default:
877 // SYNC_PREF_TAKE_BOTH not implemented 887 // SYNC_PREF_TAKE_BOTH not implemented
878 break; 888 break;
879 } 889 }
880 return 0; 890 return 0;
881} 891}
882Event* CalendarView::getLastSyncEvent() 892Event* CalendarView::getLastSyncEvent()
883{ 893{
884 Event* lse; 894 Event* lse;
885 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 895 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
886 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 896 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
887 if (!lse) { 897 if (!lse) {
888 lse = new Event(); 898 lse = new Event();
889 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 899 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
890 QString sum = ""; 900 QString sum = "";
891 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 901 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
892 sum = "E: "; 902 sum = "E: ";
893 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 903 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
894 lse->setDtStart( mLastCalendarSync ); 904 lse->setDtStart( mLastCalendarSync );
895 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 905 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
896 lse->setCategories( i18n("SyncEvent") ); 906 lse->setCategories( i18n("SyncEvent") );
897 lse->setReadOnly( true ); 907 lse->setReadOnly( true );
898 mCalendar->addEvent( lse ); 908 mCalendar->addEvent( lse );
899 } 909 }
900 910
901 return lse; 911 return lse;
902 912
903} 913}
904 914
905// we check, if the to delete event has a id for a profile 915// we check, if the to delete event has a id for a profile
906// if yes, we set this id in the profile to delete 916// if yes, we set this id in the profile to delete
907void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 917void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
908{ 918{
909 if ( lastSync.count() == 0 ) { 919 if ( lastSync.count() == 0 ) {
910 //qDebug(" lastSync.count() == 0"); 920 //qDebug(" lastSync.count() == 0");
911 return; 921 return;
912 } 922 }
913 if ( toDelete->type() == "Journal" ) 923 if ( toDelete->type() == "Journal" )
914 return; 924 return;
915 925
916 Event* eve = lastSync.first(); 926 Event* eve = lastSync.first();
917 927
918 while ( eve ) { 928 while ( eve ) {
919 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 929 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
920 if ( !id.isEmpty() ) { 930 if ( !id.isEmpty() ) {
921 QString des = eve->description(); 931 QString des = eve->description();
922 QString pref = "e"; 932 QString pref = "e";
923 if ( toDelete->type() == "Todo" ) 933 if ( toDelete->type() == "Todo" )
924 pref = "t"; 934 pref = "t";
925 des += pref+ id + ","; 935 des += pref+ id + ",";
926 eve->setReadOnly( false ); 936 eve->setReadOnly( false );
927 eve->setDescription( des ); 937 eve->setDescription( des );
928 //qDebug("setdes %s ", des.latin1()); 938 //qDebug("setdes %s ", des.latin1());
929 eve->setReadOnly( true ); 939 eve->setReadOnly( true );
930 } 940 }
931 eve = lastSync.next(); 941 eve = lastSync.next();
932 } 942 }
933 943
934} 944}
935void CalendarView::checkExternalId( Incidence * inc ) 945void CalendarView::checkExternalId( Incidence * inc )
936{ 946{
937 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 947 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
938 checkExternSyncEvent( lastSync, inc ); 948 checkExternSyncEvent( lastSync, inc );
939 949
940} 950}
941bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 951bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
942{ 952{
943 bool syncOK = true; 953 bool syncOK = true;
944 int addedEvent = 0; 954 int addedEvent = 0;
945 int addedEventR = 0; 955 int addedEventR = 0;
946 int deletedEventR = 0; 956 int deletedEventR = 0;
947 int deletedEventL = 0; 957 int deletedEventL = 0;
948 int changedLocal = 0; 958 int changedLocal = 0;
949 int changedRemote = 0; 959 int changedRemote = 0;
950 int filteredIN = 0; 960 int filteredIN = 0;
951 int filteredOUT = 0; 961 int filteredOUT = 0;
952 //QPtrList<Event> el = local->rawEvents(); 962 //QPtrList<Event> el = local->rawEvents();
953 Event* eventR; 963 Event* eventR;
954 QString uid; 964 QString uid;
955 int take; 965 int take;
956 Event* eventL; 966 Event* eventL;
957 Event* eventRSync; 967 Event* eventRSync;
958 Event* eventLSync; 968 Event* eventLSync;
959 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 969 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
960 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 970 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
961 bool fullDateRange = false; 971 bool fullDateRange = false;
962 local->resetTempSyncStat(); 972 local->resetTempSyncStat();
963 mLastCalendarSync = QDateTime::currentDateTime(); 973 mLastCalendarSync = QDateTime::currentDateTime();
964 if ( mSyncManager->syncWithDesktop() ) { 974 if ( mSyncManager->syncWithDesktop() ) {
965 remote->resetPilotStat(1); 975 remote->resetPilotStat(1);
966 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 976 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
967 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 977 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
968 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 978 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
969 } else { 979 } else {
970 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 980 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
971 } 981 }
972 } 982 }
973 QDateTime modifiedCalendar = mLastCalendarSync; 983 QDateTime modifiedCalendar = mLastCalendarSync;
974 eventLSync = getLastSyncEvent(); 984 eventLSync = getLastSyncEvent();
975 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 985 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
976 if ( eventR ) { 986 if ( eventR ) {
977 eventRSync = (Event*) eventR->clone(); 987 eventRSync = (Event*) eventR->clone();
978 remote->deleteEvent(eventR ); 988 remote->deleteEvent(eventR );
979 989
980 } else { 990 } else {
981 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 991 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
982 eventRSync = (Event*)eventLSync->clone(); 992 eventRSync = (Event*)eventLSync->clone();
983 } else { 993 } else {
984 fullDateRange = true; 994 fullDateRange = true;
985 eventRSync = new Event(); 995 eventRSync = new Event();
986 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 996 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
987 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 997 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
988 eventRSync->setDtStart( mLastCalendarSync ); 998 eventRSync->setDtStart( mLastCalendarSync );
989 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 999 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
990 eventRSync->setCategories( i18n("SyncEvent") ); 1000 eventRSync->setCategories( i18n("SyncEvent") );
991 } 1001 }
992 } 1002 }
993 if ( eventLSync->dtStart() == mLastCalendarSync ) 1003 if ( eventLSync->dtStart() == mLastCalendarSync )
994 fullDateRange = true; 1004 fullDateRange = true;
995 1005
996 if ( ! fullDateRange ) { 1006 if ( ! fullDateRange ) {
997 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1007 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
998 1008
999 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1009 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1000 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1010 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1001 fullDateRange = true; 1011 fullDateRange = true;
1002 } 1012 }
1003 } 1013 }
1004 if ( mSyncManager->syncWithDesktop() ) { 1014 if ( mSyncManager->syncWithDesktop() ) {
1005 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1015 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1006 } 1016 }
1007 if ( fullDateRange ) 1017 if ( fullDateRange )
1008 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1018 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1009 else 1019 else
1010 mLastCalendarSync = eventLSync->dtStart(); 1020 mLastCalendarSync = eventLSync->dtStart();
1011 // for resyncing if own file has changed 1021 // for resyncing if own file has changed
1012 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1022 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1013 mLastCalendarSync = loadedFileVersion; 1023 mLastCalendarSync = loadedFileVersion;
1014 //qDebug("setting mLastCalendarSync "); 1024 //qDebug("setting mLastCalendarSync ");
1015 } 1025 }
1016 //qDebug("*************************** "); 1026 //qDebug("*************************** ");
1017 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1027 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1018 QPtrList<Incidence> er = remote->rawIncidences(); 1028 QPtrList<Incidence> er = remote->rawIncidences();
1019 Incidence* inR = er.first(); 1029 Incidence* inR = er.first();
1020 Incidence* inL; 1030 Incidence* inL;
1021 QProgressBar bar( er.count(),0 ); 1031 QProgressBar bar( er.count(),0 );
1022 bar.setCaption (i18n("Syncing - close to abort!") ); 1032 bar.setCaption (i18n("Syncing - close to abort!") );
1023 1033
1024 // ************** setting up filter ************* 1034 // ************** setting up filter *************
1025 CalFilter *filterIN = 0; 1035 CalFilter *filterIN = 0;
1026 CalFilter *filterOUT = 0; 1036 CalFilter *filterOUT = 0;
1027 CalFilter *filter = mFilters.first(); 1037 CalFilter *filter = mFilters.first();
1028 while(filter) { 1038 while(filter) {
1029 if ( filter->name() == mSyncManager->mFilterInCal ) 1039 if ( filter->name() == mSyncManager->mFilterInCal )
1030 filterIN = filter; 1040 filterIN = filter;
1031 if ( filter->name() == mSyncManager->mFilterOutCal ) 1041 if ( filter->name() == mSyncManager->mFilterOutCal )
1032 filterOUT = filter; 1042 filterOUT = filter;
1033 filter = mFilters.next(); 1043 filter = mFilters.next();
1034 } 1044 }
1035 int w = 300; 1045 int w = 300;
1036 if ( QApplication::desktop()->width() < 320 ) 1046 if ( QApplication::desktop()->width() < 320 )