-rw-r--r-- | kabc/addressee.cpp | 23 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmconverter.cpp | 20 |
2 files changed, 29 insertions, 14 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 3b238f5..82b4b9b 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -281,41 +281,47 @@ void Addressee::computeCsum(const QString &dev) | |||
281 | 281 | ||
282 | setCsum( dev, QString::number (cs )); | 282 | setCsum( dev, QString::number (cs )); |
283 | } | 283 | } |
284 | 284 | ||
285 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 285 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
286 | { | 286 | { |
287 | // merge all standard non-outlook fields. | ||
288 | //if isSubSet (e.g. mobile phone sync) merge all fields | ||
287 | 289 | ||
288 | detach(); | 290 | detach(); |
291 | if ( isSubSet ) { | ||
289 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 292 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
290 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 293 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
291 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 294 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
292 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 295 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
293 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 296 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
294 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 297 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
295 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 298 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
299 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | ||
300 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | ||
296 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 301 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
302 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | ||
303 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | ||
304 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | ||
305 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | ||
297 | if ( !mData->birthday.isValid() ) | 306 | if ( !mData->birthday.isValid() ) |
298 | if ( ad.mData->birthday.isValid()) | 307 | if ( ad.mData->birthday.isValid()) |
299 | mData->birthday = ad.mData->birthday; | 308 | mData->birthday = ad.mData->birthday; |
309 | |||
310 | } | ||
300 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 311 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
301 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 312 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
302 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 313 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
303 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | ||
304 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | ||
305 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | ||
306 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | ||
307 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 314 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
308 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 315 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
309 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | ||
310 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | ||
311 | QStringList t; | 316 | QStringList t; |
312 | QStringList tAD; | 317 | QStringList tAD; |
313 | uint iii; | 318 | uint iii; |
314 | 319 | ||
315 | // ********** phone numbers | 320 | // ********** phone numbers |
321 | if ( isSubSet ) { | ||
316 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 322 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
317 | PhoneNumber::List::Iterator phoneItAD; | 323 | PhoneNumber::List::Iterator phoneItAD; |
318 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 324 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
319 | bool found = false; | 325 | bool found = false; |
320 | PhoneNumber::List::Iterator it; | 326 | PhoneNumber::List::Iterator it; |
321 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 327 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
@@ -327,27 +333,30 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | |||
327 | } | 333 | } |
328 | } | 334 | } |
329 | // if ( isSubSet && ! found ) | 335 | // if ( isSubSet && ! found ) |
330 | if ( ! found ) // LR try this one... | 336 | if ( ! found ) // LR try this one... |
331 | mData->phoneNumbers.append( *phoneItAD ); | 337 | mData->phoneNumbers.append( *phoneItAD ); |
332 | } | 338 | } |
339 | } | ||
333 | if ( isSubSet ) { | 340 | if ( isSubSet ) { |
334 | // ************* emails; | 341 | // ************* emails; |
335 | t = mData->emails; | 342 | t = mData->emails; |
336 | tAD = ad.mData->emails; | 343 | tAD = ad.mData->emails; |
337 | for ( iii = 0; iii < tAD.count(); ++iii) | 344 | for ( iii = 0; iii < tAD.count(); ++iii) |
338 | if ( !t.contains(tAD[iii] ) ) | 345 | if ( !t.contains(tAD[iii] ) ) |
339 | mData->emails.append( tAD[iii] ); | 346 | mData->emails.append( tAD[iii] ); |
340 | } | 347 | } |
341 | 348 | ||
342 | // ************* categories; | 349 | // ************* categories; |
350 | if ( isSubSet ) { | ||
343 | t = mData->categories; | 351 | t = mData->categories; |
344 | tAD = ad.mData->categories; | 352 | tAD = ad.mData->categories; |
345 | for ( iii = 0; iii < tAD.count(); ++iii) | 353 | for ( iii = 0; iii < tAD.count(); ++iii) |
346 | if ( !t.contains(tAD[iii] ) ) | 354 | if ( !t.contains(tAD[iii] ) ) |
347 | mData->categories.append( tAD[iii] ); | 355 | mData->categories.append( tAD[iii] ); |
356 | } | ||
348 | QStringList::ConstIterator it; | 357 | QStringList::ConstIterator it; |
349 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 358 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
350 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 359 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
351 | bool found = false; | 360 | bool found = false; |
352 | QStringList::ConstIterator itL; | 361 | QStringList::ConstIterator itL; |
353 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 362 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
@@ -386,12 +395,13 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | |||
386 | } | 395 | } |
387 | if ( ! found ) { | 396 | if ( ! found ) { |
388 | mData->keys.append( *itA ); | 397 | mData->keys.append( *itA ); |
389 | } | 398 | } |
390 | } | 399 | } |
391 | } | 400 | } |
401 | if ( isSubSet ) { | ||
392 | KABC::Address::List::Iterator addressIterA; | 402 | KABC::Address::List::Iterator addressIterA; |
393 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 403 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
394 | bool found = false; | 404 | bool found = false; |
395 | KABC::Address::List::Iterator addressIter; | 405 | KABC::Address::List::Iterator addressIter; |
396 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 406 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
397 | ++addressIter ) { | 407 | ++addressIter ) { |
@@ -403,12 +413,13 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | |||
403 | 413 | ||
404 | } | 414 | } |
405 | if ( isSubSet && ! found ) { | 415 | if ( isSubSet && ! found ) { |
406 | mData->addresses.append( *addressIterA ); | 416 | mData->addresses.append( *addressIterA ); |
407 | } | 417 | } |
408 | } | 418 | } |
419 | } | ||
409 | //qDebug("merge contact %s ", ad.uid().latin1()); | 420 | //qDebug("merge contact %s ", ad.uid().latin1()); |
410 | setUid( ad.uid() ); | 421 | setUid( ad.uid() ); |
411 | setRevision( ad.revision() ); | 422 | setRevision( ad.revision() ); |
412 | } | 423 | } |
413 | 424 | ||
414 | bool Addressee::removeVoice() | 425 | bool Addressee::removeVoice() |
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp index ae4cfbb..8165b4c 100644 --- a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp +++ b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp | |||
@@ -77,13 +77,14 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa | |||
77 | addr.setOriginalExternalUID( QString::number( contact ) ); | 77 | addr.setOriginalExternalUID( QString::number( contact ) ); |
78 | addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 78 | addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
79 | 79 | ||
80 | 80 | ||
81 | // name | 81 | // name |
82 | //qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!"); | 82 | //qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!"); |
83 | addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); // needs fix | 83 | addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); |
84 | addr.setName(db->readField(ZdbAdrs::FullName)); | ||
84 | 85 | ||
85 | addr.setFamilyName( db->readField(ZdbAdrs::LastName) ); | 86 | addr.setFamilyName( db->readField(ZdbAdrs::LastName) ); |
86 | addr.setGivenName( db->readField(ZdbAdrs::FirstName) ); | 87 | addr.setGivenName( db->readField(ZdbAdrs::FirstName) ); |
87 | addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) ); | 88 | addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) ); |
88 | addr.setPrefix( db->readField(ZdbAdrs::Title) ); | 89 | addr.setPrefix( db->readField(ZdbAdrs::Title) ); |
89 | addr.setSuffix( db->readField(ZdbAdrs::Suffix) ); | 90 | addr.setSuffix( db->readField(ZdbAdrs::Suffix) ); |
@@ -219,25 +220,28 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa | |||
219 | //personal | 220 | //personal |
220 | addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) ); | 221 | addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) ); |
221 | 222 | ||
222 | QString gen = db->readField(ZdbAdrs::Gender); | 223 | QString gen = db->readField(ZdbAdrs::Gender); |
223 | //qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1()); | 224 | //qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1()); |
224 | //qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited"); | 225 | //qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited"); |
225 | 226 | if (gen == "1") | |
226 | if (gen == "male") | ||
227 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); | 227 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); |
228 | else if (gen == "female") | 228 | else if (gen == "2") |
229 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); | 229 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); |
230 | else | ||
231 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "undef"); | ||
230 | 232 | ||
231 | 233 | ||
232 | QDate ann = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Anniversary) ); | 234 | QDate ann = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Anniversary) ); |
233 | if (ann.isValid()) { | 235 | if (ann.isValid()) { |
234 | QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); | 236 | QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); |
235 | //qDebug("qtopiaToAddressee annyversary found:%s", dt.latin1()); | 237 | //qDebug("qtopiaToAddressee annyversary found:%s", dt.latin1()); |
236 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | 238 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); |
237 | } | 239 | } else |
240 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", " "); | ||
241 | |||
238 | 242 | ||
239 | 243 | ||
240 | addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) ); | 244 | addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) ); |
241 | 245 | ||
242 | 246 | ||
243 | QDate birthd = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Birthday) ); | 247 | QDate birthd = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Birthday) ); |
@@ -295,13 +299,13 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da | |||
295 | formattedName += addr.givenName(); | 299 | formattedName += addr.givenName(); |
296 | } | 300 | } |
297 | } else | 301 | } else |
298 | formattedName = addr.givenName(); | 302 | formattedName = addr.givenName(); |
299 | } | 303 | } |
300 | database->writeField(ZdbAdrs::FileAs, formattedName); | 304 | database->writeField(ZdbAdrs::FileAs, formattedName); |
301 | database->writeField(ZdbAdrs::FullName, formattedName); | 305 | database->writeField(ZdbAdrs::FullName, addr.name()); |
302 | 306 | ||
303 | 307 | ||
304 | //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); | 308 | //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); |
305 | //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); | 309 | //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); |
306 | QString emails = addr.emails().join(" "); | 310 | QString emails = addr.emails().join(" "); |
307 | database->writeField(ZdbAdrs::Emails, emails ); | 311 | database->writeField(ZdbAdrs::Emails, emails ); |
@@ -370,15 +374,15 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da | |||
370 | 374 | ||
371 | QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); | 375 | QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); |
372 | //qDebug("SharpDTMConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1()); | 376 | //qDebug("SharpDTMConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1()); |
373 | //qDebug("SharpDTMConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?"); | 377 | //qDebug("SharpDTMConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?"); |
374 | //qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee"); | 378 | //qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee"); |
375 | if (gt == "male") | 379 | if (gt == "male") |
376 | database->writeField(ZdbAdrs::Gender, "male"); | 380 | database->writeField(ZdbAdrs::Gender, "1"); |
377 | else if (gt == "female") | 381 | else if (gt == "female") |
378 | database->writeField(ZdbAdrs::Gender, "female"); | 382 | database->writeField(ZdbAdrs::Gender, "2"); |
379 | else | 383 | else |
380 | database->writeField(ZdbAdrs::Gender, ""); | 384 | database->writeField(ZdbAdrs::Gender, ""); |
381 | 385 | ||
382 | QString dateS ; | 386 | QString dateS ; |
383 | QDate dt = KGlobal::locale()->readDate(addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate | 387 | QDate dt = KGlobal::locale()->readDate(addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate |
384 | if ( dt.isValid() ) { | 388 | if ( dt.isValid() ) { |