summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index efae874..e56e46a 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2719,194 +2719,194 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2719 } 2719 }
2720 } 2720 }
2721 } 2721 }
2722 ++incCounter; 2722 ++incCounter;
2723 } 2723 }
2724 el.clear(); 2724 el.clear();
2725 syncManager->hideProgressBar(); 2725 syncManager->hideProgressBar();
2726 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2726 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2727 // get rid of micro seconds 2727 // get rid of micro seconds
2728 QTime t = mLastAddressbookSync.time(); 2728 QTime t = mLastAddressbookSync.time();
2729 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2729 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2730 addresseeLSync.setRevision( mLastAddressbookSync ); 2730 addresseeLSync.setRevision( mLastAddressbookSync );
2731 addresseeRSync.setRevision( mLastAddressbookSync ); 2731 addresseeRSync.setRevision( mLastAddressbookSync );
2732 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2732 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2733 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2733 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2734 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2734 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2735 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2735 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2736 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2736 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2737 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2737 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2738 addresseeRSync.setNote( "" ) ; 2738 addresseeRSync.setNote( "" ) ;
2739 addresseeLSync.setNote( "" ); 2739 addresseeLSync.setNote( "" );
2740 2740
2741 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2741 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2742 remote->insertAddressee( addresseeRSync, false ); 2742 remote->insertAddressee( addresseeRSync, false );
2743 local->insertAddressee( addresseeLSync, false ); 2743 local->insertAddressee( addresseeLSync, false );
2744 QString mes; 2744 QString mes;
2745 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 ); 2745 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 );
2746 if ( syncManager->mShowSyncSummary ) { 2746 if ( syncManager->mShowSyncSummary ) {
2747 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2747 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2748 } 2748 }
2749 qDebug( mes ); 2749 qDebug( mes );
2750 return syncOK; 2750 return syncOK;
2751} 2751}
2752 2752
2753 2753
2754//this is a overwritten callbackmethods from the syncinterface 2754//this is a overwritten callbackmethods from the syncinterface
2755bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2755bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2756{ 2756{
2757 2757
2758 //pending prepare addresseeview for output 2758 //pending prepare addresseeview for output
2759 //pending detect, if remote file has REV field. if not switch to external sync 2759 //pending detect, if remote file has REV field. if not switch to external sync
2760 mGlobalSyncMode = SYNC_MODE_NORMAL; 2760 mGlobalSyncMode = SYNC_MODE_NORMAL;
2761 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2761 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2762 2762
2763 AddressBook abLocal(filename,"syncContact"); 2763 AddressBook abLocal(filename,"syncContact");
2764 bool syncOK = false; 2764 bool syncOK = false;
2765 if ( abLocal.load() ) { 2765 if ( abLocal.load() ) {
2766 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2766 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2767 bool external = false; 2767 bool external = false;
2768 bool isXML = false; 2768 bool isXML = false;
2769 if ( filename.right(4) == ".xml") { 2769 if ( filename.right(4) == ".xml") {
2770 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2770 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2771 isXML = true; 2771 isXML = true;
2772 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2772 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2773 } else { 2773 } else {
2774 external = !manager->mIsKapiFile; 2774 external = !manager->mIsKapiFile;
2775 if ( external ) { 2775 if ( external ) {
2776 qDebug("Setting vcf mode to external "); 2776 qDebug("Setting vcf mode to external ");
2777 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2777 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2778 AddressBook::Iterator it; 2778 AddressBook::Iterator it;
2779 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2779 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2780 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2780 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2781 (*it).computeCsum( mCurrentSyncDevice ); 2781 (*it).computeCsum( mCurrentSyncDevice );
2782 } 2782 }
2783 } 2783 }
2784 } 2784 }
2785 //AddressBook::Iterator it; 2785 //AddressBook::Iterator it;
2786 //QStringList vcards; 2786 //QStringList vcards;
2787 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2787 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2788 // qDebug("Name %s ", (*it).familyName().latin1()); 2788 // qDebug("Name %s ", (*it).familyName().latin1());
2789 //} 2789 //}
2790 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2790 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2791 if ( syncOK ) { 2791 if ( syncOK ) {
2792 if ( syncManager->mWriteBackFile ) 2792 if ( syncManager->mWriteBackFile )
2793 { 2793 {
2794 if ( external ) 2794 if ( external )
2795 abLocal.removeSyncAddressees( !isXML); 2795 abLocal.removeSyncAddressees( !isXML);
2796 qDebug("Saving remote AB "); 2796 qDebug("Saving remote AB ");
2797 if ( ! abLocal.saveAB()) 2797 if ( ! abLocal.saveAB())
2798 qDebug("Error writing back AB to file "); 2798 qDebug("Error writing back AB to file ");
2799 if ( isXML ) { 2799 if ( isXML ) {
2800 // afterwrite processing 2800 // afterwrite processing
2801 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2801 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2802 } 2802 }
2803 } 2803 }
2804 } 2804 }
2805 setModified(); 2805 setModified();
2806 2806
2807 } 2807 }
2808 if ( syncOK ) 2808 if ( syncOK )
2809 mViewManager->refreshView(); 2809 mViewManager->refreshView();
2810 return syncOK; 2810 return syncOK;
2811 2811
2812} 2812}
2813void KABCore::removeSyncInfo( QString syncProfile) 2813void KABCore::removeSyncInfo( QString syncProfile)
2814{ 2814{
2815 qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); 2815 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
2816 2816 mAddressBook->removeSyncInfo( syncProfile );
2817} 2817}
2818 2818
2819 2819
2820//this is a overwritten callbackmethods from the syncinterface 2820//this is a overwritten callbackmethods from the syncinterface
2821bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2821bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2822{ 2822{
2823 if ( resource == "phone" ) 2823 if ( resource == "phone" )
2824 return syncPhone(); 2824 return syncPhone();
2825 disableBR( true ); 2825 disableBR( true );
2826 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2826 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2827 2827
2828 AddressBook abLocal( resource,"syncContact"); 2828 AddressBook abLocal( resource,"syncContact");
2829 bool syncOK = false; 2829 bool syncOK = false;
2830 if ( abLocal.load() ) { 2830 if ( abLocal.load() ) {
2831 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2831 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2832 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2832 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2833 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 2833 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
2834 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2834 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2835 if ( syncOK ) { 2835 if ( syncOK ) {
2836 if ( syncManager->mWriteBackFile ) { 2836 if ( syncManager->mWriteBackFile ) {
2837 abLocal.removeSyncAddressees( false ); 2837 abLocal.removeSyncAddressees( false );
2838 abLocal.saveAB(); 2838 abLocal.saveAB();
2839 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2839 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2840 } 2840 }
2841 } 2841 }
2842 setModified(); 2842 setModified();
2843 } 2843 }
2844 if ( syncOK ) 2844 if ( syncOK )
2845 mViewManager->refreshView(); 2845 mViewManager->refreshView();
2846 disableBR( false ); 2846 disableBR( false );
2847 return syncOK; 2847 return syncOK;
2848 2848
2849} 2849}
2850void KABCore::message( QString m ) 2850void KABCore::message( QString m )
2851{ 2851{
2852 topLevelWidget()->setCaption( m ); 2852 topLevelWidget()->setCaption( m );
2853 mMessageTimer->start( 15000, true ); 2853 mMessageTimer->start( 15000, true );
2854} 2854}
2855bool KABCore::syncPhone() 2855bool KABCore::syncPhone()
2856{ 2856{
2857 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2857 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2858 QString fileName = getPhoneFile(); 2858 QString fileName = getPhoneFile();
2859 if ( !PhoneAccess::readFromPhone( fileName) ) { 2859 if ( !PhoneAccess::readFromPhone( fileName) ) {
2860 message(i18n("Phone access failed!")); 2860 message(i18n("Phone access failed!"));
2861 return false; 2861 return false;
2862 } 2862 }
2863 AddressBook abLocal( fileName,"syncContact"); 2863 AddressBook abLocal( fileName,"syncContact");
2864 bool syncOK = false; 2864 bool syncOK = false;
2865 { 2865 {
2866 abLocal.importFromFile( fileName ); 2866 abLocal.importFromFile( fileName );
2867 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2867 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
2868 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2868 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2869 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 2869 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
2870 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2870 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2871 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2871 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2872 if ( syncOK ) { 2872 if ( syncOK ) {
2873 if ( syncManager->mWriteBackFile ) { 2873 if ( syncManager->mWriteBackFile ) {
2874 abLocal.removeSyncAddressees( true ); 2874 abLocal.removeSyncAddressees( true );
2875 abLocal.saveABphone( fileName ); 2875 abLocal.saveABphone( fileName );
2876 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 2876 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
2877 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 2877 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
2878 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2878 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2879 } 2879 }
2880 } 2880 }
2881 setModified(); 2881 setModified();
2882 } 2882 }
2883 if ( syncOK ) 2883 if ( syncOK )
2884 mViewManager->refreshView(); 2884 mViewManager->refreshView();
2885 return syncOK; 2885 return syncOK;
2886} 2886}
2887void KABCore::getFile( bool success ) 2887void KABCore::getFile( bool success )
2888{ 2888{
2889 if ( ! success ) { 2889 if ( ! success ) {
2890 message( i18n("Error receiving file. Nothing changed!") ); 2890 message( i18n("Error receiving file. Nothing changed!") );
2891 return; 2891 return;
2892 } 2892 }
2893 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 2893 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
2894 if ( count ) 2894 if ( count )
2895 setModified( true ); 2895 setModified( true );
2896 message( i18n("Pi-Sync successful!") ); 2896 message( i18n("Pi-Sync successful!") );
2897 mViewManager->refreshView(); 2897 mViewManager->refreshView();
2898} 2898}
2899void KABCore::syncFileRequest() 2899void KABCore::syncFileRequest()
2900{ 2900{
2901 mAddressBook->export2File( sentSyncFile() ); 2901 mAddressBook->export2File( sentSyncFile() );
2902} 2902}
2903QString KABCore::sentSyncFile() 2903QString KABCore::sentSyncFile()
2904{ 2904{
2905#ifdef DESKTOP_VERSION 2905#ifdef DESKTOP_VERSION
2906 return locateLocal( "tmp", "copysyncab.vcf" ); 2906 return locateLocal( "tmp", "copysyncab.vcf" );
2907#else 2907#else
2908 return QString( "/tmp/copysyncab.vcf" ); 2908 return QString( "/tmp/copysyncab.vcf" );
2909#endif 2909#endif
2910} 2910}
2911 2911
2912void KABCore::setCaptionBack() 2912void KABCore::setCaptionBack()