-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 | |||
@@ -135,210 +135,235 @@ bool Addressee::operator==( const Addressee &a ) const | |||
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; |