summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
Unidiff
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index e8e440c..9994e29 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -138,513 +138,513 @@ bool Addressee::operator==( const Addressee &a ) const
138 if ( mData->formattedName != a.mData->formattedName ) return false; 138 if ( mData->formattedName != a.mData->formattedName ) return false;
139 if ( mData->familyName != a.mData->familyName ) return false; 139 if ( mData->familyName != a.mData->familyName ) return false;
140 if ( mData->givenName != a.mData->givenName ) return false; 140 if ( mData->givenName != a.mData->givenName ) return false;
141 if ( mData->additionalName != a.mData->additionalName ) return false; 141 if ( mData->additionalName != a.mData->additionalName ) return false;
142 if ( mData->prefix != a.mData->prefix ) return false; 142 if ( mData->prefix != a.mData->prefix ) return false;
143 if ( mData->suffix != a.mData->suffix ) return false; 143 if ( mData->suffix != a.mData->suffix ) return false;
144 if ( mData->nickName != a.mData->nickName ) return false; 144 if ( mData->nickName != a.mData->nickName ) return false;
145 if ( mData->birthday != a.mData->birthday ) return false; 145 if ( mData->birthday != a.mData->birthday ) return false;
146 if ( mData->mailer != a.mData->mailer ) return false; 146 if ( mData->mailer != a.mData->mailer ) return false;
147 if ( mData->timeZone != a.mData->timeZone ) return false; 147 if ( mData->timeZone != a.mData->timeZone ) return false;
148 if ( mData->geo != a.mData->geo ) return false; 148 if ( mData->geo != a.mData->geo ) return false;
149 if ( mData->title != a.mData->title ) return false; 149 if ( mData->title != a.mData->title ) return false;
150 if ( mData->role != a.mData->role ) return false; 150 if ( mData->role != a.mData->role ) return false;
151 if ( mData->organization != a.mData->organization ) return false; 151 if ( mData->organization != a.mData->organization ) return false;
152 if ( mData->note != a.mData->note ) return false; 152 if ( mData->note != a.mData->note ) return false;
153 if ( mData->productId != a.mData->productId ) return false; 153 if ( mData->productId != a.mData->productId ) return false;
154 //if ( mData->revision != a.mData->revision ) return false; 154 //if ( mData->revision != a.mData->revision ) return false;
155 if ( mData->sortString != a.mData->sortString ) return false; 155 if ( mData->sortString != a.mData->sortString ) return false;
156 if ( mData->secrecy != a.mData->secrecy ) return false; 156 if ( mData->secrecy != a.mData->secrecy ) return false;
157 if ( mData->logo != a.mData->logo ) return false; 157 if ( mData->logo != a.mData->logo ) return false;
158 if ( mData->photo != a.mData->photo ) return false; 158 if ( mData->photo != a.mData->photo ) return false;
159 if ( mData->sound != a.mData->sound ) return false; 159 if ( mData->sound != a.mData->sound ) return false;
160 if ( mData->agent != a.mData->agent ) return false; 160 if ( mData->agent != a.mData->agent ) return false;
161 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 161 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
162 ( mData->url != a.mData->url ) ) return false; 162 ( mData->url != a.mData->url ) ) return false;
163 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 163 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
164 if ( mData->addresses != a.mData->addresses ) return false; 164 if ( mData->addresses != a.mData->addresses ) return false;
165 if ( mData->keys != a.mData->keys ) return false; 165 if ( mData->keys != a.mData->keys ) return false;
166 if ( mData->emails != a.mData->emails ) return false; 166 if ( mData->emails != a.mData->emails ) return false;
167 if ( mData->categories != a.mData->categories ) return false; 167 if ( mData->categories != a.mData->categories ) return false;
168 if ( mData->custom != a.mData->custom ) return false; 168 if ( mData->custom != a.mData->custom ) return false;
169 169
170 return true; 170 return true;
171} 171}
172 172
173bool Addressee::operator!=( const Addressee &a ) const 173bool Addressee::operator!=( const Addressee &a ) const
174{ 174{
175 return !( a == *this ); 175 return !( a == *this );
176} 176}
177 177
178bool Addressee::isEmpty() const 178bool Addressee::isEmpty() const
179{ 179{
180 return mData->empty; 180 return mData->empty;
181} 181}
182ulong Addressee::getCsum4List( const QStringList & attList) 182ulong Addressee::getCsum4List( const QStringList & attList)
183{ 183{
184 int max = attList.count(); 184 int max = attList.count();
185 ulong cSum = 0; 185 ulong cSum = 0;
186 int j,k,i; 186 int j,k,i;
187 int add; 187 int add;
188 for ( i = 0; i < max ; ++i ) { 188 for ( i = 0; i < max ; ++i ) {
189 QString s = attList[i]; 189 QString s = attList[i];
190 if ( ! s.isEmpty() ){ 190 if ( ! s.isEmpty() ){
191 j = s.length(); 191 j = s.length();
192 for ( k = 0; k < j; ++k ) { 192 for ( k = 0; k < j; ++k ) {
193 int mul = k +1; 193 int mul = k +1;
194 add = s[k].unicode (); 194 add = s[k].unicode ();
195 if ( k < 16 ) 195 if ( k < 16 )
196 mul = mul * mul; 196 mul = mul * mul;
197 int ii = i+1; 197 int ii = i+1;
198 add = add * mul *ii*ii*ii; 198 add = add * mul *ii*ii*ii;
199 cSum += add; 199 cSum += add;
200 //qDebug("csum: %d %d %d", i,k,cSum); 200 //qDebug("csum: %d %d %d", i,k,cSum);
201 } 201 }
202 } 202 }
203 203
204 } 204 }
205 //QString dump = attList.join(","); 205 //QString dump = attList.join(",");
206 //qDebug("csum: %d %s", cSum,dump.latin1()); 206 //qDebug("csum: %d %s", cSum,dump.latin1());
207 207
208 return cSum; 208 return cSum;
209 209
210} 210}
211void Addressee::computeCsum(const QString &dev) 211void Addressee::computeCsum(const QString &dev)
212{ 212{
213 QStringList l; 213 QStringList l;
214 //if ( !mData->name.isEmpty() ) l.append(mData->name); 214 //if ( !mData->name.isEmpty() ) l.append(mData->name);
215 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 215 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
216 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 216 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
217 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 217 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
218 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); 218 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName );
219 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 219 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
220 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 220 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
221 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 221 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
222 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 222 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
223 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 223 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
224 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 224 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
225 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 225 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
226 if ( !mData->title .isEmpty() ) l.append( mData->title ); 226 if ( !mData->title .isEmpty() ) l.append( mData->title );
227 if ( !mData->role.isEmpty() ) l.append( mData->role ); 227 if ( !mData->role.isEmpty() ) l.append( mData->role );
228 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 228 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
229 if ( !mData->note.isEmpty() ) l.append( mData->note ); 229 if ( !mData->note.isEmpty() ) l.append( mData->note );
230 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 230 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
231 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 231 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
232 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 232 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
233 if ( !mData->logo.undefined() ) { 233 if ( !mData->logo.undefined() ) {
234 if ( !mData->logo.isIntern() ) 234 if ( !mData->logo.isIntern() )
235 l.append( mData->logo.url() ); 235 l.append( mData->logo.url() );
236 else 236 else
237 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()));
238 } else { 238 } else {
239 l.append( "nologo"); 239 l.append( "nologo");
240 } 240 }
241 if ( !mData->photo.undefined() ) { 241 if ( !mData->photo.undefined() ) {
242 if ( !mData->photo.isIntern() ) 242 if ( !mData->photo.isIntern() )
243 l.append( mData->photo.url() ); 243 l.append( mData->photo.url() );
244 else 244 else
245 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()));
246 } else { 246 } else {
247 l.append( "nophoto"); 247 l.append( "nophoto");
248 } 248 }
249#if 0 249#if 0
250 if ( !mData->sound.undefined() ) { 250 if ( !mData->sound.undefined() ) {
251 if ( !mData->sound.isIntern() ) 251 if ( !mData->sound.isIntern() )
252 l.append( mData->sound.url() ); 252 l.append( mData->sound.url() );
253 else 253 else
254 l.append( QString(mData->sound.data().with()* mData->sound.data().height())); 254 l.append( QString(mData->sound.data().with()* mData->sound.data().height()));
255 } else { 255 } else {
256 l.append( "nosound"); 256 l.append( "nosound");
257 } 257 }
258#endif 258#endif
259 //if ( !mData->agent.isEmpty() ) l.append( ); 259 //if ( !mData->agent.isEmpty() ) l.append( );
260 if ( mData->url.isValid() ) 260 if ( mData->url.isValid() )
261 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); 261 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
262 KABC::PhoneNumber::List phoneNumbers; 262 KABC::PhoneNumber::List phoneNumbers;
263 KABC::PhoneNumber::List::Iterator phoneIter; 263 KABC::PhoneNumber::List::Iterator phoneIter;
264 264
265 QStringList t; 265 QStringList t;
266 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 266 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
267 ++phoneIter ) 267 ++phoneIter )
268 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 268 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
269 t.sort(); 269 t.sort();
270 uint iii; 270 uint iii;
271 for ( iii = 0; iii < t.count(); ++iii) 271 for ( iii = 0; iii < t.count(); ++iii)
272 l.append( t[iii] ); 272 l.append( t[iii] );
273 t = mData->emails; 273 t = mData->emails;
274 t.sort(); 274 t.sort();
275 for ( iii = 0; iii < t.count(); ++iii) 275 for ( iii = 0; iii < t.count(); ++iii)
276 l.append( t[iii] ); 276 l.append( t[iii] );
277 t = mData->categories; 277 t = mData->categories;
278 t.sort(); 278 t.sort();
279 for ( iii = 0; iii < t.count(); ++iii) 279 for ( iii = 0; iii < t.count(); ++iii)
280 l.append( t[iii] ); 280 l.append( t[iii] );
281 t = mData->custom; 281 t = mData->custom;
282 t.sort(); 282 t.sort();
283 for ( iii = 0; iii < t.count(); ++iii) 283 for ( iii = 0; iii < t.count(); ++iii)
284 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { 284 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) {
285 int find = t[iii].find (':')+1; 285 int find = t[iii].find (':')+1;
286 //qDebug("lennnn %d %d ", find, t[iii].length()); 286 //qDebug("lennnn %d %d ", find, t[iii].length());
287 if ( find < t[iii].length()) 287 if ( find < t[iii].length())
288 l.append( t[iii] ); 288 l.append( t[iii] );
289 289
290 } 290 }
291 KABC::Address::List::Iterator addressIter; 291 KABC::Address::List::Iterator addressIter;
292 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 292 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
293 ++addressIter ) { 293 ++addressIter ) {
294 t = (*addressIter).asList(); 294 t = (*addressIter).asList();
295 t.sort(); 295 t.sort();
296 for ( iii = 0; iii < t.count(); ++iii) 296 for ( iii = 0; iii < t.count(); ++iii)
297 l.append( t[iii] ); 297 l.append( t[iii] );
298 } 298 }
299 uint cs = getCsum4List(l); 299 uint cs = getCsum4List(l);
300 300
301#if 0 301#if 0
302 for ( iii = 0; iii < l.count(); ++iii) 302 for ( iii = 0; iii < l.count(); ++iii)
303 qDebug("%d***%s***",iii,l[iii].latin1()); 303 qDebug("%d***%s***",iii,l[iii].latin1());
304 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() );
305#endif 305#endif
306 306
307 307
308 setCsum( dev, QString::number (cs )); 308 setCsum( dev, QString::number (cs ));
309} 309}
310bool Addressee::matchAddress( QRegExp* re ) const 310bool Addressee::matchAddress( QRegExp* re ) const
311{ 311{
312 KABC::Address::List::Iterator addressIter; 312 KABC::Address::List::Iterator addressIter;
313 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 313 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
314 ++addressIter ) { 314 ++addressIter ) {
315 if ( (*addressIter).matchAddress( re ) ) 315 if ( (*addressIter).matchAddress( re ) )
316 return true; 316 return true;
317 } 317 }
318 return false; 318 return false;
319} 319}
320bool Addressee::matchPhoneNumber( QRegExp* re ) const 320bool Addressee::matchPhoneNumber( QRegExp* re ) const
321{ 321{
322 KABC::PhoneNumber::List::Iterator phoneIter; 322 KABC::PhoneNumber::List::Iterator phoneIter;
323 323
324 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) { 324 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) {
325#if QT_VERSION >= 0x030000 325#if QT_VERSION >= 0x030000
326 if (re->search( (*phoneIter).number() ) == 0) 326 if (re->search( (*phoneIter).number() ) == 0)
327#else 327#else
328 if (re->match( (*phoneIter).number() ) == 0) 328 if (re->match( (*phoneIter).number() ) == 0)
329#endif 329#endif
330 return true; 330 return true;
331 331
332 } 332 }
333 return false; 333 return false;
334 334
335} 335}
336void Addressee::mergeOLContact( const Addressee& ad ) 336void Addressee::mergeOLContact( const Addressee& ad )
337{ 337{
338 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 338 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
339 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 339 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
340 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 340 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
341 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 341 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
342 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 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; 343 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
344 if ( !mData->sound.isIntern() ) { 344 if ( !mData->sound.isIntern() ) {
345 if ( mData->sound.url().isEmpty() ) { 345 if ( mData->sound.url().isEmpty() ) {
346 mData->sound = ad.mData->sound; 346 mData->sound = ad.mData->sound;
347 } 347 }
348 } 348 }
349 if ( !mData->agent.isIntern() ) { 349 if ( !mData->agent.isIntern() ) {
350 if ( mData->agent.url().isEmpty() ) { 350 if ( mData->agent.url().isEmpty() ) {
351 mData->agent = ad.mData->agent; 351 mData->agent = ad.mData->agent;
352 } 352 }
353 } 353 }
354 { 354 {
355 Key::List::Iterator itA; 355 Key::List::Iterator itA;
356 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 356 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
357 bool found = false; 357 bool found = false;
358 Key::List::Iterator it; 358 Key::List::Iterator it;
359 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 359 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
360 if ( (*it) == (*itA)) { 360 if ( (*it) == (*itA)) {
361 found = true; 361 found = true;
362 break; 362 break;
363 363
364 } 364 }
365 } 365 }
366 if ( ! found ) { 366 if ( ! found ) {
367 mData->keys.append( *itA ); 367 mData->keys.append( *itA );
368 } 368 }
369 } 369 }
370 } 370 }
371 371
372 KABC::Address addthis = otherAddress(); 372 KABC::Address addthis = otherAddress();
373 KABC::Address addother = ad.otherAddress(); 373 KABC::Address addother = ad.otherAddress();
374 if ( !addthis.isEmpty() && !addother.isEmpty() ) 374 if ( !addthis.isEmpty() && !addother.isEmpty() )
375 addthis.setType( addother.type() ); 375 addthis.setType( addother.type() );
376 //qDebug("merge contact %s ", ad.uid().latin1()); 376 //qDebug("merge contact %s ", ad.uid().latin1());
377 setUid( ad.uid() ); 377 setUid( ad.uid() );
378 setRevision( ad.revision() ); 378 setRevision( ad.revision() );
379 379
380 380
381} 381}
382 382
383void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 383void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
384{ 384{
385 // merge all standard non-outlook fields. 385 // merge all standard non-outlook fields.
386 //if isSubSet (e.g. mobile phone sync) merge all fields 386 //if isSubSet (e.g. mobile phone sync) merge all fields
387 387
388 detach(); 388 detach();
389 if ( isSubSet ) { 389 if ( isSubSet ) {
390 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 390 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
391 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 391 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
392 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 392 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
393 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 393 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
394 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 394 if ( mData->additionalName.isEmpty() ) mData->additionalName = ad.mData->additionalName;
395 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 395 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
396 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 396 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
397 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 397 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
398 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 398 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
399 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 399 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
400 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 400 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
401 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 401 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
402 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 402 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
403 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 ;
404 if ( !mData->birthday.isValid() ) 404 if ( !mData->birthday.isValid() )
405 if ( ad.mData->birthday.isValid()) 405 if ( ad.mData->birthday.isValid())
406 mData->birthday = ad.mData->birthday; 406 mData->birthday = ad.mData->birthday;
407 407
408 } 408 }
409 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 409 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
410 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 410 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
411 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 411 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
412 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 412 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
413 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 413 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
414 QStringList t; 414 QStringList t;
415 QStringList tAD; 415 QStringList tAD;
416 uint iii; 416 uint iii;
417 417
418 // ********** phone numbers 418 // ********** phone numbers
419 if ( isSubSet ) { 419 if ( isSubSet ) {
420 PhoneNumber::List phoneAD = ad.phoneNumbers(); 420 PhoneNumber::List phoneAD = ad.phoneNumbers();
421 PhoneNumber::List::Iterator phoneItAD; 421 PhoneNumber::List::Iterator phoneItAD;
422 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 422 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
423 bool found = false; 423 bool found = false;
424 PhoneNumber::List::Iterator it; 424 PhoneNumber::List::Iterator it;
425 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 425 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
426 if ( ( *phoneItAD ).contains( (*it) ) ) { 426 if ( ( *phoneItAD ).contains( (*it) ) ) {
427 found = true; 427 found = true;
428 (*it).setType( ( *phoneItAD ).type() ); 428 (*it).setType( ( *phoneItAD ).type() );
429 (*it).setNumber( ( *phoneItAD ).number() ); 429 (*it).setNumber( ( *phoneItAD ).number() );
430 break; 430 break;
431 } 431 }
432 } 432 }
433 // if ( isSubSet && ! found ) 433 // if ( isSubSet && ! found )
434 if ( ! found ) // LR try this one... 434 if ( ! found ) // LR try this one...
435 mData->phoneNumbers.append( *phoneItAD ); 435 mData->phoneNumbers.append( *phoneItAD );
436 } 436 }
437 } else { 437 } else {
438 PhoneNumber::List phoneAD = ad.phoneNumbers(); 438 PhoneNumber::List phoneAD = ad.phoneNumbers();
439 PhoneNumber::List::Iterator phoneItAD; 439 PhoneNumber::List::Iterator phoneItAD;
440 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 440 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
441 bool found = false; 441 bool found = false;
442 PhoneNumber::List::Iterator it; 442 PhoneNumber::List::Iterator it;
443 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 443 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
444 if ( ( *phoneItAD ).contains( (*it) ) ) { 444 if ( ( *phoneItAD ).contains( (*it) ) ) {
445 found = true; 445 found = true;
446 (*it).setType( ( *phoneItAD ).type() ); 446 (*it).setType( ( *phoneItAD ).type() );
447 (*it).setNumber( ( *phoneItAD ).number() ); 447 (*it).setNumber( ( *phoneItAD ).number() );
448 break; 448 break;
449 } 449 }
450 } 450 }
451 if ( ! found ) { // append numbers which do not have work or home type 451 if ( ! found ) { // append numbers which do not have work or home type
452 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) 452 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) )
453 mData->phoneNumbers.append( *phoneItAD ); 453 mData->phoneNumbers.append( *phoneItAD );
454 } 454 }
455 } 455 }
456 } 456 }
457 if ( isSubSet ) { 457 if ( isSubSet ) {
458 // ************* emails; 458 // ************* emails;
459 t = mData->emails; 459 t = mData->emails;
460 tAD = ad.mData->emails; 460 tAD = ad.mData->emails;
461 for ( iii = 0; iii < tAD.count(); ++iii) 461 for ( iii = 0; iii < tAD.count(); ++iii)
462 if ( !t.contains(tAD[iii] ) ) 462 if ( !t.contains(tAD[iii] ) )
463 mData->emails.append( tAD[iii] ); 463 mData->emails.append( tAD[iii] );
464 } 464 }
465 465
466 // ************* categories; 466 // ************* categories;
467 if ( isSubSet ) { 467 if ( isSubSet ) {
468 t = mData->categories; 468 t = mData->categories;
469 tAD = ad.mData->categories; 469 tAD = ad.mData->categories;
470 for ( iii = 0; iii < tAD.count(); ++iii) 470 for ( iii = 0; iii < tAD.count(); ++iii)
471 if ( !t.contains(tAD[iii] ) ) 471 if ( !t.contains(tAD[iii] ) )
472 mData->categories.append( tAD[iii] ); 472 mData->categories.append( tAD[iii] );
473 } 473 }
474 QStringList::ConstIterator it; 474 QStringList::ConstIterator it;
475 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 475 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
476 QString qualifiedName = (*it).left( (*it).find( ":" )); 476 QString qualifiedName = (*it).left( (*it).find( ":" ));
477 bool found = false; 477 bool found = false;
478 QStringList::ConstIterator itL; 478 QStringList::ConstIterator itL;
479 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 479 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
480 if ( (*itL).startsWith( qualifiedName ) ) { 480 if ( (*itL).startsWith( qualifiedName ) ) {
481 found = true; 481 found = true;
482 break; 482 break;
483 } 483 }
484 } 484 }
485 if ( ! found ) { 485 if ( ! found ) {
486 mData->custom.append( *it ); 486 mData->custom.append( *it );
487 } 487 }
488 } 488 }
489 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 489 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
490 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 490 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
491 if ( !mData->sound.isIntern() ) { 491 if ( !mData->sound.isIntern() ) {
492 if ( mData->sound.url().isEmpty() ) { 492 if ( mData->sound.url().isEmpty() ) {
493 mData->sound = ad.mData->sound; 493 mData->sound = ad.mData->sound;
494 } 494 }
495 } 495 }
496 if ( !mData->agent.isIntern() ) { 496 if ( !mData->agent.isIntern() ) {
497 if ( mData->agent.url().isEmpty() ) { 497 if ( mData->agent.url().isEmpty() ) {
498 mData->agent = ad.mData->agent; 498 mData->agent = ad.mData->agent;
499 } 499 }
500 } 500 }
501 { 501 {
502 Key::List::Iterator itA; 502 Key::List::Iterator itA;
503 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 503 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
504 bool found = false; 504 bool found = false;
505 Key::List::Iterator it; 505 Key::List::Iterator it;
506 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 506 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
507 if ( (*it) == (*itA)) { 507 if ( (*it) == (*itA)) {
508 found = true; 508 found = true;
509 break; 509 break;
510 510
511 } 511 }
512 } 512 }
513 if ( ! found ) { 513 if ( ! found ) {
514 mData->keys.append( *itA ); 514 mData->keys.append( *itA );
515 } 515 }
516 } 516 }
517 } 517 }
518 if ( isSubSet ) { 518 if ( isSubSet ) {
519 KABC::Address::List::Iterator addressIterA; 519 KABC::Address::List::Iterator addressIterA;
520 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 520 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
521 bool found = false; 521 bool found = false;
522 KABC::Address::List::Iterator addressIter; 522 KABC::Address::List::Iterator addressIter;
523 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 523 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
524 ++addressIter ) { 524 ++addressIter ) {
525 if ( (*addressIter) == (*addressIterA)) { 525 if ( (*addressIter) == (*addressIterA)) {
526 found = true; 526 found = true;
527 (*addressIter).setType( (*addressIterA).type() ); 527 (*addressIter).setType( (*addressIterA).type() );
528 break; 528 break;
529 } 529 }
530 530
531 } 531 }
532 if ( isSubSet && ! found ) { 532 if ( isSubSet && ! found ) {
533 mData->addresses.append( *addressIterA ); 533 mData->addresses.append( *addressIterA );
534 } 534 }
535 } 535 }
536 } 536 }
537 //qDebug("merge contact %s ", ad.uid().latin1()); 537 //qDebug("merge contact %s ", ad.uid().latin1());
538 setUid( ad.uid() ); 538 setUid( ad.uid() );
539 setRevision( ad.revision() ); 539 setRevision( ad.revision() );
540} 540}
541 541
542bool Addressee::removeVoice() 542bool Addressee::removeVoice()
543{ 543{
544 PhoneNumber::List phoneN = phoneNumbers(); 544 PhoneNumber::List phoneN = phoneNumbers();
545 PhoneNumber::List::Iterator phoneIt; 545 PhoneNumber::List::Iterator phoneIt;
546 bool found = false; 546 bool found = false;
547 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 547 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
548 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 548 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
549 if ((*phoneIt).type() - PhoneNumber::Voice ) { 549 if ((*phoneIt).type() - PhoneNumber::Voice ) {
550 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 550 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
551 insertPhoneNumber( (*phoneIt) ); 551 insertPhoneNumber( (*phoneIt) );
552 found = true; 552 found = true;
553 } 553 }
554 } 554 }
555 555
556 } 556 }
557 return found; 557 return found;
558} 558}
559 559
560bool Addressee::containsAdr(const Addressee& ad ) 560bool Addressee::containsAdr(const Addressee& ad )
561{ 561{
562 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 562 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
563 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 563 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
564 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 564 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
565 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 565 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
566 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 566 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
567 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 567 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
568 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 568 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
569 569
570 // compare phone numbers 570 // compare phone numbers
571 PhoneNumber::List phoneN = ad.phoneNumbers(); 571 PhoneNumber::List phoneN = ad.phoneNumbers();
572 PhoneNumber::List::Iterator phoneIt; 572 PhoneNumber::List::Iterator phoneIt;
573 bool found = false; 573 bool found = false;
574 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 574 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
575 bool found = false; 575 bool found = false;
576 PhoneNumber::List phoneL = ad.phoneNumbers(); 576 PhoneNumber::List phoneL = ad.phoneNumbers();
577 PhoneNumber::List::Iterator phoneItL; 577 PhoneNumber::List::Iterator phoneItL;
578 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 578 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
579 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 579 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
580 found = true; 580 found = true;
581 break; 581 break;
582 } 582 }
583 } 583 }
584 if ( ! found ) 584 if ( ! found )
585 return false; 585 return false;
586 } 586 }
587 return true; 587 return true;
588 588
589} 589}
590void Addressee::simplifyAddresses() 590void Addressee::simplifyAddresses()
591{ 591{
592 592
593 593
594 Address::List list; 594 Address::List list;
595 Address::List::Iterator it; 595 Address::List::Iterator it;
596 Address::List::Iterator it2; 596 Address::List::Iterator it2;
597 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 597 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
598 it2 = it; 598 it2 = it;
599 ++it2; 599 ++it2;
600 for( ; it2 != mData->addresses.end(); ++it2 ) { 600 for( ; it2 != mData->addresses.end(); ++it2 ) {
601 if ( (*it) == (*it2) ) { 601 if ( (*it) == (*it2) ) {
602 list.append( *it ); 602 list.append( *it );
603 break; 603 break;
604 } 604 }
605 } 605 }
606 } 606 }
607 for( it = list.begin(); it != list.end(); ++it ) { 607 for( it = list.begin(); it != list.end(); ++it ) {
608 removeAddress( (*it) ); 608 removeAddress( (*it) );
609 } 609 }
610 610
611 list.clear(); 611 list.clear();
612 int max = 2; 612 int max = 2;
613 if ( mData->url.isValid() ) 613 if ( mData->url.isValid() )
614 max = 1; 614 max = 1;
615 if ( mData->addresses.count() <= max ) return ; 615 if ( mData->addresses.count() <= max ) return ;
616 int count = 0; 616 int count = 0;
617 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 617 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
618 if ( count >= max ) 618 if ( count >= max )
619 list.append( *it ); 619 list.append( *it );
620 ++count; 620 ++count;
621 } 621 }
622 for( it = list.begin(); it != list.end(); ++it ) { 622 for( it = list.begin(); it != list.end(); ++it ) {
623 removeAddress( (*it) ); 623 removeAddress( (*it) );
624 } 624 }
625} 625}
626 626
627// removes all emails but the first 627// removes all emails but the first
628// needed by phone sync 628// needed by phone sync
629void Addressee::simplifyEmails() 629void Addressee::simplifyEmails()
630{ 630{
631 if ( mData->emails.count() == 0 ) return ; 631 if ( mData->emails.count() == 0 ) return ;
632 QString email = mData->emails.first(); 632 QString email = mData->emails.first();
633 detach(); 633 detach();
634 mData->emails.clear(); 634 mData->emails.clear();
635 mData->emails.append( email ); 635 mData->emails.append( email );
636} 636}
637void Addressee::makePhoneNumbersOLcompatible() 637void Addressee::makePhoneNumbersOLcompatible()
638{ 638{
639 KABC::PhoneNumber::List::Iterator phoneIter; 639 KABC::PhoneNumber::List::Iterator phoneIter;
640 KABC::PhoneNumber::List::Iterator phoneIter2; 640 KABC::PhoneNumber::List::Iterator phoneIter2;
641 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 641 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
642 ++phoneIter ) { 642 ++phoneIter ) {
643 ( *phoneIter ).makeCompat(); 643 ( *phoneIter ).makeCompat();
644 } 644 }
645 int hasHome = hasPhoneNumberType( PhoneNumber::Home | PhoneNumber::Pref ); 645 int hasHome = hasPhoneNumberType( PhoneNumber::Home | PhoneNumber::Pref );
646 int hasHome2 = hasPhoneNumberType( PhoneNumber::Home ); 646 int hasHome2 = hasPhoneNumberType( PhoneNumber::Home );
647 int hasWork = hasPhoneNumberType( PhoneNumber::Work | PhoneNumber::Pref ); 647 int hasWork = hasPhoneNumberType( PhoneNumber::Work | PhoneNumber::Pref );
648 int hasWork2 = hasPhoneNumberType( PhoneNumber::Work ); 648 int hasWork2 = hasPhoneNumberType( PhoneNumber::Work );
649 int hasCell = hasPhoneNumberType( PhoneNumber::Cell ); 649 int hasCell = hasPhoneNumberType( PhoneNumber::Cell );
650 int hasCell2 = hasPhoneNumberType( PhoneNumber::Car ); 650 int hasCell2 = hasPhoneNumberType( PhoneNumber::Car );