author | zautrix <zautrix> | 2005-01-18 09:31:59 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-18 09:31:59 (UTC) |
commit | 2d6776d79732f6771885a549de5c37f9e75f7641 (patch) (unidiff) | |
tree | 5dc2abf48a99e2a35f8e1458f731b3ef9210ac7e /kabc | |
parent | 522486966ecf041a6e49913b6e420d58d4284837 (diff) | |
download | kdepimpi-2d6776d79732f6771885a549de5c37f9e75f7641.zip kdepimpi-2d6776d79732f6771885a549de5c37f9e75f7641.tar.gz kdepimpi-2d6776d79732f6771885a549de5c37f9e75f7641.tar.bz2 |
fixed merging
-rw-r--r-- | kabc/addressee.cpp | 111 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmconverter.cpp | 20 |
2 files changed, 73 insertions, 58 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 3b238f5..82b4b9b 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -239,216 +239,227 @@ void Addressee::computeCsum(const QString &dev) | |||
239 | 239 | ||
240 | QStringList t; | 240 | QStringList t; |
241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
242 | ++phoneIter ) | 242 | ++phoneIter ) |
243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
244 | t.sort(); | 244 | t.sort(); |
245 | uint iii; | 245 | uint iii; |
246 | for ( iii = 0; iii < t.count(); ++iii) | 246 | for ( iii = 0; iii < t.count(); ++iii) |
247 | l.append( t[iii] ); | 247 | l.append( t[iii] ); |
248 | t = mData->emails; | 248 | t = mData->emails; |
249 | t.sort(); | 249 | t.sort(); |
250 | for ( iii = 0; iii < t.count(); ++iii) | 250 | for ( iii = 0; iii < t.count(); ++iii) |
251 | l.append( t[iii] ); | 251 | l.append( t[iii] ); |
252 | t = mData->categories; | 252 | t = mData->categories; |
253 | t.sort(); | 253 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 254 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 255 | l.append( t[iii] ); |
256 | t = mData->custom; | 256 | t = mData->custom; |
257 | t.sort(); | 257 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 258 | for ( iii = 0; iii < t.count(); ++iii) |
259 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { | 259 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { |
260 | int find = t[iii].find (':')+1; | 260 | int find = t[iii].find (':')+1; |
261 | //qDebug("lennnn %d %d ", find, t[iii].length()); | 261 | //qDebug("lennnn %d %d ", find, t[iii].length()); |
262 | if ( find < t[iii].length()) | 262 | if ( find < t[iii].length()) |
263 | l.append( t[iii] ); | 263 | l.append( t[iii] ); |
264 | 264 | ||
265 | } | 265 | } |
266 | KABC::Address::List::Iterator addressIter; | 266 | KABC::Address::List::Iterator addressIter; |
267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
268 | ++addressIter ) { | 268 | ++addressIter ) { |
269 | t = (*addressIter).asList(); | 269 | t = (*addressIter).asList(); |
270 | t.sort(); | 270 | t.sort(); |
271 | for ( iii = 0; iii < t.count(); ++iii) | 271 | for ( iii = 0; iii < t.count(); ++iii) |
272 | l.append( t[iii] ); | 272 | l.append( t[iii] ); |
273 | } | 273 | } |
274 | uint cs = getCsum4List(l); | 274 | uint cs = getCsum4List(l); |
275 | 275 | ||
276 | #if 0 | 276 | #if 0 |
277 | for ( iii = 0; iii < l.count(); ++iii) | 277 | for ( iii = 0; iii < l.count(); ++iii) |
278 | qDebug("%d***%s***",iii,l[iii].latin1()); | 278 | qDebug("%d***%s***",iii,l[iii].latin1()); |
279 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 279 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
280 | #endif | 280 | #endif |
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(); |
289 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 291 | if ( isSubSet ) { |
290 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 292 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
291 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 293 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
292 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 294 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
293 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 295 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
294 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 296 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
295 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 297 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
296 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 298 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
297 | if ( !mData->birthday.isValid() ) | 299 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
298 | if ( ad.mData->birthday.isValid()) | 300 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
299 | mData->birthday = ad.mData->birthday; | 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 ; | ||
306 | if ( !mData->birthday.isValid() ) | ||
307 | if ( ad.mData->birthday.isValid()) | ||
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 |
316 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 321 | if ( isSubSet ) { |
317 | PhoneNumber::List::Iterator phoneItAD; | 322 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
318 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 323 | PhoneNumber::List::Iterator phoneItAD; |
319 | bool found = false; | 324 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
320 | PhoneNumber::List::Iterator it; | 325 | bool found = false; |
321 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 326 | PhoneNumber::List::Iterator it; |
322 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 327 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
323 | found = true; | 328 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
324 | (*it).setType( ( *phoneItAD ).type() ); | 329 | found = true; |
325 | (*it).setNumber( ( *phoneItAD ).number() ); | 330 | (*it).setType( ( *phoneItAD ).type() ); |
326 | break; | 331 | (*it).setNumber( ( *phoneItAD ).number() ); |
332 | break; | ||
333 | } | ||
327 | } | 334 | } |
335 | // if ( isSubSet && ! found ) | ||
336 | if ( ! found ) // LR try this one... | ||
337 | mData->phoneNumbers.append( *phoneItAD ); | ||
328 | } | 338 | } |
329 | // if ( isSubSet && ! found ) | ||
330 | if ( ! found ) // LR try this one... | ||
331 | mData->phoneNumbers.append( *phoneItAD ); | ||
332 | } | 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; |
343 | t = mData->categories; | 350 | if ( isSubSet ) { |
344 | tAD = ad.mData->categories; | 351 | t = mData->categories; |
345 | for ( iii = 0; iii < tAD.count(); ++iii) | 352 | tAD = ad.mData->categories; |
346 | if ( !t.contains(tAD[iii] ) ) | 353 | for ( iii = 0; iii < tAD.count(); ++iii) |
347 | mData->categories.append( tAD[iii] ); | 354 | if ( !t.contains(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 ) { |
354 | if ( (*itL).startsWith( qualifiedName ) ) { | 363 | if ( (*itL).startsWith( qualifiedName ) ) { |
355 | found = true; | 364 | found = true; |
356 | break; | 365 | break; |
357 | } | 366 | } |
358 | } | 367 | } |
359 | if ( ! found ) { | 368 | if ( ! found ) { |
360 | mData->custom.append( *it ); | 369 | mData->custom.append( *it ); |
361 | } | 370 | } |
362 | } | 371 | } |
363 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 372 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
364 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 373 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
365 | if ( !mData->sound.isIntern() ) { | 374 | if ( !mData->sound.isIntern() ) { |
366 | if ( mData->sound.url().isEmpty() ) { | 375 | if ( mData->sound.url().isEmpty() ) { |
367 | mData->sound = ad.mData->sound; | 376 | mData->sound = ad.mData->sound; |
368 | } | 377 | } |
369 | } | 378 | } |
370 | if ( !mData->agent.isIntern() ) { | 379 | if ( !mData->agent.isIntern() ) { |
371 | if ( mData->agent.url().isEmpty() ) { | 380 | if ( mData->agent.url().isEmpty() ) { |
372 | mData->agent = ad.mData->agent; | 381 | mData->agent = ad.mData->agent; |
373 | } | 382 | } |
374 | } | 383 | } |
375 | { | 384 | { |
376 | Key::List::Iterator itA; | 385 | Key::List::Iterator itA; |
377 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | 386 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { |
378 | bool found = false; | 387 | bool found = false; |
379 | Key::List::Iterator it; | 388 | Key::List::Iterator it; |
380 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 389 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
381 | if ( (*it) == (*itA)) { | 390 | if ( (*it) == (*itA)) { |
382 | found = true; | 391 | found = true; |
383 | break; | 392 | break; |
384 | 393 | ||
385 | } | 394 | } |
386 | } | 395 | } |
387 | if ( ! found ) { | 396 | if ( ! found ) { |
388 | mData->keys.append( *itA ); | 397 | mData->keys.append( *itA ); |
389 | } | 398 | } |
390 | } | 399 | } |
391 | } | 400 | } |
392 | KABC::Address::List::Iterator addressIterA; | 401 | if ( isSubSet ) { |
393 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 402 | KABC::Address::List::Iterator addressIterA; |
394 | bool found = false; | 403 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
395 | KABC::Address::List::Iterator addressIter; | 404 | bool found = false; |
396 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 405 | KABC::Address::List::Iterator addressIter; |
397 | ++addressIter ) { | 406 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
398 | if ( (*addressIter) == (*addressIterA)) { | 407 | ++addressIter ) { |
399 | found = true; | 408 | if ( (*addressIter) == (*addressIterA)) { |
400 | (*addressIter).setType( (*addressIterA).type() ); | 409 | found = true; |
401 | break; | 410 | (*addressIter).setType( (*addressIterA).type() ); |
402 | } | 411 | break; |
412 | } | ||
403 | 413 | ||
404 | } | 414 | } |
405 | if ( isSubSet && ! found ) { | 415 | if ( isSubSet && ! found ) { |
406 | mData->addresses.append( *addressIterA ); | 416 | mData->addresses.append( *addressIterA ); |
417 | } | ||
407 | } | 418 | } |
408 | } | 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() |
415 | { | 426 | { |
416 | PhoneNumber::List phoneN = phoneNumbers(); | 427 | PhoneNumber::List phoneN = phoneNumbers(); |
417 | PhoneNumber::List::Iterator phoneIt; | 428 | PhoneNumber::List::Iterator phoneIt; |
418 | bool found = false; | 429 | bool found = false; |
419 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 430 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
420 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 431 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
421 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 432 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
422 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 433 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
423 | insertPhoneNumber( (*phoneIt) ); | 434 | insertPhoneNumber( (*phoneIt) ); |
424 | found = true; | 435 | found = true; |
425 | } | 436 | } |
426 | } | 437 | } |
427 | 438 | ||
428 | } | 439 | } |
429 | return found; | 440 | return found; |
430 | } | 441 | } |
431 | 442 | ||
432 | bool Addressee::containsAdr(const Addressee& ad ) | 443 | bool Addressee::containsAdr(const Addressee& ad ) |
433 | { | 444 | { |
434 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; | 445 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; |
435 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; | 446 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; |
436 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; | 447 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; |
437 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; | 448 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; |
438 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; | 449 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; |
439 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; | 450 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; |
440 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; | 451 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; |
441 | 452 | ||
442 | // compare phone numbers | 453 | // compare phone numbers |
443 | PhoneNumber::List phoneN = ad.phoneNumbers(); | 454 | PhoneNumber::List phoneN = ad.phoneNumbers(); |
444 | PhoneNumber::List::Iterator phoneIt; | 455 | PhoneNumber::List::Iterator phoneIt; |
445 | bool found = false; | 456 | bool found = false; |
446 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 457 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
447 | bool found = false; | 458 | bool found = false; |
448 | PhoneNumber::List phoneL = ad.phoneNumbers(); | 459 | PhoneNumber::List phoneL = ad.phoneNumbers(); |
449 | PhoneNumber::List::Iterator phoneItL; | 460 | PhoneNumber::List::Iterator phoneItL; |
450 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { | 461 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { |
451 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { | 462 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { |
452 | found = true; | 463 | found = true; |
453 | break; | 464 | break; |
454 | } | 465 | } |
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 | |||
@@ -35,97 +35,98 @@ $Id$ | |||
35 | #include <libkdepim/ksyncprofile.h> | 35 | #include <libkdepim/ksyncprofile.h> |
36 | //US #include <qpe/categoryselect.h> | 36 | //US #include <qpe/categoryselect.h> |
37 | 37 | ||
38 | 38 | ||
39 | using namespace KABC; | 39 | using namespace KABC; |
40 | using namespace SlCategory; | 40 | using namespace SlCategory; |
41 | 41 | ||
42 | SharpDTMConverter::SharpDTMConverter() : catDB(0) | 42 | SharpDTMConverter::SharpDTMConverter() : catDB(0) |
43 | { | 43 | { |
44 | } | 44 | } |
45 | 45 | ||
46 | SharpDTMConverter::~SharpDTMConverter() | 46 | SharpDTMConverter::~SharpDTMConverter() |
47 | { | 47 | { |
48 | deinit(); | 48 | deinit(); |
49 | } | 49 | } |
50 | 50 | ||
51 | bool SharpDTMConverter::init() | 51 | bool SharpDTMConverter::init() |
52 | { | 52 | { |
53 | catDB = new SlCategory::SlCategories(); | 53 | catDB = new SlCategory::SlCategories(); |
54 | 54 | ||
55 | if (!catDB) | 55 | if (!catDB) |
56 | return false; | 56 | return false; |
57 | 57 | ||
58 | // catDB->load( categoryFileName() ); | 58 | // catDB->load( categoryFileName() ); |
59 | return true; | 59 | return true; |
60 | } | 60 | } |
61 | 61 | ||
62 | void SharpDTMConverter::deinit() | 62 | void SharpDTMConverter::deinit() |
63 | { | 63 | { |
64 | if (catDB) | 64 | if (catDB) |
65 | { | 65 | { |
66 | delete catDB; | 66 | delete catDB; |
67 | catDB = 0; | 67 | catDB = 0; |
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ) | 71 | bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ) |
72 | { | 72 | { |
73 | SlZDataBase* db = (SlZDataBase*)database; | 73 | SlZDataBase* db = (SlZDataBase*)database; |
74 | 74 | ||
75 | // for syncing: we need setting of the two fields | 75 | // for syncing: we need setting of the two fields |
76 | addr.setExternalUID( QString::number( contact ) ); | 76 | addr.setExternalUID( QString::number( contact ) ); |
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) ); |
90 | 91 | ||
91 | 92 | ||
92 | QString emailstr = db->readField(ZdbAdrs::Emails); | 93 | QString emailstr = db->readField(ZdbAdrs::Emails); |
93 | emailstr.replace( QRegExp(","), " " ); | 94 | emailstr.replace( QRegExp(","), " " ); |
94 | emailstr.replace( QRegExp(";"), " " ); | 95 | emailstr.replace( QRegExp(";"), " " ); |
95 | emailstr.replace( QRegExp(":"), " " ); | 96 | emailstr.replace( QRegExp(":"), " " ); |
96 | //qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1()); | 97 | //qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1()); |
97 | QStringList emails = QStringList::split(" ", emailstr.simplifyWhiteSpace()); | 98 | QStringList emails = QStringList::split(" ", emailstr.simplifyWhiteSpace()); |
98 | bool defE = false; | 99 | bool defE = false; |
99 | bool found = false; | 100 | bool found = false; |
100 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 101 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
101 | if (found ) | 102 | if (found ) |
102 | defE = false; | 103 | defE = false; |
103 | else | 104 | else |
104 | found = defE = ((*it).lower() == db->readField(ZdbAdrs::DefaultEmail).lower()); | 105 | found = defE = ((*it).lower() == db->readField(ZdbAdrs::DefaultEmail).lower()); |
105 | addr.insertEmail( *it, defE ); | 106 | addr.insertEmail( *it, defE ); |
106 | } | 107 | } |
107 | if ( ! found ) | 108 | if ( ! found ) |
108 | if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty()) | 109 | if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty()) |
109 | addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true); | 110 | addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true); |
110 | 111 | ||
111 | // home | 112 | // home |
112 | if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) || | 113 | if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) || |
113 | (!db->readField(ZdbAdrs::HomeCity).isEmpty()) || | 114 | (!db->readField(ZdbAdrs::HomeCity).isEmpty()) || |
114 | (!db->readField(ZdbAdrs::HomeState).isEmpty()) || | 115 | (!db->readField(ZdbAdrs::HomeState).isEmpty()) || |
115 | (!db->readField(ZdbAdrs::HomeZip).isEmpty()) || | 116 | (!db->readField(ZdbAdrs::HomeZip).isEmpty()) || |
116 | (!db->readField(ZdbAdrs::HomeCountry).isEmpty())) | 117 | (!db->readField(ZdbAdrs::HomeCountry).isEmpty())) |
117 | { | 118 | { |
118 | Address homeaddress; | 119 | Address homeaddress; |
119 | homeaddress.setType(Address::Home); | 120 | homeaddress.setType(Address::Home); |
120 | //US homeaddress.setPostOfficeBox( "" ); | 121 | //US homeaddress.setPostOfficeBox( "" ); |
121 | //US homeaddress.setExtended( "" ); | 122 | //US homeaddress.setExtended( "" ); |
122 | homeaddress.setStreet( db->readField(ZdbAdrs::HomeStreet).replace( QRegExp("\\r"), "")); | 123 | homeaddress.setStreet( db->readField(ZdbAdrs::HomeStreet).replace( QRegExp("\\r"), "")); |
123 | homeaddress.setLocality( db->readField(ZdbAdrs::HomeCity) ); | 124 | homeaddress.setLocality( db->readField(ZdbAdrs::HomeCity) ); |
124 | homeaddress.setRegion( db->readField(ZdbAdrs::HomeState) ); | 125 | homeaddress.setRegion( db->readField(ZdbAdrs::HomeState) ); |
125 | homeaddress.setPostalCode( db->readField(ZdbAdrs::HomeZip) ); | 126 | homeaddress.setPostalCode( db->readField(ZdbAdrs::HomeZip) ); |
126 | homeaddress.setCountry( db->readField(ZdbAdrs::HomeCountry) ); | 127 | homeaddress.setCountry( db->readField(ZdbAdrs::HomeCountry) ); |
127 | 128 | ||
128 | addr.insertAddress( homeaddress ); | 129 | addr.insertAddress( homeaddress ); |
129 | } | 130 | } |
130 | 131 | ||
131 | if (!db->readField(ZdbAdrs::HomePhone).isEmpty()) | 132 | if (!db->readField(ZdbAdrs::HomePhone).isEmpty()) |
@@ -177,250 +178,253 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa | |||
177 | 178 | ||
178 | 179 | ||
179 | if (!db->readField(ZdbAdrs::BusinessPhone).isEmpty()) | 180 | if (!db->readField(ZdbAdrs::BusinessPhone).isEmpty()) |
180 | { | 181 | { |
181 | PhoneNumber businessphone; | 182 | PhoneNumber businessphone; |
182 | businessphone.setType( PhoneNumber::Work ); | 183 | businessphone.setType( PhoneNumber::Work ); |
183 | businessphone.setNumber( db->readField(ZdbAdrs::BusinessPhone) ); | 184 | businessphone.setNumber( db->readField(ZdbAdrs::BusinessPhone) ); |
184 | addr.insertPhoneNumber( businessphone ); | 185 | addr.insertPhoneNumber( businessphone ); |
185 | } | 186 | } |
186 | 187 | ||
187 | if (!db->readField(ZdbAdrs::BusinessFax).isEmpty()) | 188 | if (!db->readField(ZdbAdrs::BusinessFax).isEmpty()) |
188 | { | 189 | { |
189 | PhoneNumber businessfax; | 190 | PhoneNumber businessfax; |
190 | businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); | 191 | businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); |
191 | businessfax.setNumber( db->readField(ZdbAdrs::BusinessFax) ); | 192 | businessfax.setNumber( db->readField(ZdbAdrs::BusinessFax) ); |
192 | addr.insertPhoneNumber( businessfax ); | 193 | addr.insertPhoneNumber( businessfax ); |
193 | } | 194 | } |
194 | 195 | ||
195 | if (!db->readField(ZdbAdrs::BusinessMobile).isEmpty()) | 196 | if (!db->readField(ZdbAdrs::BusinessMobile).isEmpty()) |
196 | { | 197 | { |
197 | PhoneNumber businessmobile; | 198 | PhoneNumber businessmobile; |
198 | businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); | 199 | businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); |
199 | businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) ); | 200 | businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) ); |
200 | addr.insertPhoneNumber( businessmobile ); | 201 | addr.insertPhoneNumber( businessmobile ); |
201 | } | 202 | } |
202 | 203 | ||
203 | if (!db->readField(ZdbAdrs::BusinessPager).isEmpty()) | 204 | if (!db->readField(ZdbAdrs::BusinessPager).isEmpty()) |
204 | { | 205 | { |
205 | PhoneNumber businesspager; | 206 | PhoneNumber businesspager; |
206 | businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); | 207 | businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); |
207 | businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) ); | 208 | businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) ); |
208 | addr.insertPhoneNumber( businesspager ); | 209 | addr.insertPhoneNumber( businesspager ); |
209 | } | 210 | } |
210 | 211 | ||
211 | addr.setRole( db->readField(ZdbAdrs::JobTitle) ); | 212 | addr.setRole( db->readField(ZdbAdrs::JobTitle) ); |
212 | addr.setOrganization( db->readField(ZdbAdrs::Company) ); | 213 | addr.setOrganization( db->readField(ZdbAdrs::Company) ); |
213 | addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) ); | 214 | addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) ); |
214 | addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) ); | 215 | addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) ); |
215 | addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) ); | 216 | addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) ); |
216 | addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) ); | 217 | addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) ); |
217 | addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) ); | 218 | addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) ); |
218 | 219 | ||
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) ); |
244 | //qDebug("birtd %s ", birthd.toString().latin1()); | 248 | //qDebug("birtd %s ", birthd.toString().latin1()); |
245 | if (birthd.isValid()) | 249 | if (birthd.isValid()) |
246 | addr.setBirthday( birthd ); | 250 | addr.setBirthday( birthd ); |
247 | 251 | ||
248 | addr.setNickName( db->readField(ZdbAdrs::Nickname) ); | 252 | addr.setNickName( db->readField(ZdbAdrs::Nickname) ); |
249 | 253 | ||
250 | // others | 254 | // others |
251 | //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. | 255 | //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. |
252 | //QString notes = db->readField(ZdbAdrs::Notes); | 256 | //QString notes = db->readField(ZdbAdrs::Notes); |
253 | //notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n"; | 257 | //notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n"; |
254 | if ( addr.url().isEmpty() ) | 258 | if ( addr.url().isEmpty() ) |
255 | addr.setUrl( db->readField(ZdbAdrs::BusinessWebPage) ); | 259 | addr.setUrl( db->readField(ZdbAdrs::BusinessWebPage) ); |
256 | addr.setNote( db->readField(ZdbAdrs::Notes).replace( QRegExp("\\r"), "")); | 260 | addr.setNote( db->readField(ZdbAdrs::Notes).replace( QRegExp("\\r"), "")); |
257 | 261 | ||
258 | 262 | ||
259 | 263 | ||
260 | //US QString groups() const { return find( Qtopia::Groups ); } | 264 | //US QString groups() const { return find( Qtopia::Groups ); } |
261 | //US QStringList groupList() const; | 265 | //US QStringList groupList() const; |
262 | 266 | ||
263 | //qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" ); | 267 | //qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" ); |
264 | QArray<int> catArray = db->readCategories(); | 268 | QArray<int> catArray = db->readCategories(); |
265 | QString cat; | 269 | QString cat; |
266 | 270 | ||
267 | for ( unsigned int i=0; i < catArray.size(); i++ ) { | 271 | for ( unsigned int i=0; i < catArray.size(); i++ ) { |
268 | cat = catDB->label(catArray[i]); | 272 | cat = catDB->label(catArray[i]); |
269 | if ( cat.isEmpty() ) | 273 | if ( cat.isEmpty() ) |
270 | addr.insertCategory(QString::number(catArray[i])); | 274 | addr.insertCategory(QString::number(catArray[i])); |
271 | else | 275 | else |
272 | addr.insertCategory( cat ); | 276 | addr.insertCategory( cat ); |
273 | } | 277 | } |
274 | 278 | ||
275 | return true; | 279 | return true; |
276 | } | 280 | } |
277 | 281 | ||
278 | bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) | 282 | bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) |
279 | { | 283 | { |
280 | bool cellHome = false, cellWork = false; | 284 | bool cellHome = false, cellWork = false; |
281 | // name | 285 | // name |
282 | database->writeField(ZdbAdrs::LastName, addr.familyName()); | 286 | database->writeField(ZdbAdrs::LastName, addr.familyName()); |
283 | database->writeField(ZdbAdrs::FirstName, addr.givenName()); | 287 | database->writeField(ZdbAdrs::FirstName, addr.givenName()); |
284 | database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); | 288 | database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); |
285 | database->writeField(ZdbAdrs::Title, addr.prefix()); | 289 | database->writeField(ZdbAdrs::Title, addr.prefix()); |
286 | database->writeField(ZdbAdrs::Suffix, addr.suffix()); | 290 | database->writeField(ZdbAdrs::Suffix, addr.suffix()); |
287 | 291 | ||
288 | //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); | 292 | //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); |
289 | QString formattedName = addr.formattedName(); | 293 | QString formattedName = addr.formattedName(); |
290 | if ( formattedName.isEmpty() ) { | 294 | if ( formattedName.isEmpty() ) { |
291 | if ( !addr.familyName().isEmpty() ) { | 295 | if ( !addr.familyName().isEmpty() ) { |
292 | formattedName = addr.familyName(); | 296 | formattedName = addr.familyName(); |
293 | if ( !addr.givenName().isEmpty() ) { | 297 | if ( !addr.givenName().isEmpty() ) { |
294 | formattedName += ", "; | 298 | formattedName += ", "; |
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 ); |
308 | 312 | ||
309 | database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() ); | 313 | database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() ); |
310 | // home | 314 | // home |
311 | const Address homeaddress = addr.address(Address::Home); | 315 | const Address homeaddress = addr.address(Address::Home); |
312 | database->writeField(ZdbAdrs::HomeStreet, homeaddress.street()); | 316 | database->writeField(ZdbAdrs::HomeStreet, homeaddress.street()); |
313 | database->writeField(ZdbAdrs::HomeCity, homeaddress.locality()); | 317 | database->writeField(ZdbAdrs::HomeCity, homeaddress.locality()); |
314 | database->writeField(ZdbAdrs::HomeState, homeaddress.region()); | 318 | database->writeField(ZdbAdrs::HomeState, homeaddress.region()); |
315 | database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode()); | 319 | database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode()); |
316 | database->writeField(ZdbAdrs::HomeCountry, homeaddress.country()); | 320 | database->writeField(ZdbAdrs::HomeCountry, homeaddress.country()); |
317 | 321 | ||
318 | PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); | 322 | PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); |
319 | database->writeField(ZdbAdrs::HomePhone, homephone.number()); | 323 | database->writeField(ZdbAdrs::HomePhone, homephone.number()); |
320 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); | 324 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); |
321 | database->writeField(ZdbAdrs::HomeFax, homefax.number()); | 325 | database->writeField(ZdbAdrs::HomeFax, homefax.number()); |
322 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); | 326 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); |
323 | database->writeField(ZdbAdrs::HomeMobile, homemobile.number()); | 327 | database->writeField(ZdbAdrs::HomeMobile, homemobile.number()); |
324 | if (!homemobile.number().isEmpty()) { | 328 | if (!homemobile.number().isEmpty()) { |
325 | cellHome = true; | 329 | cellHome = true; |
326 | } | 330 | } |
327 | database->writeField(ZdbAdrs::HomeWebPage, addr.url().url()); | 331 | database->writeField(ZdbAdrs::HomeWebPage, addr.url().url()); |
328 | // business | 332 | // business |
329 | const Address businessaddress = addr.address(Address::Work); | 333 | const Address businessaddress = addr.address(Address::Work); |
330 | //qDebug("write business address "); | 334 | //qDebug("write business address "); |
331 | database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street()); | 335 | database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street()); |
332 | database->writeField(ZdbAdrs::BusinessCity, businessaddress.locality()); | 336 | database->writeField(ZdbAdrs::BusinessCity, businessaddress.locality()); |
333 | database->writeField(ZdbAdrs::BusinessState, businessaddress.region()); | 337 | database->writeField(ZdbAdrs::BusinessState, businessaddress.region()); |
334 | database->writeField(ZdbAdrs::BusinessZip, businessaddress.postalCode()); | 338 | database->writeField(ZdbAdrs::BusinessZip, businessaddress.postalCode()); |
335 | database->writeField(ZdbAdrs::BusinessCountry, businessaddress.country()); | 339 | database->writeField(ZdbAdrs::BusinessCountry, businessaddress.country()); |
336 | 340 | ||
337 | PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); | 341 | PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); |
338 | database->writeField(ZdbAdrs::BusinessPhone, businessphone.number()); | 342 | database->writeField(ZdbAdrs::BusinessPhone, businessphone.number()); |
339 | 343 | ||
340 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); | 344 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); |
341 | database->writeField(ZdbAdrs::BusinessFax, businessfax.number()); | 345 | database->writeField(ZdbAdrs::BusinessFax, businessfax.number()); |
342 | 346 | ||
343 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); | 347 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); |
344 | database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number()); | 348 | database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number()); |
345 | if (!businessmobile.number().isEmpty()) { | 349 | if (!businessmobile.number().isEmpty()) { |
346 | cellWork = true; | 350 | cellWork = true; |
347 | } | 351 | } |
348 | PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell ); | 352 | PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell ); |
349 | if (! mobile.number().isEmpty()) { | 353 | if (! mobile.number().isEmpty()) { |
350 | if ( ! cellHome ) | 354 | if ( ! cellHome ) |
351 | database->writeField(ZdbAdrs::HomeMobile, mobile.number()); | 355 | database->writeField(ZdbAdrs::HomeMobile, mobile.number()); |
352 | else if (! cellWork ) | 356 | else if (! cellWork ) |
353 | database->writeField(ZdbAdrs::BusinessMobile, mobile.number()); | 357 | database->writeField(ZdbAdrs::BusinessMobile, mobile.number()); |
354 | } | 358 | } |
355 | 359 | ||
356 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); | 360 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); |
357 | database->writeField(ZdbAdrs::BusinessPager, businesspager.number()); | 361 | database->writeField(ZdbAdrs::BusinessPager, businesspager.number()); |
358 | 362 | ||
359 | database->writeField(ZdbAdrs::JobTitle, addr.role()); | 363 | database->writeField(ZdbAdrs::JobTitle, addr.role()); |
360 | database->writeField(ZdbAdrs::Company, addr.organization()); | 364 | database->writeField(ZdbAdrs::Company, addr.organization()); |
361 | 365 | ||
362 | database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" )); | 366 | database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" )); |
363 | database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); | 367 | database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); |
364 | database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" )); | 368 | database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" )); |
365 | database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" )); | 369 | database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" )); |
366 | database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" )); | 370 | database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" )); |
367 | 371 | ||
368 | //personal | 372 | //personal |
369 | database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" )); | 373 | database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" )); |
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() ) { |
385 | dateS = KGlobal::locale()->formatDate(dt, true ); | 389 | dateS = KGlobal::locale()->formatDate(dt, true ); |
386 | } | 390 | } |
387 | database->writeField(ZdbAdrs::Anniversary, dateS ); | 391 | database->writeField(ZdbAdrs::Anniversary, dateS ); |
388 | database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); | 392 | database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); |
389 | dt = addr.birthday().date(); | 393 | dt = addr.birthday().date(); |
390 | dateS = ""; | 394 | dateS = ""; |
391 | if ( dt.isValid() ) { | 395 | if ( dt.isValid() ) { |
392 | dateS = KGlobal::locale()->formatDate(dt, true ); | 396 | dateS = KGlobal::locale()->formatDate(dt, true ); |
393 | } | 397 | } |
394 | database->writeField(ZdbAdrs::Birthday, dateS); | 398 | database->writeField(ZdbAdrs::Birthday, dateS); |
395 | database->writeField(ZdbAdrs::Nickname, addr.nickName()); | 399 | database->writeField(ZdbAdrs::Nickname, addr.nickName()); |
396 | 400 | ||
397 | // other | 401 | // other |
398 | database->writeField(ZdbAdrs::Notes, addr.note()); | 402 | database->writeField(ZdbAdrs::Notes, addr.note()); |
399 | 403 | ||
400 | //US QString groups() const { return find( Qtopia::Groups ); } | 404 | //US QString groups() const { return find( Qtopia::Groups ); } |
401 | //US QStringList groupList() const; | 405 | //US QStringList groupList() const; |
402 | 406 | ||
403 | 407 | ||
404 | //qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works"); | 408 | //qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works"); |
405 | 409 | ||
406 | return true; | 410 | return true; |
407 | } | 411 | } |
408 | 412 | ||
409 | 413 | ||
410 | bool SharpDTMConverter::setCategories( const Addressee &addr, SlZDataBase* database , const CardId &contact ) | 414 | bool SharpDTMConverter::setCategories( const Addressee &addr, SlZDataBase* database , const CardId &contact ) |
411 | { | 415 | { |
412 | QStringList list = addr.categories(); | 416 | QStringList list = addr.categories(); |
413 | 417 | ||
414 | QArray<int> ids(list.count()); | 418 | QArray<int> ids(list.count()); |
415 | uint index = 0; | 419 | uint index = 0; |
416 | for(uint i=0; i<ids.size(); i++){ | 420 | for(uint i=0; i<ids.size(); i++){ |
417 | if(catDB->exists(list[i])){ | 421 | if(catDB->exists(list[i])){ |
418 | ids[index] = catDB->id(list[i]); | 422 | ids[index] = catDB->id(list[i]); |
419 | qDebug("set ex cat %d %s ",ids[index] , list[i].latin1()); | 423 | qDebug("set ex cat %d %s ",ids[index] , list[i].latin1()); |
420 | index++; | 424 | index++; |
421 | } else { | 425 | } else { |
422 | ids[index] = catDB->addCategory(list[i]); | 426 | ids[index] = catDB->addCategory(list[i]); |
423 | qDebug("add new cat %d %s ",ids[index] , list[i].latin1()); | 427 | qDebug("add new cat %d %s ",ids[index] , list[i].latin1()); |
424 | index++; | 428 | index++; |
425 | } | 429 | } |
426 | } | 430 | } |