summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
authorzautrix <zautrix>2004-09-20 00:12:42 (UTC)
committer zautrix <zautrix>2004-09-20 00:12:42 (UTC)
commitb01b669d88fa195261d29ecf73b1c69e608a5ebc (patch) (unidiff)
treec0e79d45242a764b49470d07a9c95be156c121cc /kabc/addressee.cpp
parent3da2cfeab2edbe64a17251662e56668fe143f7a3 (diff)
downloadkdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.zip
kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.tar.gz
kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.tar.bz2
more AB sync
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index fda62f1..e241281 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -50,97 +50,97 @@ struct Addressee::AddresseeData : public KShared
50 QString name; 50 QString name;
51 QString formattedName; 51 QString formattedName;
52 QString familyName; 52 QString familyName;
53 QString givenName; 53 QString givenName;
54 QString additionalName; 54 QString additionalName;
55 QString prefix; 55 QString prefix;
56 QString suffix; 56 QString suffix;
57 QString nickName; 57 QString nickName;
58 QDateTime birthday; 58 QDateTime birthday;
59 QString mailer; 59 QString mailer;
60 TimeZone timeZone; 60 TimeZone timeZone;
61 Geo geo; 61 Geo geo;
62 QString title; 62 QString title;
63 QString role; 63 QString role;
64 QString organization; 64 QString organization;
65 QString note; 65 QString note;
66 QString productId; 66 QString productId;
67 QDateTime revision; 67 QDateTime revision;
68 QString sortString; 68 QString sortString;
69 QString externalUID; 69 QString externalUID;
70 QString originalExternalUID; 70 QString originalExternalUID;
71 KURL url; 71 KURL url;
72 Secrecy secrecy; 72 Secrecy secrecy;
73 Picture logo; 73 Picture logo;
74 Picture photo; 74 Picture photo;
75 Sound sound; 75 Sound sound;
76 Agent agent; 76 Agent agent;
77 QString mExternalId; 77 QString mExternalId;
78 PhoneNumber::List phoneNumbers; 78 PhoneNumber::List phoneNumbers;
79 Address::List addresses; 79 Address::List addresses;
80 Key::List keys; 80 Key::List keys;
81 QStringList emails; 81 QStringList emails;
82 QStringList categories; 82 QStringList categories;
83 QStringList custom; 83 QStringList custom;
84 int mTempSyncStat; 84 int mTempSyncStat;
85 Resource *resource; 85 Resource *resource;
86 86
87 bool empty :1; 87 bool empty :1;
88 bool changed :1; 88 bool changed :1;
89}; 89};
90 90
91Addressee::Addressee() 91Addressee::Addressee()
92{ 92{
93 mData = new AddresseeData; 93 mData = new AddresseeData;
94 mData->empty = true; 94 mData->empty = true;
95 mData->changed = false; 95 mData->changed = false;
96 mData->resource = 0; 96 mData->resource = 0;
97 mData->mExternalId = ":"; 97 mData->mExternalId = ":";
98 mData->revision = QDateTime ( QDate( 2004,1,1)); 98 mData->revision = QDateTime ( QDate( 2003,1,1));
99 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 99 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
100} 100}
101 101
102Addressee::~Addressee() 102Addressee::~Addressee()
103{ 103{
104} 104}
105 105
106Addressee::Addressee( const Addressee &a ) 106Addressee::Addressee( const Addressee &a )
107{ 107{
108 mData = a.mData; 108 mData = a.mData;
109} 109}
110 110
111Addressee &Addressee::operator=( const Addressee &a ) 111Addressee &Addressee::operator=( const Addressee &a )
112{ 112{
113 mData = a.mData; 113 mData = a.mData;
114 return (*this); 114 return (*this);
115} 115}
116 116
117Addressee Addressee::copy() 117Addressee Addressee::copy()
118{ 118{
119 Addressee a; 119 Addressee a;
120 *(a.mData) = *mData; 120 *(a.mData) = *mData;
121 return a; 121 return a;
122} 122}
123 123
124void Addressee::detach() 124void Addressee::detach()
125{ 125{
126 if ( mData.count() == 1 ) return; 126 if ( mData.count() == 1 ) return;
127 *this = copy(); 127 *this = copy();
128} 128}
129 129
130bool Addressee::operator==( const Addressee &a ) const 130bool Addressee::operator==( const Addressee &a ) const
131{ 131{
132 if ( uid() != a.uid() ) return false; 132 if ( uid() != a.uid() ) return false;
133 if ( mData->name != a.mData->name ) return false; 133 if ( mData->name != a.mData->name ) return false;
134 if ( mData->formattedName != a.mData->formattedName ) return false; 134 if ( mData->formattedName != a.mData->formattedName ) return false;
135 if ( mData->familyName != a.mData->familyName ) return false; 135 if ( mData->familyName != a.mData->familyName ) return false;
136 if ( mData->givenName != a.mData->givenName ) return false; 136 if ( mData->givenName != a.mData->givenName ) return false;
137 if ( mData->additionalName != a.mData->additionalName ) return false; 137 if ( mData->additionalName != a.mData->additionalName ) return false;
138 if ( mData->prefix != a.mData->prefix ) return false; 138 if ( mData->prefix != a.mData->prefix ) return false;
139 if ( mData->suffix != a.mData->suffix ) return false; 139 if ( mData->suffix != a.mData->suffix ) return false;
140 if ( mData->nickName != a.mData->nickName ) return false; 140 if ( mData->nickName != a.mData->nickName ) return false;
141 if ( mData->birthday != a.mData->birthday ) return false; 141 if ( mData->birthday != a.mData->birthday ) return false;
142 if ( mData->mailer != a.mData->mailer ) return false; 142 if ( mData->mailer != a.mData->mailer ) return false;
143 if ( mData->timeZone != a.mData->timeZone ) return false; 143 if ( mData->timeZone != a.mData->timeZone ) return false;
144 if ( mData->geo != a.mData->geo ) return false; 144 if ( mData->geo != a.mData->geo ) return false;
145 if ( mData->title != a.mData->title ) return false; 145 if ( mData->title != a.mData->title ) return false;
146 if ( mData->role != a.mData->role ) return false; 146 if ( mData->role != a.mData->role ) return false;
@@ -263,179 +263,183 @@ void Addressee::computeCsum(const QString &dev)
263 l.append( t[iii] ); 263 l.append( t[iii] );
264 KABC::Address::List::Iterator addressIter; 264 KABC::Address::List::Iterator addressIter;
265 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 265 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
266 ++addressIter ) { 266 ++addressIter ) {
267 t = (*addressIter).asList(); 267 t = (*addressIter).asList();
268 t.sort(); 268 t.sort();
269 for ( iii = 0; iii < t.count(); ++iii) 269 for ( iii = 0; iii < t.count(); ++iii)
270 l.append( t[iii] ); 270 l.append( t[iii] );
271 } 271 }
272 uint cs = getCsum4List(l); 272 uint cs = getCsum4List(l);
273 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 273 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
274 setCsum( dev, QString::number (cs )); 274 setCsum( dev, QString::number (cs ));
275} 275}
276 276
277void Addressee::mergeContact( const Addressee& ad ) 277void Addressee::mergeContact( const Addressee& ad )
278{ 278{
279 279
280 detach(); 280 detach();
281 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 281 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
282 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 282 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
283 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 283 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
284 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 284 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
285 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 285 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
286 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 286 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
287 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 287 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
288 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 288 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
289 if ( !mData->birthday.isValid() ) 289 if ( !mData->birthday.isValid() )
290 if ( ad.mData->birthday.isValid()) 290 if ( ad.mData->birthday.isValid())
291 mData->birthday = ad.mData->birthday; 291 mData->birthday = ad.mData->birthday;
292 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 292 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
293 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 293 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
294 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 294 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
295 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 295 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
296 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 296 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
297 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 297 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
298 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 298 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
299 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 299 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
300 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 300 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
301 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 301 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
302 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 302 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
303 303
304 // pending: 304 // pending:
305 // merging phonenumbers 305 // merging phonenumbers
306 // merging addresses 306 // merging addresses
307 // merging emails; 307 // merging emails;
308 // merging categories; 308 // merging categories;
309 // merging custom; 309 // merging custom;
310 // merging keys 310 // merging keys
311 qDebug("merge contact %s ", ad.uid().latin1());
312 setUid( ad.uid() );
311} 313}
312 314
313void Addressee::removeID(const QString &prof) 315void Addressee::removeID(const QString &prof)
314{ 316{
315 detach(); 317 detach();
316 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 318 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
317 319
318} 320}
319void Addressee::setID( const QString & prof , const QString & id ) 321void Addressee::setID( const QString & prof , const QString & id )
320{ 322{
321 detach(); 323 detach();
322 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 324 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
323 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 325 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
324} 326}
325void Addressee::setTempSyncStat( int id ) 327void Addressee::setTempSyncStat( int id )
326{ 328{
327 if ( mData->mTempSyncStat == id ) return; 329 if ( mData->mTempSyncStat == id ) return;
328 detach(); 330 detach();
329 mData->mTempSyncStat = id; 331 mData->mTempSyncStat = id;
330} 332}
331int Addressee::tempSyncStat() const 333int Addressee::tempSyncStat() const
332{ 334{
333 return mData->mTempSyncStat; 335 return mData->mTempSyncStat;
334} 336}
335 337
336QString Addressee::getID( const QString & prof) 338QString Addressee::getID( const QString & prof)
337{ 339{
338 return KIdManager::getId ( mData->mExternalId, prof ); 340 return KIdManager::getId ( mData->mExternalId, prof );
339} 341}
340 342
341void Addressee::setCsum( const QString & prof , const QString & id ) 343void Addressee::setCsum( const QString & prof , const QString & id )
342{ 344{
343 detach(); 345 detach();
344 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 346 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
345 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 347 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
346 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 348 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
347} 349}
348 350
349QString Addressee::getCsum( const QString & prof) 351QString Addressee::getCsum( const QString & prof)
350{ 352{
351 return KIdManager::getCsum ( mData->mExternalId, prof ); 353 return KIdManager::getCsum ( mData->mExternalId, prof );
352} 354}
353 355
354void Addressee::setIDStr( const QString & s ) 356void Addressee::setIDStr( const QString & s )
355{ 357{
356 detach(); 358 detach();
357 mData->mExternalId = s; 359 mData->mExternalId = s;
358} 360}
359 361
360QString Addressee::IDStr() const 362QString Addressee::IDStr() const
361{ 363{
362 return mData->mExternalId; 364 return mData->mExternalId;
363} 365}
364 366
365void Addressee::setExternalUID( const QString &id ) 367void Addressee::setExternalUID( const QString &id )
366{ 368{
367 if ( id == mData->externalUID ) return; 369 if ( id == mData->externalUID ) return;
368 detach(); 370 detach();
369 mData->empty = false; 371 mData->empty = false;
370 mData->externalUID = id; 372 mData->externalUID = id;
371} 373}
372 374
373QString Addressee::externalUID() const 375QString Addressee::externalUID() const
374{ 376{
375 return mData->externalUID; 377 return mData->externalUID;
376} 378}
377void Addressee::setOriginalExternalUID( const QString &id ) 379void Addressee::setOriginalExternalUID( const QString &id )
378{ 380{
379 if ( id == mData->originalExternalUID ) return; 381 if ( id == mData->originalExternalUID ) return;
380 detach(); 382 detach();
381 mData->empty = false; 383 mData->empty = false;
384 qDebug("*******Set orig uid %s ", id.latin1());
382 mData->originalExternalUID = id; 385 mData->originalExternalUID = id;
383} 386}
384 387
385QString Addressee::originalExternalUID() const 388QString Addressee::originalExternalUID() const
386{ 389{
387 return mData->originalExternalUID; 390 return mData->originalExternalUID;
388} 391}
389 392
390void Addressee::setUid( const QString &id ) 393void Addressee::setUid( const QString &id )
391{ 394{
392 if ( id == mData->uid ) return; 395 if ( id == mData->uid ) return;
393 detach(); 396 detach();
397 qDebug("****setuid %s ", id.latin1());
394 mData->empty = false; 398 mData->empty = false;
395 mData->uid = id; 399 mData->uid = id;
396} 400}
397 401
398QString Addressee::uid() const 402QString Addressee::uid() const
399{ 403{
400 if ( mData->uid.isEmpty() ) 404 if ( mData->uid.isEmpty() )
401 mData->uid = KApplication::randomString( 10 ); 405 mData->uid = KApplication::randomString( 10 );
402 406
403 return mData->uid; 407 return mData->uid;
404} 408}
405 409
406QString Addressee::uidLabel() 410QString Addressee::uidLabel()
407{ 411{
408 return i18n("Unique Identifier"); 412 return i18n("Unique Identifier");
409} 413}
410 414
411void Addressee::setName( const QString &name ) 415void Addressee::setName( const QString &name )
412{ 416{
413 if ( name == mData->name ) return; 417 if ( name == mData->name ) return;
414 detach(); 418 detach();
415 mData->empty = false; 419 mData->empty = false;
416 mData->name = name; 420 mData->name = name;
417} 421}
418 422
419QString Addressee::name() const 423QString Addressee::name() const
420{ 424{
421 return mData->name; 425 return mData->name;
422} 426}
423 427
424QString Addressee::nameLabel() 428QString Addressee::nameLabel()
425{ 429{
426 return i18n("Name"); 430 return i18n("Name");
427} 431}
428 432
429 433
430void Addressee::setFormattedName( const QString &formattedName ) 434void Addressee::setFormattedName( const QString &formattedName )
431{ 435{
432 if ( formattedName == mData->formattedName ) return; 436 if ( formattedName == mData->formattedName ) return;
433 detach(); 437 detach();
434 mData->empty = false; 438 mData->empty = false;
435 mData->formattedName = formattedName; 439 mData->formattedName = formattedName;
436} 440}
437 441
438QString Addressee::formattedName() const 442QString Addressee::formattedName() const
439{ 443{
440 return mData->formattedName; 444 return mData->formattedName;
441} 445}