summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
authorzautrix <zautrix>2004-10-10 16:00:04 (UTC)
committer zautrix <zautrix>2004-10-10 16:00:04 (UTC)
commitee6e29a5092d32165b7bf6b39069bd8a1dcd5b0a (patch) (unidiff)
tree1d908bfc23b8a49d43a58bbeadd82c4e08faeff6 /kabc/addressee.cpp
parent213a9d993e5a4751b64e18320cfbebb000681d13 (diff)
downloadkdepimpi-ee6e29a5092d32165b7bf6b39069bd8a1dcd5b0a.zip
kdepimpi-ee6e29a5092d32165b7bf6b39069bd8a1dcd5b0a.tar.gz
kdepimpi-ee6e29a5092d32165b7bf6b39069bd8a1dcd5b0a.tar.bz2
many phone AB sync fixes
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp46
1 files changed, 43 insertions, 3 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 607ae26..548305a 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -114,422 +114,462 @@ Addressee::Addressee( const Addressee &a )
114Addressee &Addressee::operator=( const Addressee &a ) 114Addressee &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
120Addressee Addressee::copy() 120Addressee 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
127void Addressee::detach() 127void 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
133bool Addressee::operator==( const Addressee &a ) const 133bool 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
172bool Addressee::operator!=( const Addressee &a ) const 172bool Addressee::operator!=( const Addressee &a ) const
173{ 173{
174 return !( a == *this ); 174 return !( a == *this );
175} 175}
176 176
177bool Addressee::isEmpty() const 177bool Addressee::isEmpty() const
178{ 178{
179 return mData->empty; 179 return mData->empty;
180} 180}
181ulong Addressee::getCsum4List( const QStringList & attList) 181ulong 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 } 199 }
200 } 200 }
201 201
202 } 202 }
203 //QString dump = attList.join(","); 203 //QString dump = attList.join(",");
204 //qDebug("csum: %d %s", cSum,dump.latin1()); 204 //qDebug("csum: %d %s", cSum,dump.latin1());
205 205
206 return cSum; 206 return cSum;
207 207
208} 208}
209void Addressee::computeCsum(const QString &dev) 209void Addressee::computeCsum(const QString &dev)
210{ 210{
211 QStringList l; 211 QStringList l;
212 if ( !mData->name.isEmpty() ) l.append(mData->name); 212 if ( !mData->name.isEmpty() ) l.append(mData->name);
213 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 213 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
216 if ( !mData->additionalName ) l.append( mData->additionalName ); 216 if ( !mData->additionalName ) l.append( mData->additionalName );
217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
224 if ( !mData->title .isEmpty() ) l.append( mData->title ); 224 if ( !mData->title .isEmpty() ) l.append( mData->title );
225 if ( !mData->role.isEmpty() ) l.append( mData->role ); 225 if ( !mData->role.isEmpty() ) l.append( mData->role );
226 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 226 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
227 if ( !mData->note.isEmpty() ) l.append( mData->note ); 227 if ( !mData->note.isEmpty() ) l.append( mData->note );
228 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 228 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
231 // if ( !mData->logo.isEmpty() ) l.append( ); 231 // if ( !mData->logo.isEmpty() ) l.append( );
232 //if ( !mData->photo.isEmpty() ) l.append( ); 232 //if ( !mData->photo.isEmpty() ) l.append( );
233 //if ( !mData->sound.isEmpty() ) l.append( ); 233 //if ( !mData->sound.isEmpty() ) l.append( );
234 //if ( !mData->agent.isEmpty() ) l.append( ); 234 //if ( !mData->agent.isEmpty() ) l.append( );
235 //if ( mData->url.isValid() ) l.append( ); 235 //if ( mData->url.isValid() ) l.append( );
236#if 0 236#if 0
237 if ( !mData->phoneNumbers.isEmpty() ) l.append( ); 237 if ( !mData->phoneNumbers.isEmpty() ) l.append( );
238 if ( !mData->addresses.isEmpty() ) l.append( ); 238 if ( !mData->addresses.isEmpty() ) l.append( );
239 //if ( !mData->keys.isEmpty() ) l.append( ); 239 //if ( !mData->keys.isEmpty() ) l.append( );
240 if ( !mData->emails.isEmpty() ) l.append( ); 240 if ( !mData->emails.isEmpty() ) l.append( );
241 if ( !mData->categories .isEmpty() ) l.append( ); 241 if ( !mData->categories .isEmpty() ) l.append( );
242 if ( !mData->custom.isEmpty() ) l.append( ); 242 if ( !mData->custom.isEmpty() ) l.append( );
243#endif 243#endif
244 KABC::PhoneNumber::List phoneNumbers; 244 KABC::PhoneNumber::List phoneNumbers;
245 KABC::PhoneNumber::List::Iterator phoneIter; 245 KABC::PhoneNumber::List::Iterator phoneIter;
246 246
247 QStringList t; 247 QStringList t;
248 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 248 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
249 ++phoneIter ) 249 ++phoneIter )
250 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 250 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
251 t.sort(); 251 t.sort();
252 uint iii; 252 uint iii;
253 for ( iii = 0; iii < t.count(); ++iii) 253 for ( iii = 0; iii < t.count(); ++iii)
254 l.append( t[iii] ); 254 l.append( t[iii] );
255 t = mData->emails; 255 t = mData->emails;
256 t.sort(); 256 t.sort();
257 for ( iii = 0; iii < t.count(); ++iii) 257 for ( iii = 0; iii < t.count(); ++iii)
258 l.append( t[iii] ); 258 l.append( t[iii] );
259 t = mData->categories; 259 t = mData->categories;
260 t.sort(); 260 t.sort();
261 for ( iii = 0; iii < t.count(); ++iii) 261 for ( iii = 0; iii < t.count(); ++iii)
262 l.append( t[iii] ); 262 l.append( t[iii] );
263 t = mData->custom; 263 t = mData->custom;
264 t.sort(); 264 t.sort();
265 for ( iii = 0; iii < t.count(); ++iii) 265 for ( iii = 0; iii < t.count(); ++iii)
266 l.append( t[iii] ); 266 l.append( t[iii] );
267 KABC::Address::List::Iterator addressIter; 267 KABC::Address::List::Iterator addressIter;
268 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 268 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
269 ++addressIter ) { 269 ++addressIter ) {
270 t = (*addressIter).asList(); 270 t = (*addressIter).asList();
271 t.sort(); 271 t.sort();
272 for ( iii = 0; iii < t.count(); ++iii) 272 for ( iii = 0; iii < t.count(); ++iii)
273 l.append( t[iii] ); 273 l.append( t[iii] );
274 } 274 }
275 uint cs = getCsum4List(l); 275 uint cs = getCsum4List(l);
276 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 276 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
277 setCsum( dev, QString::number (cs )); 277 setCsum( dev, QString::number (cs ));
278} 278}
279 279
280void Addressee::mergeContact( const Addressee& ad ) 280void Addressee::mergeContact( const Addressee& ad )
281{ 281{
282 282
283 detach(); 283 detach();
284 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 284 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
285 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 285 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
286 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 286 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
287 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 287 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
288 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 288 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
289 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 289 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
290 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 290 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
291 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 291 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
292 if ( !mData->birthday.isValid() ) 292 if ( !mData->birthday.isValid() )
293 if ( ad.mData->birthday.isValid()) 293 if ( ad.mData->birthday.isValid())
294 mData->birthday = ad.mData->birthday; 294 mData->birthday = ad.mData->birthday;
295 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 295 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
296 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 296 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
297 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 297 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
298 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 298 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
299 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 299 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
300 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 300 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
301 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 301 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
302 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 302 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
303 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 303 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
304 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 304 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
305 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 305 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
306 PhoneNumber::List phoneAD = phoneNumbers();
307 PhoneNumber::List::Iterator phoneItAD;
308 bool found = false;
309 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
306 310
311
312 }
307 // pending: 313 // pending:
308 // merging phonenumbers 314 // merging phonenumbers
309 // merging addresses 315 // merging addresses
310 // merging emails; 316 // merging emails;
311 // merging categories; 317 // merging categories;
312 // merging custom; 318 // merging custom;
313 // merging keys 319 // merging keys
314 qDebug("merge contact %s ", ad.uid().latin1()); 320 //qDebug("merge contact %s ", ad.uid().latin1());
315 setUid( ad.uid() ); 321 setUid( ad.uid() );
316 setRevision( ad.revision() ); 322 setRevision( ad.revision() );
317} 323}
318 324
319bool Addressee::removeVoice() 325bool Addressee::removeVoice()
320{ 326{
321 PhoneNumber::List phoneN = phoneNumbers(); 327 PhoneNumber::List phoneN = phoneNumbers();
322 PhoneNumber::List::Iterator phoneIt; 328 PhoneNumber::List::Iterator phoneIt;
323 bool found = false; 329 bool found = false;
324 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 330 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
325 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 331 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
326 if ((*phoneIt).type() - PhoneNumber::Voice ) { 332 if ((*phoneIt).type() - PhoneNumber::Voice ) {
327 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 333 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
328 insertPhoneNumber( (*phoneIt) ); 334 insertPhoneNumber( (*phoneIt) );
329 found = true; 335 found = true;
330 } 336 }
331 } 337 }
332 338
333 } 339 }
334 return found; 340 return found;
335} 341}
342
343bool Addressee::containsAdr(const Addressee& ad )
344{
345 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
346 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
347 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
348 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
349 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
350 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
351 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
352
353 // compare phone numbers
354 PhoneNumber::List phoneN = ad.phoneNumbers();
355 PhoneNumber::List::Iterator phoneIt;
356 bool found = false;
357 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
358 bool found = false;
359 PhoneNumber::List phoneL = ad.phoneNumbers();
360 PhoneNumber::List::Iterator phoneItL;
361 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
362 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
363 found = true;
364 break;
365 }
366 }
367 if ( ! found )
368 return false;
369 }
370 return true;
371
372}
336void Addressee::simplifyAddresses() 373void Addressee::simplifyAddresses()
337{ 374{
338 if ( mData->addresses.count() < 3 ) return ; 375 int max = 2;
376 if ( mData->url.isValid() )
377 max = 1;
378 if ( mData->addresses.count() <= max ) return ;
339 int count = 0; 379 int count = 0;
340 Address::List list; 380 Address::List list;
341 Address::List::Iterator it; 381 Address::List::Iterator it;
342 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 382 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
343 if ( count > 1 ) 383 if ( count >= max )
344 list.append( *it ); 384 list.append( *it );
345 ++count; 385 ++count;
346 } 386 }
347 for( it = list.begin(); it != list.end(); ++it ) { 387 for( it = list.begin(); it != list.end(); ++it ) {
348 removeAddress( (*it) ); 388 removeAddress( (*it) );
349 } 389 }
350} 390}
351 391
352// removes all emails but the first 392// removes all emails but the first
353// needed by phone sync 393// needed by phone sync
354void Addressee::simplifyEmails() 394void Addressee::simplifyEmails()
355{ 395{
356 if ( mData->emails.count() == 0 ) return ; 396 if ( mData->emails.count() == 0 ) return ;
357 QString email = mData->emails.first(); 397 QString email = mData->emails.first();
358 detach(); 398 detach();
359 mData->emails.clear(); 399 mData->emails.clear();
360 mData->emails.append( email ); 400 mData->emails.append( email );
361} 401}
362 402
363void Addressee::simplifyPhoneNumbers() 403void Addressee::simplifyPhoneNumbers()
364{ 404{
365 KABC::PhoneNumber::List removeNumbers; 405 KABC::PhoneNumber::List removeNumbers;
366 KABC::PhoneNumber::List::Iterator phoneIter; 406 KABC::PhoneNumber::List::Iterator phoneIter;
367 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 407 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
368 ++phoneIter ) { 408 ++phoneIter ) {
369 if ( ! ( *phoneIter ).simplifyNumber() ) 409 if ( ! ( *phoneIter ).simplifyNumber() )
370 removeNumbers.append( ( *phoneIter ) ); 410 removeNumbers.append( ( *phoneIter ) );
371 } 411 }
372 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 412 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
373 ++phoneIter ) { 413 ++phoneIter ) {
374 removePhoneNumber(( *phoneIter )); 414 removePhoneNumber(( *phoneIter ));
375 } 415 }
376} 416}
377void Addressee::simplifyPhoneNumberTypes() 417void Addressee::simplifyPhoneNumberTypes()
378{ 418{
379 KABC::PhoneNumber::List::Iterator phoneIter; 419 KABC::PhoneNumber::List::Iterator phoneIter;
380 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 420 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
381 ++phoneIter ) 421 ++phoneIter )
382 ( *phoneIter ).simplifyType(); 422 ( *phoneIter ).simplifyType();
383} 423}
384void Addressee::removeID(const QString &prof) 424void Addressee::removeID(const QString &prof)
385{ 425{
386 detach(); 426 detach();
387 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 427 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
388 428
389} 429}
390void Addressee::setID( const QString & prof , const QString & id ) 430void Addressee::setID( const QString & prof , const QString & id )
391{ 431{
392 detach(); 432 detach();
393 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 433 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
394 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 434 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
395} 435}
396void Addressee::setTempSyncStat( int id ) 436void Addressee::setTempSyncStat( int id )
397{ 437{
398 if ( mData->mTempSyncStat == id ) return; 438 if ( mData->mTempSyncStat == id ) return;
399 detach(); 439 detach();
400 mData->mTempSyncStat = id; 440 mData->mTempSyncStat = id;
401} 441}
402int Addressee::tempSyncStat() const 442int Addressee::tempSyncStat() const
403{ 443{
404 return mData->mTempSyncStat; 444 return mData->mTempSyncStat;
405} 445}
406 446
407QString Addressee::getID( const QString & prof) 447QString Addressee::getID( const QString & prof)
408{ 448{
409 return KIdManager::getId ( mData->mExternalId, prof ); 449 return KIdManager::getId ( mData->mExternalId, prof );
410} 450}
411 451
412void Addressee::setCsum( const QString & prof , const QString & id ) 452void Addressee::setCsum( const QString & prof , const QString & id )
413{ 453{
414 detach(); 454 detach();
415 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 455 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
416 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 456 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
417 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 457 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
418} 458}
419 459
420QString Addressee::getCsum( const QString & prof) 460QString Addressee::getCsum( const QString & prof)
421{ 461{
422 return KIdManager::getCsum ( mData->mExternalId, prof ); 462 return KIdManager::getCsum ( mData->mExternalId, prof );
423} 463}
424 464
425void Addressee::setIDStr( const QString & s ) 465void Addressee::setIDStr( const QString & s )
426{ 466{
427 detach(); 467 detach();
428 mData->mExternalId = s; 468 mData->mExternalId = s;
429} 469}
430 470
431QString Addressee::IDStr() const 471QString Addressee::IDStr() const
432{ 472{
433 return mData->mExternalId; 473 return mData->mExternalId;
434} 474}
435 475
436void Addressee::setExternalUID( const QString &id ) 476void Addressee::setExternalUID( const QString &id )
437{ 477{
438 if ( id == mData->externalUID ) return; 478 if ( id == mData->externalUID ) return;
439 detach(); 479 detach();
440 mData->empty = false; 480 mData->empty = false;
441 mData->externalUID = id; 481 mData->externalUID = id;
442} 482}
443 483
444QString Addressee::externalUID() const 484QString Addressee::externalUID() const
445{ 485{
446 return mData->externalUID; 486 return mData->externalUID;
447} 487}
448void Addressee::setOriginalExternalUID( const QString &id ) 488void Addressee::setOriginalExternalUID( const QString &id )
449{ 489{
450 if ( id == mData->originalExternalUID ) return; 490 if ( id == mData->originalExternalUID ) return;
451 detach(); 491 detach();
452 mData->empty = false; 492 mData->empty = false;
453 //qDebug("*******Set orig uid %s ", id.latin1()); 493 //qDebug("*******Set orig uid %s ", id.latin1());
454 mData->originalExternalUID = id; 494 mData->originalExternalUID = id;
455} 495}
456 496
457QString Addressee::originalExternalUID() const 497QString Addressee::originalExternalUID() const
458{ 498{
459 return mData->originalExternalUID; 499 return mData->originalExternalUID;
460} 500}
461 501
462void Addressee::setUid( const QString &id ) 502void Addressee::setUid( const QString &id )
463{ 503{
464 if ( id == mData->uid ) return; 504 if ( id == mData->uid ) return;
465 detach(); 505 detach();
466 //qDebug("****setuid %s ", id.latin1()); 506 //qDebug("****setuid %s ", id.latin1());
467 mData->empty = false; 507 mData->empty = false;
468 mData->uid = id; 508 mData->uid = id;
469} 509}
470 510
471QString Addressee::uid() const 511QString Addressee::uid() const
472{ 512{
473 if ( mData->uid.isEmpty() ) 513 if ( mData->uid.isEmpty() )
474 mData->uid = KApplication::randomString( 10 ); 514 mData->uid = KApplication::randomString( 10 );
475 515
476 return mData->uid; 516 return mData->uid;
477} 517}
478 518
479QString Addressee::uidLabel() 519QString Addressee::uidLabel()
480{ 520{
481 return i18n("Unique Identifier"); 521 return i18n("Unique Identifier");
482} 522}
483 523
484void Addressee::setName( const QString &name ) 524void Addressee::setName( const QString &name )
485{ 525{
486 if ( name == mData->name ) return; 526 if ( name == mData->name ) return;
487 detach(); 527 detach();
488 mData->empty = false; 528 mData->empty = false;
489 mData->name = name; 529 mData->name = name;
490} 530}
491 531
492QString Addressee::name() const 532QString Addressee::name() const
493{ 533{
494 return mData->name; 534 return mData->name;
495} 535}
496 536
497QString Addressee::nameLabel() 537QString Addressee::nameLabel()
498{ 538{
499 return i18n("Name"); 539 return i18n("Name");
500} 540}
501 541
502 542
503void Addressee::setFormattedName( const QString &formattedName ) 543void Addressee::setFormattedName( const QString &formattedName )
504{ 544{
505 if ( formattedName == mData->formattedName ) return; 545 if ( formattedName == mData->formattedName ) return;
506 detach(); 546 detach();
507 mData->empty = false; 547 mData->empty = false;
508 mData->formattedName = formattedName; 548 mData->formattedName = formattedName;
509} 549}
510 550
511QString Addressee::formattedName() const 551QString Addressee::formattedName() const
512{ 552{
513 return mData->formattedName; 553 return mData->formattedName;
514} 554}
515 555
516QString Addressee::formattedNameLabel() 556QString Addressee::formattedNameLabel()
517{ 557{
518 return i18n("Formatted Name"); 558 return i18n("Formatted Name");
519} 559}
520 560
521 561
522void Addressee::setFamilyName( const QString &familyName ) 562void Addressee::setFamilyName( const QString &familyName )
523{ 563{
524 if ( familyName == mData->familyName ) return; 564 if ( familyName == mData->familyName ) return;
525 detach(); 565 detach();
526 mData->empty = false; 566 mData->empty = false;
527 mData->familyName = familyName; 567 mData->familyName = familyName;
528} 568}
529 569
530QString Addressee::familyName() const 570QString Addressee::familyName() const
531{ 571{
532 return mData->familyName; 572 return mData->familyName;
533} 573}
534 574
535QString Addressee::familyNameLabel() 575QString Addressee::familyNameLabel()