-rw-r--r-- | kabc/addressbook.cpp | 35 | ||||
-rw-r--r-- | kabc/addressbook.h | 2 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 146 | ||||
-rw-r--r-- | microkde/kresources/configdialog.cpp | 5 | ||||
-rw-r--r-- | microkde/kresources/configdialog.h | 1 | ||||
-rw-r--r-- | microkde/kresources/resource.cpp | 14 | ||||
-rw-r--r-- | microkde/kresources/resource.h | 2 |
7 files changed, 119 insertions, 86 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 8882259..592d78d 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -367,67 +367,72 @@ bool AddressBook::load() | |||
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 | void AddressBook::export2File( QString fileName ) | 380 | void AddressBook::export2File( QString fileName ) |
380 | { | 381 | { |
381 | 382 | ||
382 | QFile outFile( fileName ); | 383 | QFile outFile( fileName ); |
383 | if ( !outFile.open( IO_WriteOnly ) ) { | 384 | if ( !outFile.open( IO_WriteOnly ) ) { |
384 | 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>" ); |
385 | KMessageBox::error( 0, text.arg( fileName ) ); | 386 | KMessageBox::error( 0, text.arg( fileName ) ); |
386 | return ; | 387 | return ; |
387 | } | 388 | } |
388 | QTextStream t( &outFile ); | 389 | QTextStream t( &outFile ); |
389 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 390 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
390 | Iterator it; | 391 | Iterator it; |
391 | KABC::VCardConverter::Version version; | 392 | KABC::VCardConverter::Version version; |
392 | version = KABC::VCardConverter::v3_0; | 393 | version = KABC::VCardConverter::v3_0; |
393 | for ( it = begin(); it != end(); ++it ) { | 394 | for ( it = begin(); it != end(); ++it ) { |
394 | if ( !(*it).IDStr().isEmpty() ) { | 395 | if ( (*it).resource() && (*it).resource()->includeInSync() ) { |
395 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | 396 | if ( !(*it).IDStr().isEmpty() ) { |
397 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | ||
398 | } | ||
399 | KABC::VCardConverter converter; | ||
400 | QString vcard; | ||
401 | //Resource *resource() const; | ||
402 | converter.addresseeToVCard( *it, vcard, version ); | ||
403 | t << vcard << "\r\n"; | ||
396 | } | 404 | } |
397 | KABC::VCardConverter converter; | ||
398 | QString vcard; | ||
399 | //Resource *resource() const; | ||
400 | converter.addresseeToVCard( *it, vcard, version ); | ||
401 | t << vcard << "\r\n"; | ||
402 | } | 405 | } |
403 | t << "\r\n\r\n"; | 406 | t << "\r\n\r\n"; |
404 | outFile.close(); | 407 | outFile.close(); |
405 | } | 408 | } |
406 | // if QStringList uids is empty, all are exported | 409 | // if QStringList uids is empty, all are exported |
407 | bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) | 410 | bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) |
408 | { | 411 | { |
409 | KABC::VCardConverter converter; | 412 | KABC::VCardConverter converter; |
410 | QString datastream; | 413 | QString datastream; |
411 | Iterator it; | 414 | Iterator it; |
412 | bool all = uids.isEmpty(); | 415 | bool all = uids.isEmpty(); |
413 | for ( it = begin(); it != end(); ++it ) { | 416 | for ( it = begin(); it != end(); ++it ) { |
414 | // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 417 | // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
415 | if ( ! all ) { | 418 | if ( ! all ) { |
416 | if ( ! ( uids.contains((*it).uid() ) )) | 419 | if ( ! ( uids.contains((*it).uid() ) )) |
417 | continue; | 420 | continue; |
418 | } | 421 | } |
419 | KABC::Addressee a = ( *it ); | 422 | KABC::Addressee a = ( *it ); |
420 | if ( a.isEmpty() ) | 423 | if ( a.isEmpty() ) |
421 | continue; | 424 | continue; |
425 | if ( all && a.resource() && !a.resource()->includeInSync() ) | ||
426 | continue; | ||
422 | a.simplifyEmails(); | 427 | a.simplifyEmails(); |
423 | a.simplifyPhoneNumbers(); | 428 | a.simplifyPhoneNumbers(); |
424 | a.simplifyPhoneNumberTypes(); | 429 | a.simplifyPhoneNumberTypes(); |
425 | a.simplifyAddresses(); | 430 | a.simplifyAddresses(); |
426 | 431 | ||
427 | QString vcard; | 432 | QString vcard; |
428 | QString vcardnew; | 433 | QString vcardnew; |
429 | converter.addresseeToVCard( a, vcard ); | 434 | converter.addresseeToVCard( a, vcard ); |
430 | int start = 0; | 435 | int start = 0; |
431 | int next; | 436 | int next; |
432 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 437 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
433 | int semi = vcard.find(";", next); | 438 | int semi = vcard.find(";", next); |
@@ -467,25 +472,25 @@ bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) | |||
467 | 472 | ||
468 | } else { | 473 | } else { |
469 | qDebug("Error open temp file "); | 474 | qDebug("Error open temp file "); |
470 | return false; | 475 | return false; |
471 | } | 476 | } |
472 | return true; | 477 | return true; |
473 | 478 | ||
474 | } | 479 | } |
475 | void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) | 480 | void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) |
476 | { | 481 | { |
477 | 482 | ||
478 | if ( removeOld ) | 483 | if ( removeOld ) |
479 | setUntagged(); | 484 | setUntagged( true ); |
480 | KABC::Addressee::List list; | 485 | KABC::Addressee::List list; |
481 | QFile file( fileName ); | 486 | QFile file( fileName ); |
482 | file.open( IO_ReadOnly ); | 487 | file.open( IO_ReadOnly ); |
483 | QByteArray rawData = file.readAll(); | 488 | QByteArray rawData = file.readAll(); |
484 | file.close(); | 489 | file.close(); |
485 | QString data; | 490 | QString data; |
486 | if ( replaceLabel ) { | 491 | if ( replaceLabel ) { |
487 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); | 492 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); |
488 | data.replace ( QRegExp("LABEL") , "ADR" ); | 493 | data.replace ( QRegExp("LABEL") , "ADR" ); |
489 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); | 494 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); |
490 | } else | 495 | } else |
491 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 496 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
@@ -497,29 +502,35 @@ void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool rem | |||
497 | if ( !id.isEmpty() ) | 502 | if ( !id.isEmpty() ) |
498 | (*it).setIDStr(id ); | 503 | (*it).setIDStr(id ); |
499 | (*it).setResource( 0 ); | 504 | (*it).setResource( 0 ); |
500 | if ( replaceLabel ) | 505 | if ( replaceLabel ) |
501 | (*it).removeVoice(); | 506 | (*it).removeVoice(); |
502 | if ( removeOld ) | 507 | if ( removeOld ) |
503 | (*it).setTagged( true ); | 508 | (*it).setTagged( true ); |
504 | insertAddressee( (*it), false, true ); | 509 | insertAddressee( (*it), false, true ); |
505 | } | 510 | } |
506 | if ( removeOld ) | 511 | if ( removeOld ) |
507 | removeUntagged(); | 512 | removeUntagged(); |
508 | } | 513 | } |
509 | void AddressBook::setUntagged() | 514 | void AddressBook::setUntagged(bool setNonSyncTagged) // = false) |
510 | { | 515 | { |
511 | Iterator ait; | 516 | Iterator ait; |
512 | for ( ait = begin(); ait != end(); ++ait ) { | 517 | for ( ait = begin(); ait != end(); ++ait ) { |
513 | (*ait).setTagged( false ); | 518 | if ( setNonSyncTagged ) { |
519 | if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { | ||
520 | (*ait).setTagged( true ); | ||
521 | } else | ||
522 | (*ait).setTagged( false ); | ||
523 | } else | ||
524 | (*ait).setTagged( false ); | ||
514 | } | 525 | } |
515 | } | 526 | } |
516 | void AddressBook::removeUntagged() | 527 | void AddressBook::removeUntagged() |
517 | { | 528 | { |
518 | Iterator ait; | 529 | Iterator ait; |
519 | bool todelete = false; | 530 | bool todelete = false; |
520 | Iterator todel; | 531 | Iterator todel; |
521 | for ( ait = begin(); ait != end(); ++ait ) { | 532 | for ( ait = begin(); ait != end(); ++ait ) { |
522 | if ( todelete ) | 533 | if ( todelete ) |
523 | removeAddressee( todel ); | 534 | removeAddressee( todel ); |
524 | if (!(*ait).tagged()) { | 535 | if (!(*ait).tagged()) { |
525 | todelete = true; | 536 | todelete = true; |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index a6bf451..23bba02 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -139,25 +139,25 @@ class AddressBook : public QObject | |||
139 | object has been requested for by @ref requestSaveTicket(). | 139 | object has been requested for by @ref requestSaveTicket(). |
140 | 140 | ||
141 | @param ticket a ticket object returned by @ref requestSaveTicket() | 141 | @param ticket a ticket object returned by @ref requestSaveTicket() |
142 | */ | 142 | */ |
143 | bool save( Ticket *ticket ); | 143 | bool save( Ticket *ticket ); |
144 | bool saveAB( ); | 144 | bool saveAB( ); |
145 | bool saveABphone( QString fileName ); | 145 | bool saveABphone( QString fileName ); |
146 | void smplifyAddressees(); | 146 | void smplifyAddressees(); |
147 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); | 147 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); |
148 | void export2File( QString fileName ); | 148 | void export2File( QString fileName ); |
149 | bool export2PhoneFormat( QStringList uids ,QString fileName ); | 149 | bool export2PhoneFormat( QStringList uids ,QString fileName ); |
150 | void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); | 150 | void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); |
151 | void setUntagged(); | 151 | void setUntagged( bool setNonSyncTagged = false ); |
152 | void removeUntagged(); | 152 | void removeUntagged(); |
153 | void findNewExtIds( QString fileName, QString currentSyncDevice ); | 153 | void findNewExtIds( QString fileName, QString currentSyncDevice ); |
154 | /** | 154 | /** |
155 | Returns a iterator for first entry of address book. | 155 | Returns a iterator for first entry of address book. |
156 | */ | 156 | */ |
157 | Iterator begin(); | 157 | Iterator begin(); |
158 | 158 | ||
159 | /** | 159 | /** |
160 | Returns a const iterator for first entry of address book. | 160 | Returns a const iterator for first entry of address book. |
161 | */ | 161 | */ |
162 | ConstIterator begin() const; | 162 | ConstIterator begin() const; |
163 | 163 | ||
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index ea34be2..47ed858 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2542,66 +2542,68 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2542 | uid = er[ incCounter ]; | 2542 | uid = er[ incCounter ]; |
2543 | bool skipIncidence = false; | 2543 | bool skipIncidence = false; |
2544 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2544 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2545 | skipIncidence = true; | 2545 | skipIncidence = true; |
2546 | QString idS,OidS; | 2546 | QString idS,OidS; |
2547 | qApp->processEvents(); | 2547 | qApp->processEvents(); |
2548 | if ( !skipIncidence ) { | 2548 | if ( !skipIncidence ) { |
2549 | inL = local->findByUid( uid ); | 2549 | inL = local->findByUid( uid ); |
2550 | inR = remote->findByUid( uid ); | 2550 | inR = remote->findByUid( uid ); |
2551 | //inL.setResource( 0 ); | 2551 | //inL.setResource( 0 ); |
2552 | //inR.setResource( 0 ); | 2552 | //inR.setResource( 0 ); |
2553 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2553 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2554 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2554 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2555 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2555 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2556 | if ( take == 3 ) | 2556 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2557 | return false; | 2557 | if ( take == 3 ) |
2558 | if ( take == 1 ) {// take local | 2558 | return false; |
2559 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2559 | if ( take == 1 ) {// take local |
2560 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2560 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2561 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2561 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2562 | local->insertAddressee( inL, false ); | 2562 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2563 | idS = inR.externalUID(); | 2563 | local->insertAddressee( inL, false ); |
2564 | OidS = inR.originalExternalUID(); | 2564 | idS = inR.externalUID(); |
2565 | } | 2565 | OidS = inR.originalExternalUID(); |
2566 | else | 2566 | } |
2567 | idS = inR.IDStr(); | 2567 | else |
2568 | remote->removeAddressee( inR ); | 2568 | idS = inR.IDStr(); |
2569 | inR = inL; | 2569 | remote->removeAddressee( inR ); |
2570 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2570 | inR = inL; |
2571 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2571 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2572 | inR.setOriginalExternalUID( OidS ); | 2572 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2573 | inR.setExternalUID( idS ); | 2573 | inR.setOriginalExternalUID( OidS ); |
2574 | } else { | 2574 | inR.setExternalUID( idS ); |
2575 | inR.setIDStr( idS ); | 2575 | } else { |
2576 | } | 2576 | inR.setIDStr( idS ); |
2577 | inR.setResource( 0 ); | 2577 | } |
2578 | remote->insertAddressee( inR , false); | 2578 | inR.setResource( 0 ); |
2579 | ++changedRemote; | 2579 | remote->insertAddressee( inR , false); |
2580 | } else { // take == 2 take remote | 2580 | ++changedRemote; |
2581 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2581 | } else { // take == 2 take remote |
2582 | if ( inR.revision().date().year() < 2004 ) | 2582 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2583 | inR.setRevision( modifiedCalendar ); | 2583 | if ( inR.revision().date().year() < 2004 ) |
2584 | } | 2584 | inR.setRevision( modifiedCalendar ); |
2585 | idS = inL.IDStr(); | 2585 | } |
2586 | local->removeAddressee( inL ); | 2586 | idS = inL.IDStr(); |
2587 | inL = inR; | 2587 | local->removeAddressee( inL ); |
2588 | inL.setIDStr( idS ); | 2588 | inL = inR; |
2589 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2589 | inL.setIDStr( idS ); |
2590 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2590 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2591 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2591 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2592 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | ||
2593 | } | ||
2594 | inL.setResource( 0 ); | ||
2595 | local->insertAddressee( inL , false ); | ||
2596 | ++changedLocal; | ||
2592 | } | 2597 | } |
2593 | inL.setResource( 0 ); | ||
2594 | local->insertAddressee( inL , false ); | ||
2595 | ++changedLocal; | ||
2596 | } | 2598 | } |
2597 | } | 2599 | } |
2598 | } else { // no conflict | 2600 | } else { // no conflict |
2599 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2601 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2600 | QString des = addresseeLSync.note(); | 2602 | QString des = addresseeLSync.note(); |
2601 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2603 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2602 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2604 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2603 | remote->insertAddressee( inR, false ); | 2605 | remote->insertAddressee( inR, false ); |
2604 | ++deletedAddresseeR; | 2606 | ++deletedAddresseeR; |
2605 | } else { | 2607 | } else { |
2606 | inR.setRevision( modifiedCalendar ); | 2608 | inR.setRevision( modifiedCalendar ); |
2607 | remote->insertAddressee( inR, false ); | 2609 | remote->insertAddressee( inR, false ); |
@@ -2636,56 +2638,58 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2636 | while ( incCounter < el.count()) { | 2638 | while ( incCounter < el.count()) { |
2637 | qApp->processEvents(); | 2639 | qApp->processEvents(); |
2638 | if (syncManager->isProgressBarCanceled()) | 2640 | if (syncManager->isProgressBarCanceled()) |
2639 | return false; | 2641 | return false; |
2640 | if ( incCounter % modulo == 0 ) | 2642 | if ( incCounter % modulo == 0 ) |
2641 | syncManager->showProgressBar(incCounter); | 2643 | syncManager->showProgressBar(incCounter); |
2642 | uid = el[ incCounter ]; | 2644 | uid = el[ incCounter ]; |
2643 | bool skipIncidence = false; | 2645 | bool skipIncidence = false; |
2644 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2646 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2645 | skipIncidence = true; | 2647 | skipIncidence = true; |
2646 | if ( !skipIncidence ) { | 2648 | if ( !skipIncidence ) { |
2647 | inL = local->findByUid( uid ); | 2649 | inL = local->findByUid( uid ); |
2648 | inR = remote->findByUid( uid ); | 2650 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2649 | if ( inR.isEmpty() ) { | 2651 | inR = remote->findByUid( uid ); |
2650 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2652 | if ( inR.isEmpty() ) { |
2651 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2653 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2652 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2654 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2653 | local->removeAddressee( inL ); | 2655 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2654 | ++deletedAddresseeL; | 2656 | local->removeAddressee( inL ); |
2655 | } else { | 2657 | ++deletedAddresseeL; |
2656 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2658 | } else { |
2657 | inL.removeID(mCurrentSyncDevice ); | 2659 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2658 | ++addedAddresseeR; | 2660 | inL.removeID(mCurrentSyncDevice ); |
2659 | inL.setRevision( modifiedCalendar ); | 2661 | ++addedAddresseeR; |
2660 | local->insertAddressee( inL, false ); | 2662 | inL.setRevision( modifiedCalendar ); |
2661 | inR = inL; | 2663 | local->insertAddressee( inL, false ); |
2662 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2664 | inR = inL; |
2663 | inR.setResource( 0 ); | 2665 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2664 | remote->insertAddressee( inR, false ); | 2666 | inR.setResource( 0 ); |
2667 | remote->insertAddressee( inR, false ); | ||
2668 | } | ||
2665 | } | 2669 | } |
2666 | } | ||
2667 | } else { | ||
2668 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | ||
2669 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | ||
2670 | local->removeAddressee( inL ); | ||
2671 | ++deletedAddresseeL; | ||
2672 | } else { | 2670 | } else { |
2673 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2671 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2674 | ++addedAddresseeR; | 2672 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2675 | inL.setRevision( modifiedCalendar ); | 2673 | local->removeAddressee( inL ); |
2676 | local->insertAddressee( inL, false ); | 2674 | ++deletedAddresseeL; |
2677 | inR = inL; | 2675 | } else { |
2678 | inR.setResource( 0 ); | 2676 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2679 | remote->insertAddressee( inR, false ); | 2677 | ++addedAddresseeR; |
2678 | inL.setRevision( modifiedCalendar ); | ||
2679 | local->insertAddressee( inL, false ); | ||
2680 | inR = inL; | ||
2681 | inR.setResource( 0 ); | ||
2682 | remote->insertAddressee( inR, false ); | ||
2683 | } | ||
2680 | } | 2684 | } |
2681 | } | 2685 | } |
2682 | } | 2686 | } |
2683 | } | 2687 | } |
2684 | } | 2688 | } |
2685 | ++incCounter; | 2689 | ++incCounter; |
2686 | } | 2690 | } |
2687 | el.clear(); | 2691 | el.clear(); |
2688 | syncManager->hideProgressBar(); | 2692 | syncManager->hideProgressBar(); |
2689 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2693 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2690 | // get rid of micro seconds | 2694 | // get rid of micro seconds |
2691 | QTime t = mLastAddressbookSync.time(); | 2695 | QTime t = mLastAddressbookSync.time(); |
diff --git a/microkde/kresources/configdialog.cpp b/microkde/kresources/configdialog.cpp index f8240f9..030b547 100644 --- a/microkde/kresources/configdialog.cpp +++ b/microkde/kresources/configdialog.cpp | |||
@@ -66,26 +66,30 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, | |||
66 | QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); | 66 | QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); |
67 | 67 | ||
68 | 68 | ||
69 | QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); | 69 | QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); |
70 | generalGroupBox->layout()->setSpacing( spacingHint() ); | 70 | generalGroupBox->layout()->setSpacing( spacingHint() ); |
71 | generalGroupBox->setTitle( i18n( "General Settings" ) ); | 71 | generalGroupBox->setTitle( i18n( "General Settings" ) ); |
72 | 72 | ||
73 | new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox ); | 73 | new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox ); |
74 | 74 | ||
75 | mName = new KLineEdit( generalGroupBox ); | 75 | mName = new KLineEdit( generalGroupBox ); |
76 | 76 | ||
77 | if (!mResource->isSyncable()) { | 77 | if (!mResource->isSyncable()) { |
78 | new QLabel("", generalGroupBox ); | ||
78 | mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); | 79 | mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); |
79 | mReadOnly->setChecked( mResource->readOnly() ); | 80 | mReadOnly->setChecked( mResource->readOnly() ); |
81 | new QLabel("", generalGroupBox ); | ||
82 | mIncludeInSync = new QCheckBox( i18n( "Include in sync" ), generalGroupBox ); | ||
83 | mIncludeInSync->setChecked( mResource->includeInSync() ); | ||
80 | } | 84 | } |
81 | 85 | ||
82 | mName->setText( mResource->resourceName() ); | 86 | mName->setText( mResource->resourceName() ); |
83 | 87 | ||
84 | mainLayout->addWidget( generalGroupBox ); | 88 | mainLayout->addWidget( generalGroupBox ); |
85 | 89 | ||
86 | QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); | 90 | QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); |
87 | resourceGroupBox->layout()->setSpacing( spacingHint()); | 91 | resourceGroupBox->layout()->setSpacing( spacingHint()); |
88 | resourceGroupBox->setTitle( i18n( "%1 Resource Settings" ) | 92 | resourceGroupBox->setTitle( i18n( "%1 Resource Settings" ) |
89 | .arg( factory->typeName( resource->type() ) ) ); | 93 | .arg( factory->typeName( resource->type() ) ) ); |
90 | mainLayout->addWidget( resourceGroupBox ); | 94 | mainLayout->addWidget( resourceGroupBox ); |
91 | 95 | ||
@@ -211,24 +215,25 @@ void ConfigDialog::setPersistentReadOnly( bool value ) | |||
211 | } | 215 | } |
212 | 216 | ||
213 | void ConfigDialog::accept() | 217 | void ConfigDialog::accept() |
214 | { | 218 | { |
215 | if ( mName->text().isEmpty() ) { | 219 | if ( mName->text().isEmpty() ) { |
216 | KMessageBox::sorry( this, mResource->isSyncable()?i18n( "Please enter a profile name" ):i18n( "Please enter a resource name" ) ); | 220 | KMessageBox::sorry( this, mResource->isSyncable()?i18n( "Please enter a profile name" ):i18n( "Please enter a resource name" ) ); |
217 | return; | 221 | return; |
218 | } | 222 | } |
219 | 223 | ||
220 | mResource->setResourceName( mName->text() ); | 224 | mResource->setResourceName( mName->text() ); |
221 | if (!mResource->isSyncable()) | 225 | if (!mResource->isSyncable()) |
222 | mResource->setReadOnly( mReadOnly->isChecked() ); | 226 | mResource->setReadOnly( mReadOnly->isChecked() ); |
227 | mResource->setIncludeInSync( mIncludeInSync->isChecked() ); | ||
223 | 228 | ||
224 | if ( mConfigWidget ) { | 229 | if ( mConfigWidget ) { |
225 | // First save generic information | 230 | // First save generic information |
226 | // Also save setting of specific resource type | 231 | // Also save setting of specific resource type |
227 | mConfigWidget->saveSettings( mResource ); | 232 | mConfigWidget->saveSettings( mResource ); |
228 | } | 233 | } |
229 | 234 | ||
230 | if ( mSyncWidget_Settings ) | 235 | if ( mSyncWidget_Settings ) |
231 | mSyncWidget_Settings->saveSettings( mResource ); | 236 | mSyncWidget_Settings->saveSettings( mResource ); |
232 | if ( mSyncWidget_Conflicts ) | 237 | if ( mSyncWidget_Conflicts ) |
233 | mSyncWidget_Conflicts->saveSettings( mResource ); | 238 | mSyncWidget_Conflicts->saveSettings( mResource ); |
234 | if ( mSyncWidget_Remote ) | 239 | if ( mSyncWidget_Remote ) |
diff --git a/microkde/kresources/configdialog.h b/microkde/kresources/configdialog.h index 63cd4e9..ed3ecab 100644 --- a/microkde/kresources/configdialog.h +++ b/microkde/kresources/configdialog.h | |||
@@ -49,19 +49,20 @@ class ConfigDialog : public KDialogBase | |||
49 | void setPersistentReadOnly( bool value ); | 49 | void setPersistentReadOnly( bool value ); |
50 | void slotNameChanged( const QString &text); | 50 | void slotNameChanged( const QString &text); |
51 | 51 | ||
52 | private: | 52 | private: |
53 | ConfigWidget *mConfigWidget; | 53 | ConfigWidget *mConfigWidget; |
54 | SyncWidget *mSyncWidget_Settings; | 54 | SyncWidget *mSyncWidget_Settings; |
55 | SyncWidget *mSyncWidget_Conflicts; | 55 | SyncWidget *mSyncWidget_Conflicts; |
56 | SyncWidget *mSyncWidget_Remote; | 56 | SyncWidget *mSyncWidget_Remote; |
57 | Resource* mResource; | 57 | Resource* mResource; |
58 | 58 | ||
59 | KLineEdit *mName; | 59 | KLineEdit *mName; |
60 | QCheckBox *mReadOnly; | 60 | QCheckBox *mReadOnly; |
61 | QCheckBox *mIncludeInSync; | ||
61 | //US add a persistent readonly flag. We need that for opie and qtopia addressbooks. | 62 | //US add a persistent readonly flag. We need that for opie and qtopia addressbooks. |
62 | bool mPersistentReadOnly; | 63 | bool mPersistentReadOnly; |
63 | }; | 64 | }; |
64 | 65 | ||
65 | } | 66 | } |
66 | 67 | ||
67 | #endif | 68 | #endif |
diff --git a/microkde/kresources/resource.cpp b/microkde/kresources/resource.cpp index 4f69540..f79bcd0 100644 --- a/microkde/kresources/resource.cpp +++ b/microkde/kresources/resource.cpp | |||
@@ -30,72 +30,74 @@ | |||
30 | using namespace KRES; | 30 | using namespace KRES; |
31 | 31 | ||
32 | class Resource::ResourcePrivate | 32 | class Resource::ResourcePrivate |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | #ifdef QT_THREAD_SUPPORT | 35 | #ifdef QT_THREAD_SUPPORT |
36 | QMutex mMutex; | 36 | QMutex mMutex; |
37 | #endif | 37 | #endif |
38 | int mOpenCount; | 38 | int mOpenCount; |
39 | QString mType; | 39 | QString mType; |
40 | QString mIdentifier; | 40 | QString mIdentifier; |
41 | bool mReadOnly; | 41 | bool mReadOnly; |
42 | bool mIncludeInSync; | ||
42 | QString mName; | 43 | QString mName; |
43 | bool mActive; | 44 | bool mActive; |
44 | bool mIsOpen; | 45 | bool mIsOpen; |
45 | }; | 46 | }; |
46 | 47 | ||
47 | Resource::Resource( const KConfig* config ) | 48 | Resource::Resource( const KConfig* config ) |
48 | : QObject( 0, "" ), d( new ResourcePrivate ) | 49 | : QObject( 0, "" ), d( new ResourcePrivate ) |
49 | { | 50 | { |
50 | d->mOpenCount = 0; | 51 | d->mOpenCount = 0; |
51 | d->mIsOpen = false; | 52 | d->mIsOpen = false; |
52 | 53 | ||
53 | //US compiler claimed that const discards qualifier | 54 | //US compiler claimed that const discards qualifier |
54 | KConfig* cfg = (KConfig*)config; | 55 | KConfig* cfg = (KConfig*)config; |
55 | if ( cfg ) { | 56 | if ( cfg ) { |
56 | #ifdef _WIN32_ | 57 | #ifdef _WIN32_ |
57 | // we use plugins on win32. the group is stored in a static variable | 58 | // we use plugins on win32. the group is stored in a static variable |
58 | // such that group info not available on win32 plugins | 59 | // such that group info not available on win32 plugins |
59 | // to fix that, it would be a looooot of work | 60 | // to fix that, it would be a looooot of work |
60 | if ( !cfg->tempGroup().isEmpty() ) | 61 | if ( !cfg->tempGroup().isEmpty() ) |
61 | cfg->setGroup( cfg->tempGroup() ); | 62 | cfg->setGroup( cfg->tempGroup() ); |
62 | #endif | 63 | #endif |
63 | d->mType = cfg->readEntry( "ResourceType" ); | 64 | d->mType = cfg->readEntry( "ResourceType" ); |
64 | d->mName = cfg->readEntry( "ResourceName" ); | 65 | d->mName = cfg->readEntry( "ResourceName" ); |
65 | d->mReadOnly = cfg->readBoolEntry( "ResourceIsReadOnly", false ); | 66 | d->mReadOnly = cfg->readBoolEntry( "ResourceIsReadOnly", false ); |
67 | d->mIncludeInSync = cfg->readBoolEntry( "ResourceIncludeInSync", true );; | ||
66 | d->mActive = cfg->readBoolEntry( "ResourceIsActive", true ); | 68 | d->mActive = cfg->readBoolEntry( "ResourceIsActive", true ); |
67 | d->mIdentifier = cfg->readEntry( "ResourceIdentifier" ); | 69 | d->mIdentifier = cfg->readEntry( "ResourceIdentifier" ); |
68 | } else { | 70 | } else { |
69 | d->mType = "type"; | 71 | d->mType = "type"; |
70 | d->mName = "resource-name"; | 72 | d->mName = "resource-name"; |
71 | d->mReadOnly = false; | 73 | d->mReadOnly = false; |
74 | d->mIncludeInSync = true; | ||
72 | d->mActive = true; | 75 | d->mActive = true; |
73 | d->mIdentifier = KApplication::randomString( 10 ); | 76 | d->mIdentifier = KApplication::randomString( 10 ); |
74 | } | 77 | } |
75 | } | 78 | } |
76 | 79 | ||
77 | Resource::~Resource() | 80 | Resource::~Resource() |
78 | { | 81 | { |
79 | delete d; | 82 | delete d; |
80 | d = 0; | 83 | d = 0; |
81 | } | 84 | } |
82 | 85 | ||
83 | void Resource::writeConfig( KConfig* config ) | 86 | void Resource::writeConfig( KConfig* config ) |
84 | { | 87 | { |
85 | |||
86 | |||
87 | config->writeEntry( "ResourceType", d->mType ); | 88 | config->writeEntry( "ResourceType", d->mType ); |
88 | config->writeEntry( "ResourceName", d->mName ); | 89 | config->writeEntry( "ResourceName", d->mName ); |
89 | config->writeEntry( "ResourceIsReadOnly", d->mReadOnly ); | 90 | config->writeEntry( "ResourceIsReadOnly", d->mReadOnly ); |
91 | config->writeEntry( "ResourceIncludeInSync", d->mIncludeInSync ); | ||
90 | config->writeEntry( "ResourceIsActive", d->mActive ); | 92 | config->writeEntry( "ResourceIsActive", d->mActive ); |
91 | config->writeEntry( "ResourceIdentifier", d->mIdentifier ); | 93 | config->writeEntry( "ResourceIdentifier", d->mIdentifier ); |
92 | } | 94 | } |
93 | 95 | ||
94 | bool Resource::open() | 96 | bool Resource::open() |
95 | { | 97 | { |
96 | d->mIsOpen = true; | 98 | d->mIsOpen = true; |
97 | #ifdef QT_THREAD_SUPPORT | 99 | #ifdef QT_THREAD_SUPPORT |
98 | QMutexLocker guard( &(d->mMutex) ); | 100 | QMutexLocker guard( &(d->mMutex) ); |
99 | #endif | 101 | #endif |
100 | if ( !d->mOpenCount ) { | 102 | if ( !d->mOpenCount ) { |
101 | kdDebug(5650) << "Opening resource " << resourceName() << endl; | 103 | kdDebug(5650) << "Opening resource " << resourceName() << endl; |
@@ -140,24 +142,32 @@ QString Resource::identifier() const | |||
140 | } | 142 | } |
141 | 143 | ||
142 | void Resource::setType( const QString& type ) | 144 | void Resource::setType( const QString& type ) |
143 | { | 145 | { |
144 | d->mType = type; | 146 | d->mType = type; |
145 | } | 147 | } |
146 | 148 | ||
147 | QString Resource::type() const | 149 | QString Resource::type() const |
148 | { | 150 | { |
149 | return d->mType; | 151 | return d->mType; |
150 | } | 152 | } |
151 | 153 | ||
154 | void Resource::setIncludeInSync( bool value ) | ||
155 | { | ||
156 | d->mIncludeInSync = value; | ||
157 | } | ||
158 | bool Resource::includeInSync() const | ||
159 | { | ||
160 | return d->mIncludeInSync; | ||
161 | } | ||
152 | void Resource::setReadOnly( bool value ) | 162 | void Resource::setReadOnly( bool value ) |
153 | { | 163 | { |
154 | d->mReadOnly = value; | 164 | d->mReadOnly = value; |
155 | } | 165 | } |
156 | 166 | ||
157 | bool Resource::readOnly() const | 167 | bool Resource::readOnly() const |
158 | { | 168 | { |
159 | return d->mReadOnly; | 169 | return d->mReadOnly; |
160 | } | 170 | } |
161 | 171 | ||
162 | void Resource::setResourceName( const QString &name ) | 172 | void Resource::setResourceName( const QString &name ) |
163 | { | 173 | { |
diff --git a/microkde/kresources/resource.h b/microkde/kresources/resource.h index 580b5d1..70b5613 100644 --- a/microkde/kresources/resource.h +++ b/microkde/kresources/resource.h | |||
@@ -301,24 +301,26 @@ class Resource : public QObject | |||
301 | 301 | ||
302 | /** | 302 | /** |
303 | * Mark the resource as read-only. You can override this method, | 303 | * Mark the resource as read-only. You can override this method, |
304 | * but also remember to call Resource::setReadOnly(). | 304 | * but also remember to call Resource::setReadOnly(). |
305 | */ | 305 | */ |
306 | virtual void setReadOnly( bool value ); | 306 | virtual void setReadOnly( bool value ); |
307 | 307 | ||
308 | /** | 308 | /** |
309 | * Returns, if the resource is read-only. | 309 | * Returns, if the resource is read-only. |
310 | */ | 310 | */ |
311 | virtual bool readOnly() const; | 311 | virtual bool readOnly() const; |
312 | 312 | ||
313 | void setIncludeInSync( bool value ); | ||
314 | bool includeInSync() const; | ||
313 | /** | 315 | /** |
314 | * Set the name of resource.You can override this method, | 316 | * Set the name of resource.You can override this method, |
315 | * but also remember to call Resource::setResourceName(). | 317 | * but also remember to call Resource::setResourceName(). |
316 | */ | 318 | */ |
317 | virtual void setResourceName( const QString &name ); | 319 | virtual void setResourceName( const QString &name ); |
318 | 320 | ||
319 | /** | 321 | /** |
320 | * Returns the name of resource. | 322 | * Returns the name of resource. |
321 | */ | 323 | */ |
322 | virtual QString resourceName() const; | 324 | virtual QString resourceName() const; |
323 | 325 | ||
324 | 326 | ||