summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp8
-rw-r--r--kabc/addressbook.h4
-rw-r--r--kabc/addressee.cpp82
-rw-r--r--kabc/addressee.h2
-rw-r--r--kaddressbook/kabcore.cpp6
5 files changed, 68 insertions, 34 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 19c26eb..8882259 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -98,1102 +98,1102 @@ AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iter
98} 98}
99 99
100AddressBook::Iterator::~Iterator() 100AddressBook::Iterator::~Iterator()
101{ 101{
102 delete d; 102 delete d;
103} 103}
104 104
105const Addressee &AddressBook::Iterator::operator*() const 105const Addressee &AddressBook::Iterator::operator*() const
106{ 106{
107 return *(d->mIt); 107 return *(d->mIt);
108} 108}
109 109
110Addressee &AddressBook::Iterator::operator*() 110Addressee &AddressBook::Iterator::operator*()
111{ 111{
112 return *(d->mIt); 112 return *(d->mIt);
113} 113}
114 114
115Addressee *AddressBook::Iterator::operator->() 115Addressee *AddressBook::Iterator::operator->()
116{ 116{
117 return &(*(d->mIt)); 117 return &(*(d->mIt));
118} 118}
119 119
120AddressBook::Iterator &AddressBook::Iterator::operator++() 120AddressBook::Iterator &AddressBook::Iterator::operator++()
121{ 121{
122 (d->mIt)++; 122 (d->mIt)++;
123 return *this; 123 return *this;
124} 124}
125 125
126AddressBook::Iterator &AddressBook::Iterator::operator++(int) 126AddressBook::Iterator &AddressBook::Iterator::operator++(int)
127{ 127{
128 (d->mIt)++; 128 (d->mIt)++;
129 return *this; 129 return *this;
130} 130}
131 131
132AddressBook::Iterator &AddressBook::Iterator::operator--() 132AddressBook::Iterator &AddressBook::Iterator::operator--()
133{ 133{
134 (d->mIt)--; 134 (d->mIt)--;
135 return *this; 135 return *this;
136} 136}
137 137
138AddressBook::Iterator &AddressBook::Iterator::operator--(int) 138AddressBook::Iterator &AddressBook::Iterator::operator--(int)
139{ 139{
140 (d->mIt)--; 140 (d->mIt)--;
141 return *this; 141 return *this;
142} 142}
143 143
144bool AddressBook::Iterator::operator==( const Iterator &it ) 144bool AddressBook::Iterator::operator==( const Iterator &it )
145{ 145{
146 return ( d->mIt == it.d->mIt ); 146 return ( d->mIt == it.d->mIt );
147} 147}
148 148
149bool AddressBook::Iterator::operator!=( const Iterator &it ) 149bool AddressBook::Iterator::operator!=( const Iterator &it )
150{ 150{
151 return ( d->mIt != it.d->mIt ); 151 return ( d->mIt != it.d->mIt );
152} 152}
153 153
154 154
155AddressBook::ConstIterator::ConstIterator() 155AddressBook::ConstIterator::ConstIterator()
156{ 156{
157 d = new ConstIteratorData; 157 d = new ConstIteratorData;
158} 158}
159 159
160AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) 160AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i )
161{ 161{
162 d = new ConstIteratorData; 162 d = new ConstIteratorData;
163 d->mIt = i.d->mIt; 163 d->mIt = i.d->mIt;
164} 164}
165 165
166AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) 166AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i )
167{ 167{
168 if( this == &i ) return *this; // guard for self assignment 168 if( this == &i ) return *this; // guard for self assignment
169 delete d; // delete the old data because the Iterator was really constructed before 169 delete d; // delete the old data because the Iterator was really constructed before
170 d = new ConstIteratorData; 170 d = new ConstIteratorData;
171 d->mIt = i.d->mIt; 171 d->mIt = i.d->mIt;
172 return *this; 172 return *this;
173} 173}
174 174
175AddressBook::ConstIterator::~ConstIterator() 175AddressBook::ConstIterator::~ConstIterator()
176{ 176{
177 delete d; 177 delete d;
178} 178}
179 179
180const Addressee &AddressBook::ConstIterator::operator*() const 180const Addressee &AddressBook::ConstIterator::operator*() const
181{ 181{
182 return *(d->mIt); 182 return *(d->mIt);
183} 183}
184 184
185const Addressee* AddressBook::ConstIterator::operator->() const 185const Addressee* AddressBook::ConstIterator::operator->() const
186{ 186{
187 return &(*(d->mIt)); 187 return &(*(d->mIt));
188} 188}
189 189
190AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() 190AddressBook::ConstIterator &AddressBook::ConstIterator::operator++()
191{ 191{
192 (d->mIt)++; 192 (d->mIt)++;
193 return *this; 193 return *this;
194} 194}
195 195
196AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) 196AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
197{ 197{
198 (d->mIt)++; 198 (d->mIt)++;
199 return *this; 199 return *this;
200} 200}
201 201
202AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() 202AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
203{ 203{
204 (d->mIt)--; 204 (d->mIt)--;
205 return *this; 205 return *this;
206} 206}
207 207
208AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) 208AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
209{ 209{
210 (d->mIt)--; 210 (d->mIt)--;
211 return *this; 211 return *this;
212} 212}
213 213
214bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) 214bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
215{ 215{
216 return ( d->mIt == it.d->mIt ); 216 return ( d->mIt == it.d->mIt );
217} 217}
218 218
219bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 219bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
220{ 220{
221 return ( d->mIt != it.d->mIt ); 221 return ( d->mIt != it.d->mIt );
222} 222}
223 223
224 224
225AddressBook::AddressBook() 225AddressBook::AddressBook()
226{ 226{
227 init(0, "contact"); 227 init(0, "contact");
228} 228}
229 229
230AddressBook::AddressBook( const QString &config ) 230AddressBook::AddressBook( const QString &config )
231{ 231{
232 init(config, "contact"); 232 init(config, "contact");
233} 233}
234 234
235AddressBook::AddressBook( const QString &config, const QString &family ) 235AddressBook::AddressBook( const QString &config, const QString &family )
236{ 236{
237 init(config, family); 237 init(config, family);
238 238
239} 239}
240 240
241// the default family is "contact" 241// the default family is "contact"
242void AddressBook::init(const QString &config, const QString &family ) 242void AddressBook::init(const QString &config, const QString &family )
243{ 243{
244 blockLSEchange = false; 244 blockLSEchange = false;
245 d = new AddressBookData; 245 d = new AddressBookData;
246 QString fami = family; 246 QString fami = family;
247 if (config != 0) { 247 if (config != 0) {
248 if ( family == "syncContact" ) { 248 if ( family == "syncContact" ) {
249 qDebug("creating sync config "); 249 qDebug("creating sync config ");
250 fami = "contact"; 250 fami = "contact";
251 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 251 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
252 con->setGroup( "General" ); 252 con->setGroup( "General" );
253 con->writeEntry( "ResourceKeys", QString("sync") ); 253 con->writeEntry( "ResourceKeys", QString("sync") );
254 con->writeEntry( "Standard", QString("sync") ); 254 con->writeEntry( "Standard", QString("sync") );
255 con->setGroup( "Resource_sync" ); 255 con->setGroup( "Resource_sync" );
256 con->writeEntry( "FileName", config ); 256 con->writeEntry( "FileName", config );
257 con->writeEntry( "FileFormat", QString("vcard") ); 257 con->writeEntry( "FileFormat", QString("vcard") );
258 con->writeEntry( "ResourceIdentifier", QString("sync") ); 258 con->writeEntry( "ResourceIdentifier", QString("sync") );
259 con->writeEntry( "ResourceName", QString("sync_res") ); 259 con->writeEntry( "ResourceName", QString("sync_res") );
260 if ( config.right(4) == ".xml" ) 260 if ( config.right(4) == ".xml" )
261 con->writeEntry( "ResourceType", QString("qtopia") ); 261 con->writeEntry( "ResourceType", QString("qtopia") );
262 else if ( config == "sharp" ) { 262 else if ( config == "sharp" ) {
263 con->writeEntry( "ResourceType", QString("sharp") ); 263 con->writeEntry( "ResourceType", QString("sharp") );
264 } else { 264 } else {
265 con->writeEntry( "ResourceType", QString("file") ); 265 con->writeEntry( "ResourceType", QString("file") );
266 } 266 }
267 //con->sync(); 267 //con->sync();
268 d->mConfig = con; 268 d->mConfig = con;
269 } 269 }
270 else 270 else
271 d->mConfig = new KConfig( locateLocal("config", config) ); 271 d->mConfig = new KConfig( locateLocal("config", config) );
272// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 272// qDebug("AddressBook::init 1 config=%s",config.latin1() );
273 } 273 }
274 else { 274 else {
275 d->mConfig = 0; 275 d->mConfig = 0;
276// qDebug("AddressBook::init 1 config=0"); 276// qDebug("AddressBook::init 1 config=0");
277 } 277 }
278 278
279//US d->mErrorHandler = 0; 279//US d->mErrorHandler = 0;
280 d->mManager = new KRES::Manager<Resource>( fami, false ); 280 d->mManager = new KRES::Manager<Resource>( fami, false );
281 d->mManager->readConfig( d->mConfig ); 281 d->mManager->readConfig( d->mConfig );
282 if ( family == "syncContact" ) { 282 if ( family == "syncContact" ) {
283 KRES::Manager<Resource> *manager = d->mManager; 283 KRES::Manager<Resource> *manager = d->mManager;
284 KRES::Manager<Resource>::ActiveIterator it; 284 KRES::Manager<Resource>::ActiveIterator it;
285 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 285 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
286 (*it)->setAddressBook( this ); 286 (*it)->setAddressBook( this );
287 if ( !(*it)->open() ) 287 if ( !(*it)->open() )
288 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 288 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
289 } 289 }
290 Resource *res = standardResource(); 290 Resource *res = standardResource();
291 if ( !res ) { 291 if ( !res ) {
292 qDebug("ERROR: no standard resource"); 292 qDebug("ERROR: no standard resource");
293 res = manager->createResource( "file" ); 293 res = manager->createResource( "file" );
294 if ( res ) 294 if ( res )
295 { 295 {
296 addResource( res ); 296 addResource( res );
297 } 297 }
298 else 298 else
299 qDebug(" No resource available!!!"); 299 qDebug(" No resource available!!!");
300 } 300 }
301 setStandardResource( res ); 301 setStandardResource( res );
302 manager->writeConfig(); 302 manager->writeConfig();
303 } 303 }
304 addCustomField( i18n( "Department" ), KABC::Field::Organization, 304 addCustomField( i18n( "Department" ), KABC::Field::Organization,
305 "X-Department", "KADDRESSBOOK" ); 305 "X-Department", "KADDRESSBOOK" );
306 addCustomField( i18n( "Profession" ), KABC::Field::Organization, 306 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
307 "X-Profession", "KADDRESSBOOK" ); 307 "X-Profession", "KADDRESSBOOK" );
308 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 308 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
309 "X-AssistantsName", "KADDRESSBOOK" ); 309 "X-AssistantsName", "KADDRESSBOOK" );
310 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 310 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
311 "X-ManagersName", "KADDRESSBOOK" ); 311 "X-ManagersName", "KADDRESSBOOK" );
312 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 312 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
313 "X-SpousesName", "KADDRESSBOOK" ); 313 "X-SpousesName", "KADDRESSBOOK" );
314 addCustomField( i18n( "Office" ), KABC::Field::Personal, 314 addCustomField( i18n( "Office" ), KABC::Field::Personal,
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}
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}
406// if QStringList uids is empty, all are exported 406// if QStringList uids is empty, all are exported
407bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) 407bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName )
408{ 408{
409 KABC::VCardConverter converter; 409 KABC::VCardConverter converter;
410 QString datastream; 410 QString datastream;
411 Iterator it; 411 Iterator it;
412 bool all = uids.isEmpty(); 412 bool all = uids.isEmpty();
413 for ( it = begin(); it != end(); ++it ) { 413 for ( it = begin(); it != end(); ++it ) {
414 // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 414 // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
415 if ( ! all ) { 415 if ( ! all ) {
416 if ( ! ( uids.contains((*it).uid() ) )) 416 if ( ! ( uids.contains((*it).uid() ) ))
417 continue; 417 continue;
418 } 418 }
419 KABC::Addressee a = ( *it ); 419 KABC::Addressee a = ( *it );
420 if ( a.isEmpty() ) 420 if ( a.isEmpty() )
421 continue; 421 continue;
422 a.simplifyEmails(); 422 a.simplifyEmails();
423 a.simplifyPhoneNumbers(); 423 a.simplifyPhoneNumbers();
424 a.simplifyPhoneNumberTypes(); 424 a.simplifyPhoneNumberTypes();
425 a.simplifyAddresses(); 425 a.simplifyAddresses();
426 426
427 QString vcard; 427 QString vcard;
428 QString vcardnew; 428 QString vcardnew;
429 converter.addresseeToVCard( a, vcard ); 429 converter.addresseeToVCard( a, vcard );
430 int start = 0; 430 int start = 0;
431 int next; 431 int next;
432 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 432 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
433 int semi = vcard.find(";", next); 433 int semi = vcard.find(";", next);
434 int dopp = vcard.find(":", next); 434 int dopp = vcard.find(":", next);
435 int sep; 435 int sep;
436 if ( semi < dopp && semi >= 0 ) 436 if ( semi < dopp && semi >= 0 )
437 sep = semi ; 437 sep = semi ;
438 else 438 else
439 sep = dopp; 439 sep = dopp;
440 vcardnew +=vcard.mid( start, next - start); 440 vcardnew +=vcard.mid( start, next - start);
441 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); 441 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
442 start = sep; 442 start = sep;
443 } 443 }
444 vcardnew += vcard.mid( start,vcard.length() ); 444 vcardnew += vcard.mid( start,vcard.length() );
445 vcard = ""; 445 vcard = "";
446 start = 0; 446 start = 0;
447 while ( (next = vcardnew.find("ADR", start) )>= 0 ) { 447 while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
448 int sep = vcardnew.find(":", next); 448 int sep = vcardnew.find(":", next);
449 vcard +=vcardnew.mid( start, next - start+3); 449 vcard +=vcardnew.mid( start, next - start+3);
450 start = sep; 450 start = sep;
451 } 451 }
452 vcard += vcardnew.mid( start,vcardnew.length() ); 452 vcard += vcardnew.mid( start,vcardnew.length() );
453 vcard.replace ( QRegExp(";;;") , "" ); 453 vcard.replace ( QRegExp(";;;") , "" );
454 vcard.replace ( QRegExp(";;") , "" ); 454 vcard.replace ( QRegExp(";;") , "" );
455 datastream += vcard; 455 datastream += vcard;
456 456
457 } 457 }
458 458
459 QFile outFile(fileName); 459 QFile outFile(fileName);
460 if ( outFile.open(IO_WriteOnly) ) { 460 if ( outFile.open(IO_WriteOnly) ) {
461 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 461 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
462 QTextStream t( &outFile ); // use a text stream 462 QTextStream t( &outFile ); // use a text stream
463 t.setEncoding( QTextStream::UnicodeUTF8 ); 463 t.setEncoding( QTextStream::UnicodeUTF8 );
464 t <<datastream; 464 t <<datastream;
465 t << "\r\n\r\n"; 465 t << "\r\n\r\n";
466 outFile.close(); 466 outFile.close();
467 467
468 } else { 468 } else {
469 qDebug("Error open temp file "); 469 qDebug("Error open temp file ");
470 return false; 470 return false;
471 } 471 }
472 return true; 472 return true;
473 473
474} 474}
475void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) 475void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld )
476{ 476{
477 477
478 if ( removeOld ) 478 if ( removeOld )
479 setUntagged(); 479 setUntagged();
480 KABC::Addressee::List list; 480 KABC::Addressee::List list;
481 QFile file( fileName ); 481 QFile file( fileName );
482 file.open( IO_ReadOnly ); 482 file.open( IO_ReadOnly );
483 QByteArray rawData = file.readAll(); 483 QByteArray rawData = file.readAll();
484 file.close(); 484 file.close();
485 QString data; 485 QString data;
486 if ( replaceLabel ) { 486 if ( replaceLabel ) {
487 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); 487 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 );
488 data.replace ( QRegExp("LABEL") , "ADR" ); 488 data.replace ( QRegExp("LABEL") , "ADR" );
489 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); 489 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" );
490 } else 490 } else
491 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 491 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
492 KABC::VCardTool tool; 492 KABC::VCardTool tool;
493 list = tool.parseVCards( data ); 493 list = tool.parseVCards( data );
494 KABC::Addressee::List::Iterator it; 494 KABC::Addressee::List::Iterator it;
495 for ( it = list.begin(); it != list.end(); ++it ) { 495 for ( it = list.begin(); it != list.end(); ++it ) {
496 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); 496 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
497 if ( !id.isEmpty() ) 497 if ( !id.isEmpty() )
498 (*it).setIDStr(id ); 498 (*it).setIDStr(id );
499 (*it).setResource( 0 ); 499 (*it).setResource( 0 );
500 if ( replaceLabel ) 500 if ( replaceLabel )
501 (*it).removeVoice(); 501 (*it).removeVoice();
502 if ( removeOld ) 502 if ( removeOld )
503 (*it).setTagged( true ); 503 (*it).setTagged( true );
504 insertAddressee( (*it), false, true ); 504 insertAddressee( (*it), false, true );
505 } 505 }
506 if ( removeOld ) 506 if ( removeOld )
507 removeUntagged(); 507 removeUntagged();
508} 508}
509void AddressBook::setUntagged() 509void AddressBook::setUntagged()
510{ 510{
511 Iterator ait; 511 Iterator ait;
512 for ( ait = begin(); ait != end(); ++ait ) { 512 for ( ait = begin(); ait != end(); ++ait ) {
513 (*ait).setTagged( false ); 513 (*ait).setTagged( false );
514 } 514 }
515} 515}
516void AddressBook::removeUntagged() 516void AddressBook::removeUntagged()
517{ 517{
518 Iterator ait; 518 Iterator ait;
519 bool todelete = false; 519 bool todelete = false;
520 Iterator todel; 520 Iterator todel;
521 for ( ait = begin(); ait != end(); ++ait ) { 521 for ( ait = begin(); ait != end(); ++ait ) {
522 if ( todelete ) 522 if ( todelete )
523 removeAddressee( todel ); 523 removeAddressee( todel );
524 if (!(*ait).tagged()) { 524 if (!(*ait).tagged()) {
525 todelete = true; 525 todelete = true;
526 todel = ait; 526 todel = ait;
527 } else 527 } else
528 todelete = false; 528 todelete = false;
529 } 529 }
530 if ( todelete ) 530 if ( todelete )
531 removeAddressee( todel ); 531 removeAddressee( todel );
532 deleteRemovedAddressees(); 532 deleteRemovedAddressees();
533} 533}
534void AddressBook::smplifyAddressees() 534void AddressBook::smplifyAddressees()
535{ 535{
536 Iterator ait; 536 Iterator ait;
537 for ( ait = begin(); ait != end(); ++ait ) { 537 for ( ait = begin(); ait != end(); ++ait ) {
538 (*ait).simplifyEmails(); 538 (*ait).simplifyEmails();
539 (*ait).simplifyPhoneNumbers(); 539 (*ait).simplifyPhoneNumbers();
540 (*ait).simplifyPhoneNumberTypes(); 540 (*ait).simplifyPhoneNumberTypes();
541 (*ait).simplifyAddresses(); 541 (*ait).simplifyAddresses();
542 } 542 }
543} 543}
544void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) 544void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync )
545{ 545{
546 Iterator ait; 546 Iterator ait;
547 for ( ait = begin(); ait != end(); ++ait ) { 547 for ( ait = begin(); ait != end(); ++ait ) {
548 QString id = (*ait).IDStr(); 548 QString id = (*ait).IDStr();
549 (*ait).setIDStr( ":"); 549 (*ait).setIDStr( ":");
550 (*ait).setExternalUID( id ); 550 (*ait).setExternalUID( id );
551 (*ait).setOriginalExternalUID( id ); 551 (*ait).setOriginalExternalUID( id );
552 if ( isPreSync ) 552 if ( isPreSync )
553 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 553 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
554 else { 554 else {
555 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 555 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
556 (*ait).setID( currentSyncDevice,id ); 556 (*ait).setID( currentSyncDevice,id );
557 557
558 } 558 }
559 } 559 }
560} 560}
561void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) 561void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice )
562{ 562{
563 563
564 setUntagged(); 564 setUntagged();
565 KABC::Addressee::List list; 565 KABC::Addressee::List list;
566 QFile file( fileName ); 566 QFile file( fileName );
567 file.open( IO_ReadOnly ); 567 file.open( IO_ReadOnly );
568 QByteArray rawData = file.readAll(); 568 QByteArray rawData = file.readAll();
569 file.close(); 569 file.close();
570 QString data; 570 QString data;
571 571
572 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 572 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
573 KABC::VCardTool tool; 573 KABC::VCardTool tool;
574 list = tool.parseVCards( data ); 574 list = tool.parseVCards( data );
575 KABC::Addressee::List::Iterator it; 575 KABC::Addressee::List::Iterator it;
576 for ( it = list.begin(); it != list.end(); ++it ) { 576 for ( it = list.begin(); it != list.end(); ++it ) {
577 Iterator ait; 577 Iterator ait;
578 for ( ait = begin(); ait != end(); ++ait ) { 578 for ( ait = begin(); ait != end(); ++ait ) {
579 if ( !(*ait).tagged() ) { 579 if ( !(*ait).tagged() ) {
580 if ( (*ait).containsAdr(*it)) { 580 if ( (*ait).containsAdr(*it)) {
581 (*ait).setTagged(true); 581 (*ait).setTagged(true);
582 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); 582 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
583 (*it).setIDStr( ":"); 583 (*it).setIDStr( ":");
584 (*it).setID( currentSyncDevice,id ); 584 (*it).setID( currentSyncDevice,id );
585 (*it).setExternalUID( id ); 585 (*it).setExternalUID( id );
586 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 586 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
587 (*it).setUid( ( (*ait).uid() )); 587 (*it).setUid( ( (*ait).uid() ));
588 break; 588 break;
589 } 589 }
590 } 590 }
591 591
592 } 592 }
593 if ( ait == end() ) 593 if ( ait == end() )
594 qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); 594 qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1());
595 } 595 }
596 clear(); 596 clear();
597 for ( it = list.begin(); it != list.end(); ++it ) { 597 for ( it = list.begin(); it != list.end(); ++it ) {
598 insertAddressee( (*it) ); 598 insertAddressee( (*it) );
599 } 599 }
600} 600}
601 601
602bool AddressBook::saveABphone( QString fileName ) 602bool AddressBook::saveABphone( QString fileName )
603{ 603{
604 //smplifyAddressees(); 604 //smplifyAddressees();
605 qDebug("saveABphone:: saving AB... "); 605 qDebug("saveABphone:: saving AB... ");
606 if ( ! export2PhoneFormat( QStringList() ,fileName ) ) 606 if ( ! export2PhoneFormat( QStringList() ,fileName ) )
607 return false; 607 return false;
608 qDebug("saveABphone:: writing to phone... "); 608 qDebug("saveABphone:: writing to phone... ");
609 if ( !PhoneAccess::writeToPhone( fileName) ) { 609 if ( !PhoneAccess::writeToPhone( fileName) ) {
610 return false; 610 return false;
611 } 611 }
612 qDebug("saveABphone:: re-reading from phone... "); 612 qDebug("saveABphone:: re-reading from phone... ");
613 if ( !PhoneAccess::readFromPhone( fileName) ) { 613 if ( !PhoneAccess::readFromPhone( fileName) ) {
614 return false; 614 return false;
615 } 615 }
616 return true; 616 return true;
617} 617}
618bool AddressBook::saveAB() 618bool AddressBook::saveAB()
619{ 619{
620 bool ok = true; 620 bool ok = true;
621 621
622 deleteRemovedAddressees(); 622 deleteRemovedAddressees();
623 Iterator ait; 623 Iterator ait;
624 for ( ait = begin(); ait != end(); ++ait ) { 624 for ( ait = begin(); ait != end(); ++ait ) {
625 if ( !(*ait).IDStr().isEmpty() ) { 625 if ( !(*ait).IDStr().isEmpty() ) {
626 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 626 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
627 } 627 }
628 } 628 }
629 KRES::Manager<Resource>::ActiveIterator it; 629 KRES::Manager<Resource>::ActiveIterator it;
630 KRES::Manager<Resource> *manager = d->mManager; 630 KRES::Manager<Resource> *manager = d->mManager;
631 qDebug("SaveAB::saving..." ); 631 qDebug("SaveAB::saving..." );
632 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 632 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
633 qDebug("SaveAB::checking resource..." ); 633 qDebug("SaveAB::checking resource..." );
634 if ( (*it)->readOnly() ) 634 if ( (*it)->readOnly() )
635 qDebug("resource is readonly." ); 635 qDebug("resource is readonly." );
636 if ( (*it)->isOpen() ) 636 if ( (*it)->isOpen() )
637 qDebug("resource is open" ); 637 qDebug("resource is open" );
638 638
639 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 639 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
640 Ticket *ticket = requestSaveTicket( *it ); 640 Ticket *ticket = requestSaveTicket( *it );
641 qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 641 qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
642 if ( !ticket ) { 642 if ( !ticket ) {
643 qDebug( i18n( "Unable to save to resource '%1'. It is locked." ) 643 qDebug( i18n( "Unable to save to resource '%1'. It is locked." )
644 .arg( (*it)->resourceName() ) ); 644 .arg( (*it)->resourceName() ) );
645 return false; 645 return false;
646 } 646 }
647 647
648 //if ( !save( ticket ) ) 648 //if ( !save( ticket ) )
649 if ( ticket->resource() ) { 649 if ( ticket->resource() ) {
650 QString name = ticket->resource()->resourceName(); 650 QString name = ticket->resource()->resourceName();
651 if ( ! ticket->resource()->save( ticket ) ) 651 if ( ! ticket->resource()->save( ticket ) )
652 ok = false; 652 ok = false;
653 else 653 else
654 qDebug("StdAddressBook::resource saved '%s'", name.latin1() ); 654 qDebug("StdAddressBook::resource saved '%s'", name.latin1() );
655 655
656 } else 656 } else
657 ok = false; 657 ok = false;
658 658
659 } 659 }
660 } 660 }
661 return ok; 661 return ok;
662} 662}
663 663
664AddressBook::Iterator AddressBook::begin() 664AddressBook::Iterator AddressBook::begin()
665{ 665{
666 Iterator it = Iterator(); 666 Iterator it = Iterator();
667 it.d->mIt = d->mAddressees.begin(); 667 it.d->mIt = d->mAddressees.begin();
668 return it; 668 return it;
669} 669}
670 670
671AddressBook::ConstIterator AddressBook::begin() const 671AddressBook::ConstIterator AddressBook::begin() const
672{ 672{
673 ConstIterator it = ConstIterator(); 673 ConstIterator it = ConstIterator();
674 it.d->mIt = d->mAddressees.begin(); 674 it.d->mIt = d->mAddressees.begin();
675 return it; 675 return it;
676} 676}
677 677
678AddressBook::Iterator AddressBook::end() 678AddressBook::Iterator AddressBook::end()
679{ 679{
680 Iterator it = Iterator(); 680 Iterator it = Iterator();
681 it.d->mIt = d->mAddressees.end(); 681 it.d->mIt = d->mAddressees.end();
682 return it; 682 return it;
683} 683}
684 684
685AddressBook::ConstIterator AddressBook::end() const 685AddressBook::ConstIterator AddressBook::end() const
686{ 686{
687 ConstIterator it = ConstIterator(); 687 ConstIterator it = ConstIterator();
688 it.d->mIt = d->mAddressees.end(); 688 it.d->mIt = d->mAddressees.end();
689 return it; 689 return it;
690} 690}
691 691
692void AddressBook::clear() 692void AddressBook::clear()
693{ 693{
694 d->mAddressees.clear(); 694 d->mAddressees.clear();
695} 695}
696 696
697Ticket *AddressBook::requestSaveTicket( Resource *resource ) 697Ticket *AddressBook::requestSaveTicket( Resource *resource )
698{ 698{
699 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 699 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
700 700
701 if ( !resource ) 701 if ( !resource )
702 { 702 {
703 qDebug("AddressBook::requestSaveTicket no resource" ); 703 qDebug("AddressBook::requestSaveTicket no resource" );
704 resource = standardResource(); 704 resource = standardResource();
705 } 705 }
706 706
707 KRES::Manager<Resource>::ActiveIterator it; 707 KRES::Manager<Resource>::ActiveIterator it;
708 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 708 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
709 if ( (*it) == resource ) { 709 if ( (*it) == resource ) {
710 if ( (*it)->readOnly() || !(*it)->isOpen() ) 710 if ( (*it)->readOnly() || !(*it)->isOpen() )
711 return 0; 711 return 0;
712 else 712 else
713 return (*it)->requestSaveTicket(); 713 return (*it)->requestSaveTicket();
714 } 714 }
715 } 715 }
716 716
717 return 0; 717 return 0;
718} 718}
719//void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); 719//void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
720void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) 720void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource )
721{ 721{
722 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 722 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
723 //qDebug("block insert "); 723 //qDebug("block insert ");
724 return; 724 return;
725 } 725 }
726 //qDebug("inserting.... %s ",a.uid().latin1() ); 726 //qDebug("inserting.... %s ",a.uid().latin1() );
727 bool found = false; 727 bool found = false;
728 Addressee::List::Iterator it; 728 Addressee::List::Iterator it;
729 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 729 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
730 if ( a.uid() == (*it).uid() ) { 730 if ( a.uid() == (*it).uid() ) {
731 731
732 bool changed = false; 732 bool changed = false;
733 Addressee addr = a; 733 Addressee addr = a;
734 if ( addr != (*it) ) 734 if ( addr != (*it) )
735 changed = true; 735 changed = true;
736 736
737 if ( takeResource ) { 737 if ( takeResource ) {
738 Resource * res = (*it).resource(); 738 Resource * res = (*it).resource();
739 (*it) = a; 739 (*it) = a;
740 (*it).setResource( res ); 740 (*it).setResource( res );
741 } else { 741 } else {
742 (*it) = a; 742 (*it) = a;
743 if ( (*it).resource() == 0 ) 743 if ( (*it).resource() == 0 )
744 (*it).setResource( standardResource() ); 744 (*it).setResource( standardResource() );
745 } 745 }
746 if ( changed ) { 746 if ( changed ) {
747 if ( setRev ) { 747 if ( setRev ) {
748 748
749 // get rid of micro seconds 749 // get rid of micro seconds
750 QDateTime dt = QDateTime::currentDateTime(); 750 QDateTime dt = QDateTime::currentDateTime();
751 QTime t = dt.time(); 751 QTime t = dt.time();
752 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 752 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
753 (*it).setRevision( dt ); 753 (*it).setRevision( dt );
754 } 754 }
755 (*it).setChanged( true ); 755 (*it).setChanged( true );
756 } 756 }
757 757
758 found = true; 758 found = true;
759 } else { 759 } else {
760 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 760 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
761 QString name = (*it).uid().mid( 19 ); 761 QString name = (*it).uid().mid( 19 );
762 Addressee b = a; 762 Addressee b = a;
763 QString id = b.getID( name ); 763 QString id = b.getID( name );
764 if ( ! id.isEmpty() ) { 764 if ( ! id.isEmpty() ) {
765 QString des = (*it).note(); 765 QString des = (*it).note();
766 int startN; 766 int startN;
767 if( (startN = des.find( id ) ) >= 0 ) { 767 if( (startN = des.find( id ) ) >= 0 ) {
768 int endN = des.find( ",", startN+1 ); 768 int endN = des.find( ",", startN+1 );
769 des = des.left( startN ) + des.mid( endN+1 ); 769 des = des.left( startN ) + des.mid( endN+1 );
770 (*it).setNote( des ); 770 (*it).setNote( des );
771 } 771 }
772 } 772 }
773 } 773 }
774 } 774 }
775 } 775 }
776 if ( found ) 776 if ( found )
777 return; 777 return;
778 d->mAddressees.append( a ); 778 d->mAddressees.append( a );
779 Addressee& addr = d->mAddressees.last(); 779 Addressee& addr = d->mAddressees.last();
780 if ( addr.resource() == 0 ) 780 if ( addr.resource() == 0 )
781 addr.setResource( standardResource() ); 781 addr.setResource( standardResource() );
782 782
783 addr.setChanged( true ); 783 addr.setChanged( true );
784} 784}
785 785
786void AddressBook::removeAddressee( const Addressee &a ) 786void AddressBook::removeAddressee( const Addressee &a )
787{ 787{
788 Iterator it; 788 Iterator it;
789 Iterator it2; 789 Iterator it2;
790 bool found = false; 790 bool found = false;
791 for ( it = begin(); it != end(); ++it ) { 791 for ( it = begin(); it != end(); ++it ) {
792 if ( a.uid() == (*it).uid() ) { 792 if ( a.uid() == (*it).uid() ) {
793 found = true; 793 found = true;
794 it2 = it; 794 it2 = it;
795 } else { 795 } else {
796 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 796 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
797 QString name = (*it).uid().mid( 19 ); 797 QString name = (*it).uid().mid( 19 );
798 Addressee b = a; 798 Addressee b = a;
799 QString id = b.getID( name ); 799 QString id = b.getID( name );
800 if ( ! id.isEmpty() ) { 800 if ( ! id.isEmpty() ) {
801 QString des = (*it).note(); 801 QString des = (*it).note();
802 if( des.find( id ) < 0 ) { 802 if( des.find( id ) < 0 ) {
803 des += id + ","; 803 des += id + ",";
804 (*it).setNote( des ); 804 (*it).setNote( des );
805 } 805 }
806 } 806 }
807 } 807 }
808 808
809 } 809 }
810 } 810 }
811 811
812 if ( found ) 812 if ( found )
813 removeAddressee( it2 ); 813 removeAddressee( it2 );
814 814
815} 815}
816 816
817void AddressBook::removeSyncAddressees( bool removeDeleted ) 817void AddressBook::removeSyncAddressees( bool removeDeleted )
818{ 818{
819 Iterator it = begin(); 819 Iterator it = begin();
820 Iterator it2 ; 820 Iterator it2 ;
821 QDateTime dt ( QDate( 2004,1,1) ); 821 QDateTime dt ( QDate( 2004,1,1) );
822 while ( it != end() ) { 822 while ( it != end() ) {
823 (*it).setRevision( dt ); 823 (*it).setRevision( dt );
824 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 824 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
825 (*it).setIDStr(""); 825 (*it).setIDStr("");
826 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 826 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
827 it2 = it; 827 it2 = it;
828 //qDebug("removing %s ",(*it).uid().latin1() ); 828 //qDebug("removing %s ",(*it).uid().latin1() );
829 ++it; 829 ++it;
830 removeAddressee( it2 ); 830 removeAddressee( it2 );
831 } else { 831 } else {
832 //qDebug("skipping %s ",(*it).uid().latin1() ); 832 //qDebug("skipping %s ",(*it).uid().latin1() );
833 ++it; 833 ++it;
834 } 834 }
835 } 835 }
836 deleteRemovedAddressees(); 836 deleteRemovedAddressees();
837} 837}
838 838
839void AddressBook::removeAddressee( const Iterator &it ) 839void AddressBook::removeAddressee( const Iterator &it )
840{ 840{
841 d->mRemovedAddressees.append( (*it) ); 841 d->mRemovedAddressees.append( (*it) );
842 d->mAddressees.remove( it.d->mIt ); 842 d->mAddressees.remove( it.d->mIt );
843} 843}
844 844
845AddressBook::Iterator AddressBook::find( const Addressee &a ) 845AddressBook::Iterator AddressBook::find( const Addressee &a )
846{ 846{
847 Iterator it; 847 Iterator it;
848 for ( it = begin(); it != end(); ++it ) { 848 for ( it = begin(); it != end(); ++it ) {
849 if ( a.uid() == (*it).uid() ) { 849 if ( a.uid() == (*it).uid() ) {
850 return it; 850 return it;
851 } 851 }
852 } 852 }
853 return end(); 853 return end();
854} 854}
855 855
856Addressee AddressBook::findByUid( const QString &uid ) 856Addressee AddressBook::findByUid( const QString &uid )
857{ 857{
858 Iterator it; 858 Iterator it;
859 for ( it = begin(); it != end(); ++it ) { 859 for ( it = begin(); it != end(); ++it ) {
860 if ( uid == (*it).uid() ) { 860 if ( uid == (*it).uid() ) {
861 return *it; 861 return *it;
862 } 862 }
863 } 863 }
864 return Addressee(); 864 return Addressee();
865} 865}
866void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) 866void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset )
867{ 867{
868 //qDebug("AddressBook::preExternSync "); 868 //qDebug("AddressBook::preExternSync ");
869 AddressBook::Iterator it; 869 AddressBook::Iterator it;
870 for ( it = begin(); it != end(); ++it ) { 870 for ( it = begin(); it != end(); ++it ) {
871 (*it).setID( csd, (*it).externalUID() ); 871 (*it).setID( csd, (*it).externalUID() );
872 (*it).computeCsum( csd ); 872 (*it).computeCsum( csd );
873 } 873 }
874 mergeAB( aBook ,csd ); 874 mergeAB( aBook ,csd, isSubset );
875} 875}
876void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) 876void AddressBook::postExternSync( AddressBook* aBook , const QString& csd)
877{ 877{
878 //qDebug("AddressBook::postExternSync "); 878 //qDebug("AddressBook::postExternSync ");
879 AddressBook::Iterator it; 879 AddressBook::Iterator it;
880 for ( it = begin(); it != end(); ++it ) { 880 for ( it = begin(); it != end(); ++it ) {
881 // qDebug("check uid %s ", (*it).uid().latin1() ); 881 // qDebug("check uid %s ", (*it).uid().latin1() );
882 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 882 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
883 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { 883 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
884 Addressee ad = aBook->findByUid( ( (*it).uid() )); 884 Addressee ad = aBook->findByUid( ( (*it).uid() ));
885 if ( ad.isEmpty() ) { 885 if ( ad.isEmpty() ) {
886 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); 886 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1());
887 } else { 887 } else {
888 (*it).computeCsum( csd ); 888 (*it).computeCsum( csd );
889 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 889 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
890 ad.setID( csd, (*it).externalUID() ); 890 ad.setID( csd, (*it).externalUID() );
891 ad.setCsum( csd, (*it).getCsum( csd ) ); 891 ad.setCsum( csd, (*it).getCsum( csd ) );
892 aBook->insertAddressee( ad ); 892 aBook->insertAddressee( ad );
893 } 893 }
894 } 894 }
895 } 895 }
896} 896}
897 897
898bool AddressBook::containsExternalUid( const QString& uid ) 898bool AddressBook::containsExternalUid( const QString& uid )
899{ 899{
900 Iterator it; 900 Iterator it;
901 for ( it = begin(); it != end(); ++it ) { 901 for ( it = begin(); it != end(); ++it ) {
902 if ( uid == (*it).externalUID( ) ) 902 if ( uid == (*it).externalUID( ) )
903 return true; 903 return true;
904 } 904 }
905 return false; 905 return false;
906} 906}
907Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) 907Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
908{ 908{
909 Iterator it; 909 Iterator it;
910 for ( it = begin(); it != end(); ++it ) { 910 for ( it = begin(); it != end(); ++it ) {
911 if ( uid == (*it).getID( profile ) ) 911 if ( uid == (*it).getID( profile ) )
912 return (*it); 912 return (*it);
913 } 913 }
914 return Addressee(); 914 return Addressee();
915} 915}
916void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) 916void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset )
917{ 917{
918 Iterator it; 918 Iterator it;
919 Addressee ad; 919 Addressee ad;
920 for ( it = begin(); it != end(); ++it ) { 920 for ( it = begin(); it != end(); ++it ) {
921 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 921 ad = aBook->findByExternUid( (*it).externalUID(), profile );
922 if ( !ad.isEmpty() ) { 922 if ( !ad.isEmpty() ) {
923 (*it).mergeContact( ad ); 923 (*it).mergeContact( ad ,isSubset);
924 } 924 }
925 } 925 }
926#if 0 926#if 0
927 // test only 927 // test only
928 for ( it = begin(); it != end(); ++it ) { 928 for ( it = begin(); it != end(); ++it ) {
929 929
930 qDebug("uid %s ", (*it).uid().latin1()); 930 qDebug("uid %s ", (*it).uid().latin1());
931 } 931 }
932#endif 932#endif
933} 933}
934 934
935#if 0 935#if 0
936Addressee::List AddressBook::getExternLastSyncAddressees() 936Addressee::List AddressBook::getExternLastSyncAddressees()
937{ 937{
938 Addressee::List results; 938 Addressee::List results;
939 939
940 Iterator it; 940 Iterator it;
941 for ( it = begin(); it != end(); ++it ) { 941 for ( it = begin(); it != end(); ++it ) {
942 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 942 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
943 if ( (*it).familyName().left(4) == "!E: " ) 943 if ( (*it).familyName().left(4) == "!E: " )
944 results.append( *it ); 944 results.append( *it );
945 } 945 }
946 } 946 }
947 947
948 return results; 948 return results;
949} 949}
950#endif 950#endif
951void AddressBook::resetTempSyncStat() 951void AddressBook::resetTempSyncStat()
952{ 952{
953 Iterator it; 953 Iterator it;
954 for ( it = begin(); it != end(); ++it ) { 954 for ( it = begin(); it != end(); ++it ) {
955 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 955 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
956 } 956 }
957 957
958} 958}
959 959
960QStringList AddressBook:: uidList() 960QStringList AddressBook:: uidList()
961{ 961{
962 QStringList results; 962 QStringList results;
963 Iterator it; 963 Iterator it;
964 for ( it = begin(); it != end(); ++it ) { 964 for ( it = begin(); it != end(); ++it ) {
965 results.append( (*it).uid() ); 965 results.append( (*it).uid() );
966 } 966 }
967 return results; 967 return results;
968} 968}
969 969
970 970
971Addressee::List AddressBook::allAddressees() 971Addressee::List AddressBook::allAddressees()
972{ 972{
973 return d->mAddressees; 973 return d->mAddressees;
974 974
975} 975}
976 976
977Addressee::List AddressBook::findByName( const QString &name ) 977Addressee::List AddressBook::findByName( const QString &name )
978{ 978{
979 Addressee::List results; 979 Addressee::List results;
980 980
981 Iterator it; 981 Iterator it;
982 for ( it = begin(); it != end(); ++it ) { 982 for ( it = begin(); it != end(); ++it ) {
983 if ( name == (*it).realName() ) { 983 if ( name == (*it).realName() ) {
984 results.append( *it ); 984 results.append( *it );
985 } 985 }
986 } 986 }
987 987
988 return results; 988 return results;
989} 989}
990 990
991Addressee::List AddressBook::findByEmail( const QString &email ) 991Addressee::List AddressBook::findByEmail( const QString &email )
992{ 992{
993 Addressee::List results; 993 Addressee::List results;
994 QStringList mailList; 994 QStringList mailList;
995 995
996 Iterator it; 996 Iterator it;
997 for ( it = begin(); it != end(); ++it ) { 997 for ( it = begin(); it != end(); ++it ) {
998 mailList = (*it).emails(); 998 mailList = (*it).emails();
999 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 999 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
1000 if ( email == (*ite) ) { 1000 if ( email == (*ite) ) {
1001 results.append( *it ); 1001 results.append( *it );
1002 } 1002 }
1003 } 1003 }
1004 } 1004 }
1005 1005
1006 return results; 1006 return results;
1007} 1007}
1008 1008
1009Addressee::List AddressBook::findByCategory( const QString &category ) 1009Addressee::List AddressBook::findByCategory( const QString &category )
1010{ 1010{
1011 Addressee::List results; 1011 Addressee::List results;
1012 1012
1013 Iterator it; 1013 Iterator it;
1014 for ( it = begin(); it != end(); ++it ) { 1014 for ( it = begin(); it != end(); ++it ) {
1015 if ( (*it).hasCategory( category) ) { 1015 if ( (*it).hasCategory( category) ) {
1016 results.append( *it ); 1016 results.append( *it );
1017 } 1017 }
1018 } 1018 }
1019 1019
1020 return results; 1020 return results;
1021} 1021}
1022 1022
1023void AddressBook::dump() const 1023void AddressBook::dump() const
1024{ 1024{
1025 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; 1025 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
1026 1026
1027 ConstIterator it; 1027 ConstIterator it;
1028 for( it = begin(); it != end(); ++it ) { 1028 for( it = begin(); it != end(); ++it ) {
1029 (*it).dump(); 1029 (*it).dump();
1030 } 1030 }
1031 1031
1032 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; 1032 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
1033} 1033}
1034 1034
1035QString AddressBook::identifier() 1035QString AddressBook::identifier()
1036{ 1036{
1037 QStringList identifier; 1037 QStringList identifier;
1038 1038
1039 1039
1040 KRES::Manager<Resource>::ActiveIterator it; 1040 KRES::Manager<Resource>::ActiveIterator it;
1041 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 1041 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
1042 if ( !(*it)->identifier().isEmpty() ) 1042 if ( !(*it)->identifier().isEmpty() )
1043 identifier.append( (*it)->identifier() ); 1043 identifier.append( (*it)->identifier() );
1044 } 1044 }
1045 1045
1046 return identifier.join( ":" ); 1046 return identifier.join( ":" );
1047} 1047}
1048 1048
1049Field::List AddressBook::fields( int category ) 1049Field::List AddressBook::fields( int category )
1050{ 1050{
1051 if ( d->mAllFields.isEmpty() ) { 1051 if ( d->mAllFields.isEmpty() ) {
1052 d->mAllFields = Field::allFields(); 1052 d->mAllFields = Field::allFields();
1053 } 1053 }
1054 1054
1055 if ( category == Field::All ) return d->mAllFields; 1055 if ( category == Field::All ) return d->mAllFields;
1056 1056
1057 Field::List result; 1057 Field::List result;
1058 Field::List::ConstIterator it; 1058 Field::List::ConstIterator it;
1059 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { 1059 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
1060 if ( (*it)->category() & category ) result.append( *it ); 1060 if ( (*it)->category() & category ) result.append( *it );
1061 } 1061 }
1062 1062
1063 return result; 1063 return result;
1064} 1064}
1065 1065
1066bool AddressBook::addCustomField( const QString &label, int category, 1066bool AddressBook::addCustomField( const QString &label, int category,
1067 const QString &key, const QString &app ) 1067 const QString &key, const QString &app )
1068{ 1068{
1069 if ( d->mAllFields.isEmpty() ) { 1069 if ( d->mAllFields.isEmpty() ) {
1070 d->mAllFields = Field::allFields(); 1070 d->mAllFields = Field::allFields();
1071 } 1071 }
1072//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; 1072//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
1073 QString a = app.isNull() ? KGlobal::getAppName() : app; 1073 QString a = app.isNull() ? KGlobal::getAppName() : app;
1074 1074
1075 QString k = key.isNull() ? label : key; 1075 QString k = key.isNull() ? label : key;
1076 1076
1077 Field *field = Field::createCustomField( label, category, k, a ); 1077 Field *field = Field::createCustomField( label, category, k, a );
1078 1078
1079 if ( !field ) return false; 1079 if ( !field ) return false;
1080 1080
1081 d->mAllFields.append( field ); 1081 d->mAllFields.append( field );
1082 1082
1083 return true; 1083 return true;
1084} 1084}
1085 1085
1086QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) 1086QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab )
1087{ 1087{
1088 if (!ab.d) return s; 1088 if (!ab.d) return s;
1089 1089
1090 return s << ab.d->mAddressees; 1090 return s << ab.d->mAddressees;
1091} 1091}
1092 1092
1093QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) 1093QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
1094{ 1094{
1095 if (!ab.d) return s; 1095 if (!ab.d) return s;
1096 1096
1097 s >> ab.d->mAddressees; 1097 s >> ab.d->mAddressees;
1098 1098
1099 return s; 1099 return s;
1100} 1100}
1101 1101
1102bool AddressBook::addResource( Resource *resource ) 1102bool AddressBook::addResource( Resource *resource )
1103{ 1103{
1104 if ( !resource->open() ) { 1104 if ( !resource->open() ) {
1105 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; 1105 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl;
1106 return false; 1106 return false;
1107 } 1107 }
1108 1108
1109 resource->setAddressBook( this ); 1109 resource->setAddressBook( this );
1110 1110
1111 d->mManager->add( resource ); 1111 d->mManager->add( resource );
1112 return true; 1112 return true;
1113} 1113}
1114 1114
1115bool AddressBook::removeResource( Resource *resource ) 1115bool AddressBook::removeResource( Resource *resource )
1116{ 1116{
1117 resource->close(); 1117 resource->close();
1118 1118
1119 if ( resource == standardResource() ) 1119 if ( resource == standardResource() )
1120 d->mManager->setStandardResource( 0 ); 1120 d->mManager->setStandardResource( 0 );
1121 1121
1122 resource->setAddressBook( 0 ); 1122 resource->setAddressBook( 0 );
1123 1123
1124 d->mManager->remove( resource ); 1124 d->mManager->remove( resource );
1125 return true; 1125 return true;
1126} 1126}
1127 1127
1128QPtrList<Resource> AddressBook::resources() 1128QPtrList<Resource> AddressBook::resources()
1129{ 1129{
1130 QPtrList<Resource> list; 1130 QPtrList<Resource> list;
1131 1131
1132// qDebug("AddressBook::resources() 1"); 1132// qDebug("AddressBook::resources() 1");
1133 1133
1134 KRES::Manager<Resource>::ActiveIterator it; 1134 KRES::Manager<Resource>::ActiveIterator it;
1135 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 1135 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
1136 list.append( *it ); 1136 list.append( *it );
1137 1137
1138 return list; 1138 return list;
1139} 1139}
1140 1140
1141/*US 1141/*US
1142void AddressBook::setErrorHandler( ErrorHandler *handler ) 1142void AddressBook::setErrorHandler( ErrorHandler *handler )
1143{ 1143{
1144 delete d->mErrorHandler; 1144 delete d->mErrorHandler;
1145 d->mErrorHandler = handler; 1145 d->mErrorHandler = handler;
1146} 1146}
1147*/ 1147*/
1148 1148
1149void AddressBook::error( const QString& msg ) 1149void AddressBook::error( const QString& msg )
1150{ 1150{
1151/*US 1151/*US
1152 if ( !d->mErrorHandler ) // create default error handler 1152 if ( !d->mErrorHandler ) // create default error handler
1153 d->mErrorHandler = new ConsoleErrorHandler; 1153 d->mErrorHandler = new ConsoleErrorHandler;
1154 1154
1155 if ( d->mErrorHandler ) 1155 if ( d->mErrorHandler )
1156 d->mErrorHandler->error( msg ); 1156 d->mErrorHandler->error( msg );
1157 else 1157 else
1158 kdError(5700) << "no error handler defined" << endl; 1158 kdError(5700) << "no error handler defined" << endl;
1159*/ 1159*/
1160 kdDebug(5700) << "msg" << endl; 1160 kdDebug(5700) << "msg" << endl;
1161 qDebug(msg); 1161 qDebug(msg);
1162} 1162}
1163 1163
1164void AddressBook::deleteRemovedAddressees() 1164void AddressBook::deleteRemovedAddressees()
1165{ 1165{
1166 Addressee::List::Iterator it; 1166 Addressee::List::Iterator it;
1167 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { 1167 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) {
1168 Resource *resource = (*it).resource(); 1168 Resource *resource = (*it).resource();
1169 if ( resource && !resource->readOnly() && resource->isOpen() ) 1169 if ( resource && !resource->readOnly() && resource->isOpen() )
1170 resource->removeAddressee( *it ); 1170 resource->removeAddressee( *it );
1171 } 1171 }
1172 1172
1173 d->mRemovedAddressees.clear(); 1173 d->mRemovedAddressees.clear();
1174} 1174}
1175 1175
1176void AddressBook::setStandardResource( Resource *resource ) 1176void AddressBook::setStandardResource( Resource *resource )
1177{ 1177{
1178// qDebug("AddressBook::setStandardResource 1"); 1178// qDebug("AddressBook::setStandardResource 1");
1179 d->mManager->setStandardResource( resource ); 1179 d->mManager->setStandardResource( resource );
1180} 1180}
1181 1181
1182Resource *AddressBook::standardResource() 1182Resource *AddressBook::standardResource()
1183{ 1183{
1184 return d->mManager->standardResource(); 1184 return d->mManager->standardResource();
1185} 1185}
1186 1186
1187KRES::Manager<Resource> *AddressBook::resourceManager() 1187KRES::Manager<Resource> *AddressBook::resourceManager()
1188{ 1188{
1189 return d->mManager; 1189 return d->mManager;
1190} 1190}
1191 1191
1192void AddressBook::cleanUp() 1192void AddressBook::cleanUp()
1193{ 1193{
1194 KRES::Manager<Resource>::ActiveIterator it; 1194 KRES::Manager<Resource>::ActiveIterator it;
1195 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 1195 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
1196 if ( !(*it)->readOnly() && (*it)->isOpen() ) 1196 if ( !(*it)->readOnly() && (*it)->isOpen() )
1197 (*it)->cleanUp(); 1197 (*it)->cleanUp();
1198 } 1198 }
1199} 1199}
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index df9048b..a6bf451 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -1,348 +1,348 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
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#ifndef KABC_ADDRESSBOOK_H 28#ifndef KABC_ADDRESSBOOK_H
29#define KABC_ADDRESSBOOK_H 29#define KABC_ADDRESSBOOK_H
30 30
31#include <qobject.h> 31#include <qobject.h>
32 32
33#include <kresources/manager.h> 33#include <kresources/manager.h>
34#include <qptrlist.h> 34#include <qptrlist.h>
35 35
36#include "addressee.h" 36#include "addressee.h"
37#include "field.h" 37#include "field.h"
38 38
39namespace KABC { 39namespace KABC {
40 40
41class ErrorHandler; 41class ErrorHandler;
42class Resource; 42class Resource;
43class Ticket; 43class Ticket;
44 44
45/** 45/**
46 @short Address Book 46 @short Address Book
47 47
48 This class provides access to a collection of address book entries. 48 This class provides access to a collection of address book entries.
49*/ 49*/
50class AddressBook : public QObject 50class AddressBook : public QObject
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
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 void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false );
151 void setUntagged(); 151 void setUntagged();
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 ); }
247 247
248 /** 248 /**
249 Return list of all Fields known to the address book which are associated 249 Return list of all Fields known to the address book which are associated
250 with the given field category. 250 with the given field category.
251 */ 251 */
252 Field::List fields( int category = Field::All ); 252 Field::List fields( int category = Field::All );
253 253
254 /** 254 /**
255 Add custom field to address book. 255 Add custom field to address book.
256 256
257 @param label User visible label of the field. 257 @param label User visible label of the field.
258 @param category Ored list of field categories. 258 @param category Ored list of field categories.
259 @param key Identifier used as key for reading and writing the field. 259 @param key Identifier used as key for reading and writing the field.
260 @param app String used as application key for reading and writing 260 @param app String used as application key for reading and writing
261 the field. 261 the field.
262 */ 262 */
263 bool addCustomField( const QString &label, int category = Field::All, 263 bool addCustomField( const QString &label, int category = Field::All,
264 const QString &key = QString::null, 264 const QString &key = QString::null,
265 const QString &app = QString::null ); 265 const QString &app = QString::null );
266 266
267 267
268 /** 268 /**
269 Add address book resource. 269 Add address book resource.
270 */ 270 */
271 bool addResource( Resource * ); 271 bool addResource( Resource * );
272 272
273 /** 273 /**
274 Remove address book resource. 274 Remove address book resource.
275 */ 275 */
276 bool removeResource( Resource * ); 276 bool removeResource( Resource * );
277 277
278 /** 278 /**
279 Return pointer list of all resources. 279 Return pointer list of all resources.
280 */ 280 */
281 QPtrList<Resource> resources(); 281 QPtrList<Resource> resources();
282 282
283 /** 283 /**
284 Set the @p ErrorHandler, that is used by @ref error() to 284 Set the @p ErrorHandler, that is used by @ref error() to
285 provide gui-independend error messages. 285 provide gui-independend error messages.
286 */ 286 */
287 void setErrorHandler( ErrorHandler * ); 287 void setErrorHandler( ErrorHandler * );
288 288
289 /** 289 /**
290 Shows gui independend error messages. 290 Shows gui independend error messages.
291 */ 291 */
292 void error( const QString& ); 292 void error( const QString& );
293 293
294 /** 294 /**
295 Query all resources to clean up their lock files 295 Query all resources to clean up their lock files
296 */ 296 */
297 void cleanUp(); 297 void cleanUp();
298 298
299 // sync stuff 299 // sync stuff
300 //Addressee::List getExternLastSyncAddressees(); 300 //Addressee::List getExternLastSyncAddressees();
301 void resetTempSyncStat(); 301 void resetTempSyncStat();
302 QStringList uidList(); 302 QStringList uidList();
303 void removeSyncAddressees( bool removeDeleted = false ); 303 void removeSyncAddressees( bool removeDeleted = false );
304 void mergeAB( AddressBook *aBook, const QString& profile ); 304 void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset );
305 Addressee findByExternUid( const QString& uid , const QString& profile ); 305 Addressee findByExternUid( const QString& uid , const QString& profile );
306 bool containsExternalUid( const QString& uid ); 306 bool containsExternalUid( const QString& uid );
307 307
308 void preExternSync( AddressBook* aBook, const QString& csd ); 308 void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset );
309 void postExternSync( AddressBook* aBook, const QString& csd ); 309 void postExternSync( AddressBook* aBook, const QString& csd );
310 signals: 310 signals:
311 /** 311 /**
312 Emitted, when the address book has changed on disk. 312 Emitted, when the address book has changed on disk.
313 */ 313 */
314 void addressBookChanged( AddressBook * ); 314 void addressBookChanged( AddressBook * );
315 315
316 /** 316 /**
317 Emitted, when the address book has been locked for writing. 317 Emitted, when the address book has been locked for writing.
318 */ 318 */
319 void addressBookLocked( AddressBook * ); 319 void addressBookLocked( AddressBook * );
320 320
321 /** 321 /**
322 Emitted, when the address book has been unlocked. 322 Emitted, when the address book has been unlocked.
323 */ 323 */
324 void addressBookUnlocked( AddressBook * ); 324 void addressBookUnlocked( AddressBook * );
325 325
326 protected: 326 protected:
327 void deleteRemovedAddressees(); 327 void deleteRemovedAddressees();
328 void setStandardResource( Resource * ); 328 void setStandardResource( Resource * );
329 Resource *standardResource(); 329 Resource *standardResource();
330 KRES::Manager<Resource> *resourceManager(); 330 KRES::Manager<Resource> *resourceManager();
331 331
332 void init(const QString &config, const QString &family); 332 void init(const QString &config, const QString &family);
333 333
334 private: 334 private:
335//US QPtrList<Resource> mDummy; // Remove in KDE 4 335//US QPtrList<Resource> mDummy; // Remove in KDE 4
336 336
337 337
338 struct AddressBookData; 338 struct AddressBookData;
339 AddressBookData *d; 339 AddressBookData *d;
340 bool blockLSEchange; 340 bool blockLSEchange;
341}; 341};
342 342
343QDataStream &operator<<( QDataStream &, const AddressBook & ); 343QDataStream &operator<<( QDataStream &, const AddressBook & );
344QDataStream &operator>>( QDataStream &, AddressBook & ); 344QDataStream &operator>>( QDataStream &, AddressBook & );
345 345
346} 346}
347 347
348#endif 348#endif
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 2aca559..295ee4f 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,1250 +1,1284 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.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/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$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 bool tagged :1;
92}; 92};
93 93
94Addressee::Addressee() 94Addressee::Addressee()
95{ 95{
96 mData = new AddresseeData; 96 mData = new AddresseeData;
97 mData->empty = true; 97 mData->empty = true;
98 mData->changed = false; 98 mData->changed = false;
99 mData->resource = 0; 99 mData->resource = 0;
100 mData->mExternalId = ":"; 100 mData->mExternalId = ":";
101 mData->revision = QDateTime ( QDate( 2003,1,1)); 101 mData->revision = QDateTime ( QDate( 2003,1,1));
102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
103} 103}
104 104
105Addressee::~Addressee() 105Addressee::~Addressee()
106{ 106{
107} 107}
108 108
109Addressee::Addressee( const Addressee &a ) 109Addressee::Addressee( const Addressee &a )
110{ 110{
111 mData = a.mData; 111 mData = a.mData;
112} 112}
113 113
114Addressee &Addressee::operator=( const Addressee &a ) 114Addressee &Addressee::operator=( const Addressee &a )
115{ 115{
116 mData = a.mData; 116 mData = a.mData;
117 return (*this); 117 return (*this);
118} 118}
119 119
120Addressee Addressee::copy() 120Addressee Addressee::copy()
121{ 121{
122 Addressee a; 122 Addressee a;
123 *(a.mData) = *mData; 123 *(a.mData) = *mData;
124 return a; 124 return a;
125} 125}
126 126
127void Addressee::detach() 127void Addressee::detach()
128{ 128{
129 if ( mData.count() == 1 ) return; 129 if ( mData.count() == 1 ) return;
130 *this = copy(); 130 *this = copy();
131} 131}
132 132
133bool Addressee::operator==( const Addressee &a ) const 133bool Addressee::operator==( const Addressee &a ) const
134{ 134{
135 if ( uid() != a.uid() ) return false; 135 if ( uid() != a.uid() ) return false;
136 if ( mData->name != a.mData->name ) return false; 136 if ( mData->name != a.mData->name ) return false;
137 if ( mData->formattedName != a.mData->formattedName ) return false; 137 if ( mData->formattedName != a.mData->formattedName ) return false;
138 if ( mData->familyName != a.mData->familyName ) return false; 138 if ( mData->familyName != a.mData->familyName ) return false;
139 if ( mData->givenName != a.mData->givenName ) return false; 139 if ( mData->givenName != a.mData->givenName ) return false;
140 if ( mData->additionalName != a.mData->additionalName ) return false; 140 if ( mData->additionalName != a.mData->additionalName ) return false;
141 if ( mData->prefix != a.mData->prefix ) return false; 141 if ( mData->prefix != a.mData->prefix ) return false;
142 if ( mData->suffix != a.mData->suffix ) return false; 142 if ( mData->suffix != a.mData->suffix ) return false;
143 if ( mData->nickName != a.mData->nickName ) return false; 143 if ( mData->nickName != a.mData->nickName ) return false;
144 if ( mData->birthday != a.mData->birthday ) return false; 144 if ( mData->birthday != a.mData->birthday ) return false;
145 if ( mData->mailer != a.mData->mailer ) return false; 145 if ( mData->mailer != a.mData->mailer ) return false;
146 if ( mData->timeZone != a.mData->timeZone ) return false; 146 if ( mData->timeZone != a.mData->timeZone ) return false;
147 if ( mData->geo != a.mData->geo ) return false; 147 if ( mData->geo != a.mData->geo ) return false;
148 if ( mData->title != a.mData->title ) return false; 148 if ( mData->title != a.mData->title ) return false;
149 if ( mData->role != a.mData->role ) return false; 149 if ( mData->role != a.mData->role ) return false;
150 if ( mData->organization != a.mData->organization ) return false; 150 if ( mData->organization != a.mData->organization ) return false;
151 if ( mData->note != a.mData->note ) return false; 151 if ( mData->note != a.mData->note ) return false;
152 if ( mData->productId != a.mData->productId ) return false; 152 if ( mData->productId != a.mData->productId ) return false;
153 //if ( mData->revision != a.mData->revision ) return false; 153 //if ( mData->revision != a.mData->revision ) return false;
154 if ( mData->sortString != a.mData->sortString ) return false; 154 if ( mData->sortString != a.mData->sortString ) return false;
155 if ( mData->secrecy != a.mData->secrecy ) return false; 155 if ( mData->secrecy != a.mData->secrecy ) return false;
156 if ( mData->logo != a.mData->logo ) return false; 156 if ( mData->logo != a.mData->logo ) return false;
157 if ( mData->photo != a.mData->photo ) return false; 157 if ( mData->photo != a.mData->photo ) return false;
158 if ( mData->sound != a.mData->sound ) return false; 158 if ( mData->sound != a.mData->sound ) return false;
159 if ( mData->agent != a.mData->agent ) return false; 159 if ( mData->agent != a.mData->agent ) return false;
160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
161 ( mData->url != a.mData->url ) ) return false; 161 ( mData->url != a.mData->url ) ) return false;
162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
163 if ( mData->addresses != a.mData->addresses ) return false; 163 if ( mData->addresses != a.mData->addresses ) return false;
164 if ( mData->keys != a.mData->keys ) return false; 164 if ( mData->keys != a.mData->keys ) return false;
165 if ( mData->emails != a.mData->emails ) return false; 165 if ( mData->emails != a.mData->emails ) return false;
166 if ( mData->categories != a.mData->categories ) return false; 166 if ( mData->categories != a.mData->categories ) return false;
167 if ( mData->custom != a.mData->custom ) return false; 167 if ( mData->custom != a.mData->custom ) return false;
168 168
169 return true; 169 return true;
170} 170}
171 171
172bool Addressee::operator!=( const Addressee &a ) const 172bool Addressee::operator!=( const Addressee &a ) const
173{ 173{
174 return !( a == *this ); 174 return !( a == *this );
175} 175}
176 176
177bool Addressee::isEmpty() const 177bool Addressee::isEmpty() const
178{ 178{
179 return mData->empty; 179 return mData->empty;
180} 180}
181ulong Addressee::getCsum4List( const QStringList & attList) 181ulong Addressee::getCsum4List( const QStringList & attList)
182{ 182{
183 int max = attList.count(); 183 int max = attList.count();
184 ulong cSum = 0; 184 ulong cSum = 0;
185 int j,k,i; 185 int j,k,i;
186 int add; 186 int add;
187 for ( i = 0; i < max ; ++i ) { 187 for ( i = 0; i < max ; ++i ) {
188 QString s = attList[i]; 188 QString s = attList[i];
189 if ( ! s.isEmpty() ){ 189 if ( ! s.isEmpty() ){
190 j = s.length(); 190 j = s.length();
191 for ( k = 0; k < j; ++k ) { 191 for ( k = 0; k < j; ++k ) {
192 int mul = k +1; 192 int mul = k +1;
193 add = s[k].unicode (); 193 add = s[k].unicode ();
194 if ( k < 16 ) 194 if ( k < 16 )
195 mul = mul * mul; 195 mul = mul * mul;
196 int ii = i+1; 196 int ii = i+1;
197 add = add * mul *ii*ii*ii; 197 add = add * mul *ii*ii*ii;
198 cSum += add; 198 cSum += add;
199 } 199 }
200 } 200 }
201 201
202 } 202 }
203 //QString dump = attList.join(","); 203 //QString dump = attList.join(",");
204 //qDebug("csum: %d %s", cSum,dump.latin1()); 204 //qDebug("csum: %d %s", cSum,dump.latin1());
205 205
206 return cSum; 206 return cSum;
207 207
208} 208}
209void Addressee::computeCsum(const QString &dev) 209void Addressee::computeCsum(const QString &dev)
210{ 210{
211 QStringList l; 211 QStringList l;
212 if ( !mData->name.isEmpty() ) l.append(mData->name); 212 if ( !mData->name.isEmpty() ) l.append(mData->name);
213 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 213 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
216 if ( !mData->additionalName ) l.append( mData->additionalName ); 216 if ( !mData->additionalName ) l.append( mData->additionalName );
217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
224 if ( !mData->title .isEmpty() ) l.append( mData->title ); 224 if ( !mData->title .isEmpty() ) l.append( mData->title );
225 if ( !mData->role.isEmpty() ) l.append( mData->role ); 225 if ( !mData->role.isEmpty() ) l.append( mData->role );
226 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 226 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
227 if ( !mData->note.isEmpty() ) l.append( mData->note ); 227 if ( !mData->note.isEmpty() ) l.append( mData->note );
228 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 228 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
231 // if ( !mData->logo.isEmpty() ) l.append( ); 231 // if ( !mData->logo.isEmpty() ) l.append( );
232 //if ( !mData->photo.isEmpty() ) l.append( ); 232 //if ( !mData->photo.isEmpty() ) l.append( );
233 //if ( !mData->sound.isEmpty() ) l.append( ); 233 //if ( !mData->sound.isEmpty() ) l.append( );
234 //if ( !mData->agent.isEmpty() ) l.append( ); 234 //if ( !mData->agent.isEmpty() ) l.append( );
235 if ( mData->url.isValid() ) 235 if ( mData->url.isValid() )
236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); 236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
237 KABC::PhoneNumber::List phoneNumbers; 237 KABC::PhoneNumber::List phoneNumbers;
238 KABC::PhoneNumber::List::Iterator phoneIter; 238 KABC::PhoneNumber::List::Iterator phoneIter;
239 239
240 QStringList t; 240 QStringList t;
241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
242 ++phoneIter ) 242 ++phoneIter )
243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
244 t.sort(); 244 t.sort();
245 uint iii; 245 uint iii;
246 for ( iii = 0; iii < t.count(); ++iii) 246 for ( iii = 0; iii < t.count(); ++iii)
247 l.append( t[iii] ); 247 l.append( t[iii] );
248 t = mData->emails; 248 t = mData->emails;
249 t.sort(); 249 t.sort();
250 for ( iii = 0; iii < t.count(); ++iii) 250 for ( iii = 0; iii < t.count(); ++iii)
251 l.append( t[iii] ); 251 l.append( t[iii] );
252 t = mData->categories; 252 t = mData->categories;
253 t.sort(); 253 t.sort();
254 for ( iii = 0; iii < t.count(); ++iii) 254 for ( iii = 0; iii < t.count(); ++iii)
255 l.append( t[iii] ); 255 l.append( t[iii] );
256 t = mData->custom; 256 t = mData->custom;
257 t.sort(); 257 t.sort();
258 for ( iii = 0; iii < t.count(); ++iii) 258 for ( iii = 0; iii < t.count(); ++iii)
259 l.append( t[iii] ); 259 l.append( t[iii] );
260 KABC::Address::List::Iterator addressIter; 260 KABC::Address::List::Iterator addressIter;
261 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 261 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
262 ++addressIter ) { 262 ++addressIter ) {
263 t = (*addressIter).asList(); 263 t = (*addressIter).asList();
264 t.sort(); 264 t.sort();
265 for ( iii = 0; iii < t.count(); ++iii) 265 for ( iii = 0; iii < t.count(); ++iii)
266 l.append( t[iii] ); 266 l.append( t[iii] );
267 } 267 }
268 uint cs = getCsum4List(l); 268 uint cs = getCsum4List(l);
269 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 269 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
270 setCsum( dev, QString::number (cs )); 270 setCsum( dev, QString::number (cs ));
271} 271}
272 272
273void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 273void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
274{ 274{
275 275
276 detach(); 276 detach();
277 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 277 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
278 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 278 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
279 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 279 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
280 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 280 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
281 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 281 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
282 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 282 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
283 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 283 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
284 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 284 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
285 if ( !mData->birthday.isValid() ) 285 if ( !mData->birthday.isValid() )
286 if ( ad.mData->birthday.isValid()) 286 if ( ad.mData->birthday.isValid())
287 mData->birthday = ad.mData->birthday; 287 mData->birthday = ad.mData->birthday;
288 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 288 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
289 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 289 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
290 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 290 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
291 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 291 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
292 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 292 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
293 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 293 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
294 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 294 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
295 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 295 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
296 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 296 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
297 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 297 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
298 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 298 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
299 QStringList t; 299 QStringList t;
300 QStringList tAD; 300 QStringList tAD;
301 uint iii; 301 uint iii;
302 if ( isSubSet ) { 302
303 // ********** phone numbers 303 // ********** phone numbers
304 PhoneNumber::List phoneAD = ad.phoneNumbers(); 304 PhoneNumber::List phoneAD = ad.phoneNumbers();
305 PhoneNumber::List::Iterator phoneItAD; 305 PhoneNumber::List::Iterator phoneItAD;
306 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 306 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
307 bool found = false; 307 bool found = false;
308 PhoneNumber::List::Iterator it; 308 PhoneNumber::List::Iterator it;
309 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 309 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
310 if ( ( *phoneItAD ).contains( (*it) ) ) { 310 if ( ( *phoneItAD ).contains( (*it) ) ) {
311 found = true; 311 found = true;
312 (*it).setType( ( *phoneItAD ).type() ); 312 (*it).setType( ( *phoneItAD ).type() );
313 break; 313 break;
314 }
315 } 314 }
316 if ( ! found )
317 mData->phoneNumbers.append( *phoneItAD );
318 } 315 }
316 if ( isSubSet && ! found )
317 mData->phoneNumbers.append( *phoneItAD );
318 }
319 if ( isSubSet ) {
319 // ************* emails; 320 // ************* emails;
320 t = mData->emails; 321 t = mData->emails;
321 tAD = ad.mData->emails; 322 tAD = ad.mData->emails;
322 for ( iii = 0; iii < tAD.count(); ++iii) 323 for ( iii = 0; iii < tAD.count(); ++iii)
323 if ( !t.contains(tAD[iii] ) ) 324 if ( !t.contains(tAD[iii] ) )
324 mData->emails.append( tAD[iii] ); 325 mData->emails.append( tAD[iii] );
325 // ************* categories;
326 t = mData->categories;
327 tAD = ad.mData->categories;
328 for ( iii = 0; iii < tAD.count(); ++iii)
329 if ( !t.contains(tAD[iii] ) )
330 mData->categories.append( tAD[iii] );
331
332
333 } 326 }
334 327
328 // ************* categories;
329 t = mData->categories;
330 tAD = ad.mData->categories;
331 for ( iii = 0; iii < tAD.count(); ++iii)
332 if ( !t.contains(tAD[iii] ) )
333 mData->categories.append( tAD[iii] );
335 QStringList::ConstIterator it; 334 QStringList::ConstIterator it;
336 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 335 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
337 QString qualifiedName = (*it).left( (*it).find( ":" )); 336 QString qualifiedName = (*it).left( (*it).find( ":" ));
338 bool found = false; 337 bool found = false;
339 QStringList::ConstIterator itL; 338 QStringList::ConstIterator itL;
340 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 339 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
341 if ( (*itL).startsWith( qualifiedName ) ) { 340 if ( (*itL).startsWith( qualifiedName ) ) {
342 found = true; 341 found = true;
343 break; 342 break;
344 } 343 }
345 } 344 }
346 if ( ! found ) { 345 if ( ! found ) {
347 mData->custom.append( *it ); 346 mData->custom.append( *it );
348 } 347 }
349 } 348 }
350 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 349 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
351 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 350 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
352 if ( !mData->sound.isIntern() ) { 351 if ( !mData->sound.isIntern() ) {
353 if ( mData->sound.url().isEmpty() ) { 352 if ( mData->sound.url().isEmpty() ) {
354 mData->sound = ad.mData->sound; 353 mData->sound = ad.mData->sound;
355 } 354 }
356 } 355 }
357 if ( !mData->agent.isIntern() ) { 356 if ( !mData->agent.isIntern() ) {
358 if ( mData->agent.url().isEmpty() ) { 357 if ( mData->agent.url().isEmpty() ) {
359 mData->agent = ad.mData->agent; 358 mData->agent = ad.mData->agent;
360 } 359 }
361 } 360 }
362 { 361 {
363 Key::List::Iterator itA; 362 Key::List::Iterator itA;
364 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 363 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
365 bool found = false; 364 bool found = false;
366 Key::List::Iterator it; 365 Key::List::Iterator it;
367 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 366 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
368 if ( (*it) == (*itA)) { 367 if ( (*it) == (*itA)) {
369 found = true; 368 found = true;
370 break; 369 break;
371 370
372 } 371 }
373 } 372 }
374 if ( ! found ) { 373 if ( ! found ) {
375 mData->keys.append( *itA ); 374 mData->keys.append( *itA );
376 } 375 }
377 } 376 }
378 } 377 }
379 KABC::Address::List::Iterator addressIterA; 378 KABC::Address::List::Iterator addressIterA;
380 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 379 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
381 bool found = false; 380 bool found = false;
382 KABC::Address::List::Iterator addressIter; 381 KABC::Address::List::Iterator addressIter;
383 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 382 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
384 ++addressIter ) { 383 ++addressIter ) {
385 if ( (*addressIter) == (*addressIterA)) { 384 if ( (*addressIter) == (*addressIterA)) {
386 found = true; 385 found = true;
387 (*addressIter).setType( (*addressIterA).type() ); 386 (*addressIter).setType( (*addressIterA).type() );
388 break; 387 break;
389 } 388 }
390 389
391 } 390 }
392 if ( ! found ) { 391 if ( isSubSet && ! found ) {
393 mData->addresses.append( *addressIterA ); 392 mData->addresses.append( *addressIterA );
394 } 393 }
395 } 394 }
396 //qDebug("merge contact %s ", ad.uid().latin1()); 395 //qDebug("merge contact %s ", ad.uid().latin1());
397 setUid( ad.uid() ); 396 setUid( ad.uid() );
398 setRevision( ad.revision() ); 397 setRevision( ad.revision() );
399} 398}
400 399
401bool Addressee::removeVoice() 400bool Addressee::removeVoice()
402{ 401{
403 PhoneNumber::List phoneN = phoneNumbers(); 402 PhoneNumber::List phoneN = phoneNumbers();
404 PhoneNumber::List::Iterator phoneIt; 403 PhoneNumber::List::Iterator phoneIt;
405 bool found = false; 404 bool found = false;
406 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 405 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
407 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 406 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
408 if ((*phoneIt).type() - PhoneNumber::Voice ) { 407 if ((*phoneIt).type() - PhoneNumber::Voice ) {
409 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 408 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
410 insertPhoneNumber( (*phoneIt) ); 409 insertPhoneNumber( (*phoneIt) );
411 found = true; 410 found = true;
412 } 411 }
413 } 412 }
414 413
415 } 414 }
416 return found; 415 return found;
417} 416}
418 417
419bool Addressee::containsAdr(const Addressee& ad ) 418bool Addressee::containsAdr(const Addressee& ad )
420{ 419{
421 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 420 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
422 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 421 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
423 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 422 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
424 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 423 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
425 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 424 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
426 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 425 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
427 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 426 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
428 427
429 // compare phone numbers 428 // compare phone numbers
430 PhoneNumber::List phoneN = ad.phoneNumbers(); 429 PhoneNumber::List phoneN = ad.phoneNumbers();
431 PhoneNumber::List::Iterator phoneIt; 430 PhoneNumber::List::Iterator phoneIt;
432 bool found = false; 431 bool found = false;
433 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 432 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
434 bool found = false; 433 bool found = false;
435 PhoneNumber::List phoneL = ad.phoneNumbers(); 434 PhoneNumber::List phoneL = ad.phoneNumbers();
436 PhoneNumber::List::Iterator phoneItL; 435 PhoneNumber::List::Iterator phoneItL;
437 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 436 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
438 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 437 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
439 found = true; 438 found = true;
440 break; 439 break;
441 } 440 }
442 } 441 }
443 if ( ! found ) 442 if ( ! found )
444 return false; 443 return false;
445 } 444 }
446 return true; 445 return true;
447 446
448} 447}
449void Addressee::simplifyAddresses() 448void Addressee::simplifyAddresses()
450{ 449{
451 int max = 2; 450 int max = 2;
452 if ( mData->url.isValid() ) 451 if ( mData->url.isValid() )
453 max = 1; 452 max = 1;
454 if ( mData->addresses.count() <= max ) return ; 453 if ( mData->addresses.count() <= max ) return ;
455 int count = 0; 454 int count = 0;
456 Address::List list; 455 Address::List list;
457 Address::List::Iterator it; 456 Address::List::Iterator it;
458 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 457 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
459 if ( count >= max ) 458 if ( count >= max )
460 list.append( *it ); 459 list.append( *it );
461 ++count; 460 ++count;
462 } 461 }
463 for( it = list.begin(); it != list.end(); ++it ) { 462 for( it = list.begin(); it != list.end(); ++it ) {
464 removeAddress( (*it) ); 463 removeAddress( (*it) );
465 } 464 }
466} 465}
467 466
468// removes all emails but the first 467// removes all emails but the first
469// needed by phone sync 468// needed by phone sync
470void Addressee::simplifyEmails() 469void Addressee::simplifyEmails()
471{ 470{
472 if ( mData->emails.count() == 0 ) return ; 471 if ( mData->emails.count() == 0 ) return ;
473 QString email = mData->emails.first(); 472 QString email = mData->emails.first();
474 detach(); 473 detach();
475 mData->emails.clear(); 474 mData->emails.clear();
476 mData->emails.append( email ); 475 mData->emails.append( email );
477} 476}
478 477
479void Addressee::simplifyPhoneNumbers() 478void Addressee::simplifyPhoneNumbers()
480{ 479{
480 int max = 4;
481 int inList = mData->phoneNumbers.count();
481 KABC::PhoneNumber::List removeNumbers; 482 KABC::PhoneNumber::List removeNumbers;
482 KABC::PhoneNumber::List::Iterator phoneIter; 483 KABC::PhoneNumber::List::Iterator phoneIter;
484 if ( inList > max ) {
485 // delete non-preferred numbers
486 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
487 ++phoneIter ) {
488 if ( inList > max ) {
489 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) {
490 removeNumbers.append( ( *phoneIter ) );
491 --inList;
492 }
493 } else
494 break;
495 }
496 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
497 ++phoneIter ) {
498 removePhoneNumber(( *phoneIter ));
499 }
500 // delete preferred numbers
501 if ( inList > max ) {
502 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
503 ++phoneIter ) {
504 if ( inList > max ) {
505 removeNumbers.append( ( *phoneIter ) );
506 --inList;
507 } else
508 break;
509 }
510 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
511 ++phoneIter ) {
512 removePhoneNumber(( *phoneIter ));
513 }
514 }
515 }
516 // remove non-numeric characters
483 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 517 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
484 ++phoneIter ) { 518 ++phoneIter ) {
485 if ( ! ( *phoneIter ).simplifyNumber() ) 519 if ( ! ( *phoneIter ).simplifyNumber() )
486 removeNumbers.append( ( *phoneIter ) ); 520 removeNumbers.append( ( *phoneIter ) );
487 } 521 }
488 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 522 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
489 ++phoneIter ) { 523 ++phoneIter ) {
490 removePhoneNumber(( *phoneIter )); 524 removePhoneNumber(( *phoneIter ));
491 } 525 }
492} 526}
493void Addressee::simplifyPhoneNumberTypes() 527void Addressee::simplifyPhoneNumberTypes()
494{ 528{
495 KABC::PhoneNumber::List::Iterator phoneIter; 529 KABC::PhoneNumber::List::Iterator phoneIter;
496 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 530 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
497 ++phoneIter ) 531 ++phoneIter )
498 ( *phoneIter ).simplifyType(); 532 ( *phoneIter ).simplifyType();
499} 533}
500void Addressee::removeID(const QString &prof) 534void Addressee::removeID(const QString &prof)
501{ 535{
502 detach(); 536 detach();
503 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 537 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
504 538
505} 539}
506void Addressee::setID( const QString & prof , const QString & id ) 540void Addressee::setID( const QString & prof , const QString & id )
507{ 541{
508 detach(); 542 detach();
509 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 543 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
510 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 544 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
511} 545}
512void Addressee::setTempSyncStat( int id ) 546void Addressee::setTempSyncStat( int id )
513{ 547{
514 if ( mData->mTempSyncStat == id ) return; 548 if ( mData->mTempSyncStat == id ) return;
515 detach(); 549 detach();
516 mData->mTempSyncStat = id; 550 mData->mTempSyncStat = id;
517} 551}
518int Addressee::tempSyncStat() const 552int Addressee::tempSyncStat() const
519{ 553{
520 return mData->mTempSyncStat; 554 return mData->mTempSyncStat;
521} 555}
522 556
523QString Addressee::getID( const QString & prof) 557QString Addressee::getID( const QString & prof)
524{ 558{
525 return KIdManager::getId ( mData->mExternalId, prof ); 559 return KIdManager::getId ( mData->mExternalId, prof );
526} 560}
527 561
528void Addressee::setCsum( const QString & prof , const QString & id ) 562void Addressee::setCsum( const QString & prof , const QString & id )
529{ 563{
530 detach(); 564 detach();
531 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 565 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
532 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 566 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
533 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 567 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
534} 568}
535 569
536QString Addressee::getCsum( const QString & prof) 570QString Addressee::getCsum( const QString & prof)
537{ 571{
538 return KIdManager::getCsum ( mData->mExternalId, prof ); 572 return KIdManager::getCsum ( mData->mExternalId, prof );
539} 573}
540 574
541void Addressee::setIDStr( const QString & s ) 575void Addressee::setIDStr( const QString & s )
542{ 576{
543 detach(); 577 detach();
544 mData->mExternalId = s; 578 mData->mExternalId = s;
545} 579}
546 580
547QString Addressee::IDStr() const 581QString Addressee::IDStr() const
548{ 582{
549 return mData->mExternalId; 583 return mData->mExternalId;
550} 584}
551 585
552void Addressee::setExternalUID( const QString &id ) 586void Addressee::setExternalUID( const QString &id )
553{ 587{
554 if ( id == mData->externalUID ) return; 588 if ( id == mData->externalUID ) return;
555 detach(); 589 detach();
556 mData->empty = false; 590 mData->empty = false;
557 mData->externalUID = id; 591 mData->externalUID = id;
558} 592}
559 593
560QString Addressee::externalUID() const 594QString Addressee::externalUID() const
561{ 595{
562 return mData->externalUID; 596 return mData->externalUID;
563} 597}
564void Addressee::setOriginalExternalUID( const QString &id ) 598void Addressee::setOriginalExternalUID( const QString &id )
565{ 599{
566 if ( id == mData->originalExternalUID ) return; 600 if ( id == mData->originalExternalUID ) return;
567 detach(); 601 detach();
568 mData->empty = false; 602 mData->empty = false;
569 //qDebug("*******Set orig uid %s ", id.latin1()); 603 //qDebug("*******Set orig uid %s ", id.latin1());
570 mData->originalExternalUID = id; 604 mData->originalExternalUID = id;
571} 605}
572 606
573QString Addressee::originalExternalUID() const 607QString Addressee::originalExternalUID() const
574{ 608{
575 return mData->originalExternalUID; 609 return mData->originalExternalUID;
576} 610}
577 611
578void Addressee::setUid( const QString &id ) 612void Addressee::setUid( const QString &id )
579{ 613{
580 if ( id == mData->uid ) return; 614 if ( id == mData->uid ) return;
581 detach(); 615 detach();
582 //qDebug("****setuid %s ", id.latin1()); 616 //qDebug("****setuid %s ", id.latin1());
583 mData->empty = false; 617 mData->empty = false;
584 mData->uid = id; 618 mData->uid = id;
585} 619}
586 620
587QString Addressee::uid() const 621QString Addressee::uid() const
588{ 622{
589 if ( mData->uid.isEmpty() ) 623 if ( mData->uid.isEmpty() )
590 mData->uid = KApplication::randomString( 10 ); 624 mData->uid = KApplication::randomString( 10 );
591 625
592 return mData->uid; 626 return mData->uid;
593} 627}
594 628
595QString Addressee::uidLabel() 629QString Addressee::uidLabel()
596{ 630{
597 return i18n("Unique Identifier"); 631 return i18n("Unique Identifier");
598} 632}
599 633
600void Addressee::setName( const QString &name ) 634void Addressee::setName( const QString &name )
601{ 635{
602 if ( name == mData->name ) return; 636 if ( name == mData->name ) return;
603 detach(); 637 detach();
604 mData->empty = false; 638 mData->empty = false;
605 mData->name = name; 639 mData->name = name;
606} 640}
607 641
608QString Addressee::name() const 642QString Addressee::name() const
609{ 643{
610 return mData->name; 644 return mData->name;
611} 645}
612 646
613QString Addressee::nameLabel() 647QString Addressee::nameLabel()
614{ 648{
615 return i18n("Name"); 649 return i18n("Name");
616} 650}
617 651
618 652
619void Addressee::setFormattedName( const QString &formattedName ) 653void Addressee::setFormattedName( const QString &formattedName )
620{ 654{
621 if ( formattedName == mData->formattedName ) return; 655 if ( formattedName == mData->formattedName ) return;
622 detach(); 656 detach();
623 mData->empty = false; 657 mData->empty = false;
624 mData->formattedName = formattedName; 658 mData->formattedName = formattedName;
625} 659}
626 660
627QString Addressee::formattedName() const 661QString Addressee::formattedName() const
628{ 662{
629 return mData->formattedName; 663 return mData->formattedName;
630} 664}
631 665
632QString Addressee::formattedNameLabel() 666QString Addressee::formattedNameLabel()
633{ 667{
634 return i18n("Formatted Name"); 668 return i18n("Formatted Name");
635} 669}
636 670
637 671
638void Addressee::setFamilyName( const QString &familyName ) 672void Addressee::setFamilyName( const QString &familyName )
639{ 673{
640 if ( familyName == mData->familyName ) return; 674 if ( familyName == mData->familyName ) return;
641 detach(); 675 detach();
642 mData->empty = false; 676 mData->empty = false;
643 mData->familyName = familyName; 677 mData->familyName = familyName;
644} 678}
645 679
646QString Addressee::familyName() const 680QString Addressee::familyName() const
647{ 681{
648 return mData->familyName; 682 return mData->familyName;
649} 683}
650 684
651QString Addressee::familyNameLabel() 685QString Addressee::familyNameLabel()
652{ 686{
653 return i18n("Family Name"); 687 return i18n("Family Name");
654} 688}
655 689
656 690
657void Addressee::setGivenName( const QString &givenName ) 691void Addressee::setGivenName( const QString &givenName )
658{ 692{
659 if ( givenName == mData->givenName ) return; 693 if ( givenName == mData->givenName ) return;
660 detach(); 694 detach();
661 mData->empty = false; 695 mData->empty = false;
662 mData->givenName = givenName; 696 mData->givenName = givenName;
663} 697}
664 698
665QString Addressee::givenName() const 699QString Addressee::givenName() const
666{ 700{
667 return mData->givenName; 701 return mData->givenName;
668} 702}
669 703
670QString Addressee::givenNameLabel() 704QString Addressee::givenNameLabel()
671{ 705{
672 return i18n("Given Name"); 706 return i18n("Given Name");
673} 707}
674 708
675 709
676void Addressee::setAdditionalName( const QString &additionalName ) 710void Addressee::setAdditionalName( const QString &additionalName )
677{ 711{
678 if ( additionalName == mData->additionalName ) return; 712 if ( additionalName == mData->additionalName ) return;
679 detach(); 713 detach();
680 mData->empty = false; 714 mData->empty = false;
681 mData->additionalName = additionalName; 715 mData->additionalName = additionalName;
682} 716}
683 717
684QString Addressee::additionalName() const 718QString Addressee::additionalName() const
685{ 719{
686 return mData->additionalName; 720 return mData->additionalName;
687} 721}
688 722
689QString Addressee::additionalNameLabel() 723QString Addressee::additionalNameLabel()
690{ 724{
691 return i18n("Additional Names"); 725 return i18n("Additional Names");
692} 726}
693 727
694 728
695void Addressee::setPrefix( const QString &prefix ) 729void Addressee::setPrefix( const QString &prefix )
696{ 730{
697 if ( prefix == mData->prefix ) return; 731 if ( prefix == mData->prefix ) return;
698 detach(); 732 detach();
699 mData->empty = false; 733 mData->empty = false;
700 mData->prefix = prefix; 734 mData->prefix = prefix;
701} 735}
702 736
703QString Addressee::prefix() const 737QString Addressee::prefix() const
704{ 738{
705 return mData->prefix; 739 return mData->prefix;
706} 740}
707 741
708QString Addressee::prefixLabel() 742QString Addressee::prefixLabel()
709{ 743{
710 return i18n("Honorific Prefixes"); 744 return i18n("Honorific Prefixes");
711} 745}
712 746
713 747
714void Addressee::setSuffix( const QString &suffix ) 748void Addressee::setSuffix( const QString &suffix )
715{ 749{
716 if ( suffix == mData->suffix ) return; 750 if ( suffix == mData->suffix ) return;
717 detach(); 751 detach();
718 mData->empty = false; 752 mData->empty = false;
719 mData->suffix = suffix; 753 mData->suffix = suffix;
720} 754}
721 755
722QString Addressee::suffix() const 756QString Addressee::suffix() const
723{ 757{
724 return mData->suffix; 758 return mData->suffix;
725} 759}
726 760
727QString Addressee::suffixLabel() 761QString Addressee::suffixLabel()
728{ 762{
729 return i18n("Honorific Suffixes"); 763 return i18n("Honorific Suffixes");
730} 764}
731 765
732 766
733void Addressee::setNickName( const QString &nickName ) 767void Addressee::setNickName( const QString &nickName )
734{ 768{
735 if ( nickName == mData->nickName ) return; 769 if ( nickName == mData->nickName ) return;
736 detach(); 770 detach();
737 mData->empty = false; 771 mData->empty = false;
738 mData->nickName = nickName; 772 mData->nickName = nickName;
739} 773}
740 774
741QString Addressee::nickName() const 775QString Addressee::nickName() const
742{ 776{
743 return mData->nickName; 777 return mData->nickName;
744} 778}
745 779
746QString Addressee::nickNameLabel() 780QString Addressee::nickNameLabel()
747{ 781{
748 return i18n("Nick Name"); 782 return i18n("Nick Name");
749} 783}
750 784
751 785
752void Addressee::setBirthday( const QDateTime &birthday ) 786void Addressee::setBirthday( const QDateTime &birthday )
753{ 787{
754 if ( birthday == mData->birthday ) return; 788 if ( birthday == mData->birthday ) return;
755 detach(); 789 detach();
756 mData->empty = false; 790 mData->empty = false;
757 mData->birthday = birthday; 791 mData->birthday = birthday;
758} 792}
759 793
760QDateTime Addressee::birthday() const 794QDateTime Addressee::birthday() const
761{ 795{
762 return mData->birthday; 796 return mData->birthday;
763} 797}
764 798
765QString Addressee::birthdayLabel() 799QString Addressee::birthdayLabel()
766{ 800{
767 return i18n("Birthday"); 801 return i18n("Birthday");
768} 802}
769 803
770 804
771QString Addressee::homeAddressStreetLabel() 805QString Addressee::homeAddressStreetLabel()
772{ 806{
773 return i18n("Home Address Street"); 807 return i18n("Home Address Street");
774} 808}
775 809
776 810
777QString Addressee::homeAddressLocalityLabel() 811QString Addressee::homeAddressLocalityLabel()
778{ 812{
779 return i18n("Home Address Locality"); 813 return i18n("Home Address Locality");
780} 814}
781 815
782 816
783QString Addressee::homeAddressRegionLabel() 817QString Addressee::homeAddressRegionLabel()
784{ 818{
785 return i18n("Home Address Region"); 819 return i18n("Home Address Region");
786} 820}
787 821
788 822
789QString Addressee::homeAddressPostalCodeLabel() 823QString Addressee::homeAddressPostalCodeLabel()
790{ 824{
791 return i18n("Home Address Postal Code"); 825 return i18n("Home Address Postal Code");
792} 826}
793 827
794 828
795QString Addressee::homeAddressCountryLabel() 829QString Addressee::homeAddressCountryLabel()
796{ 830{
797 return i18n("Home Address Country"); 831 return i18n("Home Address Country");
798} 832}
799 833
800 834
801QString Addressee::homeAddressLabelLabel() 835QString Addressee::homeAddressLabelLabel()
802{ 836{
803 return i18n("Home Address Label"); 837 return i18n("Home Address Label");
804} 838}
805 839
806 840
807QString Addressee::businessAddressStreetLabel() 841QString Addressee::businessAddressStreetLabel()
808{ 842{
809 return i18n("Business Address Street"); 843 return i18n("Business Address Street");
810} 844}
811 845
812 846
813QString Addressee::businessAddressLocalityLabel() 847QString Addressee::businessAddressLocalityLabel()
814{ 848{
815 return i18n("Business Address Locality"); 849 return i18n("Business Address Locality");
816} 850}
817 851
818 852
819QString Addressee::businessAddressRegionLabel() 853QString Addressee::businessAddressRegionLabel()
820{ 854{
821 return i18n("Business Address Region"); 855 return i18n("Business Address Region");
822} 856}
823 857
824 858
825QString Addressee::businessAddressPostalCodeLabel() 859QString Addressee::businessAddressPostalCodeLabel()
826{ 860{
827 return i18n("Business Address Postal Code"); 861 return i18n("Business Address Postal Code");
828} 862}
829 863
830 864
831QString Addressee::businessAddressCountryLabel() 865QString Addressee::businessAddressCountryLabel()
832{ 866{
833 return i18n("Business Address Country"); 867 return i18n("Business Address Country");
834} 868}
835 869
836 870
837QString Addressee::businessAddressLabelLabel() 871QString Addressee::businessAddressLabelLabel()
838{ 872{
839 return i18n("Business Address Label"); 873 return i18n("Business Address Label");
840} 874}
841 875
842 876
843QString Addressee::homePhoneLabel() 877QString Addressee::homePhoneLabel()
844{ 878{
845 return i18n("Home Phone"); 879 return i18n("Home Phone");
846} 880}
847 881
848 882
849QString Addressee::businessPhoneLabel() 883QString Addressee::businessPhoneLabel()
850{ 884{
851 return i18n("Business Phone"); 885 return i18n("Business Phone");
852} 886}
853 887
854 888
855QString Addressee::mobilePhoneLabel() 889QString Addressee::mobilePhoneLabel()
856{ 890{
857 return i18n("Mobile Phone"); 891 return i18n("Mobile Phone");
858} 892}
859 893
860 894
861QString Addressee::homeFaxLabel() 895QString Addressee::homeFaxLabel()
862{ 896{
863 return i18n("Home Fax"); 897 return i18n("Home Fax");
864} 898}
865 899
866 900
867QString Addressee::businessFaxLabel() 901QString Addressee::businessFaxLabel()
868{ 902{
869 return i18n("Business Fax"); 903 return i18n("Business Fax");
870} 904}
871 905
872 906
873QString Addressee::carPhoneLabel() 907QString Addressee::carPhoneLabel()
874{ 908{
875 return i18n("Car Phone"); 909 return i18n("Car Phone");
876} 910}
877 911
878 912
879QString Addressee::isdnLabel() 913QString Addressee::isdnLabel()
880{ 914{
881 return i18n("ISDN"); 915 return i18n("ISDN");
882} 916}
883 917
884 918
885QString Addressee::pagerLabel() 919QString Addressee::pagerLabel()
886{ 920{
887 return i18n("Pager"); 921 return i18n("Pager");
888} 922}
889 923
890QString Addressee::sipLabel() 924QString Addressee::sipLabel()
891{ 925{
892 return i18n("SIP"); 926 return i18n("SIP");
893} 927}
894 928
895QString Addressee::emailLabel() 929QString Addressee::emailLabel()
896{ 930{
897 return i18n("Email Address"); 931 return i18n("Email Address");
898} 932}
899 933
900 934
901void Addressee::setMailer( const QString &mailer ) 935void Addressee::setMailer( const QString &mailer )
902{ 936{
903 if ( mailer == mData->mailer ) return; 937 if ( mailer == mData->mailer ) return;
904 detach(); 938 detach();
905 mData->empty = false; 939 mData->empty = false;
906 mData->mailer = mailer; 940 mData->mailer = mailer;
907} 941}
908 942
909QString Addressee::mailer() const 943QString Addressee::mailer() const
910{ 944{
911 return mData->mailer; 945 return mData->mailer;
912} 946}
913 947
914QString Addressee::mailerLabel() 948QString Addressee::mailerLabel()
915{ 949{
916 return i18n("Mail Client"); 950 return i18n("Mail Client");
917} 951}
918 952
919 953
920void Addressee::setTimeZone( const TimeZone &timeZone ) 954void Addressee::setTimeZone( const TimeZone &timeZone )
921{ 955{
922 if ( timeZone == mData->timeZone ) return; 956 if ( timeZone == mData->timeZone ) return;
923 detach(); 957 detach();
924 mData->empty = false; 958 mData->empty = false;
925 mData->timeZone = timeZone; 959 mData->timeZone = timeZone;
926} 960}
927 961
928TimeZone Addressee::timeZone() const 962TimeZone Addressee::timeZone() const
929{ 963{
930 return mData->timeZone; 964 return mData->timeZone;
931} 965}
932 966
933QString Addressee::timeZoneLabel() 967QString Addressee::timeZoneLabel()
934{ 968{
935 return i18n("Time Zone"); 969 return i18n("Time Zone");
936} 970}
937 971
938 972
939void Addressee::setGeo( const Geo &geo ) 973void Addressee::setGeo( const Geo &geo )
940{ 974{
941 if ( geo == mData->geo ) return; 975 if ( geo == mData->geo ) return;
942 detach(); 976 detach();
943 mData->empty = false; 977 mData->empty = false;
944 mData->geo = geo; 978 mData->geo = geo;
945} 979}
946 980
947Geo Addressee::geo() const 981Geo Addressee::geo() const
948{ 982{
949 return mData->geo; 983 return mData->geo;
950} 984}
951 985
952QString Addressee::geoLabel() 986QString Addressee::geoLabel()
953{ 987{
954 return i18n("Geographic Position"); 988 return i18n("Geographic Position");
955} 989}
956 990
957 991
958void Addressee::setTitle( const QString &title ) 992void Addressee::setTitle( const QString &title )
959{ 993{
960 if ( title == mData->title ) return; 994 if ( title == mData->title ) return;
961 detach(); 995 detach();
962 mData->empty = false; 996 mData->empty = false;
963 mData->title = title; 997 mData->title = title;
964} 998}
965 999
966QString Addressee::title() const 1000QString Addressee::title() const
967{ 1001{
968 return mData->title; 1002 return mData->title;
969} 1003}
970 1004
971QString Addressee::titleLabel() 1005QString Addressee::titleLabel()
972{ 1006{
973 return i18n("Title"); 1007 return i18n("Title");
974} 1008}
975 1009
976 1010
977void Addressee::setRole( const QString &role ) 1011void Addressee::setRole( const QString &role )
978{ 1012{
979 if ( role == mData->role ) return; 1013 if ( role == mData->role ) return;
980 detach(); 1014 detach();
981 mData->empty = false; 1015 mData->empty = false;
982 mData->role = role; 1016 mData->role = role;
983} 1017}
984 1018
985QString Addressee::role() const 1019QString Addressee::role() const
986{ 1020{
987 return mData->role; 1021 return mData->role;
988} 1022}
989 1023
990QString Addressee::roleLabel() 1024QString Addressee::roleLabel()
991{ 1025{
992 return i18n("Role"); 1026 return i18n("Role");
993} 1027}
994 1028
995 1029
996void Addressee::setOrganization( const QString &organization ) 1030void Addressee::setOrganization( const QString &organization )
997{ 1031{
998 if ( organization == mData->organization ) return; 1032 if ( organization == mData->organization ) return;
999 detach(); 1033 detach();
1000 mData->empty = false; 1034 mData->empty = false;
1001 mData->organization = organization; 1035 mData->organization = organization;
1002} 1036}
1003 1037
1004QString Addressee::organization() const 1038QString Addressee::organization() const
1005{ 1039{
1006 return mData->organization; 1040 return mData->organization;
1007} 1041}
1008 1042
1009QString Addressee::organizationLabel() 1043QString Addressee::organizationLabel()
1010{ 1044{
1011 return i18n("Organization"); 1045 return i18n("Organization");
1012} 1046}
1013 1047
1014 1048
1015void Addressee::setNote( const QString &note ) 1049void Addressee::setNote( const QString &note )
1016{ 1050{
1017 if ( note == mData->note ) return; 1051 if ( note == mData->note ) return;
1018 detach(); 1052 detach();
1019 mData->empty = false; 1053 mData->empty = false;
1020 mData->note = note; 1054 mData->note = note;
1021} 1055}
1022 1056
1023QString Addressee::note() const 1057QString Addressee::note() const
1024{ 1058{
1025 return mData->note; 1059 return mData->note;
1026} 1060}
1027 1061
1028QString Addressee::noteLabel() 1062QString Addressee::noteLabel()
1029{ 1063{
1030 return i18n("Note"); 1064 return i18n("Note");
1031} 1065}
1032 1066
1033 1067
1034void Addressee::setProductId( const QString &productId ) 1068void Addressee::setProductId( const QString &productId )
1035{ 1069{
1036 if ( productId == mData->productId ) return; 1070 if ( productId == mData->productId ) return;
1037 detach(); 1071 detach();
1038 mData->empty = false; 1072 mData->empty = false;
1039 mData->productId = productId; 1073 mData->productId = productId;
1040} 1074}
1041 1075
1042QString Addressee::productId() const 1076QString Addressee::productId() const
1043{ 1077{
1044 return mData->productId; 1078 return mData->productId;
1045} 1079}
1046 1080
1047QString Addressee::productIdLabel() 1081QString Addressee::productIdLabel()
1048{ 1082{
1049 return i18n("Product Identifier"); 1083 return i18n("Product Identifier");
1050} 1084}
1051 1085
1052 1086
1053void Addressee::setRevision( const QDateTime &revision ) 1087void Addressee::setRevision( const QDateTime &revision )
1054{ 1088{
1055 if ( revision == mData->revision ) return; 1089 if ( revision == mData->revision ) return;
1056 detach(); 1090 detach();
1057 mData->empty = false; 1091 mData->empty = false;
1058 mData->revision = revision; 1092 mData->revision = revision;
1059} 1093}
1060 1094
1061QDateTime Addressee::revision() const 1095QDateTime Addressee::revision() const
1062{ 1096{
1063 return mData->revision; 1097 return mData->revision;
1064} 1098}
1065 1099
1066QString Addressee::revisionLabel() 1100QString Addressee::revisionLabel()
1067{ 1101{
1068 return i18n("Revision Date"); 1102 return i18n("Revision Date");
1069} 1103}
1070 1104
1071 1105
1072void Addressee::setSortString( const QString &sortString ) 1106void Addressee::setSortString( const QString &sortString )
1073{ 1107{
1074 if ( sortString == mData->sortString ) return; 1108 if ( sortString == mData->sortString ) return;
1075 detach(); 1109 detach();
1076 mData->empty = false; 1110 mData->empty = false;
1077 mData->sortString = sortString; 1111 mData->sortString = sortString;
1078} 1112}
1079 1113
1080QString Addressee::sortString() const 1114QString Addressee::sortString() const
1081{ 1115{
1082 return mData->sortString; 1116 return mData->sortString;
1083} 1117}
1084 1118
1085QString Addressee::sortStringLabel() 1119QString Addressee::sortStringLabel()
1086{ 1120{
1087 return i18n("Sort String"); 1121 return i18n("Sort String");
1088} 1122}
1089 1123
1090 1124
1091void Addressee::setUrl( const KURL &url ) 1125void Addressee::setUrl( const KURL &url )
1092{ 1126{
1093 if ( url == mData->url ) return; 1127 if ( url == mData->url ) return;
1094 detach(); 1128 detach();
1095 mData->empty = false; 1129 mData->empty = false;
1096 mData->url = url; 1130 mData->url = url;
1097} 1131}
1098 1132
1099KURL Addressee::url() const 1133KURL Addressee::url() const
1100{ 1134{
1101 return mData->url; 1135 return mData->url;
1102} 1136}
1103 1137
1104QString Addressee::urlLabel() 1138QString Addressee::urlLabel()
1105{ 1139{
1106 return i18n("URL"); 1140 return i18n("URL");
1107} 1141}
1108 1142
1109 1143
1110void Addressee::setSecrecy( const Secrecy &secrecy ) 1144void Addressee::setSecrecy( const Secrecy &secrecy )
1111{ 1145{
1112 if ( secrecy == mData->secrecy ) return; 1146 if ( secrecy == mData->secrecy ) return;
1113 detach(); 1147 detach();
1114 mData->empty = false; 1148 mData->empty = false;
1115 mData->secrecy = secrecy; 1149 mData->secrecy = secrecy;
1116} 1150}
1117 1151
1118Secrecy Addressee::secrecy() const 1152Secrecy Addressee::secrecy() const
1119{ 1153{
1120 return mData->secrecy; 1154 return mData->secrecy;
1121} 1155}
1122 1156
1123QString Addressee::secrecyLabel() 1157QString Addressee::secrecyLabel()
1124{ 1158{
1125 return i18n("Security Class"); 1159 return i18n("Security Class");
1126} 1160}
1127 1161
1128 1162
1129void Addressee::setLogo( const Picture &logo ) 1163void Addressee::setLogo( const Picture &logo )
1130{ 1164{
1131 if ( logo == mData->logo ) return; 1165 if ( logo == mData->logo ) return;
1132 detach(); 1166 detach();
1133 mData->empty = false; 1167 mData->empty = false;
1134 mData->logo = logo; 1168 mData->logo = logo;
1135} 1169}
1136 1170
1137Picture Addressee::logo() const 1171Picture Addressee::logo() const
1138{ 1172{
1139 return mData->logo; 1173 return mData->logo;
1140} 1174}
1141 1175
1142QString Addressee::logoLabel() 1176QString Addressee::logoLabel()
1143{ 1177{
1144 return i18n("Logo"); 1178 return i18n("Logo");
1145} 1179}
1146 1180
1147 1181
1148void Addressee::setPhoto( const Picture &photo ) 1182void Addressee::setPhoto( const Picture &photo )
1149{ 1183{
1150 if ( photo == mData->photo ) return; 1184 if ( photo == mData->photo ) return;
1151 detach(); 1185 detach();
1152 mData->empty = false; 1186 mData->empty = false;
1153 mData->photo = photo; 1187 mData->photo = photo;
1154} 1188}
1155 1189
1156Picture Addressee::photo() const 1190Picture Addressee::photo() const
1157{ 1191{
1158 return mData->photo; 1192 return mData->photo;
1159} 1193}
1160 1194
1161QString Addressee::photoLabel() 1195QString Addressee::photoLabel()
1162{ 1196{
1163 return i18n("Photo"); 1197 return i18n("Photo");
1164} 1198}
1165 1199
1166 1200
1167void Addressee::setSound( const Sound &sound ) 1201void Addressee::setSound( const Sound &sound )
1168{ 1202{
1169 if ( sound == mData->sound ) return; 1203 if ( sound == mData->sound ) return;
1170 detach(); 1204 detach();
1171 mData->empty = false; 1205 mData->empty = false;
1172 mData->sound = sound; 1206 mData->sound = sound;
1173} 1207}
1174 1208
1175Sound Addressee::sound() const 1209Sound Addressee::sound() const
1176{ 1210{
1177 return mData->sound; 1211 return mData->sound;
1178} 1212}
1179 1213
1180QString Addressee::soundLabel() 1214QString Addressee::soundLabel()
1181{ 1215{
1182 return i18n("Sound"); 1216 return i18n("Sound");
1183} 1217}
1184 1218
1185 1219
1186void Addressee::setAgent( const Agent &agent ) 1220void Addressee::setAgent( const Agent &agent )
1187{ 1221{
1188 if ( agent == mData->agent ) return; 1222 if ( agent == mData->agent ) return;
1189 detach(); 1223 detach();
1190 mData->empty = false; 1224 mData->empty = false;
1191 mData->agent = agent; 1225 mData->agent = agent;
1192} 1226}
1193 1227
1194Agent Addressee::agent() const 1228Agent Addressee::agent() const
1195{ 1229{
1196 return mData->agent; 1230 return mData->agent;
1197} 1231}
1198 1232
1199QString Addressee::agentLabel() 1233QString Addressee::agentLabel()
1200{ 1234{
1201 return i18n("Agent"); 1235 return i18n("Agent");
1202} 1236}
1203 1237
1204 1238
1205 1239
1206void Addressee::setNameFromString( const QString &str ) 1240void Addressee::setNameFromString( const QString &str )
1207{ 1241{
1208 setFormattedName( str ); 1242 setFormattedName( str );
1209 setName( str ); 1243 setName( str );
1210 1244
1211 static bool first = true; 1245 static bool first = true;
1212 static QStringList titles; 1246 static QStringList titles;
1213 static QStringList suffixes; 1247 static QStringList suffixes;
1214 static QStringList prefixes; 1248 static QStringList prefixes;
1215 1249
1216 if ( first ) { 1250 if ( first ) {
1217 first = false; 1251 first = false;
1218 titles += i18n( "Dr." ); 1252 titles += i18n( "Dr." );
1219 titles += i18n( "Miss" ); 1253 titles += i18n( "Miss" );
1220 titles += i18n( "Mr." ); 1254 titles += i18n( "Mr." );
1221 titles += i18n( "Mrs." ); 1255 titles += i18n( "Mrs." );
1222 titles += i18n( "Ms." ); 1256 titles += i18n( "Ms." );
1223 titles += i18n( "Prof." ); 1257 titles += i18n( "Prof." );
1224 1258
1225 suffixes += i18n( "I" ); 1259 suffixes += i18n( "I" );
1226 suffixes += i18n( "II" ); 1260 suffixes += i18n( "II" );
1227 suffixes += i18n( "III" ); 1261 suffixes += i18n( "III" );
1228 suffixes += i18n( "Jr." ); 1262 suffixes += i18n( "Jr." );
1229 suffixes += i18n( "Sr." ); 1263 suffixes += i18n( "Sr." );
1230 1264
1231 prefixes += "van"; 1265 prefixes += "van";
1232 prefixes += "von"; 1266 prefixes += "von";
1233 prefixes += "de"; 1267 prefixes += "de";
1234 1268
1235 KConfig config( locateLocal( "config", "kabcrc") ); 1269 KConfig config( locateLocal( "config", "kabcrc") );
1236 config.setGroup( "General" ); 1270 config.setGroup( "General" );
1237 titles += config.readListEntry( "Prefixes" ); 1271 titles += config.readListEntry( "Prefixes" );
1238 titles.remove( "" ); 1272 titles.remove( "" );
1239 prefixes += config.readListEntry( "Inclusions" ); 1273 prefixes += config.readListEntry( "Inclusions" );
1240 prefixes.remove( "" ); 1274 prefixes.remove( "" );
1241 suffixes += config.readListEntry( "Suffixes" ); 1275 suffixes += config.readListEntry( "Suffixes" );
1242 suffixes.remove( "" ); 1276 suffixes.remove( "" );
1243 } 1277 }
1244 1278
1245 // clear all name parts 1279 // clear all name parts
1246 setPrefix( "" ); 1280 setPrefix( "" );
1247 setGivenName( "" ); 1281 setGivenName( "" );
1248 setAdditionalName( "" ); 1282 setAdditionalName( "" );
1249 setFamilyName( "" ); 1283 setFamilyName( "" );
1250 setSuffix( "" ); 1284 setSuffix( "" );
diff --git a/kabc/addressee.h b/kabc/addressee.h
index e7900c6..2c81c1a 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -1,853 +1,853 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.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/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#ifndef KABC_ADDRESSEE_H 29#ifndef KABC_ADDRESSEE_H
30#define KABC_ADDRESSEE_H 30#define KABC_ADDRESSEE_H
31 31
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qstringlist.h> 34#include <qstringlist.h>
35#include <qvaluelist.h> 35#include <qvaluelist.h>
36 36
37#include <ksharedptr.h> 37#include <ksharedptr.h>
38#include <kurl.h> 38#include <kurl.h>
39 39
40#include "address.h" 40#include "address.h"
41#include "agent.h" 41#include "agent.h"
42#include "geo.h" 42#include "geo.h"
43#include "key.h" 43#include "key.h"
44#include "phonenumber.h" 44#include "phonenumber.h"
45#include "picture.h" 45#include "picture.h"
46#include "secrecy.h" 46#include "secrecy.h"
47#include "sound.h" 47#include "sound.h"
48#include "timezone.h" 48#include "timezone.h"
49 49
50namespace KABC { 50namespace KABC {
51 51
52class Resource; 52class Resource;
53 53
54/** 54/**
55 @short address book entry 55 @short address book entry
56 56
57 This class represents an entry in the address book. 57 This class represents an entry in the address book.
58 58
59 The data of this class is implicitly shared. You can pass this class by value. 59 The data of this class is implicitly shared. You can pass this class by value.
60 60
61 If you need the name of a field for presenting it to the user you should use 61 If you need the name of a field for presenting it to the user you should use
62 the functions ending in Label(). They return a translated string which can be 62 the functions ending in Label(). They return a translated string which can be
63 used as label for the corresponding field. 63 used as label for the corresponding field.
64 64
65 About the name fields: 65 About the name fields:
66 66
67 givenName() is the first name and familyName() the last name. In some 67 givenName() is the first name and familyName() the last name. In some
68 countries the family name comes first, that's the reason for the 68 countries the family name comes first, that's the reason for the
69 naming. formattedName() is the full name with the correct formatting. 69 naming. formattedName() is the full name with the correct formatting.
70 It is used as an override, when the correct formatting can't be generated 70 It is used as an override, when the correct formatting can't be generated
71 from the other name fields automatically. 71 from the other name fields automatically.
72 72
73 realName() returns a fully formatted name(). It uses formattedName, if set, 73 realName() returns a fully formatted name(). It uses formattedName, if set,
74 otherwise it constucts the name from the name fields. As fallback, if 74 otherwise it constucts the name from the name fields. As fallback, if
75 nothing else is set it uses name(). 75 nothing else is set it uses name().
76 76
77 name() is the NAME type of RFC2426. It can be used as internal name for the 77 name() is the NAME type of RFC2426. It can be used as internal name for the
78 data enty, but shouldn't be used for displaying the data to the user. 78 data enty, but shouldn't be used for displaying the data to the user.
79 */ 79 */
80class Addressee 80class Addressee
81{ 81{
82 friend QDataStream &operator<<( QDataStream &, const Addressee & ); 82 friend QDataStream &operator<<( QDataStream &, const Addressee & );
83 friend QDataStream &operator>>( QDataStream &, Addressee & ); 83 friend QDataStream &operator>>( QDataStream &, Addressee & );
84 84
85 public: 85 public:
86 typedef QValueList<Addressee> List; 86 typedef QValueList<Addressee> List;
87 87
88 /** 88 /**
89 Construct an empty address book entry. 89 Construct an empty address book entry.
90 */ 90 */
91 Addressee(); 91 Addressee();
92 ~Addressee(); 92 ~Addressee();
93 93
94 Addressee( const Addressee & ); 94 Addressee( const Addressee & );
95 Addressee &operator=( const Addressee & ); 95 Addressee &operator=( const Addressee & );
96 96
97 bool operator==( const Addressee & ) const; 97 bool operator==( const Addressee & ) const;
98 bool operator!=( const Addressee & ) const; 98 bool operator!=( const Addressee & ) const;
99 // sync stuff 99 // sync stuff
100 void setTempSyncStat(int id); 100 void setTempSyncStat(int id);
101 int tempSyncStat() const; 101 int tempSyncStat() const;
102 void setIDStr( const QString & ); 102 void setIDStr( const QString & );
103 QString IDStr() const; 103 QString IDStr() const;
104 void setID( const QString &, const QString & ); 104 void setID( const QString &, const QString & );
105 QString getID( const QString & ); 105 QString getID( const QString & );
106 void setCsum( const QString &, const QString & ); 106 void setCsum( const QString &, const QString & );
107 QString getCsum( const QString & ); 107 QString getCsum( const QString & );
108 void removeID(const QString &); 108 void removeID(const QString &);
109 void computeCsum(const QString &dev); 109 void computeCsum(const QString &dev);
110 ulong getCsum4List( const QStringList & attList); 110 ulong getCsum4List( const QStringList & attList);
111 /** 111 /**
112 Return, if the address book entry is empty. 112 Return, if the address book entry is empty.
113 */ 113 */
114 bool isEmpty() const; 114 bool isEmpty() const;
115 void setExternalUID( const QString &id ); 115 void setExternalUID( const QString &id );
116 QString externalUID() const; 116 QString externalUID() const;
117 void setOriginalExternalUID( const QString &id ); 117 void setOriginalExternalUID( const QString &id );
118 QString originalExternalUID() const; 118 QString originalExternalUID() const;
119 void mergeContact( const Addressee& ad, bool isSubSet = false ); 119 void mergeContact( const Addressee& ad, bool isSubSet );
120 void simplifyEmails(); 120 void simplifyEmails();
121 void simplifyAddresses(); 121 void simplifyAddresses();
122 void simplifyPhoneNumbers(); 122 void simplifyPhoneNumbers();
123 void simplifyPhoneNumberTypes(); 123 void simplifyPhoneNumberTypes();
124 bool removeVoice(); 124 bool removeVoice();
125 bool containsAdr(const Addressee& addr ); 125 bool containsAdr(const Addressee& addr );
126 126
127 /** 127 /**
128 Set unique identifier. 128 Set unique identifier.
129 */ 129 */
130 void setUid( const QString &uid ); 130 void setUid( const QString &uid );
131 /** 131 /**
132 Return unique identifier. 132 Return unique identifier.
133 */ 133 */
134 QString uid() const; 134 QString uid() const;
135 /** 135 /**
136 Return translated label for uid field. 136 Return translated label for uid field.
137 */ 137 */
138 static QString uidLabel(); 138 static QString uidLabel();
139 139
140 /** 140 /**
141 Set name. 141 Set name.
142 */ 142 */
143 void setName( const QString &name ); 143 void setName( const QString &name );
144 /** 144 /**
145 Return name. 145 Return name.
146 */ 146 */
147 QString name() const; 147 QString name() const;
148 /** 148 /**
149 Return translated label for name field. 149 Return translated label for name field.
150 */ 150 */
151 static QString nameLabel(); 151 static QString nameLabel();
152 152
153 /** 153 /**
154 Set formatted name. 154 Set formatted name.
155 */ 155 */
156 void setFormattedName( const QString &formattedName ); 156 void setFormattedName( const QString &formattedName );
157 /** 157 /**
158 Return formatted name. 158 Return formatted name.
159 */ 159 */
160 QString formattedName() const; 160 QString formattedName() const;
161 /** 161 /**
162 Return translated label for formattedName field. 162 Return translated label for formattedName field.
163 */ 163 */
164 static QString formattedNameLabel(); 164 static QString formattedNameLabel();
165 165
166 /** 166 /**
167 Set family name. 167 Set family name.
168 */ 168 */
169 void setFamilyName( const QString &familyName ); 169 void setFamilyName( const QString &familyName );
170 /** 170 /**
171 Return family name. 171 Return family name.
172 */ 172 */
173 QString familyName() const; 173 QString familyName() const;
174 /** 174 /**
175 Return translated label for familyName field. 175 Return translated label for familyName field.
176 */ 176 */
177 static QString familyNameLabel(); 177 static QString familyNameLabel();
178 178
179 /** 179 /**
180 Set given name. 180 Set given name.
181 */ 181 */
182 void setGivenName( const QString &givenName ); 182 void setGivenName( const QString &givenName );
183 /** 183 /**
184 Return given name. 184 Return given name.
185 */ 185 */
186 QString givenName() const; 186 QString givenName() const;
187 /** 187 /**
188 Return translated label for givenName field. 188 Return translated label for givenName field.
189 */ 189 */
190 static QString givenNameLabel(); 190 static QString givenNameLabel();
191 191
192 /** 192 /**
193 Set additional names. 193 Set additional names.
194 */ 194 */
195 void setAdditionalName( const QString &additionalName ); 195 void setAdditionalName( const QString &additionalName );
196 /** 196 /**
197 Return additional names. 197 Return additional names.
198 */ 198 */
199 QString additionalName() const; 199 QString additionalName() const;
200 /** 200 /**
201 Return translated label for additionalName field. 201 Return translated label for additionalName field.
202 */ 202 */
203 static QString additionalNameLabel(); 203 static QString additionalNameLabel();
204 204
205 /** 205 /**
206 Set honorific prefixes. 206 Set honorific prefixes.
207 */ 207 */
208 void setPrefix( const QString &prefix ); 208 void setPrefix( const QString &prefix );
209 /** 209 /**
210 Return honorific prefixes. 210 Return honorific prefixes.
211 */ 211 */
212 QString prefix() const; 212 QString prefix() const;
213 /** 213 /**
214 Return translated label for prefix field. 214 Return translated label for prefix field.
215 */ 215 */
216 static QString prefixLabel(); 216 static QString prefixLabel();
217 217
218 /** 218 /**
219 Set honorific suffixes. 219 Set honorific suffixes.
220 */ 220 */
221 void setSuffix( const QString &suffix ); 221 void setSuffix( const QString &suffix );
222 /** 222 /**
223 Return honorific suffixes. 223 Return honorific suffixes.
224 */ 224 */
225 QString suffix() const; 225 QString suffix() const;
226 /** 226 /**
227 Return translated label for suffix field. 227 Return translated label for suffix field.
228 */ 228 */
229 static QString suffixLabel(); 229 static QString suffixLabel();
230 230
231 /** 231 /**
232 Set nick name. 232 Set nick name.
233 */ 233 */
234 void setNickName( const QString &nickName ); 234 void setNickName( const QString &nickName );
235 /** 235 /**
236 Return nick name. 236 Return nick name.
237 */ 237 */
238 QString nickName() const; 238 QString nickName() const;
239 /** 239 /**
240 Return translated label for nickName field. 240 Return translated label for nickName field.
241 */ 241 */
242 static QString nickNameLabel(); 242 static QString nickNameLabel();
243 243
244 /** 244 /**
245 Set birthday. 245 Set birthday.
246 */ 246 */
247 void setBirthday( const QDateTime &birthday ); 247 void setBirthday( const QDateTime &birthday );
248 /** 248 /**
249 Return birthday. 249 Return birthday.
250 */ 250 */
251 QDateTime birthday() const; 251 QDateTime birthday() const;
252 /** 252 /**
253 Return translated label for birthday field. 253 Return translated label for birthday field.
254 */ 254 */
255 static QString birthdayLabel(); 255 static QString birthdayLabel();
256 256
257 /** 257 /**
258 Return translated label for homeAddressStreet field. 258 Return translated label for homeAddressStreet field.
259 */ 259 */
260 static QString homeAddressStreetLabel(); 260 static QString homeAddressStreetLabel();
261 261
262 /** 262 /**
263 Return translated label for homeAddressLocality field. 263 Return translated label for homeAddressLocality field.
264 */ 264 */
265 static QString homeAddressLocalityLabel(); 265 static QString homeAddressLocalityLabel();
266 266
267 /** 267 /**
268 Return translated label for homeAddressRegion field. 268 Return translated label for homeAddressRegion field.
269 */ 269 */
270 static QString homeAddressRegionLabel(); 270 static QString homeAddressRegionLabel();
271 271
272 /** 272 /**
273 Return translated label for homeAddressPostalCode field. 273 Return translated label for homeAddressPostalCode field.
274 */ 274 */
275 static QString homeAddressPostalCodeLabel(); 275 static QString homeAddressPostalCodeLabel();
276 276
277 /** 277 /**
278 Return translated label for homeAddressCountry field. 278 Return translated label for homeAddressCountry field.
279 */ 279 */
280 static QString homeAddressCountryLabel(); 280 static QString homeAddressCountryLabel();
281 281
282 /** 282 /**
283 Return translated label for homeAddressLabel field. 283 Return translated label for homeAddressLabel field.
284 */ 284 */
285 static QString homeAddressLabelLabel(); 285 static QString homeAddressLabelLabel();
286 286
287 /** 287 /**
288 Return translated label for businessAddressStreet field. 288 Return translated label for businessAddressStreet field.
289 */ 289 */
290 static QString businessAddressStreetLabel(); 290 static QString businessAddressStreetLabel();
291 291
292 /** 292 /**
293 Return translated label for businessAddressLocality field. 293 Return translated label for businessAddressLocality field.
294 */ 294 */
295 static QString businessAddressLocalityLabel(); 295 static QString businessAddressLocalityLabel();
296 296
297 /** 297 /**
298 Return translated label for businessAddressRegion field. 298 Return translated label for businessAddressRegion field.
299 */ 299 */
300 static QString businessAddressRegionLabel(); 300 static QString businessAddressRegionLabel();
301 301
302 /** 302 /**
303 Return translated label for businessAddressPostalCode field. 303 Return translated label for businessAddressPostalCode field.
304 */ 304 */
305 static QString businessAddressPostalCodeLabel(); 305 static QString businessAddressPostalCodeLabel();
306 306
307 /** 307 /**
308 Return translated label for businessAddressCountry field. 308 Return translated label for businessAddressCountry field.
309 */ 309 */
310 static QString businessAddressCountryLabel(); 310 static QString businessAddressCountryLabel();
311 311
312 /** 312 /**
313 Return translated label for businessAddressLabel field. 313 Return translated label for businessAddressLabel field.
314 */ 314 */
315 static QString businessAddressLabelLabel(); 315 static QString businessAddressLabelLabel();
316 316
317 /** 317 /**
318 Return translated label for homePhone field. 318 Return translated label for homePhone field.
319 */ 319 */
320 static QString homePhoneLabel(); 320 static QString homePhoneLabel();
321 321
322 /** 322 /**
323 Return translated label for businessPhone field. 323 Return translated label for businessPhone field.
324 */ 324 */
325 static QString businessPhoneLabel(); 325 static QString businessPhoneLabel();
326 326
327 /** 327 /**
328 Return translated label for mobilePhone field. 328 Return translated label for mobilePhone field.
329 */ 329 */
330 static QString mobilePhoneLabel(); 330 static QString mobilePhoneLabel();
331 331
332 /** 332 /**
333 Return translated label for homeFax field. 333 Return translated label for homeFax field.
334 */ 334 */
335 static QString homeFaxLabel(); 335 static QString homeFaxLabel();
336 336
337 /** 337 /**
338 Return translated label for businessFax field. 338 Return translated label for businessFax field.
339 */ 339 */
340 static QString businessFaxLabel(); 340 static QString businessFaxLabel();
341 341
342 /** 342 /**
343 Return translated label for carPhone field. 343 Return translated label for carPhone field.
344 */ 344 */
345 static QString carPhoneLabel(); 345 static QString carPhoneLabel();
346 346
347 /** 347 /**
348 Return translated label for isdn field. 348 Return translated label for isdn field.
349 */ 349 */
350 static QString isdnLabel(); 350 static QString isdnLabel();
351 351
352 /** 352 /**
353 Return translated label for pager field. 353 Return translated label for pager field.
354 */ 354 */
355 static QString pagerLabel(); 355 static QString pagerLabel();
356 356
357 /** 357 /**
358 Return translated label for sip field. 358 Return translated label for sip field.
359 */ 359 */
360 static QString sipLabel(); 360 static QString sipLabel();
361 361
362 /** 362 /**
363 Return translated label for email field. 363 Return translated label for email field.
364 */ 364 */
365 static QString emailLabel(); 365 static QString emailLabel();
366 366
367 /** 367 /**
368 Set mail client. 368 Set mail client.
369 */ 369 */
370 void setMailer( const QString &mailer ); 370 void setMailer( const QString &mailer );
371 /** 371 /**
372 Return mail client. 372 Return mail client.
373 */ 373 */
374 QString mailer() const; 374 QString mailer() const;
375 /** 375 /**
376 Return translated label for mailer field. 376 Return translated label for mailer field.
377 */ 377 */
378 static QString mailerLabel(); 378 static QString mailerLabel();
379 379
380 /** 380 /**
381 Set time zone. 381 Set time zone.
382 */ 382 */
383 void setTimeZone( const TimeZone &timeZone ); 383 void setTimeZone( const TimeZone &timeZone );
384 /** 384 /**
385 Return time zone. 385 Return time zone.
386 */ 386 */
387 TimeZone timeZone() const; 387 TimeZone timeZone() const;
388 /** 388 /**
389 Return translated label for timeZone field. 389 Return translated label for timeZone field.
390 */ 390 */
391 static QString timeZoneLabel(); 391 static QString timeZoneLabel();
392 392
393 /** 393 /**
394 Set geographic position. 394 Set geographic position.
395 */ 395 */
396 void setGeo( const Geo &geo ); 396 void setGeo( const Geo &geo );
397 /** 397 /**
398 Return geographic position. 398 Return geographic position.
399 */ 399 */
400 Geo geo() const; 400 Geo geo() const;
401 /** 401 /**
402 Return translated label for geo field. 402 Return translated label for geo field.
403 */ 403 */
404 static QString geoLabel(); 404 static QString geoLabel();
405 405
406 /** 406 /**
407 Set title. 407 Set title.
408 */ 408 */
409 void setTitle( const QString &title ); 409 void setTitle( const QString &title );
410 /** 410 /**
411 Return title. 411 Return title.
412 */ 412 */
413 QString title() const; 413 QString title() const;
414 /** 414 /**
415 Return translated label for title field. 415 Return translated label for title field.
416 */ 416 */
417 static QString titleLabel(); 417 static QString titleLabel();
418 418
419 /** 419 /**
420 Set role. 420 Set role.
421 */ 421 */
422 void setRole( const QString &role ); 422 void setRole( const QString &role );
423 /** 423 /**
424 Return role. 424 Return role.
425 */ 425 */
426 QString role() const; 426 QString role() const;
427 /** 427 /**
428 Return translated label for role field. 428 Return translated label for role field.
429 */ 429 */
430 static QString roleLabel(); 430 static QString roleLabel();
431 431
432 /** 432 /**
433 Set organization. 433 Set organization.
434 */ 434 */
435 void setOrganization( const QString &organization ); 435 void setOrganization( const QString &organization );
436 /** 436 /**
437 Return organization. 437 Return organization.
438 */ 438 */
439 QString organization() const; 439 QString organization() const;
440 /** 440 /**
441 Return translated label for organization field. 441 Return translated label for organization field.
442 */ 442 */
443 static QString organizationLabel(); 443 static QString organizationLabel();
444 444
445 /** 445 /**
446 Set note. 446 Set note.
447 */ 447 */
448 void setNote( const QString &note ); 448 void setNote( const QString &note );
449 /** 449 /**
450 Return note. 450 Return note.
451 */ 451 */
452 QString note() const; 452 QString note() const;
453 /** 453 /**
454 Return translated label for note field. 454 Return translated label for note field.
455 */ 455 */
456 static QString noteLabel(); 456 static QString noteLabel();
457 457
458 /** 458 /**
459 Set product identifier. 459 Set product identifier.
460 */ 460 */
461 void setProductId( const QString &productId ); 461 void setProductId( const QString &productId );
462 /** 462 /**
463 Return product identifier. 463 Return product identifier.
464 */ 464 */
465 QString productId() const; 465 QString productId() const;
466 /** 466 /**
467 Return translated label for productId field. 467 Return translated label for productId field.
468 */ 468 */
469 static QString productIdLabel(); 469 static QString productIdLabel();
470 470
471 /** 471 /**
472 Set revision date. 472 Set revision date.
473 */ 473 */
474 void setRevision( const QDateTime &revision ); 474 void setRevision( const QDateTime &revision );
475 /** 475 /**
476 Return revision date. 476 Return revision date.
477 */ 477 */
478 QDateTime revision() const; 478 QDateTime revision() const;
479 /** 479 /**
480 Return translated label for revision field. 480 Return translated label for revision field.
481 */ 481 */
482 static QString revisionLabel(); 482 static QString revisionLabel();
483 483
484 /** 484 /**
485 Set sort string. 485 Set sort string.
486 */ 486 */
487 void setSortString( const QString &sortString ); 487 void setSortString( const QString &sortString );
488 /** 488 /**
489 Return sort string. 489 Return sort string.
490 */ 490 */
491 QString sortString() const; 491 QString sortString() const;
492 /** 492 /**
493 Return translated label for sortString field. 493 Return translated label for sortString field.
494 */ 494 */
495 static QString sortStringLabel(); 495 static QString sortStringLabel();
496 496
497 /** 497 /**
498 Set URL. 498 Set URL.
499 */ 499 */
500 void setUrl( const KURL &url ); 500 void setUrl( const KURL &url );
501 /** 501 /**
502 Return URL. 502 Return URL.
503 */ 503 */
504 KURL url() const; 504 KURL url() const;
505 /** 505 /**
506 Return translated label for url field. 506 Return translated label for url field.
507 */ 507 */
508 static QString urlLabel(); 508 static QString urlLabel();
509 509
510 /** 510 /**
511 Set security class. 511 Set security class.
512 */ 512 */
513 void setSecrecy( const Secrecy &secrecy ); 513 void setSecrecy( const Secrecy &secrecy );
514 /** 514 /**
515 Return security class. 515 Return security class.
516 */ 516 */
517 Secrecy secrecy() const; 517 Secrecy secrecy() const;
518 /** 518 /**
519 Return translated label for secrecy field. 519 Return translated label for secrecy field.
520 */ 520 */
521 static QString secrecyLabel(); 521 static QString secrecyLabel();
522 522
523 /** 523 /**
524 Set logo. 524 Set logo.
525 */ 525 */
526 void setLogo( const Picture &logo ); 526 void setLogo( const Picture &logo );
527 /** 527 /**
528 Return logo. 528 Return logo.
529 */ 529 */
530 Picture logo() const; 530 Picture logo() const;
531 /** 531 /**
532 Return translated label for logo field. 532 Return translated label for logo field.
533 */ 533 */
534 static QString logoLabel(); 534 static QString logoLabel();
535 535
536 /** 536 /**
537 Set photo. 537 Set photo.
538 */ 538 */
539 void setPhoto( const Picture &photo ); 539 void setPhoto( const Picture &photo );
540 /** 540 /**
541 Return photo. 541 Return photo.
542 */ 542 */
543 Picture photo() const; 543 Picture photo() const;
544 /** 544 /**
545 Return translated label for photo field. 545 Return translated label for photo field.
546 */ 546 */
547 static QString photoLabel(); 547 static QString photoLabel();
548 548
549 /** 549 /**
550 Set sound. 550 Set sound.
551 */ 551 */
552 void setSound( const Sound &sound ); 552 void setSound( const Sound &sound );
553 /** 553 /**
554 Return sound. 554 Return sound.
555 */ 555 */
556 Sound sound() const; 556 Sound sound() const;
557 /** 557 /**
558 Return translated label for sound field. 558 Return translated label for sound field.
559 */ 559 */
560 static QString soundLabel(); 560 static QString soundLabel();
561 561
562 /** 562 /**
563 Set agent. 563 Set agent.
564 */ 564 */
565 void setAgent( const Agent &agent ); 565 void setAgent( const Agent &agent );
566 /** 566 /**
567 Return agent. 567 Return agent.
568 */ 568 */
569 Agent agent() const; 569 Agent agent() const;
570 /** 570 /**
571 Return translated label for agent field. 571 Return translated label for agent field.
572 */ 572 */
573 static QString agentLabel(); 573 static QString agentLabel();
574 574
575 /** 575 /**
576 Set name fields by parsing the given string and trying to associate the 576 Set name fields by parsing the given string and trying to associate the
577 parts of the string with according fields. This function should probably 577 parts of the string with according fields. This function should probably
578 be a bit more clever. 578 be a bit more clever.
579 */ 579 */
580 void setNameFromString( const QString & ); 580 void setNameFromString( const QString & );
581 581
582 /** 582 /**
583 Return the name of the addressee. This is calculated from all the name 583 Return the name of the addressee. This is calculated from all the name
584 fields. 584 fields.
585 */ 585 */
586 QString realName() const; 586 QString realName() const;
587 587
588 /** 588 /**
589 Return the name that consists of all name parts. 589 Return the name that consists of all name parts.
590 */ 590 */
591 QString assembledName() const; 591 QString assembledName() const;
592 592
593 /** 593 /**
594 Return email address including real name. 594 Return email address including real name.
595 595
596 @param email Email address to be used to construct the full email string. 596 @param email Email address to be used to construct the full email string.
597 If this is QString::null the preferred email address is used. 597 If this is QString::null the preferred email address is used.
598 */ 598 */
599 QString fullEmail( const QString &email=QString::null ) const; 599 QString fullEmail( const QString &email=QString::null ) const;
600 600
601 /** 601 /**
602 Insert an email address. If the email address already exists in this 602 Insert an email address. If the email address already exists in this
603 addressee it is not duplicated. 603 addressee it is not duplicated.
604 604
605 @param email Email address 605 @param email Email address
606 @param preferred Set to true, if this is the preferred email address of 606 @param preferred Set to true, if this is the preferred email address of
607 the addressee. 607 the addressee.
608 */ 608 */
609 void insertEmail( const QString &email, bool preferred=false ); 609 void insertEmail( const QString &email, bool preferred=false );
610 610
611 /** 611 /**
612 Remove email address. If the email address doesn't exist, nothing happens. 612 Remove email address. If the email address doesn't exist, nothing happens.
613 */ 613 */
614 void removeEmail( const QString &email ); 614 void removeEmail( const QString &email );
615 615
616 /** 616 /**
617 Return preferred email address. This is the first email address or the 617 Return preferred email address. This is the first email address or the
618 last one added with @ref insertEmail() with a set preferred parameter. 618 last one added with @ref insertEmail() with a set preferred parameter.
619 */ 619 */
620 QString preferredEmail() const; 620 QString preferredEmail() const;
621 621
622 /** 622 /**
623 Return list of all email addresses. 623 Return list of all email addresses.
624 */ 624 */
625 QStringList emails() const; 625 QStringList emails() const;
626 626
627 /** 627 /**
628 Set the emails to @param. 628 Set the emails to @param.
629 The first email address gets the preferred one! 629 The first email address gets the preferred one!
630 @param list The list of email addresses. 630 @param list The list of email addresses.
631 */ 631 */
632 void setEmails( const QStringList& list); 632 void setEmails( const QStringList& list);
633 633
634 /** 634 /**
635 Insert a phone number. If a phone number with the same id already exists 635 Insert a phone number. If a phone number with the same id already exists
636 in this addressee it is not duplicated. 636 in this addressee it is not duplicated.
637 */ 637 */
638 void insertPhoneNumber( const PhoneNumber &phoneNumber ); 638 void insertPhoneNumber( const PhoneNumber &phoneNumber );
639 639
640 /** 640 /**
641 Remove phone number. If no phone number with the given id exists for this 641 Remove phone number. If no phone number with the given id exists for this
642 addresse nothing happens. 642 addresse nothing happens.
643 */ 643 */
644 void removePhoneNumber( const PhoneNumber &phoneNumber ); 644 void removePhoneNumber( const PhoneNumber &phoneNumber );
645 645
646 /** 646 /**
647 Return phone number, which matches the given type. 647 Return phone number, which matches the given type.
648 */ 648 */
649 PhoneNumber phoneNumber( int type ) const; 649 PhoneNumber phoneNumber( int type ) const;
650 650
651 /** 651 /**
652 Return list of all phone numbers. 652 Return list of all phone numbers.
653 */ 653 */
654 PhoneNumber::List phoneNumbers() const; 654 PhoneNumber::List phoneNumbers() const;
655 655
656 /** 656 /**
657 Return list of phone numbers with a special type. 657 Return list of phone numbers with a special type.
658 */ 658 */
659 PhoneNumber::List phoneNumbers( int type ) const; 659 PhoneNumber::List phoneNumbers( int type ) const;
660 660
661 /** 661 /**
662 Return phone number with the given id. 662 Return phone number with the given id.
663 */ 663 */
664 PhoneNumber findPhoneNumber( const QString &id ) const; 664 PhoneNumber findPhoneNumber( const QString &id ) const;
665 665
666 /** 666 /**
667 Insert a key. If a key with the same id already exists 667 Insert a key. If a key with the same id already exists
668 in this addressee it is not duplicated. 668 in this addressee it is not duplicated.
669 */ 669 */
670 void insertKey( const Key &key ); 670 void insertKey( const Key &key );
671 671
672 /** 672 /**
673 Remove a key. If no key with the given id exists for this 673 Remove a key. If no key with the given id exists for this
674 addresse nothing happens. 674 addresse nothing happens.
675 */ 675 */
676 void removeKey( const Key &key ); 676 void removeKey( const Key &key );
677 677
678 /** 678 /**
679 Return key, which matches the given type. 679 Return key, which matches the given type.
680 If @p type == Key::Custom you can specify a string 680 If @p type == Key::Custom you can specify a string
681 that should match. If you leave the string empty, the first 681 that should match. If you leave the string empty, the first
682 key with a custom value is returned. 682 key with a custom value is returned.
683 */ 683 */
684 Key key( int type, QString customTypeString = QString::null ) const; 684 Key key( int type, QString customTypeString = QString::null ) const;
685 685
686 /** 686 /**
687 Return list of all keys. 687 Return list of all keys.
688 */ 688 */
689 Key::List keys() const; 689 Key::List keys() const;
690 690
691 /** 691 /**
692 Set the list of keys 692 Set the list of keys
693 @param keys The keys to be set. 693 @param keys The keys to be set.
694 */ 694 */
695 void setKeys( const Key::List& keys); 695 void setKeys( const Key::List& keys);
696 696
697 /** 697 /**
698 Return list of keys with a special type. 698 Return list of keys with a special type.
699 If @p type == Key::Custom you can specify a string 699 If @p type == Key::Custom you can specify a string
700 that should match. If you leave the string empty, all custom 700 that should match. If you leave the string empty, all custom
701 keys will be returned. 701 keys will be returned.
702 */ 702 */
703 Key::List keys( int type, QString customTypeString = QString::null ) const; 703 Key::List keys( int type, QString customTypeString = QString::null ) const;
704 704
705 /** 705 /**
706 Return key with the given id. 706 Return key with the given id.
707 */ 707 */
708 Key findKey( const QString &id ) const; 708 Key findKey( const QString &id ) const;
709 709
710 /** 710 /**
711 Insert an address. If an address with the same id already exists 711 Insert an address. If an address with the same id already exists
712 in this addressee it is not duplicated. 712 in this addressee it is not duplicated.
713 */ 713 */
714 void insertAddress( const Address &address ); 714 void insertAddress( const Address &address );
715 715
716 /** 716 /**
717 Remove address. If no address with the given id exists for this 717 Remove address. If no address with the given id exists for this
718 addresse nothing happens. 718 addresse nothing happens.
719 */ 719 */
720 void removeAddress( const Address &address ); 720 void removeAddress( const Address &address );
721 721
722 /** 722 /**
723 Return address, which matches the given type. 723 Return address, which matches the given type.
724 */ 724 */
725 Address address( int type ) const; 725 Address address( int type ) const;
726 726
727 /** 727 /**
728 Return list of all addresses. 728 Return list of all addresses.
729 */ 729 */
730 Address::List addresses() const; 730 Address::List addresses() const;
731 731
732 /** 732 /**
733 Return list of addresses with a special type. 733 Return list of addresses with a special type.
734 */ 734 */
735 Address::List addresses( int type ) const; 735 Address::List addresses( int type ) const;
736 736
737 /** 737 /**
738 Return address with the given id. 738 Return address with the given id.
739 */ 739 */
740 Address findAddress( const QString &id ) const; 740 Address findAddress( const QString &id ) const;
741 741
742 /** 742 /**
743 Insert category. If the category already exists it is not duplicated. 743 Insert category. If the category already exists it is not duplicated.
744 */ 744 */
745 void insertCategory( const QString & ); 745 void insertCategory( const QString & );
746 746
747 /** 747 /**
748 Remove category. 748 Remove category.
749 */ 749 */
750 void removeCategory( const QString & ); 750 void removeCategory( const QString & );
751 751
752 /** 752 /**
753 Return, if addressee has the given category. 753 Return, if addressee has the given category.
754 */ 754 */
755 bool hasCategory( const QString & ) const; 755 bool hasCategory( const QString & ) const;
756 756
757 /** 757 /**
758 Set categories to given value. 758 Set categories to given value.
759 */ 759 */
760 void setCategories( const QStringList & ); 760 void setCategories( const QStringList & );
761 761
762 /** 762 /**
763 Return list of all set categories. 763 Return list of all set categories.
764 */ 764 */
765 QStringList categories() const; 765 QStringList categories() const;
766 766
767 /** 767 /**
768 Insert custom entry. The entry is identified by the name of the inserting 768 Insert custom entry. The entry is identified by the name of the inserting
769 application and a unique name. If an entry with the given app and name 769 application and a unique name. If an entry with the given app and name
770 already exists its value is replaced with the new given value. 770 already exists its value is replaced with the new given value.
771 */ 771 */
772 void insertCustom( const QString &app, const QString &name, 772 void insertCustom( const QString &app, const QString &name,
773 const QString &value ); 773 const QString &value );
774 774
775 /** 775 /**
776 Remove custom entry. 776 Remove custom entry.
777 */ 777 */
778 void removeCustom( const QString &app, const QString &name ); 778 void removeCustom( const QString &app, const QString &name );
779 779
780 /** 780 /**
781 Return value of custom entry, identified by app and entry name. 781 Return value of custom entry, identified by app and entry name.
782 */ 782 */
783 QString custom( const QString &app, const QString &name ) const; 783 QString custom( const QString &app, const QString &name ) const;
784 784
785 /** 785 /**
786 Set all custom entries. 786 Set all custom entries.
787 */ 787 */
788 void setCustoms( const QStringList & ); 788 void setCustoms( const QStringList & );
789 789
790 /** 790 /**
791 Return list of all custom entries. 791 Return list of all custom entries.
792 */ 792 */
793 QStringList customs() const; 793 QStringList customs() const;
794 794
795 /** 795 /**
796 Parse full email address. The result is given back in fullName and email. 796 Parse full email address. The result is given back in fullName and email.
797 */ 797 */
798 static void parseEmailAddress( const QString &rawEmail, QString &fullName, 798 static void parseEmailAddress( const QString &rawEmail, QString &fullName,
799 QString &email ); 799 QString &email );
800 800
801 /** 801 /**
802 Debug output. 802 Debug output.
803 */ 803 */
804 void dump() const; 804 void dump() const;
805 805
806 /** 806 /**
807 Returns string representation of the addressee. 807 Returns string representation of the addressee.
808 */ 808 */
809 QString asString() const; 809 QString asString() const;
810 810
811 /** 811 /**
812 Set resource where the addressee is from. 812 Set resource where the addressee is from.
813 */ 813 */
814 void setResource( Resource *resource ); 814 void setResource( Resource *resource );
815 815
816 /** 816 /**
817 Return pointer to resource. 817 Return pointer to resource.
818 */ 818 */
819 Resource *resource() const; 819 Resource *resource() const;
820 820
821 /** 821 /**
822 Return resourcelabel. 822 Return resourcelabel.
823 */ 823 */
824 //US 824 //US
825 static QString resourceLabel(); 825 static QString resourceLabel();
826 826
827 /** 827 /**
828 Mark addressee as changed. 828 Mark addressee as changed.
829 */ 829 */
830 void setChanged( bool value ); 830 void setChanged( bool value );
831 831
832 /** 832 /**
833 Return whether the addressee is changed. 833 Return whether the addressee is changed.
834 */ 834 */
835 bool changed() const; 835 bool changed() const;
836 836
837 void setTagged( bool value ); 837 void setTagged( bool value );
838 bool tagged() const; 838 bool tagged() const;
839 839
840 private: 840 private:
841 Addressee copy(); 841 Addressee copy();
842 void detach(); 842 void detach();
843 843
844 struct AddresseeData; 844 struct AddresseeData;
845 mutable KSharedPtr<AddresseeData> mData; 845 mutable KSharedPtr<AddresseeData> mData;
846}; 846};
847 847
848QDataStream &operator<<( QDataStream &, const Addressee & ); 848QDataStream &operator<<( QDataStream &, const Addressee & );
849QDataStream &operator>>( QDataStream &, Addressee & ); 849QDataStream &operator>>( QDataStream &, Addressee & );
850 850
851} 851}
852 852
853#endif 853#endif
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 205dbc8..ea34be2 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1967,909 +1967,909 @@ void KABCore::addActionsManually()
1967 editMenu->insertSeparator(); 1967 editMenu->insertSeparator();
1968 mActionSelectAll->plug( editMenu ); 1968 mActionSelectAll->plug( editMenu );
1969 1969
1970 mActionRemoveVoice->plug( changeMenu ); 1970 mActionRemoveVoice->plug( changeMenu );
1971 // settings menu 1971 // settings menu
1972//US special menuentry to configure the addressbook resources. On KDE 1972//US special menuentry to configure the addressbook resources. On KDE
1973// you do that through the control center !!! 1973// you do that through the control center !!!
1974 mActionConfigResources->plug( settingsMenu ); 1974 mActionConfigResources->plug( settingsMenu );
1975 settingsMenu->insertSeparator(); 1975 settingsMenu->insertSeparator();
1976 1976
1977 mActionConfigKAddressbook->plug( settingsMenu ); 1977 mActionConfigKAddressbook->plug( settingsMenu );
1978 1978
1979 if ( mIsPart ) { 1979 if ( mIsPart ) {
1980 mActionConfigShortcuts->plug( settingsMenu ); 1980 mActionConfigShortcuts->plug( settingsMenu );
1981 mActionConfigureToolbars->plug( settingsMenu ); 1981 mActionConfigureToolbars->plug( settingsMenu );
1982 1982
1983 } else { 1983 } else {
1984 mActionKeyBindings->plug( settingsMenu ); 1984 mActionKeyBindings->plug( settingsMenu );
1985 } 1985 }
1986 1986
1987 settingsMenu->insertSeparator(); 1987 settingsMenu->insertSeparator();
1988 1988
1989 mActionJumpBar->plug( settingsMenu ); 1989 mActionJumpBar->plug( settingsMenu );
1990 mActionDetails->plug( settingsMenu ); 1990 mActionDetails->plug( settingsMenu );
1991 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 1991 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
1992 mActionDetails->plug( tb ); 1992 mActionDetails->plug( tb );
1993 settingsMenu->insertSeparator(); 1993 settingsMenu->insertSeparator();
1994 1994
1995 mActionWhoAmI->plug( settingsMenu ); 1995 mActionWhoAmI->plug( settingsMenu );
1996 mActionCategories->plug( settingsMenu ); 1996 mActionCategories->plug( settingsMenu );
1997 1997
1998 1998
1999 mActionWN->plug( helpMenu ); 1999 mActionWN->plug( helpMenu );
2000 mActionSyncHowto->plug( helpMenu ); 2000 mActionSyncHowto->plug( helpMenu );
2001 mActionLicence->plug( helpMenu ); 2001 mActionLicence->plug( helpMenu );
2002 mActionFaq->plug( helpMenu ); 2002 mActionFaq->plug( helpMenu );
2003 mActionAboutKAddressbook->plug( helpMenu ); 2003 mActionAboutKAddressbook->plug( helpMenu );
2004 2004
2005 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2005 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2006 2006
2007 mActionSave->plug( tb ); 2007 mActionSave->plug( tb );
2008 mViewManager->getFilterAction()->plug ( tb); 2008 mViewManager->getFilterAction()->plug ( tb);
2009 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2009 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2010 mActionUndo->plug( tb ); 2010 mActionUndo->plug( tb );
2011 mActionDelete->plug( tb ); 2011 mActionDelete->plug( tb );
2012 mActionRedo->plug( tb ); 2012 mActionRedo->plug( tb );
2013 } 2013 }
2014 } 2014 }
2015 //mActionQuit->plug ( tb ); 2015 //mActionQuit->plug ( tb );
2016 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2016 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2017 2017
2018 //US link the searchwidget first to this. 2018 //US link the searchwidget first to this.
2019 // The real linkage to the toolbar happens later. 2019 // The real linkage to the toolbar happens later.
2020//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2020//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2021//US tb->insertItem( mIncSearchWidget ); 2021//US tb->insertItem( mIncSearchWidget );
2022/*US 2022/*US
2023 mIncSearchWidget = new IncSearchWidget( tb ); 2023 mIncSearchWidget = new IncSearchWidget( tb );
2024 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2024 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2025 SLOT( incrementalSearch( const QString& ) ) ); 2025 SLOT( incrementalSearch( const QString& ) ) );
2026 2026
2027 mJumpButtonBar = new JumpButtonBar( this, this ); 2027 mJumpButtonBar = new JumpButtonBar( this, this );
2028 2028
2029//US topLayout->addWidget( mJumpButtonBar ); 2029//US topLayout->addWidget( mJumpButtonBar );
2030 this->layout()->add( mJumpButtonBar ); 2030 this->layout()->add( mJumpButtonBar );
2031*/ 2031*/
2032 2032
2033#endif //KAB_EMBEDDED 2033#endif //KAB_EMBEDDED
2034 2034
2035 mActionExport2phone->plug( ExportMenu ); 2035 mActionExport2phone->plug( ExportMenu );
2036 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2036 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2037 syncManager->fillSyncMenu(); 2037 syncManager->fillSyncMenu();
2038 2038
2039} 2039}
2040void KABCore::showLicence() 2040void KABCore::showLicence()
2041{ 2041{
2042 KApplication::showLicence(); 2042 KApplication::showLicence();
2043} 2043}
2044void KABCore::removeVoice() 2044void KABCore::removeVoice()
2045{ 2045{
2046 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2046 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2047 return; 2047 return;
2048 KABC::Addressee::List list = mViewManager->selectedAddressees(); 2048 KABC::Addressee::List list = mViewManager->selectedAddressees();
2049 KABC::Addressee::List::Iterator it; 2049 KABC::Addressee::List::Iterator it;
2050 for ( it = list.begin(); it != list.end(); ++it ) { 2050 for ( it = list.begin(); it != list.end(); ++it ) {
2051 2051
2052 if ( (*it).removeVoice() ) 2052 if ( (*it).removeVoice() )
2053 contactModified((*it) ); 2053 contactModified((*it) );
2054 } 2054 }
2055} 2055}
2056 2056
2057 2057
2058 2058
2059void KABCore::clipboardDataChanged() 2059void KABCore::clipboardDataChanged()
2060{ 2060{
2061 2061
2062 if ( mReadWrite ) 2062 if ( mReadWrite )
2063 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2063 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2064 2064
2065} 2065}
2066 2066
2067void KABCore::updateActionMenu() 2067void KABCore::updateActionMenu()
2068{ 2068{
2069 UndoStack *undo = UndoStack::instance(); 2069 UndoStack *undo = UndoStack::instance();
2070 RedoStack *redo = RedoStack::instance(); 2070 RedoStack *redo = RedoStack::instance();
2071 2071
2072 if ( undo->isEmpty() ) 2072 if ( undo->isEmpty() )
2073 mActionUndo->setText( i18n( "Undo" ) ); 2073 mActionUndo->setText( i18n( "Undo" ) );
2074 else 2074 else
2075 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2075 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2076 2076
2077 mActionUndo->setEnabled( !undo->isEmpty() ); 2077 mActionUndo->setEnabled( !undo->isEmpty() );
2078 2078
2079 if ( !redo->top() ) 2079 if ( !redo->top() )
2080 mActionRedo->setText( i18n( "Redo" ) ); 2080 mActionRedo->setText( i18n( "Redo" ) );
2081 else 2081 else
2082 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2082 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2083 2083
2084 mActionRedo->setEnabled( !redo->isEmpty() ); 2084 mActionRedo->setEnabled( !redo->isEmpty() );
2085} 2085}
2086 2086
2087void KABCore::configureKeyBindings() 2087void KABCore::configureKeyBindings()
2088{ 2088{
2089#ifndef KAB_EMBEDDED 2089#ifndef KAB_EMBEDDED
2090 KKeyDialog::configure( actionCollection(), true ); 2090 KKeyDialog::configure( actionCollection(), true );
2091#else //KAB_EMBEDDED 2091#else //KAB_EMBEDDED
2092 qDebug("KABCore::configureKeyBindings() not implemented"); 2092 qDebug("KABCore::configureKeyBindings() not implemented");
2093#endif //KAB_EMBEDDED 2093#endif //KAB_EMBEDDED
2094} 2094}
2095 2095
2096#ifdef KAB_EMBEDDED 2096#ifdef KAB_EMBEDDED
2097void KABCore::configureResources() 2097void KABCore::configureResources()
2098{ 2098{
2099 KRES::KCMKResources dlg( this, "" , 0 ); 2099 KRES::KCMKResources dlg( this, "" , 0 );
2100 2100
2101 if ( !dlg.exec() ) 2101 if ( !dlg.exec() )
2102 return; 2102 return;
2103 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2103 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2104} 2104}
2105#endif //KAB_EMBEDDED 2105#endif //KAB_EMBEDDED
2106 2106
2107 2107
2108/* this method will be called through the QCop interface from Ko/Pi to select addresses 2108/* this method will be called through the QCop interface from Ko/Pi to select addresses
2109 * for the attendees list of an event. 2109 * for the attendees list of an event.
2110 */ 2110 */
2111void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2111void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2112{ 2112{
2113 QStringList nameList; 2113 QStringList nameList;
2114 QStringList emailList; 2114 QStringList emailList;
2115 QStringList uidList; 2115 QStringList uidList;
2116 2116
2117 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2117 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2118 uint i=0; 2118 uint i=0;
2119 for (i=0; i < list.count(); i++) 2119 for (i=0; i < list.count(); i++)
2120 { 2120 {
2121 nameList.append(list[i].realName()); 2121 nameList.append(list[i].realName());
2122 emailList.append(list[i].preferredEmail()); 2122 emailList.append(list[i].preferredEmail());
2123 uidList.append(list[i].uid()); 2123 uidList.append(list[i].uid());
2124 } 2124 }
2125 2125
2126 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2126 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2127 2127
2128} 2128}
2129 2129
2130/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2130/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2131 * to put them into the calendar. 2131 * to put them into the calendar.
2132 */ 2132 */
2133void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2133void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2134{ 2134{
2135 // qDebug("KABCore::requestForBirthdayList"); 2135 // qDebug("KABCore::requestForBirthdayList");
2136 QStringList birthdayList; 2136 QStringList birthdayList;
2137 QStringList anniversaryList; 2137 QStringList anniversaryList;
2138 QStringList realNameList; 2138 QStringList realNameList;
2139 QStringList preferredEmailList; 2139 QStringList preferredEmailList;
2140 QStringList assembledNameList; 2140 QStringList assembledNameList;
2141 QStringList uidList; 2141 QStringList uidList;
2142 2142
2143 KABC::AddressBook::Iterator it; 2143 KABC::AddressBook::Iterator it;
2144 2144
2145 int count = 0; 2145 int count = 0;
2146 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2146 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2147 ++count; 2147 ++count;
2148 } 2148 }
2149 QProgressBar bar(count,0 ); 2149 QProgressBar bar(count,0 );
2150 int w = 300; 2150 int w = 300;
2151 if ( QApplication::desktop()->width() < 320 ) 2151 if ( QApplication::desktop()->width() < 320 )
2152 w = 220; 2152 w = 220;
2153 int h = bar.sizeHint().height() ; 2153 int h = bar.sizeHint().height() ;
2154 int dw = QApplication::desktop()->width(); 2154 int dw = QApplication::desktop()->width();
2155 int dh = QApplication::desktop()->height(); 2155 int dh = QApplication::desktop()->height();
2156 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2156 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2157 bar.show(); 2157 bar.show();
2158 bar.setCaption (i18n("collecting birthdays - close to abort!") ); 2158 bar.setCaption (i18n("collecting birthdays - close to abort!") );
2159 qApp->processEvents(); 2159 qApp->processEvents();
2160 2160
2161 QDate bday; 2161 QDate bday;
2162 QString anni; 2162 QString anni;
2163 QString formattedbday; 2163 QString formattedbday;
2164 2164
2165 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2165 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2166 { 2166 {
2167 if ( ! bar.isVisible() ) 2167 if ( ! bar.isVisible() )
2168 return; 2168 return;
2169 bar.setProgress( count++ ); 2169 bar.setProgress( count++ );
2170 qApp->processEvents(); 2170 qApp->processEvents();
2171 bday = (*it).birthday().date(); 2171 bday = (*it).birthday().date();
2172 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2172 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2173 2173
2174 if ( bday.isValid() || !anni.isEmpty()) 2174 if ( bday.isValid() || !anni.isEmpty())
2175 { 2175 {
2176 if (bday.isValid()) 2176 if (bday.isValid())
2177 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2177 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2178 else 2178 else
2179 formattedbday = "NOTVALID"; 2179 formattedbday = "NOTVALID";
2180 if (anni.isEmpty()) 2180 if (anni.isEmpty())
2181 anni = "INVALID"; 2181 anni = "INVALID";
2182 2182
2183 birthdayList.append(formattedbday); 2183 birthdayList.append(formattedbday);
2184 anniversaryList.append(anni); //should be ISODate 2184 anniversaryList.append(anni); //should be ISODate
2185 realNameList.append((*it).realName()); 2185 realNameList.append((*it).realName());
2186 preferredEmailList.append((*it).preferredEmail()); 2186 preferredEmailList.append((*it).preferredEmail());
2187 assembledNameList.append((*it).assembledName()); 2187 assembledNameList.append((*it).assembledName());
2188 uidList.append((*it).uid()); 2188 uidList.append((*it).uid());
2189 2189
2190 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2190 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2191 } 2191 }
2192 } 2192 }
2193 2193
2194 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2194 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2195 2195
2196} 2196}
2197 2197
2198/* this method will be called through the QCop interface from other apps to show details of a contact. 2198/* this method will be called through the QCop interface from other apps to show details of a contact.
2199 */ 2199 */
2200void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2200void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2201{ 2201{
2202 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2202 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2203 2203
2204 QString foundUid = QString::null; 2204 QString foundUid = QString::null;
2205 if ( ! uid.isEmpty() ) { 2205 if ( ! uid.isEmpty() ) {
2206 Addressee adrr = mAddressBook->findByUid( uid ); 2206 Addressee adrr = mAddressBook->findByUid( uid );
2207 if ( !adrr.isEmpty() ) { 2207 if ( !adrr.isEmpty() ) {
2208 foundUid = uid; 2208 foundUid = uid;
2209 } 2209 }
2210 if ( email == "sendbacklist" ) { 2210 if ( email == "sendbacklist" ) {
2211 //qDebug("ssssssssssssssssssssssend "); 2211 //qDebug("ssssssssssssssssssssssend ");
2212 QStringList nameList; 2212 QStringList nameList;
2213 QStringList emailList; 2213 QStringList emailList;
2214 QStringList uidList; 2214 QStringList uidList;
2215 nameList.append(adrr.realName()); 2215 nameList.append(adrr.realName());
2216 emailList = adrr.emails(); 2216 emailList = adrr.emails();
2217 uidList.append( adrr.preferredEmail()); 2217 uidList.append( adrr.preferredEmail());
2218 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2218 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2219 return; 2219 return;
2220 } 2220 }
2221 2221
2222 } 2222 }
2223 2223
2224 if ( email == "sendbacklist" ) 2224 if ( email == "sendbacklist" )
2225 return; 2225 return;
2226 if (foundUid.isEmpty()) 2226 if (foundUid.isEmpty())
2227 { 2227 {
2228 //find the uid of the person first 2228 //find the uid of the person first
2229 Addressee::List namelist; 2229 Addressee::List namelist;
2230 Addressee::List emaillist; 2230 Addressee::List emaillist;
2231 2231
2232 if (!name.isEmpty()) 2232 if (!name.isEmpty())
2233 namelist = mAddressBook->findByName( name ); 2233 namelist = mAddressBook->findByName( name );
2234 2234
2235 if (!email.isEmpty()) 2235 if (!email.isEmpty())
2236 emaillist = mAddressBook->findByEmail( email ); 2236 emaillist = mAddressBook->findByEmail( email );
2237 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2237 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2238 //check if we have a match in Namelist and Emaillist 2238 //check if we have a match in Namelist and Emaillist
2239 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2239 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2240 foundUid = emaillist[0].uid(); 2240 foundUid = emaillist[0].uid();
2241 } 2241 }
2242 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2242 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2243 foundUid = namelist[0].uid(); 2243 foundUid = namelist[0].uid();
2244 else 2244 else
2245 { 2245 {
2246 for (int i = 0; i < namelist.count(); i++) 2246 for (int i = 0; i < namelist.count(); i++)
2247 { 2247 {
2248 for (int j = 0; j < emaillist.count(); j++) 2248 for (int j = 0; j < emaillist.count(); j++)
2249 { 2249 {
2250 if (namelist[i] == emaillist[j]) 2250 if (namelist[i] == emaillist[j])
2251 { 2251 {
2252 foundUid = namelist[i].uid(); 2252 foundUid = namelist[i].uid();
2253 } 2253 }
2254 } 2254 }
2255 } 2255 }
2256 } 2256 }
2257 } 2257 }
2258 else 2258 else
2259 { 2259 {
2260 foundUid = uid; 2260 foundUid = uid;
2261 } 2261 }
2262 2262
2263 if (!foundUid.isEmpty()) 2263 if (!foundUid.isEmpty())
2264 { 2264 {
2265 2265
2266 // raise Ka/Pi if it is in the background 2266 // raise Ka/Pi if it is in the background
2267#ifndef DESKTOP_VERSION 2267#ifndef DESKTOP_VERSION
2268#ifndef KORG_NODCOP 2268#ifndef KORG_NODCOP
2269 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2269 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2270#endif 2270#endif
2271#endif 2271#endif
2272 2272
2273 mMainWindow->showMaximized(); 2273 mMainWindow->showMaximized();
2274 mMainWindow-> raise(); 2274 mMainWindow-> raise();
2275 2275
2276 mViewManager->setSelected( "", false); 2276 mViewManager->setSelected( "", false);
2277 mViewManager->refreshView( "" ); 2277 mViewManager->refreshView( "" );
2278 mViewManager->setSelected( foundUid, true ); 2278 mViewManager->setSelected( foundUid, true );
2279 mViewManager->refreshView( foundUid ); 2279 mViewManager->refreshView( foundUid );
2280 2280
2281 if ( !mMultipleViewsAtOnce ) 2281 if ( !mMultipleViewsAtOnce )
2282 { 2282 {
2283 setDetailsVisible( true ); 2283 setDetailsVisible( true );
2284 mActionDetails->setChecked(true); 2284 mActionDetails->setChecked(true);
2285 } 2285 }
2286 } 2286 }
2287} 2287}
2288 2288
2289void KABCore::whatsnew() 2289void KABCore::whatsnew()
2290{ 2290{
2291 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2291 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2292} 2292}
2293void KABCore::synchowto() 2293void KABCore::synchowto()
2294{ 2294{
2295 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2295 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2296} 2296}
2297 2297
2298void KABCore::faq() 2298void KABCore::faq()
2299{ 2299{
2300 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2300 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2301} 2301}
2302 2302
2303#include <libkcal/syncdefines.h> 2303#include <libkcal/syncdefines.h>
2304 2304
2305KABC::Addressee KABCore::getLastSyncAddressee() 2305KABC::Addressee KABCore::getLastSyncAddressee()
2306{ 2306{
2307 Addressee lse; 2307 Addressee lse;
2308 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2308 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2309 2309
2310 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2310 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2311 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2311 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2312 if (lse.isEmpty()) { 2312 if (lse.isEmpty()) {
2313 qDebug("Creating new last-syncAddressee "); 2313 qDebug("Creating new last-syncAddressee ");
2314 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2314 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2315 QString sum = ""; 2315 QString sum = "";
2316 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2316 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2317 sum = "E: "; 2317 sum = "E: ";
2318 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2318 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2319 lse.setRevision( mLastAddressbookSync ); 2319 lse.setRevision( mLastAddressbookSync );
2320 lse.setCategories( i18n("SyncEvent") ); 2320 lse.setCategories( i18n("SyncEvent") );
2321 mAddressBook->insertAddressee( lse ); 2321 mAddressBook->insertAddressee( lse );
2322 } 2322 }
2323 return lse; 2323 return lse;
2324} 2324}
2325int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2325int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2326{ 2326{
2327 2327
2328 //void setZaurusId(int id); 2328 //void setZaurusId(int id);
2329 // int zaurusId() const; 2329 // int zaurusId() const;
2330 // void setZaurusUid(int id); 2330 // void setZaurusUid(int id);
2331 // int zaurusUid() const; 2331 // int zaurusUid() const;
2332 // void setZaurusStat(int id); 2332 // void setZaurusStat(int id);
2333 // int zaurusStat() const; 2333 // int zaurusStat() const;
2334 // 0 equal 2334 // 0 equal
2335 // 1 take local 2335 // 1 take local
2336 // 2 take remote 2336 // 2 take remote
2337 // 3 cancel 2337 // 3 cancel
2338 QDateTime lastSync = mLastAddressbookSync; 2338 QDateTime lastSync = mLastAddressbookSync;
2339 QDateTime localMod = local->revision(); 2339 QDateTime localMod = local->revision();
2340 QDateTime remoteMod = remote->revision(); 2340 QDateTime remoteMod = remote->revision();
2341 2341
2342 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2342 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2343 2343
2344 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2344 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2345 bool remCh, locCh; 2345 bool remCh, locCh;
2346 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2346 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2347 2347
2348 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2348 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2349 locCh = ( localMod > mLastAddressbookSync ); 2349 locCh = ( localMod > mLastAddressbookSync );
2350 if ( !remCh && ! locCh ) { 2350 if ( !remCh && ! locCh ) {
2351 //qDebug("both not changed "); 2351 //qDebug("both not changed ");
2352 lastSync = localMod.addDays(1); 2352 lastSync = localMod.addDays(1);
2353 if ( mode <= SYNC_PREF_ASK ) 2353 if ( mode <= SYNC_PREF_ASK )
2354 return 0; 2354 return 0;
2355 } else { 2355 } else {
2356 if ( locCh ) { 2356 if ( locCh ) {
2357 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2357 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2358 lastSync = localMod.addDays( -1 ); 2358 lastSync = localMod.addDays( -1 );
2359 if ( !remCh ) 2359 if ( !remCh )
2360 remoteMod =( lastSync.addDays( -1 ) ); 2360 remoteMod =( lastSync.addDays( -1 ) );
2361 } else { 2361 } else {
2362 //qDebug(" not loc changed "); 2362 //qDebug(" not loc changed ");
2363 lastSync = localMod.addDays( 1 ); 2363 lastSync = localMod.addDays( 1 );
2364 if ( remCh ) 2364 if ( remCh )
2365 remoteMod =( lastSync.addDays( 1 ) ); 2365 remoteMod =( lastSync.addDays( 1 ) );
2366 2366
2367 } 2367 }
2368 } 2368 }
2369 full = true; 2369 full = true;
2370 if ( mode < SYNC_PREF_ASK ) 2370 if ( mode < SYNC_PREF_ASK )
2371 mode = SYNC_PREF_ASK; 2371 mode = SYNC_PREF_ASK;
2372 } else { 2372 } else {
2373 if ( localMod == remoteMod ) 2373 if ( localMod == remoteMod )
2374 return 0; 2374 return 0;
2375 2375
2376 } 2376 }
2377 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2377 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2378 2378
2379 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 2379 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2380 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2380 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2381 //full = true; //debug only 2381 //full = true; //debug only
2382 if ( full ) { 2382 if ( full ) {
2383 bool equ = ( (*local) == (*remote) ); 2383 bool equ = ( (*local) == (*remote) );
2384 if ( equ ) { 2384 if ( equ ) {
2385 //qDebug("equal "); 2385 //qDebug("equal ");
2386 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2386 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2387 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2387 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2388 } 2388 }
2389 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2389 if ( mode < SYNC_PREF_FORCE_LOCAL )
2390 return 0; 2390 return 0;
2391 2391
2392 }//else //debug only 2392 }//else //debug only
2393 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2393 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2394 } 2394 }
2395 int result; 2395 int result;
2396 bool localIsNew; 2396 bool localIsNew;
2397 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2397 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2398 2398
2399 if ( full && mode < SYNC_PREF_NEWEST ) 2399 if ( full && mode < SYNC_PREF_NEWEST )
2400 mode = SYNC_PREF_ASK; 2400 mode = SYNC_PREF_ASK;
2401 2401
2402 switch( mode ) { 2402 switch( mode ) {
2403 case SYNC_PREF_LOCAL: 2403 case SYNC_PREF_LOCAL:
2404 if ( lastSync > remoteMod ) 2404 if ( lastSync > remoteMod )
2405 return 1; 2405 return 1;
2406 if ( lastSync > localMod ) 2406 if ( lastSync > localMod )
2407 return 2; 2407 return 2;
2408 return 1; 2408 return 1;
2409 break; 2409 break;
2410 case SYNC_PREF_REMOTE: 2410 case SYNC_PREF_REMOTE:
2411 if ( lastSync > remoteMod ) 2411 if ( lastSync > remoteMod )
2412 return 1; 2412 return 1;
2413 if ( lastSync > localMod ) 2413 if ( lastSync > localMod )
2414 return 2; 2414 return 2;
2415 return 2; 2415 return 2;
2416 break; 2416 break;
2417 case SYNC_PREF_NEWEST: 2417 case SYNC_PREF_NEWEST:
2418 if ( localMod > remoteMod ) 2418 if ( localMod > remoteMod )
2419 return 1; 2419 return 1;
2420 else 2420 else
2421 return 2; 2421 return 2;
2422 break; 2422 break;
2423 case SYNC_PREF_ASK: 2423 case SYNC_PREF_ASK:
2424 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2424 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2425 if ( lastSync > remoteMod ) 2425 if ( lastSync > remoteMod )
2426 return 1; 2426 return 1;
2427 if ( lastSync > localMod ) 2427 if ( lastSync > localMod )
2428 return 2; 2428 return 2;
2429 localIsNew = localMod >= remoteMod; 2429 localIsNew = localMod >= remoteMod;
2430 //qDebug("conflict! ************************************** "); 2430 //qDebug("conflict! ************************************** ");
2431 { 2431 {
2432 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2432 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2433 result = acd.executeD(localIsNew); 2433 result = acd.executeD(localIsNew);
2434 return result; 2434 return result;
2435 } 2435 }
2436 break; 2436 break;
2437 case SYNC_PREF_FORCE_LOCAL: 2437 case SYNC_PREF_FORCE_LOCAL:
2438 return 1; 2438 return 1;
2439 break; 2439 break;
2440 case SYNC_PREF_FORCE_REMOTE: 2440 case SYNC_PREF_FORCE_REMOTE:
2441 return 2; 2441 return 2;
2442 break; 2442 break;
2443 2443
2444 default: 2444 default:
2445 // SYNC_PREF_TAKE_BOTH not implemented 2445 // SYNC_PREF_TAKE_BOTH not implemented
2446 break; 2446 break;
2447 } 2447 }
2448 return 0; 2448 return 0;
2449} 2449}
2450 2450
2451 2451
2452bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2452bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2453{ 2453{
2454 bool syncOK = true; 2454 bool syncOK = true;
2455 int addedAddressee = 0; 2455 int addedAddressee = 0;
2456 int addedAddresseeR = 0; 2456 int addedAddresseeR = 0;
2457 int deletedAddresseeR = 0; 2457 int deletedAddresseeR = 0;
2458 int deletedAddresseeL = 0; 2458 int deletedAddresseeL = 0;
2459 int changedLocal = 0; 2459 int changedLocal = 0;
2460 int changedRemote = 0; 2460 int changedRemote = 0;
2461 2461
2462 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2462 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2463 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2463 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2464 2464
2465 //QPtrList<Addressee> el = local->rawAddressees(); 2465 //QPtrList<Addressee> el = local->rawAddressees();
2466 Addressee addresseeR; 2466 Addressee addresseeR;
2467 QString uid; 2467 QString uid;
2468 int take; 2468 int take;
2469 Addressee addresseeL; 2469 Addressee addresseeL;
2470 Addressee addresseeRSync; 2470 Addressee addresseeRSync;
2471 Addressee addresseeLSync; 2471 Addressee addresseeLSync;
2472 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2472 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2473 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2473 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2474 bool fullDateRange = false; 2474 bool fullDateRange = false;
2475 local->resetTempSyncStat(); 2475 local->resetTempSyncStat();
2476 mLastAddressbookSync = QDateTime::currentDateTime(); 2476 mLastAddressbookSync = QDateTime::currentDateTime();
2477 QDateTime modifiedCalendar = mLastAddressbookSync;; 2477 QDateTime modifiedCalendar = mLastAddressbookSync;;
2478 addresseeLSync = getLastSyncAddressee(); 2478 addresseeLSync = getLastSyncAddressee();
2479 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2479 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2480 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2480 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2481 if ( !addresseeR.isEmpty() ) { 2481 if ( !addresseeR.isEmpty() ) {
2482 addresseeRSync = addresseeR; 2482 addresseeRSync = addresseeR;
2483 remote->removeAddressee(addresseeR ); 2483 remote->removeAddressee(addresseeR );
2484 2484
2485 } else { 2485 } else {
2486 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2486 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2487 addresseeRSync = addresseeLSync ; 2487 addresseeRSync = addresseeLSync ;
2488 } else { 2488 } else {
2489 qDebug("FULLDATE 1"); 2489 qDebug("FULLDATE 1");
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 ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2555 //qDebug("take %d %s ", take, inL.summary().latin1()); 2555 //qDebug("take %d %s ", take, inL.summary().latin1());
2556 if ( take == 3 ) 2556 if ( take == 3 )
2557 return false; 2557 return false;
2558 if ( take == 1 ) {// take local 2558 if ( take == 1 ) {// take local
2559 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2559 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2560 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2560 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2561 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2561 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2562 local->insertAddressee( inL, false ); 2562 local->insertAddressee( inL, false );
2563 idS = inR.externalUID(); 2563 idS = inR.externalUID();
2564 OidS = inR.originalExternalUID(); 2564 OidS = inR.originalExternalUID();
2565 } 2565 }
2566 else 2566 else
2567 idS = inR.IDStr(); 2567 idS = inR.IDStr();
2568 remote->removeAddressee( inR ); 2568 remote->removeAddressee( inR );
2569 inR = inL; 2569 inR = inL;
2570 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2570 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2571 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2571 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2572 inR.setOriginalExternalUID( OidS ); 2572 inR.setOriginalExternalUID( OidS );
2573 inR.setExternalUID( idS ); 2573 inR.setExternalUID( idS );
2574 } else { 2574 } else {
2575 inR.setIDStr( idS ); 2575 inR.setIDStr( idS );
2576 } 2576 }
2577 inR.setResource( 0 ); 2577 inR.setResource( 0 );
2578 remote->insertAddressee( inR , false); 2578 remote->insertAddressee( inR , false);
2579 ++changedRemote; 2579 ++changedRemote;
2580 } else { // take == 2 take remote 2580 } else { // take == 2 take remote
2581 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2581 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2582 if ( inR.revision().date().year() < 2004 ) 2582 if ( inR.revision().date().year() < 2004 )
2583 inR.setRevision( modifiedCalendar ); 2583 inR.setRevision( modifiedCalendar );
2584 } 2584 }
2585 idS = inL.IDStr(); 2585 idS = inL.IDStr();
2586 local->removeAddressee( inL ); 2586 local->removeAddressee( inL );
2587 inL = inR; 2587 inL = inR;
2588 inL.setIDStr( idS ); 2588 inL.setIDStr( idS );
2589 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2589 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2590 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2590 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2591 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2591 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2592 } 2592 }
2593 inL.setResource( 0 ); 2593 inL.setResource( 0 );
2594 local->insertAddressee( inL , false ); 2594 local->insertAddressee( inL , false );
2595 ++changedLocal; 2595 ++changedLocal;
2596 } 2596 }
2597 } 2597 }
2598 } else { // no conflict 2598 } else { // no conflict
2599 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2599 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2600 QString des = addresseeLSync.note(); 2600 QString des = addresseeLSync.note();
2601 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2601 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2602 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2602 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2603 remote->insertAddressee( inR, false ); 2603 remote->insertAddressee( inR, false );
2604 ++deletedAddresseeR; 2604 ++deletedAddresseeR;
2605 } else { 2605 } else {
2606 inR.setRevision( modifiedCalendar ); 2606 inR.setRevision( modifiedCalendar );
2607 remote->insertAddressee( inR, false ); 2607 remote->insertAddressee( inR, false );
2608 inL = inR; 2608 inL = inR;
2609 inL.setResource( 0 ); 2609 inL.setResource( 0 );
2610 local->insertAddressee( inL , false); 2610 local->insertAddressee( inL , false);
2611 ++addedAddressee; 2611 ++addedAddressee;
2612 } 2612 }
2613 } else { 2613 } else {
2614 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2614 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2615 inR.setRevision( modifiedCalendar ); 2615 inR.setRevision( modifiedCalendar );
2616 remote->insertAddressee( inR, false ); 2616 remote->insertAddressee( inR, false );
2617 inR.setResource( 0 ); 2617 inR.setResource( 0 );
2618 local->insertAddressee( inR, false ); 2618 local->insertAddressee( inR, false );
2619 ++addedAddressee; 2619 ++addedAddressee;
2620 } else { 2620 } else {
2621 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2621 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2622 remote->removeAddressee( inR ); 2622 remote->removeAddressee( inR );
2623 ++deletedAddresseeR; 2623 ++deletedAddresseeR;
2624 } 2624 }
2625 } 2625 }
2626 } 2626 }
2627 } 2627 }
2628 ++incCounter; 2628 ++incCounter;
2629 } 2629 }
2630 er.clear(); 2630 er.clear();
2631 QStringList el = local->uidList(); 2631 QStringList el = local->uidList();
2632 modulo = (el.count()/10)+1; 2632 modulo = (el.count()/10)+1;
2633 2633
2634 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2634 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2635 incCounter = 0; 2635 incCounter = 0;
2636 while ( incCounter < el.count()) { 2636 while ( incCounter < el.count()) {
2637 qApp->processEvents(); 2637 qApp->processEvents();
2638 if (syncManager->isProgressBarCanceled()) 2638 if (syncManager->isProgressBarCanceled())
2639 return false; 2639 return false;
2640 if ( incCounter % modulo == 0 ) 2640 if ( incCounter % modulo == 0 )
2641 syncManager->showProgressBar(incCounter); 2641 syncManager->showProgressBar(incCounter);
2642 uid = el[ incCounter ]; 2642 uid = el[ incCounter ];
2643 bool skipIncidence = false; 2643 bool skipIncidence = false;
2644 if ( uid.left(19) == QString("last-syncAddressee-") ) 2644 if ( uid.left(19) == QString("last-syncAddressee-") )
2645 skipIncidence = true; 2645 skipIncidence = true;
2646 if ( !skipIncidence ) { 2646 if ( !skipIncidence ) {
2647 inL = local->findByUid( uid ); 2647 inL = local->findByUid( uid );
2648 inR = remote->findByUid( uid ); 2648 inR = remote->findByUid( uid );
2649 if ( inR.isEmpty() ) { 2649 if ( inR.isEmpty() ) {
2650 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2650 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2651 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2651 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2652 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2652 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2653 local->removeAddressee( inL ); 2653 local->removeAddressee( inL );
2654 ++deletedAddresseeL; 2654 ++deletedAddresseeL;
2655 } else { 2655 } else {
2656 if ( ! syncManager->mWriteBackExistingOnly ) { 2656 if ( ! syncManager->mWriteBackExistingOnly ) {
2657 inL.removeID(mCurrentSyncDevice ); 2657 inL.removeID(mCurrentSyncDevice );
2658 ++addedAddresseeR; 2658 ++addedAddresseeR;
2659 inL.setRevision( modifiedCalendar ); 2659 inL.setRevision( modifiedCalendar );
2660 local->insertAddressee( inL, false ); 2660 local->insertAddressee( inL, false );
2661 inR = inL; 2661 inR = inL;
2662 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2662 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2663 inR.setResource( 0 ); 2663 inR.setResource( 0 );
2664 remote->insertAddressee( inR, false ); 2664 remote->insertAddressee( inR, false );
2665 } 2665 }
2666 } 2666 }
2667 } else { 2667 } else {
2668 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2668 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2669 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2669 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2670 local->removeAddressee( inL ); 2670 local->removeAddressee( inL );
2671 ++deletedAddresseeL; 2671 ++deletedAddresseeL;
2672 } else { 2672 } else {
2673 if ( ! syncManager->mWriteBackExistingOnly ) { 2673 if ( ! syncManager->mWriteBackExistingOnly ) {
2674 ++addedAddresseeR; 2674 ++addedAddresseeR;
2675 inL.setRevision( modifiedCalendar ); 2675 inL.setRevision( modifiedCalendar );
2676 local->insertAddressee( inL, false ); 2676 local->insertAddressee( inL, false );
2677 inR = inL; 2677 inR = inL;
2678 inR.setResource( 0 ); 2678 inR.setResource( 0 );
2679 remote->insertAddressee( inR, false ); 2679 remote->insertAddressee( inR, false );
2680 } 2680 }
2681 } 2681 }
2682 } 2682 }
2683 } 2683 }
2684 } 2684 }
2685 ++incCounter; 2685 ++incCounter;
2686 } 2686 }
2687 el.clear(); 2687 el.clear();
2688 syncManager->hideProgressBar(); 2688 syncManager->hideProgressBar();
2689 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2689 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2690 // get rid of micro seconds 2690 // get rid of micro seconds
2691 QTime t = mLastAddressbookSync.time(); 2691 QTime t = mLastAddressbookSync.time();
2692 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2692 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2693 addresseeLSync.setRevision( mLastAddressbookSync ); 2693 addresseeLSync.setRevision( mLastAddressbookSync );
2694 addresseeRSync.setRevision( mLastAddressbookSync ); 2694 addresseeRSync.setRevision( mLastAddressbookSync );
2695 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2695 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2696 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2696 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2697 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2697 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2698 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2698 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2699 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2699 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2700 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2700 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2701 addresseeRSync.setNote( "" ) ; 2701 addresseeRSync.setNote( "" ) ;
2702 addresseeLSync.setNote( "" ); 2702 addresseeLSync.setNote( "" );
2703 2703
2704 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2704 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2705 remote->insertAddressee( addresseeRSync, false ); 2705 remote->insertAddressee( addresseeRSync, false );
2706 local->insertAddressee( addresseeLSync, false ); 2706 local->insertAddressee( addresseeLSync, false );
2707 QString mes; 2707 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 ); 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 );
2709 if ( syncManager->mShowSyncSummary ) { 2709 if ( syncManager->mShowSyncSummary ) {
2710 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2710 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2711 } 2711 }
2712 qDebug( mes ); 2712 qDebug( mes );
2713 return syncOK; 2713 return syncOK;
2714} 2714}
2715 2715
2716 2716
2717//this is a overwritten callbackmethods from the syncinterface 2717//this is a overwritten callbackmethods from the syncinterface
2718bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2718bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2719{ 2719{
2720 2720
2721 //pending prepare addresseeview for output 2721 //pending prepare addresseeview for output
2722 //pending detect, if remote file has REV field. if not switch to external sync 2722 //pending detect, if remote file has REV field. if not switch to external sync
2723 mGlobalSyncMode = SYNC_MODE_NORMAL; 2723 mGlobalSyncMode = SYNC_MODE_NORMAL;
2724 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2724 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2725 2725
2726 AddressBook abLocal(filename,"syncContact"); 2726 AddressBook abLocal(filename,"syncContact");
2727 bool syncOK = false; 2727 bool syncOK = false;
2728 if ( abLocal.load() ) { 2728 if ( abLocal.load() ) {
2729 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2729 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2730 bool external = false; 2730 bool external = false;
2731 bool isXML = false; 2731 bool isXML = false;
2732 if ( filename.right(4) == ".xml") { 2732 if ( filename.right(4) == ".xml") {
2733 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2733 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2734 isXML = true; 2734 isXML = true;
2735 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2735 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2736 } else { 2736 } else {
2737 external = !manager->mIsKapiFile; 2737 external = !manager->mIsKapiFile;
2738 if ( external ) { 2738 if ( external ) {
2739 qDebug("Setting vcf mode to external "); 2739 qDebug("Setting vcf mode to external ");
2740 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2740 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2741 AddressBook::Iterator it; 2741 AddressBook::Iterator it;
2742 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2742 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2743 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2743 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2744 (*it).computeCsum( mCurrentSyncDevice ); 2744 (*it).computeCsum( mCurrentSyncDevice );
2745 } 2745 }
2746 } 2746 }
2747 } 2747 }
2748 //AddressBook::Iterator it; 2748 //AddressBook::Iterator it;
2749 //QStringList vcards; 2749 //QStringList vcards;
2750 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2750 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2751 // qDebug("Name %s ", (*it).familyName().latin1()); 2751 // qDebug("Name %s ", (*it).familyName().latin1());
2752 //} 2752 //}
2753 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2753 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2754 if ( syncOK ) { 2754 if ( syncOK ) {
2755 if ( syncManager->mWriteBackFile ) 2755 if ( syncManager->mWriteBackFile )
2756 { 2756 {
2757 if ( external ) 2757 if ( external )
2758 abLocal.removeSyncAddressees( !isXML); 2758 abLocal.removeSyncAddressees( !isXML);
2759 qDebug("Saving remote AB "); 2759 qDebug("Saving remote AB ");
2760 if ( ! abLocal.saveAB()) 2760 if ( ! abLocal.saveAB())
2761 qDebug("Error writing back AB to file "); 2761 qDebug("Error writing back AB to file ");
2762 if ( isXML ) { 2762 if ( isXML ) {
2763 // afterwrite processing 2763 // afterwrite processing
2764 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2764 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2765 } 2765 }
2766 } 2766 }
2767 } 2767 }
2768 setModified(); 2768 setModified();
2769 2769
2770 } 2770 }
2771 if ( syncOK ) 2771 if ( syncOK )
2772 mViewManager->refreshView(); 2772 mViewManager->refreshView();
2773 return syncOK; 2773 return syncOK;
2774 2774
2775} 2775}
2776 2776
2777 2777
2778//this is a overwritten callbackmethods from the syncinterface 2778//this is a overwritten callbackmethods from the syncinterface
2779bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2779bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2780{ 2780{
2781 if ( resource == "phone" ) 2781 if ( resource == "phone" )
2782 return syncPhone(); 2782 return syncPhone();
2783 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2783 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2784 2784
2785 AddressBook abLocal( resource,"syncContact"); 2785 AddressBook abLocal( resource,"syncContact");
2786 bool syncOK = false; 2786 bool syncOK = false;
2787 if ( abLocal.load() ) { 2787 if ( abLocal.load() ) {
2788 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2788 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2789 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2789 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2790 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2790 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
2791 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2791 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2792 if ( syncOK ) { 2792 if ( syncOK ) {
2793 if ( syncManager->mWriteBackFile ) { 2793 if ( syncManager->mWriteBackFile ) {
2794 abLocal.removeSyncAddressees( false ); 2794 abLocal.removeSyncAddressees( false );
2795 abLocal.saveAB(); 2795 abLocal.saveAB();
2796 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2796 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2797 } 2797 }
2798 } 2798 }
2799 setModified(); 2799 setModified();
2800 } 2800 }
2801 if ( syncOK ) 2801 if ( syncOK )
2802 mViewManager->refreshView(); 2802 mViewManager->refreshView();
2803 return syncOK; 2803 return syncOK;
2804 2804
2805} 2805}
2806void KABCore::message( QString m ) 2806void KABCore::message( QString m )
2807{ 2807{
2808 2808
2809 topLevelWidget()->setCaption( m ); 2809 topLevelWidget()->setCaption( m );
2810 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); 2810 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
2811} 2811}
2812bool KABCore::syncPhone() 2812bool KABCore::syncPhone()
2813{ 2813{
2814 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2814 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2815 QString fileName; 2815 QString fileName;
2816#ifdef _WIN32_ 2816#ifdef _WIN32_
2817 fileName = locateLocal("tmp", "phonefile.vcf"); 2817 fileName = locateLocal("tmp", "phonefile.vcf");
2818#else 2818#else
2819 fileName = "/tmp/phonefile.vcf"; 2819 fileName = "/tmp/phonefile.vcf";
2820#endif 2820#endif
2821 if ( !PhoneAccess::readFromPhone( fileName) ) { 2821 if ( !PhoneAccess::readFromPhone( fileName) ) {
2822 message(i18n("Phone access failed!")); 2822 message(i18n("Phone access failed!"));
2823 return false; 2823 return false;
2824 } 2824 }
2825 AddressBook abLocal( fileName,"syncContact"); 2825 AddressBook abLocal( fileName,"syncContact");
2826 bool syncOK = false; 2826 bool syncOK = false;
2827 { 2827 {
2828 abLocal.importFromFile( fileName ); 2828 abLocal.importFromFile( fileName );
2829 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2829 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
2830 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2830 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2831 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 2831 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
2832 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2832 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2833 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2833 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2834 if ( syncOK ) { 2834 if ( syncOK ) {
2835 if ( syncManager->mWriteBackFile ) { 2835 if ( syncManager->mWriteBackFile ) {
2836 abLocal.removeSyncAddressees( true ); 2836 abLocal.removeSyncAddressees( true );
2837 abLocal.saveABphone( fileName ); 2837 abLocal.saveABphone( fileName );
2838 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 2838 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
2839 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 2839 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
2840 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2840 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2841 } 2841 }
2842 } 2842 }
2843 setModified(); 2843 setModified();
2844 } 2844 }
2845 if ( syncOK ) 2845 if ( syncOK )
2846 mViewManager->refreshView(); 2846 mViewManager->refreshView();
2847 return syncOK; 2847 return syncOK;
2848} 2848}
2849void KABCore::getFile( bool success ) 2849void KABCore::getFile( bool success )
2850{ 2850{
2851 if ( ! success ) { 2851 if ( ! success ) {
2852 message( i18n("Error receiving file. Nothing changed!") ); 2852 message( i18n("Error receiving file. Nothing changed!") );
2853 return; 2853 return;
2854 } 2854 }
2855 mAddressBook->importFromFile( sentSyncFile() , false, true ); 2855 mAddressBook->importFromFile( sentSyncFile() , false, true );
2856 message( i18n("Pi-Sync successful!") ); 2856 message( i18n("Pi-Sync successful!") );
2857 mViewManager->refreshView(); 2857 mViewManager->refreshView();
2858} 2858}
2859void KABCore::syncFileRequest() 2859void KABCore::syncFileRequest()
2860{ 2860{
2861 mAddressBook->export2File( sentSyncFile() ); 2861 mAddressBook->export2File( sentSyncFile() );
2862} 2862}
2863QString KABCore::sentSyncFile() 2863QString KABCore::sentSyncFile()
2864{ 2864{
2865#ifdef _WIN32_ 2865#ifdef _WIN32_
2866 return locateLocal( "tmp", "copysyncab.vcf" ); 2866 return locateLocal( "tmp", "copysyncab.vcf" );
2867#else 2867#else
2868 return QString( "/tmp/copysyncab.vcf" ); 2868 return QString( "/tmp/copysyncab.vcf" );
2869#endif 2869#endif
2870} 2870}
2871 2871
2872void KABCore::setCaptionBack() 2872void KABCore::setCaptionBack()
2873{ 2873{
2874 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2874 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2875} 2875}