-rw-r--r-- | kabc/addressee.cpp | 3 | ||||
-rw-r--r-- | kabc/phonenumber.cpp | 31 | ||||
-rw-r--r-- | kabc/plugins/ldap/ldapE.pro | 2 |
3 files changed, 16 insertions, 20 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 028d3bb..eec0f1f 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -135,385 +135,386 @@ 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 | } | 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 | } |
209 | void Addressee::computeCsum(const QString &dev) | 209 | void 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.isEmpty() ) l.append( mData->additionalName ); | 216 | if ( !mData->additionalName.isEmpty() ) 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() ) | 235 | if ( mData->url.isValid() ) |
236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
237 | KABC::PhoneNumber::List phoneNumbers; | 237 | KABC::PhoneNumber::List phoneNumbers; |
238 | KABC::PhoneNumber::List::Iterator phoneIter; | 238 | KABC::PhoneNumber::List::Iterator phoneIter; |
239 | 239 | ||
240 | QStringList t; | 240 | QStringList t; |
241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
242 | ++phoneIter ) | 242 | ++phoneIter ) |
243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
244 | t.sort(); | 244 | t.sort(); |
245 | uint iii; | 245 | uint iii; |
246 | for ( iii = 0; iii < t.count(); ++iii) | 246 | for ( iii = 0; iii < t.count(); ++iii) |
247 | l.append( t[iii] ); | 247 | l.append( t[iii] ); |
248 | t = mData->emails; | 248 | t = mData->emails; |
249 | t.sort(); | 249 | t.sort(); |
250 | for ( iii = 0; iii < t.count(); ++iii) | 250 | for ( iii = 0; iii < t.count(); ++iii) |
251 | l.append( t[iii] ); | 251 | l.append( t[iii] ); |
252 | t = mData->categories; | 252 | t = mData->categories; |
253 | t.sort(); | 253 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 254 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 255 | l.append( t[iii] ); |
256 | t = mData->custom; | 256 | t = mData->custom; |
257 | t.sort(); | 257 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 258 | for ( iii = 0; iii < t.count(); ++iii) |
259 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { | 259 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { |
260 | int find = t[iii].find (':')+1; | 260 | int find = t[iii].find (':')+1; |
261 | //qDebug("lennnn %d %d ", find, t[iii].length()); | 261 | //qDebug("lennnn %d %d ", find, t[iii].length()); |
262 | if ( find < t[iii].length()) | 262 | if ( find < t[iii].length()) |
263 | l.append( t[iii] ); | 263 | l.append( t[iii] ); |
264 | 264 | ||
265 | } | 265 | } |
266 | KABC::Address::List::Iterator addressIter; | 266 | KABC::Address::List::Iterator addressIter; |
267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
268 | ++addressIter ) { | 268 | ++addressIter ) { |
269 | t = (*addressIter).asList(); | 269 | t = (*addressIter).asList(); |
270 | t.sort(); | 270 | t.sort(); |
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 | } | 273 | } |
274 | uint cs = getCsum4List(l); | 274 | uint cs = getCsum4List(l); |
275 | #if 0 | 275 | #if 0 |
276 | for ( iii = 0; iii < l.count(); ++iii) | 276 | for ( iii = 0; iii < l.count(); ++iii) |
277 | qDebug("%d***%s***",iii,l[iii].latin1()); | 277 | qDebug("%d***%s***",iii,l[iii].latin1()); |
278 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 278 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
279 | #endif | 279 | #endif |
280 | setCsum( dev, QString::number (cs )); | 280 | setCsum( dev, QString::number (cs )); |
281 | } | 281 | } |
282 | 282 | ||
283 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 283 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
284 | { | 284 | { |
285 | 285 | ||
286 | detach(); | 286 | detach(); |
287 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 287 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
288 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 288 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
289 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 289 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
290 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 290 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
291 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 291 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
292 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 292 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
293 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 293 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
294 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 294 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
295 | if ( !mData->birthday.isValid() ) | 295 | if ( !mData->birthday.isValid() ) |
296 | if ( ad.mData->birthday.isValid()) | 296 | if ( ad.mData->birthday.isValid()) |
297 | mData->birthday = ad.mData->birthday; | 297 | mData->birthday = ad.mData->birthday; |
298 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 298 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
299 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 299 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
300 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 300 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
301 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 301 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
302 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 302 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
303 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 303 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
304 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 304 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
305 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 305 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
306 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 306 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
307 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 307 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
308 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 308 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
309 | QStringList t; | 309 | QStringList t; |
310 | QStringList tAD; | 310 | QStringList tAD; |
311 | uint iii; | 311 | uint iii; |
312 | 312 | ||
313 | // ********** phone numbers | 313 | // ********** phone numbers |
314 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 314 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
315 | PhoneNumber::List::Iterator phoneItAD; | 315 | PhoneNumber::List::Iterator phoneItAD; |
316 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 316 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
317 | bool found = false; | 317 | bool found = false; |
318 | PhoneNumber::List::Iterator it; | 318 | PhoneNumber::List::Iterator it; |
319 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 319 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
320 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 320 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
321 | found = true; | 321 | found = true; |
322 | (*it).setType( ( *phoneItAD ).type() ); | 322 | (*it).setType( ( *phoneItAD ).type() ); |
323 | (*it).setNumber( ( *phoneItAD ).number() ); | 323 | (*it).setNumber( ( *phoneItAD ).number() ); |
324 | break; | 324 | break; |
325 | } | 325 | } |
326 | } | 326 | } |
327 | if ( isSubSet && ! found ) | 327 | // if ( isSubSet && ! found ) |
328 | if ( ! found ) // LR try this one... | ||
328 | mData->phoneNumbers.append( *phoneItAD ); | 329 | mData->phoneNumbers.append( *phoneItAD ); |
329 | } | 330 | } |
330 | if ( isSubSet ) { | 331 | if ( isSubSet ) { |
331 | // ************* emails; | 332 | // ************* emails; |
332 | t = mData->emails; | 333 | t = mData->emails; |
333 | tAD = ad.mData->emails; | 334 | tAD = ad.mData->emails; |
334 | for ( iii = 0; iii < tAD.count(); ++iii) | 335 | for ( iii = 0; iii < tAD.count(); ++iii) |
335 | if ( !t.contains(tAD[iii] ) ) | 336 | if ( !t.contains(tAD[iii] ) ) |
336 | mData->emails.append( tAD[iii] ); | 337 | mData->emails.append( tAD[iii] ); |
337 | } | 338 | } |
338 | 339 | ||
339 | // ************* categories; | 340 | // ************* categories; |
340 | t = mData->categories; | 341 | t = mData->categories; |
341 | tAD = ad.mData->categories; | 342 | tAD = ad.mData->categories; |
342 | for ( iii = 0; iii < tAD.count(); ++iii) | 343 | for ( iii = 0; iii < tAD.count(); ++iii) |
343 | if ( !t.contains(tAD[iii] ) ) | 344 | if ( !t.contains(tAD[iii] ) ) |
344 | mData->categories.append( tAD[iii] ); | 345 | mData->categories.append( tAD[iii] ); |
345 | QStringList::ConstIterator it; | 346 | QStringList::ConstIterator it; |
346 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 347 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
347 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 348 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
348 | bool found = false; | 349 | bool found = false; |
349 | QStringList::ConstIterator itL; | 350 | QStringList::ConstIterator itL; |
350 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 351 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
351 | if ( (*itL).startsWith( qualifiedName ) ) { | 352 | if ( (*itL).startsWith( qualifiedName ) ) { |
352 | found = true; | 353 | found = true; |
353 | break; | 354 | break; |
354 | } | 355 | } |
355 | } | 356 | } |
356 | if ( ! found ) { | 357 | if ( ! found ) { |
357 | mData->custom.append( *it ); | 358 | mData->custom.append( *it ); |
358 | } | 359 | } |
359 | } | 360 | } |
360 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 361 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
361 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 362 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
362 | if ( !mData->sound.isIntern() ) { | 363 | if ( !mData->sound.isIntern() ) { |
363 | if ( mData->sound.url().isEmpty() ) { | 364 | if ( mData->sound.url().isEmpty() ) { |
364 | mData->sound = ad.mData->sound; | 365 | mData->sound = ad.mData->sound; |
365 | } | 366 | } |
366 | } | 367 | } |
367 | if ( !mData->agent.isIntern() ) { | 368 | if ( !mData->agent.isIntern() ) { |
368 | if ( mData->agent.url().isEmpty() ) { | 369 | if ( mData->agent.url().isEmpty() ) { |
369 | mData->agent = ad.mData->agent; | 370 | mData->agent = ad.mData->agent; |
370 | } | 371 | } |
371 | } | 372 | } |
372 | { | 373 | { |
373 | Key::List::Iterator itA; | 374 | Key::List::Iterator itA; |
374 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | 375 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { |
375 | bool found = false; | 376 | bool found = false; |
376 | Key::List::Iterator it; | 377 | Key::List::Iterator it; |
377 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 378 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
378 | if ( (*it) == (*itA)) { | 379 | if ( (*it) == (*itA)) { |
379 | found = true; | 380 | found = true; |
380 | break; | 381 | break; |
381 | 382 | ||
382 | } | 383 | } |
383 | } | 384 | } |
384 | if ( ! found ) { | 385 | if ( ! found ) { |
385 | mData->keys.append( *itA ); | 386 | mData->keys.append( *itA ); |
386 | } | 387 | } |
387 | } | 388 | } |
388 | } | 389 | } |
389 | KABC::Address::List::Iterator addressIterA; | 390 | KABC::Address::List::Iterator addressIterA; |
390 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 391 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
391 | bool found = false; | 392 | bool found = false; |
392 | KABC::Address::List::Iterator addressIter; | 393 | KABC::Address::List::Iterator addressIter; |
393 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 394 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
394 | ++addressIter ) { | 395 | ++addressIter ) { |
395 | if ( (*addressIter) == (*addressIterA)) { | 396 | if ( (*addressIter) == (*addressIterA)) { |
396 | found = true; | 397 | found = true; |
397 | (*addressIter).setType( (*addressIterA).type() ); | 398 | (*addressIter).setType( (*addressIterA).type() ); |
398 | break; | 399 | break; |
399 | } | 400 | } |
400 | 401 | ||
401 | } | 402 | } |
402 | if ( isSubSet && ! found ) { | 403 | if ( isSubSet && ! found ) { |
403 | mData->addresses.append( *addressIterA ); | 404 | mData->addresses.append( *addressIterA ); |
404 | } | 405 | } |
405 | } | 406 | } |
406 | //qDebug("merge contact %s ", ad.uid().latin1()); | 407 | //qDebug("merge contact %s ", ad.uid().latin1()); |
407 | setUid( ad.uid() ); | 408 | setUid( ad.uid() ); |
408 | setRevision( ad.revision() ); | 409 | setRevision( ad.revision() ); |
409 | } | 410 | } |
410 | 411 | ||
411 | bool Addressee::removeVoice() | 412 | bool Addressee::removeVoice() |
412 | { | 413 | { |
413 | PhoneNumber::List phoneN = phoneNumbers(); | 414 | PhoneNumber::List phoneN = phoneNumbers(); |
414 | PhoneNumber::List::Iterator phoneIt; | 415 | PhoneNumber::List::Iterator phoneIt; |
415 | bool found = false; | 416 | bool found = false; |
416 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 417 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
417 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 418 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
418 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 419 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
419 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 420 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
420 | insertPhoneNumber( (*phoneIt) ); | 421 | insertPhoneNumber( (*phoneIt) ); |
421 | found = true; | 422 | found = true; |
422 | } | 423 | } |
423 | } | 424 | } |
424 | 425 | ||
425 | } | 426 | } |
426 | return found; | 427 | return found; |
427 | } | 428 | } |
428 | 429 | ||
429 | bool Addressee::containsAdr(const Addressee& ad ) | 430 | bool Addressee::containsAdr(const Addressee& ad ) |
430 | { | 431 | { |
431 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; | 432 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; |
432 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; | 433 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; |
433 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; | 434 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; |
434 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; | 435 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; |
435 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; | 436 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; |
436 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; | 437 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; |
437 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; | 438 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; |
438 | 439 | ||
439 | // compare phone numbers | 440 | // compare phone numbers |
440 | PhoneNumber::List phoneN = ad.phoneNumbers(); | 441 | PhoneNumber::List phoneN = ad.phoneNumbers(); |
441 | PhoneNumber::List::Iterator phoneIt; | 442 | PhoneNumber::List::Iterator phoneIt; |
442 | bool found = false; | 443 | bool found = false; |
443 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 444 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
444 | bool found = false; | 445 | bool found = false; |
445 | PhoneNumber::List phoneL = ad.phoneNumbers(); | 446 | PhoneNumber::List phoneL = ad.phoneNumbers(); |
446 | PhoneNumber::List::Iterator phoneItL; | 447 | PhoneNumber::List::Iterator phoneItL; |
447 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { | 448 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { |
448 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { | 449 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { |
449 | found = true; | 450 | found = true; |
450 | break; | 451 | break; |
451 | } | 452 | } |
452 | } | 453 | } |
453 | if ( ! found ) | 454 | if ( ! found ) |
454 | return false; | 455 | return false; |
455 | } | 456 | } |
456 | return true; | 457 | return true; |
457 | 458 | ||
458 | } | 459 | } |
459 | void Addressee::simplifyAddresses() | 460 | void Addressee::simplifyAddresses() |
460 | { | 461 | { |
461 | 462 | ||
462 | 463 | ||
463 | Address::List list; | 464 | Address::List list; |
464 | Address::List::Iterator it; | 465 | Address::List::Iterator it; |
465 | Address::List::Iterator it2; | 466 | Address::List::Iterator it2; |
466 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 467 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
467 | it2 = it; | 468 | it2 = it; |
468 | ++it2; | 469 | ++it2; |
469 | for( ; it2 != mData->addresses.end(); ++it2 ) { | 470 | for( ; it2 != mData->addresses.end(); ++it2 ) { |
470 | if ( (*it) == (*it2) ) { | 471 | if ( (*it) == (*it2) ) { |
471 | list.append( *it ); | 472 | list.append( *it ); |
472 | break; | 473 | break; |
473 | } | 474 | } |
474 | } | 475 | } |
475 | } | 476 | } |
476 | for( it = list.begin(); it != list.end(); ++it ) { | 477 | for( it = list.begin(); it != list.end(); ++it ) { |
477 | removeAddress( (*it) ); | 478 | removeAddress( (*it) ); |
478 | } | 479 | } |
479 | 480 | ||
480 | list.clear(); | 481 | list.clear(); |
481 | int max = 2; | 482 | int max = 2; |
482 | if ( mData->url.isValid() ) | 483 | if ( mData->url.isValid() ) |
483 | max = 1; | 484 | max = 1; |
484 | if ( mData->addresses.count() <= max ) return ; | 485 | if ( mData->addresses.count() <= max ) return ; |
485 | int count = 0; | 486 | int count = 0; |
486 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 487 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
487 | if ( count >= max ) | 488 | if ( count >= max ) |
488 | list.append( *it ); | 489 | list.append( *it ); |
489 | ++count; | 490 | ++count; |
490 | } | 491 | } |
491 | for( it = list.begin(); it != list.end(); ++it ) { | 492 | for( it = list.begin(); it != list.end(); ++it ) { |
492 | removeAddress( (*it) ); | 493 | removeAddress( (*it) ); |
493 | } | 494 | } |
494 | } | 495 | } |
495 | 496 | ||
496 | // removes all emails but the first | 497 | // removes all emails but the first |
497 | // needed by phone sync | 498 | // needed by phone sync |
498 | void Addressee::simplifyEmails() | 499 | void Addressee::simplifyEmails() |
499 | { | 500 | { |
500 | if ( mData->emails.count() == 0 ) return ; | 501 | if ( mData->emails.count() == 0 ) return ; |
501 | QString email = mData->emails.first(); | 502 | QString email = mData->emails.first(); |
502 | detach(); | 503 | detach(); |
503 | mData->emails.clear(); | 504 | mData->emails.clear(); |
504 | mData->emails.append( email ); | 505 | mData->emails.append( email ); |
505 | } | 506 | } |
506 | 507 | ||
507 | void Addressee::simplifyPhoneNumbers() | 508 | void Addressee::simplifyPhoneNumbers() |
508 | { | 509 | { |
509 | int max = 4; | 510 | int max = 4; |
510 | int inList = mData->phoneNumbers.count(); | 511 | int inList = mData->phoneNumbers.count(); |
511 | KABC::PhoneNumber::List removeNumbers; | 512 | KABC::PhoneNumber::List removeNumbers; |
512 | KABC::PhoneNumber::List::Iterator phoneIter; | 513 | KABC::PhoneNumber::List::Iterator phoneIter; |
513 | if ( inList > max ) { | 514 | if ( inList > max ) { |
514 | // delete non-preferred numbers | 515 | // delete non-preferred numbers |
515 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 516 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
516 | ++phoneIter ) { | 517 | ++phoneIter ) { |
517 | if ( inList > max ) { | 518 | if ( inList > max ) { |
518 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | 519 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { |
519 | removeNumbers.append( ( *phoneIter ) ); | 520 | removeNumbers.append( ( *phoneIter ) ); |
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index 3d82553..abb3b3b 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp | |||
@@ -1,245 +1,240 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <kapplication.h> | 28 | #include <kapplication.h> |
29 | #include <klocale.h> | 29 | #include <klocale.h> |
30 | 30 | ||
31 | #include "phonenumber.h" | 31 | #include "phonenumber.h" |
32 | 32 | ||
33 | using namespace KABC; | 33 | using namespace KABC; |
34 | 34 | ||
35 | PhoneNumber::PhoneNumber() : | 35 | PhoneNumber::PhoneNumber() : |
36 | mType( Home ) | 36 | mType( Home ) |
37 | { | 37 | { |
38 | init(); | 38 | init(); |
39 | } | 39 | } |
40 | 40 | ||
41 | PhoneNumber::PhoneNumber( const QString &number, int type ) : | 41 | PhoneNumber::PhoneNumber( const QString &number, int type ) : |
42 | mType( type ), mNumber( number ) | 42 | mType( type ), mNumber( number ) |
43 | { | 43 | { |
44 | init(); | 44 | init(); |
45 | } | 45 | } |
46 | 46 | ||
47 | PhoneNumber::~PhoneNumber() | 47 | PhoneNumber::~PhoneNumber() |
48 | { | 48 | { |
49 | } | 49 | } |
50 | 50 | ||
51 | void PhoneNumber::init() | 51 | void PhoneNumber::init() |
52 | { | 52 | { |
53 | mId = KApplication::randomString( 8 ); | 53 | mId = KApplication::randomString( 8 ); |
54 | } | 54 | } |
55 | 55 | ||
56 | bool PhoneNumber::operator==( const PhoneNumber &p ) const | 56 | bool PhoneNumber::operator==( const PhoneNumber &p ) const |
57 | { | 57 | { |
58 | if ( mNumber != p.mNumber ) return false; | 58 | if ( mNumber != p.mNumber ) return false; |
59 | if ( mType != p.mType ) return false; | 59 | if ( mType != p.mType ) return false; |
60 | 60 | ||
61 | return true; | 61 | return true; |
62 | } | 62 | } |
63 | 63 | ||
64 | bool PhoneNumber::operator!=( const PhoneNumber &p ) const | 64 | bool PhoneNumber::operator!=( const PhoneNumber &p ) const |
65 | { | 65 | { |
66 | return !( p == *this ); | 66 | return !( p == *this ); |
67 | } | 67 | } |
68 | 68 | ||
69 | bool PhoneNumber::simplifyNumber() | 69 | bool PhoneNumber::simplifyNumber() |
70 | { | 70 | { |
71 | QString Number; | 71 | QString Number; |
72 | int i; | 72 | int i; |
73 | Number = mNumber.stripWhiteSpace (); | 73 | Number = mNumber.stripWhiteSpace (); |
74 | mNumber = ""; | 74 | mNumber = ""; |
75 | for ( i = 0; i < Number.length(); ++i) { | 75 | for ( i = 0; i < Number.length(); ++i) { |
76 | if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) | 76 | if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) |
77 | mNumber += Number.at(i); | 77 | mNumber += Number.at(i); |
78 | } | 78 | } |
79 | return ( mNumber.length() > 0 ); | 79 | return ( mNumber.length() > 0 ); |
80 | } | 80 | } |
81 | // make cellphone compatible | 81 | // make cellphone compatible |
82 | void PhoneNumber::simplifyType() | 82 | void PhoneNumber::simplifyType() |
83 | { | 83 | { |
84 | if ( mType & Fax ) mType = Fax; | 84 | if ( mType & Fax ) mType = Fax; |
85 | else if ( mType & Cell ) mType = Cell; | 85 | else if ( mType & Cell ) mType = Cell; |
86 | else if ( mType & Work ) mType = Work ; | 86 | else if ( mType & Work ) mType = Work ; |
87 | else if ( mType & Home ) mType = Home; | 87 | else if ( mType & Home ) mType = Home; |
88 | else mType = Pref; | 88 | else mType = Pref; |
89 | } | 89 | } |
90 | bool PhoneNumber::contains( const PhoneNumber &p ) | 90 | bool PhoneNumber::contains( const PhoneNumber &p ) |
91 | { | 91 | { |
92 | QString Number; | 92 | PhoneNumber myself; |
93 | QString Num; | 93 | PhoneNumber other; |
94 | uint i; | 94 | myself = *this; |
95 | Number = mNumber.stripWhiteSpace (); | 95 | other = p; |
96 | Num = ""; | 96 | myself.simplifyNumber(); |
97 | for ( i = 0; i < Number.length(); ++i) { | 97 | other.simplifyNumber(); |
98 | if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) | 98 | if ( myself.number() != other.number ()) |
99 | Num += Number.at(i); | 99 | return false; |
100 | } | 100 | myself.simplifyType(); |
101 | QString NumberR; | 101 | other.simplifyType(); |
102 | QString NumR; | 102 | if ( myself.type() == other.type()) |
103 | NumberR = p.mNumber.stripWhiteSpace (); | 103 | return true; |
104 | NumR = ""; | 104 | return false; |
105 | for ( i = 0; i < NumberR.length(); ++i) { | ||
106 | if ( NumberR.at(i).isDigit() || NumberR.at(i) == '+'|| NumberR.at(i) == '*'|| NumberR.at(i) == '#' ) | ||
107 | NumR += NumberR.at(i); | ||
108 | } | ||
109 | return (Num == NumR); | ||
110 | } | 105 | } |
111 | 106 | ||
112 | void PhoneNumber::setId( const QString &id ) | 107 | void PhoneNumber::setId( const QString &id ) |
113 | { | 108 | { |
114 | mId = id; | 109 | mId = id; |
115 | } | 110 | } |
116 | 111 | ||
117 | QString PhoneNumber::id() const | 112 | QString PhoneNumber::id() const |
118 | { | 113 | { |
119 | return mId; | 114 | return mId; |
120 | } | 115 | } |
121 | 116 | ||
122 | void PhoneNumber::setNumber( const QString &number ) | 117 | void PhoneNumber::setNumber( const QString &number ) |
123 | { | 118 | { |
124 | mNumber = number; | 119 | mNumber = number; |
125 | } | 120 | } |
126 | 121 | ||
127 | QString PhoneNumber::number() const | 122 | QString PhoneNumber::number() const |
128 | { | 123 | { |
129 | return mNumber; | 124 | return mNumber; |
130 | } | 125 | } |
131 | 126 | ||
132 | void PhoneNumber::setType( int type ) | 127 | void PhoneNumber::setType( int type ) |
133 | { | 128 | { |
134 | mType = type; | 129 | mType = type; |
135 | } | 130 | } |
136 | 131 | ||
137 | int PhoneNumber::type() const | 132 | int PhoneNumber::type() const |
138 | { | 133 | { |
139 | return mType; | 134 | return mType; |
140 | } | 135 | } |
141 | 136 | ||
142 | QString PhoneNumber::typeLabel() const | 137 | QString PhoneNumber::typeLabel() const |
143 | { | 138 | { |
144 | QString label; | 139 | QString label; |
145 | bool first = true; | 140 | bool first = true; |
146 | 141 | ||
147 | TypeList list = typeList(); | 142 | TypeList list = typeList(); |
148 | 143 | ||
149 | TypeList::Iterator it; | 144 | TypeList::Iterator it; |
150 | for ( it = list.begin(); it != list.end(); ++it ) { | 145 | for ( it = list.begin(); it != list.end(); ++it ) { |
151 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { | 146 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { |
152 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); | 147 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); |
153 | if ( first ) | 148 | if ( first ) |
154 | first = false; | 149 | first = false; |
155 | } | 150 | } |
156 | } | 151 | } |
157 | 152 | ||
158 | return label; | 153 | return label; |
159 | } | 154 | } |
160 | 155 | ||
161 | QString PhoneNumber::label() const | 156 | QString PhoneNumber::label() const |
162 | { | 157 | { |
163 | return typeLabel( type() ); | 158 | return typeLabel( type() ); |
164 | } | 159 | } |
165 | 160 | ||
166 | PhoneNumber::TypeList PhoneNumber::typeList() | 161 | PhoneNumber::TypeList PhoneNumber::typeList() |
167 | { | 162 | { |
168 | TypeList list; | 163 | TypeList list; |
169 | 164 | ||
170 | list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video | 165 | list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video |
171 | << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip; | 166 | << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip; |
172 | 167 | ||
173 | return list; | 168 | return list; |
174 | } | 169 | } |
175 | 170 | ||
176 | QString PhoneNumber::label( int type ) | 171 | QString PhoneNumber::label( int type ) |
177 | { | 172 | { |
178 | return typeLabel( type ); | 173 | return typeLabel( type ); |
179 | } | 174 | } |
180 | 175 | ||
181 | QString PhoneNumber::typeLabel( int type ) | 176 | QString PhoneNumber::typeLabel( int type ) |
182 | { | 177 | { |
183 | QString typeString; | 178 | QString typeString; |
184 | 179 | ||
185 | if ((type & Home) == Home) | 180 | if ((type & Home) == Home) |
186 | typeString += i18n("Home"); | 181 | typeString += i18n("Home"); |
187 | else if ((type & Work) == Work) | 182 | else if ((type & Work) == Work) |
188 | typeString += i18n("Work"); | 183 | typeString += i18n("Work"); |
189 | 184 | ||
190 | if (!typeString.isEmpty()) | 185 | if (!typeString.isEmpty()) |
191 | typeString += " "; | 186 | typeString += " "; |
192 | 187 | ||
193 | if ((type & Cell) == Cell) | 188 | if ((type & Cell) == Cell) |
194 | typeString += i18n("Mobile"); | 189 | typeString += i18n("Mobile"); |
195 | else if ((type & Fax) == Fax) | 190 | else if ((type & Fax) == Fax) |
196 | typeString += i18n("Fax"); | 191 | typeString += i18n("Fax"); |
197 | else if ((type & Msg) == Msg) | 192 | else if ((type & Msg) == Msg) |
198 | typeString += i18n("Messenger"); | 193 | typeString += i18n("Messenger"); |
199 | else if ((type & Voice) == Voice) { | 194 | else if ((type & Voice) == Voice) { |
200 | // add nothing in case of the Voice flag | 195 | // add nothing in case of the Voice flag |
201 | // typeString += i18n("Voice"); | 196 | // typeString += i18n("Voice"); |
202 | } | 197 | } |
203 | else if ((type & Video) == Video) | 198 | else if ((type & Video) == Video) |
204 | typeString += i18n("Video"); | 199 | typeString += i18n("Video"); |
205 | else if ((type & Bbs) == Bbs) | 200 | else if ((type & Bbs) == Bbs) |
206 | typeString += i18n("Mailbox"); | 201 | typeString += i18n("Mailbox"); |
207 | else if ((type & Modem) == Modem) | 202 | else if ((type & Modem) == Modem) |
208 | typeString += i18n("Modem"); | 203 | typeString += i18n("Modem"); |
209 | else if ((type & Car) == Car) | 204 | else if ((type & Car) == Car) |
210 | typeString += i18n("Car"); | 205 | typeString += i18n("Car"); |
211 | else if ((type & Isdn) == Isdn) | 206 | else if ((type & Isdn) == Isdn) |
212 | typeString += i18n("ISDN"); | 207 | typeString += i18n("ISDN"); |
213 | else if ((type & Pcs) == Pcs) | 208 | else if ((type & Pcs) == Pcs) |
214 | typeString += i18n("PCS"); | 209 | typeString += i18n("PCS"); |
215 | else if ((type & Pager) == Pager) | 210 | else if ((type & Pager) == Pager) |
216 | typeString += i18n("Pager"); | 211 | typeString += i18n("Pager"); |
217 | else if ((type & Sip) == Sip) | 212 | else if ((type & Sip) == Sip) |
218 | typeString += i18n("SIP"); | 213 | typeString += i18n("SIP"); |
219 | 214 | ||
220 | // add the prefered flag | 215 | // add the prefered flag |
221 | if (!typeString.isEmpty()) | 216 | if (!typeString.isEmpty()) |
222 | typeString += " "; | 217 | typeString += " "; |
223 | /* | 218 | /* |
224 | if ((type & Pref) == Pref) | 219 | if ((type & Pref) == Pref) |
225 | typeString += i18n("(p)"); | 220 | typeString += i18n("(p)"); |
226 | */ | 221 | */ |
227 | //if we still have no match, return "other" | 222 | //if we still have no match, return "other" |
228 | if (typeString.isEmpty()) | 223 | if (typeString.isEmpty()) |
229 | return i18n("Other"); | 224 | return i18n("Other"); |
230 | 225 | ||
231 | 226 | ||
232 | return typeString; | 227 | return typeString; |
233 | } | 228 | } |
234 | 229 | ||
235 | QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) | 230 | QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) |
236 | { | 231 | { |
237 | return s << phone.mId << phone.mType << phone.mNumber; | 232 | return s << phone.mId << phone.mType << phone.mNumber; |
238 | } | 233 | } |
239 | 234 | ||
240 | QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) | 235 | QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) |
241 | { | 236 | { |
242 | s >> phone.mId >> phone.mType >> phone.mNumber; | 237 | s >> phone.mId >> phone.mType >> phone.mNumber; |
243 | 238 | ||
244 | return s; | 239 | return s; |
245 | } | 240 | } |
diff --git a/kabc/plugins/ldap/ldapE.pro b/kabc/plugins/ldap/ldapE.pro index df3c94c..57b6f84 100644 --- a/kabc/plugins/ldap/ldapE.pro +++ b/kabc/plugins/ldap/ldapE.pro | |||
@@ -1,21 +1,21 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | #release debug | 3 | #release debug |
4 | 4 | ||
5 | TARGET = microkabc_ldap | 5 | TARGET = microkabc_ldap |
6 | INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include | 6 | INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include |
7 | OBJECTS_DIR = obj/$(PLATFORM) | 7 | OBJECTS_DIR = obj/$(PLATFORM) |
8 | MOC_DIR = moc/$(PLATFORM) | 8 | MOC_DIR = moc/$(PLATFORM) |
9 | DESTDIR = $(QPEDIR)/lib | 9 | DESTDIR = $(QPEDIR)/lib |
10 | LIBS += -lmicrokde -lkamicrokabc | 10 | LIBS += -lmicrokde -lmicrokabc |
11 | LIBS += -L$(QPEDIR)/lib | 11 | LIBS += -L$(QPEDIR)/lib |
12 | 12 | ||
13 | INTERFACES = \ | 13 | INTERFACES = \ |
14 | 14 | ||
15 | HEADERS = \ | 15 | HEADERS = \ |
16 | resourceldap.h \ | 16 | resourceldap.h \ |
17 | resourceldapconfig.h | 17 | resourceldapconfig.h |
18 | 18 | ||
19 | SOURCES = \ | 19 | SOURCES = \ |
20 | resourceldap.cpp \ | 20 | resourceldap.cpp \ |
21 | resourceldapconfig.cpp | 21 | resourceldapconfig.cpp |