summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kabc/plugins/file/resourcefile.cpp3
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.cpp48
-rw-r--r--kabc/plugins/sharpdtm/sharpdtmconverter.cpp17
-rw-r--r--kaddressbook/kabcore.cpp5
-rw-r--r--korganizer/calendarview.cpp4
5 files changed, 70 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
@@ -163,6 +163,7 @@ Ticket *ResourceFile::requestSaveTicket()
163bool ResourceFile::doOpen() 163bool ResourceFile::doOpen()
164{ 164{
165 QFile file( mFileName ); 165 QFile file( mFileName );
166 qDebug("ResourceFile::openfile %s ", mFileName.latin1());
166 167
167 if ( !file.exists() ) { 168 if ( !file.exists() ) {
168 // try to create the file 169 // try to create the file
@@ -194,7 +195,7 @@ void ResourceFile::doClose()
194bool ResourceFile::load() 195bool ResourceFile::load()
195{ 196{
196 197
197 198 qDebug("ResourceFile::loadfile %s ", mFileName.latin1());
198 QFile file( mFileName ); 199 QFile file( mFileName );
199 if ( !file.open( IO_ReadOnly ) ) { 200 if ( !file.open( IO_ReadOnly ) ) {
200 addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) ); 201 addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) );
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 )
204 KABC::AddressBook::Iterator it; 204 KABC::AddressBook::Iterator it;
205 bool res; 205 bool res;
206 KABC::Addressee::List changedAddressees; 206 KABC::Addressee::List changedAddressees;
207 typedef QMap<int,QString> AddresseeMap;
208 AddresseeMap map;
209 CardId id ;
207 210
208 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { 211 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
209 212
210 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 213 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
211 QString uid = (*it).originalExternalUID(); 214 QString uid = (*it).originalExternalUID();
212 CardId id ;
213 bool res; 215 bool res;
214 if ( uid.isEmpty() ) 216 if ( uid.isEmpty() )
215 id = 0; 217 id = 0;
@@ -223,15 +225,23 @@ bool ResourceSharpDTM::save( Ticket *ticket )
223 res = mConverter->addresseeToSharp( (*it), mAccess, id ); 225 res = mConverter->addresseeToSharp( (*it), mAccess, id );
224 if (res == true) 226 if (res == true)
225 { 227 {
228 res = mAccess->finishEditCard(&id);
229 //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
230 //(*it).setExternalUID( QString::number( id ) );
231 //(*it).setOriginalExternalUID( QString::number( id ) );
232 map.insert(id,(*it).uid());
233
234#if 0
226 KABC::Addressee addressee; 235 KABC::Addressee addressee;
227 res = mConverter->sharpToAddressee( id, mAccess, addressee ); 236 res = mConverter->sharpToAddressee( id, mAccess, addressee );
228 addressee.setUid((*it).uid() ); 237 addressee.setUid((*it).uid() );
229 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 238 (it*).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
230 res = mAccess->finishEditCard(&id); 239 res = mAccess->finishEditCard(&id);
231 //qDebug("2NEW id is %d", id); 240 //qDebug("2NEW id is %d", id);
232 addressee.setExternalUID( QString::number( id ) ); 241 addressee.setExternalUID( QString::number( id ) );
233 addressee.setOriginalExternalUID( QString::number( id ) ); 242 addressee.setOriginalExternalUID( QString::number( id ) );
234 changedAddressees.append( addressee ); 243 changedAddressees.append( addressee );
244#endif
235 245
236 if (res == false) 246 if (res == false)
237 qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); 247 qDebug("Unable to append Contact: %s", addressee.formattedName().latin1());
@@ -261,12 +271,18 @@ bool ResourceSharpDTM::save( Ticket *ticket )
261 res = mConverter->addresseeToSharp( (*it), mAccess, id ); 271 res = mConverter->addresseeToSharp( (*it), mAccess, id );
262 if (res == true) 272 if (res == true)
263 { 273 {
274 res = mAccess->finishEditCard(&id);
275 //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
276 map.insert(id,(*it).uid());
277
278#if 0
264 KABC::Addressee addressee; 279 KABC::Addressee addressee;
265 res = mConverter->sharpToAddressee( id, mAccess, addressee ); 280 res = mConverter->sharpToAddressee( id, mAccess, addressee );
266 addressee.setUid((*it).uid() ); 281 addressee.setUid((*it).uid() );
267 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); 282 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
268 changedAddressees.append( addressee ); 283 changedAddressees.append( addressee );
269 res = mAccess->finishEditCard(&id); 284 res = mAccess->finishEditCard(&id);
285#endif
270 if (res == false) 286 if (res == false)
271 qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); 287 qDebug("Unable to append Contact: %s", addressee.formattedName().latin1());
272 288
@@ -281,9 +297,35 @@ bool ResourceSharpDTM::save( Ticket *ticket )
281 } 297 }
282 298
283 } 299 }
300 AddresseeMap::Iterator itam;
301 res;
302 for ( res=mAccess->first(); res == true; res=mAccess->next())
303 {
304 id = mAccess->cardId();
305 int idint = id;
306 itam = map.find( idint );
307 if ( itam != map.end() ) {
308 KABC::Addressee addressee;
309 qDebug("found change %d %s ", idint, itam.data().latin1());
310 res = mConverter->sharpToAddressee( id, mAccess, addressee );
311
312 if ( !addressee.isEmpty() && res )
313 {
314 addressee.setResource( this );
315 addressee.setUid( itam.data() );
316 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
317 addressBook()->insertAddressee( addressee , false );
318 }
319 }
320 }
321#if 0
284 KABC::Addressee::List::Iterator it2; 322 KABC::Addressee::List::Iterator it2;
285 for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 ) 323 for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 ) {
324 (*it2).computeCsum( "Sharp_DTM" );
325 qDebug("CSUM: %s ",(*it2).getCsum( "Sharp_DTM" ).latin1() );
286 addressBook()->insertAddressee((*it2)); 326 addressBook()->insertAddressee((*it2));
327 }
328#endif
287 //US mAccess->save(); 329 //US mAccess->save();
288 330
289 mDirWatch.startScan(); 331 mDirWatch.startScan();
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
@@ -286,8 +286,19 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da
286 database->writeField(ZdbAdrs::Suffix, addr.suffix()); 286 database->writeField(ZdbAdrs::Suffix, addr.suffix());
287 287
288 //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); 288 //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() );
289 database->writeField(ZdbAdrs::FileAs, addr.formattedName()); 289 QString formattedName = addr.formattedName();
290 database->writeField(ZdbAdrs::FullName, addr.formattedName()); 290 if ( formattedName.isEmpty() ) {
291 if ( !addr.familyName().isEmpty() ) {
292 formattedName = addr.familyName();
293 if ( !addr.givenName().isEmpty() ) {
294 formattedName += ", ";
295 formattedName += addr.givenName();
296 }
297 } else
298 formattedName = addr.givenName();
299 }
300 database->writeField(ZdbAdrs::FileAs, formattedName);
301 database->writeField(ZdbAdrs::FullName, formattedName);
291 302
292 // email 303 // email
293 //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); 304 //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!");
@@ -349,7 +360,7 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da
349 database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number()); 360 database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number());
350 } 361 }
351 PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell ); 362 PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell );
352 if (!businessmobile.number().isEmpty()) { 363 if (! mobile.number().isEmpty()) {
353 if ( ! cellHome ) 364 if ( ! cellHome )
354 database->writeField(ZdbAdrs::HomeMobile, mobile.number()); 365 database->writeField(ZdbAdrs::HomeMobile, mobile.number());
355 else if (! cellWork ) 366 else if (! cellWork )
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index c1ead9d..c2f031a 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2769,6 +2769,7 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2769 if ( take == 1 ) {// take local 2769 if ( take == 1 ) {// take local
2770 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2770 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2771 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2771 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2772 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2772 local->insertAddressee( inL, false ); 2773 local->insertAddressee( inL, false );
2773 idS = inR.externalUID(); 2774 idS = inR.externalUID();
2774 OidS = inR.originalExternalUID(); 2775 OidS = inR.originalExternalUID();
@@ -2796,6 +2797,10 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2796 local->removeAddressee( inL ); 2797 local->removeAddressee( inL );
2797 inL = inR; 2798 inL = inR;
2798 inL.setIDStr( idS ); 2799 inL.setIDStr( idS );
2800 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2801 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2802 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2803 }
2799 inL.setResource( 0 ); 2804 inL.setResource( 0 );
2800 local->insertAddressee( inL , false ); 2805 local->insertAddressee( inL , false );
2801 ++changedLocal; 2806 ++changedLocal;
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index bbed05b..7fae4a9 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1049,6 +1049,10 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1049 local->deleteIncidence( inL ); 1049 local->deleteIncidence( inL );
1050 inL = inR->clone(); 1050 inL = inR->clone();
1051 inL->setIDStr( idS ); 1051 inL->setIDStr( idS );
1052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1053 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1054 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1055 }
1052 local->addIncidence( inL ); 1056 local->addIncidence( inL );
1053 ++changedLocal; 1057 ++changedLocal;
1054 } 1058 }