-rw-r--r-- | kabc/addressbook.cpp | 20 | ||||
-rw-r--r-- | kabc/addressbook.h | 1 | ||||
-rw-r--r-- | kabc/addressee.cpp | 75 | ||||
-rw-r--r-- | kabc/addressee.h | 4 | ||||
-rw-r--r-- | kabc/phonenumber.cpp | 24 |
5 files changed, 119 insertions, 5 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index f9e4387..fe59fcb 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -946,6 +946,23 @@ void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool i | |||
946 | } | 946 | } |
947 | mergeAB( aBook ,csd, isSubset ); | 947 | mergeAB( aBook ,csd, isSubset ); |
948 | } | 948 | } |
949 | void AddressBook::preOLSync( AddressBook* aBook, const QString& csd ) | ||
950 | { | ||
951 | //qDebug("AddressBook::preExternSync "); | ||
952 | AddressBook::Iterator it; | ||
953 | for ( it = begin(); it != end(); ++it ) { | ||
954 | (*it).setID( csd, (*it).externalUID() ); | ||
955 | (*it).computeCsum( csd ); | ||
956 | } | ||
957 | |||
958 | Addressee ad; | ||
959 | for ( it = begin(); it != end(); ++it ) { | ||
960 | ad = aBook->findByExternUid( (*it).externalUID(), csd ); | ||
961 | if ( !ad.isEmpty() ) { | ||
962 | (*it).mergeOLContact( ad ); | ||
963 | } | ||
964 | } | ||
965 | } | ||
949 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) | 966 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) |
950 | { | 967 | { |
951 | //qDebug("AddressBook::postExternSync "); | 968 | //qDebug("AddressBook::postExternSync "); |
@@ -965,7 +982,8 @@ void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool | |||
965 | (*it).setIDStr(":"); | 982 | (*it).setIDStr(":"); |
966 | if ( setID ) { | 983 | if ( setID ) { |
967 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 984 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
968 | ad.setID( csd, (*it).externalUID() ); | 985 | ad.setID( csd, (*it).externalUID() );{ |
986 | } | ||
969 | } else | 987 | } else |
970 | ad.setID( csd, (*it).uid() ); | 988 | ad.setID( csd, (*it).uid() ); |
971 | (*it).computeCsum( csd ); | 989 | (*it).computeCsum( csd ); |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index e6daa5e..a8a9fc1 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -308,6 +308,7 @@ class AddressBook : public QObject | |||
308 | bool containsExternalUid( const QString& uid ); | 308 | bool containsExternalUid( const QString& uid ); |
309 | 309 | ||
310 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); | 310 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); |
311 | void preOLSync( AddressBook* aBook, const QString& csd); | ||
311 | void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); | 312 | void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); |
312 | signals: | 313 | signals: |
313 | /** | 314 | /** |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 6cfac80..e8e440c 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -32,6 +32,7 @@ $Id$ | |||
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> |
@@ -211,7 +212,7 @@ 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 ); |
@@ -332,6 +333,53 @@ bool Addressee::matchPhoneNumber( QRegExp* re ) const | |||
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. |
@@ -1653,7 +1701,6 @@ 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() ) { |
@@ -1720,6 +1767,17 @@ PhoneNumber::List Addressee::phoneNumbers( int type ) const | |||
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 | { |
@@ -1925,7 +1983,18 @@ void Addressee::removeAddress( const Address &address ) | |||
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 ); |
diff --git a/kabc/addressee.h b/kabc/addressee.h index aac78dc..0ea1803 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -118,6 +118,7 @@ class Addressee | |||
118 | void setOriginalExternalUID( const QString &id ); | 118 | void setOriginalExternalUID( const QString &id ); |
119 | QString originalExternalUID() const; | 119 | QString originalExternalUID() const; |
120 | void mergeContact( const Addressee& ad, bool isSubSet ); | 120 | void mergeContact( const Addressee& ad, bool isSubSet ); |
121 | void mergeOLContact( const Addressee& ad ); | ||
121 | void simplifyEmails(); | 122 | void simplifyEmails(); |
122 | void simplifyAddresses(); | 123 | void simplifyAddresses(); |
123 | void simplifyPhoneNumbers(); | 124 | void simplifyPhoneNumbers(); |
@@ -647,6 +648,7 @@ class Addressee | |||
647 | Return phone number, which matches the given type. | 648 | Return phone number, which matches the given type. |
648 | */ | 649 | */ |
649 | PhoneNumber phoneNumber( int type ) const; | 650 | PhoneNumber phoneNumber( int type ) const; |
651 | QString phoneNumberString( int type ) const; | ||
650 | 652 | ||
651 | bool matchPhoneNumber( QRegExp* searchExp ) const; | 653 | bool matchPhoneNumber( QRegExp* searchExp ) const; |
652 | bool matchAddress( QRegExp* searchExp ) const; | 654 | bool matchAddress( QRegExp* searchExp ) const; |
@@ -731,7 +733,7 @@ class Addressee | |||
731 | Return list of all addresses. | 733 | Return list of all addresses. |
732 | */ | 734 | */ |
733 | Address::List addresses() const; | 735 | Address::List addresses() const; |
734 | 736 | Address otherAddress() const; | |
735 | /** | 737 | /** |
736 | Return list of addresses with a special type. | 738 | Return list of addresses with a special type. |
737 | */ | 739 | */ |
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index 12b9b09..1752745 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp | |||
@@ -232,6 +232,30 @@ PhoneNumber::TypeList PhoneNumber::supportedTypeList() | |||
232 | list << (Home| Pref) << (Work| Pref) << Cell <<(Pcs|Pref)<< (Pcs|Voice)<< Home << Work << Car << Pcs <<(Work| Msg | Voice) << (Work| Msg) << (Home | Fax) << (Work| Fax) << Fax<< Pager << Isdn << Msg << Pref << Voice; | 232 | list << (Home| Pref) << (Work| Pref) << Cell <<(Pcs|Pref)<< (Pcs|Voice)<< Home << Work << Car << Pcs <<(Work| Msg | Voice) << (Work| Msg) << (Home | Fax) << (Work| Fax) << Fax<< Pager << Isdn << Msg << Pref << Voice; |
233 | return list; | 233 | return list; |
234 | } | 234 | } |
235 | |||
236 | #if 0 | ||
237 | Home| Pref i18n("Home") Home | ||
238 | Work| Pref i18n("Work") Business | ||
239 | Cell i18n("Mobile") Mobile | ||
240 | Pcs|Pref i18n("SiP") Radio | ||
241 | Pcs|Voice i18n("VoIP") TTY/TTD | ||
242 | Home i18n("Home2") Home 2 | ||
243 | Work i18n("Work2") Business 2 | ||
244 | Car i18n("Mobile2") Car | ||
245 | Pcs i18n("SiP2") Telex | ||
246 | Work| Msg | Voice i18n("Assistent") Assistent | ||
247 | Work| Msg i18n("Company") Company | ||
248 | Home | Fax i18n("Fax (Home)") Home Fax | ||
249 | Work| Fax i18n("Fax (Work)") Business Fax | ||
250 | Fax i18n("Fax (Other)") Other Fax | ||
251 | Pager i18n("Pager") Pager | ||
252 | Isdn i18n("ISDN") Isdn | ||
253 | Msg i18n("Callback") Callback | ||
254 | Pref i18n("Primary") Primary | ||
255 | Voice; i18n("Other") Other | ||
256 | |||
257 | #endif | ||
258 | |||
235 | QStringList PhoneNumber::supportedTypeListNames() | 259 | QStringList PhoneNumber::supportedTypeListNames() |
236 | { | 260 | { |
237 | static QStringList list; | 261 | static QStringList list; |