author | zautrix <zautrix> | 2005-01-18 14:09:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-18 14:09:00 (UTC) |
commit | ced210b0c4643ddac6a2e80eab4c85c1994b20e0 (patch) (unidiff) | |
tree | 5126b599b1213553ae71512a400f46d7b2037d92 /kabc/addressee.cpp | |
parent | 4b82a36d1b2479dd2e6f00aef45af848f6793099 (diff) | |
download | kdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.zip kdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.tar.gz kdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.tar.bz2 |
ab sync fixes
-rw-r--r-- | kabc/addressee.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index bfcfab5..18b4d58 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,792 +1,817 @@ | |||
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 <kidmanager.h> | 35 | #include <kidmanager.h> |
36 | //US | 36 | //US |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | //US #include "resource.h" | 40 | //US #include "resource.h" |
41 | #include "addressee.h" | 41 | #include "addressee.h" |
42 | 42 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 46 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 47 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 48 | ||
49 | struct Addressee::AddresseeData : public KShared | 49 | struct Addressee::AddresseeData : public KShared |
50 | { | 50 | { |
51 | QString uid; | 51 | QString uid; |
52 | QString name; | 52 | QString name; |
53 | QString formattedName; | 53 | QString formattedName; |
54 | QString familyName; | 54 | QString familyName; |
55 | QString givenName; | 55 | QString givenName; |
56 | QString additionalName; | 56 | QString additionalName; |
57 | QString prefix; | 57 | QString prefix; |
58 | QString suffix; | 58 | QString suffix; |
59 | QString nickName; | 59 | QString nickName; |
60 | QDateTime birthday; | 60 | QDateTime birthday; |
61 | QString mailer; | 61 | QString mailer; |
62 | TimeZone timeZone; | 62 | TimeZone timeZone; |
63 | Geo geo; | 63 | Geo geo; |
64 | QString title; | 64 | QString title; |
65 | QString role; | 65 | QString role; |
66 | QString organization; | 66 | QString organization; |
67 | QString note; | 67 | QString note; |
68 | QString productId; | 68 | QString productId; |
69 | QDateTime revision; | 69 | QDateTime revision; |
70 | QString sortString; | 70 | QString sortString; |
71 | QString externalUID; | 71 | QString externalUID; |
72 | QString originalExternalUID; | 72 | QString originalExternalUID; |
73 | KURL url; | 73 | KURL url; |
74 | Secrecy secrecy; | 74 | Secrecy secrecy; |
75 | Picture logo; | 75 | Picture logo; |
76 | Picture photo; | 76 | Picture photo; |
77 | Sound sound; | 77 | Sound sound; |
78 | Agent agent; | 78 | Agent agent; |
79 | QString mExternalId; | 79 | QString mExternalId; |
80 | PhoneNumber::List phoneNumbers; | 80 | PhoneNumber::List phoneNumbers; |
81 | Address::List addresses; | 81 | Address::List addresses; |
82 | Key::List keys; | 82 | Key::List keys; |
83 | QStringList emails; | 83 | QStringList emails; |
84 | QStringList categories; | 84 | QStringList categories; |
85 | QStringList custom; | 85 | QStringList custom; |
86 | int mTempSyncStat; | 86 | int mTempSyncStat; |
87 | Resource *resource; | 87 | Resource *resource; |
88 | 88 | ||
89 | bool empty :1; | 89 | bool empty :1; |
90 | bool changed :1; | 90 | bool changed :1; |
91 | bool tagged :1; | 91 | bool tagged :1; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | Addressee::Addressee() | 94 | Addressee::Addressee() |
95 | { | 95 | { |
96 | mData = new AddresseeData; | 96 | mData = new AddresseeData; |
97 | mData->empty = true; | 97 | mData->empty = true; |
98 | mData->changed = false; | 98 | mData->changed = false; |
99 | mData->resource = 0; | 99 | mData->resource = 0; |
100 | mData->mExternalId = ":"; | 100 | mData->mExternalId = ":"; |
101 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 101 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
103 | } | 103 | } |
104 | 104 | ||
105 | Addressee::~Addressee() | 105 | Addressee::~Addressee() |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee::Addressee( const Addressee &a ) | 109 | Addressee::Addressee( const Addressee &a ) |
110 | { | 110 | { |
111 | mData = a.mData; | 111 | mData = a.mData; |
112 | } | 112 | } |
113 | 113 | ||
114 | Addressee &Addressee::operator=( const Addressee &a ) | 114 | Addressee &Addressee::operator=( const Addressee &a ) |
115 | { | 115 | { |
116 | mData = a.mData; | 116 | mData = a.mData; |
117 | return (*this); | 117 | return (*this); |
118 | } | 118 | } |
119 | 119 | ||
120 | Addressee Addressee::copy() | 120 | Addressee Addressee::copy() |
121 | { | 121 | { |
122 | Addressee a; | 122 | Addressee a; |
123 | *(a.mData) = *mData; | 123 | *(a.mData) = *mData; |
124 | return a; | 124 | return a; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Addressee::detach() | 127 | void Addressee::detach() |
128 | { | 128 | { |
129 | if ( mData.count() == 1 ) return; | 129 | if ( mData.count() == 1 ) return; |
130 | *this = copy(); | 130 | *this = copy(); |
131 | } | 131 | } |
132 | 132 | ||
133 | bool Addressee::operator==( const Addressee &a ) const | 133 | bool Addressee::operator==( const Addressee &a ) const |
134 | { | 134 | { |
135 | if ( uid() != a.uid() ) return false; | 135 | if ( uid() != a.uid() ) return false; |
136 | if ( mData->name != a.mData->name ) return false; | 136 | if ( mData->name != a.mData->name ) return false; |
137 | if ( mData->formattedName != a.mData->formattedName ) return false; | 137 | if ( mData->formattedName != a.mData->formattedName ) return false; |
138 | if ( mData->familyName != a.mData->familyName ) return false; | 138 | if ( mData->familyName != a.mData->familyName ) return false; |
139 | if ( mData->givenName != a.mData->givenName ) return false; | 139 | if ( mData->givenName != a.mData->givenName ) return false; |
140 | if ( mData->additionalName != a.mData->additionalName ) return false; | 140 | if ( mData->additionalName != a.mData->additionalName ) return false; |
141 | if ( mData->prefix != a.mData->prefix ) return false; | 141 | if ( mData->prefix != a.mData->prefix ) return false; |
142 | if ( mData->suffix != a.mData->suffix ) return false; | 142 | if ( mData->suffix != a.mData->suffix ) return false; |
143 | if ( mData->nickName != a.mData->nickName ) return false; | 143 | if ( mData->nickName != a.mData->nickName ) return false; |
144 | if ( mData->birthday != a.mData->birthday ) return false; | 144 | if ( mData->birthday != a.mData->birthday ) return false; |
145 | if ( mData->mailer != a.mData->mailer ) return false; | 145 | if ( mData->mailer != a.mData->mailer ) return false; |
146 | if ( mData->timeZone != a.mData->timeZone ) return false; | 146 | if ( mData->timeZone != a.mData->timeZone ) return false; |
147 | if ( mData->geo != a.mData->geo ) return false; | 147 | if ( mData->geo != a.mData->geo ) return false; |
148 | if ( mData->title != a.mData->title ) return false; | 148 | if ( mData->title != a.mData->title ) return false; |
149 | if ( mData->role != a.mData->role ) return false; | 149 | if ( mData->role != a.mData->role ) return false; |
150 | if ( mData->organization != a.mData->organization ) return false; | 150 | if ( mData->organization != a.mData->organization ) return false; |
151 | if ( mData->note != a.mData->note ) return false; | 151 | if ( mData->note != a.mData->note ) return false; |
152 | if ( mData->productId != a.mData->productId ) return false; | 152 | if ( mData->productId != a.mData->productId ) return false; |
153 | //if ( mData->revision != a.mData->revision ) return false; | 153 | //if ( mData->revision != a.mData->revision ) return false; |
154 | if ( mData->sortString != a.mData->sortString ) return false; | 154 | if ( mData->sortString != a.mData->sortString ) return false; |
155 | if ( mData->secrecy != a.mData->secrecy ) return false; | 155 | if ( mData->secrecy != a.mData->secrecy ) return false; |
156 | if ( mData->logo != a.mData->logo ) return false; | 156 | if ( mData->logo != a.mData->logo ) return false; |
157 | if ( mData->photo != a.mData->photo ) return false; | 157 | if ( mData->photo != a.mData->photo ) return false; |
158 | if ( mData->sound != a.mData->sound ) return false; | 158 | if ( mData->sound != a.mData->sound ) return false; |
159 | if ( mData->agent != a.mData->agent ) return false; | 159 | if ( mData->agent != a.mData->agent ) return false; |
160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
161 | ( mData->url != a.mData->url ) ) return false; | 161 | ( mData->url != a.mData->url ) ) return false; |
162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
163 | if ( mData->addresses != a.mData->addresses ) return false; | 163 | if ( mData->addresses != a.mData->addresses ) return false; |
164 | if ( mData->keys != a.mData->keys ) return false; | 164 | if ( mData->keys != a.mData->keys ) return false; |
165 | if ( mData->emails != a.mData->emails ) return false; | 165 | if ( mData->emails != a.mData->emails ) return false; |
166 | if ( mData->categories != a.mData->categories ) return false; | 166 | if ( mData->categories != a.mData->categories ) return false; |
167 | if ( mData->custom != a.mData->custom ) return false; | 167 | if ( mData->custom != a.mData->custom ) return false; |
168 | 168 | ||
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | 171 | ||
172 | bool Addressee::operator!=( const Addressee &a ) const | 172 | bool Addressee::operator!=( const Addressee &a ) const |
173 | { | 173 | { |
174 | return !( a == *this ); | 174 | return !( a == *this ); |
175 | } | 175 | } |
176 | 176 | ||
177 | bool Addressee::isEmpty() const | 177 | bool Addressee::isEmpty() const |
178 | { | 178 | { |
179 | return mData->empty; | 179 | return mData->empty; |
180 | } | 180 | } |
181 | ulong Addressee::getCsum4List( const QStringList & attList) | 181 | ulong Addressee::getCsum4List( const QStringList & attList) |
182 | { | 182 | { |
183 | int max = attList.count(); | 183 | int max = attList.count(); |
184 | ulong cSum = 0; | 184 | ulong cSum = 0; |
185 | int j,k,i; | 185 | int j,k,i; |
186 | int add; | 186 | int add; |
187 | for ( i = 0; i < max ; ++i ) { | 187 | for ( i = 0; i < max ; ++i ) { |
188 | QString s = attList[i]; | 188 | QString s = attList[i]; |
189 | if ( ! s.isEmpty() ){ | 189 | if ( ! s.isEmpty() ){ |
190 | j = s.length(); | 190 | j = s.length(); |
191 | for ( k = 0; k < j; ++k ) { | 191 | for ( k = 0; k < j; ++k ) { |
192 | int mul = k +1; | 192 | int mul = k +1; |
193 | add = s[k].unicode (); | 193 | add = s[k].unicode (); |
194 | if ( k < 16 ) | 194 | if ( k < 16 ) |
195 | mul = mul * mul; | 195 | mul = mul * mul; |
196 | int ii = i+1; | 196 | int ii = i+1; |
197 | add = add * mul *ii*ii*ii; | 197 | add = add * mul *ii*ii*ii; |
198 | cSum += add; | 198 | cSum += add; |
199 | //qDebug("csum: %d %d %d", i,k,cSum); | ||
199 | } | 200 | } |
200 | } | 201 | } |
201 | 202 | ||
202 | } | 203 | } |
203 | //QString dump = attList.join(","); | 204 | //QString dump = attList.join(","); |
204 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 205 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
205 | 206 | ||
206 | return cSum; | 207 | return cSum; |
207 | 208 | ||
208 | } | 209 | } |
209 | void Addressee::computeCsum(const QString &dev) | 210 | void Addressee::computeCsum(const QString &dev) |
210 | { | 211 | { |
211 | QStringList l; | 212 | QStringList l; |
212 | //if ( !mData->name.isEmpty() ) l.append(mData->name); | 213 | //if ( !mData->name.isEmpty() ) l.append(mData->name); |
213 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 214 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 215 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 216 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
216 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); | 217 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); |
217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 218 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 219 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 220 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 221 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 222 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 223 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 224 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 225 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 226 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 227 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 228 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 229 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 230 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 231 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
231 | // if ( !mData->logo.isEmpty() ) l.append( ); | 232 | if ( !mData->logo.undefined() ) { |
232 | //if ( !mData->photo.isEmpty() ) l.append( ); | 233 | if ( !mData->logo.isIntern() ) |
233 | //if ( !mData->sound.isEmpty() ) l.append( ); | 234 | l.append( mData->logo.url() ); |
235 | else | ||
236 | l.append( QString::number(mData->logo.data().width()* mData->logo.data().height())); | ||
237 | } else { | ||
238 | l.append( "nologo"); | ||
239 | } | ||
240 | if ( !mData->photo.undefined() ) { | ||
241 | if ( !mData->photo.isIntern() ) | ||
242 | l.append( mData->photo.url() ); | ||
243 | else | ||
244 | l.append( QString::number(mData->photo.data().width()* mData->photo.data().height())); | ||
245 | } else { | ||
246 | l.append( "nophoto"); | ||
247 | } | ||
248 | #if 0 | ||
249 | if ( !mData->sound.undefined() ) { | ||
250 | if ( !mData->sound.isIntern() ) | ||
251 | l.append( mData->sound.url() ); | ||
252 | else | ||
253 | l.append( QString(mData->sound.data().with()* mData->sound.data().height())); | ||
254 | } else { | ||
255 | l.append( "nosound"); | ||
256 | } | ||
257 | #endif | ||
234 | //if ( !mData->agent.isEmpty() ) l.append( ); | 258 | //if ( !mData->agent.isEmpty() ) l.append( ); |
235 | if ( mData->url.isValid() ) | 259 | if ( mData->url.isValid() ) |
236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 260 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
237 | KABC::PhoneNumber::List phoneNumbers; | 261 | KABC::PhoneNumber::List phoneNumbers; |
238 | KABC::PhoneNumber::List::Iterator phoneIter; | 262 | KABC::PhoneNumber::List::Iterator phoneIter; |
239 | 263 | ||
240 | QStringList t; | 264 | QStringList t; |
241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 265 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
242 | ++phoneIter ) | 266 | ++phoneIter ) |
243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 267 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
244 | t.sort(); | 268 | t.sort(); |
245 | uint iii; | 269 | uint iii; |
246 | for ( iii = 0; iii < t.count(); ++iii) | 270 | for ( iii = 0; iii < t.count(); ++iii) |
247 | l.append( t[iii] ); | 271 | l.append( t[iii] ); |
248 | t = mData->emails; | 272 | t = mData->emails; |
249 | t.sort(); | 273 | t.sort(); |
250 | for ( iii = 0; iii < t.count(); ++iii) | 274 | for ( iii = 0; iii < t.count(); ++iii) |
251 | l.append( t[iii] ); | 275 | l.append( t[iii] ); |
252 | t = mData->categories; | 276 | t = mData->categories; |
253 | t.sort(); | 277 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 278 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 279 | l.append( t[iii] ); |
256 | t = mData->custom; | 280 | t = mData->custom; |
257 | t.sort(); | 281 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 282 | for ( iii = 0; iii < t.count(); ++iii) |
259 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { | 283 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { |
260 | int find = t[iii].find (':')+1; | 284 | int find = t[iii].find (':')+1; |
261 | //qDebug("lennnn %d %d ", find, t[iii].length()); | 285 | //qDebug("lennnn %d %d ", find, t[iii].length()); |
262 | if ( find < t[iii].length()) | 286 | if ( find < t[iii].length()) |
263 | l.append( t[iii] ); | 287 | l.append( t[iii] ); |
264 | 288 | ||
265 | } | 289 | } |
266 | KABC::Address::List::Iterator addressIter; | 290 | KABC::Address::List::Iterator addressIter; |
267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 291 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
268 | ++addressIter ) { | 292 | ++addressIter ) { |
269 | t = (*addressIter).asList(); | 293 | t = (*addressIter).asList(); |
270 | t.sort(); | 294 | t.sort(); |
271 | for ( iii = 0; iii < t.count(); ++iii) | 295 | for ( iii = 0; iii < t.count(); ++iii) |
272 | l.append( t[iii] ); | 296 | l.append( t[iii] ); |
273 | } | 297 | } |
274 | uint cs = getCsum4List(l); | 298 | uint cs = getCsum4List(l); |
275 | 299 | ||
276 | #if 0 | 300 | #if 0 |
277 | for ( iii = 0; iii < l.count(); ++iii) | 301 | for ( iii = 0; iii < l.count(); ++iii) |
278 | qDebug("%d***%s***",iii,l[iii].latin1()); | 302 | qDebug("%d***%s***",iii,l[iii].latin1()); |
279 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 303 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
280 | #endif | 304 | #endif |
305 | |||
281 | 306 | ||
282 | setCsum( dev, QString::number (cs )); | 307 | setCsum( dev, QString::number (cs )); |
283 | } | 308 | } |
284 | 309 | ||
285 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 310 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
286 | { | 311 | { |
287 | // merge all standard non-outlook fields. | 312 | // merge all standard non-outlook fields. |
288 | //if isSubSet (e.g. mobile phone sync) merge all fields | 313 | //if isSubSet (e.g. mobile phone sync) merge all fields |
289 | 314 | ||
290 | detach(); | 315 | detach(); |
291 | if ( isSubSet ) { | 316 | if ( isSubSet ) { |
292 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 317 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
293 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 318 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
294 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 319 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
295 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 320 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
296 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 321 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
297 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 322 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
298 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 323 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
299 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 324 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
300 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 325 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
301 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 326 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
302 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 327 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
303 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 328 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
304 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 329 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
305 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 330 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
306 | if ( !mData->birthday.isValid() ) | 331 | if ( !mData->birthday.isValid() ) |
307 | if ( ad.mData->birthday.isValid()) | 332 | if ( ad.mData->birthday.isValid()) |
308 | mData->birthday = ad.mData->birthday; | 333 | mData->birthday = ad.mData->birthday; |
309 | 334 | ||
310 | } | 335 | } |
311 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 336 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
312 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 337 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
313 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 338 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
314 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 339 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
315 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 340 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
316 | QStringList t; | 341 | QStringList t; |
317 | QStringList tAD; | 342 | QStringList tAD; |
318 | uint iii; | 343 | uint iii; |
319 | 344 | ||
320 | // ********** phone numbers | 345 | // ********** phone numbers |
321 | if ( isSubSet ) { | 346 | if ( isSubSet ) { |
322 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 347 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
323 | PhoneNumber::List::Iterator phoneItAD; | 348 | PhoneNumber::List::Iterator phoneItAD; |
324 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 349 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
325 | bool found = false; | 350 | bool found = false; |
326 | PhoneNumber::List::Iterator it; | 351 | PhoneNumber::List::Iterator it; |
327 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 352 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
328 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 353 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
329 | found = true; | 354 | found = true; |
330 | (*it).setType( ( *phoneItAD ).type() ); | 355 | (*it).setType( ( *phoneItAD ).type() ); |
331 | (*it).setNumber( ( *phoneItAD ).number() ); | 356 | (*it).setNumber( ( *phoneItAD ).number() ); |
332 | break; | 357 | break; |
333 | } | 358 | } |
334 | } | 359 | } |
335 | // if ( isSubSet && ! found ) | 360 | // if ( isSubSet && ! found ) |
336 | if ( ! found ) // LR try this one... | 361 | if ( ! found ) // LR try this one... |
337 | mData->phoneNumbers.append( *phoneItAD ); | 362 | mData->phoneNumbers.append( *phoneItAD ); |
338 | } | 363 | } |
339 | } else { | 364 | } else { |
340 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 365 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
341 | PhoneNumber::List::Iterator phoneItAD; | 366 | PhoneNumber::List::Iterator phoneItAD; |
342 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 367 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
343 | bool found = false; | 368 | bool found = false; |
344 | PhoneNumber::List::Iterator it; | 369 | PhoneNumber::List::Iterator it; |
345 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 370 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
346 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 371 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
347 | found = true; | 372 | found = true; |
348 | (*it).setType( ( *phoneItAD ).type() ); | 373 | (*it).setType( ( *phoneItAD ).type() ); |
349 | (*it).setNumber( ( *phoneItAD ).number() ); | 374 | (*it).setNumber( ( *phoneItAD ).number() ); |
350 | break; | 375 | break; |
351 | } | 376 | } |
352 | } | 377 | } |
353 | if ( ! found ) { // append numbers which do not have work or home type | 378 | if ( ! found ) { // append numbers which do not have work or home type |
354 | if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) | 379 | if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) |
355 | mData->phoneNumbers.append( *phoneItAD ); | 380 | mData->phoneNumbers.append( *phoneItAD ); |
356 | } | 381 | } |
357 | } | 382 | } |
358 | } | 383 | } |
359 | if ( isSubSet ) { | 384 | if ( isSubSet ) { |
360 | // ************* emails; | 385 | // ************* emails; |
361 | t = mData->emails; | 386 | t = mData->emails; |
362 | tAD = ad.mData->emails; | 387 | tAD = ad.mData->emails; |
363 | for ( iii = 0; iii < tAD.count(); ++iii) | 388 | for ( iii = 0; iii < tAD.count(); ++iii) |
364 | if ( !t.contains(tAD[iii] ) ) | 389 | if ( !t.contains(tAD[iii] ) ) |
365 | mData->emails.append( tAD[iii] ); | 390 | mData->emails.append( tAD[iii] ); |
366 | } | 391 | } |
367 | 392 | ||
368 | // ************* categories; | 393 | // ************* categories; |
369 | if ( isSubSet ) { | 394 | if ( isSubSet ) { |
370 | t = mData->categories; | 395 | t = mData->categories; |
371 | tAD = ad.mData->categories; | 396 | tAD = ad.mData->categories; |
372 | for ( iii = 0; iii < tAD.count(); ++iii) | 397 | for ( iii = 0; iii < tAD.count(); ++iii) |
373 | if ( !t.contains(tAD[iii] ) ) | 398 | if ( !t.contains(tAD[iii] ) ) |
374 | mData->categories.append( tAD[iii] ); | 399 | mData->categories.append( tAD[iii] ); |
375 | } | 400 | } |
376 | QStringList::ConstIterator it; | 401 | QStringList::ConstIterator it; |
377 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 402 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
378 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 403 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
379 | bool found = false; | 404 | bool found = false; |
380 | QStringList::ConstIterator itL; | 405 | QStringList::ConstIterator itL; |
381 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 406 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
382 | if ( (*itL).startsWith( qualifiedName ) ) { | 407 | if ( (*itL).startsWith( qualifiedName ) ) { |
383 | found = true; | 408 | found = true; |
384 | break; | 409 | break; |
385 | } | 410 | } |
386 | } | 411 | } |
387 | if ( ! found ) { | 412 | if ( ! found ) { |
388 | mData->custom.append( *it ); | 413 | mData->custom.append( *it ); |
389 | } | 414 | } |
390 | } | 415 | } |
391 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 416 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
392 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 417 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
393 | if ( !mData->sound.isIntern() ) { | 418 | if ( !mData->sound.isIntern() ) { |
394 | if ( mData->sound.url().isEmpty() ) { | 419 | if ( mData->sound.url().isEmpty() ) { |
395 | mData->sound = ad.mData->sound; | 420 | mData->sound = ad.mData->sound; |
396 | } | 421 | } |
397 | } | 422 | } |
398 | if ( !mData->agent.isIntern() ) { | 423 | if ( !mData->agent.isIntern() ) { |
399 | if ( mData->agent.url().isEmpty() ) { | 424 | if ( mData->agent.url().isEmpty() ) { |
400 | mData->agent = ad.mData->agent; | 425 | mData->agent = ad.mData->agent; |
401 | } | 426 | } |
402 | } | 427 | } |
403 | { | 428 | { |
404 | Key::List::Iterator itA; | 429 | Key::List::Iterator itA; |
405 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | 430 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { |
406 | bool found = false; | 431 | bool found = false; |
407 | Key::List::Iterator it; | 432 | Key::List::Iterator it; |
408 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 433 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
409 | if ( (*it) == (*itA)) { | 434 | if ( (*it) == (*itA)) { |
410 | found = true; | 435 | found = true; |
411 | break; | 436 | break; |
412 | 437 | ||
413 | } | 438 | } |
414 | } | 439 | } |
415 | if ( ! found ) { | 440 | if ( ! found ) { |
416 | mData->keys.append( *itA ); | 441 | mData->keys.append( *itA ); |
417 | } | 442 | } |
418 | } | 443 | } |
419 | } | 444 | } |
420 | if ( isSubSet ) { | 445 | if ( isSubSet ) { |
421 | KABC::Address::List::Iterator addressIterA; | 446 | KABC::Address::List::Iterator addressIterA; |
422 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 447 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
423 | bool found = false; | 448 | bool found = false; |
424 | KABC::Address::List::Iterator addressIter; | 449 | KABC::Address::List::Iterator addressIter; |
425 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 450 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
426 | ++addressIter ) { | 451 | ++addressIter ) { |
427 | if ( (*addressIter) == (*addressIterA)) { | 452 | if ( (*addressIter) == (*addressIterA)) { |
428 | found = true; | 453 | found = true; |
429 | (*addressIter).setType( (*addressIterA).type() ); | 454 | (*addressIter).setType( (*addressIterA).type() ); |
430 | break; | 455 | break; |
431 | } | 456 | } |
432 | 457 | ||
433 | } | 458 | } |
434 | if ( isSubSet && ! found ) { | 459 | if ( isSubSet && ! found ) { |
435 | mData->addresses.append( *addressIterA ); | 460 | mData->addresses.append( *addressIterA ); |
436 | } | 461 | } |
437 | } | 462 | } |
438 | } | 463 | } |
439 | //qDebug("merge contact %s ", ad.uid().latin1()); | 464 | //qDebug("merge contact %s ", ad.uid().latin1()); |
440 | setUid( ad.uid() ); | 465 | setUid( ad.uid() ); |
441 | setRevision( ad.revision() ); | 466 | setRevision( ad.revision() ); |
442 | } | 467 | } |
443 | 468 | ||
444 | bool Addressee::removeVoice() | 469 | bool Addressee::removeVoice() |
445 | { | 470 | { |
446 | PhoneNumber::List phoneN = phoneNumbers(); | 471 | PhoneNumber::List phoneN = phoneNumbers(); |
447 | PhoneNumber::List::Iterator phoneIt; | 472 | PhoneNumber::List::Iterator phoneIt; |
448 | bool found = false; | 473 | bool found = false; |
449 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 474 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
450 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 475 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
451 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 476 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
452 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 477 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
453 | insertPhoneNumber( (*phoneIt) ); | 478 | insertPhoneNumber( (*phoneIt) ); |
454 | found = true; | 479 | found = true; |
455 | } | 480 | } |
456 | } | 481 | } |
457 | 482 | ||
458 | } | 483 | } |
459 | return found; | 484 | return found; |
460 | } | 485 | } |
461 | 486 | ||
462 | bool Addressee::containsAdr(const Addressee& ad ) | 487 | bool Addressee::containsAdr(const Addressee& ad ) |
463 | { | 488 | { |
464 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; | 489 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; |
465 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; | 490 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; |
466 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; | 491 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; |
467 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; | 492 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; |
468 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; | 493 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; |
469 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; | 494 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; |
470 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; | 495 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; |
471 | 496 | ||
472 | // compare phone numbers | 497 | // compare phone numbers |
473 | PhoneNumber::List phoneN = ad.phoneNumbers(); | 498 | PhoneNumber::List phoneN = ad.phoneNumbers(); |
474 | PhoneNumber::List::Iterator phoneIt; | 499 | PhoneNumber::List::Iterator phoneIt; |
475 | bool found = false; | 500 | bool found = false; |
476 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 501 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
477 | bool found = false; | 502 | bool found = false; |
478 | PhoneNumber::List phoneL = ad.phoneNumbers(); | 503 | PhoneNumber::List phoneL = ad.phoneNumbers(); |
479 | PhoneNumber::List::Iterator phoneItL; | 504 | PhoneNumber::List::Iterator phoneItL; |
480 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { | 505 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { |
481 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { | 506 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { |
482 | found = true; | 507 | found = true; |
483 | break; | 508 | break; |
484 | } | 509 | } |
485 | } | 510 | } |
486 | if ( ! found ) | 511 | if ( ! found ) |
487 | return false; | 512 | return false; |
488 | } | 513 | } |
489 | return true; | 514 | return true; |
490 | 515 | ||
491 | } | 516 | } |
492 | void Addressee::simplifyAddresses() | 517 | void Addressee::simplifyAddresses() |
493 | { | 518 | { |
494 | 519 | ||
495 | 520 | ||
496 | Address::List list; | 521 | Address::List list; |
497 | Address::List::Iterator it; | 522 | Address::List::Iterator it; |
498 | Address::List::Iterator it2; | 523 | Address::List::Iterator it2; |
499 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 524 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
500 | it2 = it; | 525 | it2 = it; |
501 | ++it2; | 526 | ++it2; |
502 | for( ; it2 != mData->addresses.end(); ++it2 ) { | 527 | for( ; it2 != mData->addresses.end(); ++it2 ) { |
503 | if ( (*it) == (*it2) ) { | 528 | if ( (*it) == (*it2) ) { |
504 | list.append( *it ); | 529 | list.append( *it ); |
505 | break; | 530 | break; |
506 | } | 531 | } |
507 | } | 532 | } |
508 | } | 533 | } |
509 | for( it = list.begin(); it != list.end(); ++it ) { | 534 | for( it = list.begin(); it != list.end(); ++it ) { |
510 | removeAddress( (*it) ); | 535 | removeAddress( (*it) ); |
511 | } | 536 | } |
512 | 537 | ||
513 | list.clear(); | 538 | list.clear(); |
514 | int max = 2; | 539 | int max = 2; |
515 | if ( mData->url.isValid() ) | 540 | if ( mData->url.isValid() ) |
516 | max = 1; | 541 | max = 1; |
517 | if ( mData->addresses.count() <= max ) return ; | 542 | if ( mData->addresses.count() <= max ) return ; |
518 | int count = 0; | 543 | int count = 0; |
519 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 544 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
520 | if ( count >= max ) | 545 | if ( count >= max ) |
521 | list.append( *it ); | 546 | list.append( *it ); |
522 | ++count; | 547 | ++count; |
523 | } | 548 | } |
524 | for( it = list.begin(); it != list.end(); ++it ) { | 549 | for( it = list.begin(); it != list.end(); ++it ) { |
525 | removeAddress( (*it) ); | 550 | removeAddress( (*it) ); |
526 | } | 551 | } |
527 | } | 552 | } |
528 | 553 | ||
529 | // removes all emails but the first | 554 | // removes all emails but the first |
530 | // needed by phone sync | 555 | // needed by phone sync |
531 | void Addressee::simplifyEmails() | 556 | void Addressee::simplifyEmails() |
532 | { | 557 | { |
533 | if ( mData->emails.count() == 0 ) return ; | 558 | if ( mData->emails.count() == 0 ) return ; |
534 | QString email = mData->emails.first(); | 559 | QString email = mData->emails.first(); |
535 | detach(); | 560 | detach(); |
536 | mData->emails.clear(); | 561 | mData->emails.clear(); |
537 | mData->emails.append( email ); | 562 | mData->emails.append( email ); |
538 | } | 563 | } |
539 | 564 | ||
540 | void Addressee::simplifyPhoneNumbers() | 565 | void Addressee::simplifyPhoneNumbers() |
541 | { | 566 | { |
542 | int max = 4; | 567 | int max = 4; |
543 | int inList = mData->phoneNumbers.count(); | 568 | int inList = mData->phoneNumbers.count(); |
544 | KABC::PhoneNumber::List removeNumbers; | 569 | KABC::PhoneNumber::List removeNumbers; |
545 | KABC::PhoneNumber::List::Iterator phoneIter; | 570 | KABC::PhoneNumber::List::Iterator phoneIter; |
546 | if ( inList > max ) { | 571 | if ( inList > max ) { |
547 | // delete non-preferred numbers | 572 | // delete non-preferred numbers |
548 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 573 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
549 | ++phoneIter ) { | 574 | ++phoneIter ) { |
550 | if ( inList > max ) { | 575 | if ( inList > max ) { |
551 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | 576 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { |
552 | removeNumbers.append( ( *phoneIter ) ); | 577 | removeNumbers.append( ( *phoneIter ) ); |
553 | --inList; | 578 | --inList; |
554 | } | 579 | } |
555 | } else | 580 | } else |
556 | break; | 581 | break; |
557 | } | 582 | } |
558 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 583 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
559 | ++phoneIter ) { | 584 | ++phoneIter ) { |
560 | removePhoneNumber(( *phoneIter )); | 585 | removePhoneNumber(( *phoneIter )); |
561 | } | 586 | } |
562 | // delete preferred numbers | 587 | // delete preferred numbers |
563 | if ( inList > max ) { | 588 | if ( inList > max ) { |
564 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 589 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
565 | ++phoneIter ) { | 590 | ++phoneIter ) { |
566 | if ( inList > max ) { | 591 | if ( inList > max ) { |
567 | removeNumbers.append( ( *phoneIter ) ); | 592 | removeNumbers.append( ( *phoneIter ) ); |
568 | --inList; | 593 | --inList; |
569 | } else | 594 | } else |
570 | break; | 595 | break; |
571 | } | 596 | } |
572 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 597 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
573 | ++phoneIter ) { | 598 | ++phoneIter ) { |
574 | removePhoneNumber(( *phoneIter )); | 599 | removePhoneNumber(( *phoneIter )); |
575 | } | 600 | } |
576 | } | 601 | } |
577 | } | 602 | } |
578 | // remove non-numeric characters | 603 | // remove non-numeric characters |
579 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 604 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
580 | ++phoneIter ) { | 605 | ++phoneIter ) { |
581 | if ( ! ( *phoneIter ).simplifyNumber() ) | 606 | if ( ! ( *phoneIter ).simplifyNumber() ) |
582 | removeNumbers.append( ( *phoneIter ) ); | 607 | removeNumbers.append( ( *phoneIter ) ); |
583 | } | 608 | } |
584 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 609 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
585 | ++phoneIter ) { | 610 | ++phoneIter ) { |
586 | removePhoneNumber(( *phoneIter )); | 611 | removePhoneNumber(( *phoneIter )); |
587 | } | 612 | } |
588 | } | 613 | } |
589 | void Addressee::simplifyPhoneNumberTypes() | 614 | void Addressee::simplifyPhoneNumberTypes() |
590 | { | 615 | { |
591 | KABC::PhoneNumber::List::Iterator phoneIter; | 616 | KABC::PhoneNumber::List::Iterator phoneIter; |
592 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 617 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
593 | ++phoneIter ) | 618 | ++phoneIter ) |
594 | ( *phoneIter ).simplifyType(); | 619 | ( *phoneIter ).simplifyType(); |
595 | } | 620 | } |
596 | void Addressee::removeID(const QString &prof) | 621 | void Addressee::removeID(const QString &prof) |
597 | { | 622 | { |
598 | detach(); | 623 | detach(); |
599 | if ( prof.isEmpty() ) | 624 | if ( prof.isEmpty() ) |
600 | mData->mExternalId = ":"; | 625 | mData->mExternalId = ":"; |
601 | else | 626 | else |
602 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 627 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
603 | 628 | ||
604 | } | 629 | } |
605 | void Addressee::setID( const QString & prof , const QString & id ) | 630 | void Addressee::setID( const QString & prof , const QString & id ) |
606 | { | 631 | { |
607 | detach(); | 632 | detach(); |
608 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 633 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
609 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 634 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
610 | } | 635 | } |
611 | void Addressee::setTempSyncStat( int id ) | 636 | void Addressee::setTempSyncStat( int id ) |
612 | { | 637 | { |
613 | if ( mData->mTempSyncStat == id ) return; | 638 | if ( mData->mTempSyncStat == id ) return; |
614 | detach(); | 639 | detach(); |
615 | mData->mTempSyncStat = id; | 640 | mData->mTempSyncStat = id; |
616 | } | 641 | } |
617 | int Addressee::tempSyncStat() const | 642 | int Addressee::tempSyncStat() const |
618 | { | 643 | { |
619 | return mData->mTempSyncStat; | 644 | return mData->mTempSyncStat; |
620 | } | 645 | } |
621 | 646 | ||
622 | const QString Addressee::getID( const QString & prof) const | 647 | const QString Addressee::getID( const QString & prof) const |
623 | { | 648 | { |
624 | return KIdManager::getId ( mData->mExternalId, prof ); | 649 | return KIdManager::getId ( mData->mExternalId, prof ); |
625 | } | 650 | } |
626 | 651 | ||
627 | void Addressee::setCsum( const QString & prof , const QString & id ) | 652 | void Addressee::setCsum( const QString & prof , const QString & id ) |
628 | { | 653 | { |
629 | detach(); | 654 | detach(); |
630 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 655 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
631 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 656 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
632 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 657 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
633 | } | 658 | } |
634 | 659 | ||
635 | const QString Addressee::getCsum( const QString & prof) const | 660 | const QString Addressee::getCsum( const QString & prof) const |
636 | { | 661 | { |
637 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 662 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
638 | } | 663 | } |
639 | 664 | ||
640 | void Addressee::setIDStr( const QString & s ) | 665 | void Addressee::setIDStr( const QString & s ) |
641 | { | 666 | { |
642 | detach(); | 667 | detach(); |
643 | mData->mExternalId = s; | 668 | mData->mExternalId = s; |
644 | } | 669 | } |
645 | 670 | ||
646 | const QString Addressee::IDStr() const | 671 | const QString Addressee::IDStr() const |
647 | { | 672 | { |
648 | return mData->mExternalId; | 673 | return mData->mExternalId; |
649 | } | 674 | } |
650 | 675 | ||
651 | void Addressee::setExternalUID( const QString &id ) | 676 | void Addressee::setExternalUID( const QString &id ) |
652 | { | 677 | { |
653 | if ( id == mData->externalUID ) return; | 678 | if ( id == mData->externalUID ) return; |
654 | detach(); | 679 | detach(); |
655 | mData->empty = false; | 680 | mData->empty = false; |
656 | mData->externalUID = id; | 681 | mData->externalUID = id; |
657 | } | 682 | } |
658 | 683 | ||
659 | const QString Addressee::externalUID() const | 684 | const QString Addressee::externalUID() const |
660 | { | 685 | { |
661 | return mData->externalUID; | 686 | return mData->externalUID; |
662 | } | 687 | } |
663 | void Addressee::setOriginalExternalUID( const QString &id ) | 688 | void Addressee::setOriginalExternalUID( const QString &id ) |
664 | { | 689 | { |
665 | if ( id == mData->originalExternalUID ) return; | 690 | if ( id == mData->originalExternalUID ) return; |
666 | detach(); | 691 | detach(); |
667 | mData->empty = false; | 692 | mData->empty = false; |
668 | //qDebug("*******Set orig uid %s ", id.latin1()); | 693 | //qDebug("*******Set orig uid %s ", id.latin1()); |
669 | mData->originalExternalUID = id; | 694 | mData->originalExternalUID = id; |
670 | } | 695 | } |
671 | 696 | ||
672 | QString Addressee::originalExternalUID() const | 697 | QString Addressee::originalExternalUID() const |
673 | { | 698 | { |
674 | return mData->originalExternalUID; | 699 | return mData->originalExternalUID; |
675 | } | 700 | } |
676 | 701 | ||
677 | void Addressee::setUid( const QString &id ) | 702 | void Addressee::setUid( const QString &id ) |
678 | { | 703 | { |
679 | if ( id == mData->uid ) return; | 704 | if ( id == mData->uid ) return; |
680 | detach(); | 705 | detach(); |
681 | //qDebug("****setuid %s ", id.latin1()); | 706 | //qDebug("****setuid %s ", id.latin1()); |
682 | mData->empty = false; | 707 | mData->empty = false; |
683 | mData->uid = id; | 708 | mData->uid = id; |
684 | } | 709 | } |
685 | 710 | ||
686 | const QString Addressee::uid() const | 711 | const QString Addressee::uid() const |
687 | { | 712 | { |
688 | if ( mData->uid.isEmpty() ) | 713 | if ( mData->uid.isEmpty() ) |
689 | mData->uid = KApplication::randomString( 10 ); | 714 | mData->uid = KApplication::randomString( 10 ); |
690 | 715 | ||
691 | return mData->uid; | 716 | return mData->uid; |
692 | } | 717 | } |
693 | 718 | ||
694 | QString Addressee::uidLabel() | 719 | QString Addressee::uidLabel() |
695 | { | 720 | { |
696 | return i18n("Unique Identifier"); | 721 | return i18n("Unique Identifier"); |
697 | } | 722 | } |
698 | 723 | ||
699 | void Addressee::setName( const QString &name ) | 724 | void Addressee::setName( const QString &name ) |
700 | { | 725 | { |
701 | if ( name == mData->name ) return; | 726 | if ( name == mData->name ) return; |
702 | detach(); | 727 | detach(); |
703 | mData->empty = false; | 728 | mData->empty = false; |
704 | mData->name = name; | 729 | mData->name = name; |
705 | } | 730 | } |
706 | 731 | ||
707 | QString Addressee::name() const | 732 | QString Addressee::name() const |
708 | { | 733 | { |
709 | return mData->name; | 734 | return mData->name; |
710 | } | 735 | } |
711 | 736 | ||
712 | QString Addressee::nameLabel() | 737 | QString Addressee::nameLabel() |
713 | { | 738 | { |
714 | return i18n("Name"); | 739 | return i18n("Name"); |
715 | } | 740 | } |
716 | 741 | ||
717 | 742 | ||
718 | void Addressee::setFormattedName( const QString &formattedName ) | 743 | void Addressee::setFormattedName( const QString &formattedName ) |
719 | { | 744 | { |
720 | if ( formattedName == mData->formattedName ) return; | 745 | if ( formattedName == mData->formattedName ) return; |
721 | detach(); | 746 | detach(); |
722 | mData->empty = false; | 747 | mData->empty = false; |
723 | mData->formattedName = formattedName; | 748 | mData->formattedName = formattedName; |
724 | } | 749 | } |
725 | 750 | ||
726 | QString Addressee::formattedName() const | 751 | QString Addressee::formattedName() const |
727 | { | 752 | { |
728 | return mData->formattedName; | 753 | return mData->formattedName; |
729 | } | 754 | } |
730 | 755 | ||
731 | QString Addressee::formattedNameLabel() | 756 | QString Addressee::formattedNameLabel() |
732 | { | 757 | { |
733 | return i18n("Formatted Name"); | 758 | return i18n("Formatted Name"); |
734 | } | 759 | } |
735 | 760 | ||
736 | 761 | ||
737 | void Addressee::setFamilyName( const QString &familyName ) | 762 | void Addressee::setFamilyName( const QString &familyName ) |
738 | { | 763 | { |
739 | if ( familyName == mData->familyName ) return; | 764 | if ( familyName == mData->familyName ) return; |
740 | detach(); | 765 | detach(); |
741 | mData->empty = false; | 766 | mData->empty = false; |
742 | mData->familyName = familyName; | 767 | mData->familyName = familyName; |
743 | } | 768 | } |
744 | 769 | ||
745 | QString Addressee::familyName() const | 770 | QString Addressee::familyName() const |
746 | { | 771 | { |
747 | return mData->familyName; | 772 | return mData->familyName; |
748 | } | 773 | } |
749 | 774 | ||
750 | QString Addressee::familyNameLabel() | 775 | QString Addressee::familyNameLabel() |
751 | { | 776 | { |
752 | return i18n("Family Name"); | 777 | return i18n("Family Name"); |
753 | } | 778 | } |
754 | 779 | ||
755 | 780 | ||
756 | void Addressee::setGivenName( const QString &givenName ) | 781 | void Addressee::setGivenName( const QString &givenName ) |
757 | { | 782 | { |
758 | if ( givenName == mData->givenName ) return; | 783 | if ( givenName == mData->givenName ) return; |
759 | detach(); | 784 | detach(); |
760 | mData->empty = false; | 785 | mData->empty = false; |
761 | mData->givenName = givenName; | 786 | mData->givenName = givenName; |
762 | } | 787 | } |
763 | 788 | ||
764 | QString Addressee::givenName() const | 789 | QString Addressee::givenName() const |
765 | { | 790 | { |
766 | return mData->givenName; | 791 | return mData->givenName; |
767 | } | 792 | } |
768 | 793 | ||
769 | QString Addressee::givenNameLabel() | 794 | QString Addressee::givenNameLabel() |
770 | { | 795 | { |
771 | return i18n("Given Name"); | 796 | return i18n("Given Name"); |
772 | } | 797 | } |
773 | 798 | ||
774 | 799 | ||
775 | void Addressee::setAdditionalName( const QString &additionalName ) | 800 | void Addressee::setAdditionalName( const QString &additionalName ) |
776 | { | 801 | { |
777 | if ( additionalName == mData->additionalName ) return; | 802 | if ( additionalName == mData->additionalName ) return; |
778 | detach(); | 803 | detach(); |
779 | mData->empty = false; | 804 | mData->empty = false; |
780 | mData->additionalName = additionalName; | 805 | mData->additionalName = additionalName; |
781 | } | 806 | } |
782 | 807 | ||
783 | QString Addressee::additionalName() const | 808 | QString Addressee::additionalName() const |
784 | { | 809 | { |
785 | return mData->additionalName; | 810 | return mData->additionalName; |
786 | } | 811 | } |
787 | 812 | ||
788 | QString Addressee::additionalNameLabel() | 813 | QString Addressee::additionalNameLabel() |
789 | { | 814 | { |
790 | return i18n("Additional Names"); | 815 | return i18n("Additional Names"); |
791 | } | 816 | } |
792 | 817 | ||