-rw-r--r-- | kabc/addressbook.cpp | 19 | ||||
-rw-r--r-- | kabc/addressbook.h | 2 | ||||
-rw-r--r-- | kabc/addressee.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 16 |
4 files changed, 26 insertions, 13 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 9b196b5..5774c36 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -861,32 +861,39 @@ void AddressBook::removeSyncAddressees( bool removeDeleted ) | |||
861 | Iterator it2 ; | 861 | Iterator it2 ; |
862 | QDateTime dt ( QDate( 2004,1,1) ); | 862 | QDateTime dt ( QDate( 2004,1,1) ); |
863 | while ( it != end() ) { | 863 | while ( it != end() ) { |
864 | (*it).setRevision( dt ); | 864 | (*it).setRevision( dt ); |
865 | if (( *it).IDStr() != "changed" ) { | 865 | if (( *it).IDStr() != "changed" ) { |
866 | // "changed" is used for tagging changed addressees when syncing with KDE or OL | 866 | // "changed" is used for tagging changed addressees when syncing with KDE or OL |
867 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 867 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
868 | (*it).setIDStr(""); | 868 | (*it).setIDStr(""); |
869 | } | 869 | } |
870 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 870 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
871 | it2 = it; | 871 | it2 = it; |
872 | //qDebug("removing %s ",(*it).uid().latin1() ); | 872 | //qDebug("removing %s ",(*it).uid().latin1() ); |
873 | ++it; | 873 | ++it; |
874 | removeAddressee( it2 ); | 874 | removeAddressee( it2 ); |
875 | } else { | 875 | } else { |
876 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 876 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
877 | if ( removeDeleted ) { | ||
878 | // we have no postprocessing in the resource, we have to do it here | ||
879 | // we have to compute csum for all, because it could be the first sync | ||
880 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); | ||
881 | |||
882 | |||
883 | } | ||
877 | ++it; | 884 | ++it; |
878 | } | 885 | } |
879 | } | 886 | } |
880 | deleteRemovedAddressees(); | 887 | deleteRemovedAddressees(); |
881 | } | 888 | } |
882 | 889 | ||
883 | void AddressBook::removeAddressee( const Iterator &it ) | 890 | void AddressBook::removeAddressee( const Iterator &it ) |
884 | { | 891 | { |
885 | d->mRemovedAddressees.append( (*it) ); | 892 | d->mRemovedAddressees.append( (*it) ); |
886 | d->mAddressees.remove( it.d->mIt ); | 893 | d->mAddressees.remove( it.d->mIt ); |
887 | } | 894 | } |
888 | 895 | ||
889 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 896 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
890 | { | 897 | { |
891 | Iterator it; | 898 | Iterator it; |
892 | for ( it = begin(); it != end(); ++it ) { | 899 | for ( it = begin(); it != end(); ++it ) { |
@@ -904,47 +911,51 @@ Addressee AddressBook::findByUid( const QString &uid ) | |||
904 | if ( uid == (*it).uid() ) { | 911 | if ( uid == (*it).uid() ) { |
905 | return *it; | 912 | return *it; |
906 | } | 913 | } |
907 | } | 914 | } |
908 | return Addressee(); | 915 | return Addressee(); |
909 | } | 916 | } |
910 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) | 917 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) |
911 | { | 918 | { |
912 | //qDebug("AddressBook::preExternSync "); | 919 | //qDebug("AddressBook::preExternSync "); |
913 | AddressBook::Iterator it; | 920 | AddressBook::Iterator it; |
914 | for ( it = begin(); it != end(); ++it ) { | 921 | for ( it = begin(); it != end(); ++it ) { |
915 | (*it).setID( csd, (*it).externalUID() ); | 922 | (*it).setID( csd, (*it).externalUID() ); |
916 | (*it).computeCsum( csd ); | 923 | (*it).computeCsum( csd ); |
917 | } | 924 | } |
918 | mergeAB( aBook ,csd, isSubset ); | 925 | mergeAB( aBook ,csd, isSubset ); |
919 | } | 926 | } |
920 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) | 927 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) |
921 | { | 928 | { |
922 | //qDebug("AddressBook::postExternSync "); | 929 | //qDebug("AddressBook::postExternSync "); |
923 | AddressBook::Iterator it; | 930 | AddressBook::Iterator it; |
924 | for ( it = begin(); it != end(); ++it ) { | 931 | for ( it = begin(); it != end(); ++it ) { |
925 | // qDebug("check uid %s ", (*it).uid().latin1() ); | 932 | //qDebug("check uid %s ", (*it).uid().latin1() ); |
926 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 933 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
927 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { | 934 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { |
928 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 935 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
929 | if ( ad.isEmpty() ) { | 936 | if ( ad.isEmpty() ) { |
930 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); | 937 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); |
931 | } else { | 938 | } else { |
939 | (*it).setIDStr(":"); | ||
932 | (*it).computeCsum( csd ); | 940 | (*it).computeCsum( csd ); |
933 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 941 | if ( setID ) { |
934 | ad.setID( csd, (*it).externalUID() ); | 942 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
943 | ad.setID( csd, (*it).externalUID() ); | ||
944 | } else | ||
945 | ad.setID( csd, "_" ); | ||
935 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 946 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
936 | aBook->insertAddressee( ad ); | 947 | aBook->insertAddressee( ad ); |
937 | } | 948 | } |
938 | } | 949 | } |
939 | } | 950 | } |
940 | } | 951 | } |
941 | 952 | ||
942 | bool AddressBook::containsExternalUid( const QString& uid ) | 953 | bool AddressBook::containsExternalUid( const QString& uid ) |
943 | { | 954 | { |
944 | Iterator it; | 955 | Iterator it; |
945 | for ( it = begin(); it != end(); ++it ) { | 956 | for ( it = begin(); it != end(); ++it ) { |
946 | if ( uid == (*it).externalUID( ) ) | 957 | if ( uid == (*it).externalUID( ) ) |
947 | return true; | 958 | return true; |
948 | } | 959 | } |
949 | return false; | 960 | return false; |
950 | } | 961 | } |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index f124dc9..75f8b51 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -294,33 +294,33 @@ class AddressBook : public QObject | |||
294 | 294 | ||
295 | /** | 295 | /** |
296 | Query all resources to clean up their lock files | 296 | Query all resources to clean up their lock files |
297 | */ | 297 | */ |
298 | void cleanUp(); | 298 | void cleanUp(); |
299 | 299 | ||
300 | // sync stuff | 300 | // sync stuff |
301 | //Addressee::List getExternLastSyncAddressees(); | 301 | //Addressee::List getExternLastSyncAddressees(); |
302 | void resetTempSyncStat(); | 302 | void resetTempSyncStat(); |
303 | QStringList uidList(); | 303 | QStringList uidList(); |
304 | void removeSyncAddressees( bool removeDeleted = false ); | 304 | void removeSyncAddressees( bool removeDeleted = false ); |
305 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); | 305 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); |
306 | Addressee findByExternUid( const QString& uid , const QString& profile ); | 306 | Addressee findByExternUid( const QString& uid , const QString& profile ); |
307 | bool containsExternalUid( const QString& uid ); | 307 | bool containsExternalUid( const QString& uid ); |
308 | 308 | ||
309 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); | 309 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); |
310 | void postExternSync( AddressBook* aBook, const QString& csd ); | 310 | void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); |
311 | signals: | 311 | signals: |
312 | /** | 312 | /** |
313 | Emitted, when the address book has changed on disk. | 313 | Emitted, when the address book has changed on disk. |
314 | */ | 314 | */ |
315 | void addressBookChanged( AddressBook * ); | 315 | void addressBookChanged( AddressBook * ); |
316 | 316 | ||
317 | /** | 317 | /** |
318 | Emitted, when the address book has been locked for writing. | 318 | Emitted, when the address book has been locked for writing. |
319 | */ | 319 | */ |
320 | void addressBookLocked( AddressBook * ); | 320 | void addressBookLocked( AddressBook * ); |
321 | 321 | ||
322 | /** | 322 | /** |
323 | Emitted, when the address book has been unlocked. | 323 | Emitted, when the address book has been unlocked. |
324 | */ | 324 | */ |
325 | void addressBookUnlocked( AddressBook * ); | 325 | void addressBookUnlocked( AddressBook * ); |
326 | 326 | ||
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index a660a9d..d5a110a 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -253,33 +253,33 @@ void Addressee::computeCsum(const QString &dev) | |||
253 | t.sort(); | 253 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 254 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 255 | l.append( t[iii] ); |
256 | t = mData->custom; | 256 | t = mData->custom; |
257 | t.sort(); | 257 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 258 | for ( iii = 0; iii < t.count(); ++iii) |
259 | l.append( t[iii] ); | 259 | l.append( t[iii] ); |
260 | KABC::Address::List::Iterator addressIter; | 260 | KABC::Address::List::Iterator addressIter; |
261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
262 | ++addressIter ) { | 262 | ++addressIter ) { |
263 | t = (*addressIter).asList(); | 263 | t = (*addressIter).asList(); |
264 | t.sort(); | 264 | t.sort(); |
265 | for ( iii = 0; iii < t.count(); ++iii) | 265 | for ( iii = 0; iii < t.count(); ++iii) |
266 | l.append( t[iii] ); | 266 | l.append( t[iii] ); |
267 | } | 267 | } |
268 | uint cs = getCsum4List(l); | 268 | uint cs = getCsum4List(l); |
269 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 269 | //qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
270 | setCsum( dev, QString::number (cs )); | 270 | setCsum( dev, QString::number (cs )); |
271 | } | 271 | } |
272 | 272 | ||
273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
274 | { | 274 | { |
275 | 275 | ||
276 | detach(); | 276 | detach(); |
277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
285 | if ( !mData->birthday.isValid() ) | 285 | if ( !mData->birthday.isValid() ) |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index ea87929..b0cb986 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2500,38 +2500,38 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2500 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2500 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2501 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2501 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2502 | 2502 | ||
2503 | //QPtrList<Addressee> el = local->rawAddressees(); | 2503 | //QPtrList<Addressee> el = local->rawAddressees(); |
2504 | Addressee addresseeR; | 2504 | Addressee addresseeR; |
2505 | QString uid; | 2505 | QString uid; |
2506 | int take; | 2506 | int take; |
2507 | Addressee addresseeL; | 2507 | Addressee addresseeL; |
2508 | Addressee addresseeRSync; | 2508 | Addressee addresseeRSync; |
2509 | Addressee addresseeLSync; | 2509 | Addressee addresseeLSync; |
2510 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2510 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2511 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2511 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2512 | bool fullDateRange = false; | 2512 | bool fullDateRange = false; |
2513 | local->resetTempSyncStat(); | 2513 | local->resetTempSyncStat(); |
2514 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2514 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2515 | if ( syncManager->syncWithDesktop() ) { | 2515 | if ( syncManager->syncWithDesktop() ) { |
2516 | remote->removeSyncInfo( QString());//remove all info | 2516 | // remote->removeSyncInfo( QString());//remove all info |
2517 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2517 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2518 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2518 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2519 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2519 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2520 | } else { | 2520 | } else { |
2521 | qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2521 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2522 | } | 2522 | } |
2523 | } | 2523 | } |
2524 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2524 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2525 | addresseeLSync = getLastSyncAddressee(); | 2525 | addresseeLSync = getLastSyncAddressee(); |
2526 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2526 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2527 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2527 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2528 | if ( !addresseeR.isEmpty() ) { | 2528 | if ( !addresseeR.isEmpty() ) { |
2529 | addresseeRSync = addresseeR; | 2529 | addresseeRSync = addresseeR; |
2530 | remote->removeAddressee(addresseeR ); | 2530 | remote->removeAddressee(addresseeR ); |
2531 | 2531 | ||
2532 | } else { | 2532 | } else { |
2533 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2533 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2534 | addresseeRSync = addresseeLSync ; | 2534 | addresseeRSync = addresseeLSync ; |
2535 | } else { | 2535 | } else { |
2536 | qDebug("FULLDATE 1"); | 2536 | qDebug("FULLDATE 1"); |
2537 | fullDateRange = true; | 2537 | fullDateRange = true; |
@@ -2607,33 +2607,34 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2607 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2607 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2608 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2608 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2609 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2609 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2610 | local->insertAddressee( inL, false ); | 2610 | local->insertAddressee( inL, false ); |
2611 | idS = inR.externalUID(); | 2611 | idS = inR.externalUID(); |
2612 | OidS = inR.originalExternalUID(); | 2612 | OidS = inR.originalExternalUID(); |
2613 | } | 2613 | } |
2614 | else | 2614 | else |
2615 | idS = inR.IDStr(); | 2615 | idS = inR.IDStr(); |
2616 | remote->removeAddressee( inR ); | 2616 | remote->removeAddressee( inR ); |
2617 | inR = inL; | 2617 | inR = inL; |
2618 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2618 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2619 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2619 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2620 | inR.setOriginalExternalUID( OidS ); | 2620 | inR.setOriginalExternalUID( OidS ); |
2621 | inR.setExternalUID( idS ); | 2621 | inR.setExternalUID( idS ); |
2622 | if ( syncManager->syncWithDesktop() ) | 2622 | if ( syncManager->syncWithDesktop() ) |
2623 | inR.setIDStr( "changed" ); | 2623 | inR.setIDStr("changed" ); |
2624 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | ||
2624 | } else { | 2625 | } else { |
2625 | inR.setIDStr( idS ); | 2626 | inR.setIDStr( idS ); |
2626 | } | 2627 | } |
2627 | inR.setResource( 0 ); | 2628 | inR.setResource( 0 ); |
2628 | remote->insertAddressee( inR , false); | 2629 | remote->insertAddressee( inR , false); |
2629 | ++changedRemote; | 2630 | ++changedRemote; |
2630 | } else { // take == 2 take remote | 2631 | } else { // take == 2 take remote |
2631 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2632 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2632 | if ( inR.revision().date().year() < 2004 ) | 2633 | if ( inR.revision().date().year() < 2004 ) |
2633 | inR.setRevision( modifiedCalendar ); | 2634 | inR.setRevision( modifiedCalendar ); |
2634 | } | 2635 | } |
2635 | idS = inL.IDStr(); | 2636 | idS = inL.IDStr(); |
2636 | local->removeAddressee( inL ); | 2637 | local->removeAddressee( inL ); |
2637 | inL = inR; | 2638 | inL = inR; |
2638 | inL.setIDStr( idS ); | 2639 | inL.setIDStr( idS ); |
2639 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2640 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
@@ -2799,73 +2800,74 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | |||
2799 | } | 2800 | } |
2800 | } | 2801 | } |
2801 | //AddressBook::Iterator it; | 2802 | //AddressBook::Iterator it; |
2802 | //QStringList vcards; | 2803 | //QStringList vcards; |
2803 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2804 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2804 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2805 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2805 | //} | 2806 | //} |
2806 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2807 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2807 | if ( syncOK ) { | 2808 | if ( syncOK ) { |
2808 | if ( syncManager->mWriteBackFile ) | 2809 | if ( syncManager->mWriteBackFile ) |
2809 | { | 2810 | { |
2810 | if ( external ) | 2811 | if ( external ) |
2811 | abLocal.removeSyncAddressees( !isXML); | 2812 | abLocal.removeSyncAddressees( !isXML); |
2812 | qDebug("Saving remote AB "); | 2813 | qDebug("Saving remote AB "); |
2813 | if ( ! abLocal.saveAB()) | 2814 | if ( ! abLocal.saveAB()) |
2814 | qDebug("Error writing back AB to file "); | 2815 | qDebug("Error writing back AB to file "); |
2815 | if ( isXML ) { | 2816 | if ( external ) { |
2816 | // afterwrite processing | 2817 | // afterwrite processing |
2817 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2818 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
2818 | } | 2819 | } |
2819 | } | 2820 | } |
2820 | } | 2821 | } |
2821 | setModified(); | 2822 | setModified(); |
2822 | 2823 | ||
2823 | } | 2824 | } |
2824 | if ( syncOK ) | 2825 | if ( syncOK ) |
2825 | mViewManager->refreshView(); | 2826 | mViewManager->refreshView(); |
2826 | return syncOK; | 2827 | return syncOK; |
2827 | 2828 | ||
2828 | } | 2829 | } |
2829 | void KABCore::removeSyncInfo( QString syncProfile) | 2830 | void KABCore::removeSyncInfo( QString syncProfile) |
2830 | { | 2831 | { |
2831 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 2832 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
2832 | mAddressBook->removeSyncInfo( syncProfile ); | 2833 | mAddressBook->removeSyncInfo( syncProfile ); |
2834 | setModified(); | ||
2833 | } | 2835 | } |
2834 | 2836 | ||
2835 | 2837 | ||
2836 | //this is a overwritten callbackmethods from the syncinterface | 2838 | //this is a overwritten callbackmethods from the syncinterface |
2837 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2839 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2838 | { | 2840 | { |
2839 | if ( resource == "phone" ) | 2841 | if ( resource == "phone" ) |
2840 | return syncPhone(); | 2842 | return syncPhone(); |
2841 | disableBR( true ); | 2843 | disableBR( true ); |
2842 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2844 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2843 | 2845 | ||
2844 | AddressBook abLocal( resource,"syncContact"); | 2846 | AddressBook abLocal( resource,"syncContact"); |
2845 | bool syncOK = false; | 2847 | bool syncOK = false; |
2846 | if ( abLocal.load() ) { | 2848 | if ( abLocal.load() ) { |
2847 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2849 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2848 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2850 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2849 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 2851 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
2850 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2852 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2851 | if ( syncOK ) { | 2853 | if ( syncOK ) { |
2852 | if ( syncManager->mWriteBackFile ) { | 2854 | if ( syncManager->mWriteBackFile ) { |
2853 | abLocal.removeSyncAddressees( false ); | 2855 | abLocal.removeSyncAddressees( false ); |
2854 | abLocal.saveAB(); | 2856 | abLocal.saveAB(); |
2855 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2857 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
2856 | } | 2858 | } |
2857 | } | 2859 | } |
2858 | setModified(); | 2860 | setModified(); |
2859 | } | 2861 | } |
2860 | if ( syncOK ) | 2862 | if ( syncOK ) |
2861 | mViewManager->refreshView(); | 2863 | mViewManager->refreshView(); |
2862 | disableBR( false ); | 2864 | disableBR( false ); |
2863 | return syncOK; | 2865 | return syncOK; |
2864 | 2866 | ||
2865 | } | 2867 | } |
2866 | void KABCore::message( QString m ) | 2868 | void KABCore::message( QString m ) |
2867 | { | 2869 | { |
2868 | topLevelWidget()->setCaption( m ); | 2870 | topLevelWidget()->setCaption( m ); |
2869 | mMessageTimer->start( 15000, true ); | 2871 | mMessageTimer->start( 15000, true ); |
2870 | } | 2872 | } |
2871 | bool KABCore::syncPhone() | 2873 | bool KABCore::syncPhone() |
@@ -2878,33 +2880,33 @@ bool KABCore::syncPhone() | |||
2878 | } | 2880 | } |
2879 | AddressBook abLocal( fileName,"syncContact"); | 2881 | AddressBook abLocal( fileName,"syncContact"); |
2880 | bool syncOK = false; | 2882 | bool syncOK = false; |
2881 | { | 2883 | { |
2882 | abLocal.importFromFile( fileName ); | 2884 | abLocal.importFromFile( fileName ); |
2883 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2885 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2884 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2886 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2885 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 2887 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
2886 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2888 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2887 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2889 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2888 | if ( syncOK ) { | 2890 | if ( syncOK ) { |
2889 | if ( syncManager->mWriteBackFile ) { | 2891 | if ( syncManager->mWriteBackFile ) { |
2890 | abLocal.removeSyncAddressees( true ); | 2892 | abLocal.removeSyncAddressees( true ); |
2891 | abLocal.saveABphone( fileName ); | 2893 | abLocal.saveABphone( fileName ); |
2892 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 2894 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
2893 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 2895 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
2894 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2896 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
2895 | } | 2897 | } |
2896 | } | 2898 | } |
2897 | setModified(); | 2899 | setModified(); |
2898 | } | 2900 | } |
2899 | if ( syncOK ) | 2901 | if ( syncOK ) |
2900 | mViewManager->refreshView(); | 2902 | mViewManager->refreshView(); |
2901 | return syncOK; | 2903 | return syncOK; |
2902 | } | 2904 | } |
2903 | void KABCore::getFile( bool success ) | 2905 | void KABCore::getFile( bool success ) |
2904 | { | 2906 | { |
2905 | if ( ! success ) { | 2907 | if ( ! success ) { |
2906 | message( i18n("Error receiving file. Nothing changed!") ); | 2908 | message( i18n("Error receiving file. Nothing changed!") ); |
2907 | return; | 2909 | return; |
2908 | } | 2910 | } |
2909 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2911 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2910 | if ( count ) | 2912 | if ( count ) |