author | zautrix <zautrix> | 2004-10-27 10:36:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-27 10:36:51 (UTC) |
commit | ce5b6b62c92cc051c5c9e780508b6d42c46df8ed (patch) (side-by-side diff) | |
tree | 257fa9c582c6f8c0bd1948a04e8f4083862932a8 /kabc/addressbook.cpp | |
parent | 835411009ea43a8182b16b78c03b11616f989f50 (diff) | |
download | kdepimpi-ce5b6b62c92cc051c5c9e780508b6d42c46df8ed.zip kdepimpi-ce5b6b62c92cc051c5c9e780508b6d42c46df8ed.tar.gz kdepimpi-ce5b6b62c92cc051c5c9e780508b6d42c46df8ed.tar.bz2 |
fixed remove sync info
-rw-r--r-- | kabc/addressbook.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 2785131..df0fba4 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -498,128 +498,149 @@ int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool remo list = tool.parseVCards( data ); KABC::Addressee::List::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); if ( !id.isEmpty() ) (*it).setIDStr(id ); (*it).setResource( 0 ); if ( replaceLabel ) (*it).removeVoice(); if ( removeOld ) (*it).setTagged( true ); insertAddressee( (*it), false, true ); } if ( removeOld ) removeUntagged(); return list.count(); } void AddressBook::setUntagged(bool setNonSyncTagged) // = false) { Iterator ait; for ( ait = begin(); ait != end(); ++ait ) { if ( setNonSyncTagged ) { if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { (*ait).setTagged( true ); } else (*ait).setTagged( false ); } else (*ait).setTagged( false ); } } void AddressBook::removeUntagged() { Iterator ait; bool todelete = false; Iterator todel; for ( ait = begin(); ait != end(); ++ait ) { if ( todelete ) removeAddressee( todel ); if (!(*ait).tagged()) { todelete = true; todel = ait; } else todelete = false; } if ( todelete ) removeAddressee( todel ); deleteRemovedAddressees(); } void AddressBook::smplifyAddressees() { Iterator ait; for ( ait = begin(); ait != end(); ++ait ) { (*ait).simplifyEmails(); (*ait).simplifyPhoneNumbers(); (*ait).simplifyPhoneNumberTypes(); (*ait).simplifyAddresses(); } } void AddressBook::removeSyncInfo( QString syncProfile) { Iterator ait; for ( ait = begin(); ait != end(); ++ait ) { (*ait).removeID( syncProfile ); } + if ( syncProfile.isEmpty() ) { + Iterator it = begin(); + Iterator it2 ; + QDateTime dt ( QDate( 2004,1,1) ); + while ( it != end() ) { + if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { + it2 = it; + //qDebug("removing %s ",(*it).uid().latin1() ); + ++it; + removeAddressee( it2 ); + } else { + //qDebug("skipping %s ",(*it).uid().latin1() ); + ++it; + } + } + } else { + Addressee lse; + lse = mAddressBook->findByUid( "last-syncAddressee-"+ syncProfile ); + if ( ! lse.isEmpty() ) + removeAddressee( lse ); + } } void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) { Iterator ait; for ( ait = begin(); ait != end(); ++ait ) { QString id = (*ait).IDStr(); (*ait).setIDStr( ":"); (*ait).setExternalUID( id ); (*ait).setOriginalExternalUID( id ); if ( isPreSync ) (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); else { (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); (*ait).setID( currentSyncDevice,id ); } } } void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) { setUntagged(); KABC::Addressee::List list; QFile file( fileName ); file.open( IO_ReadOnly ); QByteArray rawData = file.readAll(); file.close(); QString data; data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); KABC::VCardTool tool; list = tool.parseVCards( data ); KABC::Addressee::List::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { Iterator ait; for ( ait = begin(); ait != end(); ++ait ) { if ( !(*ait).tagged() ) { if ( (*ait).containsAdr(*it)) { (*ait).setTagged(true); QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); (*it).setIDStr( ":"); (*it).setID( currentSyncDevice,id ); (*it).setExternalUID( id ); (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); (*it).setUid( ( (*ait).uid() )); break; } } } if ( ait == end() ) qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); } clear(); for ( it = list.begin(); it != list.end(); ++it ) { insertAddressee( (*it) ); } } bool AddressBook::saveABphone( QString fileName ) { //smplifyAddressees(); qDebug("saveABphone:: saving AB... "); |