author | zautrix <zautrix> | 2004-10-13 13:18:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-13 13:18:51 (UTC) |
commit | d41893fb0a49fbb080326a4c1fd98e1a032a182a (patch) (unidiff) | |
tree | 9b95603ff93801accaa94de4b73d88ea9c5c9386 /kaddressbook | |
parent | efdd0735bda81dcd82dfb6d6dc0d0c143f249336 (diff) | |
download | kdepimpi-d41893fb0a49fbb080326a4c1fd98e1a032a182a.zip kdepimpi-d41893fb0a49fbb080326a4c1fd98e1a032a182a.tar.gz kdepimpi-d41893fb0a49fbb080326a4c1fd98e1a032a182a.tar.bz2 |
merge contact fixes
-rw-r--r-- | kaddressbook/kabcore.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 205dbc8..ea34be2 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2687,189 +2687,189 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2687 | el.clear(); | 2687 | el.clear(); |
2688 | syncManager->hideProgressBar(); | 2688 | syncManager->hideProgressBar(); |
2689 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2689 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2690 | // get rid of micro seconds | 2690 | // get rid of micro seconds |
2691 | QTime t = mLastAddressbookSync.time(); | 2691 | QTime t = mLastAddressbookSync.time(); |
2692 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2692 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2693 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2693 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2694 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2694 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2695 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2695 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2696 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2696 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2697 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2697 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2698 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2698 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2699 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2699 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2700 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2700 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2701 | addresseeRSync.setNote( "" ) ; | 2701 | addresseeRSync.setNote( "" ) ; |
2702 | addresseeLSync.setNote( "" ); | 2702 | addresseeLSync.setNote( "" ); |
2703 | 2703 | ||
2704 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2704 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2705 | remote->insertAddressee( addresseeRSync, false ); | 2705 | remote->insertAddressee( addresseeRSync, false ); |
2706 | local->insertAddressee( addresseeLSync, false ); | 2706 | local->insertAddressee( addresseeLSync, false ); |
2707 | QString mes; | 2707 | QString mes; |
2708 | 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 ); | 2708 | 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 ); |
2709 | if ( syncManager->mShowSyncSummary ) { | 2709 | if ( syncManager->mShowSyncSummary ) { |
2710 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2710 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2711 | } | 2711 | } |
2712 | qDebug( mes ); | 2712 | qDebug( mes ); |
2713 | return syncOK; | 2713 | return syncOK; |
2714 | } | 2714 | } |
2715 | 2715 | ||
2716 | 2716 | ||
2717 | //this is a overwritten callbackmethods from the syncinterface | 2717 | //this is a overwritten callbackmethods from the syncinterface |
2718 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2718 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2719 | { | 2719 | { |
2720 | 2720 | ||
2721 | //pending prepare addresseeview for output | 2721 | //pending prepare addresseeview for output |
2722 | //pending detect, if remote file has REV field. if not switch to external sync | 2722 | //pending detect, if remote file has REV field. if not switch to external sync |
2723 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2723 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2724 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2724 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2725 | 2725 | ||
2726 | AddressBook abLocal(filename,"syncContact"); | 2726 | AddressBook abLocal(filename,"syncContact"); |
2727 | bool syncOK = false; | 2727 | bool syncOK = false; |
2728 | if ( abLocal.load() ) { | 2728 | if ( abLocal.load() ) { |
2729 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2729 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2730 | bool external = false; | 2730 | bool external = false; |
2731 | bool isXML = false; | 2731 | bool isXML = false; |
2732 | if ( filename.right(4) == ".xml") { | 2732 | if ( filename.right(4) == ".xml") { |
2733 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2733 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2734 | isXML = true; | 2734 | isXML = true; |
2735 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2735 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2736 | } else { | 2736 | } else { |
2737 | external = !manager->mIsKapiFile; | 2737 | external = !manager->mIsKapiFile; |
2738 | if ( external ) { | 2738 | if ( external ) { |
2739 | qDebug("Setting vcf mode to external "); | 2739 | qDebug("Setting vcf mode to external "); |
2740 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2740 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2741 | AddressBook::Iterator it; | 2741 | AddressBook::Iterator it; |
2742 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2742 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2743 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2743 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2744 | (*it).computeCsum( mCurrentSyncDevice ); | 2744 | (*it).computeCsum( mCurrentSyncDevice ); |
2745 | } | 2745 | } |
2746 | } | 2746 | } |
2747 | } | 2747 | } |
2748 | //AddressBook::Iterator it; | 2748 | //AddressBook::Iterator it; |
2749 | //QStringList vcards; | 2749 | //QStringList vcards; |
2750 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2750 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2751 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2751 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2752 | //} | 2752 | //} |
2753 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2753 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2754 | if ( syncOK ) { | 2754 | if ( syncOK ) { |
2755 | if ( syncManager->mWriteBackFile ) | 2755 | if ( syncManager->mWriteBackFile ) |
2756 | { | 2756 | { |
2757 | if ( external ) | 2757 | if ( external ) |
2758 | abLocal.removeSyncAddressees( !isXML); | 2758 | abLocal.removeSyncAddressees( !isXML); |
2759 | qDebug("Saving remote AB "); | 2759 | qDebug("Saving remote AB "); |
2760 | if ( ! abLocal.saveAB()) | 2760 | if ( ! abLocal.saveAB()) |
2761 | qDebug("Error writing back AB to file "); | 2761 | qDebug("Error writing back AB to file "); |
2762 | if ( isXML ) { | 2762 | if ( isXML ) { |
2763 | // afterwrite processing | 2763 | // afterwrite processing |
2764 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2764 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2765 | } | 2765 | } |
2766 | } | 2766 | } |
2767 | } | 2767 | } |
2768 | setModified(); | 2768 | setModified(); |
2769 | 2769 | ||
2770 | } | 2770 | } |
2771 | if ( syncOK ) | 2771 | if ( syncOK ) |
2772 | mViewManager->refreshView(); | 2772 | mViewManager->refreshView(); |
2773 | return syncOK; | 2773 | return syncOK; |
2774 | 2774 | ||
2775 | } | 2775 | } |
2776 | 2776 | ||
2777 | 2777 | ||
2778 | //this is a overwritten callbackmethods from the syncinterface | 2778 | //this is a overwritten callbackmethods from the syncinterface |
2779 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2779 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2780 | { | 2780 | { |
2781 | if ( resource == "phone" ) | 2781 | if ( resource == "phone" ) |
2782 | return syncPhone(); | 2782 | return syncPhone(); |
2783 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2783 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2784 | 2784 | ||
2785 | AddressBook abLocal( resource,"syncContact"); | 2785 | AddressBook abLocal( resource,"syncContact"); |
2786 | bool syncOK = false; | 2786 | bool syncOK = false; |
2787 | if ( abLocal.load() ) { | 2787 | if ( abLocal.load() ) { |
2788 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2788 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2789 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2789 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2790 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2790 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
2791 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2791 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2792 | if ( syncOK ) { | 2792 | if ( syncOK ) { |
2793 | if ( syncManager->mWriteBackFile ) { | 2793 | if ( syncManager->mWriteBackFile ) { |
2794 | abLocal.removeSyncAddressees( false ); | 2794 | abLocal.removeSyncAddressees( false ); |
2795 | abLocal.saveAB(); | 2795 | abLocal.saveAB(); |
2796 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2796 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2797 | } | 2797 | } |
2798 | } | 2798 | } |
2799 | setModified(); | 2799 | setModified(); |
2800 | } | 2800 | } |
2801 | if ( syncOK ) | 2801 | if ( syncOK ) |
2802 | mViewManager->refreshView(); | 2802 | mViewManager->refreshView(); |
2803 | return syncOK; | 2803 | return syncOK; |
2804 | 2804 | ||
2805 | } | 2805 | } |
2806 | void KABCore::message( QString m ) | 2806 | void KABCore::message( QString m ) |
2807 | { | 2807 | { |
2808 | 2808 | ||
2809 | topLevelWidget()->setCaption( m ); | 2809 | topLevelWidget()->setCaption( m ); |
2810 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); | 2810 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); |
2811 | } | 2811 | } |
2812 | bool KABCore::syncPhone() | 2812 | bool KABCore::syncPhone() |
2813 | { | 2813 | { |
2814 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2814 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2815 | QString fileName; | 2815 | QString fileName; |
2816 | #ifdef _WIN32_ | 2816 | #ifdef _WIN32_ |
2817 | fileName = locateLocal("tmp", "phonefile.vcf"); | 2817 | fileName = locateLocal("tmp", "phonefile.vcf"); |
2818 | #else | 2818 | #else |
2819 | fileName = "/tmp/phonefile.vcf"; | 2819 | fileName = "/tmp/phonefile.vcf"; |
2820 | #endif | 2820 | #endif |
2821 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 2821 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
2822 | message(i18n("Phone access failed!")); | 2822 | message(i18n("Phone access failed!")); |
2823 | return false; | 2823 | return false; |
2824 | } | 2824 | } |
2825 | AddressBook abLocal( fileName,"syncContact"); | 2825 | AddressBook abLocal( fileName,"syncContact"); |
2826 | bool syncOK = false; | 2826 | bool syncOK = false; |
2827 | { | 2827 | { |
2828 | abLocal.importFromFile( fileName ); | 2828 | abLocal.importFromFile( fileName ); |
2829 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2829 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2830 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2830 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2831 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 2831 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
2832 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2832 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2833 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2833 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2834 | if ( syncOK ) { | 2834 | if ( syncOK ) { |
2835 | if ( syncManager->mWriteBackFile ) { | 2835 | if ( syncManager->mWriteBackFile ) { |
2836 | abLocal.removeSyncAddressees( true ); | 2836 | abLocal.removeSyncAddressees( true ); |
2837 | abLocal.saveABphone( fileName ); | 2837 | abLocal.saveABphone( fileName ); |
2838 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 2838 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
2839 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 2839 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
2840 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2840 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2841 | } | 2841 | } |
2842 | } | 2842 | } |
2843 | setModified(); | 2843 | setModified(); |
2844 | } | 2844 | } |
2845 | if ( syncOK ) | 2845 | if ( syncOK ) |
2846 | mViewManager->refreshView(); | 2846 | mViewManager->refreshView(); |
2847 | return syncOK; | 2847 | return syncOK; |
2848 | } | 2848 | } |
2849 | void KABCore::getFile( bool success ) | 2849 | void KABCore::getFile( bool success ) |
2850 | { | 2850 | { |
2851 | if ( ! success ) { | 2851 | if ( ! success ) { |
2852 | message( i18n("Error receiving file. Nothing changed!") ); | 2852 | message( i18n("Error receiving file. Nothing changed!") ); |
2853 | return; | 2853 | return; |
2854 | } | 2854 | } |
2855 | mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2855 | mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2856 | message( i18n("Pi-Sync successful!") ); | 2856 | message( i18n("Pi-Sync successful!") ); |
2857 | mViewManager->refreshView(); | 2857 | mViewManager->refreshView(); |
2858 | } | 2858 | } |
2859 | void KABCore::syncFileRequest() | 2859 | void KABCore::syncFileRequest() |
2860 | { | 2860 | { |
2861 | mAddressBook->export2File( sentSyncFile() ); | 2861 | mAddressBook->export2File( sentSyncFile() ); |
2862 | } | 2862 | } |
2863 | QString KABCore::sentSyncFile() | 2863 | QString KABCore::sentSyncFile() |
2864 | { | 2864 | { |
2865 | #ifdef _WIN32_ | 2865 | #ifdef _WIN32_ |
2866 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2866 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2867 | #else | 2867 | #else |
2868 | return QString( "/tmp/copysyncab.vcf" ); | 2868 | return QString( "/tmp/copysyncab.vcf" ); |
2869 | #endif | 2869 | #endif |
2870 | } | 2870 | } |
2871 | 2871 | ||
2872 | void KABCore::setCaptionBack() | 2872 | void KABCore::setCaptionBack() |
2873 | { | 2873 | { |
2874 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2874 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2875 | } | 2875 | } |