author | zautrix <zautrix> | 2006-02-24 18:49:56 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2006-02-24 18:49:56 (UTC) |
commit | d7738fdfc685192eb2f8317db6ffad3c246001c8 (patch) (unidiff) | |
tree | d9aae6ca97851fd1b53c4d9e74740a5ee2b69ea9 /kabc/addressee.cpp | |
parent | 987757f168bbae56100f2aff763b865e81ceec18 (diff) | |
download | kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.zip kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.gz kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.bz2 |
kapi sync
-rw-r--r-- | kabc/addressee.cpp | 75 |
1 files changed, 72 insertions, 3 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 6cfac80..e8e440c 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -29,12 +29,13 @@ $Id$ | |||
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 <kmessagebox.h> | ||
35 | #include <kidmanager.h> | 36 | #include <kidmanager.h> |
36 | //US | 37 | //US |
37 | #include <kstandarddirs.h> | 38 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 39 | #include <libkcal/syncdefines.h> |
39 | 40 | ||
40 | //US #include "resource.h" | 41 | //US #include "resource.h" |
@@ -208,13 +209,13 @@ ulong Addressee::getCsum4List( const QStringList & attList) | |||
208 | 209 | ||
209 | } | 210 | } |
210 | void Addressee::computeCsum(const QString &dev) | 211 | void Addressee::computeCsum(const QString &dev) |
211 | { | 212 | { |
212 | QStringList l; | 213 | QStringList l; |
213 | //if ( !mData->name.isEmpty() ) l.append(mData->name); | 214 | //if ( !mData->name.isEmpty() ) l.append(mData->name); |
214 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 215 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
215 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 216 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
216 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 217 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
217 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); | 218 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); |
218 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 219 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
219 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 220 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
220 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 221 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
@@ -329,12 +330,59 @@ bool Addressee::matchPhoneNumber( QRegExp* re ) const | |||
329 | return true; | 330 | return true; |
330 | 331 | ||
331 | } | 332 | } |
332 | return false; | 333 | return false; |
333 | 334 | ||
334 | } | 335 | } |
336 | void Addressee::mergeOLContact( const Addressee& ad ) | ||
337 | { | ||
338 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | ||
339 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | ||
340 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | ||
341 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | ||
342 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | ||
343 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | ||
344 | if ( !mData->sound.isIntern() ) { | ||
345 | if ( mData->sound.url().isEmpty() ) { | ||
346 | mData->sound = ad.mData->sound; | ||
347 | } | ||
348 | } | ||
349 | if ( !mData->agent.isIntern() ) { | ||
350 | if ( mData->agent.url().isEmpty() ) { | ||
351 | mData->agent = ad.mData->agent; | ||
352 | } | ||
353 | } | ||
354 | { | ||
355 | Key::List::Iterator itA; | ||
356 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | ||
357 | bool found = false; | ||
358 | Key::List::Iterator it; | ||
359 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | ||
360 | if ( (*it) == (*itA)) { | ||
361 | found = true; | ||
362 | break; | ||
363 | |||
364 | } | ||
365 | } | ||
366 | if ( ! found ) { | ||
367 | mData->keys.append( *itA ); | ||
368 | } | ||
369 | } | ||
370 | } | ||
371 | |||
372 | KABC::Address addthis = otherAddress(); | ||
373 | KABC::Address addother = ad.otherAddress(); | ||
374 | if ( !addthis.isEmpty() && !addother.isEmpty() ) | ||
375 | addthis.setType( addother.type() ); | ||
376 | //qDebug("merge contact %s ", ad.uid().latin1()); | ||
377 | setUid( ad.uid() ); | ||
378 | setRevision( ad.revision() ); | ||
379 | |||
380 | |||
381 | } | ||
382 | |||
335 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 383 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
336 | { | 384 | { |
337 | // merge all standard non-outlook fields. | 385 | // merge all standard non-outlook fields. |
338 | //if isSubSet (e.g. mobile phone sync) merge all fields | 386 | //if isSubSet (e.g. mobile phone sync) merge all fields |
339 | 387 | ||
340 | detach(); | 388 | detach(); |
@@ -1650,13 +1698,12 @@ void Addressee::setEmails( const QStringList& emails ) { | |||
1650 | mData->emails = emails; | 1698 | mData->emails = emails; |
1651 | } | 1699 | } |
1652 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1700 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1653 | { | 1701 | { |
1654 | detach(); | 1702 | detach(); |
1655 | mData->empty = false; | 1703 | mData->empty = false; |
1656 | |||
1657 | PhoneNumber::List::Iterator it; | 1704 | PhoneNumber::List::Iterator it; |
1658 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1705 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1659 | if ( (*it).id() == phoneNumber.id() ) { | 1706 | if ( (*it).id() == phoneNumber.id() ) { |
1660 | *it = phoneNumber; | 1707 | *it = phoneNumber; |
1661 | return; | 1708 | return; |
1662 | } | 1709 | } |
@@ -1717,12 +1764,23 @@ PhoneNumber::List Addressee::phoneNumbers( int type ) const | |||
1717 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1764 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1718 | list.append( *it ); | 1765 | list.append( *it ); |
1719 | } | 1766 | } |
1720 | } | 1767 | } |
1721 | return list; | 1768 | return list; |
1722 | } | 1769 | } |
1770 | QString Addressee::phoneNumberString( int type ) const | ||
1771 | { | ||
1772 | |||
1773 | PhoneNumber::List::ConstIterator it; | ||
1774 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | ||
1775 | if ((*it).type() == type ) { | ||
1776 | return ( *it ).number(); | ||
1777 | } | ||
1778 | } | ||
1779 | return ""; | ||
1780 | } | ||
1723 | 1781 | ||
1724 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1782 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1725 | { | 1783 | { |
1726 | PhoneNumber::List::ConstIterator it; | 1784 | PhoneNumber::List::ConstIterator it; |
1727 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1785 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1728 | if ( (*it).id() == id ) { | 1786 | if ( (*it).id() == id ) { |
@@ -1922,13 +1980,24 @@ void Addressee::removeAddress( const Address &address ) | |||
1922 | if ( (*it).id() == address.id() ) { | 1980 | if ( (*it).id() == address.id() ) { |
1923 | mData->addresses.remove( it ); | 1981 | mData->addresses.remove( it ); |
1924 | return; | 1982 | return; |
1925 | } | 1983 | } |
1926 | } | 1984 | } |
1927 | } | 1985 | } |
1928 | 1986 | Address Addressee::otherAddress() const | |
1987 | { | ||
1988 | Address::List::ConstIterator it; | ||
1989 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | ||
1990 | if ( matchBinaryPatternA( (*it).type(), KABC::Address::Work ) ) | ||
1991 | continue; | ||
1992 | if ( matchBinaryPatternA( (*it).type(), KABC::Address::Home ) ) | ||
1993 | continue; | ||
1994 | return (*it); | ||
1995 | } | ||
1996 | return Address(); | ||
1997 | } | ||
1929 | Address Addressee::address( int type ) const | 1998 | Address Addressee::address( int type ) const |
1930 | { | 1999 | { |
1931 | Address address( type ); | 2000 | Address address( type ); |
1932 | Address::List::ConstIterator it; | 2001 | Address::List::ConstIterator it; |
1933 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 2002 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1934 | if ( matchBinaryPatternA( (*it).type(), type ) ) { | 2003 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |