summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp35
-rw-r--r--kabc/addressbook.h2
-rw-r--r--kaddressbook/kabcore.cpp146
-rw-r--r--microkde/kresources/configdialog.cpp5
-rw-r--r--microkde/kresources/configdialog.h1
-rw-r--r--microkde/kresources/resource.cpp14
-rw-r--r--microkde/kresources/resource.h2
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
@@ -315,263 +315,274 @@ void AddressBook::init(const QString &config, const QString &family )
315 "X-Office", "KADDRESSBOOK" ); 315 "X-Office", "KADDRESSBOOK" );
316 addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 316 addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
317 "X-IMAddress", "KADDRESSBOOK" ); 317 "X-IMAddress", "KADDRESSBOOK" );
318 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 318 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
319 "X-Anniversary", "KADDRESSBOOK" ); 319 "X-Anniversary", "KADDRESSBOOK" );
320 320
321 //US added this field to become compatible with Opie/qtopia addressbook 321 //US added this field to become compatible with Opie/qtopia addressbook
322 // values can be "female" or "male" or "". An empty field represents undefined. 322 // values can be "female" or "male" or "". An empty field represents undefined.
323 addCustomField( i18n( "Gender" ), KABC::Field::Personal, 323 addCustomField( i18n( "Gender" ), KABC::Field::Personal,
324 "X-Gender", "KADDRESSBOOK" ); 324 "X-Gender", "KADDRESSBOOK" );
325 addCustomField( i18n( "Children" ), KABC::Field::Personal, 325 addCustomField( i18n( "Children" ), KABC::Field::Personal,
326 "X-Children", "KADDRESSBOOK" ); 326 "X-Children", "KADDRESSBOOK" );
327 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 327 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
328 "X-FreeBusyUrl", "KADDRESSBOOK" ); 328 "X-FreeBusyUrl", "KADDRESSBOOK" );
329 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, 329 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal,
330 "X-ExternalID", "KADDRESSBOOK" ); 330 "X-ExternalID", "KADDRESSBOOK" );
331} 331}
332 332
333AddressBook::~AddressBook() 333AddressBook::~AddressBook()
334{ 334{
335 delete d->mConfig; d->mConfig = 0; 335 delete d->mConfig; d->mConfig = 0;
336 delete d->mManager; d->mManager = 0; 336 delete d->mManager; d->mManager = 0;
337//US delete d->mErrorHandler; d->mErrorHandler = 0; 337//US delete d->mErrorHandler; d->mErrorHandler = 0;
338 delete d; d = 0; 338 delete d; d = 0;
339} 339}
340 340
341bool AddressBook::load() 341bool AddressBook::load()
342{ 342{
343 343
344 clear(); 344 clear();
345 KRES::Manager<Resource>::ActiveIterator it; 345 KRES::Manager<Resource>::ActiveIterator it;
346 bool ok = true; 346 bool ok = true;
347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
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
368bool AddressBook::save( Ticket *ticket ) 368bool 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
379void AddressBook::export2File( QString fileName ) 380void 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
407bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) 410bool 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);
434 int dopp = vcard.find(":", next); 439 int dopp = vcard.find(":", next);
435 int sep; 440 int sep;
436 if ( semi < dopp && semi >= 0 ) 441 if ( semi < dopp && semi >= 0 )
437 sep = semi ; 442 sep = semi ;
438 else 443 else
439 sep = dopp; 444 sep = dopp;
440 vcardnew +=vcard.mid( start, next - start); 445 vcardnew +=vcard.mid( start, next - start);
441 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); 446 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
442 start = sep; 447 start = sep;
443 } 448 }
444 vcardnew += vcard.mid( start,vcard.length() ); 449 vcardnew += vcard.mid( start,vcard.length() );
445 vcard = ""; 450 vcard = "";
446 start = 0; 451 start = 0;
447 while ( (next = vcardnew.find("ADR", start) )>= 0 ) { 452 while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
448 int sep = vcardnew.find(":", next); 453 int sep = vcardnew.find(":", next);
449 vcard +=vcardnew.mid( start, next - start+3); 454 vcard +=vcardnew.mid( start, next - start+3);
450 start = sep; 455 start = sep;
451 } 456 }
452 vcard += vcardnew.mid( start,vcardnew.length() ); 457 vcard += vcardnew.mid( start,vcardnew.length() );
453 vcard.replace ( QRegExp(";;;") , "" ); 458 vcard.replace ( QRegExp(";;;") , "" );
454 vcard.replace ( QRegExp(";;") , "" ); 459 vcard.replace ( QRegExp(";;") , "" );
455 datastream += vcard; 460 datastream += vcard;
456 461
457 } 462 }
458 463
459 QFile outFile(fileName); 464 QFile outFile(fileName);
460 if ( outFile.open(IO_WriteOnly) ) { 465 if ( outFile.open(IO_WriteOnly) ) {
461 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 466 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
462 QTextStream t( &outFile ); // use a text stream 467 QTextStream t( &outFile ); // use a text stream
463 t.setEncoding( QTextStream::UnicodeUTF8 ); 468 t.setEncoding( QTextStream::UnicodeUTF8 );
464 t <<datastream; 469 t <<datastream;
465 t << "\r\n\r\n"; 470 t << "\r\n\r\n";
466 outFile.close(); 471 outFile.close();
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}
475void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) 480void 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 );
492 KABC::VCardTool tool; 497 KABC::VCardTool tool;
493 list = tool.parseVCards( data ); 498 list = tool.parseVCards( data );
494 KABC::Addressee::List::Iterator it; 499 KABC::Addressee::List::Iterator it;
495 for ( it = list.begin(); it != list.end(); ++it ) { 500 for ( it = list.begin(); it != list.end(); ++it ) {
496 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); 501 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
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}
509void AddressBook::setUntagged() 514void 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}
516void AddressBook::removeUntagged() 527void 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;
526 todel = ait; 537 todel = ait;
527 } else 538 } else
528 todelete = false; 539 todelete = false;
529 } 540 }
530 if ( todelete ) 541 if ( todelete )
531 removeAddressee( todel ); 542 removeAddressee( todel );
532 deleteRemovedAddressees(); 543 deleteRemovedAddressees();
533} 544}
534void AddressBook::smplifyAddressees() 545void AddressBook::smplifyAddressees()
535{ 546{
536 Iterator ait; 547 Iterator ait;
537 for ( ait = begin(); ait != end(); ++ait ) { 548 for ( ait = begin(); ait != end(); ++ait ) {
538 (*ait).simplifyEmails(); 549 (*ait).simplifyEmails();
539 (*ait).simplifyPhoneNumbers(); 550 (*ait).simplifyPhoneNumbers();
540 (*ait).simplifyPhoneNumberTypes(); 551 (*ait).simplifyPhoneNumberTypes();
541 (*ait).simplifyAddresses(); 552 (*ait).simplifyAddresses();
542 } 553 }
543} 554}
544void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) 555void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync )
545{ 556{
546 Iterator ait; 557 Iterator ait;
547 for ( ait = begin(); ait != end(); ++ait ) { 558 for ( ait = begin(); ait != end(); ++ait ) {
548 QString id = (*ait).IDStr(); 559 QString id = (*ait).IDStr();
549 (*ait).setIDStr( ":"); 560 (*ait).setIDStr( ":");
550 (*ait).setExternalUID( id ); 561 (*ait).setExternalUID( id );
551 (*ait).setOriginalExternalUID( id ); 562 (*ait).setOriginalExternalUID( id );
552 if ( isPreSync ) 563 if ( isPreSync )
553 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 564 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
554 else { 565 else {
555 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 566 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
556 (*ait).setID( currentSyncDevice,id ); 567 (*ait).setID( currentSyncDevice,id );
557 568
558 } 569 }
559 } 570 }
560} 571}
561void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) 572void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice )
562{ 573{
563 574
564 setUntagged(); 575 setUntagged();
565 KABC::Addressee::List list; 576 KABC::Addressee::List list;
566 QFile file( fileName ); 577 QFile file( fileName );
567 file.open( IO_ReadOnly ); 578 file.open( IO_ReadOnly );
568 QByteArray rawData = file.readAll(); 579 QByteArray rawData = file.readAll();
569 file.close(); 580 file.close();
570 QString data; 581 QString data;
571 582
572 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 583 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
573 KABC::VCardTool tool; 584 KABC::VCardTool tool;
574 list = tool.parseVCards( data ); 585 list = tool.parseVCards( data );
575 KABC::Addressee::List::Iterator it; 586 KABC::Addressee::List::Iterator it;
576 for ( it = list.begin(); it != list.end(); ++it ) { 587 for ( it = list.begin(); it != list.end(); ++it ) {
577 Iterator ait; 588 Iterator ait;
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index a6bf451..23bba02 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -87,129 +87,129 @@ class AddressBook : public QObject
87 @short Address Book Const Iterator 87 @short Address Book Const Iterator
88 88
89 This class provides a const iterator for address book entries. 89 This class provides a const iterator for address book entries.
90 */ 90 */
91 class ConstIterator 91 class ConstIterator
92 { 92 {
93 public: 93 public:
94 ConstIterator(); 94 ConstIterator();
95 ConstIterator( const ConstIterator & ); 95 ConstIterator( const ConstIterator & );
96 ~ConstIterator(); 96 ~ConstIterator();
97 97
98 ConstIterator &operator=( const ConstIterator & ); 98 ConstIterator &operator=( const ConstIterator & );
99 const Addressee &operator*() const; 99 const Addressee &operator*() const;
100 const Addressee* operator->() const; 100 const Addressee* operator->() const;
101 ConstIterator &operator++(); 101 ConstIterator &operator++();
102 ConstIterator &operator++(int); 102 ConstIterator &operator++(int);
103 ConstIterator &operator--(); 103 ConstIterator &operator--();
104 ConstIterator &operator--(int); 104 ConstIterator &operator--(int);
105 bool operator==( const ConstIterator &it ); 105 bool operator==( const ConstIterator &it );
106 bool operator!=( const ConstIterator &it ); 106 bool operator!=( const ConstIterator &it );
107 107
108 struct ConstIteratorData; 108 struct ConstIteratorData;
109 ConstIteratorData *d; 109 ConstIteratorData *d;
110 }; 110 };
111 111
112 /** 112 /**
113 Constructs a address book object. 113 Constructs a address book object.
114 114
115 @param format File format class. 115 @param format File format class.
116 */ 116 */
117 AddressBook(); 117 AddressBook();
118 AddressBook( const QString &config ); 118 AddressBook( const QString &config );
119 AddressBook( const QString &config, const QString &family ); 119 AddressBook( const QString &config, const QString &family );
120 virtual ~AddressBook(); 120 virtual ~AddressBook();
121 121
122 /** 122 /**
123 Requests a ticket for saving the addressbook. Calling this function locks 123 Requests a ticket for saving the addressbook. Calling this function locks
124 the addressbook for all other processes. If the address book is already 124 the addressbook for all other processes. If the address book is already
125 locked the function returns 0. You need the returned @ref Ticket object 125 locked the function returns 0. You need the returned @ref Ticket object
126 for calling the @ref save() function. 126 for calling the @ref save() function.
127 127
128 @see save() 128 @see save()
129 */ 129 */
130 Ticket *requestSaveTicket( Resource *resource=0 ); 130 Ticket *requestSaveTicket( Resource *resource=0 );
131 131
132 /** 132 /**
133 Load address book from file. 133 Load address book from file.
134 */ 134 */
135 bool load(); 135 bool load();
136 136
137 /** 137 /**
138 Save address book. The address book is saved to the file, the Ticket 138 Save address book. The address book is saved to the file, the Ticket
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
164 /** 164 /**
165 Returns a iterator for first entry of address book. 165 Returns a iterator for first entry of address book.
166 */ 166 */
167 Iterator end(); 167 Iterator end();
168 168
169 /** 169 /**
170 Returns a const iterator for first entry of address book. 170 Returns a const iterator for first entry of address book.
171 */ 171 */
172 ConstIterator end() const; 172 ConstIterator end() const;
173 173
174 /** 174 /**
175 Removes all entries from address book. 175 Removes all entries from address book.
176 */ 176 */
177 void clear(); 177 void clear();
178 178
179 /** 179 /**
180 Insert an Addressee object into address book. If an object with the same 180 Insert an Addressee object into address book. If an object with the same
181 unique id already exists in the address book it it replaced by the new 181 unique id already exists in the address book it it replaced by the new
182 one. If not the new object is appended to the address book. 182 one. If not the new object is appended to the address book.
183 */ 183 */
184 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); 184 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
185 185
186 /** 186 /**
187 Removes entry from the address book. 187 Removes entry from the address book.
188 */ 188 */
189 void removeAddressee( const Addressee & ); 189 void removeAddressee( const Addressee & );
190 190
191 /** 191 /**
192 This is like @ref removeAddressee() just above, with the difference that 192 This is like @ref removeAddressee() just above, with the difference that
193 the first element is a iterator, returned by @ref begin(). 193 the first element is a iterator, returned by @ref begin().
194 */ 194 */
195 void removeAddressee( const Iterator & ); 195 void removeAddressee( const Iterator & );
196 196
197 /** 197 /**
198 Find the specified entry in address book. Returns end(), if the entry 198 Find the specified entry in address book. Returns end(), if the entry
199 couldn't be found. 199 couldn't be found.
200 */ 200 */
201 Iterator find( const Addressee & ); 201 Iterator find( const Addressee & );
202 202
203 /** 203 /**
204 Find the entry specified by an unique id. Returns an empty Addressee 204 Find the entry specified by an unique id. Returns an empty Addressee
205 object, if the address book does not contain an entry with this id. 205 object, if the address book does not contain an entry with this id.
206 */ 206 */
207 Addressee findByUid( const QString & ); 207 Addressee findByUid( const QString & );
208 208
209 209
210 /** 210 /**
211 Returns a list of all addressees in the address book. This list can 211 Returns a list of all addressees in the address book. This list can
212 be sorted with @ref KABC::AddresseeList for example. 212 be sorted with @ref KABC::AddresseeList for example.
213 */ 213 */
214 Addressee::List allAddressees(); 214 Addressee::List allAddressees();
215 215
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index ea34be2..47ed858 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2490,254 +2490,258 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2490 fullDateRange = true; 2490 fullDateRange = true;
2491 Addressee newAdd; 2491 Addressee newAdd;
2492 addresseeRSync = newAdd; 2492 addresseeRSync = newAdd;
2493 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2493 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2494 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2494 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2495 addresseeRSync.setRevision( mLastAddressbookSync ); 2495 addresseeRSync.setRevision( mLastAddressbookSync );
2496 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2496 addresseeRSync.setCategories( i18n("SyncAddressee") );
2497 } 2497 }
2498 } 2498 }
2499 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2499 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2500 qDebug("FULLDATE 2"); 2500 qDebug("FULLDATE 2");
2501 fullDateRange = true; 2501 fullDateRange = true;
2502 } 2502 }
2503 if ( ! fullDateRange ) { 2503 if ( ! fullDateRange ) {
2504 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2504 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2505 2505
2506 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2506 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2507 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2507 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2508 fullDateRange = true; 2508 fullDateRange = true;
2509 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2509 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2510 } 2510 }
2511 } 2511 }
2512 // fullDateRange = true; // debug only! 2512 // fullDateRange = true; // debug only!
2513 if ( fullDateRange ) 2513 if ( fullDateRange )
2514 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2514 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2515 else 2515 else
2516 mLastAddressbookSync = addresseeLSync.revision(); 2516 mLastAddressbookSync = addresseeLSync.revision();
2517 // for resyncing if own file has changed 2517 // for resyncing if own file has changed
2518 // PENDING fixme later when implemented 2518 // PENDING fixme later when implemented
2519#if 0 2519#if 0
2520 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2520 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2521 mLastAddressbookSync = loadedFileVersion; 2521 mLastAddressbookSync = loadedFileVersion;
2522 qDebug("setting mLastAddressbookSync "); 2522 qDebug("setting mLastAddressbookSync ");
2523 } 2523 }
2524#endif 2524#endif
2525 2525
2526 //qDebug("*************************** "); 2526 //qDebug("*************************** ");
2527 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2527 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2528 QStringList er = remote->uidList(); 2528 QStringList er = remote->uidList();
2529 Addressee inR ;//= er.first(); 2529 Addressee inR ;//= er.first();
2530 Addressee inL; 2530 Addressee inL;
2531 2531
2532 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2532 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2533 2533
2534 int modulo = (er.count()/10)+1; 2534 int modulo = (er.count()/10)+1;
2535 int incCounter = 0; 2535 int incCounter = 0;
2536 while ( incCounter < er.count()) { 2536 while ( incCounter < er.count()) {
2537 if (syncManager->isProgressBarCanceled()) 2537 if (syncManager->isProgressBarCanceled())
2538 return false; 2538 return false;
2539 if ( incCounter % modulo == 0 ) 2539 if ( incCounter % modulo == 0 )
2540 syncManager->showProgressBar(incCounter); 2540 syncManager->showProgressBar(incCounter);
2541 2541
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 );
2608 inL = inR; 2610 inL = inR;
2609 inL.setResource( 0 ); 2611 inL.setResource( 0 );
2610 local->insertAddressee( inL , false); 2612 local->insertAddressee( inL , false);
2611 ++addedAddressee; 2613 ++addedAddressee;
2612 } 2614 }
2613 } else { 2615 } else {
2614 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2616 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2615 inR.setRevision( modifiedCalendar ); 2617 inR.setRevision( modifiedCalendar );
2616 remote->insertAddressee( inR, false ); 2618 remote->insertAddressee( inR, false );
2617 inR.setResource( 0 ); 2619 inR.setResource( 0 );
2618 local->insertAddressee( inR, false ); 2620 local->insertAddressee( inR, false );
2619 ++addedAddressee; 2621 ++addedAddressee;
2620 } else { 2622 } else {
2621 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2623 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2622 remote->removeAddressee( inR ); 2624 remote->removeAddressee( inR );
2623 ++deletedAddresseeR; 2625 ++deletedAddresseeR;
2624 } 2626 }
2625 } 2627 }
2626 } 2628 }
2627 } 2629 }
2628 ++incCounter; 2630 ++incCounter;
2629 } 2631 }
2630 er.clear(); 2632 er.clear();
2631 QStringList el = local->uidList(); 2633 QStringList el = local->uidList();
2632 modulo = (el.count()/10)+1; 2634 modulo = (el.count()/10)+1;
2633 2635
2634 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2636 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2635 incCounter = 0; 2637 incCounter = 0;
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();
2692 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2696 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2693 addresseeLSync.setRevision( mLastAddressbookSync ); 2697 addresseeLSync.setRevision( mLastAddressbookSync );
2694 addresseeRSync.setRevision( mLastAddressbookSync ); 2698 addresseeRSync.setRevision( mLastAddressbookSync );
2695 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2699 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2696 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2700 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2697 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2701 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2698 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2702 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2699 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2703 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2700 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2704 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2701 addresseeRSync.setNote( "" ) ; 2705 addresseeRSync.setNote( "" ) ;
2702 addresseeLSync.setNote( "" ); 2706 addresseeLSync.setNote( "" );
2703 2707
2704 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2708 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2705 remote->insertAddressee( addresseeRSync, false ); 2709 remote->insertAddressee( addresseeRSync, false );
2706 local->insertAddressee( addresseeLSync, false ); 2710 local->insertAddressee( addresseeLSync, false );
2707 QString mes; 2711 QString mes;
2708 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2712 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2709 if ( syncManager->mShowSyncSummary ) { 2713 if ( syncManager->mShowSyncSummary ) {
2710 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2714 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2711 } 2715 }
2712 qDebug( mes ); 2716 qDebug( mes );
2713 return syncOK; 2717 return syncOK;
2714} 2718}
2715 2719
2716 2720
2717//this is a overwritten callbackmethods from the syncinterface 2721//this is a overwritten callbackmethods from the syncinterface
2718bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2722bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2719{ 2723{
2720 2724
2721 //pending prepare addresseeview for output 2725 //pending prepare addresseeview for output
2722 //pending detect, if remote file has REV field. if not switch to external sync 2726 //pending detect, if remote file has REV field. if not switch to external sync
2723 mGlobalSyncMode = SYNC_MODE_NORMAL; 2727 mGlobalSyncMode = SYNC_MODE_NORMAL;
2724 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2728 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2725 2729
2726 AddressBook abLocal(filename,"syncContact"); 2730 AddressBook abLocal(filename,"syncContact");
2727 bool syncOK = false; 2731 bool syncOK = false;
2728 if ( abLocal.load() ) { 2732 if ( abLocal.load() ) {
2729 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2733 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2730 bool external = false; 2734 bool external = false;
2731 bool isXML = false; 2735 bool isXML = false;
2732 if ( filename.right(4) == ".xml") { 2736 if ( filename.right(4) == ".xml") {
2733 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2737 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2734 isXML = true; 2738 isXML = true;
2735 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2739 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2736 } else { 2740 } else {
2737 external = !manager->mIsKapiFile; 2741 external = !manager->mIsKapiFile;
2738 if ( external ) { 2742 if ( external ) {
2739 qDebug("Setting vcf mode to external "); 2743 qDebug("Setting vcf mode to external ");
2740 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2744 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2741 AddressBook::Iterator it; 2745 AddressBook::Iterator it;
2742 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2746 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2743 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2747 (*it).setID( mCurrentSyncDevice, (*it).uid() );
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
@@ -14,130 +14,134 @@
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#include <klocale.h> 24#include <klocale.h>
25#include <kglobal.h> 25#include <kglobal.h>
26#include <kmessagebox.h> 26#include <kmessagebox.h>
27 27
28#include <qgroupbox.h> 28#include <qgroupbox.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qlayout.h> 30#include <qlayout.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qvbox.h> 32#include <qvbox.h>
33 33
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qscrollview.h> 35#include <qscrollview.h>
36 36
37#include <kbuttonbox.h> 37#include <kbuttonbox.h>
38#include <kdialog.h> 38#include <kdialog.h>
39#include <klineedit.h> 39#include <klineedit.h>
40 40
41#include "factory.h" 41#include "factory.h"
42#include "configwidget.h" 42#include "configwidget.h"
43#include "configdialog.h" 43#include "configdialog.h"
44#include "syncwidget.h" 44#include "syncwidget.h"
45 45
46using namespace KRES; 46using namespace KRES;
47 47
48ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, 48ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
49 Resource* resource, const char *name ) 49 Resource* resource, const char *name )
50 : KDialogBase( parent, name, true, resource->isSyncable()?i18n( "Sync Profile Configuration" ):i18n( "Resource Configuration" ), 50 : KDialogBase( parent, name, true, resource->isSyncable()?i18n( "Sync Profile Configuration" ):i18n( "Resource Configuration" ),
51 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mSyncWidget_Settings(0), mSyncWidget_Conflicts(0),mSyncWidget_Remote(0), mResource( resource ), mPersistentReadOnly(false) 51 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mSyncWidget_Settings(0), mSyncWidget_Conflicts(0),mSyncWidget_Remote(0), mResource( resource ), mPersistentReadOnly(false)
52{ 52{
53 53
54 Factory *factory = Factory::self( resourceFamily ); 54 Factory *factory = Factory::self( resourceFamily );
55 55
56//US resize( 250, 240 ); 56//US resize( 250, 240 );
57 resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); 57 resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240));
58 58
59 QFrame *main; 59 QFrame *main;
60 60
61 if (!mResource->isSyncable()) 61 if (!mResource->isSyncable())
62 main = plainPage(); 62 main = plainPage();
63 else 63 else
64 main = addPage("Profile"); 64 main = addPage("Profile");
65 65
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
92 mainLayout->addStretch(); 96 mainLayout->addStretch();
93 97
94 mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); 98 mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox );
95 if ( mConfigWidget ) { 99 if ( mConfigWidget ) {
96 connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), 100 connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ),
97 SLOT( setReadOnly( bool ) ) ); 101 SLOT( setReadOnly( bool ) ) );
98 connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), 102 connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ),
99 SLOT( setPersistentReadOnly( bool ) ) ); 103 SLOT( setPersistentReadOnly( bool ) ) );
100 mConfigWidget->setInEditMode( false ); 104 mConfigWidget->setInEditMode( false );
101 mConfigWidget->loadSettings( mResource ); 105 mConfigWidget->loadSettings( mResource );
102 mConfigWidget->show(); 106 mConfigWidget->show();
103 107
104 } 108 }
105 109
106 if (mResource->isSyncable()) 110 if (mResource->isSyncable())
107 { 111 {
108 SyncWidgetContainer* c = factory->syncWidgetContainer( resource->type() ); 112 SyncWidgetContainer* c = factory->syncWidgetContainer( resource->type() );
109 113
110 QFrame* syncPage = addPage("Settings"); 114 QFrame* syncPage = addPage("Settings");
111 QVBoxLayout *syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() ); 115 QVBoxLayout *syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() );
112 mSyncWidget_Settings = c->generateSettingsTab(syncPage); 116 mSyncWidget_Settings = c->generateSettingsTab(syncPage);
113 syncLayout->addWidget( mSyncWidget_Settings ); 117 syncLayout->addWidget( mSyncWidget_Settings );
114 118
115 syncPage = addPage("Conflicts"); 119 syncPage = addPage("Conflicts");
116 syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() ); 120 syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() );
117 mSyncWidget_Conflicts = c->generateConflictsTab(syncPage); 121 mSyncWidget_Conflicts = c->generateConflictsTab(syncPage);
118 syncLayout->addWidget( mSyncWidget_Conflicts ); 122 syncLayout->addWidget( mSyncWidget_Conflicts );
119 123
120 syncPage = addPage("Remote"); 124 syncPage = addPage("Remote");
121 syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() ); 125 syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() );
122 mSyncWidget_Remote = c->generateRemoteTab(syncPage); 126 mSyncWidget_Remote = c->generateRemoteTab(syncPage);
123 syncLayout->addWidget( mSyncWidget_Remote ); 127 syncLayout->addWidget( mSyncWidget_Remote );
124 128
125 129
126 mSyncWidget_Settings->setInEditMode( false ); 130 mSyncWidget_Settings->setInEditMode( false );
127 mSyncWidget_Settings->loadSettings( mResource ); 131 mSyncWidget_Settings->loadSettings( mResource );
128 mSyncWidget_Settings->show(); 132 mSyncWidget_Settings->show();
129 133
130 mSyncWidget_Conflicts->setInEditMode( false ); 134 mSyncWidget_Conflicts->setInEditMode( false );
131 mSyncWidget_Conflicts->loadSettings( mResource ); 135 mSyncWidget_Conflicts->loadSettings( mResource );
132 mSyncWidget_Conflicts->show(); 136 mSyncWidget_Conflicts->show();
133 137
134 mSyncWidget_Remote->setInEditMode( false ); 138 mSyncWidget_Remote->setInEditMode( false );
135 mSyncWidget_Remote->loadSettings( mResource ); 139 mSyncWidget_Remote->loadSettings( mResource );
136 mSyncWidget_Remote->show(); 140 mSyncWidget_Remote->show();
137 141
138 delete c; 142 delete c;
139 143
140// QGroupBox *syncGroupBox = new QGroupBox( 2, Qt::Horizontal, syncPage ); 144// QGroupBox *syncGroupBox = new QGroupBox( 2, Qt::Horizontal, syncPage );
141// syncGroupBox->layout()->setSpacing( spacingHint()); 145// syncGroupBox->layout()->setSpacing( spacingHint());
142// syncGroupBox->setTitle( i18n( "Syncronize Preferences" ) ); 146// syncGroupBox->setTitle( i18n( "Syncronize Preferences" ) );
143// syncLayout->addWidget( syncGroupBox ); 147// syncLayout->addWidget( syncGroupBox );
@@ -159,83 +163,84 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
159 163
160 connect( mName, SIGNAL( textChanged(const QString &)), 164 connect( mName, SIGNAL( textChanged(const QString &)),
161 SLOT( slotNameChanged(const QString &))); 165 SLOT( slotNameChanged(const QString &)));
162 166
163 slotNameChanged( mName->text() ); 167 slotNameChanged( mName->text() );
164 168
165//US setMinimumSize( 400, 250 ); 169//US setMinimumSize( 400, 250 );
166 setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); 170 setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250));
167 171
168} 172}
169 173
170void ConfigDialog::setInEditMode( bool value ) 174void ConfigDialog::setInEditMode( bool value )
171{ 175{
172 if ( mConfigWidget ) 176 if ( mConfigWidget )
173 mConfigWidget->setInEditMode( value ); 177 mConfigWidget->setInEditMode( value );
174 178
175 if ( mSyncWidget_Settings ) 179 if ( mSyncWidget_Settings )
176 mSyncWidget_Settings->setInEditMode( value ); 180 mSyncWidget_Settings->setInEditMode( value );
177 if ( mSyncWidget_Conflicts ) 181 if ( mSyncWidget_Conflicts )
178 mSyncWidget_Conflicts->setInEditMode( value ); 182 mSyncWidget_Conflicts->setInEditMode( value );
179 if ( mSyncWidget_Remote ) 183 if ( mSyncWidget_Remote )
180 mSyncWidget_Remote->setInEditMode( value ); 184 mSyncWidget_Remote->setInEditMode( value );
181 185
182} 186}
183 187
184void ConfigDialog::slotNameChanged( const QString &text) 188void ConfigDialog::slotNameChanged( const QString &text)
185{ 189{
186 enableButtonOK( !text.isEmpty() ); 190 enableButtonOK( !text.isEmpty() );
187} 191}
188 192
189void ConfigDialog::setReadOnly( bool value ) 193void ConfigDialog::setReadOnly( bool value )
190{ 194{
191 if (!mResource->isSyncable()) { 195 if (!mResource->isSyncable()) {
192 196
193 if (mPersistentReadOnly == false) 197 if (mPersistentReadOnly == false)
194 mReadOnly->setChecked( value ); 198 mReadOnly->setChecked( value );
195 else 199 else
196 mReadOnly->setChecked( true ); 200 mReadOnly->setChecked( true );
197 } 201 }
198} 202}
199 203
200void ConfigDialog::setPersistentReadOnly( bool value ) 204void ConfigDialog::setPersistentReadOnly( bool value )
201{ 205{
202 if (!mResource->isSyncable()) { 206 if (!mResource->isSyncable()) {
203 207
204 mPersistentReadOnly = value; 208 mPersistentReadOnly = value;
205 209
206 if (value == true) 210 if (value == true)
207 setReadOnly( true ); 211 setReadOnly( true );
208 212
209 mReadOnly->setEnabled( !value ); 213 mReadOnly->setEnabled( !value );
210 } 214 }
211} 215}
212 216
213void ConfigDialog::accept() 217void 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 )
235 mSyncWidget_Remote->saveSettings( mResource ); 240 mSyncWidget_Remote->saveSettings( mResource );
236 241
237 242
238 KDialog::accept(); 243 KDialog::accept();
239} 244}
240 245
241//US #include "configdialog.moc" 246//US #include "configdialog.moc"
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
@@ -1,67 +1,68 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 4 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef KRESOURCES_CONFIGDIALOG_H 22#ifndef KRESOURCES_CONFIGDIALOG_H
23#define KRESOURCES_CONFIGDIALOG_H 23#define KRESOURCES_CONFIGDIALOG_H
24 24
25#include <kdialogbase.h> 25#include <kdialogbase.h>
26 26
27class KLineEdit; 27class KLineEdit;
28class QCheckBox; 28class QCheckBox;
29class KButtonBox; 29class KButtonBox;
30 30
31namespace KRES { 31namespace KRES {
32 class Resource; 32 class Resource;
33 class ConfigWidget; 33 class ConfigWidget;
34 class SyncWidget; 34 class SyncWidget;
35 35
36class ConfigDialog : public KDialogBase 36class ConfigDialog : public KDialogBase
37{ 37{
38 Q_OBJECT 38 Q_OBJECT
39 public: 39 public:
40 // Resource=0: create new resource 40 // Resource=0: create new resource
41 ConfigDialog( QWidget *parent, const QString& resourceFamily, 41 ConfigDialog( QWidget *parent, const QString& resourceFamily,
42 Resource* resource, const char *name = 0); 42 Resource* resource, const char *name = 0);
43 43
44 void setInEditMode( bool value ); 44 void setInEditMode( bool value );
45 45
46 protected slots: 46 protected slots:
47 void accept(); 47 void accept();
48 void setReadOnly( bool value ); 48 void setReadOnly( bool value );
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
@@ -1,194 +1,204 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#include <kdebug.h> 24#include <kdebug.h>
25#include <kapplication.h> 25#include <kapplication.h>
26#include <kconfig.h> 26#include <kconfig.h>
27 27
28#include "resource.h" 28#include "resource.h"
29 29
30using namespace KRES; 30using namespace KRES;
31 31
32class Resource::ResourcePrivate 32class 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
47Resource::Resource( const KConfig* config ) 48Resource::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
77Resource::~Resource() 80Resource::~Resource()
78{ 81{
79 delete d; 82 delete d;
80 d = 0; 83 d = 0;
81} 84}
82 85
83void Resource::writeConfig( KConfig* config ) 86void 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
94bool Resource::open() 96bool 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;
102 d->mIsOpen = doOpen(); 104 d->mIsOpen = doOpen();
103 } 105 }
104 d->mOpenCount++; 106 d->mOpenCount++;
105 return d->mIsOpen; 107 return d->mIsOpen;
106} 108}
107 109
108void Resource::close() 110void Resource::close()
109{ 111{
110#ifdef QT_THREAD_SUPPORT 112#ifdef QT_THREAD_SUPPORT
111 QMutexLocker guard( &(d->mMutex) ); 113 QMutexLocker guard( &(d->mMutex) );
112#endif 114#endif
113 if ( !d->mOpenCount ) { 115 if ( !d->mOpenCount ) {
114 kdDebug(5650) << "ERROR: Resource " << resourceName() << " closed more times than previously opened" << endl; 116 kdDebug(5650) << "ERROR: Resource " << resourceName() << " closed more times than previously opened" << endl;
115 return; 117 return;
116 } 118 }
117 d->mOpenCount--; 119 d->mOpenCount--;
118 if ( !d->mOpenCount ) { 120 if ( !d->mOpenCount ) {
119 kdDebug(5650) << "Closing resource " << resourceName() << endl; 121 kdDebug(5650) << "Closing resource " << resourceName() << endl;
120 doClose(); 122 doClose();
121 d->mIsOpen = false; 123 d->mIsOpen = false;
122 } else { 124 } else {
123 kdDebug(5650) << "Not yet closing resource " << resourceName() << ", open count = " << d->mOpenCount << endl; 125 kdDebug(5650) << "Not yet closing resource " << resourceName() << ", open count = " << d->mOpenCount << endl;
124 } 126 }
125} 127}
126 128
127bool Resource::isOpen() const 129bool Resource::isOpen() const
128{ 130{
129 return d->mIsOpen; 131 return d->mIsOpen;
130} 132}
131 133
132void Resource::setIdentifier( const QString& identifier ) 134void Resource::setIdentifier( const QString& identifier )
133{ 135{
134 d->mIdentifier = identifier; 136 d->mIdentifier = identifier;
135} 137}
136 138
137QString Resource::identifier() const 139QString Resource::identifier() const
138{ 140{
139 return d->mIdentifier; 141 return d->mIdentifier;
140} 142}
141 143
142void Resource::setType( const QString& type ) 144void Resource::setType( const QString& type )
143{ 145{
144 d->mType = type; 146 d->mType = type;
145} 147}
146 148
147QString Resource::type() const 149QString Resource::type() const
148{ 150{
149 return d->mType; 151 return d->mType;
150} 152}
151 153
154void Resource::setIncludeInSync( bool value )
155{
156 d->mIncludeInSync = value;
157}
158bool Resource::includeInSync() const
159{
160 return d->mIncludeInSync;
161}
152void Resource::setReadOnly( bool value ) 162void Resource::setReadOnly( bool value )
153{ 163{
154 d->mReadOnly = value; 164 d->mReadOnly = value;
155} 165}
156 166
157bool Resource::readOnly() const 167bool Resource::readOnly() const
158{ 168{
159 return d->mReadOnly; 169 return d->mReadOnly;
160} 170}
161 171
162void Resource::setResourceName( const QString &name ) 172void Resource::setResourceName( const QString &name )
163{ 173{
164 d->mName = name; 174 d->mName = name;
165} 175}
166 176
167QString Resource::resourceName() const 177QString Resource::resourceName() const
168{ 178{
169 return d->mName; 179 return d->mName;
170} 180}
171 181
172void Resource::setActive( bool value ) 182void Resource::setActive( bool value )
173{ 183{
174 d->mActive = value; 184 d->mActive = value;
175} 185}
176 186
177bool Resource::isActive() const 187bool Resource::isActive() const
178{ 188{
179 return d->mActive; 189 return d->mActive;
180} 190}
181 191
182void Resource::dump() const 192void Resource::dump() const
183{ 193{
184 qDebug("Resource::dump() "); 194 qDebug("Resource::dump() ");
185 kdDebug(5650) << "Resource:" << endl; 195 kdDebug(5650) << "Resource:" << endl;
186 kdDebug(5650) << " Name: " << d->mName << endl; 196 kdDebug(5650) << " Name: " << d->mName << endl;
187 kdDebug(5650) << " Identifier: " << d->mIdentifier << endl; 197 kdDebug(5650) << " Identifier: " << d->mIdentifier << endl;
188 kdDebug(5650) << " Type: " << d->mType << endl; 198 kdDebug(5650) << " Type: " << d->mType << endl;
189 kdDebug(5650) << " OpenCount: " << d->mOpenCount << endl; 199 kdDebug(5650) << " OpenCount: " << d->mOpenCount << endl;
190 kdDebug(5650) << " ReadOnly: " << ( d->mReadOnly ? "yes" : "no" ) << endl; 200 kdDebug(5650) << " ReadOnly: " << ( d->mReadOnly ? "yes" : "no" ) << endl;
191 kdDebug(5650) << " Active: " << ( d->mActive ? "yes" : "no" ) << endl; 201 kdDebug(5650) << " Active: " << ( d->mActive ? "yes" : "no" ) << endl;
192 kdDebug(5650) << " IsOpen: " << ( d->mIsOpen ? "yes" : "no" ) << endl; 202 kdDebug(5650) << " IsOpen: " << ( d->mIsOpen ? "yes" : "no" ) << endl;
193} 203}
194 204
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
@@ -249,128 +249,130 @@ class Resource : public QObject
249 */ 249 */
250 Resource( const KConfig* config ); 250 Resource( const KConfig* config );
251 251
252 /** 252 /**
253 * Destructor. 253 * Destructor.
254 */ 254 */
255 virtual ~Resource(); 255 virtual ~Resource();
256 256
257 /** 257 /**
258 * Write configuration information for this resource to a configuration 258 * Write configuration information for this resource to a configuration
259 * file. If you override this method, remember to call Resource::writeConfig 259 * file. If you override this method, remember to call Resource::writeConfig
260 * or Terrible Things(TM) will happen. 260 * or Terrible Things(TM) will happen.
261 * @param config Configuration to write persistence information to. 261 * @param config Configuration to write persistence information to.
262 */ 262 */
263 virtual void writeConfig( KConfig* config ); 263 virtual void writeConfig( KConfig* config );
264 264
265 /** 265 /**
266 * Open this resource, if it not already open. Increase the open 266 * Open this resource, if it not already open. Increase the open
267 * count of this object, and open the resource by calling @ref doOpen(). 267 * count of this object, and open the resource by calling @ref doOpen().
268 * This method may block while another thread is concurrently opening 268 * This method may block while another thread is concurrently opening
269 * or closing the resource. 269 * or closing the resource.
270 * 270 *
271 * Returns true if the resource was already opened or if it was opened 271 * Returns true if the resource was already opened or if it was opened
272 * successfully; returns false if the resource was not opened successfully. 272 * successfully; returns false if the resource was not opened successfully.
273 */ 273 */
274 bool open(); 274 bool open();
275 275
276 /** 276 /**
277 * Decrease the open count of this object, and if the count reaches 277 * Decrease the open count of this object, and if the count reaches
278 * zero, close this resource by calling @ref doClose(). 278 * zero, close this resource by calling @ref doClose().
279 * This method may block while another thread is concurrently closing 279 * This method may block while another thread is concurrently closing
280 * or opening the resource. 280 * or opening the resource.
281 */ 281 */
282 void close(); 282 void close();
283 283
284 /** 284 /**
285 * Returns whether the resource is open or not. 285 * Returns whether the resource is open or not.
286 */ 286 */
287 bool isOpen() const; 287 bool isOpen() const;
288 288
289 /** 289 /**
290 * Returns a unique identifier. The identifier is unique for this resource. 290 * Returns a unique identifier. The identifier is unique for this resource.
291 * It is created when the resource is first created, and it is retained 291 * It is created when the resource is first created, and it is retained
292 * in the resource family configuration file for this resource. 292 * in the resource family configuration file for this resource.
293 * @return This resource's identifier 293 * @return This resource's identifier
294 */ 294 */
295 QString identifier() const; 295 QString identifier() const;
296 296
297 /** 297 /**
298 * Returns the type of this resource. 298 * Returns the type of this resource.
299 */ 299 */
300 QString type() const; 300 QString type() const;
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
325 327
326 virtual bool isSyncable() const = 0; 328 virtual bool isSyncable() const = 0;
327 329
328 330
329 /** 331 /**
330 Sets, if the resource is active. 332 Sets, if the resource is active.
331 */ 333 */
332 void setActive( bool active ); 334 void setActive( bool active );
333 335
334 /** 336 /**
335 Return true, if the resource is active. 337 Return true, if the resource is active.
336 */ 338 */
337 bool isActive() const; 339 bool isActive() const;
338 340
339 friend class Factory; 341 friend class Factory;
340 friend class ManagerImpl; 342 friend class ManagerImpl;
341 343
342 /** 344 /**
343 Print resource information as debug output. 345 Print resource information as debug output.
344 */ 346 */
345 virtual void dump() const; 347 virtual void dump() const;
346 348
347 349
348 protected: 350 protected:
349 /** 351 /**
350 * Open this resource. When called, the resource must be in 352 * Open this resource. When called, the resource must be in
351 * a closed state. 353 * a closed state.
352 * 354 *
353 * Returns true if the resource was opened successfully; 355 * Returns true if the resource was opened successfully;
354 * returns false if the resource was not opened successfully. 356 * returns false if the resource was not opened successfully.
355 * 357 *
356 * The result of this call can be accessed later by @ref isOpen() 358 * The result of this call can be accessed later by @ref isOpen()
357 */ 359 */
358 virtual bool doOpen() { return true; } 360 virtual bool doOpen() { return true; }
359 361
360 /** 362 /**
361 * Close this resource. Pre-condition: resource is open. 363 * Close this resource. Pre-condition: resource is open.
362 * Post-condition: resource is closed. 364 * Post-condition: resource is closed.
363 */ 365 */
364 virtual void doClose() {} 366 virtual void doClose() {}
365 367
366 void setIdentifier( const QString& identifier ); 368 void setIdentifier( const QString& identifier );
367 void setType( const QString& type ); 369 void setType( const QString& type );
368 370
369 private: 371 private:
370 class ResourcePrivate; 372 class ResourcePrivate;
371 ResourcePrivate *d; 373 ResourcePrivate *d;
372}; 374};
373 375
374class PluginFactoryBase : public KLibFactory 376class PluginFactoryBase : public KLibFactory
375{ 377{
376 public: 378 public: