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 | |
parent | 987757f168bbae56100f2aff763b865e81ceec18 (diff) | |
download | kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.zip kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.gz kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.bz2 |
kapi sync
-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 | |||
@@ -901,116 +901,134 @@ void AddressBook::removeSyncAddressees( bool removeDeleted ) | |||
901 | if ( removeDeleted ) { | 901 | if ( removeDeleted ) { |
902 | // we have no postprocessing in the resource, we have to do it here | 902 | // we have no postprocessing in the resource, we have to do it here |
903 | // we have to compute csum for all, because it could be the first sync | 903 | // we have to compute csum for all, because it could be the first sync |
904 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 904 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
905 | } | 905 | } |
906 | ++it; | 906 | ++it; |
907 | } | 907 | } |
908 | } | 908 | } |
909 | deleteRemovedAddressees(); | 909 | deleteRemovedAddressees(); |
910 | } | 910 | } |
911 | 911 | ||
912 | void AddressBook::removeAddressee( const Iterator &it ) | 912 | void AddressBook::removeAddressee( const Iterator &it ) |
913 | { | 913 | { |
914 | d->mRemovedAddressees.append( (*it) ); | 914 | d->mRemovedAddressees.append( (*it) ); |
915 | d->mAddressees.remove( it.d->mIt ); | 915 | d->mAddressees.remove( it.d->mIt ); |
916 | } | 916 | } |
917 | 917 | ||
918 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 918 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
919 | { | 919 | { |
920 | Iterator it; | 920 | Iterator it; |
921 | for ( it = begin(); it != end(); ++it ) { | 921 | for ( it = begin(); it != end(); ++it ) { |
922 | if ( a.uid() == (*it).uid() ) { | 922 | if ( a.uid() == (*it).uid() ) { |
923 | return it; | 923 | return it; |
924 | } | 924 | } |
925 | } | 925 | } |
926 | return end(); | 926 | return end(); |
927 | } | 927 | } |
928 | 928 | ||
929 | Addressee AddressBook::findByUid( const QString &uid ) | 929 | Addressee AddressBook::findByUid( const QString &uid ) |
930 | { | 930 | { |
931 | Iterator it; | 931 | Iterator it; |
932 | for ( it = begin(); it != end(); ++it ) { | 932 | for ( it = begin(); it != end(); ++it ) { |
933 | if ( uid == (*it).uid() ) { | 933 | if ( uid == (*it).uid() ) { |
934 | return *it; | 934 | return *it; |
935 | } | 935 | } |
936 | } | 936 | } |
937 | return Addressee(); | 937 | return Addressee(); |
938 | } | 938 | } |
939 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) | 939 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) |
940 | { | 940 | { |
941 | //qDebug("AddressBook::preExternSync "); | 941 | //qDebug("AddressBook::preExternSync "); |
942 | AddressBook::Iterator it; | 942 | AddressBook::Iterator it; |
943 | for ( it = begin(); it != end(); ++it ) { | 943 | for ( it = begin(); it != end(); ++it ) { |
944 | (*it).setID( csd, (*it).externalUID() ); | 944 | (*it).setID( csd, (*it).externalUID() ); |
945 | (*it).computeCsum( csd ); | 945 | (*it).computeCsum( csd ); |
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 "); |
952 | AddressBook::Iterator it; | 969 | AddressBook::Iterator it; |
953 | int foundEmpty = 0; | 970 | int foundEmpty = 0; |
954 | for ( it = begin(); it != end(); ++it ) { | 971 | for ( it = begin(); it != end(); ++it ) { |
955 | //qDebug("check uid %s ", (*it).uid().latin1() ); | 972 | //qDebug("check uid %s ", (*it).uid().latin1() ); |
956 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 973 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
957 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || | 974 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || |
958 | (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { | 975 | (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { |
959 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 976 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
960 | if ( ad.isEmpty() ) { | 977 | if ( ad.isEmpty() ) { |
961 | ++foundEmpty; | 978 | ++foundEmpty; |
962 | //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); | 979 | //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); |
963 | //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); | 980 | //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); |
964 | } else { | 981 | } else { |
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 ); |
972 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 990 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
973 | //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); | 991 | //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); |
974 | aBook->insertAddressee( ad , false); | 992 | aBook->insertAddressee( ad , false); |
975 | } | 993 | } |
976 | } | 994 | } |
977 | } | 995 | } |
978 | if ( foundEmpty ) { | 996 | if ( foundEmpty ) { |
979 | qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); | 997 | qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); |
980 | } | 998 | } |
981 | 999 | ||
982 | } | 1000 | } |
983 | 1001 | ||
984 | bool AddressBook::containsExternalUid( const QString& uid ) | 1002 | bool AddressBook::containsExternalUid( const QString& uid ) |
985 | { | 1003 | { |
986 | Iterator it; | 1004 | Iterator it; |
987 | for ( it = begin(); it != end(); ++it ) { | 1005 | for ( it = begin(); it != end(); ++it ) { |
988 | if ( uid == (*it).externalUID( ) ) | 1006 | if ( uid == (*it).externalUID( ) ) |
989 | return true; | 1007 | return true; |
990 | } | 1008 | } |
991 | return false; | 1009 | return false; |
992 | } | 1010 | } |
993 | const Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) const | 1011 | const Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) const |
994 | { | 1012 | { |
995 | ConstIterator it; | 1013 | ConstIterator it; |
996 | for ( it = begin(); it != end(); ++it ) { | 1014 | for ( it = begin(); it != end(); ++it ) { |
997 | if ( uid == (*it).getID( profile ) ) | 1015 | if ( uid == (*it).getID( profile ) ) |
998 | return (*it); | 1016 | return (*it); |
999 | } | 1017 | } |
1000 | return Addressee(); | 1018 | return Addressee(); |
1001 | } | 1019 | } |
1002 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) | 1020 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) |
1003 | { | 1021 | { |
1004 | Iterator it; | 1022 | Iterator it; |
1005 | Addressee ad; | 1023 | Addressee ad; |
1006 | for ( it = begin(); it != end(); ++it ) { | 1024 | for ( it = begin(); it != end(); ++it ) { |
1007 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 1025 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
1008 | if ( !ad.isEmpty() ) { | 1026 | if ( !ad.isEmpty() ) { |
1009 | (*it).mergeContact( ad ,isSubset); | 1027 | (*it).mergeContact( ad ,isSubset); |
1010 | } | 1028 | } |
1011 | } | 1029 | } |
1012 | #if 0 | 1030 | #if 0 |
1013 | // test only | 1031 | // test only |
1014 | for ( it = begin(); it != end(); ++it ) { | 1032 | for ( it = begin(); it != end(); ++it ) { |
1015 | 1033 | ||
1016 | qDebug("uid %s ", (*it).uid().latin1()); | 1034 | qDebug("uid %s ", (*it).uid().latin1()); |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index e6daa5e..a8a9fc1 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -263,88 +263,89 @@ class AddressBook : public QObject | |||
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 | void removeResources(); | 277 | void removeResources(); |
278 | bool removeResource( Resource * ); | 278 | bool removeResource( Resource * ); |
279 | 279 | ||
280 | /** | 280 | /** |
281 | Return pointer list of all resources. | 281 | Return pointer list of all resources. |
282 | */ | 282 | */ |
283 | QPtrList<Resource> resources(); | 283 | QPtrList<Resource> resources(); |
284 | 284 | ||
285 | /** | 285 | /** |
286 | Set the @p ErrorHandler, that is used by @ref error() to | 286 | Set the @p ErrorHandler, that is used by @ref error() to |
287 | provide gui-independend error messages. | 287 | provide gui-independend error messages. |
288 | */ | 288 | */ |
289 | void setErrorHandler( ErrorHandler * ); | 289 | void setErrorHandler( ErrorHandler * ); |
290 | 290 | ||
291 | /** | 291 | /** |
292 | Shows gui independend error messages. | 292 | Shows gui independend error messages. |
293 | */ | 293 | */ |
294 | void error( const QString& ); | 294 | void error( const QString& ); |
295 | 295 | ||
296 | /** | 296 | /** |
297 | Query all resources to clean up their lock files | 297 | Query all resources to clean up their lock files |
298 | */ | 298 | */ |
299 | void cleanUp(); | 299 | void cleanUp(); |
300 | 300 | ||
301 | // sync stuff | 301 | // sync stuff |
302 | //Addressee::List getExternLastSyncAddressees(); | 302 | //Addressee::List getExternLastSyncAddressees(); |
303 | void resetTempSyncStat(); | 303 | void resetTempSyncStat(); |
304 | QStringList uidList(); | 304 | QStringList uidList(); |
305 | void removeSyncAddressees( bool removeDeleted = false ); | 305 | void removeSyncAddressees( bool removeDeleted = false ); |
306 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); | 306 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); |
307 | const Addressee findByExternUid( const QString& uid , const QString& profile ) const; | 307 | const Addressee findByExternUid( const QString& uid , const QString& profile ) const; |
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 | /** |
314 | Emitted, when the address book has changed on disk. | 315 | Emitted, when the address book has changed on disk. |
315 | */ | 316 | */ |
316 | void addressBookChanged( AddressBook * ); | 317 | void addressBookChanged( AddressBook * ); |
317 | 318 | ||
318 | /** | 319 | /** |
319 | Emitted, when the address book has been locked for writing. | 320 | Emitted, when the address book has been locked for writing. |
320 | */ | 321 | */ |
321 | void addressBookLocked( AddressBook * ); | 322 | void addressBookLocked( AddressBook * ); |
322 | 323 | ||
323 | /** | 324 | /** |
324 | Emitted, when the address book has been unlocked. | 325 | Emitted, when the address book has been unlocked. |
325 | */ | 326 | */ |
326 | void addressBookUnlocked( AddressBook * ); | 327 | void addressBookUnlocked( AddressBook * ); |
327 | 328 | ||
328 | protected: | 329 | protected: |
329 | void deleteRemovedAddressees(); | 330 | void deleteRemovedAddressees(); |
330 | void setStandardResource( Resource * ); | 331 | void setStandardResource( Resource * ); |
331 | Resource *standardResource(); | 332 | Resource *standardResource(); |
332 | KRES::Manager<Resource> *resourceManager(); | 333 | KRES::Manager<Resource> *resourceManager(); |
333 | 334 | ||
334 | void init(const QString &config, const QString &family); | 335 | void init(const QString &config, const QString &family); |
335 | 336 | ||
336 | private: | 337 | private: |
337 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 338 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
338 | 339 | ||
339 | 340 | ||
340 | struct AddressBookData; | 341 | struct AddressBookData; |
341 | AddressBookData *d; | 342 | AddressBookData *d; |
342 | bool blockLSEchange; | 343 | bool blockLSEchange; |
343 | }; | 344 | }; |
344 | 345 | ||
345 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 346 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
346 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 347 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
347 | 348 | ||
348 | } | 349 | } |
349 | 350 | ||
350 | #endif | 351 | #endif |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 6cfac80..e8e440c 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,82 +1,83 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
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" |
41 | #include "addressee.h" | 42 | #include "addressee.h" |
42 | 43 | ||
43 | using namespace KABC; | 44 | using namespace KABC; |
44 | 45 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 46 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 47 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 48 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 49 | ||
49 | struct Addressee::AddresseeData : public KShared | 50 | struct Addressee::AddresseeData : public KShared |
50 | { | 51 | { |
51 | QString uid; | 52 | QString uid; |
52 | QString name; | 53 | QString name; |
53 | QString formattedName; | 54 | QString formattedName; |
54 | QString familyName; | 55 | QString familyName; |
55 | QString givenName; | 56 | QString givenName; |
56 | QString additionalName; | 57 | QString additionalName; |
57 | QString prefix; | 58 | QString prefix; |
58 | QString suffix; | 59 | QString suffix; |
59 | QString nickName; | 60 | QString nickName; |
60 | QDateTime birthday; | 61 | QDateTime birthday; |
61 | QString mailer; | 62 | QString mailer; |
62 | TimeZone timeZone; | 63 | TimeZone timeZone; |
63 | Geo geo; | 64 | Geo geo; |
64 | QString title; | 65 | QString title; |
65 | QString role; | 66 | QString role; |
66 | QString organization; | 67 | QString organization; |
67 | QString note; | 68 | QString note; |
68 | QString productId; | 69 | QString productId; |
69 | QDateTime revision; | 70 | QDateTime revision; |
70 | QString sortString; | 71 | QString sortString; |
71 | QString externalUID; | 72 | QString externalUID; |
72 | QString originalExternalUID; | 73 | QString originalExternalUID; |
73 | KURL url; | 74 | KURL url; |
74 | Secrecy secrecy; | 75 | Secrecy secrecy; |
75 | Picture logo; | 76 | Picture logo; |
76 | Picture photo; | 77 | Picture photo; |
77 | Sound sound; | 78 | Sound sound; |
78 | Agent agent; | 79 | Agent agent; |
79 | QString mExternalId; | 80 | QString mExternalId; |
80 | PhoneNumber::List phoneNumbers; | 81 | PhoneNumber::List phoneNumbers; |
81 | Address::List addresses; | 82 | Address::List addresses; |
82 | Key::List keys; | 83 | Key::List keys; |
@@ -166,97 +167,97 @@ bool Addressee::operator==( const Addressee &a ) const | |||
166 | if ( mData->categories != a.mData->categories ) return false; | 167 | if ( mData->categories != a.mData->categories ) return false; |
167 | if ( mData->custom != a.mData->custom ) return false; | 168 | if ( mData->custom != a.mData->custom ) return false; |
168 | 169 | ||
169 | return true; | 170 | return true; |
170 | } | 171 | } |
171 | 172 | ||
172 | bool Addressee::operator!=( const Addressee &a ) const | 173 | bool Addressee::operator!=( const Addressee &a ) const |
173 | { | 174 | { |
174 | return !( a == *this ); | 175 | return !( a == *this ); |
175 | } | 176 | } |
176 | 177 | ||
177 | bool Addressee::isEmpty() const | 178 | bool Addressee::isEmpty() const |
178 | { | 179 | { |
179 | return mData->empty; | 180 | return mData->empty; |
180 | } | 181 | } |
181 | ulong Addressee::getCsum4List( const QStringList & attList) | 182 | ulong Addressee::getCsum4List( const QStringList & attList) |
182 | { | 183 | { |
183 | int max = attList.count(); | 184 | int max = attList.count(); |
184 | ulong cSum = 0; | 185 | ulong cSum = 0; |
185 | int j,k,i; | 186 | int j,k,i; |
186 | int add; | 187 | int add; |
187 | for ( i = 0; i < max ; ++i ) { | 188 | for ( i = 0; i < max ; ++i ) { |
188 | QString s = attList[i]; | 189 | QString s = attList[i]; |
189 | if ( ! s.isEmpty() ){ | 190 | if ( ! s.isEmpty() ){ |
190 | j = s.length(); | 191 | j = s.length(); |
191 | for ( k = 0; k < j; ++k ) { | 192 | for ( k = 0; k < j; ++k ) { |
192 | int mul = k +1; | 193 | int mul = k +1; |
193 | add = s[k].unicode (); | 194 | add = s[k].unicode (); |
194 | if ( k < 16 ) | 195 | if ( k < 16 ) |
195 | mul = mul * mul; | 196 | mul = mul * mul; |
196 | int ii = i+1; | 197 | int ii = i+1; |
197 | add = add * mul *ii*ii*ii; | 198 | add = add * mul *ii*ii*ii; |
198 | cSum += add; | 199 | cSum += add; |
199 | //qDebug("csum: %d %d %d", i,k,cSum); | 200 | //qDebug("csum: %d %d %d", i,k,cSum); |
200 | } | 201 | } |
201 | } | 202 | } |
202 | 203 | ||
203 | } | 204 | } |
204 | //QString dump = attList.join(","); | 205 | //QString dump = attList.join(","); |
205 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 206 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
206 | 207 | ||
207 | return cSum; | 208 | return cSum; |
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 ); |
221 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 222 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
222 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 223 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
223 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 224 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
224 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 225 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
225 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 226 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
226 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 227 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
227 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 228 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
228 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 229 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
229 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 230 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
230 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 231 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
231 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 232 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
232 | if ( !mData->logo.undefined() ) { | 233 | if ( !mData->logo.undefined() ) { |
233 | if ( !mData->logo.isIntern() ) | 234 | if ( !mData->logo.isIntern() ) |
234 | l.append( mData->logo.url() ); | 235 | l.append( mData->logo.url() ); |
235 | else | 236 | else |
236 | l.append( QString::number(mData->logo.data().width()* mData->logo.data().height())); | 237 | l.append( QString::number(mData->logo.data().width()* mData->logo.data().height())); |
237 | } else { | 238 | } else { |
238 | l.append( "nologo"); | 239 | l.append( "nologo"); |
239 | } | 240 | } |
240 | if ( !mData->photo.undefined() ) { | 241 | if ( !mData->photo.undefined() ) { |
241 | if ( !mData->photo.isIntern() ) | 242 | if ( !mData->photo.isIntern() ) |
242 | l.append( mData->photo.url() ); | 243 | l.append( mData->photo.url() ); |
243 | else | 244 | else |
244 | l.append( QString::number(mData->photo.data().width()* mData->photo.data().height())); | 245 | l.append( QString::number(mData->photo.data().width()* mData->photo.data().height())); |
245 | } else { | 246 | } else { |
246 | l.append( "nophoto"); | 247 | l.append( "nophoto"); |
247 | } | 248 | } |
248 | #if 0 | 249 | #if 0 |
249 | if ( !mData->sound.undefined() ) { | 250 | if ( !mData->sound.undefined() ) { |
250 | if ( !mData->sound.isIntern() ) | 251 | if ( !mData->sound.isIntern() ) |
251 | l.append( mData->sound.url() ); | 252 | l.append( mData->sound.url() ); |
252 | else | 253 | else |
253 | l.append( QString(mData->sound.data().with()* mData->sound.data().height())); | 254 | l.append( QString(mData->sound.data().with()* mData->sound.data().height())); |
254 | } else { | 255 | } else { |
255 | l.append( "nosound"); | 256 | l.append( "nosound"); |
256 | } | 257 | } |
257 | #endif | 258 | #endif |
258 | //if ( !mData->agent.isEmpty() ) l.append( ); | 259 | //if ( !mData->agent.isEmpty() ) l.append( ); |
259 | if ( mData->url.isValid() ) | 260 | if ( mData->url.isValid() ) |
260 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 261 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
261 | KABC::PhoneNumber::List phoneNumbers; | 262 | KABC::PhoneNumber::List phoneNumbers; |
262 | KABC::PhoneNumber::List::Iterator phoneIter; | 263 | KABC::PhoneNumber::List::Iterator phoneIter; |
@@ -287,96 +288,143 @@ void Addressee::computeCsum(const QString &dev) | |||
287 | l.append( t[iii] ); | 288 | l.append( t[iii] ); |
288 | 289 | ||
289 | } | 290 | } |
290 | KABC::Address::List::Iterator addressIter; | 291 | KABC::Address::List::Iterator addressIter; |
291 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 292 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
292 | ++addressIter ) { | 293 | ++addressIter ) { |
293 | t = (*addressIter).asList(); | 294 | t = (*addressIter).asList(); |
294 | t.sort(); | 295 | t.sort(); |
295 | for ( iii = 0; iii < t.count(); ++iii) | 296 | for ( iii = 0; iii < t.count(); ++iii) |
296 | l.append( t[iii] ); | 297 | l.append( t[iii] ); |
297 | } | 298 | } |
298 | uint cs = getCsum4List(l); | 299 | uint cs = getCsum4List(l); |
299 | 300 | ||
300 | #if 0 | 301 | #if 0 |
301 | for ( iii = 0; iii < l.count(); ++iii) | 302 | for ( iii = 0; iii < l.count(); ++iii) |
302 | qDebug("%d***%s***",iii,l[iii].latin1()); | 303 | qDebug("%d***%s***",iii,l[iii].latin1()); |
303 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 304 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
304 | #endif | 305 | #endif |
305 | 306 | ||
306 | 307 | ||
307 | setCsum( dev, QString::number (cs )); | 308 | setCsum( dev, QString::number (cs )); |
308 | } | 309 | } |
309 | bool Addressee::matchAddress( QRegExp* re ) const | 310 | bool Addressee::matchAddress( QRegExp* re ) const |
310 | { | 311 | { |
311 | KABC::Address::List::Iterator addressIter; | 312 | KABC::Address::List::Iterator addressIter; |
312 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 313 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
313 | ++addressIter ) { | 314 | ++addressIter ) { |
314 | if ( (*addressIter).matchAddress( re ) ) | 315 | if ( (*addressIter).matchAddress( re ) ) |
315 | return true; | 316 | return true; |
316 | } | 317 | } |
317 | return false; | 318 | return false; |
318 | } | 319 | } |
319 | bool Addressee::matchPhoneNumber( QRegExp* re ) const | 320 | bool Addressee::matchPhoneNumber( QRegExp* re ) const |
320 | { | 321 | { |
321 | KABC::PhoneNumber::List::Iterator phoneIter; | 322 | KABC::PhoneNumber::List::Iterator phoneIter; |
322 | 323 | ||
323 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) { | 324 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) { |
324 | #if QT_VERSION >= 0x030000 | 325 | #if QT_VERSION >= 0x030000 |
325 | if (re->search( (*phoneIter).number() ) == 0) | 326 | if (re->search( (*phoneIter).number() ) == 0) |
326 | #else | 327 | #else |
327 | if (re->match( (*phoneIter).number() ) == 0) | 328 | if (re->match( (*phoneIter).number() ) == 0) |
328 | #endif | 329 | #endif |
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(); |
341 | if ( isSubSet ) { | 389 | if ( isSubSet ) { |
342 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 390 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
343 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 391 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
344 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 392 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
345 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 393 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
346 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 394 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
347 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 395 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
348 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 396 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
349 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 397 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
350 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 398 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
351 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 399 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
352 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 400 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
353 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 401 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
354 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 402 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
355 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 403 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
356 | if ( !mData->birthday.isValid() ) | 404 | if ( !mData->birthday.isValid() ) |
357 | if ( ad.mData->birthday.isValid()) | 405 | if ( ad.mData->birthday.isValid()) |
358 | mData->birthday = ad.mData->birthday; | 406 | mData->birthday = ad.mData->birthday; |
359 | 407 | ||
360 | } | 408 | } |
361 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 409 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
362 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 410 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
363 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 411 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
364 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 412 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
365 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 413 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
366 | QStringList t; | 414 | QStringList t; |
367 | QStringList tAD; | 415 | QStringList tAD; |
368 | uint iii; | 416 | uint iii; |
369 | 417 | ||
370 | // ********** phone numbers | 418 | // ********** phone numbers |
371 | if ( isSubSet ) { | 419 | if ( isSubSet ) { |
372 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 420 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
373 | PhoneNumber::List::Iterator phoneItAD; | 421 | PhoneNumber::List::Iterator phoneItAD; |
374 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 422 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
375 | bool found = false; | 423 | bool found = false; |
376 | PhoneNumber::List::Iterator it; | 424 | PhoneNumber::List::Iterator it; |
377 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 425 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
378 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 426 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
379 | found = true; | 427 | found = true; |
380 | (*it).setType( ( *phoneItAD ).type() ); | 428 | (*it).setType( ( *phoneItAD ).type() ); |
381 | (*it).setNumber( ( *phoneItAD ).number() ); | 429 | (*it).setNumber( ( *phoneItAD ).number() ); |
382 | break; | 430 | break; |
@@ -1608,163 +1656,173 @@ QString Addressee::fullEmail( const QString &email ) const | |||
1608 | 1656 | ||
1609 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1657 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1610 | { | 1658 | { |
1611 | detach(); | 1659 | detach(); |
1612 | 1660 | ||
1613 | QStringList::Iterator it = mData->emails.find( email ); | 1661 | QStringList::Iterator it = mData->emails.find( email ); |
1614 | 1662 | ||
1615 | if ( it != mData->emails.end() ) { | 1663 | if ( it != mData->emails.end() ) { |
1616 | if ( !preferred || it == mData->emails.begin() ) return; | 1664 | if ( !preferred || it == mData->emails.begin() ) return; |
1617 | mData->emails.remove( it ); | 1665 | mData->emails.remove( it ); |
1618 | mData->emails.prepend( email ); | 1666 | mData->emails.prepend( email ); |
1619 | } else { | 1667 | } else { |
1620 | if ( preferred ) { | 1668 | if ( preferred ) { |
1621 | mData->emails.prepend( email ); | 1669 | mData->emails.prepend( email ); |
1622 | } else { | 1670 | } else { |
1623 | mData->emails.append( email ); | 1671 | mData->emails.append( email ); |
1624 | } | 1672 | } |
1625 | } | 1673 | } |
1626 | } | 1674 | } |
1627 | 1675 | ||
1628 | void Addressee::removeEmail( const QString &email ) | 1676 | void Addressee::removeEmail( const QString &email ) |
1629 | { | 1677 | { |
1630 | detach(); | 1678 | detach(); |
1631 | 1679 | ||
1632 | QStringList::Iterator it = mData->emails.find( email ); | 1680 | QStringList::Iterator it = mData->emails.find( email ); |
1633 | if ( it == mData->emails.end() ) return; | 1681 | if ( it == mData->emails.end() ) return; |
1634 | 1682 | ||
1635 | mData->emails.remove( it ); | 1683 | mData->emails.remove( it ); |
1636 | } | 1684 | } |
1637 | 1685 | ||
1638 | QString Addressee::preferredEmail() const | 1686 | QString Addressee::preferredEmail() const |
1639 | { | 1687 | { |
1640 | if ( mData->emails.count() == 0 ) return QString::null; | 1688 | if ( mData->emails.count() == 0 ) return QString::null; |
1641 | else return mData->emails.first(); | 1689 | else return mData->emails.first(); |
1642 | } | 1690 | } |
1643 | 1691 | ||
1644 | QStringList Addressee::emails() const | 1692 | QStringList Addressee::emails() const |
1645 | { | 1693 | { |
1646 | return mData->emails; | 1694 | return mData->emails; |
1647 | } | 1695 | } |
1648 | void Addressee::setEmails( const QStringList& emails ) { | 1696 | void Addressee::setEmails( const QStringList& emails ) { |
1649 | detach(); | 1697 | detach(); |
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 | } |
1663 | } | 1710 | } |
1664 | mData->phoneNumbers.append( phoneNumber ); | 1711 | mData->phoneNumbers.append( phoneNumber ); |
1665 | } | 1712 | } |
1666 | 1713 | ||
1667 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1714 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1668 | { | 1715 | { |
1669 | detach(); | 1716 | detach(); |
1670 | 1717 | ||
1671 | PhoneNumber::List::Iterator it; | 1718 | PhoneNumber::List::Iterator it; |
1672 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1719 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1673 | if ( (*it).id() == phoneNumber.id() ) { | 1720 | if ( (*it).id() == phoneNumber.id() ) { |
1674 | mData->phoneNumbers.remove( it ); | 1721 | mData->phoneNumbers.remove( it ); |
1675 | return; | 1722 | return; |
1676 | } | 1723 | } |
1677 | } | 1724 | } |
1678 | } | 1725 | } |
1679 | 1726 | ||
1680 | PhoneNumber Addressee::phoneNumber( int type ) const | 1727 | PhoneNumber Addressee::phoneNumber( int type ) const |
1681 | { | 1728 | { |
1682 | PhoneNumber phoneNumber( "", type ); | 1729 | PhoneNumber phoneNumber( "", type ); |
1683 | PhoneNumber::List::ConstIterator it; | 1730 | PhoneNumber::List::ConstIterator it; |
1684 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1731 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1685 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1732 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1686 | if ( (*it).type() & PhoneNumber::Pref ) | 1733 | if ( (*it).type() & PhoneNumber::Pref ) |
1687 | return (*it); | 1734 | return (*it); |
1688 | else if ( phoneNumber.number().isEmpty() ) | 1735 | else if ( phoneNumber.number().isEmpty() ) |
1689 | phoneNumber = (*it); | 1736 | phoneNumber = (*it); |
1690 | } | 1737 | } |
1691 | } | 1738 | } |
1692 | 1739 | ||
1693 | return phoneNumber; | 1740 | return phoneNumber; |
1694 | } | 1741 | } |
1695 | 1742 | ||
1696 | PhoneNumber::List Addressee::phoneNumbers() const | 1743 | PhoneNumber::List Addressee::phoneNumbers() const |
1697 | { | 1744 | { |
1698 | return mData->phoneNumbers; | 1745 | return mData->phoneNumbers; |
1699 | } | 1746 | } |
1700 | 1747 | ||
1701 | int Addressee::hasPhoneNumberType( int type ) | 1748 | int Addressee::hasPhoneNumberType( int type ) |
1702 | { | 1749 | { |
1703 | int retval = 0; | 1750 | int retval = 0; |
1704 | PhoneNumber::List::ConstIterator it; | 1751 | PhoneNumber::List::ConstIterator it; |
1705 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1752 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1706 | if ( (*it).type() == type ) | 1753 | if ( (*it).type() == type ) |
1707 | ++retval; | 1754 | ++retval; |
1708 | } | 1755 | } |
1709 | return retval; | 1756 | return retval; |
1710 | } | 1757 | } |
1711 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1758 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1712 | { | 1759 | { |
1713 | PhoneNumber::List list; | 1760 | PhoneNumber::List list; |
1714 | 1761 | ||
1715 | PhoneNumber::List::ConstIterator it; | 1762 | PhoneNumber::List::ConstIterator it; |
1716 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1763 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
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 ) { |
1729 | return *it; | 1787 | return *it; |
1730 | } | 1788 | } |
1731 | } | 1789 | } |
1732 | return PhoneNumber(); | 1790 | return PhoneNumber(); |
1733 | } | 1791 | } |
1734 | 1792 | ||
1735 | void Addressee::insertKey( const Key &key ) | 1793 | void Addressee::insertKey( const Key &key ) |
1736 | { | 1794 | { |
1737 | detach(); | 1795 | detach(); |
1738 | mData->empty = false; | 1796 | mData->empty = false; |
1739 | 1797 | ||
1740 | Key::List::Iterator it; | 1798 | Key::List::Iterator it; |
1741 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1799 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1742 | if ( (*it).id() == key.id() ) { | 1800 | if ( (*it).id() == key.id() ) { |
1743 | *it = key; | 1801 | *it = key; |
1744 | return; | 1802 | return; |
1745 | } | 1803 | } |
1746 | } | 1804 | } |
1747 | mData->keys.append( key ); | 1805 | mData->keys.append( key ); |
1748 | } | 1806 | } |
1749 | 1807 | ||
1750 | void Addressee::removeKey( const Key &key ) | 1808 | void Addressee::removeKey( const Key &key ) |
1751 | { | 1809 | { |
1752 | detach(); | 1810 | detach(); |
1753 | 1811 | ||
1754 | Key::List::Iterator it; | 1812 | Key::List::Iterator it; |
1755 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1813 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1756 | if ( (*it).id() == key.id() ) { | 1814 | if ( (*it).id() == key.id() ) { |
1757 | mData->keys.remove( key ); | 1815 | mData->keys.remove( key ); |
1758 | return; | 1816 | return; |
1759 | } | 1817 | } |
1760 | } | 1818 | } |
1761 | } | 1819 | } |
1762 | 1820 | ||
1763 | Key Addressee::key( int type, QString customTypeString ) const | 1821 | Key Addressee::key( int type, QString customTypeString ) const |
1764 | { | 1822 | { |
1765 | Key::List::ConstIterator it; | 1823 | Key::List::ConstIterator it; |
1766 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1824 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1767 | if ( (*it).type() == type ) { | 1825 | if ( (*it).type() == type ) { |
1768 | if ( type == Key::Custom ) { | 1826 | if ( type == Key::Custom ) { |
1769 | if ( customTypeString.isEmpty() ) { | 1827 | if ( customTypeString.isEmpty() ) { |
1770 | return *it; | 1828 | return *it; |
@@ -1880,97 +1938,108 @@ void Addressee::dump() const | |||
1880 | Address::List a = addresses(); | 1938 | Address::List a = addresses(); |
1881 | Address::List::ConstIterator it3; | 1939 | Address::List::ConstIterator it3; |
1882 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1940 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1883 | (*it3).dump(); | 1941 | (*it3).dump(); |
1884 | } | 1942 | } |
1885 | 1943 | ||
1886 | kdDebug(5700) << " Keys {" << endl; | 1944 | kdDebug(5700) << " Keys {" << endl; |
1887 | Key::List k = keys(); | 1945 | Key::List k = keys(); |
1888 | Key::List::ConstIterator it4; | 1946 | Key::List::ConstIterator it4; |
1889 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1947 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1890 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1948 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1891 | " Key: " << (*it4).textData() << | 1949 | " Key: " << (*it4).textData() << |
1892 | " CustomString: " << (*it4).customTypeString() << endl; | 1950 | " CustomString: " << (*it4).customTypeString() << endl; |
1893 | } | 1951 | } |
1894 | kdDebug(5700) << " }" << endl; | 1952 | kdDebug(5700) << " }" << endl; |
1895 | 1953 | ||
1896 | kdDebug(5700) << "}" << endl; | 1954 | kdDebug(5700) << "}" << endl; |
1897 | #endif | 1955 | #endif |
1898 | } | 1956 | } |
1899 | 1957 | ||
1900 | 1958 | ||
1901 | void Addressee::insertAddress( const Address &address ) | 1959 | void Addressee::insertAddress( const Address &address ) |
1902 | { | 1960 | { |
1903 | detach(); | 1961 | detach(); |
1904 | mData->empty = false; | 1962 | mData->empty = false; |
1905 | 1963 | ||
1906 | Address::List::Iterator it; | 1964 | Address::List::Iterator it; |
1907 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1965 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1908 | if ( (*it).id() == address.id() ) { | 1966 | if ( (*it).id() == address.id() ) { |
1909 | *it = address; | 1967 | *it = address; |
1910 | return; | 1968 | return; |
1911 | } | 1969 | } |
1912 | } | 1970 | } |
1913 | mData->addresses.append( address ); | 1971 | mData->addresses.append( address ); |
1914 | } | 1972 | } |
1915 | 1973 | ||
1916 | void Addressee::removeAddress( const Address &address ) | 1974 | void Addressee::removeAddress( const Address &address ) |
1917 | { | 1975 | { |
1918 | detach(); | 1976 | detach(); |
1919 | 1977 | ||
1920 | Address::List::Iterator it; | 1978 | Address::List::Iterator it; |
1921 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1979 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
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 ) ) { |
1935 | if ( (*it).type() & Address::Pref ) | 2004 | if ( (*it).type() & Address::Pref ) |
1936 | return (*it); | 2005 | return (*it); |
1937 | else if ( address.isEmpty() ) | 2006 | else if ( address.isEmpty() ) |
1938 | address = (*it); | 2007 | address = (*it); |
1939 | } | 2008 | } |
1940 | } | 2009 | } |
1941 | 2010 | ||
1942 | return address; | 2011 | return address; |
1943 | } | 2012 | } |
1944 | 2013 | ||
1945 | Address::List Addressee::addresses() const | 2014 | Address::List Addressee::addresses() const |
1946 | { | 2015 | { |
1947 | return mData->addresses; | 2016 | return mData->addresses; |
1948 | } | 2017 | } |
1949 | 2018 | ||
1950 | Address::List Addressee::addresses( int type ) const | 2019 | Address::List Addressee::addresses( int type ) const |
1951 | { | 2020 | { |
1952 | Address::List list; | 2021 | Address::List list; |
1953 | 2022 | ||
1954 | Address::List::ConstIterator it; | 2023 | Address::List::ConstIterator it; |
1955 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 2024 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1956 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 2025 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1957 | list.append( *it ); | 2026 | list.append( *it ); |
1958 | } | 2027 | } |
1959 | } | 2028 | } |
1960 | 2029 | ||
1961 | return list; | 2030 | return list; |
1962 | } | 2031 | } |
1963 | 2032 | ||
1964 | Address Addressee::findAddress( const QString &id ) const | 2033 | Address Addressee::findAddress( const QString &id ) const |
1965 | { | 2034 | { |
1966 | Address::List::ConstIterator it; | 2035 | Address::List::ConstIterator it; |
1967 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 2036 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1968 | if ( (*it).id() == id ) { | 2037 | if ( (*it).id() == id ) { |
1969 | return *it; | 2038 | return *it; |
1970 | } | 2039 | } |
1971 | } | 2040 | } |
1972 | return Address(); | 2041 | return Address(); |
1973 | } | 2042 | } |
1974 | 2043 | ||
1975 | void Addressee::insertCategory( const QString &c ) | 2044 | void Addressee::insertCategory( const QString &c ) |
1976 | { | 2045 | { |
diff --git a/kabc/addressee.h b/kabc/addressee.h index aac78dc..0ea1803 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -73,96 +73,97 @@ class Resource; | |||
73 | 73 | ||
74 | realName() returns a fully formatted name(). It uses formattedName, if set, | 74 | realName() returns a fully formatted name(). It uses formattedName, if set, |
75 | otherwise it constucts the name from the name fields. As fallback, if | 75 | otherwise it constucts the name from the name fields. As fallback, if |
76 | nothing else is set it uses name(). | 76 | nothing else is set it uses name(). |
77 | 77 | ||
78 | name() is the NAME type of RFC2426. It can be used as internal name for the | 78 | name() is the NAME type of RFC2426. It can be used as internal name for the |
79 | data enty, but shouldn't be used for displaying the data to the user. | 79 | data enty, but shouldn't be used for displaying the data to the user. |
80 | */ | 80 | */ |
81 | class Addressee | 81 | class Addressee |
82 | { | 82 | { |
83 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); | 83 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); |
84 | friend QDataStream &operator>>( QDataStream &, Addressee & ); | 84 | friend QDataStream &operator>>( QDataStream &, Addressee & ); |
85 | 85 | ||
86 | public: | 86 | public: |
87 | typedef QValueList<Addressee> List; | 87 | typedef QValueList<Addressee> List; |
88 | 88 | ||
89 | /** | 89 | /** |
90 | Construct an empty address book entry. | 90 | Construct an empty address book entry. |
91 | */ | 91 | */ |
92 | Addressee(); | 92 | Addressee(); |
93 | ~Addressee(); | 93 | ~Addressee(); |
94 | 94 | ||
95 | Addressee( const Addressee & ); | 95 | Addressee( const Addressee & ); |
96 | Addressee &operator=( const Addressee & ); | 96 | Addressee &operator=( const Addressee & ); |
97 | 97 | ||
98 | bool operator==( const Addressee & ) const; | 98 | bool operator==( const Addressee & ) const; |
99 | bool operator!=( const Addressee & ) const; | 99 | bool operator!=( const Addressee & ) const; |
100 | // sync stuff | 100 | // sync stuff |
101 | void setTempSyncStat(int id); | 101 | void setTempSyncStat(int id); |
102 | int tempSyncStat() const; | 102 | int tempSyncStat() const; |
103 | void setIDStr( const QString & ); | 103 | void setIDStr( const QString & ); |
104 | const QString IDStr() const; | 104 | const QString IDStr() const; |
105 | void setID( const QString &, const QString & ); | 105 | void setID( const QString &, const QString & ); |
106 | const QString getID( const QString & ) const; | 106 | const QString getID( const QString & ) const; |
107 | void setCsum( const QString &, const QString & ); | 107 | void setCsum( const QString &, const QString & ); |
108 | const QString getCsum( const QString & ) const ; | 108 | const QString getCsum( const QString & ) const ; |
109 | void removeID(const QString &); | 109 | void removeID(const QString &); |
110 | void computeCsum(const QString &dev); | 110 | void computeCsum(const QString &dev); |
111 | ulong getCsum4List( const QStringList & attList); | 111 | ulong getCsum4List( const QStringList & attList); |
112 | /** | 112 | /** |
113 | Return, if the address book entry is empty. | 113 | Return, if the address book entry is empty. |
114 | */ | 114 | */ |
115 | bool isEmpty() const; | 115 | bool isEmpty() const; |
116 | void setExternalUID( const QString &id ); | 116 | void setExternalUID( const QString &id ); |
117 | const QString externalUID() const; | 117 | const QString externalUID() const; |
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(); |
124 | void simplifyPhoneNumberTypes(); | 125 | void simplifyPhoneNumberTypes(); |
125 | void makePhoneNumbersOLcompatible(); | 126 | void makePhoneNumbersOLcompatible(); |
126 | int hasPhoneNumberType( int type ); | 127 | int hasPhoneNumberType( int type ); |
127 | bool removeVoice(); | 128 | bool removeVoice(); |
128 | bool containsAdr(const Addressee& addr ); | 129 | bool containsAdr(const Addressee& addr ); |
129 | 130 | ||
130 | /** | 131 | /** |
131 | Set unique identifier. | 132 | Set unique identifier. |
132 | */ | 133 | */ |
133 | void setUid( const QString &uid ); | 134 | void setUid( const QString &uid ); |
134 | /** | 135 | /** |
135 | Return unique identifier. | 136 | Return unique identifier. |
136 | */ | 137 | */ |
137 | const QString uid() const; | 138 | const QString uid() const; |
138 | /** | 139 | /** |
139 | Return translated label for uid field. | 140 | Return translated label for uid field. |
140 | */ | 141 | */ |
141 | static QString uidLabel(); | 142 | static QString uidLabel(); |
142 | 143 | ||
143 | /** | 144 | /** |
144 | Set name. | 145 | Set name. |
145 | */ | 146 | */ |
146 | void setName( const QString &name ); | 147 | void setName( const QString &name ); |
147 | /** | 148 | /** |
148 | Return name. | 149 | Return name. |
149 | */ | 150 | */ |
150 | QString name() const; | 151 | QString name() const; |
151 | /** | 152 | /** |
152 | Return translated label for name field. | 153 | Return translated label for name field. |
153 | */ | 154 | */ |
154 | static QString nameLabel(); | 155 | static QString nameLabel(); |
155 | 156 | ||
156 | /** | 157 | /** |
157 | Set formatted name. | 158 | Set formatted name. |
158 | */ | 159 | */ |
159 | void setFormattedName( const QString &formattedName ); | 160 | void setFormattedName( const QString &formattedName ); |
160 | /** | 161 | /** |
161 | Return formatted name. | 162 | Return formatted name. |
162 | */ | 163 | */ |
163 | QString formattedName() const; | 164 | QString formattedName() const; |
164 | /** | 165 | /** |
165 | Return translated label for formattedName field. | 166 | Return translated label for formattedName field. |
166 | */ | 167 | */ |
167 | static QString formattedNameLabel(); | 168 | static QString formattedNameLabel(); |
168 | 169 | ||
@@ -602,181 +603,182 @@ class Addressee | |||
602 | Insert an email address. If the email address already exists in this | 603 | Insert an email address. If the email address already exists in this |
603 | addressee it is not duplicated. | 604 | addressee it is not duplicated. |
604 | 605 | ||
605 | @param email Email address | 606 | @param email Email address |
606 | @param preferred Set to true, if this is the preferred email address of | 607 | @param preferred Set to true, if this is the preferred email address of |
607 | the addressee. | 608 | the addressee. |
608 | */ | 609 | */ |
609 | void insertEmail( const QString &email, bool preferred=false ); | 610 | void insertEmail( const QString &email, bool preferred=false ); |
610 | 611 | ||
611 | /** | 612 | /** |
612 | Remove email address. If the email address doesn't exist, nothing happens. | 613 | Remove email address. If the email address doesn't exist, nothing happens. |
613 | */ | 614 | */ |
614 | void removeEmail( const QString &email ); | 615 | void removeEmail( const QString &email ); |
615 | 616 | ||
616 | /** | 617 | /** |
617 | Return preferred email address. This is the first email address or the | 618 | Return preferred email address. This is the first email address or the |
618 | last one added with @ref insertEmail() with a set preferred parameter. | 619 | last one added with @ref insertEmail() with a set preferred parameter. |
619 | */ | 620 | */ |
620 | QString preferredEmail() const; | 621 | QString preferredEmail() const; |
621 | 622 | ||
622 | /** | 623 | /** |
623 | Return list of all email addresses. | 624 | Return list of all email addresses. |
624 | */ | 625 | */ |
625 | QStringList emails() const; | 626 | QStringList emails() const; |
626 | 627 | ||
627 | /** | 628 | /** |
628 | Set the emails to @param. | 629 | Set the emails to @param. |
629 | The first email address gets the preferred one! | 630 | The first email address gets the preferred one! |
630 | @param list The list of email addresses. | 631 | @param list The list of email addresses. |
631 | */ | 632 | */ |
632 | void setEmails( const QStringList& list); | 633 | void setEmails( const QStringList& list); |
633 | 634 | ||
634 | /** | 635 | /** |
635 | Insert a phone number. If a phone number with the same id already exists | 636 | Insert a phone number. If a phone number with the same id already exists |
636 | in this addressee it is not duplicated. | 637 | in this addressee it is not duplicated. |
637 | */ | 638 | */ |
638 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); | 639 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); |
639 | 640 | ||
640 | /** | 641 | /** |
641 | Remove phone number. If no phone number with the given id exists for this | 642 | Remove phone number. If no phone number with the given id exists for this |
642 | addresse nothing happens. | 643 | addresse nothing happens. |
643 | */ | 644 | */ |
644 | void removePhoneNumber( const PhoneNumber &phoneNumber ); | 645 | void removePhoneNumber( const PhoneNumber &phoneNumber ); |
645 | 646 | ||
646 | /** | 647 | /** |
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; |
653 | 655 | ||
654 | /** | 656 | /** |
655 | Return list of all phone numbers. | 657 | Return list of all phone numbers. |
656 | */ | 658 | */ |
657 | PhoneNumber::List phoneNumbers() const; | 659 | PhoneNumber::List phoneNumbers() const; |
658 | 660 | ||
659 | /** | 661 | /** |
660 | Return list of phone numbers with a special type. | 662 | Return list of phone numbers with a special type. |
661 | */ | 663 | */ |
662 | PhoneNumber::List phoneNumbers( int type ) const; | 664 | PhoneNumber::List phoneNumbers( int type ) const; |
663 | 665 | ||
664 | /** | 666 | /** |
665 | Return phone number with the given id. | 667 | Return phone number with the given id. |
666 | */ | 668 | */ |
667 | PhoneNumber findPhoneNumber( const QString &id ) const; | 669 | PhoneNumber findPhoneNumber( const QString &id ) const; |
668 | 670 | ||
669 | /** | 671 | /** |
670 | Insert a key. If a key with the same id already exists | 672 | Insert a key. If a key with the same id already exists |
671 | in this addressee it is not duplicated. | 673 | in this addressee it is not duplicated. |
672 | */ | 674 | */ |
673 | void insertKey( const Key &key ); | 675 | void insertKey( const Key &key ); |
674 | 676 | ||
675 | /** | 677 | /** |
676 | Remove a key. If no key with the given id exists for this | 678 | Remove a key. If no key with the given id exists for this |
677 | addresse nothing happens. | 679 | addresse nothing happens. |
678 | */ | 680 | */ |
679 | void removeKey( const Key &key ); | 681 | void removeKey( const Key &key ); |
680 | 682 | ||
681 | /** | 683 | /** |
682 | Return key, which matches the given type. | 684 | Return key, which matches the given type. |
683 | If @p type == Key::Custom you can specify a string | 685 | If @p type == Key::Custom you can specify a string |
684 | that should match. If you leave the string empty, the first | 686 | that should match. If you leave the string empty, the first |
685 | key with a custom value is returned. | 687 | key with a custom value is returned. |
686 | */ | 688 | */ |
687 | Key key( int type, QString customTypeString = QString::null ) const; | 689 | Key key( int type, QString customTypeString = QString::null ) const; |
688 | 690 | ||
689 | /** | 691 | /** |
690 | Return list of all keys. | 692 | Return list of all keys. |
691 | */ | 693 | */ |
692 | Key::List keys() const; | 694 | Key::List keys() const; |
693 | 695 | ||
694 | /** | 696 | /** |
695 | Set the list of keys | 697 | Set the list of keys |
696 | @param keys The keys to be set. | 698 | @param keys The keys to be set. |
697 | */ | 699 | */ |
698 | void setKeys( const Key::List& keys); | 700 | void setKeys( const Key::List& keys); |
699 | 701 | ||
700 | /** | 702 | /** |
701 | Return list of keys with a special type. | 703 | Return list of keys with a special type. |
702 | If @p type == Key::Custom you can specify a string | 704 | If @p type == Key::Custom you can specify a string |
703 | that should match. If you leave the string empty, all custom | 705 | that should match. If you leave the string empty, all custom |
704 | keys will be returned. | 706 | keys will be returned. |
705 | */ | 707 | */ |
706 | Key::List keys( int type, QString customTypeString = QString::null ) const; | 708 | Key::List keys( int type, QString customTypeString = QString::null ) const; |
707 | 709 | ||
708 | /** | 710 | /** |
709 | Return key with the given id. | 711 | Return key with the given id. |
710 | */ | 712 | */ |
711 | Key findKey( const QString &id ) const; | 713 | Key findKey( const QString &id ) const; |
712 | 714 | ||
713 | /** | 715 | /** |
714 | Insert an address. If an address with the same id already exists | 716 | Insert an address. If an address with the same id already exists |
715 | in this addressee it is not duplicated. | 717 | in this addressee it is not duplicated. |
716 | */ | 718 | */ |
717 | void insertAddress( const Address &address ); | 719 | void insertAddress( const Address &address ); |
718 | 720 | ||
719 | /** | 721 | /** |
720 | Remove address. If no address with the given id exists for this | 722 | Remove address. If no address with the given id exists for this |
721 | addresse nothing happens. | 723 | addresse nothing happens. |
722 | */ | 724 | */ |
723 | void removeAddress( const Address &address ); | 725 | void removeAddress( const Address &address ); |
724 | 726 | ||
725 | /** | 727 | /** |
726 | Return address, which matches the given type. | 728 | Return address, which matches the given type. |
727 | */ | 729 | */ |
728 | Address address( int type ) const; | 730 | Address address( int type ) const; |
729 | 731 | ||
730 | /** | 732 | /** |
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 | */ |
738 | Address::List addresses( int type ) const; | 740 | Address::List addresses( int type ) const; |
739 | 741 | ||
740 | /** | 742 | /** |
741 | Return address with the given id. | 743 | Return address with the given id. |
742 | */ | 744 | */ |
743 | Address findAddress( const QString &id ) const; | 745 | Address findAddress( const QString &id ) const; |
744 | 746 | ||
745 | /** | 747 | /** |
746 | Insert category. If the category already exists it is not duplicated. | 748 | Insert category. If the category already exists it is not duplicated. |
747 | */ | 749 | */ |
748 | void insertCategory( const QString & ); | 750 | void insertCategory( const QString & ); |
749 | 751 | ||
750 | /** | 752 | /** |
751 | Remove category. | 753 | Remove category. |
752 | */ | 754 | */ |
753 | void removeCategory( const QString & ); | 755 | void removeCategory( const QString & ); |
754 | 756 | ||
755 | /** | 757 | /** |
756 | Return, if addressee has the given category. | 758 | Return, if addressee has the given category. |
757 | */ | 759 | */ |
758 | bool hasCategory( const QString & ) const; | 760 | bool hasCategory( const QString & ) const; |
759 | 761 | ||
760 | /** | 762 | /** |
761 | Set categories to given value. | 763 | Set categories to given value. |
762 | */ | 764 | */ |
763 | void setCategories( const QStringList & ); | 765 | void setCategories( const QStringList & ); |
764 | 766 | ||
765 | /** | 767 | /** |
766 | Return list of all set categories. | 768 | Return list of all set categories. |
767 | */ | 769 | */ |
768 | QStringList categories() const; | 770 | QStringList categories() const; |
769 | 771 | ||
770 | /** | 772 | /** |
771 | Insert custom entry. The entry is identified by the name of the inserting | 773 | Insert custom entry. The entry is identified by the name of the inserting |
772 | application and a unique name. If an entry with the given app and name | 774 | application and a unique name. If an entry with the given app and name |
773 | already exists its value is replaced with the new given value. | 775 | already exists its value is replaced with the new given value. |
774 | */ | 776 | */ |
775 | void insertCustom( const QString &app, const QString &name, | 777 | void insertCustom( const QString &app, const QString &name, |
776 | const QString &value ); | 778 | const QString &value ); |
777 | 779 | ||
778 | /** | 780 | /** |
779 | Remove custom entry. | 781 | Remove custom entry. |
780 | */ | 782 | */ |
781 | void removeCustom( const QString &app, const QString &name ); | 783 | void removeCustom( const QString &app, const QString &name ); |
782 | 784 | ||
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index 12b9b09..1752745 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp | |||
@@ -187,96 +187,120 @@ void PhoneNumber::setType( int type ) | |||
187 | mType = type; | 187 | mType = type; |
188 | } | 188 | } |
189 | 189 | ||
190 | int PhoneNumber::type() const | 190 | int PhoneNumber::type() const |
191 | { | 191 | { |
192 | return mType; | 192 | return mType; |
193 | } | 193 | } |
194 | 194 | ||
195 | QString PhoneNumber::typeLabel() const | 195 | QString PhoneNumber::typeLabel() const |
196 | { | 196 | { |
197 | QString label; | 197 | QString label; |
198 | bool first = true; | 198 | bool first = true; |
199 | 199 | ||
200 | TypeList list = typeList(); | 200 | TypeList list = typeList(); |
201 | 201 | ||
202 | TypeList::Iterator it; | 202 | TypeList::Iterator it; |
203 | for ( it = list.begin(); it != list.end(); ++it ) { | 203 | for ( it = list.begin(); it != list.end(); ++it ) { |
204 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { | 204 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { |
205 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); | 205 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); |
206 | if ( first ) | 206 | if ( first ) |
207 | first = false; | 207 | first = false; |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | return label; | 211 | return label; |
212 | } | 212 | } |
213 | 213 | ||
214 | QString PhoneNumber::label() const | 214 | QString PhoneNumber::label() const |
215 | { | 215 | { |
216 | return typeLabel( type() ); | 216 | return typeLabel( type() ); |
217 | } | 217 | } |
218 | 218 | ||
219 | PhoneNumber::TypeList PhoneNumber::typeList() | 219 | PhoneNumber::TypeList PhoneNumber::typeList() |
220 | { | 220 | { |
221 | TypeList list; | 221 | TypeList list; |
222 | 222 | ||
223 | list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video | 223 | list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video |
224 | << Bbs << Modem << Car << Isdn << Pcs << Pager; | 224 | << Bbs << Modem << Car << Isdn << Pcs << Pager; |
225 | 225 | ||
226 | return list; | 226 | return list; |
227 | } | 227 | } |
228 | PhoneNumber::TypeList PhoneNumber::supportedTypeList() | 228 | PhoneNumber::TypeList PhoneNumber::supportedTypeList() |
229 | { | 229 | { |
230 | static TypeList list; | 230 | static TypeList list; |
231 | if ( list.count() == 0 ) | 231 | if ( list.count() == 0 ) |
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; |
238 | if ( list.count() == 0 ) | 262 | if ( list.count() == 0 ) |
239 | list << i18n("Home") << i18n("Work") << i18n("Mobile") << i18n("SiP") << i18n("VoIP") <<i18n("Home2")<< i18n("Work2") << i18n("Mobile2") << i18n("SiP2") << i18n("Assistent") << i18n("Company") << i18n("Fax (Home)") << i18n("Fax (Work)") << i18n("Fax (Other)") << i18n("Pager") << i18n("ISDN") << i18n("Callback") << i18n("Primary")<< i18n("Other"); | 263 | list << i18n("Home") << i18n("Work") << i18n("Mobile") << i18n("SiP") << i18n("VoIP") <<i18n("Home2")<< i18n("Work2") << i18n("Mobile2") << i18n("SiP2") << i18n("Assistent") << i18n("Company") << i18n("Fax (Home)") << i18n("Fax (Work)") << i18n("Fax (Other)") << i18n("Pager") << i18n("ISDN") << i18n("Callback") << i18n("Primary")<< i18n("Other"); |
240 | return list; | 264 | return list; |
241 | } | 265 | } |
242 | 266 | ||
243 | int PhoneNumber::typeListIndex4Type(int type ) | 267 | int PhoneNumber::typeListIndex4Type(int type ) |
244 | { | 268 | { |
245 | TypeList list = supportedTypeList(); | 269 | TypeList list = supportedTypeList(); |
246 | int i = 0; | 270 | int i = 0; |
247 | while ( i < list.count() ) { | 271 | while ( i < list.count() ) { |
248 | if ( list [i] == type ) | 272 | if ( list [i] == type ) |
249 | return i; | 273 | return i; |
250 | ++i; | 274 | ++i; |
251 | } | 275 | } |
252 | return list.count()-1; | 276 | return list.count()-1; |
253 | } | 277 | } |
254 | 278 | ||
255 | QString PhoneNumber::label( int type ) | 279 | QString PhoneNumber::label( int type ) |
256 | { | 280 | { |
257 | return typeLabel( type ); | 281 | return typeLabel( type ); |
258 | } | 282 | } |
259 | 283 | ||
260 | QString PhoneNumber::typeLabel( int type ) | 284 | QString PhoneNumber::typeLabel( int type ) |
261 | { | 285 | { |
262 | if ((type & Cell) == Cell) | 286 | if ((type & Cell) == Cell) |
263 | return i18n("Mobile"); | 287 | return i18n("Mobile"); |
264 | if ((type & Home) == Home) { | 288 | if ((type & Home) == Home) { |
265 | if ((type & Pref) == Pref) | 289 | if ((type & Pref) == Pref) |
266 | return i18n("Home"); | 290 | return i18n("Home"); |
267 | if ((type & Fax) == Fax) | 291 | if ((type & Fax) == Fax) |
268 | return i18n("Fax (Home)"); | 292 | return i18n("Fax (Home)"); |
269 | return i18n("Home2"); | 293 | return i18n("Home2"); |
270 | } | 294 | } |
271 | 295 | ||
272 | if ((type & Work) == Work) { | 296 | if ((type & Work) == Work) { |
273 | if ((type & Pref) == Pref) | 297 | if ((type & Pref) == Pref) |
274 | return i18n("Work"); | 298 | return i18n("Work"); |
275 | if ((type & Fax) == Fax) | 299 | if ((type & Fax) == Fax) |
276 | return i18n("Fax (Work)"); | 300 | return i18n("Fax (Work)"); |
277 | if ((type & Msg) == Msg) { | 301 | if ((type & Msg) == Msg) { |
278 | if ((type & Voice) == Voice) | 302 | if ((type & Voice) == Voice) |
279 | return i18n("Assistent"); | 303 | return i18n("Assistent"); |
280 | return i18n("Company"); | 304 | return i18n("Company"); |
281 | } | 305 | } |
282 | return i18n("Work2"); | 306 | return i18n("Work2"); |