author | zautrix <zautrix> | 2004-09-21 10:08:57 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-21 10:08:57 (UTC) |
commit | 19f445f0b6e7d4591db46b89e877ed9f4332ecd4 (patch) (side-by-side diff) | |
tree | fd21a5dc32332060197d792552ef1eb469e92175 /kabc/plugins/sharpdtm/resourcesharpdtm.cpp | |
parent | 1cf4cc6e7bf25ee309852c7c97155de86917289f (diff) | |
download | kdepimpi-19f445f0b6e7d4591db46b89e877ed9f4332ecd4.zip kdepimpi-19f445f0b6e7d4591db46b89e877ed9f4332ecd4.tar.gz kdepimpi-19f445f0b6e7d4591db46b89e877ed9f4332ecd4.tar.bz2 |
more sync fixes
Diffstat (limited to 'kabc/plugins/sharpdtm/resourcesharpdtm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index 48d3985..437bda8 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp @@ -204,12 +204,14 @@ bool ResourceSharpDTM::save( Ticket *ticket ) KABC::AddressBook::Iterator it; bool res; KABC::Addressee::List changedAddressees; + typedef QMap<int,QString> AddresseeMap; + AddresseeMap map; + CardId id ; for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { QString uid = (*it).originalExternalUID(); - CardId id ; bool res; if ( uid.isEmpty() ) id = 0; @@ -223,15 +225,23 @@ bool ResourceSharpDTM::save( Ticket *ticket ) res = mConverter->addresseeToSharp( (*it), mAccess, id ); if (res == true) { + res = mAccess->finishEditCard(&id); + //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); + //(*it).setExternalUID( QString::number( id ) ); + //(*it).setOriginalExternalUID( QString::number( id ) ); + map.insert(id,(*it).uid()); + +#if 0 KABC::Addressee addressee; res = mConverter->sharpToAddressee( id, mAccess, addressee ); addressee.setUid((*it).uid() ); - addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); + (it*).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); res = mAccess->finishEditCard(&id); //qDebug("2NEW id is %d", id); addressee.setExternalUID( QString::number( id ) ); addressee.setOriginalExternalUID( QString::number( id ) ); changedAddressees.append( addressee ); +#endif if (res == false) qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); @@ -261,12 +271,18 @@ bool ResourceSharpDTM::save( Ticket *ticket ) res = mConverter->addresseeToSharp( (*it), mAccess, id ); if (res == true) { + res = mAccess->finishEditCard(&id); + //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); + map.insert(id,(*it).uid()); + +#if 0 KABC::Addressee addressee; res = mConverter->sharpToAddressee( id, mAccess, addressee ); addressee.setUid((*it).uid() ); addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); changedAddressees.append( addressee ); res = mAccess->finishEditCard(&id); +#endif if (res == false) qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); @@ -281,9 +297,35 @@ bool ResourceSharpDTM::save( Ticket *ticket ) } } + AddresseeMap::Iterator itam; + res; + for ( res=mAccess->first(); res == true; res=mAccess->next()) + { + id = mAccess->cardId(); + int idint = id; + itam = map.find( idint ); + if ( itam != map.end() ) { + KABC::Addressee addressee; + qDebug("found change %d %s ", idint, itam.data().latin1()); + res = mConverter->sharpToAddressee( id, mAccess, addressee ); + + if ( !addressee.isEmpty() && res ) + { + addressee.setResource( this ); + addressee.setUid( itam.data() ); + addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); + addressBook()->insertAddressee( addressee , false ); + } + } + } +#if 0 KABC::Addressee::List::Iterator it2; - for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 ) + for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 ) { + (*it2).computeCsum( "Sharp_DTM" ); + qDebug("CSUM: %s ",(*it2).getCsum( "Sharp_DTM" ).latin1() ); addressBook()->insertAddressee((*it2)); + } +#endif //US mAccess->save(); mDirWatch.startScan(); |