author | zautrix <zautrix> | 2004-09-19 11:32:40 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-19 11:32:40 (UTC) |
commit | eea0ff04703dffdbe8b67a0dc9f592597d7450c1 (patch) (unidiff) | |
tree | 874549d9c1c6239304fe1540d1b56269652954c0 /kaddressbook | |
parent | 953277a85e6ec5630ab0d64b4d68815e4e4f9906 (diff) | |
download | kdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.zip kdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.tar.gz kdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.tar.bz2 |
more AB sync
-rw-r--r-- | kaddressbook/kabcore.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index fa0c51f..d6482fb 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2905,96 +2905,98 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2905 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2905 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2906 | } | 2906 | } |
2907 | qDebug( mes ); | 2907 | qDebug( mes ); |
2908 | return syncOK; | 2908 | return syncOK; |
2909 | } | 2909 | } |
2910 | 2910 | ||
2911 | bool KABCore::syncAB(QString filename, int mode) | 2911 | bool KABCore::syncAB(QString filename, int mode) |
2912 | { | 2912 | { |
2913 | 2913 | ||
2914 | //pending prepare addresseeview for output | 2914 | //pending prepare addresseeview for output |
2915 | //pending detect, if remote file has REV field. if not switch to external sync | 2915 | //pending detect, if remote file has REV field. if not switch to external sync |
2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2917 | AddressBook abLocal(filename,"syncContact"); | 2917 | AddressBook abLocal(filename,"syncContact"); |
2918 | bool syncOK = false; | 2918 | bool syncOK = false; |
2919 | if ( abLocal.load() ) { | 2919 | if ( abLocal.load() ) { |
2920 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2920 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2921 | bool external = false; | 2921 | bool external = false; |
2922 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2922 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2923 | if ( ! lse.isEmpty() ) { | 2923 | if ( ! lse.isEmpty() ) { |
2924 | if ( lse.familyName().left(4) == "!E: " ) | 2924 | if ( lse.familyName().left(4) == "!E: " ) |
2925 | external = true; | 2925 | external = true; |
2926 | } else { | 2926 | } else { |
2927 | bool found = false; | 2927 | bool found = false; |
2928 | QDateTime dt( QDate( 2004,1,1)); | 2928 | QDateTime dt( QDate( 2004,1,1)); |
2929 | AddressBook::Iterator it; | 2929 | AddressBook::Iterator it; |
2930 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2930 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2931 | if ( (*it).revision() != dt ) { | 2931 | if ( (*it).revision() != dt ) { |
2932 | found = true; | 2932 | found = true; |
2933 | break; | 2933 | break; |
2934 | } | 2934 | } |
2935 | } | 2935 | } |
2936 | external = ! found; | 2936 | external = ! found; |
2937 | } | 2937 | } |
2938 | 2938 | ||
2939 | if ( external ) { | 2939 | if ( external ) { |
2940 | qDebug("Setting vcf mode to external "); | 2940 | qDebug("Setting vcf mode to external "); |
2941 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2941 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2942 | AddressBook::Iterator it; | 2942 | AddressBook::Iterator it; |
2943 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2943 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2944 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2944 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2945 | (*it).computeCsum( mCurrentSyncDevice ); | 2945 | (*it).computeCsum( mCurrentSyncDevice ); |
2946 | } | 2946 | } |
2947 | } | 2947 | } |
2948 | //AddressBook::Iterator it; | 2948 | //AddressBook::Iterator it; |
2949 | //QStringList vcards; | 2949 | //QStringList vcards; |
2950 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2950 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2951 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2951 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2952 | //} | 2952 | //} |
2953 | if ( filename.right(4) == ".xml") | ||
2954 | abLocal.mergeAB( mAddressBook ,mCurrentSyncDevice ); | ||
2953 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2955 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2954 | if ( syncOK ) { | 2956 | if ( syncOK ) { |
2955 | if ( KABPrefs::instance()->mWriteBackFile ) | 2957 | if ( KABPrefs::instance()->mWriteBackFile ) |
2956 | { | 2958 | { |
2957 | if ( external ) | 2959 | if ( external ) |
2958 | abLocal.removeDeletedAddressees(); | 2960 | abLocal.removeDeletedAddressees(); |
2959 | qDebug("Saving remote AB "); | 2961 | qDebug("Saving remote AB "); |
2960 | abLocal.saveAB(); | 2962 | abLocal.saveAB(); |
2961 | } | 2963 | } |
2962 | } | 2964 | } |
2963 | setModified(); | 2965 | setModified(); |
2964 | 2966 | ||
2965 | } | 2967 | } |
2966 | if ( syncOK ) | 2968 | if ( syncOK ) |
2967 | mViewManager->refreshView(); | 2969 | mViewManager->refreshView(); |
2968 | return syncOK; | 2970 | return syncOK; |
2969 | #if 0 | 2971 | #if 0 |
2970 | 2972 | ||
2971 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2973 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2972 | getEventViewerDialog()->setSyncMode( true ); | 2974 | getEventViewerDialog()->setSyncMode( true ); |
2973 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2975 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2974 | getEventViewerDialog()->setSyncMode( false ); | 2976 | getEventViewerDialog()->setSyncMode( false ); |
2975 | if ( syncOK ) { | 2977 | if ( syncOK ) { |
2976 | if ( KOPrefs::instance()->mWriteBackFile ) | 2978 | if ( KOPrefs::instance()->mWriteBackFile ) |
2977 | { | 2979 | { |
2978 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2980 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2979 | storage->save(); | 2981 | storage->save(); |
2980 | } | 2982 | } |
2981 | } | 2983 | } |
2982 | setModified(); | 2984 | setModified(); |
2983 | } | 2985 | } |
2984 | 2986 | ||
2985 | #endif | 2987 | #endif |
2986 | } | 2988 | } |
2987 | 2989 | ||
2988 | void KABCore::confSync() | 2990 | void KABCore::confSync() |
2989 | { | 2991 | { |
2990 | static KSyncPrefsDialog* sp = 0; | 2992 | static KSyncPrefsDialog* sp = 0; |
2991 | if ( ! sp ) { | 2993 | if ( ! sp ) { |
2992 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 2994 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
2993 | } | 2995 | } |
2994 | sp->usrReadConfig(); | 2996 | sp->usrReadConfig(); |
2995 | #ifndef DESKTOP_VERSION | 2997 | #ifndef DESKTOP_VERSION |
2996 | sp->showMaximized(); | 2998 | sp->showMaximized(); |
2997 | #else | 2999 | #else |
2998 | sp->show(); | 3000 | sp->show(); |
2999 | #endif | 3001 | #endif |
3000 | sp->exec(); | 3002 | sp->exec(); |