summaryrefslogtreecommitdiffabout
path: root/kabc
authorzautrix <zautrix>2004-10-14 09:28:50 (UTC)
committer zautrix <zautrix>2004-10-14 09:28:50 (UTC)
commit3d79ab275374292196c7d032ffd2e321841c8cb0 (patch) (unidiff)
tree6ceaba2a5f375cfebc88189000221fe456e6f9d2 /kabc
parent57bd80b04dddd40a897dce8b6902d1046d71c631 (diff)
downloadkdepimpi-3d79ab275374292196c7d032ffd2e321841c8cb0.zip
kdepimpi-3d79ab275374292196c7d032ffd2e321841c8cb0.tar.gz
kdepimpi-3d79ab275374292196c7d032ffd2e321841c8cb0.tar.bz2
umlaute phone fixes
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp3
-rw-r--r--kabc/addressbook.h2
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.cpp4
3 files changed, 5 insertions, 4 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index c584c35..3641c0c 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -384,225 +384,226 @@ void AddressBook::export2File( QString fileName )
384 if ( !outFile.open( IO_WriteOnly ) ) { 384 if ( !outFile.open( IO_WriteOnly ) ) {
385 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 385 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
386 KMessageBox::error( 0, text.arg( fileName ) ); 386 KMessageBox::error( 0, text.arg( fileName ) );
387 return ; 387 return ;
388 } 388 }
389 QTextStream t( &outFile ); 389 QTextStream t( &outFile );
390 t.setEncoding( QTextStream::UnicodeUTF8 ); 390 t.setEncoding( QTextStream::UnicodeUTF8 );
391 Iterator it; 391 Iterator it;
392 KABC::VCardConverter::Version version; 392 KABC::VCardConverter::Version version;
393 version = KABC::VCardConverter::v3_0; 393 version = KABC::VCardConverter::v3_0;
394 for ( it = begin(); it != end(); ++it ) { 394 for ( it = begin(); it != end(); ++it ) {
395 if ( (*it).resource() && (*it).resource()->includeInSync() ) { 395 if ( (*it).resource() && (*it).resource()->includeInSync() ) {
396 if ( !(*it).IDStr().isEmpty() ) { 396 if ( !(*it).IDStr().isEmpty() ) {
397 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); 397 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
398 } 398 }
399 KABC::VCardConverter converter; 399 KABC::VCardConverter converter;
400 QString vcard; 400 QString vcard;
401 //Resource *resource() const; 401 //Resource *resource() const;
402 converter.addresseeToVCard( *it, vcard, version ); 402 converter.addresseeToVCard( *it, vcard, version );
403 t << vcard << "\r\n"; 403 t << vcard << "\r\n";
404 } 404 }
405 } 405 }
406 t << "\r\n\r\n"; 406 t << "\r\n\r\n";
407 outFile.close(); 407 outFile.close();
408} 408}
409// if QStringList uids is empty, all are exported 409// if QStringList uids is empty, all are exported
410bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) 410bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName )
411{ 411{
412 KABC::VCardConverter converter; 412 KABC::VCardConverter converter;
413 QString datastream; 413 QString datastream;
414 Iterator it; 414 Iterator it;
415 bool all = uids.isEmpty(); 415 bool all = uids.isEmpty();
416 for ( it = begin(); it != end(); ++it ) { 416 for ( it = begin(); it != end(); ++it ) {
417 // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 417 // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
418 if ( ! all ) { 418 if ( ! all ) {
419 if ( ! ( uids.contains((*it).uid() ) )) 419 if ( ! ( uids.contains((*it).uid() ) ))
420 continue; 420 continue;
421 } 421 }
422 KABC::Addressee a = ( *it ); 422 KABC::Addressee a = ( *it );
423 if ( a.isEmpty() ) 423 if ( a.isEmpty() )
424 continue; 424 continue;
425 if ( all && a.resource() && !a.resource()->includeInSync() ) 425 if ( all && a.resource() && !a.resource()->includeInSync() )
426 continue; 426 continue;
427 a.simplifyEmails(); 427 a.simplifyEmails();
428 a.simplifyPhoneNumbers(); 428 a.simplifyPhoneNumbers();
429 a.simplifyPhoneNumberTypes(); 429 a.simplifyPhoneNumberTypes();
430 a.simplifyAddresses(); 430 a.simplifyAddresses();
431 431
432 QString vcard; 432 QString vcard;
433 QString vcardnew; 433 QString vcardnew;
434 converter.addresseeToVCard( a, vcard ); 434 converter.addresseeToVCard( a, vcard );
435 int start = 0; 435 int start = 0;
436 int next; 436 int next;
437 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 437 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
438 int semi = vcard.find(";", next); 438 int semi = vcard.find(";", next);
439 int dopp = vcard.find(":", next); 439 int dopp = vcard.find(":", next);
440 int sep; 440 int sep;
441 if ( semi < dopp && semi >= 0 ) 441 if ( semi < dopp && semi >= 0 )
442 sep = semi ; 442 sep = semi ;
443 else 443 else
444 sep = dopp; 444 sep = dopp;
445 vcardnew +=vcard.mid( start, next - start); 445 vcardnew +=vcard.mid( start, next - start);
446 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); 446 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
447 start = sep; 447 start = sep;
448 } 448 }
449 vcardnew += vcard.mid( start,vcard.length() ); 449 vcardnew += vcard.mid( start,vcard.length() );
450 vcard = ""; 450 vcard = "";
451 start = 0; 451 start = 0;
452 while ( (next = vcardnew.find("ADR", start) )>= 0 ) { 452 while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
453 int sep = vcardnew.find(":", next); 453 int sep = vcardnew.find(":", next);
454 vcard +=vcardnew.mid( start, next - start+3); 454 vcard +=vcardnew.mid( start, next - start+3);
455 start = sep; 455 start = sep;
456 } 456 }
457 vcard += vcardnew.mid( start,vcardnew.length() ); 457 vcard += vcardnew.mid( start,vcardnew.length() );
458 vcard.replace ( QRegExp(";;;") , "" ); 458 vcard.replace ( QRegExp(";;;") , "" );
459 vcard.replace ( QRegExp(";;") , "" ); 459 vcard.replace ( QRegExp(";;") , "" );
460 datastream += vcard; 460 datastream += vcard;
461 461
462 } 462 }
463 463
464 QFile outFile(fileName); 464 QFile outFile(fileName);
465 if ( outFile.open(IO_WriteOnly) ) { 465 if ( outFile.open(IO_WriteOnly) ) {
466 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 466 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
467 QTextStream t( &outFile ); // use a text stream 467 QTextStream t( &outFile ); // use a text stream
468 t.setEncoding( QTextStream::UnicodeUTF8 ); 468 t.setEncoding( QTextStream::UnicodeUTF8 );
469 t <<datastream; 469 t <<datastream;
470 t << "\r\n\r\n"; 470 t << "\r\n\r\n";
471 outFile.close(); 471 outFile.close();
472 472
473 } else { 473 } else {
474 qDebug("Error open temp file "); 474 qDebug("Error open temp file ");
475 return false; 475 return false;
476 } 476 }
477 return true; 477 return true;
478 478
479} 479}
480void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) 480int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld )
481{ 481{
482 482
483 if ( removeOld ) 483 if ( removeOld )
484 setUntagged( true ); 484 setUntagged( true );
485 KABC::Addressee::List list; 485 KABC::Addressee::List list;
486 QFile file( fileName ); 486 QFile file( fileName );
487 file.open( IO_ReadOnly ); 487 file.open( IO_ReadOnly );
488 QByteArray rawData = file.readAll(); 488 QByteArray rawData = file.readAll();
489 file.close(); 489 file.close();
490 QString data; 490 QString data;
491 if ( replaceLabel ) { 491 if ( replaceLabel ) {
492 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); 492 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 );
493 data.replace ( QRegExp("LABEL") , "ADR" ); 493 data.replace ( QRegExp("LABEL") , "ADR" );
494 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); 494 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" );
495 } else 495 } else
496 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 496 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
497 KABC::VCardTool tool; 497 KABC::VCardTool tool;
498 list = tool.parseVCards( data ); 498 list = tool.parseVCards( data );
499 KABC::Addressee::List::Iterator it; 499 KABC::Addressee::List::Iterator it;
500 for ( it = list.begin(); it != list.end(); ++it ) { 500 for ( it = list.begin(); it != list.end(); ++it ) {
501 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); 501 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
502 if ( !id.isEmpty() ) 502 if ( !id.isEmpty() )
503 (*it).setIDStr(id ); 503 (*it).setIDStr(id );
504 (*it).setResource( 0 ); 504 (*it).setResource( 0 );
505 if ( replaceLabel ) 505 if ( replaceLabel )
506 (*it).removeVoice(); 506 (*it).removeVoice();
507 if ( removeOld ) 507 if ( removeOld )
508 (*it).setTagged( true ); 508 (*it).setTagged( true );
509 insertAddressee( (*it), false, true ); 509 insertAddressee( (*it), false, true );
510 } 510 }
511 if ( removeOld ) 511 if ( removeOld )
512 removeUntagged(); 512 removeUntagged();
513 return list.count();
513} 514}
514void AddressBook::setUntagged(bool setNonSyncTagged) // = false) 515void AddressBook::setUntagged(bool setNonSyncTagged) // = false)
515{ 516{
516 Iterator ait; 517 Iterator ait;
517 for ( ait = begin(); ait != end(); ++ait ) { 518 for ( ait = begin(); ait != end(); ++ait ) {
518 if ( setNonSyncTagged ) { 519 if ( setNonSyncTagged ) {
519 if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { 520 if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) {
520 (*ait).setTagged( true ); 521 (*ait).setTagged( true );
521 } else 522 } else
522 (*ait).setTagged( false ); 523 (*ait).setTagged( false );
523 } else 524 } else
524 (*ait).setTagged( false ); 525 (*ait).setTagged( false );
525 } 526 }
526} 527}
527void AddressBook::removeUntagged() 528void AddressBook::removeUntagged()
528{ 529{
529 Iterator ait; 530 Iterator ait;
530 bool todelete = false; 531 bool todelete = false;
531 Iterator todel; 532 Iterator todel;
532 for ( ait = begin(); ait != end(); ++ait ) { 533 for ( ait = begin(); ait != end(); ++ait ) {
533 if ( todelete ) 534 if ( todelete )
534 removeAddressee( todel ); 535 removeAddressee( todel );
535 if (!(*ait).tagged()) { 536 if (!(*ait).tagged()) {
536 todelete = true; 537 todelete = true;
537 todel = ait; 538 todel = ait;
538 } else 539 } else
539 todelete = false; 540 todelete = false;
540 } 541 }
541 if ( todelete ) 542 if ( todelete )
542 removeAddressee( todel ); 543 removeAddressee( todel );
543 deleteRemovedAddressees(); 544 deleteRemovedAddressees();
544} 545}
545void AddressBook::smplifyAddressees() 546void AddressBook::smplifyAddressees()
546{ 547{
547 Iterator ait; 548 Iterator ait;
548 for ( ait = begin(); ait != end(); ++ait ) { 549 for ( ait = begin(); ait != end(); ++ait ) {
549 (*ait).simplifyEmails(); 550 (*ait).simplifyEmails();
550 (*ait).simplifyPhoneNumbers(); 551 (*ait).simplifyPhoneNumbers();
551 (*ait).simplifyPhoneNumberTypes(); 552 (*ait).simplifyPhoneNumberTypes();
552 (*ait).simplifyAddresses(); 553 (*ait).simplifyAddresses();
553 } 554 }
554} 555}
555void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) 556void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync )
556{ 557{
557 Iterator ait; 558 Iterator ait;
558 for ( ait = begin(); ait != end(); ++ait ) { 559 for ( ait = begin(); ait != end(); ++ait ) {
559 QString id = (*ait).IDStr(); 560 QString id = (*ait).IDStr();
560 (*ait).setIDStr( ":"); 561 (*ait).setIDStr( ":");
561 (*ait).setExternalUID( id ); 562 (*ait).setExternalUID( id );
562 (*ait).setOriginalExternalUID( id ); 563 (*ait).setOriginalExternalUID( id );
563 if ( isPreSync ) 564 if ( isPreSync )
564 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 565 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
565 else { 566 else {
566 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 567 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
567 (*ait).setID( currentSyncDevice,id ); 568 (*ait).setID( currentSyncDevice,id );
568 569
569 } 570 }
570 } 571 }
571} 572}
572void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) 573void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice )
573{ 574{
574 575
575 setUntagged(); 576 setUntagged();
576 KABC::Addressee::List list; 577 KABC::Addressee::List list;
577 QFile file( fileName ); 578 QFile file( fileName );
578 file.open( IO_ReadOnly ); 579 file.open( IO_ReadOnly );
579 QByteArray rawData = file.readAll(); 580 QByteArray rawData = file.readAll();
580 file.close(); 581 file.close();
581 QString data; 582 QString data;
582 583
583 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 584 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
584 KABC::VCardTool tool; 585 KABC::VCardTool tool;
585 list = tool.parseVCards( data ); 586 list = tool.parseVCards( data );
586 KABC::Addressee::List::Iterator it; 587 KABC::Addressee::List::Iterator it;
587 for ( it = list.begin(); it != list.end(); ++it ) { 588 for ( it = list.begin(); it != list.end(); ++it ) {
588 Iterator ait; 589 Iterator ait;
589 for ( ait = begin(); ait != end(); ++ait ) { 590 for ( ait = begin(); ait != end(); ++ait ) {
590 if ( !(*ait).tagged() ) { 591 if ( !(*ait).tagged() ) {
591 if ( (*ait).containsAdr(*it)) { 592 if ( (*ait).containsAdr(*it)) {
592 (*ait).setTagged(true); 593 (*ait).setTagged(true);
593 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); 594 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
594 (*it).setIDStr( ":"); 595 (*it).setIDStr( ":");
595 (*it).setID( currentSyncDevice,id ); 596 (*it).setID( currentSyncDevice,id );
596 (*it).setExternalUID( id ); 597 (*it).setExternalUID( id );
597 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 598 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
598 (*it).setUid( ( (*ait).uid() )); 599 (*it).setUid( ( (*ait).uid() ));
599 break; 600 break;
600 } 601 }
601 } 602 }
602 603
603 } 604 }
604 if ( ait == end() ) 605 if ( ait == end() )
605 qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); 606 qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1());
606 } 607 }
607 clear(); 608 clear();
608 for ( it = list.begin(); it != list.end(); ++it ) { 609 for ( it = list.begin(); it != list.end(); ++it ) {
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 23bba02..5edca06 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -54,193 +54,193 @@ class AddressBook : public QObject
54 friend QDataStream &operator<<( QDataStream &, const AddressBook & ); 54 friend QDataStream &operator<<( QDataStream &, const AddressBook & );
55 friend QDataStream &operator>>( QDataStream &, AddressBook & ); 55 friend QDataStream &operator>>( QDataStream &, AddressBook & );
56 friend class StdAddressBook; 56 friend class StdAddressBook;
57 57
58 public: 58 public:
59 /** 59 /**
60 @short Address Book Iterator 60 @short Address Book Iterator
61 61
62 This class provides an iterator for address book entries. 62 This class provides an iterator for address book entries.
63 */ 63 */
64 class Iterator 64 class Iterator
65 { 65 {
66 public: 66 public:
67 Iterator(); 67 Iterator();
68 Iterator( const Iterator & ); 68 Iterator( const Iterator & );
69 ~Iterator(); 69 ~Iterator();
70 70
71 Iterator &operator=( const Iterator & ); 71 Iterator &operator=( const Iterator & );
72 const Addressee &operator*() const; 72 const Addressee &operator*() const;
73 Addressee &operator*(); 73 Addressee &operator*();
74 Addressee* operator->(); 74 Addressee* operator->();
75 Iterator &operator++(); 75 Iterator &operator++();
76 Iterator &operator++(int); 76 Iterator &operator++(int);
77 Iterator &operator--(); 77 Iterator &operator--();
78 Iterator &operator--(int); 78 Iterator &operator--(int);
79 bool operator==( const Iterator &it ); 79 bool operator==( const Iterator &it );
80 bool operator!=( const Iterator &it ); 80 bool operator!=( const Iterator &it );
81 81
82 struct IteratorData; 82 struct IteratorData;
83 IteratorData *d; 83 IteratorData *d;
84 }; 84 };
85 85
86 /** 86 /**
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 int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false );
151 void setUntagged( bool setNonSyncTagged = false ); 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
216 /** 216 /**
217 Find all entries with the specified name in the address book. Returns 217 Find all entries with the specified name in the address book. Returns
218 an empty list, if no entries could be found. 218 an empty list, if no entries could be found.
219 */ 219 */
220 Addressee::List findByName( const QString & ); 220 Addressee::List findByName( const QString & );
221 221
222 /** 222 /**
223 Find all entries with the specified email address in the address book. 223 Find all entries with the specified email address in the address book.
224 Returns an empty list, if no entries could be found. 224 Returns an empty list, if no entries could be found.
225 */ 225 */
226 Addressee::List findByEmail( const QString & ); 226 Addressee::List findByEmail( const QString & );
227 227
228 /** 228 /**
229 Find all entries wich have the specified category in the address book. 229 Find all entries wich have the specified category in the address book.
230 Returns an empty list, if no entries could be found. 230 Returns an empty list, if no entries could be found.
231 */ 231 */
232 Addressee::List findByCategory( const QString & ); 232 Addressee::List findByCategory( const QString & );
233 233
234 /** 234 /**
235 Return a string identifying this addressbook. 235 Return a string identifying this addressbook.
236 */ 236 */
237 virtual QString identifier(); 237 virtual QString identifier();
238 238
239 /** 239 /**
240 Used for debug output. 240 Used for debug output.
241 */ 241 */
242 void dump() const; 242 void dump() const;
243 243
244 void emitAddressBookLocked() { emit addressBookLocked( this ); } 244 void emitAddressBookLocked() { emit addressBookLocked( this ); }
245 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } 245 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); }
246 void emitAddressBookChanged() { emit addressBookChanged( this ); } 246 void emitAddressBookChanged() { emit addressBookChanged( this ); }
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
index 2cdf4bf..ba17c50 100644
--- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
+++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
@@ -1,172 +1,172 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <sys/types.h> 28#include <sys/types.h>
29#include <sys/stat.h> 29#include <sys/stat.h>
30#include <unistd.h> 30#include <unistd.h>
31 31
32#include <qdir.h> 32#include <qdir.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qfileinfo.h> 34#include <qfileinfo.h>
35#include <qregexp.h> 35#include <qregexp.h>
36//US #include <qtimer.h> 36//US #include <qtimer.h>
37 37
38#include <kapplication.h> 38#include <kapplication.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <kdebug.h> 40#include <kdebug.h>
41#include <klocale.h> 41#include <klocale.h>
42//US #include <ksavefile.h> 42//US #include <ksavefile.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kmessagebox.h> 44#include <kmessagebox.h>
45 45
46#include <sl/slzdb.h> 46#include <sl/slzdb.h>
47 47
48#include <libkdepim/ksyncprofile.h> 48#include <libkdepim/ksyncprofile.h>
49 49
50#include "resourcesharpdtmconfig.h" 50#include "resourcesharpdtmconfig.h"
51#include "resourcesharpdtm.h" 51#include "resourcesharpdtm.h"
52 52
53#include "stdaddressbook.h" 53#include "stdaddressbook.h"
54 54
55#include "sharpdtmconverter.h" 55#include "sharpdtmconverter.h"
56//#define ALLOW_LOCKING 56//#define ALLOW_LOCKING
57using namespace KABC; 57using namespace KABC;
58extern "C" 58extern "C"
59{ 59{
60 void *init_microkabc_sharpdtm() 60 void *init_microkabc_sharpdtm()
61 { 61 {
62 return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig>(); 62 return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig>();
63 } 63 }
64} 64}
65 65
66ResourceSharpDTM::ResourceSharpDTM( const KConfig *config ) 66ResourceSharpDTM::ResourceSharpDTM( const KConfig *config )
67 : Resource( config ), mConverter (0) 67 : Resource( config ), mConverter (0)
68{ 68{
69 // we can not choose the filename. Therefore use the default to display 69 // we can not choose the filename. Therefore use the default to display
70 70
71 QString fileName = SlZDataBase::addressbookFileName(); 71 QString fileName = SlZDataBase::addressbookFileName();
72 init( fileName ); 72 init( fileName );
73} 73}
74 74
75ResourceSharpDTM::ResourceSharpDTM( const QString &fileName, bool syncable ) 75ResourceSharpDTM::ResourceSharpDTM( const QString &fileName )
76 : Resource( 0, syncable ) 76 : Resource( 0 )
77{ 77{
78 init( fileName ); 78 init( fileName );
79} 79}
80 80
81void ResourceSharpDTM::init( const QString &fileName ) 81void ResourceSharpDTM::init( const QString &fileName )
82{ 82{
83 83
84 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 84 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
85 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 85 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
86 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 86 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
87 87
88 setFileName( fileName ); 88 setFileName( fileName );
89} 89}
90 90
91ResourceSharpDTM::~ResourceSharpDTM() 91ResourceSharpDTM::~ResourceSharpDTM()
92{ 92{
93 if (mConverter != 0) 93 if (mConverter != 0)
94 delete mConverter; 94 delete mConverter;
95 95
96 if(mAccess != 0) 96 if(mAccess != 0)
97 delete mAccess; 97 delete mAccess;
98} 98}
99 99
100void ResourceSharpDTM::writeConfig( KConfig *config ) 100void ResourceSharpDTM::writeConfig( KConfig *config )
101{ 101{
102 Resource::writeConfig( config ); 102 Resource::writeConfig( config );
103} 103}
104 104
105Ticket *ResourceSharpDTM::requestSaveTicket() 105Ticket *ResourceSharpDTM::requestSaveTicket()
106{ 106{
107 107
108 108
109 qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1()); 109 qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1());
110 110
111 if ( !addressBook() ) return 0; 111 if ( !addressBook() ) return 0;
112 112
113#ifdef ALLOW_LOCKING 113#ifdef ALLOW_LOCKING
114 if ( !lock( fileName() ) ) { 114 if ( !lock( fileName() ) ) {
115 qDebug("ResourceSharpDTM::requestSaveTicket(): Unable to lock file "); 115 qDebug("ResourceSharpDTM::requestSaveTicket(): Unable to lock file ");
116 return 0; 116 return 0;
117 } 117 }
118#endif 118#endif
119 return createTicket( this ); 119 return createTicket( this );
120} 120}
121 121
122 122
123bool ResourceSharpDTM::doOpen() 123bool ResourceSharpDTM::doOpen()
124{ 124{
125 qDebug("ResourceSharpDTM::doOpen: %s", fileName().latin1()); 125 qDebug("ResourceSharpDTM::doOpen: %s", fileName().latin1());
126 126
127 // the last parameter in the SlZDataBase constructor means "readonly" 127 // the last parameter in the SlZDataBase constructor means "readonly"
128 mAccess = new SlZDataBase(fileName(), 128 mAccess = new SlZDataBase(fileName(),
129 SlZDataBase::addressbookItems(), 129 SlZDataBase::addressbookItems(),
130 NULL, false); 130 NULL, false);
131 131
132 if ( !mAccess ) { 132 if ( !mAccess ) {
133 qDebug("Unable to load file() %s", fileName().latin1()); 133 qDebug("Unable to load file() %s", fileName().latin1());
134 return false; 134 return false;
135 } 135 }
136 136
137 if (mConverter == 0) 137 if (mConverter == 0)
138 { 138 {
139 mConverter = new SharpDTMConverter(); 139 mConverter = new SharpDTMConverter();
140 bool res = mConverter->init(); 140 bool res = mConverter->init();
141 if ( !res ) 141 if ( !res )
142 { 142 {
143 QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); 143 QString msg("Unable to initialize sharp converter. Most likely a problem with the category file");
144 144
145 qDebug(msg); 145 qDebug(msg);
146 delete mAccess; 146 delete mAccess;
147 mAccess = 0; 147 mAccess = 0;
148 return false; 148 return false;
149 } 149 }
150 } 150 }
151 151
152 return true; 152 return true;
153} 153}
154 154
155void ResourceSharpDTM::doClose() 155void ResourceSharpDTM::doClose()
156{ 156{
157 qDebug("ResourceSharpDTM::doClose: %s", fileName().latin1()); 157 qDebug("ResourceSharpDTM::doClose: %s", fileName().latin1());
158 158
159 if(mAccess) 159 if(mAccess)
160 { 160 {
161 delete mAccess; 161 delete mAccess;
162 mAccess = 0; 162 mAccess = 0;
163 } 163 }
164 // it seems so, that deletion of access deletes backend as well 164 // it seems so, that deletion of access deletes backend as well
165 //delete backend; 165 //delete backend;
166 166
167 return; 167 return;
168} 168}
169 169
170bool ResourceSharpDTM::load() 170bool ResourceSharpDTM::load()
171{ 171{
172 qDebug("ResourceSharpDTM::load: %s", fileName().latin1()); 172 qDebug("ResourceSharpDTM::load: %s", fileName().latin1());