author | zautrix <zautrix> | 2005-12-02 09:10:14 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-12-02 09:10:14 (UTC) |
commit | 64be8d64fc26d1025a24150d065197ba5d608f3d (patch) (unidiff) | |
tree | 4f7b0c82641ac591af04f6fdd541b662d4727850 /kabc/addressbook.cpp | |
parent | 2bd8aff44e90b6d58e2037771db8b38846addb3e (diff) | |
download | kdepimpi-64be8d64fc26d1025a24150d065197ba5d608f3d.zip kdepimpi-64be8d64fc26d1025a24150d065197ba5d608f3d.tar.gz kdepimpi-64be8d64fc26d1025a24150d065197ba5d608f3d.tar.bz2 |
more sync
-rw-r--r-- | kabc/addressbook.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index f3744bc..e04f4b1 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -348,88 +348,94 @@ bool AddressBook::load() | |||
348 | if ( !(*it)->load() ) { | 348 | if ( !(*it)->load() ) { |
349 | qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 349 | qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
350 | ok = false; | 350 | ok = false; |
351 | } else { | 351 | } else { |
352 | qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); | 352 | qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); |
353 | } | 353 | } |
354 | // mark all addressees as unchanged | 354 | // mark all addressees as unchanged |
355 | Addressee::List::Iterator addrIt; | 355 | Addressee::List::Iterator addrIt; |
356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { | 356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
357 | (*addrIt).setChanged( false ); | 357 | (*addrIt).setChanged( false ); |
358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | 358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); |
359 | if ( !id.isEmpty() ) { | 359 | if ( !id.isEmpty() ) { |
360 | //qDebug("setId aa %s ", id.latin1()); | 360 | //qDebug("setId aa %s ", id.latin1()); |
361 | (*addrIt).setIDStr(id ); | 361 | (*addrIt).setIDStr(id ); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | blockLSEchange = true; | 364 | blockLSEchange = true; |
365 | return ok; | 365 | return ok; |
366 | } | 366 | } |
367 | 367 | ||
368 | bool AddressBook::save( Ticket *ticket ) | 368 | bool AddressBook::save( Ticket *ticket ) |
369 | { | 369 | { |
370 | kdDebug(5700) << "AddressBook::save()"<< endl; | 370 | kdDebug(5700) << "AddressBook::save()"<< endl; |
371 | 371 | ||
372 | if ( ticket->resource() ) { | 372 | if ( ticket->resource() ) { |
373 | deleteRemovedAddressees(); | 373 | deleteRemovedAddressees(); |
374 | return ticket->resource()->save( ticket ); | 374 | return ticket->resource()->save( ticket ); |
375 | } | 375 | } |
376 | 376 | ||
377 | return false; | 377 | return false; |
378 | } | 378 | } |
379 | // exports all Addressees, which are syncable | 379 | // exports all Addressees, which are syncable |
380 | void AddressBook::export2File( QString fileName ) | 380 | void AddressBook::export2File( QString fileName, QString resourceName ) |
381 | { | 381 | { |
382 | 382 | ||
383 | QFile outFile( fileName ); | 383 | QFile outFile( fileName ); |
384 | if ( !outFile.open( IO_WriteOnly ) ) { | 384 | if ( !outFile.open( IO_WriteOnly ) ) { |
385 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 385 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
386 | KMessageBox::error( 0, text.arg( fileName ) ); | 386 | KMessageBox::error( 0, text.arg( fileName ) ); |
387 | return ; | 387 | return ; |
388 | } | 388 | } |
389 | QTextStream t( &outFile ); | 389 | QTextStream t( &outFile ); |
390 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 390 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
391 | Iterator it; | 391 | Iterator it; |
392 | KABC::VCardConverter::Version version; | 392 | KABC::VCardConverter::Version version; |
393 | version = KABC::VCardConverter::v3_0; | 393 | version = KABC::VCardConverter::v3_0; |
394 | for ( it = begin(); it != end(); ++it ) { | 394 | for ( it = begin(); it != end(); ++it ) { |
395 | if ( (*it).resource() && (*it).resource()->includeInSync() ) { | 395 | if ( (*it).resource() ) { |
396 | if ( !(*it).IDStr().isEmpty() ) { | 396 | bool include = (*it).resource()->includeInSync(); |
397 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | 397 | if ( !resourceName.isEmpty() ) |
398 | include = (resourceName == (*it).resource()->name() ); | ||
399 | if ( include ) { | ||
400 | qDebug(QString ("Exporting resource %1 to file %2").arg( (*it).resource()->name() ).arg( fileName ) ); | ||
401 | if ( !(*it).IDStr().isEmpty() ) { | ||
402 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | ||
403 | } | ||
404 | KABC::VCardConverter converter; | ||
405 | QString vcard; | ||
406 | //Resource *resource() const; | ||
407 | converter.addresseeToVCard( *it, vcard, version ); | ||
408 | t << vcard << "\r\n"; | ||
398 | } | 409 | } |
399 | KABC::VCardConverter converter; | ||
400 | QString vcard; | ||
401 | //Resource *resource() const; | ||
402 | converter.addresseeToVCard( *it, vcard, version ); | ||
403 | t << vcard << "\r\n"; | ||
404 | } | 410 | } |
405 | } | 411 | } |
406 | t << "\r\n\r\n"; | 412 | t << "\r\n\r\n"; |
407 | outFile.close(); | 413 | outFile.close(); |
408 | } | 414 | } |
409 | // if QStringList uids is empty, all are exported | 415 | // if QStringList uids is empty, all are exported |
410 | bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) | 416 | bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) |
411 | { | 417 | { |
412 | KABC::VCardConverter converter; | 418 | KABC::VCardConverter converter; |
413 | QString datastream; | 419 | QString datastream; |
414 | Iterator it; | 420 | Iterator it; |
415 | bool all = uids.isEmpty(); | 421 | bool all = uids.isEmpty(); |
416 | for ( it = begin(); it != end(); ++it ) { | 422 | for ( it = begin(); it != end(); ++it ) { |
417 | // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 423 | // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
418 | if ( ! all ) { | 424 | if ( ! all ) { |
419 | if ( ! ( uids.contains((*it).uid() ) )) | 425 | if ( ! ( uids.contains((*it).uid() ) )) |
420 | continue; | 426 | continue; |
421 | } | 427 | } |
422 | KABC::Addressee a = ( *it ); | 428 | KABC::Addressee a = ( *it ); |
423 | if ( a.isEmpty() ) | 429 | if ( a.isEmpty() ) |
424 | continue; | 430 | continue; |
425 | if ( all && a.resource() && !a.resource()->includeInSync() ) | 431 | if ( all && a.resource() && !a.resource()->includeInSync() ) |
426 | continue; | 432 | continue; |
427 | a.simplifyEmails(); | 433 | a.simplifyEmails(); |
428 | a.simplifyPhoneNumbers(); | 434 | a.simplifyPhoneNumbers(); |
429 | a.simplifyPhoneNumberTypes(); | 435 | a.simplifyPhoneNumberTypes(); |
430 | a.simplifyAddresses(); | 436 | a.simplifyAddresses(); |
431 | 437 | ||
432 | QString vcard; | 438 | QString vcard; |
433 | QString vcardnew; | 439 | QString vcardnew; |
434 | converter.addresseeToVCard( a, vcard ); | 440 | converter.addresseeToVCard( a, vcard ); |
435 | int start = 0; | 441 | int start = 0; |