summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2004-10-07 12:19:25 (UTC)
committer zautrix <zautrix>2004-10-07 12:19:25 (UTC)
commit826dc960353e47a60aba13916189c45ef3392c1e (patch) (unidiff)
tree52ef4058d7a1fa8d77e678391ed9165009634182 /kaddressbook
parent43c82cc5393522d2c34f34a4339cb6a1d1c6c555 (diff)
downloadkdepimpi-826dc960353e47a60aba13916189c45ef3392c1e.zip
kdepimpi-826dc960353e47a60aba13916189c45ef3392c1e.tar.gz
kdepimpi-826dc960353e47a60aba13916189c45ef3392c1e.tar.bz2
sync fixes
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index fa80f5c..12502b0 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2669,219 +2669,219 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2669 if ( uid.left(19) == QString("last-syncAddressee-") ) 2669 if ( uid.left(19) == QString("last-syncAddressee-") )
2670 skipIncidence = true; 2670 skipIncidence = true;
2671 if ( !skipIncidence ) { 2671 if ( !skipIncidence ) {
2672 inL = local->findByUid( uid ); 2672 inL = local->findByUid( uid );
2673 inR = remote->findByUid( uid ); 2673 inR = remote->findByUid( uid );
2674 if ( inR.isEmpty() ) { 2674 if ( inR.isEmpty() ) {
2675 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2675 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2676 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2676 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2677 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2677 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2678 local->removeAddressee( inL ); 2678 local->removeAddressee( inL );
2679 ++deletedAddresseeL; 2679 ++deletedAddresseeL;
2680 } else { 2680 } else {
2681 if ( ! syncManager->mWriteBackExistingOnly ) { 2681 if ( ! syncManager->mWriteBackExistingOnly ) {
2682 inL.removeID(mCurrentSyncDevice ); 2682 inL.removeID(mCurrentSyncDevice );
2683 ++addedAddresseeR; 2683 ++addedAddresseeR;
2684 inL.setRevision( modifiedCalendar ); 2684 inL.setRevision( modifiedCalendar );
2685 local->insertAddressee( inL, false ); 2685 local->insertAddressee( inL, false );
2686 inR = inL; 2686 inR = inL;
2687 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2687 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2688 inR.setResource( 0 ); 2688 inR.setResource( 0 );
2689 remote->insertAddressee( inR, false ); 2689 remote->insertAddressee( inR, false );
2690 } 2690 }
2691 } 2691 }
2692 } else { 2692 } else {
2693 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2693 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2694 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2694 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2695 local->removeAddressee( inL ); 2695 local->removeAddressee( inL );
2696 ++deletedAddresseeL; 2696 ++deletedAddresseeL;
2697 } else { 2697 } else {
2698 if ( ! syncManager->mWriteBackExistingOnly ) { 2698 if ( ! syncManager->mWriteBackExistingOnly ) {
2699 ++addedAddresseeR; 2699 ++addedAddresseeR;
2700 inL.setRevision( modifiedCalendar ); 2700 inL.setRevision( modifiedCalendar );
2701 local->insertAddressee( inL, false ); 2701 local->insertAddressee( inL, false );
2702 inR = inL; 2702 inR = inL;
2703 inR.setResource( 0 ); 2703 inR.setResource( 0 );
2704 remote->insertAddressee( inR, false ); 2704 remote->insertAddressee( inR, false );
2705 } 2705 }
2706 } 2706 }
2707 } 2707 }
2708 } 2708 }
2709 } 2709 }
2710 ++incCounter; 2710 ++incCounter;
2711 } 2711 }
2712 el.clear(); 2712 el.clear();
2713 syncManager->hideProgressBar(); 2713 syncManager->hideProgressBar();
2714 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2714 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2715 // get rid of micro seconds 2715 // get rid of micro seconds
2716 QTime t = mLastAddressbookSync.time(); 2716 QTime t = mLastAddressbookSync.time();
2717 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2717 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2718 addresseeLSync.setRevision( mLastAddressbookSync ); 2718 addresseeLSync.setRevision( mLastAddressbookSync );
2719 addresseeRSync.setRevision( mLastAddressbookSync ); 2719 addresseeRSync.setRevision( mLastAddressbookSync );
2720 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2720 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2721 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2721 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2722 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2722 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2723 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2723 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2724 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2724 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2725 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2725 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2726 addresseeRSync.setNote( "" ) ; 2726 addresseeRSync.setNote( "" ) ;
2727 addresseeLSync.setNote( "" ); 2727 addresseeLSync.setNote( "" );
2728 2728
2729 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2729 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2730 remote->insertAddressee( addresseeRSync, false ); 2730 remote->insertAddressee( addresseeRSync, false );
2731 local->insertAddressee( addresseeLSync, false ); 2731 local->insertAddressee( addresseeLSync, false );
2732 QString mes; 2732 QString mes;
2733 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 ); 2733 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 );
2734 if ( syncManager->mShowSyncSummary ) { 2734 if ( syncManager->mShowSyncSummary ) {
2735 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2735 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2736 } 2736 }
2737 qDebug( mes ); 2737 qDebug( mes );
2738 return syncOK; 2738 return syncOK;
2739} 2739}
2740 2740
2741 2741
2742//this is a overwritten callbackmethods from the syncinterface 2742//this is a overwritten callbackmethods from the syncinterface
2743bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2743bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2744{ 2744{
2745 2745
2746 //pending prepare addresseeview for output 2746 //pending prepare addresseeview for output
2747 //pending detect, if remote file has REV field. if not switch to external sync 2747 //pending detect, if remote file has REV field. if not switch to external sync
2748 mGlobalSyncMode = SYNC_MODE_NORMAL; 2748 mGlobalSyncMode = SYNC_MODE_NORMAL;
2749 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2749 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2750 2750
2751 AddressBook abLocal(filename,"syncContact"); 2751 AddressBook abLocal(filename,"syncContact");
2752 bool syncOK = false; 2752 bool syncOK = false;
2753 if ( abLocal.load() ) { 2753 if ( abLocal.load() ) {
2754 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2754 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2755 bool external = false; 2755 bool external = false;
2756 bool isXML = false; 2756 bool isXML = false;
2757 if ( filename.right(4) == ".xml") { 2757 if ( filename.right(4) == ".xml") {
2758 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2758 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2759 isXML = true; 2759 isXML = true;
2760 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2760 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2761 } else { 2761 } else {
2762 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2762 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2763 if ( ! lse.isEmpty() ) { 2763 if ( ! lse.isEmpty() ) {
2764 if ( lse.familyName().left(4) == "!E: " ) 2764 if ( lse.familyName().left(4) == "!E: " )
2765 external = true; 2765 external = true;
2766 } else { 2766 } else {
2767 bool found = false; 2767 bool found = false;
2768 AddressBook::Iterator it; 2768 AddressBook::Iterator it;
2769 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2769 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2770 if ( (*it).revision().date().year() > 2003 ) { 2770 if ( (*it).revision().date().year() > 2003 ) {
2771 found = true; 2771 found = true;
2772 break; 2772 break;
2773 } 2773 }
2774 } 2774 }
2775 external = ! found; 2775 external = ! found;
2776 } 2776 }
2777 2777
2778 if ( external ) { 2778 if ( external ) {
2779 qDebug("Setting vcf mode to external "); 2779 qDebug("Setting vcf mode to external ");
2780 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2780 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2781 AddressBook::Iterator it; 2781 AddressBook::Iterator it;
2782 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2782 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2783 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2783 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2784 (*it).computeCsum( mCurrentSyncDevice ); 2784 (*it).computeCsum( mCurrentSyncDevice );
2785 } 2785 }
2786 } 2786 }
2787 } 2787 }
2788 //AddressBook::Iterator it; 2788 //AddressBook::Iterator it;
2789 //QStringList vcards; 2789 //QStringList vcards;
2790 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2790 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2791 // qDebug("Name %s ", (*it).familyName().latin1()); 2791 // qDebug("Name %s ", (*it).familyName().latin1());
2792 //} 2792 //}
2793 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2793 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2794 if ( syncOK ) { 2794 if ( syncOK ) {
2795 if ( syncManager->mWriteBackFile ) 2795 if ( syncManager->mWriteBackFile )
2796 { 2796 {
2797 if ( external ) 2797 if ( external )
2798 abLocal.removeSyncAddressees( !isXML); 2798 abLocal.removeSyncAddressees( !isXML);
2799 qDebug("Saving remote AB "); 2799 qDebug("Saving remote AB ");
2800 abLocal.saveAB(); 2800 abLocal.saveAB();
2801 if ( isXML ) { 2801 if ( isXML ) {
2802 // afterwrite processing 2802 // afterwrite processing
2803 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2803 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2804 } 2804 }
2805 } 2805 }
2806 } 2806 }
2807 setModified(); 2807 setModified();
2808 2808
2809 } 2809 }
2810 if ( syncOK ) 2810 if ( syncOK )
2811 mViewManager->refreshView(); 2811 mViewManager->refreshView();
2812 return syncOK; 2812 return syncOK;
2813#if 0 2813#if 0
2814 2814
2815 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2815 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2816 getEventViewerDialog()->setSyncMode( true ); 2816 getEventViewerDialog()->setSyncMode( true );
2817 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2817 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2818 getEventViewerDialog()->setSyncMode( false ); 2818 getEventViewerDialog()->setSyncMode( false );
2819 if ( syncOK ) { 2819 if ( syncOK ) {
2820 if ( KOPrefs::instance()->mWriteBackFile ) 2820 if ( KOPrefs::instance()->mWriteBackFile )
2821 { 2821 {
2822 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2822 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2823 storage->save(); 2823 storage->save();
2824 } 2824 }
2825 } 2825 }
2826 setModified(); 2826 setModified();
2827 } 2827 }
2828 2828
2829#endif 2829#endif
2830} 2830}
2831 2831
2832 2832
2833//this is a overwritten callbackmethods from the syncinterface 2833//this is a overwritten callbackmethods from the syncinterface
2834bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2834bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2835{ 2835{
2836 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2836 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2837 2837
2838 AddressBook abLocal( resource,"syncContact"); 2838 AddressBook abLocal( resource,"syncContact");
2839 bool syncOK = false; 2839 bool syncOK = false;
2840 if ( abLocal.load() ) { 2840 if ( abLocal.load() ) {
2841 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2841 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2842 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2842 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2843 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2843 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2844 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2844 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2845 if ( syncOK ) { 2845 if ( syncOK ) {
2846 if ( syncManager->mWriteBackFile ) { 2846 if ( syncManager->mWriteBackFile ) {
2847 abLocal.saveAB(); 2847 abLocal.saveAB();
2848 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2848 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2849 } 2849 }
2850 } 2850 }
2851 setModified(); 2851 setModified();
2852 } 2852 }
2853 if ( syncOK ) 2853 if ( syncOK )
2854 mViewManager->refreshView(); 2854 mViewManager->refreshView();
2855 return syncOK; 2855 return syncOK;
2856 2856
2857} 2857}
2858 2858
2859void KABCore::getFile( bool success ) 2859void KABCore::getFile( bool success )
2860{ 2860{
2861 qDebug("KABCore::getFile ");
2862 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); 2861 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
2863 if ( ! success ) { 2862 if ( ! success ) {
2864 setCaption( i18n("Error receiving file. Nothing changed!") ); 2863 setCaption( i18n("Error receiving file. Nothing changed!") );
2865 return; 2864 return;
2866 } 2865 }
2867 mAddressBook->importFromFile( sentSyncFile() ); 2866 mAddressBook->importFromFile( sentSyncFile() );
2868 topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 2867 topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
2868 mViewManager->refreshView();
2869} 2869}
2870void KABCore::syncFileRequest() 2870void KABCore::syncFileRequest()
2871{ 2871{
2872 mAddressBook->export2File( sentSyncFile() ); 2872 mAddressBook->export2File( sentSyncFile() );
2873} 2873}
2874QString KABCore::sentSyncFile() 2874QString KABCore::sentSyncFile()
2875{ 2875{
2876#ifdef _WIN32_ 2876#ifdef _WIN32_
2877 return locateLocal( "tmp", "copysyncab.vcf" ); 2877 return locateLocal( "tmp", "copysyncab.vcf" );
2878#else 2878#else
2879 return QString( "/tmp/copysyncab.vcf" ); 2879 return QString( "/tmp/copysyncab.vcf" );
2880#endif 2880#endif
2881} 2881}
2882 2882
2883void KABCore::setCaptionBack() 2883void KABCore::setCaptionBack()
2884{ 2884{
2885 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2885 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2886} 2886}
2887 2887