-rw-r--r-- | kabc/addressee.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index c34f671..711c261 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -37,64 +37,65 @@ $Id$ | |||
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 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | 46 | ||
47 | struct Addressee::AddresseeData : public KShared | 47 | struct Addressee::AddresseeData : public KShared |
48 | { | 48 | { |
49 | QString uid; | 49 | QString uid; |
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 | KURL url; | 70 | KURL url; |
70 | Secrecy secrecy; | 71 | Secrecy secrecy; |
71 | Picture logo; | 72 | Picture logo; |
72 | Picture photo; | 73 | Picture photo; |
73 | Sound sound; | 74 | Sound sound; |
74 | Agent agent; | 75 | Agent agent; |
75 | QString mExternalId; | 76 | QString mExternalId; |
76 | PhoneNumber::List phoneNumbers; | 77 | PhoneNumber::List phoneNumbers; |
77 | Address::List addresses; | 78 | Address::List addresses; |
78 | Key::List keys; | 79 | Key::List keys; |
79 | QStringList emails; | 80 | QStringList emails; |
80 | QStringList categories; | 81 | QStringList categories; |
81 | QStringList custom; | 82 | QStringList custom; |
82 | int mTempSyncStat; | 83 | int mTempSyncStat; |
83 | Resource *resource; | 84 | Resource *resource; |
84 | 85 | ||
85 | bool empty :1; | 86 | bool empty :1; |
86 | bool changed :1; | 87 | bool changed :1; |
87 | }; | 88 | }; |
88 | 89 | ||
89 | Addressee::Addressee() | 90 | Addressee::Addressee() |
90 | { | 91 | { |
91 | mData = new AddresseeData; | 92 | mData = new AddresseeData; |
92 | mData->empty = true; | 93 | mData->empty = true; |
93 | mData->changed = false; | 94 | mData->changed = false; |
94 | mData->resource = 0; | 95 | mData->resource = 0; |
95 | mData->mExternalId = ":"; | 96 | mData->mExternalId = ":"; |
96 | mData->revision = QDateTime ( QDate( 2004,1,1)); | 97 | mData->revision = QDateTime ( QDate( 2004,1,1)); |
97 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 98 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
98 | } | 99 | } |
99 | 100 | ||
100 | Addressee::~Addressee() | 101 | Addressee::~Addressee() |
@@ -242,116 +243,154 @@ void Addressee::computeCsum(const QString &dev) | |||
242 | QStringList t; | 243 | QStringList t; |
243 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 244 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
244 | ++phoneIter ) | 245 | ++phoneIter ) |
245 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 246 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
246 | t.sort(); | 247 | t.sort(); |
247 | uint iii; | 248 | uint iii; |
248 | for ( iii = 0; iii < t.count(); ++iii) | 249 | for ( iii = 0; iii < t.count(); ++iii) |
249 | l.append( t[iii] ); | 250 | l.append( t[iii] ); |
250 | t = mData->emails; | 251 | t = mData->emails; |
251 | t.sort(); | 252 | t.sort(); |
252 | for ( iii = 0; iii < t.count(); ++iii) | 253 | for ( iii = 0; iii < t.count(); ++iii) |
253 | l.append( t[iii] ); | 254 | l.append( t[iii] ); |
254 | t = mData->categories; | 255 | t = mData->categories; |
255 | t.sort(); | 256 | t.sort(); |
256 | for ( iii = 0; iii < t.count(); ++iii) | 257 | for ( iii = 0; iii < t.count(); ++iii) |
257 | l.append( t[iii] ); | 258 | l.append( t[iii] ); |
258 | t = mData->custom; | 259 | t = mData->custom; |
259 | t.sort(); | 260 | t.sort(); |
260 | for ( iii = 0; iii < t.count(); ++iii) | 261 | for ( iii = 0; iii < t.count(); ++iii) |
261 | l.append( t[iii] ); | 262 | l.append( t[iii] ); |
262 | KABC::Address::List::Iterator addressIter; | 263 | KABC::Address::List::Iterator addressIter; |
263 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 264 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
264 | ++addressIter ) { | 265 | ++addressIter ) { |
265 | t = (*addressIter).asList(); | 266 | t = (*addressIter).asList(); |
266 | t.sort(); | 267 | t.sort(); |
267 | for ( iii = 0; iii < t.count(); ++iii) | 268 | for ( iii = 0; iii < t.count(); ++iii) |
268 | l.append( t[iii] ); | 269 | l.append( t[iii] ); |
269 | } | 270 | } |
270 | uint cs = getCsum4List(l); | 271 | uint cs = getCsum4List(l); |
271 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 272 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
272 | setCsum( dev, QString::number (cs )); | 273 | setCsum( dev, QString::number (cs )); |
273 | } | 274 | } |
275 | |||
276 | void Addressee::mergeContact( Addressee ad ) | ||
277 | { | ||
278 | #if 0 | ||
279 | if ( !mData->name.isEmpty() ) l.append(mData->name); | ||
280 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | ||
281 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | ||
282 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | ||
283 | if ( !mData->additionalName ) l.append( mData->additionalName ); | ||
284 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | ||
285 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | ||
286 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | ||
287 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | ||
288 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | ||
289 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | ||
290 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | ||
291 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | ||
292 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | ||
293 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | ||
294 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | ||
295 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | ||
296 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | ||
297 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | ||
298 | #endif | ||
299 | } | ||
300 | |||
274 | void Addressee::removeID(const QString &prof) | 301 | void Addressee::removeID(const QString &prof) |
275 | { | 302 | { |
276 | detach(); | 303 | detach(); |
277 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 304 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
278 | 305 | ||
279 | } | 306 | } |
280 | void Addressee::setID( const QString & prof , const QString & id ) | 307 | void Addressee::setID( const QString & prof , const QString & id ) |
281 | { | 308 | { |
282 | detach(); | 309 | detach(); |
283 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 310 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
284 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 311 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
285 | } | 312 | } |
286 | void Addressee::setTempSyncStat( int id ) | 313 | void Addressee::setTempSyncStat( int id ) |
287 | { | 314 | { |
288 | if ( mData->mTempSyncStat == id ) return; | 315 | if ( mData->mTempSyncStat == id ) return; |
289 | detach(); | 316 | detach(); |
290 | mData->mTempSyncStat = id; | 317 | mData->mTempSyncStat = id; |
291 | } | 318 | } |
292 | int Addressee::tempSyncStat() const | 319 | int Addressee::tempSyncStat() const |
293 | { | 320 | { |
294 | return mData->mTempSyncStat; | 321 | return mData->mTempSyncStat; |
295 | } | 322 | } |
296 | 323 | ||
297 | QString Addressee::getID( const QString & prof) | 324 | QString Addressee::getID( const QString & prof) |
298 | { | 325 | { |
299 | return KIdManager::getId ( mData->mExternalId, prof ); | 326 | return KIdManager::getId ( mData->mExternalId, prof ); |
300 | } | 327 | } |
301 | 328 | ||
302 | void Addressee::setCsum( const QString & prof , const QString & id ) | 329 | void Addressee::setCsum( const QString & prof , const QString & id ) |
303 | { | 330 | { |
304 | detach(); | 331 | detach(); |
305 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 332 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
306 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 333 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
307 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 334 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
308 | } | 335 | } |
309 | 336 | ||
310 | QString Addressee::getCsum( const QString & prof) | 337 | QString Addressee::getCsum( const QString & prof) |
311 | { | 338 | { |
312 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 339 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
313 | } | 340 | } |
314 | 341 | ||
315 | void Addressee::setIDStr( const QString & s ) | 342 | void Addressee::setIDStr( const QString & s ) |
316 | { | 343 | { |
317 | detach(); | 344 | detach(); |
318 | mData->mExternalId = s; | 345 | mData->mExternalId = s; |
319 | } | 346 | } |
320 | 347 | ||
321 | QString Addressee::IDStr() const | 348 | QString Addressee::IDStr() const |
322 | { | 349 | { |
323 | return mData->mExternalId; | 350 | return mData->mExternalId; |
324 | } | 351 | } |
325 | 352 | ||
353 | void Addressee::setExternalUID( const QString &id ) | ||
354 | { | ||
355 | if ( id == mData->externalUID ) return; | ||
356 | detach(); | ||
357 | mData->empty = false; | ||
358 | mData->externalUID = id; | ||
359 | } | ||
360 | |||
361 | QString Addressee::externalUID() const | ||
362 | { | ||
363 | return mData->externalUID; | ||
364 | } | ||
326 | 365 | ||
327 | void Addressee::setUid( const QString &id ) | 366 | void Addressee::setUid( const QString &id ) |
328 | { | 367 | { |
329 | if ( id == mData->uid ) return; | 368 | if ( id == mData->uid ) return; |
330 | detach(); | 369 | detach(); |
331 | mData->empty = false; | 370 | mData->empty = false; |
332 | mData->uid = id; | 371 | mData->uid = id; |
333 | } | 372 | } |
334 | 373 | ||
335 | QString Addressee::uid() const | 374 | QString Addressee::uid() const |
336 | { | 375 | { |
337 | if ( mData->uid.isEmpty() ) | 376 | if ( mData->uid.isEmpty() ) |
338 | mData->uid = KApplication::randomString( 10 ); | 377 | mData->uid = KApplication::randomString( 10 ); |
339 | 378 | ||
340 | return mData->uid; | 379 | return mData->uid; |
341 | } | 380 | } |
342 | 381 | ||
343 | QString Addressee::uidLabel() | 382 | QString Addressee::uidLabel() |
344 | { | 383 | { |
345 | return i18n("Unique Identifier"); | 384 | return i18n("Unique Identifier"); |
346 | } | 385 | } |
347 | 386 | ||
348 | void Addressee::setName( const QString &name ) | 387 | void Addressee::setName( const QString &name ) |
349 | { | 388 | { |
350 | if ( name == mData->name ) return; | 389 | if ( name == mData->name ) return; |
351 | detach(); | 390 | detach(); |
352 | mData->empty = false; | 391 | mData->empty = false; |
353 | mData->name = name; | 392 | mData->name = name; |
354 | } | 393 | } |
355 | 394 | ||
356 | QString Addressee::name() const | 395 | QString Addressee::name() const |
357 | { | 396 | { |