summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-09 16:58:08 (UTC)
committer zautrix <zautrix>2004-10-09 16:58:08 (UTC)
commit59ed933d6c43ecb0ddd3dec53cc289ee8aa68482 (patch) (unidiff)
tree8b1cbcf9c420e7dffd1e1293bcfa69e8e821f3fa
parentb80a099d9432bdc3d4eea778b1813b82b2680ecf (diff)
downloadkdepimpi-59ed933d6c43ecb0ddd3dec53cc289ee8aa68482.zip
kdepimpi-59ed933d6c43ecb0ddd3dec53cc289ee8aa68482.tar.gz
kdepimpi-59ed933d6c43ecb0ddd3dec53cc289ee8aa68482.tar.bz2
fixed sync bug
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp72
-rw-r--r--kabc/addressbook.h4
-rw-r--r--kabc/addressee.cpp12
-rw-r--r--kabc/addressee.h5
-rw-r--r--kaddressbook/kabcore.cpp2
5 files changed, 66 insertions, 29 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 1050f55..ff05f7e 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -342,156 +342,176 @@ bool AddressBook::load()
342 342
343 343
344 clear(); 344 clear();
345 345
346 KRES::Manager<Resource>::ActiveIterator it; 346 KRES::Manager<Resource>::ActiveIterator it;
347 bool ok = true; 347 bool ok = true;
348 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 348 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
349 if ( !(*it)->load() ) { 349 if ( !(*it)->load() ) {
350 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 350 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
351 ok = false; 351 ok = false;
352 } 352 }
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}
379void AddressBook::export2File( QString fileName ) 379void AddressBook::export2File( QString fileName )
380{ 380{
381 381
382 QFile outFile( fileName ); 382 QFile outFile( fileName );
383 if ( !outFile.open( IO_WriteOnly ) ) { 383 if ( !outFile.open( IO_WriteOnly ) ) {
384 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 384 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
385 KMessageBox::error( 0, text.arg( fileName ) ); 385 KMessageBox::error( 0, text.arg( fileName ) );
386 return ; 386 return ;
387 } 387 }
388 QTextStream t( &outFile ); 388 QTextStream t( &outFile );
389 t.setEncoding( QTextStream::UnicodeUTF8 ); 389 t.setEncoding( QTextStream::UnicodeUTF8 );
390 Iterator it; 390 Iterator it;
391 KABC::VCardConverter::Version version; 391 KABC::VCardConverter::Version version;
392 version = KABC::VCardConverter::v3_0; 392 version = KABC::VCardConverter::v3_0;
393 for ( it = begin(); it != end(); ++it ) { 393 for ( it = begin(); it != end(); ++it ) {
394 if ( !(*it).IDStr().isEmpty() ) { 394 if ( !(*it).IDStr().isEmpty() ) {
395 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); 395 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
396 } 396 }
397 KABC::VCardConverter converter; 397 KABC::VCardConverter converter;
398 QString vcard; 398 QString vcard;
399 //Resource *resource() const; 399 //Resource *resource() const;
400 converter.addresseeToVCard( *it, vcard, version ); 400 converter.addresseeToVCard( *it, vcard, version );
401 t << vcard << "\r\n"; 401 t << vcard << "\r\n";
402 } 402 }
403 t << "\r\n\r\n"; 403 t << "\r\n\r\n";
404 outFile.close(); 404 outFile.close();
405} 405}
406void AddressBook::importFromFile( QString fileName, bool replaceLabel ) 406void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld )
407{ 407{
408 408
409 KABC::Addressee::List list; 409 if ( removeOld )
410 QFile file( fileName ); 410 setUntagged();
411 411 KABC::Addressee::List list;
412 file.open( IO_ReadOnly ); 412 QFile file( fileName );
413 QByteArray rawData = file.readAll(); 413 file.open( IO_ReadOnly );
414 file.close(); 414 QByteArray rawData = file.readAll();
415 QString data; 415 file.close();
416 if ( replaceLabel ) { 416 QString data;
417 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); 417 if ( replaceLabel ) {
418 data.replace ( QRegExp("LABEL") , "ADR" ); 418 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 );
419 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); 419 data.replace ( QRegExp("LABEL") , "ADR" );
420 } else 420 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" );
421 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 421 } else
422 KABC::VCardTool tool; 422 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
423 list = tool.parseVCards( data ); 423 KABC::VCardTool tool;
424 KABC::Addressee::List::Iterator it; 424 list = tool.parseVCards( data );
425 for ( it = list.begin(); it != list.end(); ++it ) { 425 KABC::Addressee::List::Iterator it;
426 (*it).setResource( 0 ); 426 for ( it = list.begin(); it != list.end(); ++it ) {
427 if ( replaceLabel ) 427 (*it).setResource( 0 );
428 (*it).removeVoice(); 428 if ( replaceLabel )
429 insertAddressee( (*it), false, true ); 429 (*it).removeVoice();
430 if ( removeOld )
431 (*it).setTagged( true );
432 insertAddressee( (*it), false, true );
433 }
434 if ( removeOld )
435 removeUntagged();
436}
437void AddressBook::setUntagged()
438{
439 Iterator ait;
440 for ( ait = begin(); ait != end(); ++ait ) {
441 (*ait).setTagged( false );
442 }
443}
444void AddressBook::removeUntagged()
445{
446 Iterator ait;
447 for ( ait = begin(); ait != end(); ++ait ) {
448 if (!(*ait).tagged())
449 removeAddressee( ait );
430 } 450 }
431 451
452 deleteRemovedAddressees();
432} 453}
433
434bool AddressBook::saveAB() 454bool AddressBook::saveAB()
435{ 455{
436 bool ok = true; 456 bool ok = true;
437 457
438 deleteRemovedAddressees(); 458 deleteRemovedAddressees();
439 Iterator ait; 459 Iterator ait;
440 for ( ait = begin(); ait != end(); ++ait ) { 460 for ( ait = begin(); ait != end(); ++ait ) {
441 if ( !(*ait).IDStr().isEmpty() ) { 461 if ( !(*ait).IDStr().isEmpty() ) {
442 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 462 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
443 } 463 }
444 } 464 }
445 KRES::Manager<Resource>::ActiveIterator it; 465 KRES::Manager<Resource>::ActiveIterator it;
446 KRES::Manager<Resource> *manager = d->mManager; 466 KRES::Manager<Resource> *manager = d->mManager;
447 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 467 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
448 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 468 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
449 Ticket *ticket = requestSaveTicket( *it ); 469 Ticket *ticket = requestSaveTicket( *it );
450// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 470// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
451 if ( !ticket ) { 471 if ( !ticket ) {
452 error( i18n( "Unable to save to resource '%1'. It is locked." ) 472 error( i18n( "Unable to save to resource '%1'. It is locked." )
453 .arg( (*it)->resourceName() ) ); 473 .arg( (*it)->resourceName() ) );
454 return false; 474 return false;
455 } 475 }
456 476
457 //if ( !save( ticket ) ) 477 //if ( !save( ticket ) )
458 if ( ticket->resource() ) { 478 if ( ticket->resource() ) {
459 if ( ! ticket->resource()->save( ticket ) ) 479 if ( ! ticket->resource()->save( ticket ) )
460 ok = false; 480 ok = false;
461 } else 481 } else
462 ok = false; 482 ok = false;
463 483
464 } 484 }
465 } 485 }
466 return ok; 486 return ok;
467} 487}
468 488
469AddressBook::Iterator AddressBook::begin() 489AddressBook::Iterator AddressBook::begin()
470{ 490{
471 Iterator it = Iterator(); 491 Iterator it = Iterator();
472 it.d->mIt = d->mAddressees.begin(); 492 it.d->mIt = d->mAddressees.begin();
473 return it; 493 return it;
474} 494}
475 495
476AddressBook::ConstIterator AddressBook::begin() const 496AddressBook::ConstIterator AddressBook::begin() const
477{ 497{
478 ConstIterator it = ConstIterator(); 498 ConstIterator it = ConstIterator();
479 it.d->mIt = d->mAddressees.begin(); 499 it.d->mIt = d->mAddressees.begin();
480 return it; 500 return it;
481} 501}
482 502
483AddressBook::Iterator AddressBook::end() 503AddressBook::Iterator AddressBook::end()
484{ 504{
485 Iterator it = Iterator(); 505 Iterator it = Iterator();
486 it.d->mIt = d->mAddressees.end(); 506 it.d->mIt = d->mAddressees.end();
487 return it; 507 return it;
488} 508}
489 509
490AddressBook::ConstIterator AddressBook::end() const 510AddressBook::ConstIterator AddressBook::end() const
491{ 511{
492 ConstIterator it = ConstIterator(); 512 ConstIterator it = ConstIterator();
493 it.d->mIt = d->mAddressees.end(); 513 it.d->mIt = d->mAddressees.end();
494 return it; 514 return it;
495} 515}
496 516
497void AddressBook::clear() 517void AddressBook::clear()
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index cea1b03..532e05d 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -82,129 +82,131 @@ class AddressBook : public QObject
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 void export2File( QString fileName ); 145 void export2File( QString fileName );
146 void importFromFile( QString fileName, bool replaceLabel = false ); 146 void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false );
147 void setUntagged();
148 void removeUntagged();
147 /** 149 /**
148 Returns a iterator for first entry of address book. 150 Returns a iterator for first entry of address book.
149 */ 151 */
150 Iterator begin(); 152 Iterator begin();
151 153
152 /** 154 /**
153 Returns a const iterator for first entry of address book. 155 Returns a const iterator for first entry of address book.
154 */ 156 */
155 ConstIterator begin() const; 157 ConstIterator begin() const;
156 158
157 /** 159 /**
158 Returns a iterator for first entry of address book. 160 Returns a iterator for first entry of address book.
159 */ 161 */
160 Iterator end(); 162 Iterator end();
161 163
162 /** 164 /**
163 Returns a const iterator for first entry of address book. 165 Returns a const iterator for first entry of address book.
164 */ 166 */
165 ConstIterator end() const; 167 ConstIterator end() const;
166 168
167 /** 169 /**
168 Removes all entries from address book. 170 Removes all entries from address book.
169 */ 171 */
170 void clear(); 172 void clear();
171 173
172 /** 174 /**
173 Insert an Addressee object into address book. If an object with the same 175 Insert an Addressee object into address book. If an object with the same
174 unique id already exists in the address book it it replaced by the new 176 unique id already exists in the address book it it replaced by the new
175 one. If not the new object is appended to the address book. 177 one. If not the new object is appended to the address book.
176 */ 178 */
177 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); 179 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
178 180
179 /** 181 /**
180 Removes entry from the address book. 182 Removes entry from the address book.
181 */ 183 */
182 void removeAddressee( const Addressee & ); 184 void removeAddressee( const Addressee & );
183 185
184 /** 186 /**
185 This is like @ref removeAddressee() just above, with the difference that 187 This is like @ref removeAddressee() just above, with the difference that
186 the first element is a iterator, returned by @ref begin(). 188 the first element is a iterator, returned by @ref begin().
187 */ 189 */
188 void removeAddressee( const Iterator & ); 190 void removeAddressee( const Iterator & );
189 191
190 /** 192 /**
191 Find the specified entry in address book. Returns end(), if the entry 193 Find the specified entry in address book. Returns end(), if the entry
192 couldn't be found. 194 couldn't be found.
193 */ 195 */
194 Iterator find( const Addressee & ); 196 Iterator find( const Addressee & );
195 197
196 /** 198 /**
197 Find the entry specified by an unique id. Returns an empty Addressee 199 Find the entry specified by an unique id. Returns an empty Addressee
198 object, if the address book does not contain an entry with this id. 200 object, if the address book does not contain an entry with this id.
199 */ 201 */
200 Addressee findByUid( const QString & ); 202 Addressee findByUid( const QString & );
201 203
202 204
203 /** 205 /**
204 Returns a list of all addressees in the address book. This list can 206 Returns a list of all addressees in the address book. This list can
205 be sorted with @ref KABC::AddresseeList for example. 207 be sorted with @ref KABC::AddresseeList for example.
206 */ 208 */
207 Addressee::List allAddressees(); 209 Addressee::List allAddressees();
208 210
209 /** 211 /**
210 Find all entries with the specified name in the address book. Returns 212 Find all entries with the specified name in the address book. Returns
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 3f3d5c0..607ae26 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -27,128 +27,129 @@ $Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h> 35#include <kidmanager.h>
36//US 36//US
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40//US #include "resource.h" 40//US #include "resource.h"
41#include "addressee.h" 41#include "addressee.h"
42 42
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46static bool matchBinaryPatternA( int value, int pattern ); 46static bool matchBinaryPatternA( int value, int pattern );
47static bool matchBinaryPatternP( int value, int pattern ); 47static bool matchBinaryPatternP( int value, int pattern );
48 48
49struct Addressee::AddresseeData : public KShared 49struct Addressee::AddresseeData : public KShared
50{ 50{
51 QString uid; 51 QString uid;
52 QString name; 52 QString name;
53 QString formattedName; 53 QString formattedName;
54 QString familyName; 54 QString familyName;
55 QString givenName; 55 QString givenName;
56 QString additionalName; 56 QString additionalName;
57 QString prefix; 57 QString prefix;
58 QString suffix; 58 QString suffix;
59 QString nickName; 59 QString nickName;
60 QDateTime birthday; 60 QDateTime birthday;
61 QString mailer; 61 QString mailer;
62 TimeZone timeZone; 62 TimeZone timeZone;
63 Geo geo; 63 Geo geo;
64 QString title; 64 QString title;
65 QString role; 65 QString role;
66 QString organization; 66 QString organization;
67 QString note; 67 QString note;
68 QString productId; 68 QString productId;
69 QDateTime revision; 69 QDateTime revision;
70 QString sortString; 70 QString sortString;
71 QString externalUID; 71 QString externalUID;
72 QString originalExternalUID; 72 QString originalExternalUID;
73 KURL url; 73 KURL url;
74 Secrecy secrecy; 74 Secrecy secrecy;
75 Picture logo; 75 Picture logo;
76 Picture photo; 76 Picture photo;
77 Sound sound; 77 Sound sound;
78 Agent agent; 78 Agent agent;
79 QString mExternalId; 79 QString mExternalId;
80 PhoneNumber::List phoneNumbers; 80 PhoneNumber::List phoneNumbers;
81 Address::List addresses; 81 Address::List addresses;
82 Key::List keys; 82 Key::List keys;
83 QStringList emails; 83 QStringList emails;
84 QStringList categories; 84 QStringList categories;
85 QStringList custom; 85 QStringList custom;
86 int mTempSyncStat; 86 int mTempSyncStat;
87 Resource *resource; 87 Resource *resource;
88 88
89 bool empty :1; 89 bool empty :1;
90 bool changed :1; 90 bool changed :1;
91 bool tagged :1;
91}; 92};
92 93
93Addressee::Addressee() 94Addressee::Addressee()
94{ 95{
95 mData = new AddresseeData; 96 mData = new AddresseeData;
96 mData->empty = true; 97 mData->empty = true;
97 mData->changed = false; 98 mData->changed = false;
98 mData->resource = 0; 99 mData->resource = 0;
99 mData->mExternalId = ":"; 100 mData->mExternalId = ":";
100 mData->revision = QDateTime ( QDate( 2003,1,1)); 101 mData->revision = QDateTime ( QDate( 2003,1,1));
101 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
102} 103}
103 104
104Addressee::~Addressee() 105Addressee::~Addressee()
105{ 106{
106} 107}
107 108
108Addressee::Addressee( const Addressee &a ) 109Addressee::Addressee( const Addressee &a )
109{ 110{
110 mData = a.mData; 111 mData = a.mData;
111} 112}
112 113
113Addressee &Addressee::operator=( const Addressee &a ) 114Addressee &Addressee::operator=( const Addressee &a )
114{ 115{
115 mData = a.mData; 116 mData = a.mData;
116 return (*this); 117 return (*this);
117} 118}
118 119
119Addressee Addressee::copy() 120Addressee Addressee::copy()
120{ 121{
121 Addressee a; 122 Addressee a;
122 *(a.mData) = *mData; 123 *(a.mData) = *mData;
123 return a; 124 return a;
124} 125}
125 126
126void Addressee::detach() 127void Addressee::detach()
127{ 128{
128 if ( mData.count() == 1 ) return; 129 if ( mData.count() == 1 ) return;
129 *this = copy(); 130 *this = copy();
130} 131}
131 132
132bool Addressee::operator==( const Addressee &a ) const 133bool Addressee::operator==( const Addressee &a ) const
133{ 134{
134 if ( uid() != a.uid() ) return false; 135 if ( uid() != a.uid() ) return false;
135 if ( mData->name != a.mData->name ) return false; 136 if ( mData->name != a.mData->name ) return false;
136 if ( mData->formattedName != a.mData->formattedName ) return false; 137 if ( mData->formattedName != a.mData->formattedName ) return false;
137 if ( mData->familyName != a.mData->familyName ) return false; 138 if ( mData->familyName != a.mData->familyName ) return false;
138 if ( mData->givenName != a.mData->givenName ) return false; 139 if ( mData->givenName != a.mData->givenName ) return false;
139 if ( mData->additionalName != a.mData->additionalName ) return false; 140 if ( mData->additionalName != a.mData->additionalName ) return false;
140 if ( mData->prefix != a.mData->prefix ) return false; 141 if ( mData->prefix != a.mData->prefix ) return false;
141 if ( mData->suffix != a.mData->suffix ) return false; 142 if ( mData->suffix != a.mData->suffix ) return false;
142 if ( mData->nickName != a.mData->nickName ) return false; 143 if ( mData->nickName != a.mData->nickName ) return false;
143 if ( mData->birthday != a.mData->birthday ) return false; 144 if ( mData->birthday != a.mData->birthday ) return false;
144 if ( mData->mailer != a.mData->mailer ) return false; 145 if ( mData->mailer != a.mData->mailer ) return false;
145 if ( mData->timeZone != a.mData->timeZone ) return false; 146 if ( mData->timeZone != a.mData->timeZone ) return false;
146 if ( mData->geo != a.mData->geo ) return false; 147 if ( mData->geo != a.mData->geo ) return false;
147 if ( mData->title != a.mData->title ) return false; 148 if ( mData->title != a.mData->title ) return false;
148 if ( mData->role != a.mData->role ) return false; 149 if ( mData->role != a.mData->role ) return false;
149 if ( mData->organization != a.mData->organization ) return false; 150 if ( mData->organization != a.mData->organization ) return false;
150 if ( mData->note != a.mData->note ) return false; 151 if ( mData->note != a.mData->note ) return false;
151 if ( mData->productId != a.mData->productId ) return false; 152 if ( mData->productId != a.mData->productId ) return false;
152 //if ( mData->revision != a.mData->revision ) return false; 153 //if ( mData->revision != a.mData->revision ) return false;
153 if ( mData->sortString != a.mData->sortString ) return false; 154 if ( mData->sortString != a.mData->sortString ) return false;
154 if ( mData->secrecy != a.mData->secrecy ) return false; 155 if ( mData->secrecy != a.mData->secrecy ) return false;
@@ -1760,128 +1761,139 @@ void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
1760 } 1761 }
1761 else 1762 else
1762 { 1763 {
1763 // We have a start position, try to find an end 1764 // We have a start position, try to find an end
1764 endPos = rawEmail.find(endCh, startPos+1); 1765 endPos = rawEmail.find(endCh, startPos+1);
1765 1766
1766 if (endPos < 0) 1767 if (endPos < 0)
1767 { 1768 {
1768 // We couldn't find the end of the email address. We can only 1769 // We couldn't find the end of the email address. We can only
1769 // assume the entire string is the email address. 1770 // assume the entire string is the email address.
1770 email = rawEmail; 1771 email = rawEmail;
1771 fullName = ""; 1772 fullName = "";
1772 } 1773 }
1773 else 1774 else
1774 { 1775 {
1775 // We have a start and end to the email address 1776 // We have a start and end to the email address
1776 1777
1777 // Grab the name part 1778 // Grab the name part
1778 fullName = rawEmail.left(startPos).stripWhiteSpace(); 1779 fullName = rawEmail.left(startPos).stripWhiteSpace();
1779 1780
1780 // grab the email part 1781 // grab the email part
1781 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); 1782 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
1782 1783
1783 // Check that we do not have any extra characters on the end of the 1784 // Check that we do not have any extra characters on the end of the
1784 // strings 1785 // strings
1785 len = fullName.length(); 1786 len = fullName.length();
1786 if (fullName[0]=='"' && fullName[len-1]=='"') 1787 if (fullName[0]=='"' && fullName[len-1]=='"')
1787 fullName = fullName.mid(1, len-2); 1788 fullName = fullName.mid(1, len-2);
1788 else if (fullName[0]=='<' && fullName[len-1]=='>') 1789 else if (fullName[0]=='<' && fullName[len-1]=='>')
1789 fullName = fullName.mid(1, len-2); 1790 fullName = fullName.mid(1, len-2);
1790 else if (fullName[0]=='(' && fullName[len-1]==')') 1791 else if (fullName[0]=='(' && fullName[len-1]==')')
1791 fullName = fullName.mid(1, len-2); 1792 fullName = fullName.mid(1, len-2);
1792 } 1793 }
1793 } 1794 }
1794} 1795}
1795 1796
1796void Addressee::setResource( Resource *resource ) 1797void Addressee::setResource( Resource *resource )
1797{ 1798{
1798 detach(); 1799 detach();
1799 mData->resource = resource; 1800 mData->resource = resource;
1800} 1801}
1801 1802
1802Resource *Addressee::resource() const 1803Resource *Addressee::resource() const
1803{ 1804{
1804 return mData->resource; 1805 return mData->resource;
1805} 1806}
1806 1807
1807//US 1808//US
1808QString Addressee::resourceLabel() 1809QString Addressee::resourceLabel()
1809{ 1810{
1810 return i18n("Resource"); 1811 return i18n("Resource");
1811} 1812}
1812 1813
1813void Addressee::setChanged( bool value ) 1814void Addressee::setChanged( bool value )
1814{ 1815{
1815 detach(); 1816 detach();
1816 mData->changed = value; 1817 mData->changed = value;
1817} 1818}
1818 1819
1819bool Addressee::changed() const 1820bool Addressee::changed() const
1820{ 1821{
1821 return mData->changed; 1822 return mData->changed;
1822} 1823}
1823 1824
1825void Addressee::setTagged( bool value )
1826{
1827 detach();
1828 mData->tagged = value;
1829}
1830
1831bool Addressee::tagged() const
1832{
1833 return mData->tagged;
1834}
1835
1824QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) 1836QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
1825{ 1837{
1826 if (!a.mData) return s; 1838 if (!a.mData) return s;
1827 1839
1828 s << a.uid(); 1840 s << a.uid();
1829 1841
1830 s << a.mData->name; 1842 s << a.mData->name;
1831 s << a.mData->formattedName; 1843 s << a.mData->formattedName;
1832 s << a.mData->familyName; 1844 s << a.mData->familyName;
1833 s << a.mData->givenName; 1845 s << a.mData->givenName;
1834 s << a.mData->additionalName; 1846 s << a.mData->additionalName;
1835 s << a.mData->prefix; 1847 s << a.mData->prefix;
1836 s << a.mData->suffix; 1848 s << a.mData->suffix;
1837 s << a.mData->nickName; 1849 s << a.mData->nickName;
1838 s << a.mData->birthday; 1850 s << a.mData->birthday;
1839 s << a.mData->mailer; 1851 s << a.mData->mailer;
1840 s << a.mData->timeZone; 1852 s << a.mData->timeZone;
1841 s << a.mData->geo; 1853 s << a.mData->geo;
1842 s << a.mData->title; 1854 s << a.mData->title;
1843 s << a.mData->role; 1855 s << a.mData->role;
1844 s << a.mData->organization; 1856 s << a.mData->organization;
1845 s << a.mData->note; 1857 s << a.mData->note;
1846 s << a.mData->productId; 1858 s << a.mData->productId;
1847 s << a.mData->revision; 1859 s << a.mData->revision;
1848 s << a.mData->sortString; 1860 s << a.mData->sortString;
1849 s << a.mData->url; 1861 s << a.mData->url;
1850 s << a.mData->secrecy; 1862 s << a.mData->secrecy;
1851 s << a.mData->logo; 1863 s << a.mData->logo;
1852 s << a.mData->photo; 1864 s << a.mData->photo;
1853 s << a.mData->sound; 1865 s << a.mData->sound;
1854 s << a.mData->agent; 1866 s << a.mData->agent;
1855 s << a.mData->phoneNumbers; 1867 s << a.mData->phoneNumbers;
1856 s << a.mData->addresses; 1868 s << a.mData->addresses;
1857 s << a.mData->emails; 1869 s << a.mData->emails;
1858 s << a.mData->categories; 1870 s << a.mData->categories;
1859 s << a.mData->custom; 1871 s << a.mData->custom;
1860 s << a.mData->keys; 1872 s << a.mData->keys;
1861 return s; 1873 return s;
1862} 1874}
1863 1875
1864QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) 1876QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
1865{ 1877{
1866 if (!a.mData) return s; 1878 if (!a.mData) return s;
1867 1879
1868 s >> a.mData->uid; 1880 s >> a.mData->uid;
1869 1881
1870 s >> a.mData->name; 1882 s >> a.mData->name;
1871 s >> a.mData->formattedName; 1883 s >> a.mData->formattedName;
1872 s >> a.mData->familyName; 1884 s >> a.mData->familyName;
1873 s >> a.mData->givenName; 1885 s >> a.mData->givenName;
1874 s >> a.mData->additionalName; 1886 s >> a.mData->additionalName;
1875 s >> a.mData->prefix; 1887 s >> a.mData->prefix;
1876 s >> a.mData->suffix; 1888 s >> a.mData->suffix;
1877 s >> a.mData->nickName; 1889 s >> a.mData->nickName;
1878 s >> a.mData->birthday; 1890 s >> a.mData->birthday;
1879 s >> a.mData->mailer; 1891 s >> a.mData->mailer;
1880 s >> a.mData->timeZone; 1892 s >> a.mData->timeZone;
1881 s >> a.mData->geo; 1893 s >> a.mData->geo;
1882 s >> a.mData->title; 1894 s >> a.mData->title;
1883 s >> a.mData->role; 1895 s >> a.mData->role;
1884 s >> a.mData->organization; 1896 s >> a.mData->organization;
1885 s >> a.mData->note; 1897 s >> a.mData->note;
1886 s >> a.mData->productId; 1898 s >> a.mData->productId;
1887 s >> a.mData->revision; 1899 s >> a.mData->revision;
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 9336edc..0aa2c51 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -770,80 +770,83 @@ class Addressee
770 */ 770 */
771 void insertCustom( const QString &app, const QString &name, 771 void insertCustom( const QString &app, const QString &name,
772 const QString &value ); 772 const QString &value );
773 773
774 /** 774 /**
775 Remove custom entry. 775 Remove custom entry.
776 */ 776 */
777 void removeCustom( const QString &app, const QString &name ); 777 void removeCustom( const QString &app, const QString &name );
778 778
779 /** 779 /**
780 Return value of custom entry, identified by app and entry name. 780 Return value of custom entry, identified by app and entry name.
781 */ 781 */
782 QString custom( const QString &app, const QString &name ) const; 782 QString custom( const QString &app, const QString &name ) const;
783 783
784 /** 784 /**
785 Set all custom entries. 785 Set all custom entries.
786 */ 786 */
787 void setCustoms( const QStringList & ); 787 void setCustoms( const QStringList & );
788 788
789 /** 789 /**
790 Return list of all custom entries. 790 Return list of all custom entries.
791 */ 791 */
792 QStringList customs() const; 792 QStringList customs() const;
793 793
794 /** 794 /**
795 Parse full email address. The result is given back in fullName and email. 795 Parse full email address. The result is given back in fullName and email.
796 */ 796 */
797 static void parseEmailAddress( const QString &rawEmail, QString &fullName, 797 static void parseEmailAddress( const QString &rawEmail, QString &fullName,
798 QString &email ); 798 QString &email );
799 799
800 /** 800 /**
801 Debug output. 801 Debug output.
802 */ 802 */
803 void dump() const; 803 void dump() const;
804 804
805 /** 805 /**
806 Returns string representation of the addressee. 806 Returns string representation of the addressee.
807 */ 807 */
808 QString asString() const; 808 QString asString() const;
809 809
810 /** 810 /**
811 Set resource where the addressee is from. 811 Set resource where the addressee is from.
812 */ 812 */
813 void setResource( Resource *resource ); 813 void setResource( Resource *resource );
814 814
815 /** 815 /**
816 Return pointer to resource. 816 Return pointer to resource.
817 */ 817 */
818 Resource *resource() const; 818 Resource *resource() const;
819 819
820 /** 820 /**
821 Return resourcelabel. 821 Return resourcelabel.
822 */ 822 */
823 //US 823 //US
824 static QString resourceLabel(); 824 static QString resourceLabel();
825 825
826 /** 826 /**
827 Mark addressee as changed. 827 Mark addressee as changed.
828 */ 828 */
829 void setChanged( bool value ); 829 void setChanged( bool value );
830 830
831 /** 831 /**
832 Return whether the addressee is changed. 832 Return whether the addressee is changed.
833 */ 833 */
834 bool changed() const; 834 bool changed() const;
835
836 void setTagged( bool value );
837 bool tagged() const;
835 838
836 private: 839 private:
837 Addressee copy(); 840 Addressee copy();
838 void detach(); 841 void detach();
839 842
840 struct AddresseeData; 843 struct AddresseeData;
841 mutable KSharedPtr<AddresseeData> mData; 844 mutable KSharedPtr<AddresseeData> mData;
842}; 845};
843 846
844QDataStream &operator<<( QDataStream &, const Addressee & ); 847QDataStream &operator<<( QDataStream &, const Addressee & );
845QDataStream &operator>>( QDataStream &, Addressee & ); 848QDataStream &operator>>( QDataStream &, Addressee & );
846 849
847} 850}
848 851
849#endif 852#endif
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 7ec3fca..452f1bc 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2815,85 +2815,85 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2815 // afterwrite processing 2815 // afterwrite processing
2816 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2816 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2817 } 2817 }
2818 } 2818 }
2819 } 2819 }
2820 setModified(); 2820 setModified();
2821 2821
2822 } 2822 }
2823 if ( syncOK ) 2823 if ( syncOK )
2824 mViewManager->refreshView(); 2824 mViewManager->refreshView();
2825 return syncOK; 2825 return syncOK;
2826#if 0 2826#if 0
2827 2827
2828 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2828 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2829 getEventViewerDialog()->setSyncMode( true ); 2829 getEventViewerDialog()->setSyncMode( true );
2830 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2830 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2831 getEventViewerDialog()->setSyncMode( false ); 2831 getEventViewerDialog()->setSyncMode( false );
2832 if ( syncOK ) { 2832 if ( syncOK ) {
2833 if ( KOPrefs::instance()->mWriteBackFile ) 2833 if ( KOPrefs::instance()->mWriteBackFile )
2834 { 2834 {
2835 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2835 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2836 storage->save(); 2836 storage->save();
2837 } 2837 }
2838 } 2838 }
2839 setModified(); 2839 setModified();
2840 } 2840 }
2841 2841
2842#endif 2842#endif
2843} 2843}
2844 2844
2845 2845
2846//this is a overwritten callbackmethods from the syncinterface 2846//this is a overwritten callbackmethods from the syncinterface
2847bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2847bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2848{ 2848{
2849 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2849 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2850 2850
2851 AddressBook abLocal( resource,"syncContact"); 2851 AddressBook abLocal( resource,"syncContact");
2852 bool syncOK = false; 2852 bool syncOK = false;
2853 if ( abLocal.load() ) { 2853 if ( abLocal.load() ) {
2854 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2854 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2855 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2855 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2856 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2856 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2857 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2857 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2858 if ( syncOK ) { 2858 if ( syncOK ) {
2859 if ( syncManager->mWriteBackFile ) { 2859 if ( syncManager->mWriteBackFile ) {
2860 abLocal.saveAB(); 2860 abLocal.saveAB();
2861 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2861 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2862 } 2862 }
2863 } 2863 }
2864 setModified(); 2864 setModified();
2865 } 2865 }
2866 if ( syncOK ) 2866 if ( syncOK )
2867 mViewManager->refreshView(); 2867 mViewManager->refreshView();
2868 return syncOK; 2868 return syncOK;
2869 2869
2870} 2870}
2871 2871
2872void KABCore::getFile( bool success ) 2872void KABCore::getFile( bool success )
2873{ 2873{
2874 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); 2874 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
2875 if ( ! success ) { 2875 if ( ! success ) {
2876 setCaption( i18n("Error receiving file. Nothing changed!") ); 2876 setCaption( i18n("Error receiving file. Nothing changed!") );
2877 return; 2877 return;
2878 } 2878 }
2879 mAddressBook->importFromFile( sentSyncFile() ); 2879 mAddressBook->importFromFile( sentSyncFile() , false, true );
2880 topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 2880 topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
2881 mViewManager->refreshView(); 2881 mViewManager->refreshView();
2882} 2882}
2883void KABCore::syncFileRequest() 2883void KABCore::syncFileRequest()
2884{ 2884{
2885 mAddressBook->export2File( sentSyncFile() ); 2885 mAddressBook->export2File( sentSyncFile() );
2886} 2886}
2887QString KABCore::sentSyncFile() 2887QString KABCore::sentSyncFile()
2888{ 2888{
2889#ifdef _WIN32_ 2889#ifdef _WIN32_
2890 return locateLocal( "tmp", "copysyncab.vcf" ); 2890 return locateLocal( "tmp", "copysyncab.vcf" );
2891#else 2891#else
2892 return QString( "/tmp/copysyncab.vcf" ); 2892 return QString( "/tmp/copysyncab.vcf" );
2893#endif 2893#endif
2894} 2894}
2895 2895
2896void KABCore::setCaptionBack() 2896void KABCore::setCaptionBack()
2897{ 2897{
2898 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2898 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2899} 2899}