-rw-r--r-- | kabc/plugins/file/resourcefile.cpp | 3 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 48 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmconverter.cpp | 17 |
3 files changed, 61 insertions, 7 deletions
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp index b8c32d5..6cd63fd 100644 --- a/kabc/plugins/file/resourcefile.cpp +++ b/kabc/plugins/file/resourcefile.cpp @@ -164,4 +164,5 @@ bool ResourceFile::doOpen() { QFile file( mFileName ); + qDebug("ResourceFile::openfile %s ", mFileName.latin1()); if ( !file.exists() ) { @@ -195,5 +196,5 @@ bool ResourceFile::load() { - + qDebug("ResourceFile::loadfile %s ", mFileName.latin1()); QFile file( mFileName ); if ( !file.open( IO_ReadOnly ) ) { 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 @@ -205,4 +205,7 @@ bool ResourceSharpDTM::save( Ticket *ticket ) bool res; KABC::Addressee::List changedAddressees; + typedef QMap<int,QString> AddresseeMap; + AddresseeMap map; + CardId id ; for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { @@ -210,5 +213,4 @@ bool ResourceSharpDTM::save( Ticket *ticket ) if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { QString uid = (*it).originalExternalUID(); - CardId id ; bool res; if ( uid.isEmpty() ) @@ -224,8 +226,15 @@ bool ResourceSharpDTM::save( Ticket *ticket ) 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); @@ -233,4 +242,5 @@ bool ResourceSharpDTM::save( Ticket *ticket ) addressee.setOriginalExternalUID( QString::number( id ) ); changedAddressees.append( addressee ); +#endif if (res == false) @@ -262,4 +272,9 @@ bool ResourceSharpDTM::save( Ticket *ticket ) 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 ); @@ -268,4 +283,5 @@ bool ResourceSharpDTM::save( Ticket *ticket ) changedAddressees.append( addressee ); res = mAccess->finishEditCard(&id); +#endif if (res == false) qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); @@ -282,7 +298,33 @@ 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(); diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp index f3bf2c5..fccf625 100644 --- a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp +++ b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp @@ -287,6 +287,17 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); - database->writeField(ZdbAdrs::FileAs, addr.formattedName()); - database->writeField(ZdbAdrs::FullName, addr.formattedName()); + QString formattedName = addr.formattedName(); + if ( formattedName.isEmpty() ) { + if ( !addr.familyName().isEmpty() ) { + formattedName = addr.familyName(); + if ( !addr.givenName().isEmpty() ) { + formattedName += ", "; + formattedName += addr.givenName(); + } + } else + formattedName = addr.givenName(); + } + database->writeField(ZdbAdrs::FileAs, formattedName); + database->writeField(ZdbAdrs::FullName, formattedName); // email @@ -350,5 +361,5 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da } PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell ); - if (!businessmobile.number().isEmpty()) { + if (! mobile.number().isEmpty()) { if ( ! cellHome ) database->writeField(ZdbAdrs::HomeMobile, mobile.number()); |