-rw-r--r-- | kabc/addressbook.cpp | 19 | ||||
-rw-r--r-- | kabc/addressbook.h | 2 | ||||
-rw-r--r-- | kabc/addressee.cpp | 2 |
3 files changed, 17 insertions, 6 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 9b196b5..5774c36 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -829,154 +829,165 @@ void AddressBook::removeAddressee( const Addressee &a ) | |||
829 | Iterator it; | 829 | Iterator it; |
830 | Iterator it2; | 830 | Iterator it2; |
831 | bool found = false; | 831 | bool found = false; |
832 | for ( it = begin(); it != end(); ++it ) { | 832 | for ( it = begin(); it != end(); ++it ) { |
833 | if ( a.uid() == (*it).uid() ) { | 833 | if ( a.uid() == (*it).uid() ) { |
834 | found = true; | 834 | found = true; |
835 | it2 = it; | 835 | it2 = it; |
836 | } else { | 836 | } else { |
837 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 837 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
838 | QString name = (*it).uid().mid( 19 ); | 838 | QString name = (*it).uid().mid( 19 ); |
839 | Addressee b = a; | 839 | Addressee b = a; |
840 | QString id = b.getID( name ); | 840 | QString id = b.getID( name ); |
841 | if ( ! id.isEmpty() ) { | 841 | if ( ! id.isEmpty() ) { |
842 | QString des = (*it).note(); | 842 | QString des = (*it).note(); |
843 | if( des.find( id ) < 0 ) { | 843 | if( des.find( id ) < 0 ) { |
844 | des += id + ","; | 844 | des += id + ","; |
845 | (*it).setNote( des ); | 845 | (*it).setNote( des ); |
846 | } | 846 | } |
847 | } | 847 | } |
848 | } | 848 | } |
849 | 849 | ||
850 | } | 850 | } |
851 | } | 851 | } |
852 | 852 | ||
853 | if ( found ) | 853 | if ( found ) |
854 | removeAddressee( it2 ); | 854 | removeAddressee( it2 ); |
855 | 855 | ||
856 | } | 856 | } |
857 | 857 | ||
858 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 858 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
859 | { | 859 | { |
860 | Iterator it = begin(); | 860 | Iterator it = begin(); |
861 | Iterator it2 ; | 861 | Iterator it2 ; |
862 | QDateTime dt ( QDate( 2004,1,1) ); | 862 | QDateTime dt ( QDate( 2004,1,1) ); |
863 | while ( it != end() ) { | 863 | while ( it != end() ) { |
864 | (*it).setRevision( dt ); | 864 | (*it).setRevision( dt ); |
865 | if (( *it).IDStr() != "changed" ) { | 865 | if (( *it).IDStr() != "changed" ) { |
866 | // "changed" is used for tagging changed addressees when syncing with KDE or OL | 866 | // "changed" is used for tagging changed addressees when syncing with KDE or OL |
867 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 867 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
868 | (*it).setIDStr(""); | 868 | (*it).setIDStr(""); |
869 | } | 869 | } |
870 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 870 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
871 | it2 = it; | 871 | it2 = it; |
872 | //qDebug("removing %s ",(*it).uid().latin1() ); | 872 | //qDebug("removing %s ",(*it).uid().latin1() ); |
873 | ++it; | 873 | ++it; |
874 | removeAddressee( it2 ); | 874 | removeAddressee( it2 ); |
875 | } else { | 875 | } else { |
876 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 876 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
877 | if ( removeDeleted ) { | ||
878 | // we have no postprocessing in the resource, we have to do it here | ||
879 | // we have to compute csum for all, because it could be the first sync | ||
880 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); | ||
881 | |||
882 | |||
883 | } | ||
877 | ++it; | 884 | ++it; |
878 | } | 885 | } |
879 | } | 886 | } |
880 | deleteRemovedAddressees(); | 887 | deleteRemovedAddressees(); |
881 | } | 888 | } |
882 | 889 | ||
883 | void AddressBook::removeAddressee( const Iterator &it ) | 890 | void AddressBook::removeAddressee( const Iterator &it ) |
884 | { | 891 | { |
885 | d->mRemovedAddressees.append( (*it) ); | 892 | d->mRemovedAddressees.append( (*it) ); |
886 | d->mAddressees.remove( it.d->mIt ); | 893 | d->mAddressees.remove( it.d->mIt ); |
887 | } | 894 | } |
888 | 895 | ||
889 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 896 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
890 | { | 897 | { |
891 | Iterator it; | 898 | Iterator it; |
892 | for ( it = begin(); it != end(); ++it ) { | 899 | for ( it = begin(); it != end(); ++it ) { |
893 | if ( a.uid() == (*it).uid() ) { | 900 | if ( a.uid() == (*it).uid() ) { |
894 | return it; | 901 | return it; |
895 | } | 902 | } |
896 | } | 903 | } |
897 | return end(); | 904 | return end(); |
898 | } | 905 | } |
899 | 906 | ||
900 | Addressee AddressBook::findByUid( const QString &uid ) | 907 | Addressee AddressBook::findByUid( const QString &uid ) |
901 | { | 908 | { |
902 | Iterator it; | 909 | Iterator it; |
903 | for ( it = begin(); it != end(); ++it ) { | 910 | for ( it = begin(); it != end(); ++it ) { |
904 | if ( uid == (*it).uid() ) { | 911 | if ( uid == (*it).uid() ) { |
905 | return *it; | 912 | return *it; |
906 | } | 913 | } |
907 | } | 914 | } |
908 | return Addressee(); | 915 | return Addressee(); |
909 | } | 916 | } |
910 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) | 917 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) |
911 | { | 918 | { |
912 | //qDebug("AddressBook::preExternSync "); | 919 | //qDebug("AddressBook::preExternSync "); |
913 | AddressBook::Iterator it; | 920 | AddressBook::Iterator it; |
914 | for ( it = begin(); it != end(); ++it ) { | 921 | for ( it = begin(); it != end(); ++it ) { |
915 | (*it).setID( csd, (*it).externalUID() ); | 922 | (*it).setID( csd, (*it).externalUID() ); |
916 | (*it).computeCsum( csd ); | 923 | (*it).computeCsum( csd ); |
917 | } | 924 | } |
918 | mergeAB( aBook ,csd, isSubset ); | 925 | mergeAB( aBook ,csd, isSubset ); |
919 | } | 926 | } |
920 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) | 927 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) |
921 | { | 928 | { |
922 | //qDebug("AddressBook::postExternSync "); | 929 | //qDebug("AddressBook::postExternSync "); |
923 | AddressBook::Iterator it; | 930 | AddressBook::Iterator it; |
924 | for ( it = begin(); it != end(); ++it ) { | 931 | for ( it = begin(); it != end(); ++it ) { |
925 | // qDebug("check uid %s ", (*it).uid().latin1() ); | 932 | //qDebug("check uid %s ", (*it).uid().latin1() ); |
926 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 933 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
927 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { | 934 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { |
928 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 935 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
929 | if ( ad.isEmpty() ) { | 936 | if ( ad.isEmpty() ) { |
930 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); | 937 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); |
931 | } else { | 938 | } else { |
939 | (*it).setIDStr(":"); | ||
932 | (*it).computeCsum( csd ); | 940 | (*it).computeCsum( csd ); |
933 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 941 | if ( setID ) { |
934 | ad.setID( csd, (*it).externalUID() ); | 942 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
943 | ad.setID( csd, (*it).externalUID() ); | ||
944 | } else | ||
945 | ad.setID( csd, "_" ); | ||
935 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 946 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
936 | aBook->insertAddressee( ad ); | 947 | aBook->insertAddressee( ad ); |
937 | } | 948 | } |
938 | } | 949 | } |
939 | } | 950 | } |
940 | } | 951 | } |
941 | 952 | ||
942 | bool AddressBook::containsExternalUid( const QString& uid ) | 953 | bool AddressBook::containsExternalUid( const QString& uid ) |
943 | { | 954 | { |
944 | Iterator it; | 955 | Iterator it; |
945 | for ( it = begin(); it != end(); ++it ) { | 956 | for ( it = begin(); it != end(); ++it ) { |
946 | if ( uid == (*it).externalUID( ) ) | 957 | if ( uid == (*it).externalUID( ) ) |
947 | return true; | 958 | return true; |
948 | } | 959 | } |
949 | return false; | 960 | return false; |
950 | } | 961 | } |
951 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | 962 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) |
952 | { | 963 | { |
953 | Iterator it; | 964 | Iterator it; |
954 | for ( it = begin(); it != end(); ++it ) { | 965 | for ( it = begin(); it != end(); ++it ) { |
955 | if ( uid == (*it).getID( profile ) ) | 966 | if ( uid == (*it).getID( profile ) ) |
956 | return (*it); | 967 | return (*it); |
957 | } | 968 | } |
958 | return Addressee(); | 969 | return Addressee(); |
959 | } | 970 | } |
960 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) | 971 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) |
961 | { | 972 | { |
962 | Iterator it; | 973 | Iterator it; |
963 | Addressee ad; | 974 | Addressee ad; |
964 | for ( it = begin(); it != end(); ++it ) { | 975 | for ( it = begin(); it != end(); ++it ) { |
965 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 976 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
966 | if ( !ad.isEmpty() ) { | 977 | if ( !ad.isEmpty() ) { |
967 | (*it).mergeContact( ad ,isSubset); | 978 | (*it).mergeContact( ad ,isSubset); |
968 | } | 979 | } |
969 | } | 980 | } |
970 | #if 0 | 981 | #if 0 |
971 | // test only | 982 | // test only |
972 | for ( it = begin(); it != end(); ++it ) { | 983 | for ( it = begin(); it != end(); ++it ) { |
973 | 984 | ||
974 | qDebug("uid %s ", (*it).uid().latin1()); | 985 | qDebug("uid %s ", (*it).uid().latin1()); |
975 | } | 986 | } |
976 | #endif | 987 | #endif |
977 | } | 988 | } |
978 | 989 | ||
979 | #if 0 | 990 | #if 0 |
980 | Addressee::List AddressBook::getExternLastSyncAddressees() | 991 | Addressee::List AddressBook::getExternLastSyncAddressees() |
981 | { | 992 | { |
982 | Addressee::List results; | 993 | Addressee::List results; |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index f124dc9..75f8b51 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -262,88 +262,88 @@ class AddressBook : public QObject | |||
262 | the field. | 262 | the field. |
263 | */ | 263 | */ |
264 | bool addCustomField( const QString &label, int category = Field::All, | 264 | bool addCustomField( const QString &label, int category = Field::All, |
265 | const QString &key = QString::null, | 265 | const QString &key = QString::null, |
266 | const QString &app = QString::null ); | 266 | const QString &app = QString::null ); |
267 | 267 | ||
268 | 268 | ||
269 | /** | 269 | /** |
270 | Add address book resource. | 270 | Add address book resource. |
271 | */ | 271 | */ |
272 | bool addResource( Resource * ); | 272 | bool addResource( Resource * ); |
273 | 273 | ||
274 | /** | 274 | /** |
275 | Remove address book resource. | 275 | Remove address book resource. |
276 | */ | 276 | */ |
277 | bool removeResource( Resource * ); | 277 | bool removeResource( Resource * ); |
278 | 278 | ||
279 | /** | 279 | /** |
280 | Return pointer list of all resources. | 280 | Return pointer list of all resources. |
281 | */ | 281 | */ |
282 | QPtrList<Resource> resources(); | 282 | QPtrList<Resource> resources(); |
283 | 283 | ||
284 | /** | 284 | /** |
285 | Set the @p ErrorHandler, that is used by @ref error() to | 285 | Set the @p ErrorHandler, that is used by @ref error() to |
286 | provide gui-independend error messages. | 286 | provide gui-independend error messages. |
287 | */ | 287 | */ |
288 | void setErrorHandler( ErrorHandler * ); | 288 | void setErrorHandler( ErrorHandler * ); |
289 | 289 | ||
290 | /** | 290 | /** |
291 | Shows gui independend error messages. | 291 | Shows gui independend error messages. |
292 | */ | 292 | */ |
293 | void error( const QString& ); | 293 | void error( const QString& ); |
294 | 294 | ||
295 | /** | 295 | /** |
296 | Query all resources to clean up their lock files | 296 | Query all resources to clean up their lock files |
297 | */ | 297 | */ |
298 | void cleanUp(); | 298 | void cleanUp(); |
299 | 299 | ||
300 | // sync stuff | 300 | // sync stuff |
301 | //Addressee::List getExternLastSyncAddressees(); | 301 | //Addressee::List getExternLastSyncAddressees(); |
302 | void resetTempSyncStat(); | 302 | void resetTempSyncStat(); |
303 | QStringList uidList(); | 303 | QStringList uidList(); |
304 | void removeSyncAddressees( bool removeDeleted = false ); | 304 | void removeSyncAddressees( bool removeDeleted = false ); |
305 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); | 305 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); |
306 | Addressee findByExternUid( const QString& uid , const QString& profile ); | 306 | Addressee findByExternUid( const QString& uid , const QString& profile ); |
307 | bool containsExternalUid( const QString& uid ); | 307 | bool containsExternalUid( const QString& uid ); |
308 | 308 | ||
309 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); | 309 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); |
310 | void postExternSync( AddressBook* aBook, const QString& csd ); | 310 | void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); |
311 | signals: | 311 | signals: |
312 | /** | 312 | /** |
313 | Emitted, when the address book has changed on disk. | 313 | Emitted, when the address book has changed on disk. |
314 | */ | 314 | */ |
315 | void addressBookChanged( AddressBook * ); | 315 | void addressBookChanged( AddressBook * ); |
316 | 316 | ||
317 | /** | 317 | /** |
318 | Emitted, when the address book has been locked for writing. | 318 | Emitted, when the address book has been locked for writing. |
319 | */ | 319 | */ |
320 | void addressBookLocked( AddressBook * ); | 320 | void addressBookLocked( AddressBook * ); |
321 | 321 | ||
322 | /** | 322 | /** |
323 | Emitted, when the address book has been unlocked. | 323 | Emitted, when the address book has been unlocked. |
324 | */ | 324 | */ |
325 | void addressBookUnlocked( AddressBook * ); | 325 | void addressBookUnlocked( AddressBook * ); |
326 | 326 | ||
327 | protected: | 327 | protected: |
328 | void deleteRemovedAddressees(); | 328 | void deleteRemovedAddressees(); |
329 | void setStandardResource( Resource * ); | 329 | void setStandardResource( Resource * ); |
330 | Resource *standardResource(); | 330 | Resource *standardResource(); |
331 | KRES::Manager<Resource> *resourceManager(); | 331 | KRES::Manager<Resource> *resourceManager(); |
332 | 332 | ||
333 | void init(const QString &config, const QString &family); | 333 | void init(const QString &config, const QString &family); |
334 | 334 | ||
335 | private: | 335 | private: |
336 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 336 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
337 | 337 | ||
338 | 338 | ||
339 | struct AddressBookData; | 339 | struct AddressBookData; |
340 | AddressBookData *d; | 340 | AddressBookData *d; |
341 | bool blockLSEchange; | 341 | bool blockLSEchange; |
342 | }; | 342 | }; |
343 | 343 | ||
344 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 344 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
345 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 345 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
346 | 346 | ||
347 | } | 347 | } |
348 | 348 | ||
349 | #endif | 349 | #endif |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index a660a9d..d5a110a 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -221,97 +221,97 @@ void Addressee::computeCsum(const QString &dev) | |||
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 | ||
273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 273 | void 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 | 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 | (*it).setNumber( ( *phoneItAD ).number() ); | 313 | (*it).setNumber( ( *phoneItAD ).number() ); |
314 | break; | 314 | break; |
315 | } | 315 | } |
316 | } | 316 | } |
317 | if ( isSubSet && ! found ) | 317 | if ( isSubSet && ! found ) |