-rw-r--r-- | kabc/addressee.cpp | 4 | ||||
-rw-r--r-- | kabc/addressee.h | 5 | ||||
-rw-r--r-- | kabc/field.cpp | 8 | ||||
-rw-r--r-- | kabc/phonenumber.cpp | 4 | ||||
-rw-r--r-- | kabc/phonenumber.h | 3 | ||||
-rw-r--r-- | kabc/vcard21parser.cpp | 5 | ||||
-rw-r--r-- | kabc/vcard21parser.h | 1 | ||||
-rw-r--r-- | kabc/vcardformatimpl.cpp | 2 | ||||
-rw-r--r-- | kabc/vcardparser/vcardtool.cpp | 1 |
9 files changed, 29 insertions, 4 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index d484073..6b282e2 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -99,768 +99,772 @@ Addressee::~Addressee() | |||
99 | Addressee::Addressee( const Addressee &a ) | 99 | Addressee::Addressee( const Addressee &a ) |
100 | { | 100 | { |
101 | mData = a.mData; | 101 | mData = a.mData; |
102 | } | 102 | } |
103 | 103 | ||
104 | Addressee &Addressee::operator=( const Addressee &a ) | 104 | Addressee &Addressee::operator=( const Addressee &a ) |
105 | { | 105 | { |
106 | mData = a.mData; | 106 | mData = a.mData; |
107 | return (*this); | 107 | return (*this); |
108 | } | 108 | } |
109 | 109 | ||
110 | Addressee Addressee::copy() | 110 | Addressee Addressee::copy() |
111 | { | 111 | { |
112 | Addressee a; | 112 | Addressee a; |
113 | *(a.mData) = *mData; | 113 | *(a.mData) = *mData; |
114 | return a; | 114 | return a; |
115 | } | 115 | } |
116 | 116 | ||
117 | void Addressee::detach() | 117 | void Addressee::detach() |
118 | { | 118 | { |
119 | if ( mData.count() == 1 ) return; | 119 | if ( mData.count() == 1 ) return; |
120 | *this = copy(); | 120 | *this = copy(); |
121 | } | 121 | } |
122 | 122 | ||
123 | bool Addressee::operator==( const Addressee &a ) const | 123 | bool Addressee::operator==( const Addressee &a ) const |
124 | { | 124 | { |
125 | if ( uid() != a.uid() ) return false; | 125 | if ( uid() != a.uid() ) return false; |
126 | if ( mData->name != a.mData->name ) return false; | 126 | if ( mData->name != a.mData->name ) return false; |
127 | if ( mData->formattedName != a.mData->formattedName ) return false; | 127 | if ( mData->formattedName != a.mData->formattedName ) return false; |
128 | if ( mData->familyName != a.mData->familyName ) return false; | 128 | if ( mData->familyName != a.mData->familyName ) return false; |
129 | if ( mData->givenName != a.mData->givenName ) return false; | 129 | if ( mData->givenName != a.mData->givenName ) return false; |
130 | if ( mData->additionalName != a.mData->additionalName ) return false; | 130 | if ( mData->additionalName != a.mData->additionalName ) return false; |
131 | if ( mData->prefix != a.mData->prefix ) return false; | 131 | if ( mData->prefix != a.mData->prefix ) return false; |
132 | if ( mData->suffix != a.mData->suffix ) return false; | 132 | if ( mData->suffix != a.mData->suffix ) return false; |
133 | if ( mData->nickName != a.mData->nickName ) return false; | 133 | if ( mData->nickName != a.mData->nickName ) return false; |
134 | if ( mData->birthday != a.mData->birthday ) return false; | 134 | if ( mData->birthday != a.mData->birthday ) return false; |
135 | if ( mData->mailer != a.mData->mailer ) return false; | 135 | if ( mData->mailer != a.mData->mailer ) return false; |
136 | if ( mData->timeZone != a.mData->timeZone ) return false; | 136 | if ( mData->timeZone != a.mData->timeZone ) return false; |
137 | if ( mData->geo != a.mData->geo ) return false; | 137 | if ( mData->geo != a.mData->geo ) return false; |
138 | if ( mData->title != a.mData->title ) return false; | 138 | if ( mData->title != a.mData->title ) return false; |
139 | if ( mData->role != a.mData->role ) return false; | 139 | if ( mData->role != a.mData->role ) return false; |
140 | if ( mData->organization != a.mData->organization ) return false; | 140 | if ( mData->organization != a.mData->organization ) return false; |
141 | if ( mData->note != a.mData->note ) return false; | 141 | if ( mData->note != a.mData->note ) return false; |
142 | if ( mData->productId != a.mData->productId ) return false; | 142 | if ( mData->productId != a.mData->productId ) return false; |
143 | if ( mData->revision != a.mData->revision ) return false; | 143 | if ( mData->revision != a.mData->revision ) return false; |
144 | if ( mData->sortString != a.mData->sortString ) return false; | 144 | if ( mData->sortString != a.mData->sortString ) return false; |
145 | if ( mData->secrecy != a.mData->secrecy ) return false; | 145 | if ( mData->secrecy != a.mData->secrecy ) return false; |
146 | if ( mData->logo != a.mData->logo ) return false; | 146 | if ( mData->logo != a.mData->logo ) return false; |
147 | if ( mData->photo != a.mData->photo ) return false; | 147 | if ( mData->photo != a.mData->photo ) return false; |
148 | if ( mData->sound != a.mData->sound ) return false; | 148 | if ( mData->sound != a.mData->sound ) return false; |
149 | if ( mData->agent != a.mData->agent ) return false; | 149 | if ( mData->agent != a.mData->agent ) return false; |
150 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 150 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
151 | ( mData->url != a.mData->url ) ) return false; | 151 | ( mData->url != a.mData->url ) ) return false; |
152 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 152 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
153 | if ( mData->addresses != a.mData->addresses ) return false; | 153 | if ( mData->addresses != a.mData->addresses ) return false; |
154 | if ( mData->keys != a.mData->keys ) return false; | 154 | if ( mData->keys != a.mData->keys ) return false; |
155 | if ( mData->emails != a.mData->emails ) return false; | 155 | if ( mData->emails != a.mData->emails ) return false; |
156 | if ( mData->categories != a.mData->categories ) return false; | 156 | if ( mData->categories != a.mData->categories ) return false; |
157 | if ( mData->custom != a.mData->custom ) return false; | 157 | if ( mData->custom != a.mData->custom ) return false; |
158 | 158 | ||
159 | return true; | 159 | return true; |
160 | } | 160 | } |
161 | 161 | ||
162 | bool Addressee::operator!=( const Addressee &a ) const | 162 | bool Addressee::operator!=( const Addressee &a ) const |
163 | { | 163 | { |
164 | return !( a == *this ); | 164 | return !( a == *this ); |
165 | } | 165 | } |
166 | 166 | ||
167 | bool Addressee::isEmpty() const | 167 | bool Addressee::isEmpty() const |
168 | { | 168 | { |
169 | return mData->empty; | 169 | return mData->empty; |
170 | } | 170 | } |
171 | 171 | ||
172 | void Addressee::setUid( const QString &id ) | 172 | void Addressee::setUid( const QString &id ) |
173 | { | 173 | { |
174 | if ( id == mData->uid ) return; | 174 | if ( id == mData->uid ) return; |
175 | detach(); | 175 | detach(); |
176 | mData->empty = false; | 176 | mData->empty = false; |
177 | mData->uid = id; | 177 | mData->uid = id; |
178 | } | 178 | } |
179 | 179 | ||
180 | QString Addressee::uid() const | 180 | QString Addressee::uid() const |
181 | { | 181 | { |
182 | if ( mData->uid.isEmpty() ) | 182 | if ( mData->uid.isEmpty() ) |
183 | mData->uid = KApplication::randomString( 10 ); | 183 | mData->uid = KApplication::randomString( 10 ); |
184 | 184 | ||
185 | return mData->uid; | 185 | return mData->uid; |
186 | } | 186 | } |
187 | 187 | ||
188 | QString Addressee::uidLabel() | 188 | QString Addressee::uidLabel() |
189 | { | 189 | { |
190 | return i18n("Unique Identifier"); | 190 | return i18n("Unique Identifier"); |
191 | } | 191 | } |
192 | 192 | ||
193 | void Addressee::setName( const QString &name ) | 193 | void Addressee::setName( const QString &name ) |
194 | { | 194 | { |
195 | if ( name == mData->name ) return; | 195 | if ( name == mData->name ) return; |
196 | detach(); | 196 | detach(); |
197 | mData->empty = false; | 197 | mData->empty = false; |
198 | mData->name = name; | 198 | mData->name = name; |
199 | } | 199 | } |
200 | 200 | ||
201 | QString Addressee::name() const | 201 | QString Addressee::name() const |
202 | { | 202 | { |
203 | return mData->name; | 203 | return mData->name; |
204 | } | 204 | } |
205 | 205 | ||
206 | QString Addressee::nameLabel() | 206 | QString Addressee::nameLabel() |
207 | { | 207 | { |
208 | return i18n("Name"); | 208 | return i18n("Name"); |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | void Addressee::setFormattedName( const QString &formattedName ) | 212 | void Addressee::setFormattedName( const QString &formattedName ) |
213 | { | 213 | { |
214 | if ( formattedName == mData->formattedName ) return; | 214 | if ( formattedName == mData->formattedName ) return; |
215 | detach(); | 215 | detach(); |
216 | mData->empty = false; | 216 | mData->empty = false; |
217 | mData->formattedName = formattedName; | 217 | mData->formattedName = formattedName; |
218 | } | 218 | } |
219 | 219 | ||
220 | QString Addressee::formattedName() const | 220 | QString Addressee::formattedName() const |
221 | { | 221 | { |
222 | return mData->formattedName; | 222 | return mData->formattedName; |
223 | } | 223 | } |
224 | 224 | ||
225 | QString Addressee::formattedNameLabel() | 225 | QString Addressee::formattedNameLabel() |
226 | { | 226 | { |
227 | return i18n("Formatted Name"); | 227 | return i18n("Formatted Name"); |
228 | } | 228 | } |
229 | 229 | ||
230 | 230 | ||
231 | void Addressee::setFamilyName( const QString &familyName ) | 231 | void Addressee::setFamilyName( const QString &familyName ) |
232 | { | 232 | { |
233 | if ( familyName == mData->familyName ) return; | 233 | if ( familyName == mData->familyName ) return; |
234 | detach(); | 234 | detach(); |
235 | mData->empty = false; | 235 | mData->empty = false; |
236 | mData->familyName = familyName; | 236 | mData->familyName = familyName; |
237 | } | 237 | } |
238 | 238 | ||
239 | QString Addressee::familyName() const | 239 | QString Addressee::familyName() const |
240 | { | 240 | { |
241 | return mData->familyName; | 241 | return mData->familyName; |
242 | } | 242 | } |
243 | 243 | ||
244 | QString Addressee::familyNameLabel() | 244 | QString Addressee::familyNameLabel() |
245 | { | 245 | { |
246 | return i18n("Family Name"); | 246 | return i18n("Family Name"); |
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
250 | void Addressee::setGivenName( const QString &givenName ) | 250 | void Addressee::setGivenName( const QString &givenName ) |
251 | { | 251 | { |
252 | if ( givenName == mData->givenName ) return; | 252 | if ( givenName == mData->givenName ) return; |
253 | detach(); | 253 | detach(); |
254 | mData->empty = false; | 254 | mData->empty = false; |
255 | mData->givenName = givenName; | 255 | mData->givenName = givenName; |
256 | } | 256 | } |
257 | 257 | ||
258 | QString Addressee::givenName() const | 258 | QString Addressee::givenName() const |
259 | { | 259 | { |
260 | return mData->givenName; | 260 | return mData->givenName; |
261 | } | 261 | } |
262 | 262 | ||
263 | QString Addressee::givenNameLabel() | 263 | QString Addressee::givenNameLabel() |
264 | { | 264 | { |
265 | return i18n("Given Name"); | 265 | return i18n("Given Name"); |
266 | } | 266 | } |
267 | 267 | ||
268 | 268 | ||
269 | void Addressee::setAdditionalName( const QString &additionalName ) | 269 | void Addressee::setAdditionalName( const QString &additionalName ) |
270 | { | 270 | { |
271 | if ( additionalName == mData->additionalName ) return; | 271 | if ( additionalName == mData->additionalName ) return; |
272 | detach(); | 272 | detach(); |
273 | mData->empty = false; | 273 | mData->empty = false; |
274 | mData->additionalName = additionalName; | 274 | mData->additionalName = additionalName; |
275 | } | 275 | } |
276 | 276 | ||
277 | QString Addressee::additionalName() const | 277 | QString Addressee::additionalName() const |
278 | { | 278 | { |
279 | return mData->additionalName; | 279 | return mData->additionalName; |
280 | } | 280 | } |
281 | 281 | ||
282 | QString Addressee::additionalNameLabel() | 282 | QString Addressee::additionalNameLabel() |
283 | { | 283 | { |
284 | return i18n("Additional Names"); | 284 | return i18n("Additional Names"); |
285 | } | 285 | } |
286 | 286 | ||
287 | 287 | ||
288 | void Addressee::setPrefix( const QString &prefix ) | 288 | void Addressee::setPrefix( const QString &prefix ) |
289 | { | 289 | { |
290 | if ( prefix == mData->prefix ) return; | 290 | if ( prefix == mData->prefix ) return; |
291 | detach(); | 291 | detach(); |
292 | mData->empty = false; | 292 | mData->empty = false; |
293 | mData->prefix = prefix; | 293 | mData->prefix = prefix; |
294 | } | 294 | } |
295 | 295 | ||
296 | QString Addressee::prefix() const | 296 | QString Addressee::prefix() const |
297 | { | 297 | { |
298 | return mData->prefix; | 298 | return mData->prefix; |
299 | } | 299 | } |
300 | 300 | ||
301 | QString Addressee::prefixLabel() | 301 | QString Addressee::prefixLabel() |
302 | { | 302 | { |
303 | return i18n("Honorific Prefixes"); | 303 | return i18n("Honorific Prefixes"); |
304 | } | 304 | } |
305 | 305 | ||
306 | 306 | ||
307 | void Addressee::setSuffix( const QString &suffix ) | 307 | void Addressee::setSuffix( const QString &suffix ) |
308 | { | 308 | { |
309 | if ( suffix == mData->suffix ) return; | 309 | if ( suffix == mData->suffix ) return; |
310 | detach(); | 310 | detach(); |
311 | mData->empty = false; | 311 | mData->empty = false; |
312 | mData->suffix = suffix; | 312 | mData->suffix = suffix; |
313 | } | 313 | } |
314 | 314 | ||
315 | QString Addressee::suffix() const | 315 | QString Addressee::suffix() const |
316 | { | 316 | { |
317 | return mData->suffix; | 317 | return mData->suffix; |
318 | } | 318 | } |
319 | 319 | ||
320 | QString Addressee::suffixLabel() | 320 | QString Addressee::suffixLabel() |
321 | { | 321 | { |
322 | return i18n("Honorific Suffixes"); | 322 | return i18n("Honorific Suffixes"); |
323 | } | 323 | } |
324 | 324 | ||
325 | 325 | ||
326 | void Addressee::setNickName( const QString &nickName ) | 326 | void Addressee::setNickName( const QString &nickName ) |
327 | { | 327 | { |
328 | if ( nickName == mData->nickName ) return; | 328 | if ( nickName == mData->nickName ) return; |
329 | detach(); | 329 | detach(); |
330 | mData->empty = false; | 330 | mData->empty = false; |
331 | mData->nickName = nickName; | 331 | mData->nickName = nickName; |
332 | } | 332 | } |
333 | 333 | ||
334 | QString Addressee::nickName() const | 334 | QString Addressee::nickName() const |
335 | { | 335 | { |
336 | return mData->nickName; | 336 | return mData->nickName; |
337 | } | 337 | } |
338 | 338 | ||
339 | QString Addressee::nickNameLabel() | 339 | QString Addressee::nickNameLabel() |
340 | { | 340 | { |
341 | return i18n("Nick Name"); | 341 | return i18n("Nick Name"); |
342 | } | 342 | } |
343 | 343 | ||
344 | 344 | ||
345 | void Addressee::setBirthday( const QDateTime &birthday ) | 345 | void Addressee::setBirthday( const QDateTime &birthday ) |
346 | { | 346 | { |
347 | if ( birthday == mData->birthday ) return; | 347 | if ( birthday == mData->birthday ) return; |
348 | detach(); | 348 | detach(); |
349 | mData->empty = false; | 349 | mData->empty = false; |
350 | mData->birthday = birthday; | 350 | mData->birthday = birthday; |
351 | } | 351 | } |
352 | 352 | ||
353 | QDateTime Addressee::birthday() const | 353 | QDateTime Addressee::birthday() const |
354 | { | 354 | { |
355 | return mData->birthday; | 355 | return mData->birthday; |
356 | } | 356 | } |
357 | 357 | ||
358 | QString Addressee::birthdayLabel() | 358 | QString Addressee::birthdayLabel() |
359 | { | 359 | { |
360 | return i18n("Birthday"); | 360 | return i18n("Birthday"); |
361 | } | 361 | } |
362 | 362 | ||
363 | 363 | ||
364 | QString Addressee::homeAddressStreetLabel() | 364 | QString Addressee::homeAddressStreetLabel() |
365 | { | 365 | { |
366 | return i18n("Home Address Street"); | 366 | return i18n("Home Address Street"); |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | QString Addressee::homeAddressLocalityLabel() | 370 | QString Addressee::homeAddressLocalityLabel() |
371 | { | 371 | { |
372 | return i18n("Home Address Locality"); | 372 | return i18n("Home Address Locality"); |
373 | } | 373 | } |
374 | 374 | ||
375 | 375 | ||
376 | QString Addressee::homeAddressRegionLabel() | 376 | QString Addressee::homeAddressRegionLabel() |
377 | { | 377 | { |
378 | return i18n("Home Address Region"); | 378 | return i18n("Home Address Region"); |
379 | } | 379 | } |
380 | 380 | ||
381 | 381 | ||
382 | QString Addressee::homeAddressPostalCodeLabel() | 382 | QString Addressee::homeAddressPostalCodeLabel() |
383 | { | 383 | { |
384 | return i18n("Home Address Postal Code"); | 384 | return i18n("Home Address Postal Code"); |
385 | } | 385 | } |
386 | 386 | ||
387 | 387 | ||
388 | QString Addressee::homeAddressCountryLabel() | 388 | QString Addressee::homeAddressCountryLabel() |
389 | { | 389 | { |
390 | return i18n("Home Address Country"); | 390 | return i18n("Home Address Country"); |
391 | } | 391 | } |
392 | 392 | ||
393 | 393 | ||
394 | QString Addressee::homeAddressLabelLabel() | 394 | QString Addressee::homeAddressLabelLabel() |
395 | { | 395 | { |
396 | return i18n("Home Address Label"); | 396 | return i18n("Home Address Label"); |
397 | } | 397 | } |
398 | 398 | ||
399 | 399 | ||
400 | QString Addressee::businessAddressStreetLabel() | 400 | QString Addressee::businessAddressStreetLabel() |
401 | { | 401 | { |
402 | return i18n("Business Address Street"); | 402 | return i18n("Business Address Street"); |
403 | } | 403 | } |
404 | 404 | ||
405 | 405 | ||
406 | QString Addressee::businessAddressLocalityLabel() | 406 | QString Addressee::businessAddressLocalityLabel() |
407 | { | 407 | { |
408 | return i18n("Business Address Locality"); | 408 | return i18n("Business Address Locality"); |
409 | } | 409 | } |
410 | 410 | ||
411 | 411 | ||
412 | QString Addressee::businessAddressRegionLabel() | 412 | QString Addressee::businessAddressRegionLabel() |
413 | { | 413 | { |
414 | return i18n("Business Address Region"); | 414 | return i18n("Business Address Region"); |
415 | } | 415 | } |
416 | 416 | ||
417 | 417 | ||
418 | QString Addressee::businessAddressPostalCodeLabel() | 418 | QString Addressee::businessAddressPostalCodeLabel() |
419 | { | 419 | { |
420 | return i18n("Business Address Postal Code"); | 420 | return i18n("Business Address Postal Code"); |
421 | } | 421 | } |
422 | 422 | ||
423 | 423 | ||
424 | QString Addressee::businessAddressCountryLabel() | 424 | QString Addressee::businessAddressCountryLabel() |
425 | { | 425 | { |
426 | return i18n("Business Address Country"); | 426 | return i18n("Business Address Country"); |
427 | } | 427 | } |
428 | 428 | ||
429 | 429 | ||
430 | QString Addressee::businessAddressLabelLabel() | 430 | QString Addressee::businessAddressLabelLabel() |
431 | { | 431 | { |
432 | return i18n("Business Address Label"); | 432 | return i18n("Business Address Label"); |
433 | } | 433 | } |
434 | 434 | ||
435 | 435 | ||
436 | QString Addressee::homePhoneLabel() | 436 | QString Addressee::homePhoneLabel() |
437 | { | 437 | { |
438 | return i18n("Home Phone"); | 438 | return i18n("Home Phone"); |
439 | } | 439 | } |
440 | 440 | ||
441 | 441 | ||
442 | QString Addressee::businessPhoneLabel() | 442 | QString Addressee::businessPhoneLabel() |
443 | { | 443 | { |
444 | return i18n("Business Phone"); | 444 | return i18n("Business Phone"); |
445 | } | 445 | } |
446 | 446 | ||
447 | 447 | ||
448 | QString Addressee::mobilePhoneLabel() | 448 | QString Addressee::mobilePhoneLabel() |
449 | { | 449 | { |
450 | return i18n("Mobile Phone"); | 450 | return i18n("Mobile Phone"); |
451 | } | 451 | } |
452 | 452 | ||
453 | 453 | ||
454 | QString Addressee::homeFaxLabel() | 454 | QString Addressee::homeFaxLabel() |
455 | { | 455 | { |
456 | return i18n("Home Fax"); | 456 | return i18n("Home Fax"); |
457 | } | 457 | } |
458 | 458 | ||
459 | 459 | ||
460 | QString Addressee::businessFaxLabel() | 460 | QString Addressee::businessFaxLabel() |
461 | { | 461 | { |
462 | return i18n("Business Fax"); | 462 | return i18n("Business Fax"); |
463 | } | 463 | } |
464 | 464 | ||
465 | 465 | ||
466 | QString Addressee::carPhoneLabel() | 466 | QString Addressee::carPhoneLabel() |
467 | { | 467 | { |
468 | return i18n("Car Phone"); | 468 | return i18n("Car Phone"); |
469 | } | 469 | } |
470 | 470 | ||
471 | 471 | ||
472 | QString Addressee::isdnLabel() | 472 | QString Addressee::isdnLabel() |
473 | { | 473 | { |
474 | return i18n("ISDN"); | 474 | return i18n("ISDN"); |
475 | } | 475 | } |
476 | 476 | ||
477 | 477 | ||
478 | QString Addressee::pagerLabel() | 478 | QString Addressee::pagerLabel() |
479 | { | 479 | { |
480 | return i18n("Pager"); | 480 | return i18n("Pager"); |
481 | } | 481 | } |
482 | 482 | ||
483 | QString Addressee::sipLabel() | ||
484 | { | ||
485 | return i18n("SIP"); | ||
486 | } | ||
483 | 487 | ||
484 | QString Addressee::emailLabel() | 488 | QString Addressee::emailLabel() |
485 | { | 489 | { |
486 | return i18n("Email Address"); | 490 | return i18n("Email Address"); |
487 | } | 491 | } |
488 | 492 | ||
489 | 493 | ||
490 | void Addressee::setMailer( const QString &mailer ) | 494 | void Addressee::setMailer( const QString &mailer ) |
491 | { | 495 | { |
492 | if ( mailer == mData->mailer ) return; | 496 | if ( mailer == mData->mailer ) return; |
493 | detach(); | 497 | detach(); |
494 | mData->empty = false; | 498 | mData->empty = false; |
495 | mData->mailer = mailer; | 499 | mData->mailer = mailer; |
496 | } | 500 | } |
497 | 501 | ||
498 | QString Addressee::mailer() const | 502 | QString Addressee::mailer() const |
499 | { | 503 | { |
500 | return mData->mailer; | 504 | return mData->mailer; |
501 | } | 505 | } |
502 | 506 | ||
503 | QString Addressee::mailerLabel() | 507 | QString Addressee::mailerLabel() |
504 | { | 508 | { |
505 | return i18n("Mail Client"); | 509 | return i18n("Mail Client"); |
506 | } | 510 | } |
507 | 511 | ||
508 | 512 | ||
509 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 513 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
510 | { | 514 | { |
511 | if ( timeZone == mData->timeZone ) return; | 515 | if ( timeZone == mData->timeZone ) return; |
512 | detach(); | 516 | detach(); |
513 | mData->empty = false; | 517 | mData->empty = false; |
514 | mData->timeZone = timeZone; | 518 | mData->timeZone = timeZone; |
515 | } | 519 | } |
516 | 520 | ||
517 | TimeZone Addressee::timeZone() const | 521 | TimeZone Addressee::timeZone() const |
518 | { | 522 | { |
519 | return mData->timeZone; | 523 | return mData->timeZone; |
520 | } | 524 | } |
521 | 525 | ||
522 | QString Addressee::timeZoneLabel() | 526 | QString Addressee::timeZoneLabel() |
523 | { | 527 | { |
524 | return i18n("Time Zone"); | 528 | return i18n("Time Zone"); |
525 | } | 529 | } |
526 | 530 | ||
527 | 531 | ||
528 | void Addressee::setGeo( const Geo &geo ) | 532 | void Addressee::setGeo( const Geo &geo ) |
529 | { | 533 | { |
530 | if ( geo == mData->geo ) return; | 534 | if ( geo == mData->geo ) return; |
531 | detach(); | 535 | detach(); |
532 | mData->empty = false; | 536 | mData->empty = false; |
533 | mData->geo = geo; | 537 | mData->geo = geo; |
534 | } | 538 | } |
535 | 539 | ||
536 | Geo Addressee::geo() const | 540 | Geo Addressee::geo() const |
537 | { | 541 | { |
538 | return mData->geo; | 542 | return mData->geo; |
539 | } | 543 | } |
540 | 544 | ||
541 | QString Addressee::geoLabel() | 545 | QString Addressee::geoLabel() |
542 | { | 546 | { |
543 | return i18n("Geographic Position"); | 547 | return i18n("Geographic Position"); |
544 | } | 548 | } |
545 | 549 | ||
546 | 550 | ||
547 | void Addressee::setTitle( const QString &title ) | 551 | void Addressee::setTitle( const QString &title ) |
548 | { | 552 | { |
549 | if ( title == mData->title ) return; | 553 | if ( title == mData->title ) return; |
550 | detach(); | 554 | detach(); |
551 | mData->empty = false; | 555 | mData->empty = false; |
552 | mData->title = title; | 556 | mData->title = title; |
553 | } | 557 | } |
554 | 558 | ||
555 | QString Addressee::title() const | 559 | QString Addressee::title() const |
556 | { | 560 | { |
557 | return mData->title; | 561 | return mData->title; |
558 | } | 562 | } |
559 | 563 | ||
560 | QString Addressee::titleLabel() | 564 | QString Addressee::titleLabel() |
561 | { | 565 | { |
562 | return i18n("Title"); | 566 | return i18n("Title"); |
563 | } | 567 | } |
564 | 568 | ||
565 | 569 | ||
566 | void Addressee::setRole( const QString &role ) | 570 | void Addressee::setRole( const QString &role ) |
567 | { | 571 | { |
568 | if ( role == mData->role ) return; | 572 | if ( role == mData->role ) return; |
569 | detach(); | 573 | detach(); |
570 | mData->empty = false; | 574 | mData->empty = false; |
571 | mData->role = role; | 575 | mData->role = role; |
572 | } | 576 | } |
573 | 577 | ||
574 | QString Addressee::role() const | 578 | QString Addressee::role() const |
575 | { | 579 | { |
576 | return mData->role; | 580 | return mData->role; |
577 | } | 581 | } |
578 | 582 | ||
579 | QString Addressee::roleLabel() | 583 | QString Addressee::roleLabel() |
580 | { | 584 | { |
581 | return i18n("Role"); | 585 | return i18n("Role"); |
582 | } | 586 | } |
583 | 587 | ||
584 | 588 | ||
585 | void Addressee::setOrganization( const QString &organization ) | 589 | void Addressee::setOrganization( const QString &organization ) |
586 | { | 590 | { |
587 | if ( organization == mData->organization ) return; | 591 | if ( organization == mData->organization ) return; |
588 | detach(); | 592 | detach(); |
589 | mData->empty = false; | 593 | mData->empty = false; |
590 | mData->organization = organization; | 594 | mData->organization = organization; |
591 | } | 595 | } |
592 | 596 | ||
593 | QString Addressee::organization() const | 597 | QString Addressee::organization() const |
594 | { | 598 | { |
595 | return mData->organization; | 599 | return mData->organization; |
596 | } | 600 | } |
597 | 601 | ||
598 | QString Addressee::organizationLabel() | 602 | QString Addressee::organizationLabel() |
599 | { | 603 | { |
600 | return i18n("Organization"); | 604 | return i18n("Organization"); |
601 | } | 605 | } |
602 | 606 | ||
603 | 607 | ||
604 | void Addressee::setNote( const QString ¬e ) | 608 | void Addressee::setNote( const QString ¬e ) |
605 | { | 609 | { |
606 | if ( note == mData->note ) return; | 610 | if ( note == mData->note ) return; |
607 | detach(); | 611 | detach(); |
608 | mData->empty = false; | 612 | mData->empty = false; |
609 | mData->note = note; | 613 | mData->note = note; |
610 | } | 614 | } |
611 | 615 | ||
612 | QString Addressee::note() const | 616 | QString Addressee::note() const |
613 | { | 617 | { |
614 | return mData->note; | 618 | return mData->note; |
615 | } | 619 | } |
616 | 620 | ||
617 | QString Addressee::noteLabel() | 621 | QString Addressee::noteLabel() |
618 | { | 622 | { |
619 | return i18n("Note"); | 623 | return i18n("Note"); |
620 | } | 624 | } |
621 | 625 | ||
622 | 626 | ||
623 | void Addressee::setProductId( const QString &productId ) | 627 | void Addressee::setProductId( const QString &productId ) |
624 | { | 628 | { |
625 | if ( productId == mData->productId ) return; | 629 | if ( productId == mData->productId ) return; |
626 | detach(); | 630 | detach(); |
627 | mData->empty = false; | 631 | mData->empty = false; |
628 | mData->productId = productId; | 632 | mData->productId = productId; |
629 | } | 633 | } |
630 | 634 | ||
631 | QString Addressee::productId() const | 635 | QString Addressee::productId() const |
632 | { | 636 | { |
633 | return mData->productId; | 637 | return mData->productId; |
634 | } | 638 | } |
635 | 639 | ||
636 | QString Addressee::productIdLabel() | 640 | QString Addressee::productIdLabel() |
637 | { | 641 | { |
638 | return i18n("Product Identifier"); | 642 | return i18n("Product Identifier"); |
639 | } | 643 | } |
640 | 644 | ||
641 | 645 | ||
642 | void Addressee::setRevision( const QDateTime &revision ) | 646 | void Addressee::setRevision( const QDateTime &revision ) |
643 | { | 647 | { |
644 | if ( revision == mData->revision ) return; | 648 | if ( revision == mData->revision ) return; |
645 | detach(); | 649 | detach(); |
646 | mData->empty = false; | 650 | mData->empty = false; |
647 | mData->revision = revision; | 651 | mData->revision = revision; |
648 | } | 652 | } |
649 | 653 | ||
650 | QDateTime Addressee::revision() const | 654 | QDateTime Addressee::revision() const |
651 | { | 655 | { |
652 | return mData->revision; | 656 | return mData->revision; |
653 | } | 657 | } |
654 | 658 | ||
655 | QString Addressee::revisionLabel() | 659 | QString Addressee::revisionLabel() |
656 | { | 660 | { |
657 | return i18n("Revision Date"); | 661 | return i18n("Revision Date"); |
658 | } | 662 | } |
659 | 663 | ||
660 | 664 | ||
661 | void Addressee::setSortString( const QString &sortString ) | 665 | void Addressee::setSortString( const QString &sortString ) |
662 | { | 666 | { |
663 | if ( sortString == mData->sortString ) return; | 667 | if ( sortString == mData->sortString ) return; |
664 | detach(); | 668 | detach(); |
665 | mData->empty = false; | 669 | mData->empty = false; |
666 | mData->sortString = sortString; | 670 | mData->sortString = sortString; |
667 | } | 671 | } |
668 | 672 | ||
669 | QString Addressee::sortString() const | 673 | QString Addressee::sortString() const |
670 | { | 674 | { |
671 | return mData->sortString; | 675 | return mData->sortString; |
672 | } | 676 | } |
673 | 677 | ||
674 | QString Addressee::sortStringLabel() | 678 | QString Addressee::sortStringLabel() |
675 | { | 679 | { |
676 | return i18n("Sort String"); | 680 | return i18n("Sort String"); |
677 | } | 681 | } |
678 | 682 | ||
679 | 683 | ||
680 | void Addressee::setUrl( const KURL &url ) | 684 | void Addressee::setUrl( const KURL &url ) |
681 | { | 685 | { |
682 | if ( url == mData->url ) return; | 686 | if ( url == mData->url ) return; |
683 | detach(); | 687 | detach(); |
684 | mData->empty = false; | 688 | mData->empty = false; |
685 | mData->url = url; | 689 | mData->url = url; |
686 | } | 690 | } |
687 | 691 | ||
688 | KURL Addressee::url() const | 692 | KURL Addressee::url() const |
689 | { | 693 | { |
690 | return mData->url; | 694 | return mData->url; |
691 | } | 695 | } |
692 | 696 | ||
693 | QString Addressee::urlLabel() | 697 | QString Addressee::urlLabel() |
694 | { | 698 | { |
695 | return i18n("URL"); | 699 | return i18n("URL"); |
696 | } | 700 | } |
697 | 701 | ||
698 | 702 | ||
699 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 703 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
700 | { | 704 | { |
701 | if ( secrecy == mData->secrecy ) return; | 705 | if ( secrecy == mData->secrecy ) return; |
702 | detach(); | 706 | detach(); |
703 | mData->empty = false; | 707 | mData->empty = false; |
704 | mData->secrecy = secrecy; | 708 | mData->secrecy = secrecy; |
705 | } | 709 | } |
706 | 710 | ||
707 | Secrecy Addressee::secrecy() const | 711 | Secrecy Addressee::secrecy() const |
708 | { | 712 | { |
709 | return mData->secrecy; | 713 | return mData->secrecy; |
710 | } | 714 | } |
711 | 715 | ||
712 | QString Addressee::secrecyLabel() | 716 | QString Addressee::secrecyLabel() |
713 | { | 717 | { |
714 | return i18n("Security Class"); | 718 | return i18n("Security Class"); |
715 | } | 719 | } |
716 | 720 | ||
717 | 721 | ||
718 | void Addressee::setLogo( const Picture &logo ) | 722 | void Addressee::setLogo( const Picture &logo ) |
719 | { | 723 | { |
720 | if ( logo == mData->logo ) return; | 724 | if ( logo == mData->logo ) return; |
721 | detach(); | 725 | detach(); |
722 | mData->empty = false; | 726 | mData->empty = false; |
723 | mData->logo = logo; | 727 | mData->logo = logo; |
724 | } | 728 | } |
725 | 729 | ||
726 | Picture Addressee::logo() const | 730 | Picture Addressee::logo() const |
727 | { | 731 | { |
728 | return mData->logo; | 732 | return mData->logo; |
729 | } | 733 | } |
730 | 734 | ||
731 | QString Addressee::logoLabel() | 735 | QString Addressee::logoLabel() |
732 | { | 736 | { |
733 | return i18n("Logo"); | 737 | return i18n("Logo"); |
734 | } | 738 | } |
735 | 739 | ||
736 | 740 | ||
737 | void Addressee::setPhoto( const Picture &photo ) | 741 | void Addressee::setPhoto( const Picture &photo ) |
738 | { | 742 | { |
739 | if ( photo == mData->photo ) return; | 743 | if ( photo == mData->photo ) return; |
740 | detach(); | 744 | detach(); |
741 | mData->empty = false; | 745 | mData->empty = false; |
742 | mData->photo = photo; | 746 | mData->photo = photo; |
743 | } | 747 | } |
744 | 748 | ||
745 | Picture Addressee::photo() const | 749 | Picture Addressee::photo() const |
746 | { | 750 | { |
747 | return mData->photo; | 751 | return mData->photo; |
748 | } | 752 | } |
749 | 753 | ||
750 | QString Addressee::photoLabel() | 754 | QString Addressee::photoLabel() |
751 | { | 755 | { |
752 | return i18n("Photo"); | 756 | return i18n("Photo"); |
753 | } | 757 | } |
754 | 758 | ||
755 | 759 | ||
756 | void Addressee::setSound( const Sound &sound ) | 760 | void Addressee::setSound( const Sound &sound ) |
757 | { | 761 | { |
758 | if ( sound == mData->sound ) return; | 762 | if ( sound == mData->sound ) return; |
759 | detach(); | 763 | detach(); |
760 | mData->empty = false; | 764 | mData->empty = false; |
761 | mData->sound = sound; | 765 | mData->sound = sound; |
762 | } | 766 | } |
763 | 767 | ||
764 | Sound Addressee::sound() const | 768 | Sound Addressee::sound() const |
765 | { | 769 | { |
766 | return mData->sound; | 770 | return mData->sound; |
767 | } | 771 | } |
768 | 772 | ||
769 | QString Addressee::soundLabel() | 773 | QString Addressee::soundLabel() |
770 | { | 774 | { |
771 | return i18n("Sound"); | 775 | return i18n("Sound"); |
772 | } | 776 | } |
773 | 777 | ||
774 | 778 | ||
775 | void Addressee::setAgent( const Agent &agent ) | 779 | void Addressee::setAgent( const Agent &agent ) |
776 | { | 780 | { |
777 | if ( agent == mData->agent ) return; | 781 | if ( agent == mData->agent ) return; |
778 | detach(); | 782 | detach(); |
779 | mData->empty = false; | 783 | mData->empty = false; |
780 | mData->agent = agent; | 784 | mData->agent = agent; |
781 | } | 785 | } |
782 | 786 | ||
783 | Agent Addressee::agent() const | 787 | Agent Addressee::agent() const |
784 | { | 788 | { |
785 | return mData->agent; | 789 | return mData->agent; |
786 | } | 790 | } |
787 | 791 | ||
788 | QString Addressee::agentLabel() | 792 | QString Addressee::agentLabel() |
789 | { | 793 | { |
790 | return i18n("Agent"); | 794 | return i18n("Agent"); |
791 | } | 795 | } |
792 | 796 | ||
793 | 797 | ||
794 | 798 | ||
795 | void Addressee::setNameFromString( const QString &str ) | 799 | void Addressee::setNameFromString( const QString &str ) |
796 | { | 800 | { |
797 | setFormattedName( str ); | 801 | setFormattedName( str ); |
798 | setName( str ); | 802 | setName( str ); |
799 | 803 | ||
800 | QStringList titles; | 804 | QStringList titles; |
801 | titles += i18n( "Dr." ); | 805 | titles += i18n( "Dr." ); |
802 | titles += i18n( "Miss" ); | 806 | titles += i18n( "Miss" ); |
803 | titles += i18n( "Mr." ); | 807 | titles += i18n( "Mr." ); |
804 | titles += i18n( "Mrs." ); | 808 | titles += i18n( "Mrs." ); |
805 | titles += i18n( "Ms." ); | 809 | titles += i18n( "Ms." ); |
806 | titles += i18n( "Prof." ); | 810 | titles += i18n( "Prof." ); |
807 | 811 | ||
808 | QStringList suffixes; | 812 | QStringList suffixes; |
809 | suffixes += i18n( "I" ); | 813 | suffixes += i18n( "I" ); |
810 | suffixes += i18n( "II" ); | 814 | suffixes += i18n( "II" ); |
811 | suffixes += i18n( "III" ); | 815 | suffixes += i18n( "III" ); |
812 | suffixes += i18n( "Jr." ); | 816 | suffixes += i18n( "Jr." ); |
813 | suffixes += i18n( "Sr." ); | 817 | suffixes += i18n( "Sr." ); |
814 | 818 | ||
815 | QStringList prefixes; | 819 | QStringList prefixes; |
816 | prefixes += "van"; | 820 | prefixes += "van"; |
817 | prefixes += "von"; | 821 | prefixes += "von"; |
818 | prefixes += "de"; | 822 | prefixes += "de"; |
819 | 823 | ||
820 | //US KConfig config( "kabcrc" ); | 824 | //US KConfig config( "kabcrc" ); |
821 | KConfig config( locateLocal( "config", "kabcrc") ); | 825 | KConfig config( locateLocal( "config", "kabcrc") ); |
822 | config.setGroup( "General" ); | 826 | config.setGroup( "General" ); |
823 | titles += config.readListEntry( "Prefixes" ); | 827 | titles += config.readListEntry( "Prefixes" ); |
824 | titles.remove( "" ); | 828 | titles.remove( "" ); |
825 | prefixes += config.readListEntry( "Inclusions" ); | 829 | prefixes += config.readListEntry( "Inclusions" ); |
826 | prefixes.remove( "" ); | 830 | prefixes.remove( "" ); |
827 | suffixes += config.readListEntry( "Suffixes" ); | 831 | suffixes += config.readListEntry( "Suffixes" ); |
828 | suffixes.remove( "" ); | 832 | suffixes.remove( "" ); |
829 | 833 | ||
830 | // clear all name parts | 834 | // clear all name parts |
831 | setPrefix( "" ); | 835 | setPrefix( "" ); |
832 | setGivenName( "" ); | 836 | setGivenName( "" ); |
833 | setAdditionalName( "" ); | 837 | setAdditionalName( "" ); |
834 | setFamilyName( "" ); | 838 | setFamilyName( "" ); |
835 | setSuffix( "" ); | 839 | setSuffix( "" ); |
836 | 840 | ||
837 | if ( str.isEmpty() ) | 841 | if ( str.isEmpty() ) |
838 | return; | 842 | return; |
839 | 843 | ||
840 | int i = str.find(','); | 844 | int i = str.find(','); |
841 | if( i < 0 ) { | 845 | if( i < 0 ) { |
842 | QStringList parts = QStringList::split( " ", str ); | 846 | QStringList parts = QStringList::split( " ", str ); |
843 | int leftOffset = 0; | 847 | int leftOffset = 0; |
844 | int rightOffset = parts.count() - 1; | 848 | int rightOffset = parts.count() - 1; |
845 | 849 | ||
846 | QString suffix; | 850 | QString suffix; |
847 | while ( rightOffset >= 0 ) { | 851 | while ( rightOffset >= 0 ) { |
848 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 852 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
849 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 853 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
850 | rightOffset--; | 854 | rightOffset--; |
851 | } else | 855 | } else |
852 | break; | 856 | break; |
853 | } | 857 | } |
854 | setSuffix( suffix ); | 858 | setSuffix( suffix ); |
855 | 859 | ||
856 | if ( rightOffset < 0 ) | 860 | if ( rightOffset < 0 ) |
857 | return; | 861 | return; |
858 | 862 | ||
859 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 863 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
860 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 864 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
861 | rightOffset--; | 865 | rightOffset--; |
862 | } else | 866 | } else |
863 | setFamilyName( parts[ rightOffset ] ); | 867 | setFamilyName( parts[ rightOffset ] ); |
864 | 868 | ||
865 | QString prefix; | 869 | QString prefix; |
866 | while ( leftOffset < rightOffset ) { | 870 | while ( leftOffset < rightOffset ) { |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 393d1cc..27782f9 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -1,719 +1,724 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef KABC_ADDRESSEE_H | 29 | #ifndef KABC_ADDRESSEE_H |
30 | #define KABC_ADDRESSEE_H | 30 | #define KABC_ADDRESSEE_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | #include <ksharedptr.h> | 37 | #include <ksharedptr.h> |
38 | #include <kurl.h> | 38 | #include <kurl.h> |
39 | 39 | ||
40 | #include "address.h" | 40 | #include "address.h" |
41 | #include "agent.h" | 41 | #include "agent.h" |
42 | #include "geo.h" | 42 | #include "geo.h" |
43 | #include "key.h" | 43 | #include "key.h" |
44 | #include "phonenumber.h" | 44 | #include "phonenumber.h" |
45 | #include "picture.h" | 45 | #include "picture.h" |
46 | #include "secrecy.h" | 46 | #include "secrecy.h" |
47 | #include "sound.h" | 47 | #include "sound.h" |
48 | #include "timezone.h" | 48 | #include "timezone.h" |
49 | 49 | ||
50 | namespace KABC { | 50 | namespace KABC { |
51 | 51 | ||
52 | class Resource; | 52 | class Resource; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | @short address book entry | 55 | @short address book entry |
56 | 56 | ||
57 | This class represents an entry in the address book. | 57 | This class represents an entry in the address book. |
58 | 58 | ||
59 | The data of this class is implicitly shared. You can pass this class by value. | 59 | The data of this class is implicitly shared. You can pass this class by value. |
60 | 60 | ||
61 | If you need the name of a field for presenting it to the user you should use | 61 | If you need the name of a field for presenting it to the user you should use |
62 | the functions ending in Label(). They return a translated string which can be | 62 | the functions ending in Label(). They return a translated string which can be |
63 | used as label for the corresponding field. | 63 | used as label for the corresponding field. |
64 | 64 | ||
65 | About the name fields: | 65 | About the name fields: |
66 | 66 | ||
67 | givenName() is the first name and familyName() the last name. In some | 67 | givenName() is the first name and familyName() the last name. In some |
68 | countries the family name comes first, that's the reason for the | 68 | countries the family name comes first, that's the reason for the |
69 | naming. formattedName() is the full name with the correct formatting. | 69 | naming. formattedName() is the full name with the correct formatting. |
70 | It is used as an override, when the correct formatting can't be generated | 70 | It is used as an override, when the correct formatting can't be generated |
71 | from the other name fields automatically. | 71 | from the other name fields automatically. |
72 | 72 | ||
73 | realName() returns a fully formatted name(). It uses formattedName, if set, | 73 | realName() returns a fully formatted name(). It uses formattedName, if set, |
74 | otherwise it constucts the name from the name fields. As fallback, if | 74 | otherwise it constucts the name from the name fields. As fallback, if |
75 | nothing else is set it uses name(). | 75 | nothing else is set it uses name(). |
76 | 76 | ||
77 | name() is the NAME type of RFC2426. It can be used as internal name for the | 77 | name() is the NAME type of RFC2426. It can be used as internal name for the |
78 | data enty, but shouldn't be used for displaying the data to the user. | 78 | data enty, but shouldn't be used for displaying the data to the user. |
79 | */ | 79 | */ |
80 | class Addressee | 80 | class Addressee |
81 | { | 81 | { |
82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); | 82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); |
83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); | 83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); |
84 | 84 | ||
85 | public: | 85 | public: |
86 | typedef QValueList<Addressee> List; | 86 | typedef QValueList<Addressee> List; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | Construct an empty address book entry. | 89 | Construct an empty address book entry. |
90 | */ | 90 | */ |
91 | Addressee(); | 91 | Addressee(); |
92 | ~Addressee(); | 92 | ~Addressee(); |
93 | 93 | ||
94 | Addressee( const Addressee & ); | 94 | Addressee( const Addressee & ); |
95 | Addressee &operator=( const Addressee & ); | 95 | Addressee &operator=( const Addressee & ); |
96 | 96 | ||
97 | bool operator==( const Addressee & ) const; | 97 | bool operator==( const Addressee & ) const; |
98 | bool operator!=( const Addressee & ) const; | 98 | bool operator!=( const Addressee & ) const; |
99 | 99 | ||
100 | /** | 100 | /** |
101 | Return, if the address book entry is empty. | 101 | Return, if the address book entry is empty. |
102 | */ | 102 | */ |
103 | bool isEmpty() const; | 103 | bool isEmpty() const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Set unique identifier. | 106 | Set unique identifier. |
107 | */ | 107 | */ |
108 | void setUid( const QString &uid ); | 108 | void setUid( const QString &uid ); |
109 | /** | 109 | /** |
110 | Return unique identifier. | 110 | Return unique identifier. |
111 | */ | 111 | */ |
112 | QString uid() const; | 112 | QString uid() const; |
113 | /** | 113 | /** |
114 | Return translated label for uid field. | 114 | Return translated label for uid field. |
115 | */ | 115 | */ |
116 | static QString uidLabel(); | 116 | static QString uidLabel(); |
117 | 117 | ||
118 | /** | 118 | /** |
119 | Set name. | 119 | Set name. |
120 | */ | 120 | */ |
121 | void setName( const QString &name ); | 121 | void setName( const QString &name ); |
122 | /** | 122 | /** |
123 | Return name. | 123 | Return name. |
124 | */ | 124 | */ |
125 | QString name() const; | 125 | QString name() const; |
126 | /** | 126 | /** |
127 | Return translated label for name field. | 127 | Return translated label for name field. |
128 | */ | 128 | */ |
129 | static QString nameLabel(); | 129 | static QString nameLabel(); |
130 | 130 | ||
131 | /** | 131 | /** |
132 | Set formatted name. | 132 | Set formatted name. |
133 | */ | 133 | */ |
134 | void setFormattedName( const QString &formattedName ); | 134 | void setFormattedName( const QString &formattedName ); |
135 | /** | 135 | /** |
136 | Return formatted name. | 136 | Return formatted name. |
137 | */ | 137 | */ |
138 | QString formattedName() const; | 138 | QString formattedName() const; |
139 | /** | 139 | /** |
140 | Return translated label for formattedName field. | 140 | Return translated label for formattedName field. |
141 | */ | 141 | */ |
142 | static QString formattedNameLabel(); | 142 | static QString formattedNameLabel(); |
143 | 143 | ||
144 | /** | 144 | /** |
145 | Set family name. | 145 | Set family name. |
146 | */ | 146 | */ |
147 | void setFamilyName( const QString &familyName ); | 147 | void setFamilyName( const QString &familyName ); |
148 | /** | 148 | /** |
149 | Return family name. | 149 | Return family name. |
150 | */ | 150 | */ |
151 | QString familyName() const; | 151 | QString familyName() const; |
152 | /** | 152 | /** |
153 | Return translated label for familyName field. | 153 | Return translated label for familyName field. |
154 | */ | 154 | */ |
155 | static QString familyNameLabel(); | 155 | static QString familyNameLabel(); |
156 | 156 | ||
157 | /** | 157 | /** |
158 | Set given name. | 158 | Set given name. |
159 | */ | 159 | */ |
160 | void setGivenName( const QString &givenName ); | 160 | void setGivenName( const QString &givenName ); |
161 | /** | 161 | /** |
162 | Return given name. | 162 | Return given name. |
163 | */ | 163 | */ |
164 | QString givenName() const; | 164 | QString givenName() const; |
165 | /** | 165 | /** |
166 | Return translated label for givenName field. | 166 | Return translated label for givenName field. |
167 | */ | 167 | */ |
168 | static QString givenNameLabel(); | 168 | static QString givenNameLabel(); |
169 | 169 | ||
170 | /** | 170 | /** |
171 | Set additional names. | 171 | Set additional names. |
172 | */ | 172 | */ |
173 | void setAdditionalName( const QString &additionalName ); | 173 | void setAdditionalName( const QString &additionalName ); |
174 | /** | 174 | /** |
175 | Return additional names. | 175 | Return additional names. |
176 | */ | 176 | */ |
177 | QString additionalName() const; | 177 | QString additionalName() const; |
178 | /** | 178 | /** |
179 | Return translated label for additionalName field. | 179 | Return translated label for additionalName field. |
180 | */ | 180 | */ |
181 | static QString additionalNameLabel(); | 181 | static QString additionalNameLabel(); |
182 | 182 | ||
183 | /** | 183 | /** |
184 | Set honorific prefixes. | 184 | Set honorific prefixes. |
185 | */ | 185 | */ |
186 | void setPrefix( const QString &prefix ); | 186 | void setPrefix( const QString &prefix ); |
187 | /** | 187 | /** |
188 | Return honorific prefixes. | 188 | Return honorific prefixes. |
189 | */ | 189 | */ |
190 | QString prefix() const; | 190 | QString prefix() const; |
191 | /** | 191 | /** |
192 | Return translated label for prefix field. | 192 | Return translated label for prefix field. |
193 | */ | 193 | */ |
194 | static QString prefixLabel(); | 194 | static QString prefixLabel(); |
195 | 195 | ||
196 | /** | 196 | /** |
197 | Set honorific suffixes. | 197 | Set honorific suffixes. |
198 | */ | 198 | */ |
199 | void setSuffix( const QString &suffix ); | 199 | void setSuffix( const QString &suffix ); |
200 | /** | 200 | /** |
201 | Return honorific suffixes. | 201 | Return honorific suffixes. |
202 | */ | 202 | */ |
203 | QString suffix() const; | 203 | QString suffix() const; |
204 | /** | 204 | /** |
205 | Return translated label for suffix field. | 205 | Return translated label for suffix field. |
206 | */ | 206 | */ |
207 | static QString suffixLabel(); | 207 | static QString suffixLabel(); |
208 | 208 | ||
209 | /** | 209 | /** |
210 | Set nick name. | 210 | Set nick name. |
211 | */ | 211 | */ |
212 | void setNickName( const QString &nickName ); | 212 | void setNickName( const QString &nickName ); |
213 | /** | 213 | /** |
214 | Return nick name. | 214 | Return nick name. |
215 | */ | 215 | */ |
216 | QString nickName() const; | 216 | QString nickName() const; |
217 | /** | 217 | /** |
218 | Return translated label for nickName field. | 218 | Return translated label for nickName field. |
219 | */ | 219 | */ |
220 | static QString nickNameLabel(); | 220 | static QString nickNameLabel(); |
221 | 221 | ||
222 | /** | 222 | /** |
223 | Set birthday. | 223 | Set birthday. |
224 | */ | 224 | */ |
225 | void setBirthday( const QDateTime &birthday ); | 225 | void setBirthday( const QDateTime &birthday ); |
226 | /** | 226 | /** |
227 | Return birthday. | 227 | Return birthday. |
228 | */ | 228 | */ |
229 | QDateTime birthday() const; | 229 | QDateTime birthday() const; |
230 | /** | 230 | /** |
231 | Return translated label for birthday field. | 231 | Return translated label for birthday field. |
232 | */ | 232 | */ |
233 | static QString birthdayLabel(); | 233 | static QString birthdayLabel(); |
234 | 234 | ||
235 | /** | 235 | /** |
236 | Return translated label for homeAddressStreet field. | 236 | Return translated label for homeAddressStreet field. |
237 | */ | 237 | */ |
238 | static QString homeAddressStreetLabel(); | 238 | static QString homeAddressStreetLabel(); |
239 | 239 | ||
240 | /** | 240 | /** |
241 | Return translated label for homeAddressLocality field. | 241 | Return translated label for homeAddressLocality field. |
242 | */ | 242 | */ |
243 | static QString homeAddressLocalityLabel(); | 243 | static QString homeAddressLocalityLabel(); |
244 | 244 | ||
245 | /** | 245 | /** |
246 | Return translated label for homeAddressRegion field. | 246 | Return translated label for homeAddressRegion field. |
247 | */ | 247 | */ |
248 | static QString homeAddressRegionLabel(); | 248 | static QString homeAddressRegionLabel(); |
249 | 249 | ||
250 | /** | 250 | /** |
251 | Return translated label for homeAddressPostalCode field. | 251 | Return translated label for homeAddressPostalCode field. |
252 | */ | 252 | */ |
253 | static QString homeAddressPostalCodeLabel(); | 253 | static QString homeAddressPostalCodeLabel(); |
254 | 254 | ||
255 | /** | 255 | /** |
256 | Return translated label for homeAddressCountry field. | 256 | Return translated label for homeAddressCountry field. |
257 | */ | 257 | */ |
258 | static QString homeAddressCountryLabel(); | 258 | static QString homeAddressCountryLabel(); |
259 | 259 | ||
260 | /** | 260 | /** |
261 | Return translated label for homeAddressLabel field. | 261 | Return translated label for homeAddressLabel field. |
262 | */ | 262 | */ |
263 | static QString homeAddressLabelLabel(); | 263 | static QString homeAddressLabelLabel(); |
264 | 264 | ||
265 | /** | 265 | /** |
266 | Return translated label for businessAddressStreet field. | 266 | Return translated label for businessAddressStreet field. |
267 | */ | 267 | */ |
268 | static QString businessAddressStreetLabel(); | 268 | static QString businessAddressStreetLabel(); |
269 | 269 | ||
270 | /** | 270 | /** |
271 | Return translated label for businessAddressLocality field. | 271 | Return translated label for businessAddressLocality field. |
272 | */ | 272 | */ |
273 | static QString businessAddressLocalityLabel(); | 273 | static QString businessAddressLocalityLabel(); |
274 | 274 | ||
275 | /** | 275 | /** |
276 | Return translated label for businessAddressRegion field. | 276 | Return translated label for businessAddressRegion field. |
277 | */ | 277 | */ |
278 | static QString businessAddressRegionLabel(); | 278 | static QString businessAddressRegionLabel(); |
279 | 279 | ||
280 | /** | 280 | /** |
281 | Return translated label for businessAddressPostalCode field. | 281 | Return translated label for businessAddressPostalCode field. |
282 | */ | 282 | */ |
283 | static QString businessAddressPostalCodeLabel(); | 283 | static QString businessAddressPostalCodeLabel(); |
284 | 284 | ||
285 | /** | 285 | /** |
286 | Return translated label for businessAddressCountry field. | 286 | Return translated label for businessAddressCountry field. |
287 | */ | 287 | */ |
288 | static QString businessAddressCountryLabel(); | 288 | static QString businessAddressCountryLabel(); |
289 | 289 | ||
290 | /** | 290 | /** |
291 | Return translated label for businessAddressLabel field. | 291 | Return translated label for businessAddressLabel field. |
292 | */ | 292 | */ |
293 | static QString businessAddressLabelLabel(); | 293 | static QString businessAddressLabelLabel(); |
294 | 294 | ||
295 | /** | 295 | /** |
296 | Return translated label for homePhone field. | 296 | Return translated label for homePhone field. |
297 | */ | 297 | */ |
298 | static QString homePhoneLabel(); | 298 | static QString homePhoneLabel(); |
299 | 299 | ||
300 | /** | 300 | /** |
301 | Return translated label for businessPhone field. | 301 | Return translated label for businessPhone field. |
302 | */ | 302 | */ |
303 | static QString businessPhoneLabel(); | 303 | static QString businessPhoneLabel(); |
304 | 304 | ||
305 | /** | 305 | /** |
306 | Return translated label for mobilePhone field. | 306 | Return translated label for mobilePhone field. |
307 | */ | 307 | */ |
308 | static QString mobilePhoneLabel(); | 308 | static QString mobilePhoneLabel(); |
309 | 309 | ||
310 | /** | 310 | /** |
311 | Return translated label for homeFax field. | 311 | Return translated label for homeFax field. |
312 | */ | 312 | */ |
313 | static QString homeFaxLabel(); | 313 | static QString homeFaxLabel(); |
314 | 314 | ||
315 | /** | 315 | /** |
316 | Return translated label for businessFax field. | 316 | Return translated label for businessFax field. |
317 | */ | 317 | */ |
318 | static QString businessFaxLabel(); | 318 | static QString businessFaxLabel(); |
319 | 319 | ||
320 | /** | 320 | /** |
321 | Return translated label for carPhone field. | 321 | Return translated label for carPhone field. |
322 | */ | 322 | */ |
323 | static QString carPhoneLabel(); | 323 | static QString carPhoneLabel(); |
324 | 324 | ||
325 | /** | 325 | /** |
326 | Return translated label for isdn field. | 326 | Return translated label for isdn field. |
327 | */ | 327 | */ |
328 | static QString isdnLabel(); | 328 | static QString isdnLabel(); |
329 | 329 | ||
330 | /** | 330 | /** |
331 | Return translated label for pager field. | 331 | Return translated label for pager field. |
332 | */ | 332 | */ |
333 | static QString pagerLabel(); | 333 | static QString pagerLabel(); |
334 | 334 | ||
335 | /** | 335 | /** |
336 | Return translated label for sip field. | ||
337 | */ | ||
338 | static QString sipLabel(); | ||
339 | |||
340 | /** | ||
336 | Return translated label for email field. | 341 | Return translated label for email field. |
337 | */ | 342 | */ |
338 | static QString emailLabel(); | 343 | static QString emailLabel(); |
339 | 344 | ||
340 | /** | 345 | /** |
341 | Set mail client. | 346 | Set mail client. |
342 | */ | 347 | */ |
343 | void setMailer( const QString &mailer ); | 348 | void setMailer( const QString &mailer ); |
344 | /** | 349 | /** |
345 | Return mail client. | 350 | Return mail client. |
346 | */ | 351 | */ |
347 | QString mailer() const; | 352 | QString mailer() const; |
348 | /** | 353 | /** |
349 | Return translated label for mailer field. | 354 | Return translated label for mailer field. |
350 | */ | 355 | */ |
351 | static QString mailerLabel(); | 356 | static QString mailerLabel(); |
352 | 357 | ||
353 | /** | 358 | /** |
354 | Set time zone. | 359 | Set time zone. |
355 | */ | 360 | */ |
356 | void setTimeZone( const TimeZone &timeZone ); | 361 | void setTimeZone( const TimeZone &timeZone ); |
357 | /** | 362 | /** |
358 | Return time zone. | 363 | Return time zone. |
359 | */ | 364 | */ |
360 | TimeZone timeZone() const; | 365 | TimeZone timeZone() const; |
361 | /** | 366 | /** |
362 | Return translated label for timeZone field. | 367 | Return translated label for timeZone field. |
363 | */ | 368 | */ |
364 | static QString timeZoneLabel(); | 369 | static QString timeZoneLabel(); |
365 | 370 | ||
366 | /** | 371 | /** |
367 | Set geographic position. | 372 | Set geographic position. |
368 | */ | 373 | */ |
369 | void setGeo( const Geo &geo ); | 374 | void setGeo( const Geo &geo ); |
370 | /** | 375 | /** |
371 | Return geographic position. | 376 | Return geographic position. |
372 | */ | 377 | */ |
373 | Geo geo() const; | 378 | Geo geo() const; |
374 | /** | 379 | /** |
375 | Return translated label for geo field. | 380 | Return translated label for geo field. |
376 | */ | 381 | */ |
377 | static QString geoLabel(); | 382 | static QString geoLabel(); |
378 | 383 | ||
379 | /** | 384 | /** |
380 | Set title. | 385 | Set title. |
381 | */ | 386 | */ |
382 | void setTitle( const QString &title ); | 387 | void setTitle( const QString &title ); |
383 | /** | 388 | /** |
384 | Return title. | 389 | Return title. |
385 | */ | 390 | */ |
386 | QString title() const; | 391 | QString title() const; |
387 | /** | 392 | /** |
388 | Return translated label for title field. | 393 | Return translated label for title field. |
389 | */ | 394 | */ |
390 | static QString titleLabel(); | 395 | static QString titleLabel(); |
391 | 396 | ||
392 | /** | 397 | /** |
393 | Set role. | 398 | Set role. |
394 | */ | 399 | */ |
395 | void setRole( const QString &role ); | 400 | void setRole( const QString &role ); |
396 | /** | 401 | /** |
397 | Return role. | 402 | Return role. |
398 | */ | 403 | */ |
399 | QString role() const; | 404 | QString role() const; |
400 | /** | 405 | /** |
401 | Return translated label for role field. | 406 | Return translated label for role field. |
402 | */ | 407 | */ |
403 | static QString roleLabel(); | 408 | static QString roleLabel(); |
404 | 409 | ||
405 | /** | 410 | /** |
406 | Set organization. | 411 | Set organization. |
407 | */ | 412 | */ |
408 | void setOrganization( const QString &organization ); | 413 | void setOrganization( const QString &organization ); |
409 | /** | 414 | /** |
410 | Return organization. | 415 | Return organization. |
411 | */ | 416 | */ |
412 | QString organization() const; | 417 | QString organization() const; |
413 | /** | 418 | /** |
414 | Return translated label for organization field. | 419 | Return translated label for organization field. |
415 | */ | 420 | */ |
416 | static QString organizationLabel(); | 421 | static QString organizationLabel(); |
417 | 422 | ||
418 | /** | 423 | /** |
419 | Set note. | 424 | Set note. |
420 | */ | 425 | */ |
421 | void setNote( const QString ¬e ); | 426 | void setNote( const QString ¬e ); |
422 | /** | 427 | /** |
423 | Return note. | 428 | Return note. |
424 | */ | 429 | */ |
425 | QString note() const; | 430 | QString note() const; |
426 | /** | 431 | /** |
427 | Return translated label for note field. | 432 | Return translated label for note field. |
428 | */ | 433 | */ |
429 | static QString noteLabel(); | 434 | static QString noteLabel(); |
430 | 435 | ||
431 | /** | 436 | /** |
432 | Set product identifier. | 437 | Set product identifier. |
433 | */ | 438 | */ |
434 | void setProductId( const QString &productId ); | 439 | void setProductId( const QString &productId ); |
435 | /** | 440 | /** |
436 | Return product identifier. | 441 | Return product identifier. |
437 | */ | 442 | */ |
438 | QString productId() const; | 443 | QString productId() const; |
439 | /** | 444 | /** |
440 | Return translated label for productId field. | 445 | Return translated label for productId field. |
441 | */ | 446 | */ |
442 | static QString productIdLabel(); | 447 | static QString productIdLabel(); |
443 | 448 | ||
444 | /** | 449 | /** |
445 | Set revision date. | 450 | Set revision date. |
446 | */ | 451 | */ |
447 | void setRevision( const QDateTime &revision ); | 452 | void setRevision( const QDateTime &revision ); |
448 | /** | 453 | /** |
449 | Return revision date. | 454 | Return revision date. |
450 | */ | 455 | */ |
451 | QDateTime revision() const; | 456 | QDateTime revision() const; |
452 | /** | 457 | /** |
453 | Return translated label for revision field. | 458 | Return translated label for revision field. |
454 | */ | 459 | */ |
455 | static QString revisionLabel(); | 460 | static QString revisionLabel(); |
456 | 461 | ||
457 | /** | 462 | /** |
458 | Set sort string. | 463 | Set sort string. |
459 | */ | 464 | */ |
460 | void setSortString( const QString &sortString ); | 465 | void setSortString( const QString &sortString ); |
461 | /** | 466 | /** |
462 | Return sort string. | 467 | Return sort string. |
463 | */ | 468 | */ |
464 | QString sortString() const; | 469 | QString sortString() const; |
465 | /** | 470 | /** |
466 | Return translated label for sortString field. | 471 | Return translated label for sortString field. |
467 | */ | 472 | */ |
468 | static QString sortStringLabel(); | 473 | static QString sortStringLabel(); |
469 | 474 | ||
470 | /** | 475 | /** |
471 | Set URL. | 476 | Set URL. |
472 | */ | 477 | */ |
473 | void setUrl( const KURL &url ); | 478 | void setUrl( const KURL &url ); |
474 | /** | 479 | /** |
475 | Return URL. | 480 | Return URL. |
476 | */ | 481 | */ |
477 | KURL url() const; | 482 | KURL url() const; |
478 | /** | 483 | /** |
479 | Return translated label for url field. | 484 | Return translated label for url field. |
480 | */ | 485 | */ |
481 | static QString urlLabel(); | 486 | static QString urlLabel(); |
482 | 487 | ||
483 | /** | 488 | /** |
484 | Set security class. | 489 | Set security class. |
485 | */ | 490 | */ |
486 | void setSecrecy( const Secrecy &secrecy ); | 491 | void setSecrecy( const Secrecy &secrecy ); |
487 | /** | 492 | /** |
488 | Return security class. | 493 | Return security class. |
489 | */ | 494 | */ |
490 | Secrecy secrecy() const; | 495 | Secrecy secrecy() const; |
491 | /** | 496 | /** |
492 | Return translated label for secrecy field. | 497 | Return translated label for secrecy field. |
493 | */ | 498 | */ |
494 | static QString secrecyLabel(); | 499 | static QString secrecyLabel(); |
495 | 500 | ||
496 | /** | 501 | /** |
497 | Set logo. | 502 | Set logo. |
498 | */ | 503 | */ |
499 | void setLogo( const Picture &logo ); | 504 | void setLogo( const Picture &logo ); |
500 | /** | 505 | /** |
501 | Return logo. | 506 | Return logo. |
502 | */ | 507 | */ |
503 | Picture logo() const; | 508 | Picture logo() const; |
504 | /** | 509 | /** |
505 | Return translated label for logo field. | 510 | Return translated label for logo field. |
506 | */ | 511 | */ |
507 | static QString logoLabel(); | 512 | static QString logoLabel(); |
508 | 513 | ||
509 | /** | 514 | /** |
510 | Set photo. | 515 | Set photo. |
511 | */ | 516 | */ |
512 | void setPhoto( const Picture &photo ); | 517 | void setPhoto( const Picture &photo ); |
513 | /** | 518 | /** |
514 | Return photo. | 519 | Return photo. |
515 | */ | 520 | */ |
516 | Picture photo() const; | 521 | Picture photo() const; |
517 | /** | 522 | /** |
518 | Return translated label for photo field. | 523 | Return translated label for photo field. |
519 | */ | 524 | */ |
520 | static QString photoLabel(); | 525 | static QString photoLabel(); |
521 | 526 | ||
522 | /** | 527 | /** |
523 | Set sound. | 528 | Set sound. |
524 | */ | 529 | */ |
525 | void setSound( const Sound &sound ); | 530 | void setSound( const Sound &sound ); |
526 | /** | 531 | /** |
527 | Return sound. | 532 | Return sound. |
528 | */ | 533 | */ |
529 | Sound sound() const; | 534 | Sound sound() const; |
530 | /** | 535 | /** |
531 | Return translated label for sound field. | 536 | Return translated label for sound field. |
532 | */ | 537 | */ |
533 | static QString soundLabel(); | 538 | static QString soundLabel(); |
534 | 539 | ||
535 | /** | 540 | /** |
536 | Set agent. | 541 | Set agent. |
537 | */ | 542 | */ |
538 | void setAgent( const Agent &agent ); | 543 | void setAgent( const Agent &agent ); |
539 | /** | 544 | /** |
540 | Return agent. | 545 | Return agent. |
541 | */ | 546 | */ |
542 | Agent agent() const; | 547 | Agent agent() const; |
543 | /** | 548 | /** |
544 | Return translated label for agent field. | 549 | Return translated label for agent field. |
545 | */ | 550 | */ |
546 | static QString agentLabel(); | 551 | static QString agentLabel(); |
547 | 552 | ||
548 | /** | 553 | /** |
549 | Set name fields by parsing the given string and trying to associate the | 554 | Set name fields by parsing the given string and trying to associate the |
550 | parts of the string with according fields. This function should probably | 555 | parts of the string with according fields. This function should probably |
551 | be a bit more clever. | 556 | be a bit more clever. |
552 | */ | 557 | */ |
553 | void setNameFromString( const QString & ); | 558 | void setNameFromString( const QString & ); |
554 | 559 | ||
555 | /** | 560 | /** |
556 | Return the name of the addressee. This is calculated from all the name | 561 | Return the name of the addressee. This is calculated from all the name |
557 | fields. | 562 | fields. |
558 | */ | 563 | */ |
559 | QString realName() const; | 564 | QString realName() const; |
560 | 565 | ||
561 | /** | 566 | /** |
562 | Return the name that consists of all name parts. | 567 | Return the name that consists of all name parts. |
563 | */ | 568 | */ |
564 | QString assembledName() const; | 569 | QString assembledName() const; |
565 | 570 | ||
566 | /** | 571 | /** |
567 | Return email address including real name. | 572 | Return email address including real name. |
568 | 573 | ||
569 | @param email Email address to be used to construct the full email string. | 574 | @param email Email address to be used to construct the full email string. |
570 | If this is QString::null the preferred email address is used. | 575 | If this is QString::null the preferred email address is used. |
571 | */ | 576 | */ |
572 | QString fullEmail( const QString &email=QString::null ) const; | 577 | QString fullEmail( const QString &email=QString::null ) const; |
573 | 578 | ||
574 | /** | 579 | /** |
575 | Insert an email address. If the email address already exists in this | 580 | Insert an email address. If the email address already exists in this |
576 | addressee it is not duplicated. | 581 | addressee it is not duplicated. |
577 | 582 | ||
578 | @param email Email address | 583 | @param email Email address |
579 | @param preferred Set to true, if this is the preferred email address of | 584 | @param preferred Set to true, if this is the preferred email address of |
580 | the addressee. | 585 | the addressee. |
581 | */ | 586 | */ |
582 | void insertEmail( const QString &email, bool preferred=false ); | 587 | void insertEmail( const QString &email, bool preferred=false ); |
583 | 588 | ||
584 | /** | 589 | /** |
585 | Remove email address. If the email address doesn't exist, nothing happens. | 590 | Remove email address. If the email address doesn't exist, nothing happens. |
586 | */ | 591 | */ |
587 | void removeEmail( const QString &email ); | 592 | void removeEmail( const QString &email ); |
588 | 593 | ||
589 | /** | 594 | /** |
590 | Return preferred email address. This is the first email address or the | 595 | Return preferred email address. This is the first email address or the |
591 | last one added with @ref insertEmail() with a set preferred parameter. | 596 | last one added with @ref insertEmail() with a set preferred parameter. |
592 | */ | 597 | */ |
593 | QString preferredEmail() const; | 598 | QString preferredEmail() const; |
594 | 599 | ||
595 | /** | 600 | /** |
596 | Return list of all email addresses. | 601 | Return list of all email addresses. |
597 | */ | 602 | */ |
598 | QStringList emails() const; | 603 | QStringList emails() const; |
599 | 604 | ||
600 | /** | 605 | /** |
601 | Set the emails to @param. | 606 | Set the emails to @param. |
602 | The first email address gets the preferred one! | 607 | The first email address gets the preferred one! |
603 | @param list The list of email addresses. | 608 | @param list The list of email addresses. |
604 | */ | 609 | */ |
605 | void setEmails( const QStringList& list); | 610 | void setEmails( const QStringList& list); |
606 | 611 | ||
607 | /** | 612 | /** |
608 | Insert a phone number. If a phone number with the same id already exists | 613 | Insert a phone number. If a phone number with the same id already exists |
609 | in this addressee it is not duplicated. | 614 | in this addressee it is not duplicated. |
610 | */ | 615 | */ |
611 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); | 616 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); |
612 | 617 | ||
613 | /** | 618 | /** |
614 | Remove phone number. If no phone number with the given id exists for this | 619 | Remove phone number. If no phone number with the given id exists for this |
615 | addresse nothing happens. | 620 | addresse nothing happens. |
616 | */ | 621 | */ |
617 | void removePhoneNumber( const PhoneNumber &phoneNumber ); | 622 | void removePhoneNumber( const PhoneNumber &phoneNumber ); |
618 | 623 | ||
619 | /** | 624 | /** |
620 | Return phone number, which matches the given type. | 625 | Return phone number, which matches the given type. |
621 | */ | 626 | */ |
622 | PhoneNumber phoneNumber( int type ) const; | 627 | PhoneNumber phoneNumber( int type ) const; |
623 | 628 | ||
624 | /** | 629 | /** |
625 | Return list of all phone numbers. | 630 | Return list of all phone numbers. |
626 | */ | 631 | */ |
627 | PhoneNumber::List phoneNumbers() const; | 632 | PhoneNumber::List phoneNumbers() const; |
628 | 633 | ||
629 | /** | 634 | /** |
630 | Return list of phone numbers with a special type. | 635 | Return list of phone numbers with a special type. |
631 | */ | 636 | */ |
632 | PhoneNumber::List phoneNumbers( int type ) const; | 637 | PhoneNumber::List phoneNumbers( int type ) const; |
633 | 638 | ||
634 | /** | 639 | /** |
635 | Return phone number with the given id. | 640 | Return phone number with the given id. |
636 | */ | 641 | */ |
637 | PhoneNumber findPhoneNumber( const QString &id ) const; | 642 | PhoneNumber findPhoneNumber( const QString &id ) const; |
638 | 643 | ||
639 | /** | 644 | /** |
640 | Insert a key. If a key with the same id already exists | 645 | Insert a key. If a key with the same id already exists |
641 | in this addressee it is not duplicated. | 646 | in this addressee it is not duplicated. |
642 | */ | 647 | */ |
643 | void insertKey( const Key &key ); | 648 | void insertKey( const Key &key ); |
644 | 649 | ||
645 | /** | 650 | /** |
646 | Remove a key. If no key with the given id exists for this | 651 | Remove a key. If no key with the given id exists for this |
647 | addresse nothing happens. | 652 | addresse nothing happens. |
648 | */ | 653 | */ |
649 | void removeKey( const Key &key ); | 654 | void removeKey( const Key &key ); |
650 | 655 | ||
651 | /** | 656 | /** |
652 | Return key, which matches the given type. | 657 | Return key, which matches the given type. |
653 | If @p type == Key::Custom you can specify a string | 658 | If @p type == Key::Custom you can specify a string |
654 | that should match. If you leave the string empty, the first | 659 | that should match. If you leave the string empty, the first |
655 | key with a custom value is returned. | 660 | key with a custom value is returned. |
656 | */ | 661 | */ |
657 | Key key( int type, QString customTypeString = QString::null ) const; | 662 | Key key( int type, QString customTypeString = QString::null ) const; |
658 | 663 | ||
659 | /** | 664 | /** |
660 | Return list of all keys. | 665 | Return list of all keys. |
661 | */ | 666 | */ |
662 | Key::List keys() const; | 667 | Key::List keys() const; |
663 | 668 | ||
664 | /** | 669 | /** |
665 | Set the list of keys | 670 | Set the list of keys |
666 | @param keys The keys to be set. | 671 | @param keys The keys to be set. |
667 | */ | 672 | */ |
668 | void setKeys( const Key::List& keys); | 673 | void setKeys( const Key::List& keys); |
669 | 674 | ||
670 | /** | 675 | /** |
671 | Return list of keys with a special type. | 676 | Return list of keys with a special type. |
672 | If @p type == Key::Custom you can specify a string | 677 | If @p type == Key::Custom you can specify a string |
673 | that should match. If you leave the string empty, all custom | 678 | that should match. If you leave the string empty, all custom |
674 | keys will be returned. | 679 | keys will be returned. |
675 | */ | 680 | */ |
676 | Key::List keys( int type, QString customTypeString = QString::null ) const; | 681 | Key::List keys( int type, QString customTypeString = QString::null ) const; |
677 | 682 | ||
678 | /** | 683 | /** |
679 | Return key with the given id. | 684 | Return key with the given id. |
680 | */ | 685 | */ |
681 | Key findKey( const QString &id ) const; | 686 | Key findKey( const QString &id ) const; |
682 | 687 | ||
683 | /** | 688 | /** |
684 | Insert an address. If an address with the same id already exists | 689 | Insert an address. If an address with the same id already exists |
685 | in this addressee it is not duplicated. | 690 | in this addressee it is not duplicated. |
686 | */ | 691 | */ |
687 | void insertAddress( const Address &address ); | 692 | void insertAddress( const Address &address ); |
688 | 693 | ||
689 | /** | 694 | /** |
690 | Remove address. If no address with the given id exists for this | 695 | Remove address. If no address with the given id exists for this |
691 | addresse nothing happens. | 696 | addresse nothing happens. |
692 | */ | 697 | */ |
693 | void removeAddress( const Address &address ); | 698 | void removeAddress( const Address &address ); |
694 | 699 | ||
695 | /** | 700 | /** |
696 | Return address, which matches the given type. | 701 | Return address, which matches the given type. |
697 | */ | 702 | */ |
698 | Address address( int type ) const; | 703 | Address address( int type ) const; |
699 | 704 | ||
700 | /** | 705 | /** |
701 | Return list of all addresses. | 706 | Return list of all addresses. |
702 | */ | 707 | */ |
703 | Address::List addresses() const; | 708 | Address::List addresses() const; |
704 | 709 | ||
705 | /** | 710 | /** |
706 | Return list of addresses with a special type. | 711 | Return list of addresses with a special type. |
707 | */ | 712 | */ |
708 | Address::List addresses( int type ) const; | 713 | Address::List addresses( int type ) const; |
709 | 714 | ||
710 | /** | 715 | /** |
711 | Return address with the given id. | 716 | Return address with the given id. |
712 | */ | 717 | */ |
713 | Address findAddress( const QString &id ) const; | 718 | Address findAddress( const QString &id ) const; |
714 | 719 | ||
715 | /** | 720 | /** |
716 | Insert category. If the category already exists it is not duplicated. | 721 | Insert category. If the category already exists it is not duplicated. |
717 | */ | 722 | */ |
718 | void insertCategory( const QString & ); | 723 | void insertCategory( const QString & ); |
719 | 724 | ||
diff --git a/kabc/field.cpp b/kabc/field.cpp index e27970e..d95cd19 100644 --- a/kabc/field.cpp +++ b/kabc/field.cpp | |||
@@ -1,566 +1,572 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <klocale.h> | 29 | #include <klocale.h> |
30 | #include <kconfig.h> | 30 | #include <kconfig.h> |
31 | #include <kconfigbase.h> | 31 | #include <kconfigbase.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | 33 | ||
34 | #include "field.h" | 34 | #include "field.h" |
35 | #include "resource.h" | 35 | #include "resource.h" |
36 | 36 | ||
37 | using namespace KABC; | 37 | using namespace KABC; |
38 | 38 | ||
39 | class Field::FieldImpl | 39 | class Field::FieldImpl |
40 | { | 40 | { |
41 | public: | 41 | public: |
42 | FieldImpl( int fieldId, int category = 0, | 42 | FieldImpl( int fieldId, int category = 0, |
43 | const QString &label = QString::null, | 43 | const QString &label = QString::null, |
44 | const QString &key = QString::null, | 44 | const QString &key = QString::null, |
45 | const QString &app = QString::null ) | 45 | const QString &app = QString::null ) |
46 | : mFieldId( fieldId ), mCategory( category ), mLabel( label ), | 46 | : mFieldId( fieldId ), mCategory( category ), mLabel( label ), |
47 | mKey( key ), mApp( app ) {} | 47 | mKey( key ), mApp( app ) {} |
48 | 48 | ||
49 | enum FieldId | 49 | enum FieldId |
50 | { | 50 | { |
51 | CustomField, | 51 | CustomField, |
52 | FormattedName, | 52 | FormattedName, |
53 | FamilyName, | 53 | FamilyName, |
54 | GivenName, | 54 | GivenName, |
55 | AdditionalName, | 55 | AdditionalName, |
56 | Prefix, | 56 | Prefix, |
57 | Suffix, | 57 | Suffix, |
58 | NickName, | 58 | NickName, |
59 | Birthday, | 59 | Birthday, |
60 | HomeAddressStreet, | 60 | HomeAddressStreet, |
61 | HomeAddressLocality, | 61 | HomeAddressLocality, |
62 | HomeAddressRegion, | 62 | HomeAddressRegion, |
63 | HomeAddressPostalCode, | 63 | HomeAddressPostalCode, |
64 | HomeAddressCountry, | 64 | HomeAddressCountry, |
65 | HomeAddressLabel, | 65 | HomeAddressLabel, |
66 | BusinessAddressStreet, | 66 | BusinessAddressStreet, |
67 | BusinessAddressLocality, | 67 | BusinessAddressLocality, |
68 | BusinessAddressRegion, | 68 | BusinessAddressRegion, |
69 | BusinessAddressPostalCode, | 69 | BusinessAddressPostalCode, |
70 | BusinessAddressCountry, | 70 | BusinessAddressCountry, |
71 | BusinessAddressLabel, | 71 | BusinessAddressLabel, |
72 | HomePhone, | 72 | HomePhone, |
73 | BusinessPhone, | 73 | BusinessPhone, |
74 | MobilePhone, | 74 | MobilePhone, |
75 | HomeFax, | 75 | HomeFax, |
76 | BusinessFax, | 76 | BusinessFax, |
77 | CarPhone, | 77 | CarPhone, |
78 | Isdn, | 78 | Isdn, |
79 | Pager, | 79 | Pager, |
80 | Email, | 80 | Email, |
81 | Mailer, | 81 | Mailer, |
82 | Title, | 82 | Title, |
83 | Role, | 83 | Role, |
84 | Organization, | 84 | Organization, |
85 | Note, | 85 | Note, |
86 | Url, | 86 | Url, |
87 | Resource | 87 | Resource, |
88 | Sip | ||
88 | }; | 89 | }; |
89 | 90 | ||
90 | int fieldId() { return mFieldId; } | 91 | int fieldId() { return mFieldId; } |
91 | int category() { return mCategory; } | 92 | int category() { return mCategory; } |
92 | 93 | ||
93 | QString label() { return mLabel; } | 94 | QString label() { return mLabel; } |
94 | QString key() { return mKey; } | 95 | QString key() { return mKey; } |
95 | QString app() { return mApp; } | 96 | QString app() { return mApp; } |
96 | 97 | ||
97 | private: | 98 | private: |
98 | int mFieldId; | 99 | int mFieldId; |
99 | int mCategory; | 100 | int mCategory; |
100 | 101 | ||
101 | QString mLabel; | 102 | QString mLabel; |
102 | QString mKey; | 103 | QString mKey; |
103 | QString mApp; | 104 | QString mApp; |
104 | }; | 105 | }; |
105 | 106 | ||
106 | 107 | ||
107 | Field::List Field::mAllFields; | 108 | Field::List Field::mAllFields; |
108 | Field::List Field::mDefaultFields; | 109 | Field::List Field::mDefaultFields; |
109 | Field::List Field::mCustomFields; | 110 | Field::List Field::mCustomFields; |
110 | 111 | ||
111 | 112 | ||
112 | Field::Field( FieldImpl *impl ) | 113 | Field::Field( FieldImpl *impl ) |
113 | { | 114 | { |
114 | mImpl = impl; | 115 | mImpl = impl; |
115 | } | 116 | } |
116 | 117 | ||
117 | Field::~Field() | 118 | Field::~Field() |
118 | { | 119 | { |
119 | delete mImpl; | 120 | delete mImpl; |
120 | } | 121 | } |
121 | 122 | ||
122 | QString Field::label() | 123 | QString Field::label() |
123 | { | 124 | { |
124 | switch ( mImpl->fieldId() ) { | 125 | switch ( mImpl->fieldId() ) { |
125 | case FieldImpl::FormattedName: | 126 | case FieldImpl::FormattedName: |
126 | return Addressee::formattedNameLabel(); | 127 | return Addressee::formattedNameLabel(); |
127 | case FieldImpl::FamilyName: | 128 | case FieldImpl::FamilyName: |
128 | return Addressee::familyNameLabel(); | 129 | return Addressee::familyNameLabel(); |
129 | case FieldImpl::GivenName: | 130 | case FieldImpl::GivenName: |
130 | return Addressee::givenNameLabel(); | 131 | return Addressee::givenNameLabel(); |
131 | case FieldImpl::AdditionalName: | 132 | case FieldImpl::AdditionalName: |
132 | return Addressee::additionalNameLabel(); | 133 | return Addressee::additionalNameLabel(); |
133 | case FieldImpl::Prefix: | 134 | case FieldImpl::Prefix: |
134 | return Addressee::prefixLabel(); | 135 | return Addressee::prefixLabel(); |
135 | case FieldImpl::Suffix: | 136 | case FieldImpl::Suffix: |
136 | return Addressee::suffixLabel(); | 137 | return Addressee::suffixLabel(); |
137 | case FieldImpl::NickName: | 138 | case FieldImpl::NickName: |
138 | return Addressee::nickNameLabel(); | 139 | return Addressee::nickNameLabel(); |
139 | case FieldImpl::Birthday: | 140 | case FieldImpl::Birthday: |
140 | return Addressee::birthdayLabel(); | 141 | return Addressee::birthdayLabel(); |
141 | case FieldImpl::HomeAddressStreet: | 142 | case FieldImpl::HomeAddressStreet: |
142 | return Addressee::homeAddressStreetLabel(); | 143 | return Addressee::homeAddressStreetLabel(); |
143 | case FieldImpl::HomeAddressLocality: | 144 | case FieldImpl::HomeAddressLocality: |
144 | return Addressee::homeAddressLocalityLabel(); | 145 | return Addressee::homeAddressLocalityLabel(); |
145 | case FieldImpl::HomeAddressRegion: | 146 | case FieldImpl::HomeAddressRegion: |
146 | return Addressee::homeAddressRegionLabel(); | 147 | return Addressee::homeAddressRegionLabel(); |
147 | case FieldImpl::HomeAddressPostalCode: | 148 | case FieldImpl::HomeAddressPostalCode: |
148 | return Addressee::homeAddressPostalCodeLabel(); | 149 | return Addressee::homeAddressPostalCodeLabel(); |
149 | case FieldImpl::HomeAddressCountry: | 150 | case FieldImpl::HomeAddressCountry: |
150 | return Addressee::homeAddressCountryLabel(); | 151 | return Addressee::homeAddressCountryLabel(); |
151 | case FieldImpl::HomeAddressLabel: | 152 | case FieldImpl::HomeAddressLabel: |
152 | return Addressee::homeAddressLabelLabel(); | 153 | return Addressee::homeAddressLabelLabel(); |
153 | case FieldImpl::BusinessAddressStreet: | 154 | case FieldImpl::BusinessAddressStreet: |
154 | return Addressee::businessAddressStreetLabel(); | 155 | return Addressee::businessAddressStreetLabel(); |
155 | case FieldImpl::BusinessAddressLocality: | 156 | case FieldImpl::BusinessAddressLocality: |
156 | return Addressee::businessAddressLocalityLabel(); | 157 | return Addressee::businessAddressLocalityLabel(); |
157 | case FieldImpl::BusinessAddressRegion: | 158 | case FieldImpl::BusinessAddressRegion: |
158 | return Addressee::businessAddressRegionLabel(); | 159 | return Addressee::businessAddressRegionLabel(); |
159 | case FieldImpl::BusinessAddressPostalCode: | 160 | case FieldImpl::BusinessAddressPostalCode: |
160 | return Addressee::businessAddressPostalCodeLabel(); | 161 | return Addressee::businessAddressPostalCodeLabel(); |
161 | case FieldImpl::BusinessAddressCountry: | 162 | case FieldImpl::BusinessAddressCountry: |
162 | return Addressee::businessAddressCountryLabel(); | 163 | return Addressee::businessAddressCountryLabel(); |
163 | case FieldImpl::BusinessAddressLabel: | 164 | case FieldImpl::BusinessAddressLabel: |
164 | return Addressee::businessAddressLabelLabel(); | 165 | return Addressee::businessAddressLabelLabel(); |
165 | case FieldImpl::HomePhone: | 166 | case FieldImpl::HomePhone: |
166 | return Addressee::homePhoneLabel(); | 167 | return Addressee::homePhoneLabel(); |
167 | case FieldImpl::BusinessPhone: | 168 | case FieldImpl::BusinessPhone: |
168 | return Addressee::businessPhoneLabel(); | 169 | return Addressee::businessPhoneLabel(); |
169 | case FieldImpl::MobilePhone: | 170 | case FieldImpl::MobilePhone: |
170 | return Addressee::mobilePhoneLabel(); | 171 | return Addressee::mobilePhoneLabel(); |
171 | case FieldImpl::HomeFax: | 172 | case FieldImpl::HomeFax: |
172 | return Addressee::homeFaxLabel(); | 173 | return Addressee::homeFaxLabel(); |
173 | case FieldImpl::BusinessFax: | 174 | case FieldImpl::BusinessFax: |
174 | return Addressee::businessFaxLabel(); | 175 | return Addressee::businessFaxLabel(); |
175 | case FieldImpl::CarPhone: | 176 | case FieldImpl::CarPhone: |
176 | return Addressee::carPhoneLabel(); | 177 | return Addressee::carPhoneLabel(); |
177 | case FieldImpl::Isdn: | 178 | case FieldImpl::Isdn: |
178 | return Addressee::isdnLabel(); | 179 | return Addressee::isdnLabel(); |
179 | case FieldImpl::Pager: | 180 | case FieldImpl::Pager: |
180 | return Addressee::pagerLabel(); | 181 | return Addressee::pagerLabel(); |
181 | case FieldImpl::Email: | 182 | case FieldImpl::Email: |
182 | return Addressee::emailLabel(); | 183 | return Addressee::emailLabel(); |
183 | case FieldImpl::Mailer: | 184 | case FieldImpl::Mailer: |
184 | return Addressee::mailerLabel(); | 185 | return Addressee::mailerLabel(); |
185 | case FieldImpl::Title: | 186 | case FieldImpl::Title: |
186 | return Addressee::titleLabel(); | 187 | return Addressee::titleLabel(); |
187 | case FieldImpl::Role: | 188 | case FieldImpl::Role: |
188 | return Addressee::roleLabel(); | 189 | return Addressee::roleLabel(); |
189 | case FieldImpl::Organization: | 190 | case FieldImpl::Organization: |
190 | return Addressee::organizationLabel(); | 191 | return Addressee::organizationLabel(); |
191 | case FieldImpl::Note: | 192 | case FieldImpl::Note: |
192 | return Addressee::noteLabel(); | 193 | return Addressee::noteLabel(); |
193 | case FieldImpl::Url: | 194 | case FieldImpl::Url: |
194 | return Addressee::urlLabel(); | 195 | return Addressee::urlLabel(); |
195 | case FieldImpl::Resource: | 196 | case FieldImpl::Resource: |
196 | return Addressee::resourceLabel(); | 197 | return Addressee::resourceLabel(); |
198 | case FieldImpl::Sip: | ||
199 | return Addressee::sipLabel(); | ||
197 | case FieldImpl::CustomField: | 200 | case FieldImpl::CustomField: |
198 | return mImpl->label(); | 201 | return mImpl->label(); |
199 | default: | 202 | default: |
200 | return i18n("Unknown Field"); | 203 | return i18n("Unknown Field"); |
201 | } | 204 | } |
202 | } | 205 | } |
203 | 206 | ||
204 | int Field::category() | 207 | int Field::category() |
205 | { | 208 | { |
206 | return mImpl->category(); | 209 | return mImpl->category(); |
207 | } | 210 | } |
208 | 211 | ||
209 | QString Field::categoryLabel( int category ) | 212 | QString Field::categoryLabel( int category ) |
210 | { | 213 | { |
211 | switch ( category ) { | 214 | switch ( category ) { |
212 | case All: | 215 | case All: |
213 | return i18n("All"); | 216 | return i18n("All"); |
214 | case Frequent: | 217 | case Frequent: |
215 | return i18n("Frequent"); | 218 | return i18n("Frequent"); |
216 | case Address: | 219 | case Address: |
217 | return i18n("Address"); | 220 | return i18n("Address"); |
218 | case Email: | 221 | case Email: |
219 | return i18n("Email"); | 222 | return i18n("Email"); |
220 | case Personal: | 223 | case Personal: |
221 | return i18n("Personal"); | 224 | return i18n("Personal"); |
222 | case Organization: | 225 | case Organization: |
223 | return i18n("Organization"); | 226 | return i18n("Organization"); |
224 | case CustomCategory: | 227 | case CustomCategory: |
225 | return i18n("Custom"); | 228 | return i18n("Custom"); |
226 | default: | 229 | default: |
227 | return i18n("Undefined"); | 230 | return i18n("Undefined"); |
228 | } | 231 | } |
229 | } | 232 | } |
230 | 233 | ||
231 | QString Field::value( const KABC::Addressee &a ) | 234 | QString Field::value( const KABC::Addressee &a ) |
232 | { | 235 | { |
233 | switch ( mImpl->fieldId() ) { | 236 | switch ( mImpl->fieldId() ) { |
234 | case FieldImpl::FormattedName: | 237 | case FieldImpl::FormattedName: |
235 | return a.formattedName(); | 238 | return a.formattedName(); |
236 | case FieldImpl::FamilyName: | 239 | case FieldImpl::FamilyName: |
237 | return a.familyName(); | 240 | return a.familyName(); |
238 | case FieldImpl::GivenName: | 241 | case FieldImpl::GivenName: |
239 | return a.givenName(); | 242 | return a.givenName(); |
240 | case FieldImpl::AdditionalName: | 243 | case FieldImpl::AdditionalName: |
241 | return a.additionalName(); | 244 | return a.additionalName(); |
242 | case FieldImpl::Prefix: | 245 | case FieldImpl::Prefix: |
243 | return a.prefix(); | 246 | return a.prefix(); |
244 | case FieldImpl::Suffix: | 247 | case FieldImpl::Suffix: |
245 | return a.suffix(); | 248 | return a.suffix(); |
246 | case FieldImpl::NickName: | 249 | case FieldImpl::NickName: |
247 | return a.nickName(); | 250 | return a.nickName(); |
248 | case FieldImpl::Mailer: | 251 | case FieldImpl::Mailer: |
249 | return a.mailer(); | 252 | return a.mailer(); |
250 | case FieldImpl::Title: | 253 | case FieldImpl::Title: |
251 | return a.title(); | 254 | return a.title(); |
252 | case FieldImpl::Role: | 255 | case FieldImpl::Role: |
253 | return a.role(); | 256 | return a.role(); |
254 | case FieldImpl::Organization: | 257 | case FieldImpl::Organization: |
255 | return a.organization(); | 258 | return a.organization(); |
256 | case FieldImpl::Note: | 259 | case FieldImpl::Note: |
257 | return a.note(); | 260 | return a.note(); |
258 | case FieldImpl::Email: | 261 | case FieldImpl::Email: |
259 | return a.preferredEmail(); | 262 | return a.preferredEmail(); |
260 | case FieldImpl::Birthday: | 263 | case FieldImpl::Birthday: |
261 | if ( a.birthday().isValid() ) { | 264 | if ( a.birthday().isValid() ) { |
262 | //the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); | 265 | //the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); |
263 | // But Qt::IsoDate was not specified. | 266 | // But Qt::IsoDate was not specified. |
264 | // QString _oldFormat = KGlobal::locale()->dateFormat(); | 267 | // QString _oldFormat = KGlobal::locale()->dateFormat(); |
265 | // KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate | 268 | // KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate |
266 | QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate); | 269 | QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate); |
267 | // KGlobal::locale()->setDateFormat(_oldFormat); | 270 | // KGlobal::locale()->setDateFormat(_oldFormat); |
268 | return dt; | 271 | return dt; |
269 | } | 272 | } |
270 | else | 273 | else |
271 | return QString::null; | 274 | return QString::null; |
272 | case FieldImpl::Url: | 275 | case FieldImpl::Url: |
273 | return a.url().prettyURL(); | 276 | return a.url().prettyURL(); |
274 | //US | 277 | //US |
275 | case FieldImpl::Resource: | 278 | case FieldImpl::Resource: |
276 | return a.resource()->resourceName(); | 279 | return a.resource()->resourceName(); |
277 | case FieldImpl::HomePhone: | 280 | case FieldImpl::HomePhone: |
278 | return a.phoneNumber( PhoneNumber::Home ).number(); | 281 | return a.phoneNumber( PhoneNumber::Home ).number(); |
279 | case FieldImpl::BusinessPhone: | 282 | case FieldImpl::BusinessPhone: |
280 | return a.phoneNumber( PhoneNumber::Work ).number(); | 283 | return a.phoneNumber( PhoneNumber::Work ).number(); |
281 | case FieldImpl::MobilePhone: | 284 | case FieldImpl::MobilePhone: |
282 | return a.phoneNumber( PhoneNumber::Cell ).number(); | 285 | return a.phoneNumber( PhoneNumber::Cell ).number(); |
283 | case FieldImpl::HomeFax: | 286 | case FieldImpl::HomeFax: |
284 | return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); | 287 | return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); |
285 | case FieldImpl::BusinessFax: | 288 | case FieldImpl::BusinessFax: |
286 | return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); | 289 | return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); |
287 | case FieldImpl::CarPhone: | 290 | case FieldImpl::CarPhone: |
288 | return a.phoneNumber( PhoneNumber::Car ).number(); | 291 | return a.phoneNumber( PhoneNumber::Car ).number(); |
289 | case FieldImpl::Isdn: | 292 | case FieldImpl::Isdn: |
290 | return a.phoneNumber( PhoneNumber::Isdn ).number(); | 293 | return a.phoneNumber( PhoneNumber::Isdn ).number(); |
291 | case FieldImpl::Pager: | 294 | case FieldImpl::Pager: |
292 | return a.phoneNumber( PhoneNumber::Pager ).number(); | 295 | return a.phoneNumber( PhoneNumber::Pager ).number(); |
296 | case FieldImpl::Sip: | ||
297 | return a.phoneNumber( PhoneNumber::Sip ).number(); | ||
293 | case FieldImpl::HomeAddressStreet: | 298 | case FieldImpl::HomeAddressStreet: |
294 | return a.address( Address::Home ).street(); | 299 | return a.address( Address::Home ).street(); |
295 | case FieldImpl::HomeAddressLocality: | 300 | case FieldImpl::HomeAddressLocality: |
296 | return a.address( Address::Home ).locality(); | 301 | return a.address( Address::Home ).locality(); |
297 | case FieldImpl::HomeAddressRegion: | 302 | case FieldImpl::HomeAddressRegion: |
298 | return a.address( Address::Home ).region(); | 303 | return a.address( Address::Home ).region(); |
299 | case FieldImpl::HomeAddressPostalCode: | 304 | case FieldImpl::HomeAddressPostalCode: |
300 | return a.address( Address::Home ).postalCode(); | 305 | return a.address( Address::Home ).postalCode(); |
301 | case FieldImpl::HomeAddressCountry: | 306 | case FieldImpl::HomeAddressCountry: |
302 | return a.address( Address::Home ).country(); | 307 | return a.address( Address::Home ).country(); |
303 | case FieldImpl::BusinessAddressStreet: | 308 | case FieldImpl::BusinessAddressStreet: |
304 | return a.address( Address::Work ).street(); | 309 | return a.address( Address::Work ).street(); |
305 | case FieldImpl::BusinessAddressLocality: | 310 | case FieldImpl::BusinessAddressLocality: |
306 | return a.address( Address::Work ).locality(); | 311 | return a.address( Address::Work ).locality(); |
307 | case FieldImpl::BusinessAddressRegion: | 312 | case FieldImpl::BusinessAddressRegion: |
308 | return a.address( Address::Work ).region(); | 313 | return a.address( Address::Work ).region(); |
309 | case FieldImpl::BusinessAddressPostalCode: | 314 | case FieldImpl::BusinessAddressPostalCode: |
310 | return a.address( Address::Work ).postalCode(); | 315 | return a.address( Address::Work ).postalCode(); |
311 | case FieldImpl::BusinessAddressCountry: | 316 | case FieldImpl::BusinessAddressCountry: |
312 | return a.address( Address::Work ).country(); | 317 | return a.address( Address::Work ).country(); |
313 | case FieldImpl::CustomField: | 318 | case FieldImpl::CustomField: |
314 | return a.custom( mImpl->app(), mImpl->key() ); | 319 | return a.custom( mImpl->app(), mImpl->key() ); |
315 | default: | 320 | default: |
316 | return QString::null; | 321 | return QString::null; |
317 | } | 322 | } |
318 | } | 323 | } |
319 | 324 | ||
320 | bool Field::setValue( KABC::Addressee &a, const QString &value ) | 325 | bool Field::setValue( KABC::Addressee &a, const QString &value ) |
321 | { | 326 | { |
322 | switch ( mImpl->fieldId() ) { | 327 | switch ( mImpl->fieldId() ) { |
323 | case FieldImpl::FormattedName: | 328 | case FieldImpl::FormattedName: |
324 | a.setFormattedName( value ); | 329 | a.setFormattedName( value ); |
325 | return true; | 330 | return true; |
326 | case FieldImpl::FamilyName: | 331 | case FieldImpl::FamilyName: |
327 | a.setFamilyName( value ); | 332 | a.setFamilyName( value ); |
328 | return true; | 333 | return true; |
329 | case FieldImpl::GivenName: | 334 | case FieldImpl::GivenName: |
330 | a.setGivenName( value ); | 335 | a.setGivenName( value ); |
331 | return true; | 336 | return true; |
332 | case FieldImpl::AdditionalName: | 337 | case FieldImpl::AdditionalName: |
333 | a.setAdditionalName( value ); | 338 | a.setAdditionalName( value ); |
334 | return true; | 339 | return true; |
335 | case FieldImpl::Prefix: | 340 | case FieldImpl::Prefix: |
336 | a.setPrefix( value ); | 341 | a.setPrefix( value ); |
337 | return true; | 342 | return true; |
338 | case FieldImpl::Suffix: | 343 | case FieldImpl::Suffix: |
339 | a.setSuffix( value ); | 344 | a.setSuffix( value ); |
340 | return true; | 345 | return true; |
341 | case FieldImpl::NickName: | 346 | case FieldImpl::NickName: |
342 | a.setNickName( value ); | 347 | a.setNickName( value ); |
343 | return true; | 348 | return true; |
344 | case FieldImpl::Mailer: | 349 | case FieldImpl::Mailer: |
345 | a.setMailer( value ); | 350 | a.setMailer( value ); |
346 | return true; | 351 | return true; |
347 | case FieldImpl::Title: | 352 | case FieldImpl::Title: |
348 | a.setTitle( value ); | 353 | a.setTitle( value ); |
349 | return true; | 354 | return true; |
350 | case FieldImpl::Role: | 355 | case FieldImpl::Role: |
351 | a.setRole( value ); | 356 | a.setRole( value ); |
352 | return true; | 357 | return true; |
353 | case FieldImpl::Organization: | 358 | case FieldImpl::Organization: |
354 | a.setOrganization( value ); | 359 | a.setOrganization( value ); |
355 | return true; | 360 | return true; |
356 | case FieldImpl::Note: | 361 | case FieldImpl::Note: |
357 | a.setNote( value ); | 362 | a.setNote( value ); |
358 | return true; | 363 | return true; |
359 | case FieldImpl::Birthday: | 364 | case FieldImpl::Birthday: |
360 | //US | 365 | //US |
361 | //the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); | 366 | //the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); |
362 | // But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? | 367 | // But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? |
363 | { | 368 | { |
364 | QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate | 369 | QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate |
365 | a.setBirthday(dt); | 370 | a.setBirthday(dt); |
366 | } | 371 | } |
367 | return true; | 372 | return true; |
368 | case FieldImpl::CustomField: | 373 | case FieldImpl::CustomField: |
369 | a.insertCustom( mImpl->app(), mImpl->key(), value ); | 374 | a.insertCustom( mImpl->app(), mImpl->key(), value ); |
370 | //US never copy the resourcename back to the adressee. | 375 | //US never copy the resourcename back to the adressee. |
371 | case FieldImpl::Resource: | 376 | case FieldImpl::Resource: |
372 | default: | 377 | default: |
373 | return false; | 378 | return false; |
374 | } | 379 | } |
375 | } | 380 | } |
376 | 381 | ||
377 | bool Field::isCustom() | 382 | bool Field::isCustom() |
378 | { | 383 | { |
379 | return mImpl->fieldId() == FieldImpl::CustomField; | 384 | return mImpl->fieldId() == FieldImpl::CustomField; |
380 | } | 385 | } |
381 | 386 | ||
382 | Field::List Field::allFields() | 387 | Field::List Field::allFields() |
383 | { | 388 | { |
384 | if ( mAllFields.isEmpty() ) { | 389 | if ( mAllFields.isEmpty() ) { |
385 | createField( FieldImpl::FormattedName, Frequent ); | 390 | createField( FieldImpl::FormattedName, Frequent ); |
386 | createField( FieldImpl::FamilyName, Frequent ); | 391 | createField( FieldImpl::FamilyName, Frequent ); |
387 | createField( FieldImpl::GivenName, Frequent ); | 392 | createField( FieldImpl::GivenName, Frequent ); |
388 | createField( FieldImpl::AdditionalName ); | 393 | createField( FieldImpl::AdditionalName ); |
389 | createField( FieldImpl::Prefix ); | 394 | createField( FieldImpl::Prefix ); |
390 | createField( FieldImpl::Suffix ); | 395 | createField( FieldImpl::Suffix ); |
391 | createField( FieldImpl::NickName, Personal ); | 396 | createField( FieldImpl::NickName, Personal ); |
392 | createField( FieldImpl::Birthday, Personal ); | 397 | createField( FieldImpl::Birthday, Personal ); |
393 | createField( FieldImpl::HomeAddressStreet, Address|Personal ); | 398 | createField( FieldImpl::HomeAddressStreet, Address|Personal ); |
394 | createField( FieldImpl::HomeAddressLocality, Address|Personal ); | 399 | createField( FieldImpl::HomeAddressLocality, Address|Personal ); |
395 | createField( FieldImpl::HomeAddressRegion, Address|Personal ); | 400 | createField( FieldImpl::HomeAddressRegion, Address|Personal ); |
396 | createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); | 401 | createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); |
397 | createField( FieldImpl::HomeAddressCountry, Address|Personal ); | 402 | createField( FieldImpl::HomeAddressCountry, Address|Personal ); |
398 | createField( FieldImpl::HomeAddressLabel, Address|Personal ); | 403 | createField( FieldImpl::HomeAddressLabel, Address|Personal ); |
399 | createField( FieldImpl::BusinessAddressStreet, Address|Organization ); | 404 | createField( FieldImpl::BusinessAddressStreet, Address|Organization ); |
400 | createField( FieldImpl::BusinessAddressLocality, Address|Organization ); | 405 | createField( FieldImpl::BusinessAddressLocality, Address|Organization ); |
401 | createField( FieldImpl::BusinessAddressRegion, Address|Organization ); | 406 | createField( FieldImpl::BusinessAddressRegion, Address|Organization ); |
402 | createField( FieldImpl::BusinessAddressPostalCode, Address|Organization ); | 407 | createField( FieldImpl::BusinessAddressPostalCode, Address|Organization ); |
403 | createField( FieldImpl::BusinessAddressCountry, Address|Organization ); | 408 | createField( FieldImpl::BusinessAddressCountry, Address|Organization ); |
404 | createField( FieldImpl::BusinessAddressLabel, Address|Organization ); | 409 | createField( FieldImpl::BusinessAddressLabel, Address|Organization ); |
405 | createField( FieldImpl::HomePhone, Personal|Frequent ); | 410 | createField( FieldImpl::HomePhone, Personal|Frequent ); |
406 | createField( FieldImpl::BusinessPhone, Organization|Frequent ); | 411 | createField( FieldImpl::BusinessPhone, Organization|Frequent ); |
407 | createField( FieldImpl::MobilePhone, Frequent ); | 412 | createField( FieldImpl::MobilePhone, Frequent ); |
408 | createField( FieldImpl::HomeFax ); | 413 | createField( FieldImpl::HomeFax ); |
409 | createField( FieldImpl::BusinessFax ); | 414 | createField( FieldImpl::BusinessFax ); |
410 | createField( FieldImpl::CarPhone ); | 415 | createField( FieldImpl::CarPhone ); |
411 | createField( FieldImpl::Isdn ); | 416 | createField( FieldImpl::Isdn ); |
412 | createField( FieldImpl::Pager ); | 417 | createField( FieldImpl::Pager ); |
413 | createField( FieldImpl::Email, Email|Frequent ); | 418 | createField( FieldImpl::Email, Email|Frequent ); |
414 | createField( FieldImpl::Mailer, Email ); | 419 | createField( FieldImpl::Mailer, Email ); |
415 | createField( FieldImpl::Title, Organization ); | 420 | createField( FieldImpl::Title, Organization ); |
416 | createField( FieldImpl::Role, Organization ); | 421 | createField( FieldImpl::Role, Organization ); |
417 | createField( FieldImpl::Organization, Organization ); | 422 | createField( FieldImpl::Organization, Organization ); |
418 | createField( FieldImpl::Note ); | 423 | createField( FieldImpl::Note ); |
419 | createField( FieldImpl::Url ); | 424 | createField( FieldImpl::Url ); |
420 | createField( FieldImpl::Resource ); | 425 | createField( FieldImpl::Resource ); |
426 | createField( FieldImpl::Sip ); | ||
421 | } | 427 | } |
422 | 428 | ||
423 | return mAllFields; | 429 | return mAllFields; |
424 | } | 430 | } |
425 | 431 | ||
426 | Field::List Field::defaultFields() | 432 | Field::List Field::defaultFields() |
427 | { | 433 | { |
428 | if ( mDefaultFields.isEmpty() ) { | 434 | if ( mDefaultFields.isEmpty() ) { |
429 | createDefaultField( FieldImpl::GivenName ); | 435 | createDefaultField( FieldImpl::GivenName ); |
430 | createDefaultField( FieldImpl::FamilyName ); | 436 | createDefaultField( FieldImpl::FamilyName ); |
431 | createDefaultField( FieldImpl::Email ); | 437 | createDefaultField( FieldImpl::Email ); |
432 | } | 438 | } |
433 | 439 | ||
434 | return mDefaultFields; | 440 | return mDefaultFields; |
435 | } | 441 | } |
436 | 442 | ||
437 | void Field::createField( int id, int category ) | 443 | void Field::createField( int id, int category ) |
438 | { | 444 | { |
439 | mAllFields.append( new Field( new FieldImpl( id, category ) ) ); | 445 | mAllFields.append( new Field( new FieldImpl( id, category ) ) ); |
440 | } | 446 | } |
441 | 447 | ||
442 | void Field::createDefaultField( int id, int category ) | 448 | void Field::createDefaultField( int id, int category ) |
443 | { | 449 | { |
444 | mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); | 450 | mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); |
445 | } | 451 | } |
446 | 452 | ||
447 | void Field::deleteFields() | 453 | void Field::deleteFields() |
448 | { | 454 | { |
449 | Field::List::ConstIterator it; | 455 | Field::List::ConstIterator it; |
450 | 456 | ||
451 | for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) { | 457 | for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) { |
452 | delete (*it); | 458 | delete (*it); |
453 | } | 459 | } |
454 | mAllFields.clear(); | 460 | mAllFields.clear(); |
455 | 461 | ||
456 | for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) { | 462 | for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) { |
457 | delete (*it); | 463 | delete (*it); |
458 | } | 464 | } |
459 | mDefaultFields.clear(); | 465 | mDefaultFields.clear(); |
460 | 466 | ||
461 | for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) { | 467 | for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) { |
462 | delete (*it); | 468 | delete (*it); |
463 | } | 469 | } |
464 | mCustomFields.clear(); | 470 | mCustomFields.clear(); |
465 | } | 471 | } |
466 | 472 | ||
467 | void Field::saveFields( const QString &identifier, | 473 | void Field::saveFields( const QString &identifier, |
468 | const Field::List &fields ) | 474 | const Field::List &fields ) |
469 | { | 475 | { |
470 | KConfig *cfg = KGlobal::config(); | 476 | KConfig *cfg = KGlobal::config(); |
471 | KConfigGroupSaver( cfg, "KABCFields" ); | 477 | KConfigGroupSaver( cfg, "KABCFields" ); |
472 | saveFields( cfg, identifier, fields ); | 478 | saveFields( cfg, identifier, fields ); |
473 | } | 479 | } |
474 | 480 | ||
475 | void Field::saveFields( KConfig *cfg, const QString &identifier, | 481 | void Field::saveFields( KConfig *cfg, const QString &identifier, |
476 | const Field::List &fields ) | 482 | const Field::List &fields ) |
477 | { | 483 | { |
478 | QValueList<int> fieldIds; | 484 | QValueList<int> fieldIds; |
479 | 485 | ||
480 | //US | 486 | //US |
481 | // qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1()); | 487 | // qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1()); |
482 | 488 | ||
483 | int custom = 0; | 489 | int custom = 0; |
484 | Field::List::ConstIterator it; | 490 | Field::List::ConstIterator it; |
485 | for( it = fields.begin(); it != fields.end(); ++it ) { | 491 | for( it = fields.begin(); it != fields.end(); ++it ) { |
486 | //US | 492 | //US |
487 | // qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId()); | 493 | // qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId()); |
488 | 494 | ||
489 | fieldIds.append( (*it)->mImpl->fieldId() ); | 495 | fieldIds.append( (*it)->mImpl->fieldId() ); |
490 | if( (*it)->isCustom() ) { | 496 | if( (*it)->isCustom() ) { |
491 | QStringList customEntry; | 497 | QStringList customEntry; |
492 | customEntry << (*it)->mImpl->label(); | 498 | customEntry << (*it)->mImpl->label(); |
493 | customEntry << (*it)->mImpl->key(); | 499 | customEntry << (*it)->mImpl->key(); |
494 | customEntry << (*it)->mImpl->app(); | 500 | customEntry << (*it)->mImpl->app(); |
495 | cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" + | 501 | cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" + |
496 | QString::number( custom++ ), customEntry ); | 502 | QString::number( custom++ ), customEntry ); |
497 | } | 503 | } |
498 | } | 504 | } |
499 | cfg->writeEntry( identifier, fieldIds ); | 505 | cfg->writeEntry( identifier, fieldIds ); |
500 | } | 506 | } |
501 | 507 | ||
502 | Field::List Field::restoreFields( const QString &identifier ) | 508 | Field::List Field::restoreFields( const QString &identifier ) |
503 | { | 509 | { |
504 | //US | 510 | //US |
505 | // qDebug("Field::restoreFields, identifier: %s", identifier.latin1()); | 511 | // qDebug("Field::restoreFields, identifier: %s", identifier.latin1()); |
506 | 512 | ||
507 | KConfig *cfg = KGlobal::config(); | 513 | KConfig *cfg = KGlobal::config(); |
508 | KConfigGroupSaver( cfg, "KABCFields" ); | 514 | KConfigGroupSaver( cfg, "KABCFields" ); |
509 | cfg->setGroup( "KABCFields" ); | 515 | cfg->setGroup( "KABCFields" ); |
510 | 516 | ||
511 | Field::List l = restoreFields( cfg, identifier ); | 517 | Field::List l = restoreFields( cfg, identifier ); |
512 | 518 | ||
513 | return l; | 519 | return l; |
514 | } | 520 | } |
515 | 521 | ||
516 | Field::List Field::restoreFields( KConfig *cfg, const QString &identifier ) | 522 | Field::List Field::restoreFields( KConfig *cfg, const QString &identifier ) |
517 | { | 523 | { |
518 | QValueList<int> fieldIds = cfg->readIntListEntry( identifier); | 524 | QValueList<int> fieldIds = cfg->readIntListEntry( identifier); |
519 | //US | 525 | //US |
520 | // qDebug("Field::restoreFields from %s, identifier: %s", cfg->getFileName().latin1(), identifier.latin1()); | 526 | // qDebug("Field::restoreFields from %s, identifier: %s", cfg->getFileName().latin1(), identifier.latin1()); |
521 | 527 | ||
522 | Field::List fields; | 528 | Field::List fields; |
523 | 529 | ||
524 | int custom = 0; | 530 | int custom = 0; |
525 | QValueList<int>::ConstIterator it; | 531 | QValueList<int>::ConstIterator it; |
526 | for( it = fieldIds.begin(); it != fieldIds.end(); ++it ) { | 532 | for( it = fieldIds.begin(); it != fieldIds.end(); ++it ) { |
527 | FieldImpl *f = 0; | 533 | FieldImpl *f = 0; |
528 | if ( (*it) == FieldImpl::CustomField ) { | 534 | if ( (*it) == FieldImpl::CustomField ) { |
529 | QStringList customEntry = cfg->readListEntry( "KABC_CustomEntry_" + | 535 | QStringList customEntry = cfg->readListEntry( "KABC_CustomEntry_" + |
530 | identifier + "_" + | 536 | identifier + "_" + |
531 | QString::number( custom++ ) ); | 537 | QString::number( custom++ ) ); |
532 | f = new FieldImpl( *it, CustomCategory, customEntry[ 0 ], | 538 | f = new FieldImpl( *it, CustomCategory, customEntry[ 0 ], |
533 | customEntry[ 1 ], customEntry[ 2 ] ); | 539 | customEntry[ 1 ], customEntry[ 2 ] ); |
534 | } else { | 540 | } else { |
535 | f = new FieldImpl( *it ); | 541 | f = new FieldImpl( *it ); |
536 | } | 542 | } |
537 | fields.append( new Field( f ) ); | 543 | fields.append( new Field( f ) ); |
538 | } | 544 | } |
539 | 545 | ||
540 | return fields; | 546 | return fields; |
541 | } | 547 | } |
542 | 548 | ||
543 | bool Field::equals( Field *field ) | 549 | bool Field::equals( Field *field ) |
544 | { | 550 | { |
545 | bool sameId = ( mImpl->fieldId() == field->mImpl->fieldId() ); | 551 | bool sameId = ( mImpl->fieldId() == field->mImpl->fieldId() ); |
546 | 552 | ||
547 | if ( !sameId ) return false; | 553 | if ( !sameId ) return false; |
548 | 554 | ||
549 | if ( mImpl->fieldId() != FieldImpl::CustomField ) return true; | 555 | if ( mImpl->fieldId() != FieldImpl::CustomField ) return true; |
550 | 556 | ||
551 | return mImpl->key() == field->mImpl->key(); | 557 | return mImpl->key() == field->mImpl->key(); |
552 | } | 558 | } |
553 | 559 | ||
554 | Field *Field::createCustomField( const QString &label, int category, | 560 | Field *Field::createCustomField( const QString &label, int category, |
555 | const QString &key, const QString &app ) | 561 | const QString &key, const QString &app ) |
556 | { | 562 | { |
557 | Field *field = new Field( new FieldImpl( FieldImpl::CustomField, | 563 | Field *field = new Field( new FieldImpl( FieldImpl::CustomField, |
558 | category | CustomCategory, | 564 | category | CustomCategory, |
559 | label, key, app ) ); | 565 | label, key, app ) ); |
560 | //US | 566 | //US |
561 | // qDebug("Field::createCustomField label %s", label.latin1() ); | 567 | // qDebug("Field::createCustomField label %s", label.latin1() ); |
562 | 568 | ||
563 | mCustomFields.append( field ); | 569 | mCustomFields.append( field ); |
564 | 570 | ||
565 | return field; | 571 | return field; |
566 | } | 572 | } |
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index 4ad608d..7aeb2ee 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp | |||
@@ -1,200 +1,202 @@ | |||
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 | void PhoneNumber::setId( const QString &id ) | 69 | void PhoneNumber::setId( const QString &id ) |
70 | { | 70 | { |
71 | mId = id; | 71 | mId = id; |
72 | } | 72 | } |
73 | 73 | ||
74 | QString PhoneNumber::id() const | 74 | QString PhoneNumber::id() const |
75 | { | 75 | { |
76 | return mId; | 76 | return mId; |
77 | } | 77 | } |
78 | 78 | ||
79 | void PhoneNumber::setNumber( const QString &number ) | 79 | void PhoneNumber::setNumber( const QString &number ) |
80 | { | 80 | { |
81 | mNumber = number; | 81 | mNumber = number; |
82 | } | 82 | } |
83 | 83 | ||
84 | QString PhoneNumber::number() const | 84 | QString PhoneNumber::number() const |
85 | { | 85 | { |
86 | return mNumber; | 86 | return mNumber; |
87 | } | 87 | } |
88 | 88 | ||
89 | void PhoneNumber::setType( int type ) | 89 | void PhoneNumber::setType( int type ) |
90 | { | 90 | { |
91 | mType = type; | 91 | mType = type; |
92 | } | 92 | } |
93 | 93 | ||
94 | int PhoneNumber::type() const | 94 | int PhoneNumber::type() const |
95 | { | 95 | { |
96 | return mType; | 96 | return mType; |
97 | } | 97 | } |
98 | 98 | ||
99 | QString PhoneNumber::typeLabel() const | 99 | QString PhoneNumber::typeLabel() const |
100 | { | 100 | { |
101 | QString label; | 101 | QString label; |
102 | bool first = true; | 102 | bool first = true; |
103 | 103 | ||
104 | TypeList list = typeList(); | 104 | TypeList list = typeList(); |
105 | 105 | ||
106 | TypeList::Iterator it; | 106 | TypeList::Iterator it; |
107 | for ( it = list.begin(); it != list.end(); ++it ) { | 107 | for ( it = list.begin(); it != list.end(); ++it ) { |
108 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { | 108 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { |
109 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); | 109 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); |
110 | if ( first ) | 110 | if ( first ) |
111 | first = false; | 111 | first = false; |
112 | } | 112 | } |
113 | } | 113 | } |
114 | 114 | ||
115 | return label; | 115 | return label; |
116 | } | 116 | } |
117 | 117 | ||
118 | QString PhoneNumber::label() const | 118 | QString PhoneNumber::label() const |
119 | { | 119 | { |
120 | return typeLabel( type() ); | 120 | return typeLabel( type() ); |
121 | } | 121 | } |
122 | 122 | ||
123 | PhoneNumber::TypeList PhoneNumber::typeList() | 123 | PhoneNumber::TypeList PhoneNumber::typeList() |
124 | { | 124 | { |
125 | TypeList list; | 125 | TypeList list; |
126 | 126 | ||
127 | list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video | 127 | list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video |
128 | << Bbs << Modem << Car << Isdn << Pcs << Pager; | 128 | << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip; |
129 | 129 | ||
130 | return list; | 130 | return list; |
131 | } | 131 | } |
132 | 132 | ||
133 | QString PhoneNumber::label( int type ) | 133 | QString PhoneNumber::label( int type ) |
134 | { | 134 | { |
135 | return typeLabel( type ); | 135 | return typeLabel( type ); |
136 | } | 136 | } |
137 | 137 | ||
138 | QString PhoneNumber::typeLabel( int type ) | 138 | QString PhoneNumber::typeLabel( int type ) |
139 | { | 139 | { |
140 | QString typeString; | 140 | QString typeString; |
141 | 141 | ||
142 | if ((type & Home) == Home) | 142 | if ((type & Home) == Home) |
143 | typeString += i18n("Home"); | 143 | typeString += i18n("Home"); |
144 | else if ((type & Work) == Work) | 144 | else if ((type & Work) == Work) |
145 | typeString += i18n("Work"); | 145 | typeString += i18n("Work"); |
146 | 146 | ||
147 | if (!typeString.isEmpty()) | 147 | if (!typeString.isEmpty()) |
148 | typeString += " "; | 148 | typeString += " "; |
149 | 149 | ||
150 | if ((type & Cell) == Cell) | 150 | if ((type & Cell) == Cell) |
151 | typeString += i18n("Mobile"); | 151 | typeString += i18n("Mobile"); |
152 | else if ((type & Fax) == Fax) | 152 | else if ((type & Fax) == Fax) |
153 | typeString += i18n("Fax"); | 153 | typeString += i18n("Fax"); |
154 | else if ((type & Msg) == Msg) | 154 | else if ((type & Msg) == Msg) |
155 | typeString += i18n("Messenger"); | 155 | typeString += i18n("Messenger"); |
156 | else if ((type & Voice) == Voice) { | 156 | else if ((type & Voice) == Voice) { |
157 | // add nothing in case of the Voice flag | 157 | // add nothing in case of the Voice flag |
158 | // typeString += i18n("Voice"); | 158 | // typeString += i18n("Voice"); |
159 | } | 159 | } |
160 | else if ((type & Video) == Video) | 160 | else if ((type & Video) == Video) |
161 | typeString += i18n("Video"); | 161 | typeString += i18n("Video"); |
162 | else if ((type & Bbs) == Bbs) | 162 | else if ((type & Bbs) == Bbs) |
163 | typeString += i18n("Mailbox"); | 163 | typeString += i18n("Mailbox"); |
164 | else if ((type & Modem) == Modem) | 164 | else if ((type & Modem) == Modem) |
165 | typeString += i18n("Modem"); | 165 | typeString += i18n("Modem"); |
166 | else if ((type & Car) == Car) | 166 | else if ((type & Car) == Car) |
167 | typeString += i18n("Car"); | 167 | typeString += i18n("Car"); |
168 | else if ((type & Isdn) == Isdn) | 168 | else if ((type & Isdn) == Isdn) |
169 | typeString += i18n("ISDN"); | 169 | typeString += i18n("ISDN"); |
170 | else if ((type & Pcs) == Pcs) | 170 | else if ((type & Pcs) == Pcs) |
171 | typeString += i18n("PCS"); | 171 | typeString += i18n("PCS"); |
172 | else if ((type & Pager) == Pager) | 172 | else if ((type & Pager) == Pager) |
173 | typeString += i18n("Pager"); | 173 | typeString += i18n("Pager"); |
174 | else if ((type & Sip) == Sip) | ||
175 | typeString += i18n("SIP"); | ||
174 | 176 | ||
175 | // add the prefered flag | 177 | // add the prefered flag |
176 | if (!typeString.isEmpty()) | 178 | if (!typeString.isEmpty()) |
177 | typeString += " "; | 179 | typeString += " "; |
178 | 180 | ||
179 | if ((type & Pref) == Pref) | 181 | if ((type & Pref) == Pref) |
180 | typeString += i18n("(p)"); | 182 | typeString += i18n("(p)"); |
181 | 183 | ||
182 | //if we still have no match, return "other" | 184 | //if we still have no match, return "other" |
183 | if (typeString.isEmpty()) | 185 | if (typeString.isEmpty()) |
184 | return i18n("Other"); | 186 | return i18n("Other"); |
185 | 187 | ||
186 | 188 | ||
187 | return typeString; | 189 | return typeString; |
188 | } | 190 | } |
189 | 191 | ||
190 | QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) | 192 | QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) |
191 | { | 193 | { |
192 | return s << phone.mId << phone.mType << phone.mNumber; | 194 | return s << phone.mId << phone.mType << phone.mNumber; |
193 | } | 195 | } |
194 | 196 | ||
195 | QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) | 197 | QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) |
196 | { | 198 | { |
197 | s >> phone.mId >> phone.mType >> phone.mNumber; | 199 | s >> phone.mId >> phone.mType >> phone.mNumber; |
198 | 200 | ||
199 | return s; | 201 | return s; |
200 | } | 202 | } |
diff --git a/kabc/phonenumber.h b/kabc/phonenumber.h index 6a9c8cb..1df344f 100644 --- a/kabc/phonenumber.h +++ b/kabc/phonenumber.h | |||
@@ -1,165 +1,166 @@ | |||
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 | #ifndef KABC_PHONENUMBER_H | 28 | #ifndef KABC_PHONENUMBER_H |
29 | #define KABC_PHONENUMBER_H | 29 | #define KABC_PHONENUMBER_H |
30 | 30 | ||
31 | #include <qvaluelist.h> | 31 | #include <qvaluelist.h> |
32 | #include <qstring.h> | 32 | #include <qstring.h> |
33 | 33 | ||
34 | namespace KABC { | 34 | namespace KABC { |
35 | 35 | ||
36 | /** | 36 | /** |
37 | @short Phonenumber information. | 37 | @short Phonenumber information. |
38 | 38 | ||
39 | This class provides phone number information. A phone number is classified by | 39 | This class provides phone number information. A phone number is classified by |
40 | a type. The following types are available, it's possible to use multiple types | 40 | a type. The following types are available, it's possible to use multiple types |
41 | @ref Types for a number by combining them through a logical or. | 41 | @ref Types for a number by combining them through a logical or. |
42 | */ | 42 | */ |
43 | class PhoneNumber | 43 | class PhoneNumber |
44 | { | 44 | { |
45 | friend QDataStream &operator<<( QDataStream &, const PhoneNumber & ); | 45 | friend QDataStream &operator<<( QDataStream &, const PhoneNumber & ); |
46 | friend QDataStream &operator>>( QDataStream &, PhoneNumber & ); | 46 | friend QDataStream &operator>>( QDataStream &, PhoneNumber & ); |
47 | 47 | ||
48 | public: | 48 | public: |
49 | typedef QValueList<PhoneNumber> List; | 49 | typedef QValueList<PhoneNumber> List; |
50 | typedef QValueList<int> TypeList; | 50 | typedef QValueList<int> TypeList; |
51 | 51 | ||
52 | /** | 52 | /** |
53 | @li @p Home - Home number | 53 | @li @p Home - Home number |
54 | @li @p Work - Office number | 54 | @li @p Work - Office number |
55 | @li @p Msg - Messaging | 55 | @li @p Msg - Messaging |
56 | @li @p Pref - Preferred number | 56 | @li @p Pref - Preferred number |
57 | @li @p Voice - Voice | 57 | @li @p Voice - Voice |
58 | @li @p Fax - Fax machine | 58 | @li @p Fax - Fax machine |
59 | @li @p Cell - Cell phone | 59 | @li @p Cell - Cell phone |
60 | @li @p Video - Video phone | 60 | @li @p Video - Video phone |
61 | @li @p Bbs - Mailbox | 61 | @li @p Bbs - Mailbox |
62 | @li @p Modem - Modem | 62 | @li @p Modem - Modem |
63 | @li @p Car - Car phone | 63 | @li @p Car - Car phone |
64 | @li @p Isdn - ISDN connection | 64 | @li @p Isdn - ISDN connection |
65 | @li @p Pcs - Personal Communication Service | 65 | @li @p Pcs - Personal Communication Service |
66 | @li @p Pager - Pager | 66 | @li @p Pager - Pager |
67 | @li @p SIP - VoIP | ||
67 | */ | 68 | */ |
68 | enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32, | 69 | enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32, |
69 | Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024, | 70 | Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024, |
70 | Isdn = 2048, Pcs = 4096, Pager = 8192 }; | 71 | Isdn = 2048, Pcs = 4096, Pager = 8192, Sip = 16384 }; |
71 | 72 | ||
72 | /** | 73 | /** |
73 | Create an empty phone number object. | 74 | Create an empty phone number object. |
74 | */ | 75 | */ |
75 | PhoneNumber(); | 76 | PhoneNumber(); |
76 | 77 | ||
77 | /** | 78 | /** |
78 | Create a phonenumber object. | 79 | Create a phonenumber object. |
79 | 80 | ||
80 | @param number Number | 81 | @param number Number |
81 | @param type Type as defined in enum. Multiple types can be | 82 | @param type Type as defined in enum. Multiple types can be |
82 | specified by combining them by a logical or. | 83 | specified by combining them by a logical or. |
83 | */ | 84 | */ |
84 | PhoneNumber( const QString &number, int type = Home ); | 85 | PhoneNumber( const QString &number, int type = Home ); |
85 | 86 | ||
86 | /** | 87 | /** |
87 | Destructor. | 88 | Destructor. |
88 | */ | 89 | */ |
89 | ~PhoneNumber(); | 90 | ~PhoneNumber(); |
90 | 91 | ||
91 | bool operator==( const PhoneNumber & ) const; | 92 | bool operator==( const PhoneNumber & ) const; |
92 | bool operator!=( const PhoneNumber & ) const; | 93 | bool operator!=( const PhoneNumber & ) const; |
93 | 94 | ||
94 | /** | 95 | /** |
95 | Sets the unique identifier. | 96 | Sets the unique identifier. |
96 | */ | 97 | */ |
97 | void setId( const QString &id ); | 98 | void setId( const QString &id ); |
98 | 99 | ||
99 | /** | 100 | /** |
100 | Returns the unique identifier. | 101 | Returns the unique identifier. |
101 | */ | 102 | */ |
102 | QString id() const; | 103 | QString id() const; |
103 | 104 | ||
104 | /** | 105 | /** |
105 | Sets the number. | 106 | Sets the number. |
106 | */ | 107 | */ |
107 | void setNumber( const QString & ); | 108 | void setNumber( const QString & ); |
108 | 109 | ||
109 | /** | 110 | /** |
110 | Returns the number. | 111 | Returns the number. |
111 | */ | 112 | */ |
112 | QString number() const; | 113 | QString number() const; |
113 | 114 | ||
114 | /** | 115 | /** |
115 | Sets the type. Multiple types can be specified by combining them by | 116 | Sets the type. Multiple types can be specified by combining them by |
116 | a logical or. | 117 | a logical or. |
117 | */ | 118 | */ |
118 | void setType( int ); | 119 | void setType( int ); |
119 | 120 | ||
120 | /** | 121 | /** |
121 | Returns the type. Can be a multiple types combined by a logical or. | 122 | Returns the type. Can be a multiple types combined by a logical or. |
122 | */ | 123 | */ |
123 | int type() const; | 124 | int type() const; |
124 | 125 | ||
125 | /** | 126 | /** |
126 | Returns a translated string of all types the address has. | 127 | Returns a translated string of all types the address has. |
127 | */ | 128 | */ |
128 | QString typeLabel() const; | 129 | QString typeLabel() const; |
129 | 130 | ||
130 | /** | 131 | /** |
131 | Returns the translated label for phone number depending on its type. | 132 | Returns the translated label for phone number depending on its type. |
132 | */ | 133 | */ |
133 | QString label() const; | 134 | QString label() const; |
134 | 135 | ||
135 | /** | 136 | /** |
136 | Returns a list of all available types | 137 | Returns a list of all available types |
137 | */ | 138 | */ |
138 | static TypeList typeList(); | 139 | static TypeList typeList(); |
139 | 140 | ||
140 | /** | 141 | /** |
141 | Returns the translated label for phone number type. | 142 | Returns the translated label for phone number type. |
142 | */ | 143 | */ |
143 | static QString typeLabel( int type ); | 144 | static QString typeLabel( int type ); |
144 | 145 | ||
145 | /** | 146 | /** |
146 | Returns the translated label for phone number type. | 147 | Returns the translated label for phone number type. |
147 | @obsolete | 148 | @obsolete |
148 | */ | 149 | */ |
149 | static QString label( int type ); | 150 | static QString label( int type ); |
150 | 151 | ||
151 | private: | 152 | private: |
152 | void init(); | 153 | void init(); |
153 | 154 | ||
154 | QString mId; | 155 | QString mId; |
155 | 156 | ||
156 | int mType; | 157 | int mType; |
157 | QString mNumber; | 158 | QString mNumber; |
158 | }; | 159 | }; |
159 | 160 | ||
160 | QDataStream &operator<<( QDataStream &, const PhoneNumber & ); | 161 | QDataStream &operator<<( QDataStream &, const PhoneNumber & ); |
161 | QDataStream &operator>>( QDataStream &, PhoneNumber & ); | 162 | QDataStream &operator>>( QDataStream &, PhoneNumber & ); |
162 | 163 | ||
163 | } | 164 | } |
164 | 165 | ||
165 | #endif | 166 | #endif |
diff --git a/kabc/vcard21parser.cpp b/kabc/vcard21parser.cpp index b02aac4..277de22 100644 --- a/kabc/vcard21parser.cpp +++ b/kabc/vcard21parser.cpp | |||
@@ -1,606 +1,609 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Mark Westcott <mark@houseoffish.org> | 3 | Copyright (c) 2001 Mark Westcott <mark@houseoffish.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 <qmap.h> | 28 | #include <qmap.h> |
29 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | #include <kmdcodec.h> | 30 | #include <kmdcodec.h> |
31 | 31 | ||
32 | #include "vcard21parser.h" | 32 | #include "vcard21parser.h" |
33 | #include "vcardconverter.h" | 33 | #include "vcardconverter.h" |
34 | 34 | ||
35 | using namespace KABC; | 35 | using namespace KABC; |
36 | 36 | ||
37 | bool VCardLineX::isValid() const | 37 | bool VCardLineX::isValid() const |
38 | { | 38 | { |
39 | // Invalid: if it is "begin:vcard" or "end:vcard" | 39 | // Invalid: if it is "begin:vcard" or "end:vcard" |
40 | if ( name == VCARD_BEGIN_N || name == VCARD_END_N ) | 40 | if ( name == VCARD_BEGIN_N || name == VCARD_END_N ) |
41 | return false; | 41 | return false; |
42 | 42 | ||
43 | if ( name[0] == 'x' && name[1] == '-' ) // A custom x- line | 43 | if ( name[0] == 'x' && name[1] == '-' ) // A custom x- line |
44 | return true; | 44 | return true; |
45 | 45 | ||
46 | // This is long but it makes it a bit faster (and saves me from using | 46 | // This is long but it makes it a bit faster (and saves me from using |
47 | // a tree which is probably the ideal situation, but a bit memory heavy) | 47 | // a tree which is probably the ideal situation, but a bit memory heavy) |
48 | switch( name[0] ) { | 48 | switch( name[0] ) { |
49 | case 'a': | 49 | case 'a': |
50 | if ( name == VCARD_ADR && qualified && | 50 | if ( name == VCARD_ADR && qualified && |
51 | (qualifiers.contains(VCARD_ADR_DOM) || | 51 | (qualifiers.contains(VCARD_ADR_DOM) || |
52 | qualifiers.contains(VCARD_ADR_INTL) || | 52 | qualifiers.contains(VCARD_ADR_INTL) || |
53 | qualifiers.contains(VCARD_ADR_POSTAL) || | 53 | qualifiers.contains(VCARD_ADR_POSTAL) || |
54 | qualifiers.contains(VCARD_ADR_HOME) || | 54 | qualifiers.contains(VCARD_ADR_HOME) || |
55 | qualifiers.contains(VCARD_ADR_WORK) || | 55 | qualifiers.contains(VCARD_ADR_WORK) || |
56 | qualifiers.contains(VCARD_ADR_PREF) | 56 | qualifiers.contains(VCARD_ADR_PREF) |
57 | ) ) | 57 | ) ) |
58 | return true; | 58 | return true; |
59 | 59 | ||
60 | if ( name == VCARD_AGENT ) | 60 | if ( name == VCARD_AGENT ) |
61 | return true; | 61 | return true; |
62 | break; | 62 | break; |
63 | 63 | ||
64 | case 'b': | 64 | case 'b': |
65 | if ( name == VCARD_BDAY ) | 65 | if ( name == VCARD_BDAY ) |
66 | return true; | 66 | return true; |
67 | break; | 67 | break; |
68 | 68 | ||
69 | case 'c': | 69 | case 'c': |
70 | if ( name == VCARD_CATEGORIES ) | 70 | if ( name == VCARD_CATEGORIES ) |
71 | return true; | 71 | return true; |
72 | if ( name == VCARD_CLASS && qualified && | 72 | if ( name == VCARD_CLASS && qualified && |
73 | (qualifiers.contains(VCARD_CLASS_PUBLIC) || | 73 | (qualifiers.contains(VCARD_CLASS_PUBLIC) || |
74 | qualifiers.contains(VCARD_CLASS_PRIVATE) || | 74 | qualifiers.contains(VCARD_CLASS_PRIVATE) || |
75 | qualifiers.contains(VCARD_CLASS_CONFIDENTIAL) | 75 | qualifiers.contains(VCARD_CLASS_CONFIDENTIAL) |
76 | ) ) | 76 | ) ) |
77 | return true; | 77 | return true; |
78 | break; | 78 | break; |
79 | 79 | ||
80 | case 'e': | 80 | case 'e': |
81 | if ( name == VCARD_EMAIL && qualified && | 81 | if ( name == VCARD_EMAIL && qualified && |
82 | (qualifiers.contains(VCARD_EMAIL_INTERNET) || | 82 | (qualifiers.contains(VCARD_EMAIL_INTERNET) || |
83 | qualifiers.contains(VCARD_EMAIL_PREF) || | 83 | qualifiers.contains(VCARD_EMAIL_PREF) || |
84 | qualifiers.contains(VCARD_EMAIL_X400) | 84 | qualifiers.contains(VCARD_EMAIL_X400) |
85 | ) ) | 85 | ) ) |
86 | return true; | 86 | return true; |
87 | break; | 87 | break; |
88 | 88 | ||
89 | case 'f': | 89 | case 'f': |
90 | if ( name == VCARD_FN ) | 90 | if ( name == VCARD_FN ) |
91 | return true; | 91 | return true; |
92 | break; | 92 | break; |
93 | 93 | ||
94 | case 'g': | 94 | case 'g': |
95 | if ( name == VCARD_GEO ) | 95 | if ( name == VCARD_GEO ) |
96 | return true; | 96 | return true; |
97 | break; | 97 | break; |
98 | 98 | ||
99 | case 'k': | 99 | case 'k': |
100 | if ( name == VCARD_KEY && qualified && | 100 | if ( name == VCARD_KEY && qualified && |
101 | (qualifiers.contains(VCARD_KEY_X509) || | 101 | (qualifiers.contains(VCARD_KEY_X509) || |
102 | qualifiers.contains(VCARD_KEY_PGP) | 102 | qualifiers.contains(VCARD_KEY_PGP) |
103 | ) ) | 103 | ) ) |
104 | return true; | 104 | return true; |
105 | break; | 105 | break; |
106 | 106 | ||
107 | case 'l': | 107 | case 'l': |
108 | if ( name == VCARD_LABEL ) | 108 | if ( name == VCARD_LABEL ) |
109 | return true; | 109 | return true; |
110 | if ( name == VCARD_LOGO ) | 110 | if ( name == VCARD_LOGO ) |
111 | return true; | 111 | return true; |
112 | break; | 112 | break; |
113 | 113 | ||
114 | case 'm': | 114 | case 'm': |
115 | if ( name == VCARD_MAILER ) | 115 | if ( name == VCARD_MAILER ) |
116 | return true; | 116 | return true; |
117 | break; | 117 | break; |
118 | 118 | ||
119 | case 'n': | 119 | case 'n': |
120 | if ( name == VCARD_N ) | 120 | if ( name == VCARD_N ) |
121 | return true; | 121 | return true; |
122 | if ( name == VCARD_NAME ) | 122 | if ( name == VCARD_NAME ) |
123 | return true; | 123 | return true; |
124 | if ( name == VCARD_NICKNAME ) | 124 | if ( name == VCARD_NICKNAME ) |
125 | return true; | 125 | return true; |
126 | if ( name == VCARD_NOTE ) | 126 | if ( name == VCARD_NOTE ) |
127 | return true; | 127 | return true; |
128 | break; | 128 | break; |
129 | 129 | ||
130 | case 'o': | 130 | case 'o': |
131 | if ( name == VCARD_ORG ) | 131 | if ( name == VCARD_ORG ) |
132 | return true; | 132 | return true; |
133 | break; | 133 | break; |
134 | 134 | ||
135 | case 'p': | 135 | case 'p': |
136 | if ( name == VCARD_PHOTO ) | 136 | if ( name == VCARD_PHOTO ) |
137 | return true; | 137 | return true; |
138 | if ( name == VCARD_PROFILE ) | 138 | if ( name == VCARD_PROFILE ) |
139 | return true; | 139 | return true; |
140 | if ( name == VCARD_PRODID ) | 140 | if ( name == VCARD_PRODID ) |
141 | return true; | 141 | return true; |
142 | break; | 142 | break; |
143 | 143 | ||
144 | case 'r': | 144 | case 'r': |
145 | if ( name == VCARD_ROLE ) | 145 | if ( name == VCARD_ROLE ) |
146 | return true; | 146 | return true; |
147 | if ( name == VCARD_REV ) | 147 | if ( name == VCARD_REV ) |
148 | return true; | 148 | return true; |
149 | break; | 149 | break; |
150 | 150 | ||
151 | case 's': | 151 | case 's': |
152 | if ( name == VCARD_SOURCE ) | 152 | if ( name == VCARD_SOURCE ) |
153 | return true; | 153 | return true; |
154 | if ( name == VCARD_SOUND ) | 154 | if ( name == VCARD_SOUND ) |
155 | return true; | 155 | return true; |
156 | break; | 156 | break; |
157 | 157 | ||
158 | case 't': | 158 | case 't': |
159 | if ( name == VCARD_TEL && qualified && | 159 | if ( name == VCARD_TEL && qualified && |
160 | (qualifiers.contains(VCARD_TEL_HOME) || | 160 | (qualifiers.contains(VCARD_TEL_HOME) || |
161 | qualifiers.contains(VCARD_TEL_WORK) || | 161 | qualifiers.contains(VCARD_TEL_WORK) || |
162 | qualifiers.contains(VCARD_TEL_PREF) || | 162 | qualifiers.contains(VCARD_TEL_PREF) || |
163 | qualifiers.contains(VCARD_TEL_VOICE) || | 163 | qualifiers.contains(VCARD_TEL_VOICE) || |
164 | qualifiers.contains(VCARD_TEL_FAX) || | 164 | qualifiers.contains(VCARD_TEL_FAX) || |
165 | qualifiers.contains(VCARD_TEL_MSG) || | 165 | qualifiers.contains(VCARD_TEL_MSG) || |
166 | qualifiers.contains(VCARD_TEL_CELL) || | 166 | qualifiers.contains(VCARD_TEL_CELL) || |
167 | qualifiers.contains(VCARD_TEL_PAGER) || | 167 | qualifiers.contains(VCARD_TEL_PAGER) || |
168 | qualifiers.contains(VCARD_TEL_BBS) || | 168 | qualifiers.contains(VCARD_TEL_BBS) || |
169 | qualifiers.contains(VCARD_TEL_MODEM) || | 169 | qualifiers.contains(VCARD_TEL_MODEM) || |
170 | qualifiers.contains(VCARD_TEL_CAR) || | 170 | qualifiers.contains(VCARD_TEL_CAR) || |
171 | qualifiers.contains(VCARD_TEL_ISDN) || | 171 | qualifiers.contains(VCARD_TEL_ISDN) || |
172 | qualifiers.contains(VCARD_TEL_VIDEO) || | 172 | qualifiers.contains(VCARD_TEL_VIDEO) || |
173 | qualifiers.contains(VCARD_TEL_PCS) | 173 | qualifiers.contains(VCARD_TEL_PCS) || |
174 | qualifiers.contains(VCARD_TEL_SIP) | ||
174 | ) ) | 175 | ) ) |
175 | return true; | 176 | return true; |
176 | if ( name == VCARD_TZ ) | 177 | if ( name == VCARD_TZ ) |
177 | return true; | 178 | return true; |
178 | if ( name == VCARD_TITLE ) | 179 | if ( name == VCARD_TITLE ) |
179 | return true; | 180 | return true; |
180 | break; | 181 | break; |
181 | 182 | ||
182 | case 'u': | 183 | case 'u': |
183 | if ( name == VCARD_URL ) | 184 | if ( name == VCARD_URL ) |
184 | return true; | 185 | return true; |
185 | if ( name == VCARD_UID ) | 186 | if ( name == VCARD_UID ) |
186 | return true; | 187 | return true; |
187 | break; | 188 | break; |
188 | 189 | ||
189 | case 'v': | 190 | case 'v': |
190 | if ( name == VCARD_VERSION ) | 191 | if ( name == VCARD_VERSION ) |
191 | return true; | 192 | return true; |
192 | break; | 193 | break; |
193 | default: | 194 | default: |
194 | break; | 195 | break; |
195 | } | 196 | } |
196 | 197 | ||
197 | return false; | 198 | return false; |
198 | } | 199 | } |
199 | 200 | ||
200 | 201 | ||
201 | VCard21Parser::VCard21Parser() | 202 | VCard21Parser::VCard21Parser() |
202 | { | 203 | { |
203 | } | 204 | } |
204 | 205 | ||
205 | VCard21Parser::~VCard21Parser() | 206 | VCard21Parser::~VCard21Parser() |
206 | { | 207 | { |
207 | } | 208 | } |
208 | 209 | ||
209 | void VCard21Parser::readFromString(KABC::AddressBook *addressbook, const QString &data) | 210 | void VCard21Parser::readFromString(KABC::AddressBook *addressbook, const QString &data) |
210 | { | 211 | { |
211 | KABC::Addressee mAddressee = readFromString(data); | 212 | KABC::Addressee mAddressee = readFromString(data); |
212 | addressbook->insertAddressee(mAddressee); | 213 | addressbook->insertAddressee(mAddressee); |
213 | } | 214 | } |
214 | 215 | ||
215 | KABC::Addressee VCard21Parser::readFromString( const QString &data) | 216 | KABC::Addressee VCard21Parser::readFromString( const QString &data) |
216 | { | 217 | { |
217 | KABC::Addressee addressee; | 218 | KABC::Addressee addressee; |
218 | VCard21ParserImpl *mVCard = VCard21ParserImpl::parseVCard(data); | 219 | VCard21ParserImpl *mVCard = VCard21ParserImpl::parseVCard(data); |
219 | QString tmpStr; | 220 | QString tmpStr; |
220 | 221 | ||
221 | // Check if parsing failed | 222 | // Check if parsing failed |
222 | if (mVCard == 0) | 223 | if (mVCard == 0) |
223 | { | 224 | { |
224 | kdDebug() << "Parsing failed" << endl; | 225 | kdDebug() << "Parsing failed" << endl; |
225 | return addressee; | 226 | return addressee; |
226 | } | 227 | } |
227 | //set the addressees name and formated name | 228 | //set the addressees name and formated name |
228 | QStringList tmpList = mVCard->getValues(VCARD_N); | 229 | QStringList tmpList = mVCard->getValues(VCARD_N); |
229 | QString formattedName = ""; | 230 | QString formattedName = ""; |
230 | if (tmpList.count() > 0) | 231 | if (tmpList.count() > 0) |
231 | addressee.setFamilyName(tmpList[0]); | 232 | addressee.setFamilyName(tmpList[0]); |
232 | if (tmpList.count() > 1) | 233 | if (tmpList.count() > 1) |
233 | addressee.setGivenName(tmpList[1]); | 234 | addressee.setGivenName(tmpList[1]); |
234 | if (tmpList.count() > 2) | 235 | if (tmpList.count() > 2) |
235 | addressee.setAdditionalName(tmpList[2]); | 236 | addressee.setAdditionalName(tmpList[2]); |
236 | if (tmpList.count() > 3) | 237 | if (tmpList.count() > 3) |
237 | addressee.setPrefix(tmpList[3]); | 238 | addressee.setPrefix(tmpList[3]); |
238 | if (tmpList.count() > 4) | 239 | if (tmpList.count() > 4) |
239 | addressee.setSuffix(tmpList[4]); | 240 | addressee.setSuffix(tmpList[4]); |
240 | 241 | ||
241 | tmpStr = (mVCard->getValue(VCARD_FN)); | 242 | tmpStr = (mVCard->getValue(VCARD_FN)); |
242 | if (!tmpStr.isEmpty()) | 243 | if (!tmpStr.isEmpty()) |
243 | addressee.setFormattedName(tmpStr); | 244 | addressee.setFormattedName(tmpStr); |
244 | 245 | ||
245 | //set the addressee's nick name | 246 | //set the addressee's nick name |
246 | tmpStr = mVCard->getValue(VCARD_NICKNAME); | 247 | tmpStr = mVCard->getValue(VCARD_NICKNAME); |
247 | addressee.setNickName(tmpStr); | 248 | addressee.setNickName(tmpStr); |
248 | //set the addressee's organisation | 249 | //set the addressee's organisation |
249 | tmpStr = mVCard->getValue(VCARD_ORG); | 250 | tmpStr = mVCard->getValue(VCARD_ORG); |
250 | addressee.setOrganization(tmpStr); | 251 | addressee.setOrganization(tmpStr); |
251 | //set the addressee's title | 252 | //set the addressee's title |
252 | tmpStr = mVCard->getValue(VCARD_TITLE); | 253 | tmpStr = mVCard->getValue(VCARD_TITLE); |
253 | addressee.setTitle(tmpStr); | 254 | addressee.setTitle(tmpStr); |
254 | //set the addressee's email - we can only deal with two. The preferenced one and one other. | 255 | //set the addressee's email - we can only deal with two. The preferenced one and one other. |
255 | tmpStr = mVCard->getValue(VCARD_EMAIL, VCARD_EMAIL_INTERNET); | 256 | tmpStr = mVCard->getValue(VCARD_EMAIL, VCARD_EMAIL_INTERNET); |
256 | addressee.insertEmail(tmpStr, false); | 257 | addressee.insertEmail(tmpStr, false); |
257 | tmpStr = mVCard->getValue(VCARD_EMAIL,VCARD_EMAIL_PREF); | 258 | tmpStr = mVCard->getValue(VCARD_EMAIL,VCARD_EMAIL_PREF); |
258 | addressee.insertEmail(tmpStr, true); | 259 | addressee.insertEmail(tmpStr, true); |
259 | //set the addressee's url | 260 | //set the addressee's url |
260 | tmpStr = mVCard->getValue(VCARD_URL); | 261 | tmpStr = mVCard->getValue(VCARD_URL); |
261 | if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_WORK); | 262 | if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_WORK); |
262 | if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_HOME); | 263 | if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_HOME); |
263 | if (!tmpStr.isEmpty()) { | 264 | if (!tmpStr.isEmpty()) { |
264 | addressee.setUrl(KURL(tmpStr)); | 265 | addressee.setUrl(KURL(tmpStr)); |
265 | } | 266 | } |
266 | 267 | ||
267 | //set the addressee's birthday | 268 | //set the addressee's birthday |
268 | tmpStr = mVCard->getValue(VCARD_BDAY); | 269 | tmpStr = mVCard->getValue(VCARD_BDAY); |
269 | addressee.setBirthday(VCardStringToDate(tmpStr)); | 270 | addressee.setBirthday(VCardStringToDate(tmpStr)); |
270 | 271 | ||
271 | //set the addressee's phone numbers | 272 | //set the addressee's phone numbers |
272 | for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { | 273 | for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { |
273 | if ( (*i).name == VCARD_TEL ) { | 274 | if ( (*i).name == VCARD_TEL ) { |
274 | int type = 0; | 275 | int type = 0; |
275 | if ( (*i).qualified ) { | 276 | if ( (*i).qualified ) { |
276 | if ( (*i).qualifiers.contains( VCARD_TEL_HOME ) ) | 277 | if ( (*i).qualifiers.contains( VCARD_TEL_HOME ) ) |
277 | type |= PhoneNumber::Home; | 278 | type |= PhoneNumber::Home; |
278 | if ( (*i).qualifiers.contains( VCARD_TEL_WORK ) ) | 279 | if ( (*i).qualifiers.contains( VCARD_TEL_WORK ) ) |
279 | type |= PhoneNumber::Work; | 280 | type |= PhoneNumber::Work; |
280 | if ( (*i).qualifiers.contains( VCARD_TEL_PREF ) ) | 281 | if ( (*i).qualifiers.contains( VCARD_TEL_PREF ) ) |
281 | type |= PhoneNumber::Pref; | 282 | type |= PhoneNumber::Pref; |
282 | // if ( (*i).qualifiers.contains( VCARD_TEL_VOICE ) ) | 283 | // if ( (*i).qualifiers.contains( VCARD_TEL_VOICE ) ) |
283 | // type |= PhoneNumber::Voice; | 284 | // type |= PhoneNumber::Voice; |
284 | if ( (*i).qualifiers.contains( VCARD_TEL_FAX ) ) | 285 | if ( (*i).qualifiers.contains( VCARD_TEL_FAX ) ) |
285 | type |= PhoneNumber::Fax; | 286 | type |= PhoneNumber::Fax; |
286 | if ( (*i).qualifiers.contains( VCARD_TEL_MSG ) ) | 287 | if ( (*i).qualifiers.contains( VCARD_TEL_MSG ) ) |
287 | type |= PhoneNumber::Msg; | 288 | type |= PhoneNumber::Msg; |
288 | if ( (*i).qualifiers.contains( VCARD_TEL_CELL ) ) | 289 | if ( (*i).qualifiers.contains( VCARD_TEL_CELL ) ) |
289 | type |= PhoneNumber::Cell; | 290 | type |= PhoneNumber::Cell; |
290 | if ( (*i).qualifiers.contains( VCARD_TEL_PAGER ) ) | 291 | if ( (*i).qualifiers.contains( VCARD_TEL_PAGER ) ) |
291 | type |= PhoneNumber::Pager; | 292 | type |= PhoneNumber::Pager; |
292 | if ( (*i).qualifiers.contains( VCARD_TEL_BBS ) ) | 293 | if ( (*i).qualifiers.contains( VCARD_TEL_BBS ) ) |
293 | type |= PhoneNumber::Bbs; | 294 | type |= PhoneNumber::Bbs; |
294 | if ( (*i).qualifiers.contains( VCARD_TEL_MODEM ) ) | 295 | if ( (*i).qualifiers.contains( VCARD_TEL_MODEM ) ) |
295 | type |= PhoneNumber::Modem; | 296 | type |= PhoneNumber::Modem; |
296 | if ( (*i).qualifiers.contains( VCARD_TEL_CAR ) ) | 297 | if ( (*i).qualifiers.contains( VCARD_TEL_CAR ) ) |
297 | type |= PhoneNumber::Car; | 298 | type |= PhoneNumber::Car; |
298 | if ( (*i).qualifiers.contains( VCARD_TEL_ISDN ) ) | 299 | if ( (*i).qualifiers.contains( VCARD_TEL_ISDN ) ) |
299 | type |= PhoneNumber::Isdn; | 300 | type |= PhoneNumber::Isdn; |
300 | if ( (*i).qualifiers.contains( VCARD_TEL_VIDEO ) ) | 301 | if ( (*i).qualifiers.contains( VCARD_TEL_VIDEO ) ) |
301 | type |= PhoneNumber::Video; | 302 | type |= PhoneNumber::Video; |
302 | if ( (*i).qualifiers.contains( VCARD_TEL_PCS ) ) | 303 | if ( (*i).qualifiers.contains( VCARD_TEL_PCS ) ) |
303 | type |= PhoneNumber::Pcs; | 304 | type |= PhoneNumber::Pcs; |
305 | if ( (*i).qualifiers.contains( VCARD_TEL_SIP ) ) | ||
306 | type |= PhoneNumber::Sip; | ||
304 | } | 307 | } |
305 | addressee.insertPhoneNumber( PhoneNumber( (*i).parameters[ 0 ], type ) ); | 308 | addressee.insertPhoneNumber( PhoneNumber( (*i).parameters[ 0 ], type ) ); |
306 | } | 309 | } |
307 | } | 310 | } |
308 | 311 | ||
309 | //set the addressee's addresses | 312 | //set the addressee's addresses |
310 | for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { | 313 | for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { |
311 | if ( (*i).name == VCARD_ADR ) { | 314 | if ( (*i).name == VCARD_ADR ) { |
312 | int type = 0; | 315 | int type = 0; |
313 | if ( (*i).qualified ) { | 316 | if ( (*i).qualified ) { |
314 | if ( (*i).qualifiers.contains( VCARD_ADR_DOM ) ) | 317 | if ( (*i).qualifiers.contains( VCARD_ADR_DOM ) ) |
315 | type |= Address::Dom; | 318 | type |= Address::Dom; |
316 | if ( (*i).qualifiers.contains( VCARD_ADR_INTL ) ) | 319 | if ( (*i).qualifiers.contains( VCARD_ADR_INTL ) ) |
317 | type |= Address::Intl; | 320 | type |= Address::Intl; |
318 | if ( (*i).qualifiers.contains( VCARD_ADR_POSTAL ) ) | 321 | if ( (*i).qualifiers.contains( VCARD_ADR_POSTAL ) ) |
319 | type |= Address::Postal; | 322 | type |= Address::Postal; |
320 | if ( (*i).qualifiers.contains( VCARD_ADR_PARCEL ) ) | 323 | if ( (*i).qualifiers.contains( VCARD_ADR_PARCEL ) ) |
321 | type |= Address::Parcel; | 324 | type |= Address::Parcel; |
322 | if ( (*i).qualifiers.contains( VCARD_ADR_HOME ) ) | 325 | if ( (*i).qualifiers.contains( VCARD_ADR_HOME ) ) |
323 | type |= Address::Home; | 326 | type |= Address::Home; |
324 | if ( (*i).qualifiers.contains( VCARD_ADR_WORK ) ) | 327 | if ( (*i).qualifiers.contains( VCARD_ADR_WORK ) ) |
325 | type |= Address::Work; | 328 | type |= Address::Work; |
326 | if ( (*i).qualifiers.contains( VCARD_ADR_PREF ) ) | 329 | if ( (*i).qualifiers.contains( VCARD_ADR_PREF ) ) |
327 | type |= Address::Pref; | 330 | type |= Address::Pref; |
328 | } | 331 | } |
329 | addressee.insertAddress( readAddressFromQStringList( (*i).parameters, type ) ); | 332 | addressee.insertAddress( readAddressFromQStringList( (*i).parameters, type ) ); |
330 | } | 333 | } |
331 | } | 334 | } |
332 | 335 | ||
333 | //set the addressee's delivery label | 336 | //set the addressee's delivery label |
334 | tmpStr = mVCard->getValue(VCARD_LABEL); | 337 | tmpStr = mVCard->getValue(VCARD_LABEL); |
335 | if (!tmpStr.isEmpty()) { | 338 | if (!tmpStr.isEmpty()) { |
336 | qDebug("VCard21Parser::readFromString please verify if replace is correct"); | 339 | qDebug("VCard21Parser::readFromString please verify if replace is correct"); |
337 | //US tmpStr.replace("\r\n","\n"); | 340 | //US tmpStr.replace("\r\n","\n"); |
338 | tmpStr.replace( QRegExp("\r\n"), "\n" ); | 341 | tmpStr.replace( QRegExp("\r\n"), "\n" ); |
339 | Address tmpAddress; | 342 | Address tmpAddress; |
340 | tmpAddress.setLabel(tmpStr); | 343 | tmpAddress.setLabel(tmpStr); |
341 | addressee.insertAddress(tmpAddress); | 344 | addressee.insertAddress(tmpAddress); |
342 | } | 345 | } |
343 | 346 | ||
344 | //set the addressee's notes | 347 | //set the addressee's notes |
345 | tmpStr = mVCard->getValue(VCARD_NOTE); | 348 | tmpStr = mVCard->getValue(VCARD_NOTE); |
346 | qDebug("VCard21Parser::readFromString please verify if correct"); | 349 | qDebug("VCard21Parser::readFromString please verify if correct"); |
347 | //US tmpStr.replace("\r\n","\n"); | 350 | //US tmpStr.replace("\r\n","\n"); |
348 | tmpStr.replace( QRegExp("\r\n"), "\n" ); | 351 | tmpStr.replace( QRegExp("\r\n"), "\n" ); |
349 | addressee.setNote(tmpStr); | 352 | addressee.setNote(tmpStr); |
350 | 353 | ||
351 | //set the addressee's timezone | 354 | //set the addressee's timezone |
352 | tmpStr = mVCard->getValue(VCARD_TZ); | 355 | tmpStr = mVCard->getValue(VCARD_TZ); |
353 | TimeZone tmpZone(tmpStr.toInt()); | 356 | TimeZone tmpZone(tmpStr.toInt()); |
354 | addressee.setTimeZone(tmpZone); | 357 | addressee.setTimeZone(tmpZone); |
355 | 358 | ||
356 | //set the addressee's geographical position | 359 | //set the addressee's geographical position |
357 | tmpList = mVCard->getValues(VCARD_GEO); | 360 | tmpList = mVCard->getValues(VCARD_GEO); |
358 | if (tmpList.count()==2) | 361 | if (tmpList.count()==2) |
359 | { | 362 | { |
360 | tmpStr = tmpList[0]; | 363 | tmpStr = tmpList[0]; |
361 | float glat = tmpStr.toFloat(); | 364 | float glat = tmpStr.toFloat(); |
362 | tmpStr = tmpList[1]; | 365 | tmpStr = tmpList[1]; |
363 | float glong = tmpStr.toFloat(); | 366 | float glong = tmpStr.toFloat(); |
364 | Geo tmpGeo(glat,glong); | 367 | Geo tmpGeo(glat,glong); |
365 | addressee.setGeo(tmpGeo); | 368 | addressee.setGeo(tmpGeo); |
366 | } | 369 | } |
367 | 370 | ||
368 | //set the last revision date | 371 | //set the last revision date |
369 | tmpStr = mVCard->getValue(VCARD_REV); | 372 | tmpStr = mVCard->getValue(VCARD_REV); |
370 | addressee.setRevision(VCardStringToDate(tmpStr)); | 373 | addressee.setRevision(VCardStringToDate(tmpStr)); |
371 | 374 | ||
372 | //set the role of the addressee | 375 | //set the role of the addressee |
373 | tmpStr = mVCard->getValue(VCARD_ROLE); | 376 | tmpStr = mVCard->getValue(VCARD_ROLE); |
374 | addressee.setRole(tmpStr); | 377 | addressee.setRole(tmpStr); |
375 | 378 | ||
376 | return addressee; | 379 | return addressee; |
377 | } | 380 | } |
378 | 381 | ||
379 | 382 | ||
380 | 383 | ||
381 | KABC::Address VCard21Parser::readAddressFromQStringList ( const QStringList &data, const int type ) | 384 | KABC::Address VCard21Parser::readAddressFromQStringList ( const QStringList &data, const int type ) |
382 | { | 385 | { |
383 | KABC::Address mAddress; | 386 | KABC::Address mAddress; |
384 | mAddress.setType( type ); | 387 | mAddress.setType( type ); |
385 | 388 | ||
386 | if ( data.count() > 0 ) | 389 | if ( data.count() > 0 ) |
387 | mAddress.setPostOfficeBox( data[0] ); | 390 | mAddress.setPostOfficeBox( data[0] ); |
388 | if ( data.count() > 1 ) | 391 | if ( data.count() > 1 ) |
389 | mAddress.setExtended( data[1] ); | 392 | mAddress.setExtended( data[1] ); |
390 | if ( data.count() > 2 ) | 393 | if ( data.count() > 2 ) |
391 | mAddress.setStreet( data[2] ); | 394 | mAddress.setStreet( data[2] ); |
392 | if ( data.count() > 3 ) | 395 | if ( data.count() > 3 ) |
393 | mAddress.setLocality( data[3] ); | 396 | mAddress.setLocality( data[3] ); |
394 | if ( data.count() > 4 ) | 397 | if ( data.count() > 4 ) |
395 | mAddress.setRegion( data[4] ); | 398 | mAddress.setRegion( data[4] ); |
396 | if ( data.count() > 5 ) | 399 | if ( data.count() > 5 ) |
397 | mAddress.setPostalCode( data[5] ); | 400 | mAddress.setPostalCode( data[5] ); |
398 | if ( data.count() > 6 ) | 401 | if ( data.count() > 6 ) |
399 | mAddress.setCountry( data[6] ); | 402 | mAddress.setCountry( data[6] ); |
400 | 403 | ||
401 | return mAddress; | 404 | return mAddress; |
402 | } | 405 | } |
403 | 406 | ||
404 | 407 | ||
405 | VCard21ParserImpl *VCard21ParserImpl::parseVCard( const QString& vc, int *err ) | 408 | VCard21ParserImpl *VCard21ParserImpl::parseVCard( const QString& vc, int *err ) |
406 | { | 409 | { |
407 | int _err = 0; | 410 | int _err = 0; |
408 | int _state = VC_STATE_BEGIN; | 411 | int _state = VC_STATE_BEGIN; |
409 | 412 | ||
410 | QValueList<VCardLineX> *_vcdata; | 413 | QValueList<VCardLineX> *_vcdata; |
411 | QValueList<QString> lines; | 414 | QValueList<QString> lines; |
412 | 415 | ||
413 | _vcdata = new QValueList<VCardLineX>; | 416 | _vcdata = new QValueList<VCardLineX>; |
414 | 417 | ||
415 | lines = QStringList::split( QRegExp( "[\x0d\x0a]" ), vc ); | 418 | lines = QStringList::split( QRegExp( "[\x0d\x0a]" ), vc ); |
416 | 419 | ||
417 | // for each line in the vCard | 420 | // for each line in the vCard |
418 | for ( QStringList::Iterator j = lines.begin(); j != lines.end(); ++j ) { | 421 | for ( QStringList::Iterator j = lines.begin(); j != lines.end(); ++j ) { |
419 | VCardLineX _vcl; | 422 | VCardLineX _vcl; |
420 | 423 | ||
421 | // take spaces off the end - ugly but necessary hack | 424 | // take spaces off the end - ugly but necessary hack |
422 | for ( int g = (*j).length()-1; g > 0 && (*j)[g].isSpace(); --g ) | 425 | for ( int g = (*j).length()-1; g > 0 && (*j)[g].isSpace(); --g ) |
423 | (*j)[g] = 0; | 426 | (*j)[g] = 0; |
424 | 427 | ||
425 | // first token: | 428 | // first token: |
426 | // verify state, update if necessary | 429 | // verify state, update if necessary |
427 | if ( _state & VC_STATE_BEGIN) { | 430 | if ( _state & VC_STATE_BEGIN) { |
428 | if ( !qstricmp( (*j).latin1(), VCARD_BEGIN ) ) { | 431 | if ( !qstricmp( (*j).latin1(), VCARD_BEGIN ) ) { |
429 | _state = VC_STATE_BODY; | 432 | _state = VC_STATE_BODY; |
430 | continue; | 433 | continue; |
431 | } else { | 434 | } else { |
432 | _err = VC_ERR_NO_BEGIN; | 435 | _err = VC_ERR_NO_BEGIN; |
433 | break; | 436 | break; |
434 | } | 437 | } |
435 | } else if ( _state & VC_STATE_BODY ) { | 438 | } else if ( _state & VC_STATE_BODY ) { |
436 | if ( !qstricmp( (*j).latin1(), VCARD_END ) ) { | 439 | if ( !qstricmp( (*j).latin1(), VCARD_END ) ) { |
437 | _state |= VC_STATE_END; | 440 | _state |= VC_STATE_END; |
438 | break; | 441 | break; |
439 | } | 442 | } |
440 | 443 | ||
441 | // split into two tokens | 444 | // split into two tokens |
442 | int colon = (*j).find( ':' ); | 445 | int colon = (*j).find( ':' ); |
443 | if ( colon < 0 ) { | 446 | if ( colon < 0 ) { |
444 | _err = VC_ERR_INVALID_LINE; | 447 | _err = VC_ERR_INVALID_LINE; |
445 | break; | 448 | break; |
446 | } | 449 | } |
447 | 450 | ||
448 | QString key = (*j).left( colon ); | 451 | QString key = (*j).left( colon ); |
449 | QString value = (*j).mid( colon + 1 ); | 452 | QString value = (*j).mid( colon + 1 ); |
450 | 453 | ||
451 | // check for qualifiers and | 454 | // check for qualifiers and |
452 | // set name, qualified, qualifier(s) | 455 | // set name, qualified, qualifier(s) |
453 | QStringList keyTokens = QStringList::split( ';', key ); | 456 | QStringList keyTokens = QStringList::split( ';', key ); |
454 | bool qp = false, first_pass = true; | 457 | bool qp = false, first_pass = true; |
455 | bool b64 = false; | 458 | bool b64 = false; |
456 | 459 | ||
457 | if ( keyTokens.count() > 0 ) { | 460 | if ( keyTokens.count() > 0 ) { |
458 | _vcl.qualified = false; | 461 | _vcl.qualified = false; |
459 | _vcl.name = keyTokens[ 0 ].lower(); | 462 | _vcl.name = keyTokens[ 0 ].lower(); |
460 | 463 | ||
461 | for ( QStringList::Iterator z = keyTokens.begin(); z != keyTokens.end(); ++z ) { | 464 | for ( QStringList::Iterator z = keyTokens.begin(); z != keyTokens.end(); ++z ) { |
462 | QString zz = (*z).lower(); | 465 | QString zz = (*z).lower(); |
463 | if ( zz == VCARD_QUOTED_PRINTABLE || zz == VCARD_ENCODING_QUOTED_PRINTABLE ) { | 466 | if ( zz == VCARD_QUOTED_PRINTABLE || zz == VCARD_ENCODING_QUOTED_PRINTABLE ) { |
464 | qp = true; | 467 | qp = true; |
465 | } else if ( zz == VCARD_BASE64 ) { | 468 | } else if ( zz == VCARD_BASE64 ) { |
466 | b64 = true; | 469 | b64 = true; |
467 | } else if ( !first_pass ) { | 470 | } else if ( !first_pass ) { |
468 | _vcl.qualified = true; | 471 | _vcl.qualified = true; |
469 | _vcl.qualifiers.append( zz ); | 472 | _vcl.qualifiers.append( zz ); |
470 | } | 473 | } |
471 | first_pass = false; | 474 | first_pass = false; |
472 | } | 475 | } |
473 | } else { | 476 | } else { |
474 | _err = VC_ERR_INVALID_LINE; | 477 | _err = VC_ERR_INVALID_LINE; |
475 | } | 478 | } |
476 | 479 | ||
477 | if ( _err != 0 ) | 480 | if ( _err != 0 ) |
478 | break; | 481 | break; |
479 | 482 | ||
480 | if ( _vcl.name == VCARD_VERSION ) | 483 | if ( _vcl.name == VCARD_VERSION ) |
481 | _state |= VC_STATE_HAVE_VERSION; | 484 | _state |= VC_STATE_HAVE_VERSION; |
482 | 485 | ||
483 | if ( _vcl.name == VCARD_N || _vcl.name == VCARD_FN ) | 486 | if ( _vcl.name == VCARD_N || _vcl.name == VCARD_FN ) |
484 | _state |= VC_STATE_HAVE_N; | 487 | _state |= VC_STATE_HAVE_N; |
485 | 488 | ||
486 | // second token: | 489 | // second token: |
487 | // split into tokens by ; | 490 | // split into tokens by ; |
488 | // add to parameters vector | 491 | // add to parameters vector |
489 | if ( b64 ) { | 492 | if ( b64 ) { |
490 | if ( value.at( value.length() - 1 ) != '=' ) | 493 | if ( value.at( value.length() - 1 ) != '=' ) |
491 | do { | 494 | do { |
492 | value += *( ++j ); | 495 | value += *( ++j ); |
493 | } while ( (*j).at( (*j).length() - 1 ) != '=' ); | 496 | } while ( (*j).at( (*j).length() - 1 ) != '=' ); |
494 | } else { | 497 | } else { |
495 | if ( qp ) { // join any split lines | 498 | if ( qp ) { // join any split lines |
496 | while ( value.at( value.length() - 1 ) == '=' ) { | 499 | while ( value.at( value.length() - 1 ) == '=' ) { |
497 | value.remove( value.length() - 1, 1 ); | 500 | value.remove( value.length() - 1, 1 ); |
498 | value.append(*( ++j )); | 501 | value.append(*( ++j )); |
499 | } | 502 | } |
500 | } | 503 | } |
501 | _vcl.parameters = QStringList::split( ';', value, true ); | 504 | _vcl.parameters = QStringList::split( ';', value, true ); |
502 | if ( qp ) { // decode the quoted printable | 505 | if ( qp ) { // decode the quoted printable |
503 | for ( QStringList::Iterator z = _vcl.parameters.begin(); z != _vcl.parameters.end(); ++z ) | 506 | for ( QStringList::Iterator z = _vcl.parameters.begin(); z != _vcl.parameters.end(); ++z ) |
504 | *z = KCodecs::quotedPrintableDecode( (*z).latin1() ); | 507 | *z = KCodecs::quotedPrintableDecode( (*z).latin1() ); |
505 | } | 508 | } |
506 | } | 509 | } |
507 | } else { | 510 | } else { |
508 | _err = VC_ERR_INTERNAL; | 511 | _err = VC_ERR_INTERNAL; |
509 | break; | 512 | break; |
510 | } | 513 | } |
511 | 514 | ||
512 | // validate VCardLineX | 515 | // validate VCardLineX |
513 | if ( !_vcl.isValid() ) { | 516 | if ( !_vcl.isValid() ) { |
514 | _err = VC_ERR_INVALID_LINE; | 517 | _err = VC_ERR_INVALID_LINE; |
515 | break; | 518 | break; |
516 | } | 519 | } |
517 | 520 | ||
518 | // add to vector | 521 | // add to vector |
519 | _vcdata->append( _vcl ); | 522 | _vcdata->append( _vcl ); |
520 | } | 523 | } |
521 | 524 | ||
522 | // errors to check at the last minute (exit state related) | 525 | // errors to check at the last minute (exit state related) |
523 | if ( _err == 0 ) { | 526 | if ( _err == 0 ) { |
524 | if ( !( _state & VC_STATE_END ) ) // we have to have an end!! | 527 | if ( !( _state & VC_STATE_END ) ) // we have to have an end!! |
525 | _err = VC_ERR_NO_END; | 528 | _err = VC_ERR_NO_END; |
526 | 529 | ||
527 | if ( !( _state & VC_STATE_HAVE_N ) || // we have to have the mandatories! | 530 | if ( !( _state & VC_STATE_HAVE_N ) || // we have to have the mandatories! |
528 | !( _state & VC_STATE_HAVE_VERSION ) ) | 531 | !( _state & VC_STATE_HAVE_VERSION ) ) |
529 | _err = VC_ERR_MISSING_MANDATORY; | 532 | _err = VC_ERR_MISSING_MANDATORY; |
530 | } | 533 | } |
531 | 534 | ||
532 | // set the error message if we can, and only return an object | 535 | // set the error message if we can, and only return an object |
533 | // if the vCard was valid. | 536 | // if the vCard was valid. |
534 | if ( err ) | 537 | if ( err ) |
535 | *err = _err; | 538 | *err = _err; |
536 | 539 | ||
537 | if ( _err != 0 ) { | 540 | if ( _err != 0 ) { |
538 | delete _vcdata; | 541 | delete _vcdata; |
539 | return 0; | 542 | return 0; |
540 | } | 543 | } |
541 | 544 | ||
542 | return new VCard21ParserImpl( _vcdata ); | 545 | return new VCard21ParserImpl( _vcdata ); |
543 | } | 546 | } |
544 | 547 | ||
545 | VCard21ParserImpl::VCard21ParserImpl(QValueList<VCardLineX> *_vcd) : _vcdata(_vcd) | 548 | VCard21ParserImpl::VCard21ParserImpl(QValueList<VCardLineX> *_vcd) : _vcdata(_vcd) |
546 | { | 549 | { |
547 | } | 550 | } |
548 | 551 | ||
549 | 552 | ||
550 | QString VCard21ParserImpl::getValue(const QString& name, const QString& qualifier) | 553 | QString VCard21ParserImpl::getValue(const QString& name, const QString& qualifier) |
551 | { | 554 | { |
552 | QString failed; | 555 | QString failed; |
553 | const QString lowname = name.lower(); | 556 | const QString lowname = name.lower(); |
554 | const QString lowqualifier = qualifier.lower(); | 557 | const QString lowqualifier = qualifier.lower(); |
555 | 558 | ||
556 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { | 559 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { |
557 | if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier)) { | 560 | if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier)) { |
558 | if ((*i).parameters.count() > 0) | 561 | if ((*i).parameters.count() > 0) |
559 | return (*i).parameters[0]; | 562 | return (*i).parameters[0]; |
560 | else return failed; | 563 | else return failed; |
561 | } | 564 | } |
562 | } | 565 | } |
563 | return failed; | 566 | return failed; |
564 | } | 567 | } |
565 | 568 | ||
566 | 569 | ||
567 | QString VCard21ParserImpl::getValue(const QString& name) | 570 | QString VCard21ParserImpl::getValue(const QString& name) |
568 | { | 571 | { |
569 | QString failed; | 572 | QString failed; |
570 | const QString lowname = name.lower(); | 573 | const QString lowname = name.lower(); |
571 | 574 | ||
572 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { | 575 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { |
573 | if ((*i).name == lowname && !(*i).qualified) { | 576 | if ((*i).name == lowname && !(*i).qualified) { |
574 | if ((*i).parameters.count() > 0) | 577 | if ((*i).parameters.count() > 0) |
575 | return (*i).parameters[0]; | 578 | return (*i).parameters[0]; |
576 | else return failed; | 579 | else return failed; |
577 | } | 580 | } |
578 | } | 581 | } |
579 | return failed; | 582 | return failed; |
580 | } | 583 | } |
581 | 584 | ||
582 | 585 | ||
583 | QStringList VCard21ParserImpl::getValues(const QString& name) | 586 | QStringList VCard21ParserImpl::getValues(const QString& name) |
584 | { | 587 | { |
585 | const QString lowname = name.lower(); | 588 | const QString lowname = name.lower(); |
586 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { | 589 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { |
587 | if ((*i).name == lowname && !(*i).qualified) | 590 | if ((*i).name == lowname && !(*i).qualified) |
588 | return (*i).parameters; | 591 | return (*i).parameters; |
589 | } | 592 | } |
590 | // failed. | 593 | // failed. |
591 | return QStringList(); | 594 | return QStringList(); |
592 | } | 595 | } |
593 | 596 | ||
594 | QStringList VCard21ParserImpl::getValues(const QString& name, const QString& qualifier) | 597 | QStringList VCard21ParserImpl::getValues(const QString& name, const QString& qualifier) |
595 | { | 598 | { |
596 | const QString lowname = name.lower(); | 599 | const QString lowname = name.lower(); |
597 | const QString lowqualifier = qualifier.lower(); | 600 | const QString lowqualifier = qualifier.lower(); |
598 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { | 601 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { |
599 | if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier)) | 602 | if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier)) |
600 | return (*i).parameters; | 603 | return (*i).parameters; |
601 | } | 604 | } |
602 | // failed. | 605 | // failed. |
603 | return QStringList(); | 606 | return QStringList(); |
604 | } | 607 | } |
605 | 608 | ||
606 | 609 | ||
diff --git a/kabc/vcard21parser.h b/kabc/vcard21parser.h index 24b0eb2..77e69b6 100644 --- a/kabc/vcard21parser.h +++ b/kabc/vcard21parser.h | |||
@@ -1,225 +1,226 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | 3 | ||
4 | Copyright (c) 2002 Mark Westcott <mark@houseoffish.org> | 4 | Copyright (c) 2002 Mark Westcott <mark@houseoffish.org> |
5 | Copyright (c) 2000 George Staikos <staikos@kde.org> | 5 | Copyright (c) 2000 George Staikos <staikos@kde.org> |
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef KABC_VCARD21FORMAT_H | 29 | #ifndef KABC_VCARD21FORMAT_H |
30 | #define KABC_VCARD21FORMAT_H | 30 | #define KABC_VCARD21FORMAT_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <kdebug.h> | 33 | #include <kdebug.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | #include <qstring.h> | 35 | #include <qstring.h> |
36 | #include <kurl.h> | 36 | #include <kurl.h> |
37 | #include <qvaluelist.h> | 37 | #include <qvaluelist.h> |
38 | 38 | ||
39 | #include "addressee.h" | 39 | #include "addressee.h" |
40 | #include "addressbook.h" | 40 | #include "addressbook.h" |
41 | #include "phonenumber.h" | 41 | #include "phonenumber.h" |
42 | 42 | ||
43 | 43 | ||
44 | #define VCARD_BEGIN "begin:vcard" | 44 | #define VCARD_BEGIN "begin:vcard" |
45 | #define VCARD_END "end:vcard" | 45 | #define VCARD_END "end:vcard" |
46 | #define VCARD_BEGIN_N "begin" | 46 | #define VCARD_BEGIN_N "begin" |
47 | #define VCARD_END_N "end" | 47 | #define VCARD_END_N "end" |
48 | #define VCARD_VERSION "version" | 48 | #define VCARD_VERSION "version" |
49 | 49 | ||
50 | #define VCARD_FN "fn" | 50 | #define VCARD_FN "fn" |
51 | #define VCARD_N "n" | 51 | #define VCARD_N "n" |
52 | 52 | ||
53 | // optional | 53 | // optional |
54 | #define VCARD_NAME "name" | 54 | #define VCARD_NAME "name" |
55 | #define VCARD_NICKNAME "nickname" | 55 | #define VCARD_NICKNAME "nickname" |
56 | #define VCARD_PHOTO "photo" | 56 | #define VCARD_PHOTO "photo" |
57 | #define VCARD_BDAY "bday" | 57 | #define VCARD_BDAY "bday" |
58 | #define VCARD_ADR "adr" | 58 | #define VCARD_ADR "adr" |
59 | 59 | ||
60 | // types | 60 | // types |
61 | #define VCARD_ADR_DOM "dom" | 61 | #define VCARD_ADR_DOM "dom" |
62 | #define VCARD_ADR_INTL "intl" | 62 | #define VCARD_ADR_INTL "intl" |
63 | #define VCARD_ADR_POSTAL "postal" | 63 | #define VCARD_ADR_POSTAL "postal" |
64 | #define VCARD_ADR_PARCEL "parcel" | 64 | #define VCARD_ADR_PARCEL "parcel" |
65 | #define VCARD_ADR_HOME "home" | 65 | #define VCARD_ADR_HOME "home" |
66 | #define VCARD_ADR_WORK "work" | 66 | #define VCARD_ADR_WORK "work" |
67 | #define VCARD_ADR_PREF "pref" | 67 | #define VCARD_ADR_PREF "pref" |
68 | // values | 68 | // values |
69 | #define VCARD_ADR_POBOX "PO Box" | 69 | #define VCARD_ADR_POBOX "PO Box" |
70 | #define VCARD_ADR_EXTADR "Extended Address" | 70 | #define VCARD_ADR_EXTADR "Extended Address" |
71 | #define VCARD_ADR_STREET "Street" | 71 | #define VCARD_ADR_STREET "Street" |
72 | #define VCARD_ADR_LOCALITY "Locality" | 72 | #define VCARD_ADR_LOCALITY "Locality" |
73 | #define VCARD_ADR_REGION "Region" | 73 | #define VCARD_ADR_REGION "Region" |
74 | #define VCARD_ADR_POSTCODE "Postal Code" | 74 | #define VCARD_ADR_POSTCODE "Postal Code" |
75 | #define VCARD_ADR_COUNTRY "Country Name" | 75 | #define VCARD_ADR_COUNTRY "Country Name" |
76 | #define VCARD_LABEL "label" | 76 | #define VCARD_LABEL "label" |
77 | #define VCARD_PROFILE "profile" | 77 | #define VCARD_PROFILE "profile" |
78 | #define VCARD_SOURCE "source" | 78 | #define VCARD_SOURCE "source" |
79 | #define VCARD_TEL "tel" | 79 | #define VCARD_TEL "tel" |
80 | // types | 80 | // types |
81 | #define VCARD_TEL_HOME "home" | 81 | #define VCARD_TEL_HOME "home" |
82 | #define VCARD_TEL_WORK "work" | 82 | #define VCARD_TEL_WORK "work" |
83 | #define VCARD_TEL_PREF "pref" | 83 | #define VCARD_TEL_PREF "pref" |
84 | #define VCARD_TEL_VOICE "voice" | 84 | #define VCARD_TEL_VOICE "voice" |
85 | #define VCARD_TEL_FAX "fax" | 85 | #define VCARD_TEL_FAX "fax" |
86 | #define VCARD_TEL_MSG "msg" | 86 | #define VCARD_TEL_MSG "msg" |
87 | #define VCARD_TEL_CELL "cell" | 87 | #define VCARD_TEL_CELL "cell" |
88 | #define VCARD_TEL_PAGER "pager" | 88 | #define VCARD_TEL_PAGER "pager" |
89 | #define VCARD_TEL_BBS "bbs" | 89 | #define VCARD_TEL_BBS "bbs" |
90 | #define VCARD_TEL_MODEM "modem" | 90 | #define VCARD_TEL_MODEM "modem" |
91 | #define VCARD_TEL_CAR "car" | 91 | #define VCARD_TEL_CAR "car" |
92 | #define VCARD_TEL_ISDN "isdn" | 92 | #define VCARD_TEL_ISDN "isdn" |
93 | #define VCARD_TEL_VIDEO "video" | 93 | #define VCARD_TEL_VIDEO "video" |
94 | #define VCARD_TEL_PCS "pcs" | 94 | #define VCARD_TEL_PCS "pcs" |
95 | #define VCARD_TEL_SIP "sip" | ||
95 | #define VCARD_EMAIL "email" | 96 | #define VCARD_EMAIL "email" |
96 | // types | 97 | // types |
97 | #define VCARD_EMAIL_PREF "pref" | 98 | #define VCARD_EMAIL_PREF "pref" |
98 | #define VCARD_EMAIL_INTERNET "internet" | 99 | #define VCARD_EMAIL_INTERNET "internet" |
99 | #define VCARD_EMAIL_X400 "x400" | 100 | #define VCARD_EMAIL_X400 "x400" |
100 | #define VCARD_TZ "tz" | 101 | #define VCARD_TZ "tz" |
101 | #define VCARD_GEO "geo" | 102 | #define VCARD_GEO "geo" |
102 | #define VCARD_MAILER "mailer" | 103 | #define VCARD_MAILER "mailer" |
103 | #define VCARD_TITLE "title" | 104 | #define VCARD_TITLE "title" |
104 | #define VCARD_ROLE "role" | 105 | #define VCARD_ROLE "role" |
105 | #define VCARD_LOGO "logo" | 106 | #define VCARD_LOGO "logo" |
106 | #define VCARD_AGENT "agent" | 107 | #define VCARD_AGENT "agent" |
107 | #define VCARD_ORG "org" | 108 | #define VCARD_ORG "org" |
108 | #define VCARD_CATEGORIES "categories" | 109 | #define VCARD_CATEGORIES "categories" |
109 | #define VCARD_NOTE "note" | 110 | #define VCARD_NOTE "note" |
110 | #define VCARD_PRODID "prodid" | 111 | #define VCARD_PRODID "prodid" |
111 | #define VCARD_REV "rev" | 112 | #define VCARD_REV "rev" |
112 | #define VCARD_SOUND "sound" | 113 | #define VCARD_SOUND "sound" |
113 | #define VCARD_UID "uid" | 114 | #define VCARD_UID "uid" |
114 | #define VCARD_URL "url" | 115 | #define VCARD_URL "url" |
115 | #define VCARD_CLASS "class" | 116 | #define VCARD_CLASS "class" |
116 | #define VCARD_CLASS_PUBLIC "public" | 117 | #define VCARD_CLASS_PUBLIC "public" |
117 | #define VCARD_CLASS_PRIVATE "private" | 118 | #define VCARD_CLASS_PRIVATE "private" |
118 | #define VCARD_CLASS_CONFIDENTIAL "confidential" | 119 | #define VCARD_CLASS_CONFIDENTIAL "confidential" |
119 | #define VCARD_KEY "key" | 120 | #define VCARD_KEY "key" |
120 | // types | 121 | // types |
121 | #define VCARD_KEY_X509 "x509" | 122 | #define VCARD_KEY_X509 "x509" |
122 | #define VCARD_KEY_PGP "pgp" | 123 | #define VCARD_KEY_PGP "pgp" |
123 | 124 | ||
124 | #define VCARD_QUOTED_PRINTABLE "quoted-printable" | 125 | #define VCARD_QUOTED_PRINTABLE "quoted-printable" |
125 | // this one is a temporary hack until we support TYPE=VALUE | 126 | // this one is a temporary hack until we support TYPE=VALUE |
126 | #define VCARD_ENCODING_QUOTED_PRINTABLE "encoding=quoted-printable" | 127 | #define VCARD_ENCODING_QUOTED_PRINTABLE "encoding=quoted-printable" |
127 | #define VCARD_BASE64 "base64" | 128 | #define VCARD_BASE64 "base64" |
128 | 129 | ||
129 | #define VC_STATE_BEGIN 1 | 130 | #define VC_STATE_BEGIN 1 |
130 | #define VC_STATE_BODY 2 | 131 | #define VC_STATE_BODY 2 |
131 | #define VC_STATE_END 4 | 132 | #define VC_STATE_END 4 |
132 | #define VC_STATE_HAVE_N 8 | 133 | #define VC_STATE_HAVE_N 8 |
133 | #define VC_STATE_HAVE_VERSION 16 | 134 | #define VC_STATE_HAVE_VERSION 16 |
134 | 135 | ||
135 | #define VC_ERR_NO_BEGIN 1 | 136 | #define VC_ERR_NO_BEGIN 1 |
136 | #define VC_ERR_NO_END 2 | 137 | #define VC_ERR_NO_END 2 |
137 | #define VC_ERR_INVALID_LINE 3 | 138 | #define VC_ERR_INVALID_LINE 3 |
138 | #define VC_ERR_INTERNAL 4 | 139 | #define VC_ERR_INTERNAL 4 |
139 | #define VC_ERR_INVALID_NAME 5 | 140 | #define VC_ERR_INVALID_NAME 5 |
140 | #define VC_ERR_MISSING_MANDATORY 6 | 141 | #define VC_ERR_MISSING_MANDATORY 6 |
141 | 142 | ||
142 | namespace KABC { | 143 | namespace KABC { |
143 | 144 | ||
144 | class AddressBook; | 145 | class AddressBook; |
145 | 146 | ||
146 | class VCard21Parser | 147 | class VCard21Parser |
147 | { | 148 | { |
148 | public: | 149 | public: |
149 | 150 | ||
150 | /** | 151 | /** |
151 | * Constructor. | 152 | * Constructor. |
152 | */ | 153 | */ |
153 | VCard21Parser(); | 154 | VCard21Parser(); |
154 | 155 | ||
155 | /** | 156 | /** |
156 | * Destructor. | 157 | * Destructor. |
157 | */ | 158 | */ |
158 | virtual ~VCard21Parser(); | 159 | virtual ~VCard21Parser(); |
159 | 160 | ||
160 | /** | 161 | /** |
161 | * Parses a string in vcard2.1 format and saves the single addressees | 162 | * Parses a string in vcard2.1 format and saves the single addressees |
162 | * to the address book. | 163 | * to the address book. |
163 | * | 164 | * |
164 | * @param ab The address book. | 165 | * @param ab The address book. |
165 | * @param str The vcard string. | 166 | * @param str The vcard string. |
166 | */ | 167 | */ |
167 | void readFromString( KABC::AddressBook *ab, const QString &str ); | 168 | void readFromString( KABC::AddressBook *ab, const QString &str ); |
168 | 169 | ||
169 | /** | 170 | /** |
170 | * FIXME: we need a writeToString method | 171 | * FIXME: we need a writeToString method |
171 | * QString writeToString (KABC::AddressBook *); | 172 | * QString writeToString (KABC::AddressBook *); |
172 | */ | 173 | */ |
173 | 174 | ||
174 | /** | 175 | /** |
175 | * Parses a string in vcard2.1 format and returns the inherent addressee. | 176 | * Parses a string in vcard2.1 format and returns the inherent addressee. |
176 | */ | 177 | */ |
177 | KABC::Addressee readFromString( const QString &data); | 178 | KABC::Addressee readFromString( const QString &data); |
178 | 179 | ||
179 | /** | 180 | /** |
180 | * Helper method to store a address. | 181 | * Helper method to store a address. |
181 | * | 182 | * |
182 | * @param data A string list, that is filled with 'street', 'house number' ... | 183 | * @param data A string list, that is filled with 'street', 'house number' ... |
183 | * @param type The type of the returned address. | 184 | * @param type The type of the returned address. |
184 | */ | 185 | */ |
185 | static KABC::Address readAddressFromQStringList (const QStringList &data, const int type); | 186 | static KABC::Address readAddressFromQStringList (const QStringList &data, const int type); |
186 | }; | 187 | }; |
187 | 188 | ||
188 | } | 189 | } |
189 | 190 | ||
190 | /** | 191 | /** |
191 | * @short Helper class | 192 | * @short Helper class |
192 | */ | 193 | */ |
193 | class VCardLineX | 194 | class VCardLineX |
194 | { | 195 | { |
195 | public: | 196 | public: |
196 | QString name; | 197 | QString name; |
197 | bool qualified; | 198 | bool qualified; |
198 | QValueList<QString> qualifiers; | 199 | QValueList<QString> qualifiers; |
199 | QValueList<QString> parameters; | 200 | QValueList<QString> parameters; |
200 | bool isValid() const; | 201 | bool isValid() const; |
201 | }; | 202 | }; |
202 | 203 | ||
203 | /** | 204 | /** |
204 | * @short Helper class | 205 | * @short Helper class |
205 | */ | 206 | */ |
206 | class VCard21ParserImpl | 207 | class VCard21ParserImpl |
207 | { | 208 | { |
208 | friend class VCardLineX; | 209 | friend class VCardLineX; |
209 | 210 | ||
210 | public: | 211 | public: |
211 | VCard21ParserImpl() { }; | 212 | VCard21ParserImpl() { }; |
212 | virtual ~VCard21ParserImpl() { }; | 213 | virtual ~VCard21ParserImpl() { }; |
213 | static VCard21ParserImpl *parseVCard(const QString& vc, int *err = NULL); | 214 | static VCard21ParserImpl *parseVCard(const QString& vc, int *err = NULL); |
214 | QString getValue(const QString& name, const QString& qualifier); | 215 | QString getValue(const QString& name, const QString& qualifier); |
215 | QString getValue(const QString& name); | 216 | QString getValue(const QString& name); |
216 | QStringList getValues(const QString& name, const QString& qualifier); | 217 | QStringList getValues(const QString& name, const QString& qualifier); |
217 | QStringList getValues(const QString& name); | 218 | QStringList getValues(const QString& name); |
218 | 219 | ||
219 | QValueList<VCardLineX> *_vcdata; | 220 | QValueList<VCardLineX> *_vcdata; |
220 | 221 | ||
221 | private: | 222 | private: |
222 | VCard21ParserImpl (QValueList<VCardLineX> *_vcd); | 223 | VCard21ParserImpl (QValueList<VCardLineX> *_vcd); |
223 | }; | 224 | }; |
224 | 225 | ||
225 | #endif | 226 | #endif |
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp index bffaa64..2d6eb3d 100644 --- a/kabc/vcardformatimpl.cpp +++ b/kabc/vcardformatimpl.cpp | |||
@@ -210,800 +210,802 @@ bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) | |||
210 | case EntityTelephone: | 210 | case EntityTelephone: |
211 | addressee.insertPhoneNumber( readTelephoneValue( cl ) ); | 211 | addressee.insertPhoneNumber( readTelephoneValue( cl ) ); |
212 | break; | 212 | break; |
213 | 213 | ||
214 | case EntityCategories: | 214 | case EntityCategories: |
215 | addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) ); | 215 | addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) ); |
216 | break; | 216 | break; |
217 | 217 | ||
218 | case EntityBirthday: | 218 | case EntityBirthday: |
219 | addressee.setBirthday( readDateValue( cl ) ); | 219 | addressee.setBirthday( readDateValue( cl ) ); |
220 | break; | 220 | break; |
221 | 221 | ||
222 | case EntityRevision: | 222 | case EntityRevision: |
223 | addressee.setRevision( readDateTimeValue( cl ) ); | 223 | addressee.setRevision( readDateTimeValue( cl ) ); |
224 | break; | 224 | break; |
225 | 225 | ||
226 | case EntityGeo: | 226 | case EntityGeo: |
227 | addressee.setGeo( readGeoValue( cl ) ); | 227 | addressee.setGeo( readGeoValue( cl ) ); |
228 | break; | 228 | break; |
229 | 229 | ||
230 | case EntityTimeZone: | 230 | case EntityTimeZone: |
231 | addressee.setTimeZone( readUTCValue( cl ) ); | 231 | addressee.setTimeZone( readUTCValue( cl ) ); |
232 | break; | 232 | break; |
233 | 233 | ||
234 | case EntityVersion: | 234 | case EntityVersion: |
235 | break; | 235 | break; |
236 | 236 | ||
237 | case EntityClass: | 237 | case EntityClass: |
238 | addressee.setSecrecy( readClassValue( cl ) ); | 238 | addressee.setSecrecy( readClassValue( cl ) ); |
239 | break; | 239 | break; |
240 | 240 | ||
241 | case EntityKey: | 241 | case EntityKey: |
242 | addressee.insertKey( readKeyValue( cl ) ); | 242 | addressee.insertKey( readKeyValue( cl ) ); |
243 | break; | 243 | break; |
244 | 244 | ||
245 | case EntityPhoto: | 245 | case EntityPhoto: |
246 | addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) ); | 246 | addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) ); |
247 | break; | 247 | break; |
248 | 248 | ||
249 | case EntityLogo: | 249 | case EntityLogo: |
250 | addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) ); | 250 | addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) ); |
251 | break; | 251 | break; |
252 | 252 | ||
253 | case EntityAgent: | 253 | case EntityAgent: |
254 | addressee.setAgent( readAgentValue( cl ) ); | 254 | addressee.setAgent( readAgentValue( cl ) ); |
255 | break; | 255 | break; |
256 | 256 | ||
257 | case EntitySound: | 257 | case EntitySound: |
258 | addressee.setSound( readSoundValue( cl, addressee ) ); | 258 | addressee.setSound( readSoundValue( cl, addressee ) ); |
259 | break; | 259 | break; |
260 | 260 | ||
261 | default: | 261 | default: |
262 | kdDebug(5700) << "VCardFormat::load(): Unsupported entity: " | 262 | kdDebug(5700) << "VCardFormat::load(): Unsupported entity: " |
263 | << int( type ) << ": " << cl->asString() << endl; | 263 | << int( type ) << ": " << cl->asString() << endl; |
264 | break; | 264 | break; |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | for( cl = contentLines.first(); cl; cl = contentLines.next() ) { | 268 | for( cl = contentLines.first(); cl; cl = contentLines.next() ) { |
269 | EntityType type = cl->entityType(); | 269 | EntityType type = cl->entityType(); |
270 | if ( type == EntityLabel ) { | 270 | if ( type == EntityLabel ) { |
271 | int type = readAddressParam( cl ); | 271 | int type = readAddressParam( cl ); |
272 | Address address = addressee.address( type ); | 272 | Address address = addressee.address( type ); |
273 | if ( address.isEmpty() ) | 273 | if ( address.isEmpty() ) |
274 | address.setType( type ); | 274 | address.setType( type ); |
275 | 275 | ||
276 | address.setLabel( QString::fromUtf8( cl->value()->asString() ) ); | 276 | address.setLabel( QString::fromUtf8( cl->value()->asString() ) ); |
277 | addressee.insertAddress( address ); | 277 | addressee.insertAddress( address ); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | return true; | 281 | return true; |
282 | } | 282 | } |
283 | 283 | ||
284 | void VCardFormatImpl::saveAddressee( const Addressee &addressee, VCard *v, bool intern ) | 284 | void VCardFormatImpl::saveAddressee( const Addressee &addressee, VCard *v, bool intern ) |
285 | { | 285 | { |
286 | //US ContentLine cl; | 286 | //US ContentLine cl; |
287 | //US QString value; | 287 | //US QString value; |
288 | 288 | ||
289 | addTextValue( v, EntityName, addressee.name() ); | 289 | addTextValue( v, EntityName, addressee.name() ); |
290 | addTextValue( v, EntityUID, addressee.uid() ); | 290 | addTextValue( v, EntityUID, addressee.uid() ); |
291 | addTextValue( v, EntityFullName, addressee.formattedName() ); | 291 | addTextValue( v, EntityFullName, addressee.formattedName() ); |
292 | 292 | ||
293 | QStringList emails = addressee.emails(); | 293 | QStringList emails = addressee.emails(); |
294 | QStringList::ConstIterator it4; | 294 | QStringList::ConstIterator it4; |
295 | for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) { | 295 | for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) { |
296 | addTextValue( v, EntityEmail, *it4 ); | 296 | addTextValue( v, EntityEmail, *it4 ); |
297 | } | 297 | } |
298 | 298 | ||
299 | QStringList customs = addressee.customs(); | 299 | QStringList customs = addressee.customs(); |
300 | QStringList::ConstIterator it5; | 300 | QStringList::ConstIterator it5; |
301 | for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) { | 301 | for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) { |
302 | addCustomValue( v, *it5 ); | 302 | addCustomValue( v, *it5 ); |
303 | } | 303 | } |
304 | 304 | ||
305 | addTextValue( v, EntityURL, addressee.url().url() ); | 305 | addTextValue( v, EntityURL, addressee.url().url() ); |
306 | 306 | ||
307 | addNValue( v, addressee ); | 307 | addNValue( v, addressee ); |
308 | 308 | ||
309 | addTextValue( v, EntityNickname, addressee.nickName() ); | 309 | addTextValue( v, EntityNickname, addressee.nickName() ); |
310 | addTextValue( v, EntityMailer, addressee.mailer() ); | 310 | addTextValue( v, EntityMailer, addressee.mailer() ); |
311 | addTextValue( v, EntityTitle, addressee.title() ); | 311 | addTextValue( v, EntityTitle, addressee.title() ); |
312 | addTextValue( v, EntityRole, addressee.role() ); | 312 | addTextValue( v, EntityRole, addressee.role() ); |
313 | addTextValue( v, EntityOrganisation, addressee.organization() ); | 313 | addTextValue( v, EntityOrganisation, addressee.organization() ); |
314 | addTextValue( v, EntityNote, addressee.note() ); | 314 | addTextValue( v, EntityNote, addressee.note() ); |
315 | addTextValue( v, EntityProductID, addressee.productId() ); | 315 | addTextValue( v, EntityProductID, addressee.productId() ); |
316 | addTextValue( v, EntitySortString, addressee.sortString() ); | 316 | addTextValue( v, EntitySortString, addressee.sortString() ); |
317 | 317 | ||
318 | Address::List addresses = addressee.addresses(); | 318 | Address::List addresses = addressee.addresses(); |
319 | Address::List::ConstIterator it3; | 319 | Address::List::ConstIterator it3; |
320 | for( it3 = addresses.begin(); it3 != addresses.end(); ++it3 ) { | 320 | for( it3 = addresses.begin(); it3 != addresses.end(); ++it3 ) { |
321 | addAddressValue( v, *it3 ); | 321 | addAddressValue( v, *it3 ); |
322 | addLabelValue( v, *it3 ); | 322 | addLabelValue( v, *it3 ); |
323 | } | 323 | } |
324 | 324 | ||
325 | PhoneNumber::List phoneNumbers = addressee.phoneNumbers(); | 325 | PhoneNumber::List phoneNumbers = addressee.phoneNumbers(); |
326 | PhoneNumber::List::ConstIterator it2; | 326 | PhoneNumber::List::ConstIterator it2; |
327 | for( it2 = phoneNumbers.begin(); it2 != phoneNumbers.end(); ++it2 ) { | 327 | for( it2 = phoneNumbers.begin(); it2 != phoneNumbers.end(); ++it2 ) { |
328 | addTelephoneValue( v, *it2 ); | 328 | addTelephoneValue( v, *it2 ); |
329 | } | 329 | } |
330 | 330 | ||
331 | Key::List keys = addressee.keys(); | 331 | Key::List keys = addressee.keys(); |
332 | Key::List::ConstIterator it6; | 332 | Key::List::ConstIterator it6; |
333 | for( it6 = keys.begin(); it6 != keys.end(); ++it6 ) { | 333 | for( it6 = keys.begin(); it6 != keys.end(); ++it6 ) { |
334 | addKeyValue( v, *it6 ); | 334 | addKeyValue( v, *it6 ); |
335 | } | 335 | } |
336 | 336 | ||
337 | addTextValue( v, EntityCategories, addressee.categories().join(",") ); | 337 | addTextValue( v, EntityCategories, addressee.categories().join(",") ); |
338 | 338 | ||
339 | addDateValue( v, EntityBirthday, addressee.birthday().date() ); | 339 | addDateValue( v, EntityBirthday, addressee.birthday().date() ); |
340 | addDateTimeValue( v, EntityRevision, addressee.revision() ); | 340 | addDateTimeValue( v, EntityRevision, addressee.revision() ); |
341 | addGeoValue( v, addressee.geo() ); | 341 | addGeoValue( v, addressee.geo() ); |
342 | addUTCValue( v, addressee.timeZone() ); | 342 | addUTCValue( v, addressee.timeZone() ); |
343 | 343 | ||
344 | addClassValue( v, addressee.secrecy() ); | 344 | addClassValue( v, addressee.secrecy() ); |
345 | 345 | ||
346 | addPictureValue( v, EntityPhoto, addressee.photo(), addressee, intern ); | 346 | addPictureValue( v, EntityPhoto, addressee.photo(), addressee, intern ); |
347 | addPictureValue( v, EntityLogo, addressee.logo(), addressee, intern ); | 347 | addPictureValue( v, EntityLogo, addressee.logo(), addressee, intern ); |
348 | 348 | ||
349 | addAgentValue( v, addressee.agent() ); | 349 | addAgentValue( v, addressee.agent() ); |
350 | 350 | ||
351 | addSoundValue( v, addressee.sound(), addressee, intern ); | 351 | addSoundValue( v, addressee.sound(), addressee, intern ); |
352 | } | 352 | } |
353 | 353 | ||
354 | void VCardFormatImpl::addCustomValue( VCard *v, const QString &txt ) | 354 | void VCardFormatImpl::addCustomValue( VCard *v, const QString &txt ) |
355 | { | 355 | { |
356 | if ( txt.isEmpty() ) return; | 356 | if ( txt.isEmpty() ) return; |
357 | 357 | ||
358 | ContentLine cl; | 358 | ContentLine cl; |
359 | cl.setName( "X-" + txt.left( txt.find( ":" ) ).utf8() ); | 359 | cl.setName( "X-" + txt.left( txt.find( ":" ) ).utf8() ); |
360 | QString value = txt.mid( txt.find( ":" ) + 1 ); | 360 | QString value = txt.mid( txt.find( ":" ) + 1 ); |
361 | if ( value.isEmpty() ) | 361 | if ( value.isEmpty() ) |
362 | return; | 362 | return; |
363 | cl.setValue( new TextValue( value.utf8() ) ); | 363 | cl.setValue( new TextValue( value.utf8() ) ); |
364 | v->add(cl); | 364 | v->add(cl); |
365 | } | 365 | } |
366 | 366 | ||
367 | void VCardFormatImpl::addTextValue( VCard *v, EntityType type, const QString &txt ) | 367 | void VCardFormatImpl::addTextValue( VCard *v, EntityType type, const QString &txt ) |
368 | { | 368 | { |
369 | if ( txt.isEmpty() ) return; | 369 | if ( txt.isEmpty() ) return; |
370 | 370 | ||
371 | ContentLine cl; | 371 | ContentLine cl; |
372 | cl.setName( EntityTypeToParamName( type ) ); | 372 | cl.setName( EntityTypeToParamName( type ) ); |
373 | cl.setValue( new TextValue( txt.utf8() ) ); | 373 | cl.setValue( new TextValue( txt.utf8() ) ); |
374 | v->add(cl); | 374 | v->add(cl); |
375 | } | 375 | } |
376 | 376 | ||
377 | void VCardFormatImpl::addDateValue( VCard *vcard, EntityType type, | 377 | void VCardFormatImpl::addDateValue( VCard *vcard, EntityType type, |
378 | const QDate &date ) | 378 | const QDate &date ) |
379 | { | 379 | { |
380 | if ( !date.isValid() ) return; | 380 | if ( !date.isValid() ) return; |
381 | 381 | ||
382 | ContentLine cl; | 382 | ContentLine cl; |
383 | cl.setName( EntityTypeToParamName( type ) ); | 383 | cl.setName( EntityTypeToParamName( type ) ); |
384 | 384 | ||
385 | DateValue *v = new DateValue( date ); | 385 | DateValue *v = new DateValue( date ); |
386 | cl.setValue( v ); | 386 | cl.setValue( v ); |
387 | vcard->add(cl); | 387 | vcard->add(cl); |
388 | } | 388 | } |
389 | 389 | ||
390 | void VCardFormatImpl::addDateTimeValue( VCard *vcard, EntityType type, | 390 | void VCardFormatImpl::addDateTimeValue( VCard *vcard, EntityType type, |
391 | const QDateTime &dateTime ) | 391 | const QDateTime &dateTime ) |
392 | { | 392 | { |
393 | if ( !dateTime.isValid() ) return; | 393 | if ( !dateTime.isValid() ) return; |
394 | 394 | ||
395 | ContentLine cl; | 395 | ContentLine cl; |
396 | cl.setName( EntityTypeToParamName( type ) ); | 396 | cl.setName( EntityTypeToParamName( type ) ); |
397 | 397 | ||
398 | DateValue *v = new DateValue( dateTime ); | 398 | DateValue *v = new DateValue( dateTime ); |
399 | cl.setValue( v ); | 399 | cl.setValue( v ); |
400 | vcard->add(cl); | 400 | vcard->add(cl); |
401 | } | 401 | } |
402 | 402 | ||
403 | void VCardFormatImpl::addAddressValue( VCard *vcard, const Address &a ) | 403 | void VCardFormatImpl::addAddressValue( VCard *vcard, const Address &a ) |
404 | { | 404 | { |
405 | if ( a.isEmpty() ) | 405 | if ( a.isEmpty() ) |
406 | return; | 406 | return; |
407 | 407 | ||
408 | ContentLine cl; | 408 | ContentLine cl; |
409 | cl.setName( EntityTypeToParamName( EntityAddress ) ); | 409 | cl.setName( EntityTypeToParamName( EntityAddress ) ); |
410 | 410 | ||
411 | AdrValue *v = new AdrValue; | 411 | AdrValue *v = new AdrValue; |
412 | v->setPOBox( a.postOfficeBox().utf8() ); | 412 | v->setPOBox( a.postOfficeBox().utf8() ); |
413 | v->setExtAddress( a.extended().utf8() ); | 413 | v->setExtAddress( a.extended().utf8() ); |
414 | v->setStreet( a.street().utf8() ); | 414 | v->setStreet( a.street().utf8() ); |
415 | v->setLocality( a.locality().utf8() ); | 415 | v->setLocality( a.locality().utf8() ); |
416 | v->setRegion( a.region().utf8() ); | 416 | v->setRegion( a.region().utf8() ); |
417 | v->setPostCode( a.postalCode().utf8() ); | 417 | v->setPostCode( a.postalCode().utf8() ); |
418 | v->setCountryName( a.country().utf8() ); | 418 | v->setCountryName( a.country().utf8() ); |
419 | cl.setValue( v ); | 419 | cl.setValue( v ); |
420 | 420 | ||
421 | addAddressParam( &cl, a.type() ); | 421 | addAddressParam( &cl, a.type() ); |
422 | 422 | ||
423 | vcard->add( cl ); | 423 | vcard->add( cl ); |
424 | } | 424 | } |
425 | 425 | ||
426 | void VCardFormatImpl::addLabelValue( VCard *vcard, const Address &a ) | 426 | void VCardFormatImpl::addLabelValue( VCard *vcard, const Address &a ) |
427 | { | 427 | { |
428 | if ( a.label().isEmpty() ) return; | 428 | if ( a.label().isEmpty() ) return; |
429 | 429 | ||
430 | ContentLine cl; | 430 | ContentLine cl; |
431 | cl.setName( EntityTypeToParamName( EntityLabel ) ); | 431 | cl.setName( EntityTypeToParamName( EntityLabel ) ); |
432 | cl.setValue( new TextValue( a.label().utf8() ) ); | 432 | cl.setValue( new TextValue( a.label().utf8() ) ); |
433 | 433 | ||
434 | addAddressParam( &cl, a.type() ); | 434 | addAddressParam( &cl, a.type() ); |
435 | 435 | ||
436 | vcard->add( cl ); | 436 | vcard->add( cl ); |
437 | } | 437 | } |
438 | 438 | ||
439 | void VCardFormatImpl::addAddressParam( ContentLine *cl, int type ) | 439 | void VCardFormatImpl::addAddressParam( ContentLine *cl, int type ) |
440 | { | 440 | { |
441 | ParamList params; | 441 | ParamList params; |
442 | if ( type & Address::Dom ) params.append( new Param( "TYPE", "dom" ) ); | 442 | if ( type & Address::Dom ) params.append( new Param( "TYPE", "dom" ) ); |
443 | if ( type & Address::Intl ) params.append( new Param( "TYPE", "intl" ) ); | 443 | if ( type & Address::Intl ) params.append( new Param( "TYPE", "intl" ) ); |
444 | if ( type & Address::Parcel ) params.append( new Param( "TYPE", "parcel" ) ); | 444 | if ( type & Address::Parcel ) params.append( new Param( "TYPE", "parcel" ) ); |
445 | if ( type & Address::Postal ) params.append( new Param( "TYPE", "postal" ) ); | 445 | if ( type & Address::Postal ) params.append( new Param( "TYPE", "postal" ) ); |
446 | if ( type & Address::Work ) params.append( new Param( "TYPE", "work" ) ); | 446 | if ( type & Address::Work ) params.append( new Param( "TYPE", "work" ) ); |
447 | if ( type & Address::Home ) params.append( new Param( "TYPE", "home" ) ); | 447 | if ( type & Address::Home ) params.append( new Param( "TYPE", "home" ) ); |
448 | if ( type & Address::Pref ) params.append( new Param( "TYPE", "pref" ) ); | 448 | if ( type & Address::Pref ) params.append( new Param( "TYPE", "pref" ) ); |
449 | cl->setParamList( params ); | 449 | cl->setParamList( params ); |
450 | } | 450 | } |
451 | 451 | ||
452 | void VCardFormatImpl::addGeoValue( VCard *vcard, const Geo &geo ) | 452 | void VCardFormatImpl::addGeoValue( VCard *vcard, const Geo &geo ) |
453 | { | 453 | { |
454 | if ( !geo.isValid() ) return; | 454 | if ( !geo.isValid() ) return; |
455 | 455 | ||
456 | ContentLine cl; | 456 | ContentLine cl; |
457 | cl.setName( EntityTypeToParamName( EntityGeo ) ); | 457 | cl.setName( EntityTypeToParamName( EntityGeo ) ); |
458 | 458 | ||
459 | GeoValue *v = new GeoValue; | 459 | GeoValue *v = new GeoValue; |
460 | v->setLatitude( geo.latitude() ); | 460 | v->setLatitude( geo.latitude() ); |
461 | v->setLongitude( geo.longitude() ); | 461 | v->setLongitude( geo.longitude() ); |
462 | 462 | ||
463 | cl.setValue( v ); | 463 | cl.setValue( v ); |
464 | vcard->add(cl); | 464 | vcard->add(cl); |
465 | } | 465 | } |
466 | 466 | ||
467 | void VCardFormatImpl::addUTCValue( VCard *vcard, const TimeZone &tz ) | 467 | void VCardFormatImpl::addUTCValue( VCard *vcard, const TimeZone &tz ) |
468 | { | 468 | { |
469 | if ( !tz.isValid() ) return; | 469 | if ( !tz.isValid() ) return; |
470 | 470 | ||
471 | ContentLine cl; | 471 | ContentLine cl; |
472 | cl.setName( EntityTypeToParamName( EntityTimeZone ) ); | 472 | cl.setName( EntityTypeToParamName( EntityTimeZone ) ); |
473 | 473 | ||
474 | UTCValue *v = new UTCValue; | 474 | UTCValue *v = new UTCValue; |
475 | 475 | ||
476 | v->setPositive( tz.offset() >= 0 ); | 476 | v->setPositive( tz.offset() >= 0 ); |
477 | v->setHour( (tz.offset() / 60) * ( tz.offset() >= 0 ? 1 : -1 ) ); | 477 | v->setHour( (tz.offset() / 60) * ( tz.offset() >= 0 ? 1 : -1 ) ); |
478 | v->setMinute( (tz.offset() % 60) * ( tz.offset() >= 0 ? 1 : -1 ) ); | 478 | v->setMinute( (tz.offset() % 60) * ( tz.offset() >= 0 ? 1 : -1 ) ); |
479 | 479 | ||
480 | cl.setValue( v ); | 480 | cl.setValue( v ); |
481 | vcard->add(cl); | 481 | vcard->add(cl); |
482 | } | 482 | } |
483 | 483 | ||
484 | void VCardFormatImpl::addClassValue( VCard *vcard, const Secrecy &secrecy ) | 484 | void VCardFormatImpl::addClassValue( VCard *vcard, const Secrecy &secrecy ) |
485 | { | 485 | { |
486 | ContentLine cl; | 486 | ContentLine cl; |
487 | cl.setName( EntityTypeToParamName( EntityClass ) ); | 487 | cl.setName( EntityTypeToParamName( EntityClass ) ); |
488 | 488 | ||
489 | ClassValue *v = new ClassValue; | 489 | ClassValue *v = new ClassValue; |
490 | switch ( secrecy.type() ) { | 490 | switch ( secrecy.type() ) { |
491 | case Secrecy::Public: | 491 | case Secrecy::Public: |
492 | v->setType( (int)ClassValue::Public ); | 492 | v->setType( (int)ClassValue::Public ); |
493 | break; | 493 | break; |
494 | case Secrecy::Private: | 494 | case Secrecy::Private: |
495 | v->setType( (int)ClassValue::Private ); | 495 | v->setType( (int)ClassValue::Private ); |
496 | break; | 496 | break; |
497 | case Secrecy::Confidential: | 497 | case Secrecy::Confidential: |
498 | v->setType( (int)ClassValue::Confidential ); | 498 | v->setType( (int)ClassValue::Confidential ); |
499 | break; | 499 | break; |
500 | } | 500 | } |
501 | 501 | ||
502 | cl.setValue( v ); | 502 | cl.setValue( v ); |
503 | vcard->add(cl); | 503 | vcard->add(cl); |
504 | } | 504 | } |
505 | 505 | ||
506 | 506 | ||
507 | Address VCardFormatImpl::readAddressValue( ContentLine *cl ) | 507 | Address VCardFormatImpl::readAddressValue( ContentLine *cl ) |
508 | { | 508 | { |
509 | Address a; | 509 | Address a; |
510 | AdrValue *v = (AdrValue *)cl->value(); | 510 | AdrValue *v = (AdrValue *)cl->value(); |
511 | a.setPostOfficeBox( QString::fromUtf8( v->poBox() ) ); | 511 | a.setPostOfficeBox( QString::fromUtf8( v->poBox() ) ); |
512 | a.setExtended( QString::fromUtf8( v->extAddress() ) ); | 512 | a.setExtended( QString::fromUtf8( v->extAddress() ) ); |
513 | a.setStreet( QString::fromUtf8( v->street() ) ); | 513 | a.setStreet( QString::fromUtf8( v->street() ) ); |
514 | a.setLocality( QString::fromUtf8( v->locality() ) ); | 514 | a.setLocality( QString::fromUtf8( v->locality() ) ); |
515 | a.setRegion( QString::fromUtf8( v->region() ) ); | 515 | a.setRegion( QString::fromUtf8( v->region() ) ); |
516 | a.setPostalCode( QString::fromUtf8( v->postCode() ) ); | 516 | a.setPostalCode( QString::fromUtf8( v->postCode() ) ); |
517 | a.setCountry( QString::fromUtf8( v->countryName() ) ); | 517 | a.setCountry( QString::fromUtf8( v->countryName() ) ); |
518 | 518 | ||
519 | a.setType( readAddressParam( cl ) ); | 519 | a.setType( readAddressParam( cl ) ); |
520 | 520 | ||
521 | return a; | 521 | return a; |
522 | } | 522 | } |
523 | 523 | ||
524 | int VCardFormatImpl::readAddressParam( ContentLine *cl ) | 524 | int VCardFormatImpl::readAddressParam( ContentLine *cl ) |
525 | { | 525 | { |
526 | int type = 0; | 526 | int type = 0; |
527 | ParamList params = cl->paramList(); | 527 | ParamList params = cl->paramList(); |
528 | ParamListIterator it( params ); | 528 | ParamListIterator it( params ); |
529 | QCString tmpStr; | 529 | QCString tmpStr; |
530 | for( ; it.current(); ++it ) { | 530 | for( ; it.current(); ++it ) { |
531 | if ( (*it)->name().upper() == "TYPE" ) { | 531 | if ( (*it)->name().upper() == "TYPE" ) { |
532 | tmpStr = (*it)->value().lower(); | 532 | tmpStr = (*it)->value().lower(); |
533 | if ( tmpStr == "dom" ) type |= Address::Dom; | 533 | if ( tmpStr == "dom" ) type |= Address::Dom; |
534 | else if ( tmpStr == "intl" ) type |= Address::Intl; | 534 | else if ( tmpStr == "intl" ) type |= Address::Intl; |
535 | else if ( tmpStr == "parcel" ) type |= Address::Parcel; | 535 | else if ( tmpStr == "parcel" ) type |= Address::Parcel; |
536 | else if ( tmpStr == "postal" ) type |= Address::Postal; | 536 | else if ( tmpStr == "postal" ) type |= Address::Postal; |
537 | else if ( tmpStr == "work" ) type |= Address::Work; | 537 | else if ( tmpStr == "work" ) type |= Address::Work; |
538 | else if ( tmpStr == "home" ) type |= Address::Home; | 538 | else if ( tmpStr == "home" ) type |= Address::Home; |
539 | else if ( tmpStr == "pref" ) type |= Address::Pref; | 539 | else if ( tmpStr == "pref" ) type |= Address::Pref; |
540 | } | 540 | } |
541 | } | 541 | } |
542 | return type; | 542 | return type; |
543 | } | 543 | } |
544 | 544 | ||
545 | void VCardFormatImpl::addNValue( VCard *vcard, const Addressee &a ) | 545 | void VCardFormatImpl::addNValue( VCard *vcard, const Addressee &a ) |
546 | { | 546 | { |
547 | ContentLine cl; | 547 | ContentLine cl; |
548 | cl.setName(EntityTypeToParamName( EntityN ) ); | 548 | cl.setName(EntityTypeToParamName( EntityN ) ); |
549 | NValue *v = new NValue; | 549 | NValue *v = new NValue; |
550 | v->setFamily( a.familyName().utf8() ); | 550 | v->setFamily( a.familyName().utf8() ); |
551 | v->setGiven( a.givenName().utf8() ); | 551 | v->setGiven( a.givenName().utf8() ); |
552 | v->setMiddle( a.additionalName().utf8() ); | 552 | v->setMiddle( a.additionalName().utf8() ); |
553 | v->setPrefix( a.prefix().utf8() ); | 553 | v->setPrefix( a.prefix().utf8() ); |
554 | v->setSuffix( a.suffix().utf8() ); | 554 | v->setSuffix( a.suffix().utf8() ); |
555 | 555 | ||
556 | cl.setValue( v ); | 556 | cl.setValue( v ); |
557 | vcard->add(cl); | 557 | vcard->add(cl); |
558 | } | 558 | } |
559 | 559 | ||
560 | void VCardFormatImpl::readNValue( ContentLine *cl, Addressee &a ) | 560 | void VCardFormatImpl::readNValue( ContentLine *cl, Addressee &a ) |
561 | { | 561 | { |
562 | NValue *v = (NValue *)cl->value(); | 562 | NValue *v = (NValue *)cl->value(); |
563 | a.setFamilyName( QString::fromUtf8( v->family() ) ); | 563 | a.setFamilyName( QString::fromUtf8( v->family() ) ); |
564 | a.setGivenName( QString::fromUtf8( v->given() ) ); | 564 | a.setGivenName( QString::fromUtf8( v->given() ) ); |
565 | a.setAdditionalName( QString::fromUtf8( v->middle() ) ); | 565 | a.setAdditionalName( QString::fromUtf8( v->middle() ) ); |
566 | a.setPrefix( QString::fromUtf8( v->prefix() ) ); | 566 | a.setPrefix( QString::fromUtf8( v->prefix() ) ); |
567 | a.setSuffix( QString::fromUtf8( v->suffix() ) ); | 567 | a.setSuffix( QString::fromUtf8( v->suffix() ) ); |
568 | } | 568 | } |
569 | 569 | ||
570 | void VCardFormatImpl::addTelephoneValue( VCard *v, const PhoneNumber &p ) | 570 | void VCardFormatImpl::addTelephoneValue( VCard *v, const PhoneNumber &p ) |
571 | { | 571 | { |
572 | if ( p.number().isEmpty() ) | 572 | if ( p.number().isEmpty() ) |
573 | return; | 573 | return; |
574 | 574 | ||
575 | ContentLine cl; | 575 | ContentLine cl; |
576 | cl.setName(EntityTypeToParamName(EntityTelephone)); | 576 | cl.setName(EntityTypeToParamName(EntityTelephone)); |
577 | cl.setValue(new TelValue( p.number().utf8() )); | 577 | cl.setValue(new TelValue( p.number().utf8() )); |
578 | 578 | ||
579 | ParamList params; | 579 | ParamList params; |
580 | if( p.type() & PhoneNumber::Home ) params.append( new Param( "TYPE", "home" ) ); | 580 | if( p.type() & PhoneNumber::Home ) params.append( new Param( "TYPE", "home" ) ); |
581 | if( p.type() & PhoneNumber::Work ) params.append( new Param( "TYPE", "work" ) ); | 581 | if( p.type() & PhoneNumber::Work ) params.append( new Param( "TYPE", "work" ) ); |
582 | if( p.type() & PhoneNumber::Msg ) params.append( new Param( "TYPE", "msg" ) ); | 582 | if( p.type() & PhoneNumber::Msg ) params.append( new Param( "TYPE", "msg" ) ); |
583 | if( p.type() & PhoneNumber::Pref ) params.append( new Param( "TYPE", "pref" ) ); | 583 | if( p.type() & PhoneNumber::Pref ) params.append( new Param( "TYPE", "pref" ) ); |
584 | if( p.type() & PhoneNumber::Voice ) params.append( new Param( "TYPE", "voice" ) ); | 584 | if( p.type() & PhoneNumber::Voice ) params.append( new Param( "TYPE", "voice" ) ); |
585 | if( p.type() & PhoneNumber::Fax ) params.append( new Param( "TYPE", "fax" ) ); | 585 | if( p.type() & PhoneNumber::Fax ) params.append( new Param( "TYPE", "fax" ) ); |
586 | if( p.type() & PhoneNumber::Cell ) params.append( new Param( "TYPE", "cell" ) ); | 586 | if( p.type() & PhoneNumber::Cell ) params.append( new Param( "TYPE", "cell" ) ); |
587 | if( p.type() & PhoneNumber::Video ) params.append( new Param( "TYPE", "video" ) ); | 587 | if( p.type() & PhoneNumber::Video ) params.append( new Param( "TYPE", "video" ) ); |
588 | if( p.type() & PhoneNumber::Bbs ) params.append( new Param( "TYPE", "bbs" ) ); | 588 | if( p.type() & PhoneNumber::Bbs ) params.append( new Param( "TYPE", "bbs" ) ); |
589 | if( p.type() & PhoneNumber::Modem ) params.append( new Param( "TYPE", "modem" ) ); | 589 | if( p.type() & PhoneNumber::Modem ) params.append( new Param( "TYPE", "modem" ) ); |
590 | if( p.type() & PhoneNumber::Car ) params.append( new Param( "TYPE", "car" ) ); | 590 | if( p.type() & PhoneNumber::Car ) params.append( new Param( "TYPE", "car" ) ); |
591 | if( p.type() & PhoneNumber::Isdn ) params.append( new Param( "TYPE", "isdn" ) ); | 591 | if( p.type() & PhoneNumber::Isdn ) params.append( new Param( "TYPE", "isdn" ) ); |
592 | if( p.type() & PhoneNumber::Pcs ) params.append( new Param( "TYPE", "pcs" ) ); | 592 | if( p.type() & PhoneNumber::Pcs ) params.append( new Param( "TYPE", "pcs" ) ); |
593 | if( p.type() & PhoneNumber::Pager ) params.append( new Param( "TYPE", "pager" ) ); | 593 | if( p.type() & PhoneNumber::Pager ) params.append( new Param( "TYPE", "pager" ) ); |
594 | if( p.type() & PhoneNumber::Sip ) params.append( new Param( "TYPE", "sip" ) ); | ||
594 | cl.setParamList( params ); | 595 | cl.setParamList( params ); |
595 | 596 | ||
596 | v->add(cl); | 597 | v->add(cl); |
597 | } | 598 | } |
598 | 599 | ||
599 | PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl ) | 600 | PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl ) |
600 | { | 601 | { |
601 | PhoneNumber p; | 602 | PhoneNumber p; |
602 | TelValue *value = (TelValue *)cl->value(); | 603 | TelValue *value = (TelValue *)cl->value(); |
603 | p.setNumber( QString::fromUtf8( value->asString() ) ); | 604 | p.setNumber( QString::fromUtf8( value->asString() ) ); |
604 | 605 | ||
605 | int type = 0; | 606 | int type = 0; |
606 | ParamList params = cl->paramList(); | 607 | ParamList params = cl->paramList(); |
607 | ParamListIterator it( params ); | 608 | ParamListIterator it( params ); |
608 | QCString tmpStr; | 609 | QCString tmpStr; |
609 | for( ; it.current(); ++it ) { | 610 | for( ; it.current(); ++it ) { |
610 | if ( (*it)->name() == "TYPE" ) { | 611 | if ( (*it)->name() == "TYPE" ) { |
611 | tmpStr = (*it)->value().lower(); | 612 | tmpStr = (*it)->value().lower(); |
612 | if ( tmpStr == "home" ) type |= PhoneNumber::Home; | 613 | if ( tmpStr == "home" ) type |= PhoneNumber::Home; |
613 | else if ( tmpStr == "work" ) type |= PhoneNumber::Work; | 614 | else if ( tmpStr == "work" ) type |= PhoneNumber::Work; |
614 | else if ( tmpStr == "msg" ) type |= PhoneNumber::Msg; | 615 | else if ( tmpStr == "msg" ) type |= PhoneNumber::Msg; |
615 | else if ( tmpStr == "pref" ) type |= PhoneNumber::Pref; | 616 | else if ( tmpStr == "pref" ) type |= PhoneNumber::Pref; |
616 | else if ( tmpStr == "voice" ) type |= PhoneNumber::Voice; | 617 | else if ( tmpStr == "voice" ) type |= PhoneNumber::Voice; |
617 | else if ( tmpStr == "fax" ) type |= PhoneNumber::Fax; | 618 | else if ( tmpStr == "fax" ) type |= PhoneNumber::Fax; |
618 | else if ( tmpStr == "cell" ) type |= PhoneNumber::Cell; | 619 | else if ( tmpStr == "cell" ) type |= PhoneNumber::Cell; |
619 | else if ( tmpStr == "video" ) type |= PhoneNumber::Video; | 620 | else if ( tmpStr == "video" ) type |= PhoneNumber::Video; |
620 | else if ( tmpStr == "bbs" ) type |= PhoneNumber::Bbs; | 621 | else if ( tmpStr == "bbs" ) type |= PhoneNumber::Bbs; |
621 | else if ( tmpStr == "modem" ) type |= PhoneNumber::Modem; | 622 | else if ( tmpStr == "modem" ) type |= PhoneNumber::Modem; |
622 | else if ( tmpStr == "car" ) type |= PhoneNumber::Car; | 623 | else if ( tmpStr == "car" ) type |= PhoneNumber::Car; |
623 | else if ( tmpStr == "isdn" ) type |= PhoneNumber::Isdn; | 624 | else if ( tmpStr == "isdn" ) type |= PhoneNumber::Isdn; |
624 | else if ( tmpStr == "pcs" ) type |= PhoneNumber::Pcs; | 625 | else if ( tmpStr == "pcs" ) type |= PhoneNumber::Pcs; |
625 | else if ( tmpStr == "pager" ) type |= PhoneNumber::Pager; | 626 | else if ( tmpStr == "pager" ) type |= PhoneNumber::Pager; |
627 | else if ( tmpStr == "sip" ) type |= PhoneNumber::Sip; | ||
626 | } | 628 | } |
627 | } | 629 | } |
628 | p.setType( type ); | 630 | p.setType( type ); |
629 | 631 | ||
630 | return p; | 632 | return p; |
631 | } | 633 | } |
632 | 634 | ||
633 | QString VCardFormatImpl::readTextValue( ContentLine *cl ) | 635 | QString VCardFormatImpl::readTextValue( ContentLine *cl ) |
634 | { | 636 | { |
635 | VCARD::Value *value = cl->value(); | 637 | VCARD::Value *value = cl->value(); |
636 | if ( value ) { | 638 | if ( value ) { |
637 | return QString::fromUtf8( value->asString() ); | 639 | return QString::fromUtf8( value->asString() ); |
638 | } else { | 640 | } else { |
639 | kdDebug(5700) << "No value: " << cl->asString() << endl; | 641 | kdDebug(5700) << "No value: " << cl->asString() << endl; |
640 | return QString::null; | 642 | return QString::null; |
641 | } | 643 | } |
642 | } | 644 | } |
643 | 645 | ||
644 | QDate VCardFormatImpl::readDateValue( ContentLine *cl ) | 646 | QDate VCardFormatImpl::readDateValue( ContentLine *cl ) |
645 | { | 647 | { |
646 | DateValue *dateValue = (DateValue *)cl->value(); | 648 | DateValue *dateValue = (DateValue *)cl->value(); |
647 | if ( dateValue ) | 649 | if ( dateValue ) |
648 | return dateValue->qdate(); | 650 | return dateValue->qdate(); |
649 | else | 651 | else |
650 | return QDate(); | 652 | return QDate(); |
651 | } | 653 | } |
652 | 654 | ||
653 | QDateTime VCardFormatImpl::readDateTimeValue( ContentLine *cl ) | 655 | QDateTime VCardFormatImpl::readDateTimeValue( ContentLine *cl ) |
654 | { | 656 | { |
655 | DateValue *dateValue = (DateValue *)cl->value(); | 657 | DateValue *dateValue = (DateValue *)cl->value(); |
656 | if ( dateValue ) | 658 | if ( dateValue ) |
657 | return dateValue->qdt(); | 659 | return dateValue->qdt(); |
658 | else | 660 | else |
659 | return QDateTime(); | 661 | return QDateTime(); |
660 | } | 662 | } |
661 | 663 | ||
662 | Geo VCardFormatImpl::readGeoValue( ContentLine *cl ) | 664 | Geo VCardFormatImpl::readGeoValue( ContentLine *cl ) |
663 | { | 665 | { |
664 | GeoValue *geoValue = (GeoValue *)cl->value(); | 666 | GeoValue *geoValue = (GeoValue *)cl->value(); |
665 | if ( geoValue ) { | 667 | if ( geoValue ) { |
666 | Geo geo( geoValue->latitude(), geoValue->longitude() ); | 668 | Geo geo( geoValue->latitude(), geoValue->longitude() ); |
667 | return geo; | 669 | return geo; |
668 | } else | 670 | } else |
669 | return Geo(); | 671 | return Geo(); |
670 | } | 672 | } |
671 | 673 | ||
672 | TimeZone VCardFormatImpl::readUTCValue( ContentLine *cl ) | 674 | TimeZone VCardFormatImpl::readUTCValue( ContentLine *cl ) |
673 | { | 675 | { |
674 | UTCValue *utcValue = (UTCValue *)cl->value(); | 676 | UTCValue *utcValue = (UTCValue *)cl->value(); |
675 | if ( utcValue ) { | 677 | if ( utcValue ) { |
676 | TimeZone tz; | 678 | TimeZone tz; |
677 | tz.setOffset(((utcValue->hour()*60)+utcValue->minute())*(utcValue->positive() ? 1 : -1)); | 679 | tz.setOffset(((utcValue->hour()*60)+utcValue->minute())*(utcValue->positive() ? 1 : -1)); |
678 | return tz; | 680 | return tz; |
679 | } else | 681 | } else |
680 | return TimeZone(); | 682 | return TimeZone(); |
681 | } | 683 | } |
682 | 684 | ||
683 | Secrecy VCardFormatImpl::readClassValue( ContentLine *cl ) | 685 | Secrecy VCardFormatImpl::readClassValue( ContentLine *cl ) |
684 | { | 686 | { |
685 | ClassValue *classValue = (ClassValue *)cl->value(); | 687 | ClassValue *classValue = (ClassValue *)cl->value(); |
686 | if ( classValue ) { | 688 | if ( classValue ) { |
687 | Secrecy secrecy; | 689 | Secrecy secrecy; |
688 | switch ( classValue->type() ) { | 690 | switch ( classValue->type() ) { |
689 | case ClassValue::Public: | 691 | case ClassValue::Public: |
690 | secrecy.setType( Secrecy::Public ); | 692 | secrecy.setType( Secrecy::Public ); |
691 | break; | 693 | break; |
692 | case ClassValue::Private: | 694 | case ClassValue::Private: |
693 | secrecy.setType( Secrecy::Private ); | 695 | secrecy.setType( Secrecy::Private ); |
694 | break; | 696 | break; |
695 | case ClassValue::Confidential: | 697 | case ClassValue::Confidential: |
696 | secrecy.setType( Secrecy::Confidential ); | 698 | secrecy.setType( Secrecy::Confidential ); |
697 | break; | 699 | break; |
698 | } | 700 | } |
699 | 701 | ||
700 | return secrecy; | 702 | return secrecy; |
701 | } else | 703 | } else |
702 | return Secrecy(); | 704 | return Secrecy(); |
703 | } | 705 | } |
704 | 706 | ||
705 | void VCardFormatImpl::addKeyValue( VCARD::VCard *vcard, const Key &key ) | 707 | void VCardFormatImpl::addKeyValue( VCARD::VCard *vcard, const Key &key ) |
706 | { | 708 | { |
707 | ContentLine cl; | 709 | ContentLine cl; |
708 | cl.setName( EntityTypeToParamName( EntityKey ) ); | 710 | cl.setName( EntityTypeToParamName( EntityKey ) ); |
709 | 711 | ||
710 | ParamList params; | 712 | ParamList params; |
711 | if ( key.isBinary() ) { | 713 | if ( key.isBinary() ) { |
712 | cl.setValue( new TextValue( KCodecs::base64Encode( key.binaryData() ) ) ); | 714 | cl.setValue( new TextValue( KCodecs::base64Encode( key.binaryData() ) ) ); |
713 | params.append( new Param( "ENCODING", "b" ) ); | 715 | params.append( new Param( "ENCODING", "b" ) ); |
714 | } else { | 716 | } else { |
715 | cl.setValue( new TextValue( key.textData().utf8() ) ); | 717 | cl.setValue( new TextValue( key.textData().utf8() ) ); |
716 | } | 718 | } |
717 | 719 | ||
718 | switch ( key.type() ) { | 720 | switch ( key.type() ) { |
719 | case Key::X509: | 721 | case Key::X509: |
720 | params.append( new Param( "TYPE", "X509" ) ); | 722 | params.append( new Param( "TYPE", "X509" ) ); |
721 | break; | 723 | break; |
722 | case Key::PGP: | 724 | case Key::PGP: |
723 | params.append( new Param( "TYPE", "PGP" ) ); | 725 | params.append( new Param( "TYPE", "PGP" ) ); |
724 | break; | 726 | break; |
725 | case Key::Custom: | 727 | case Key::Custom: |
726 | params.append( new Param( "TYPE", key.customTypeString().utf8() ) ); | 728 | params.append( new Param( "TYPE", key.customTypeString().utf8() ) ); |
727 | break; | 729 | break; |
728 | } | 730 | } |
729 | 731 | ||
730 | cl.setParamList( params ); | 732 | cl.setParamList( params ); |
731 | vcard->add( cl ); | 733 | vcard->add( cl ); |
732 | } | 734 | } |
733 | 735 | ||
734 | Key VCardFormatImpl::readKeyValue( VCARD::ContentLine *cl ) | 736 | Key VCardFormatImpl::readKeyValue( VCARD::ContentLine *cl ) |
735 | { | 737 | { |
736 | Key key; | 738 | Key key; |
737 | bool isBinary = false; | 739 | bool isBinary = false; |
738 | TextValue *v = (TextValue *)cl->value(); | 740 | TextValue *v = (TextValue *)cl->value(); |
739 | 741 | ||
740 | ParamList params = cl->paramList(); | 742 | ParamList params = cl->paramList(); |
741 | ParamListIterator it( params ); | 743 | ParamListIterator it( params ); |
742 | for( ; it.current(); ++it ) { | 744 | for( ; it.current(); ++it ) { |
743 | if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) | 745 | if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) |
744 | isBinary = true; | 746 | isBinary = true; |
745 | if ( (*it)->name() == "TYPE" ) { | 747 | if ( (*it)->name() == "TYPE" ) { |
746 | if ( (*it)->value().isEmpty() ) | 748 | if ( (*it)->value().isEmpty() ) |
747 | continue; | 749 | continue; |
748 | if ( (*it)->value() == "X509" ) | 750 | if ( (*it)->value() == "X509" ) |
749 | key.setType( Key::X509 ); | 751 | key.setType( Key::X509 ); |
750 | else if ( (*it)->value() == "PGP" ) | 752 | else if ( (*it)->value() == "PGP" ) |
751 | key.setType( Key::PGP ); | 753 | key.setType( Key::PGP ); |
752 | else { | 754 | else { |
753 | key.setType( Key::Custom ); | 755 | key.setType( Key::Custom ); |
754 | key.setCustomTypeString( QString::fromUtf8( (*it)->value() ) ); | 756 | key.setCustomTypeString( QString::fromUtf8( (*it)->value() ) ); |
755 | } | 757 | } |
756 | } | 758 | } |
757 | } | 759 | } |
758 | 760 | ||
759 | 761 | ||
760 | if ( isBinary ) { | 762 | if ( isBinary ) { |
761 | QByteArray data; | 763 | QByteArray data; |
762 | KCodecs::base64Decode( v->asString().stripWhiteSpace(), data ); | 764 | KCodecs::base64Decode( v->asString().stripWhiteSpace(), data ); |
763 | key.setBinaryData( data ); | 765 | key.setBinaryData( data ); |
764 | } else { | 766 | } else { |
765 | key.setTextData( QString::fromUtf8( v->asString() ) ); | 767 | key.setTextData( QString::fromUtf8( v->asString() ) ); |
766 | } | 768 | } |
767 | 769 | ||
768 | return key; | 770 | return key; |
769 | } | 771 | } |
770 | 772 | ||
771 | 773 | ||
772 | void VCardFormatImpl::addAgentValue( VCARD::VCard *vcard, const Agent &agent ) | 774 | void VCardFormatImpl::addAgentValue( VCARD::VCard *vcard, const Agent &agent ) |
773 | { | 775 | { |
774 | if ( agent.isIntern() && !agent.addressee() ) | 776 | if ( agent.isIntern() && !agent.addressee() ) |
775 | return; | 777 | return; |
776 | 778 | ||
777 | if ( !agent.isIntern() && agent.url().isEmpty() ) | 779 | if ( !agent.isIntern() && agent.url().isEmpty() ) |
778 | return; | 780 | return; |
779 | 781 | ||
780 | ContentLine cl; | 782 | ContentLine cl; |
781 | cl.setName( EntityTypeToParamName( EntityAgent ) ); | 783 | cl.setName( EntityTypeToParamName( EntityAgent ) ); |
782 | 784 | ||
783 | ParamList params; | 785 | ParamList params; |
784 | if ( agent.isIntern() ) { | 786 | if ( agent.isIntern() ) { |
785 | QString vstr; | 787 | QString vstr; |
786 | Addressee *addr = agent.addressee(); | 788 | Addressee *addr = agent.addressee(); |
787 | if ( addr ) { | 789 | if ( addr ) { |
788 | writeToString( (*addr), vstr ); | 790 | writeToString( (*addr), vstr ); |
789 | 791 | ||
790 | qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); | 792 | qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); |
791 | /*US | 793 | /*US |
792 | vstr.replace( ":", "\\:" ); | 794 | vstr.replace( ":", "\\:" ); |
793 | vstr.replace( ",", "\\," ); | 795 | vstr.replace( ",", "\\," ); |
794 | vstr.replace( ";", "\\;" ); | 796 | vstr.replace( ";", "\\;" ); |
795 | vstr.replace( "\r\n", "\\n" ); | 797 | vstr.replace( "\r\n", "\\n" ); |
796 | */ | 798 | */ |
797 | vstr.replace( QRegExp(":"), "\\:" ); | 799 | vstr.replace( QRegExp(":"), "\\:" ); |
798 | vstr.replace( QRegExp(","), "\\," ); | 800 | vstr.replace( QRegExp(","), "\\," ); |
799 | vstr.replace( QRegExp(";"), "\\;" ); | 801 | vstr.replace( QRegExp(";"), "\\;" ); |
800 | vstr.replace( QRegExp("\r\n"), "\\n" ); | 802 | vstr.replace( QRegExp("\r\n"), "\\n" ); |
801 | 803 | ||
802 | cl.setValue( new TextValue( vstr.utf8() ) ); | 804 | cl.setValue( new TextValue( vstr.utf8() ) ); |
803 | } else | 805 | } else |
804 | return; | 806 | return; |
805 | } else { | 807 | } else { |
806 | cl.setValue( new TextValue( agent.url().utf8() ) ); | 808 | cl.setValue( new TextValue( agent.url().utf8() ) ); |
807 | params.append( new Param( "VALUE", "uri" ) ); | 809 | params.append( new Param( "VALUE", "uri" ) ); |
808 | } | 810 | } |
809 | 811 | ||
810 | cl.setParamList( params ); | 812 | cl.setParamList( params ); |
811 | vcard->add( cl ); | 813 | vcard->add( cl ); |
812 | } | 814 | } |
813 | 815 | ||
814 | Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl ) | 816 | Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl ) |
815 | { | 817 | { |
816 | Agent agent; | 818 | Agent agent; |
817 | bool isIntern = true; | 819 | bool isIntern = true; |
818 | TextValue *v = (TextValue *)cl->value(); | 820 | TextValue *v = (TextValue *)cl->value(); |
819 | 821 | ||
820 | ParamList params = cl->paramList(); | 822 | ParamList params = cl->paramList(); |
821 | ParamListIterator it( params ); | 823 | ParamListIterator it( params ); |
822 | for( ; it.current(); ++it ) { | 824 | for( ; it.current(); ++it ) { |
823 | if ( (*it)->name() == "VALUE" && (*it)->value() == "uri" ) | 825 | if ( (*it)->name() == "VALUE" && (*it)->value() == "uri" ) |
824 | isIntern = false; | 826 | isIntern = false; |
825 | } | 827 | } |
826 | 828 | ||
827 | if ( isIntern ) { | 829 | if ( isIntern ) { |
828 | QString vstr = QString::fromUtf8( v->asString() ); | 830 | QString vstr = QString::fromUtf8( v->asString() ); |
829 | qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); | 831 | qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); |
830 | /*US | 832 | /*US |
831 | vstr.replace( "\\n", "\r\n" ); | 833 | vstr.replace( "\\n", "\r\n" ); |
832 | vstr.replace( "\\:", ":" ); | 834 | vstr.replace( "\\:", ":" ); |
833 | vstr.replace( "\\,", "," ); | 835 | vstr.replace( "\\,", "," ); |
834 | vstr.replace( "\\;", ";" ); | 836 | vstr.replace( "\\;", ";" ); |
835 | */ | 837 | */ |
836 | vstr.replace( QRegExp("\\n"), "\r\n" ); | 838 | vstr.replace( QRegExp("\\n"), "\r\n" ); |
837 | vstr.replace( QRegExp("\\:"), ":" ); | 839 | vstr.replace( QRegExp("\\:"), ":" ); |
838 | vstr.replace( QRegExp("\\,"), "," ); | 840 | vstr.replace( QRegExp("\\,"), "," ); |
839 | vstr.replace( QRegExp("\\;"), ";" ); | 841 | vstr.replace( QRegExp("\\;"), ";" ); |
840 | 842 | ||
841 | Addressee *addr = new Addressee; | 843 | Addressee *addr = new Addressee; |
842 | readFromString( vstr, *addr ); | 844 | readFromString( vstr, *addr ); |
843 | agent.setAddressee( addr ); | 845 | agent.setAddressee( addr ); |
844 | } else { | 846 | } else { |
845 | agent.setUrl( QString::fromUtf8( v->asString() ) ); | 847 | agent.setUrl( QString::fromUtf8( v->asString() ) ); |
846 | } | 848 | } |
847 | 849 | ||
848 | return agent; | 850 | return agent; |
849 | } | 851 | } |
850 | 852 | ||
851 | void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType type, const Picture &pic, const Addressee &addr, bool intern ) | 853 | void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType type, const Picture &pic, const Addressee &addr, bool intern ) |
852 | { | 854 | { |
853 | ContentLine cl; | 855 | ContentLine cl; |
854 | cl.setName( EntityTypeToParamName( type ) ); | 856 | cl.setName( EntityTypeToParamName( type ) ); |
855 | 857 | ||
856 | if ( pic.isIntern() && pic.data().isNull() ) | 858 | if ( pic.isIntern() && pic.data().isNull() ) |
857 | return; | 859 | return; |
858 | 860 | ||
859 | if ( !pic.isIntern() && pic.url().isEmpty() ) | 861 | if ( !pic.isIntern() && pic.url().isEmpty() ) |
860 | return; | 862 | return; |
861 | 863 | ||
862 | ParamList params; | 864 | ParamList params; |
863 | if ( pic.isIntern() ) { | 865 | if ( pic.isIntern() ) { |
864 | QImage img = pic.data(); | 866 | QImage img = pic.data(); |
865 | if ( intern ) { // only for vCard export we really write the data inline | 867 | if ( intern ) { // only for vCard export we really write the data inline |
866 | QByteArray data; | 868 | QByteArray data; |
867 | QDataStream s( data, IO_WriteOnly ); | 869 | QDataStream s( data, IO_WriteOnly ); |
868 | s.setVersion( 4 ); // to produce valid png files | 870 | s.setVersion( 4 ); // to produce valid png files |
869 | s << img; | 871 | s << img; |
870 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); | 872 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); |
871 | 873 | ||
872 | } else { // save picture in cache | 874 | } else { // save picture in cache |
873 | QString dir; | 875 | QString dir; |
874 | if ( type == EntityPhoto ) | 876 | if ( type == EntityPhoto ) |
875 | dir = "photos"; | 877 | dir = "photos"; |
876 | if ( type == EntityLogo ) | 878 | if ( type == EntityLogo ) |
877 | dir = "logos"; | 879 | dir = "logos"; |
878 | 880 | ||
879 | img.save( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ), pic.type().utf8() ); | 881 | img.save( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ), pic.type().utf8() ); |
880 | cl.setValue( new TextValue( "<dummy>" ) ); | 882 | cl.setValue( new TextValue( "<dummy>" ) ); |
881 | } | 883 | } |
882 | params.append( new Param( "ENCODING", "b" ) ); | 884 | params.append( new Param( "ENCODING", "b" ) ); |
883 | if ( !pic.type().isEmpty() ) | 885 | if ( !pic.type().isEmpty() ) |
884 | params.append( new Param( "TYPE", pic.type().utf8() ) ); | 886 | params.append( new Param( "TYPE", pic.type().utf8() ) ); |
885 | } else { | 887 | } else { |
886 | 888 | ||
887 | cl.setValue( new TextValue( pic.url().utf8() ) ); | 889 | cl.setValue( new TextValue( pic.url().utf8() ) ); |
888 | params.append( new Param( "VALUE", "uri" ) ); | 890 | params.append( new Param( "VALUE", "uri" ) ); |
889 | } | 891 | } |
890 | 892 | ||
891 | cl.setParamList( params ); | 893 | cl.setParamList( params ); |
892 | vcard->add( cl ); | 894 | vcard->add( cl ); |
893 | } | 895 | } |
894 | 896 | ||
895 | Picture VCardFormatImpl::readPictureValue( VCARD::ContentLine *cl, VCARD::EntityType type, const Addressee &addr ) | 897 | Picture VCardFormatImpl::readPictureValue( VCARD::ContentLine *cl, VCARD::EntityType type, const Addressee &addr ) |
896 | { | 898 | { |
897 | Picture pic; | 899 | Picture pic; |
898 | bool isInline = false; | 900 | bool isInline = false; |
899 | QString picType; | 901 | QString picType; |
900 | TextValue *v = (TextValue *)cl->value(); | 902 | TextValue *v = (TextValue *)cl->value(); |
901 | 903 | ||
902 | ParamList params = cl->paramList(); | 904 | ParamList params = cl->paramList(); |
903 | ParamListIterator it( params ); | 905 | ParamListIterator it( params ); |
904 | for( ; it.current(); ++it ) { | 906 | for( ; it.current(); ++it ) { |
905 | if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) | 907 | if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) |
906 | isInline = true; | 908 | isInline = true; |
907 | if ( (*it)->name() == "TYPE" && !(*it)->value().isEmpty() ) | 909 | if ( (*it)->name() == "TYPE" && !(*it)->value().isEmpty() ) |
908 | picType = QString::fromUtf8( (*it)->value() ); | 910 | picType = QString::fromUtf8( (*it)->value() ); |
909 | } | 911 | } |
910 | 912 | ||
911 | if ( isInline ) { | 913 | if ( isInline ) { |
912 | QImage img; | 914 | QImage img; |
913 | if ( v->asString() == "<dummy>" ) { // no picture inline stored => picture is in cache | 915 | if ( v->asString() == "<dummy>" ) { // no picture inline stored => picture is in cache |
914 | QString dir; | 916 | QString dir; |
915 | if ( type == EntityPhoto ) | 917 | if ( type == EntityPhoto ) |
916 | dir = "photos"; | 918 | dir = "photos"; |
917 | if ( type == EntityLogo ) | 919 | if ( type == EntityLogo ) |
918 | dir = "logos"; | 920 | dir = "logos"; |
919 | 921 | ||
920 | img.load( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ) ); | 922 | img.load( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ) ); |
921 | } else { | 923 | } else { |
922 | QByteArray data; | 924 | QByteArray data; |
923 | KCodecs::base64Decode( v->asString(), data ); | 925 | KCodecs::base64Decode( v->asString(), data ); |
924 | img.loadFromData( data ); | 926 | img.loadFromData( data ); |
925 | } | 927 | } |
926 | pic.setData( img ); | 928 | pic.setData( img ); |
927 | pic.setType( picType ); | 929 | pic.setType( picType ); |
928 | } else { | 930 | } else { |
929 | pic.setUrl( QString::fromUtf8( v->asString() ) ); | 931 | pic.setUrl( QString::fromUtf8( v->asString() ) ); |
930 | } | 932 | } |
931 | 933 | ||
932 | return pic; | 934 | return pic; |
933 | } | 935 | } |
934 | 936 | ||
935 | void VCardFormatImpl::addSoundValue( VCARD::VCard *vcard, const Sound &sound, const Addressee &addr, bool intern ) | 937 | void VCardFormatImpl::addSoundValue( VCARD::VCard *vcard, const Sound &sound, const Addressee &addr, bool intern ) |
936 | { | 938 | { |
937 | ContentLine cl; | 939 | ContentLine cl; |
938 | cl.setName( EntityTypeToParamName( EntitySound ) ); | 940 | cl.setName( EntityTypeToParamName( EntitySound ) ); |
939 | 941 | ||
940 | if ( sound.isIntern() && sound.data().isNull() ) | 942 | if ( sound.isIntern() && sound.data().isNull() ) |
941 | return; | 943 | return; |
942 | 944 | ||
943 | if ( !sound.isIntern() && sound.url().isEmpty() ) | 945 | if ( !sound.isIntern() && sound.url().isEmpty() ) |
944 | return; | 946 | return; |
945 | 947 | ||
946 | ParamList params; | 948 | ParamList params; |
947 | if ( sound.isIntern() ) { | 949 | if ( sound.isIntern() ) { |
948 | QByteArray data = sound.data(); | 950 | QByteArray data = sound.data(); |
949 | if ( intern ) { // only for vCard export we really write the data inline | 951 | if ( intern ) { // only for vCard export we really write the data inline |
950 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); | 952 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); |
951 | } else { // save sound in cache | 953 | } else { // save sound in cache |
952 | QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); | 954 | QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); |
953 | if ( file.open( IO_WriteOnly ) ) { | 955 | if ( file.open( IO_WriteOnly ) ) { |
954 | file.writeBlock( data ); | 956 | file.writeBlock( data ); |
955 | } | 957 | } |
956 | cl.setValue( new TextValue( "<dummy>" ) ); | 958 | cl.setValue( new TextValue( "<dummy>" ) ); |
957 | } | 959 | } |
958 | params.append( new Param( "ENCODING", "b" ) ); | 960 | params.append( new Param( "ENCODING", "b" ) ); |
959 | } else { | 961 | } else { |
960 | cl.setValue( new TextValue( sound.url().utf8() ) ); | 962 | cl.setValue( new TextValue( sound.url().utf8() ) ); |
961 | params.append( new Param( "VALUE", "uri" ) ); | 963 | params.append( new Param( "VALUE", "uri" ) ); |
962 | } | 964 | } |
963 | 965 | ||
964 | cl.setParamList( params ); | 966 | cl.setParamList( params ); |
965 | vcard->add( cl ); | 967 | vcard->add( cl ); |
966 | } | 968 | } |
967 | 969 | ||
968 | Sound VCardFormatImpl::readSoundValue( VCARD::ContentLine *cl, const Addressee &addr ) | 970 | Sound VCardFormatImpl::readSoundValue( VCARD::ContentLine *cl, const Addressee &addr ) |
969 | { | 971 | { |
970 | Sound sound; | 972 | Sound sound; |
971 | bool isInline = false; | 973 | bool isInline = false; |
972 | TextValue *v = (TextValue *)cl->value(); | 974 | TextValue *v = (TextValue *)cl->value(); |
973 | 975 | ||
974 | ParamList params = cl->paramList(); | 976 | ParamList params = cl->paramList(); |
975 | ParamListIterator it( params ); | 977 | ParamListIterator it( params ); |
976 | for( ; it.current(); ++it ) { | 978 | for( ; it.current(); ++it ) { |
977 | if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) | 979 | if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) |
978 | isInline = true; | 980 | isInline = true; |
979 | } | 981 | } |
980 | 982 | ||
981 | if ( isInline ) { | 983 | if ( isInline ) { |
982 | QByteArray data; | 984 | QByteArray data; |
983 | if ( v->asString() == "<dummy>" ) { // no sound inline stored => sound is in cache | 985 | if ( v->asString() == "<dummy>" ) { // no sound inline stored => sound is in cache |
984 | QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); | 986 | QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); |
985 | if ( file.open( IO_ReadOnly ) ) { | 987 | if ( file.open( IO_ReadOnly ) ) { |
986 | data = file.readAll(); | 988 | data = file.readAll(); |
987 | file.close(); | 989 | file.close(); |
988 | } | 990 | } |
989 | } else { | 991 | } else { |
990 | KCodecs::base64Decode( v->asString(), data ); | 992 | KCodecs::base64Decode( v->asString(), data ); |
991 | } | 993 | } |
992 | sound.setData( data ); | 994 | sound.setData( data ); |
993 | } else { | 995 | } else { |
994 | sound.setUrl( QString::fromUtf8( v->asString() ) ); | 996 | sound.setUrl( QString::fromUtf8( v->asString() ) ); |
995 | } | 997 | } |
996 | 998 | ||
997 | return sound; | 999 | return sound; |
998 | } | 1000 | } |
999 | 1001 | ||
1000 | bool VCardFormatImpl::readFromString( const QString &vcard, Addressee &addressee ) | 1002 | bool VCardFormatImpl::readFromString( const QString &vcard, Addressee &addressee ) |
1001 | { | 1003 | { |
1002 | VCardEntity e( vcard.utf8() ); | 1004 | VCardEntity e( vcard.utf8() ); |
1003 | VCardListIterator it( e.cardList() ); | 1005 | VCardListIterator it( e.cardList() ); |
1004 | 1006 | ||
1005 | if ( it.current() ) { | 1007 | if ( it.current() ) { |
1006 | //US VCard v(*it.current()); | 1008 | //US VCard v(*it.current()); |
1007 | //US loadAddressee( addressee, v ); | 1009 | //US loadAddressee( addressee, v ); |
1008 | loadAddressee( addressee, it.current() ); | 1010 | loadAddressee( addressee, it.current() ); |
1009 | return true; | 1011 | return true; |
diff --git a/kabc/vcardparser/vcardtool.cpp b/kabc/vcardparser/vcardtool.cpp index 71f29d7..3fb212e 100644 --- a/kabc/vcardparser/vcardtool.cpp +++ b/kabc/vcardparser/vcardtool.cpp | |||
@@ -1,443 +1,444 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@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 | #include <qdatastream.h> | 21 | #include <qdatastream.h> |
22 | #include <qstring.h> | 22 | #include <qstring.h> |
23 | #include <qregexp.h> | 23 | #include <qregexp.h> |
24 | #include <kmdcodec.h> | 24 | #include <kmdcodec.h> |
25 | 25 | ||
26 | #include "agent.h" | 26 | #include "agent.h" |
27 | #include "key.h" | 27 | #include "key.h" |
28 | #include "picture.h" | 28 | #include "picture.h" |
29 | #include "secrecy.h" | 29 | #include "secrecy.h" |
30 | #include "sound.h" | 30 | #include "sound.h" |
31 | 31 | ||
32 | #include "vcardtool.h" | 32 | #include "vcardtool.h" |
33 | 33 | ||
34 | using namespace KABC; | 34 | using namespace KABC; |
35 | 35 | ||
36 | VCardTool::VCardTool() | 36 | VCardTool::VCardTool() |
37 | { | 37 | { |
38 | mAddressTypeMap.insert( "dom", Address::Dom ); | 38 | mAddressTypeMap.insert( "dom", Address::Dom ); |
39 | mAddressTypeMap.insert( "intl", Address::Intl ); | 39 | mAddressTypeMap.insert( "intl", Address::Intl ); |
40 | mAddressTypeMap.insert( "postal", Address::Postal ); | 40 | mAddressTypeMap.insert( "postal", Address::Postal ); |
41 | mAddressTypeMap.insert( "parcel", Address::Parcel ); | 41 | mAddressTypeMap.insert( "parcel", Address::Parcel ); |
42 | mAddressTypeMap.insert( "home", Address::Home ); | 42 | mAddressTypeMap.insert( "home", Address::Home ); |
43 | mAddressTypeMap.insert( "work", Address::Work ); | 43 | mAddressTypeMap.insert( "work", Address::Work ); |
44 | mAddressTypeMap.insert( "pref", Address::Pref ); | 44 | mAddressTypeMap.insert( "pref", Address::Pref ); |
45 | 45 | ||
46 | mPhoneTypeMap.insert( "HOME", PhoneNumber::Home ); | 46 | mPhoneTypeMap.insert( "HOME", PhoneNumber::Home ); |
47 | mPhoneTypeMap.insert( "WORK", PhoneNumber::Work ); | 47 | mPhoneTypeMap.insert( "WORK", PhoneNumber::Work ); |
48 | mPhoneTypeMap.insert( "MSG", PhoneNumber::Msg ); | 48 | mPhoneTypeMap.insert( "MSG", PhoneNumber::Msg ); |
49 | mPhoneTypeMap.insert( "PREF", PhoneNumber::Pref ); | 49 | mPhoneTypeMap.insert( "PREF", PhoneNumber::Pref ); |
50 | mPhoneTypeMap.insert( "VOICE", PhoneNumber::Voice ); | 50 | mPhoneTypeMap.insert( "VOICE", PhoneNumber::Voice ); |
51 | mPhoneTypeMap.insert( "FAX", PhoneNumber::Fax ); | 51 | mPhoneTypeMap.insert( "FAX", PhoneNumber::Fax ); |
52 | mPhoneTypeMap.insert( "CELL", PhoneNumber::Cell ); | 52 | mPhoneTypeMap.insert( "CELL", PhoneNumber::Cell ); |
53 | mPhoneTypeMap.insert( "VIDEO", PhoneNumber::Video ); | 53 | mPhoneTypeMap.insert( "VIDEO", PhoneNumber::Video ); |
54 | mPhoneTypeMap.insert( "BBS", PhoneNumber::Bbs ); | 54 | mPhoneTypeMap.insert( "BBS", PhoneNumber::Bbs ); |
55 | mPhoneTypeMap.insert( "MODEM", PhoneNumber::Modem ); | 55 | mPhoneTypeMap.insert( "MODEM", PhoneNumber::Modem ); |
56 | mPhoneTypeMap.insert( "CAR", PhoneNumber::Car ); | 56 | mPhoneTypeMap.insert( "CAR", PhoneNumber::Car ); |
57 | mPhoneTypeMap.insert( "ISDN", PhoneNumber::Isdn ); | 57 | mPhoneTypeMap.insert( "ISDN", PhoneNumber::Isdn ); |
58 | mPhoneTypeMap.insert( "PCS", PhoneNumber::Pcs ); | 58 | mPhoneTypeMap.insert( "PCS", PhoneNumber::Pcs ); |
59 | mPhoneTypeMap.insert( "PAGER", PhoneNumber::Pager ); | 59 | mPhoneTypeMap.insert( "PAGER", PhoneNumber::Pager ); |
60 | mPhoneTypeMap.insert( "SIP", PhoneNumber::Sip ); | ||
60 | } | 61 | } |
61 | 62 | ||
62 | VCardTool::~VCardTool() | 63 | VCardTool::~VCardTool() |
63 | { | 64 | { |
64 | } | 65 | } |
65 | 66 | ||
66 | QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | 67 | QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) |
67 | { | 68 | { |
68 | VCard::List vCardList; | 69 | VCard::List vCardList; |
69 | 70 | ||
70 | Addressee::List::Iterator addrIt; | 71 | Addressee::List::Iterator addrIt; |
71 | for ( addrIt = list.begin(); addrIt != list.end(); ++addrIt ) { | 72 | for ( addrIt = list.begin(); addrIt != list.end(); ++addrIt ) { |
72 | VCard card; | 73 | VCard card; |
73 | QStringList::ConstIterator strIt; | 74 | QStringList::ConstIterator strIt; |
74 | 75 | ||
75 | // ADR + LABEL | 76 | // ADR + LABEL |
76 | Address::List addresses = (*addrIt).addresses(); | 77 | Address::List addresses = (*addrIt).addresses(); |
77 | for ( Address::List::Iterator it = addresses.begin(); it != addresses.end(); ++it ) { | 78 | for ( Address::List::Iterator it = addresses.begin(); it != addresses.end(); ++it ) { |
78 | QStringList address; | 79 | QStringList address; |
79 | 80 | ||
80 | /*US | 81 | /*US |
81 | address.append( (*it).postOfficeBox().replace( ';', "\\;" ) ); | 82 | address.append( (*it).postOfficeBox().replace( ';', "\\;" ) ); |
82 | address.append( (*it).extended().replace( ';', "\\;" ) ); | 83 | address.append( (*it).extended().replace( ';', "\\;" ) ); |
83 | address.append( (*it).street().replace( ';', "\\;" ) ); | 84 | address.append( (*it).street().replace( ';', "\\;" ) ); |
84 | address.append( (*it).locality().replace( ';', "\\;" ) ); | 85 | address.append( (*it).locality().replace( ';', "\\;" ) ); |
85 | address.append( (*it).region().replace( ';', "\\;" ) ); | 86 | address.append( (*it).region().replace( ';', "\\;" ) ); |
86 | address.append( (*it).postalCode().replace( ';', "\\;" ) ); | 87 | address.append( (*it).postalCode().replace( ';', "\\;" ) ); |
87 | address.append( (*it).country().replace( ';', "\\;" ) ); | 88 | address.append( (*it).country().replace( ';', "\\;" ) ); |
88 | */ | 89 | */ |
89 | //US using the old implementation instead | 90 | //US using the old implementation instead |
90 | //qDebug("VCardTool::createVCards has to be verified"); | 91 | //qDebug("VCardTool::createVCards has to be verified"); |
91 | address.append( (*it).postOfficeBox().replace( QRegExp(";"), "\\;" ) ); | 92 | address.append( (*it).postOfficeBox().replace( QRegExp(";"), "\\;" ) ); |
92 | address.append( (*it).extended().replace( QRegExp(";"), "\\;" ) ); | 93 | address.append( (*it).extended().replace( QRegExp(";"), "\\;" ) ); |
93 | address.append( (*it).street().replace( QRegExp(";"), "\\;" ) ); | 94 | address.append( (*it).street().replace( QRegExp(";"), "\\;" ) ); |
94 | address.append( (*it).locality().replace( QRegExp(";"), "\\;" ) ); | 95 | address.append( (*it).locality().replace( QRegExp(";"), "\\;" ) ); |
95 | address.append( (*it).region().replace( QRegExp(";"), "\\;" ) ); | 96 | address.append( (*it).region().replace( QRegExp(";"), "\\;" ) ); |
96 | address.append( (*it).postalCode().replace( QRegExp(";"), "\\;" ) ); | 97 | address.append( (*it).postalCode().replace( QRegExp(";"), "\\;" ) ); |
97 | address.append( (*it).country().replace( QRegExp(";"), "\\;" ) ); | 98 | address.append( (*it).country().replace( QRegExp(";"), "\\;" ) ); |
98 | 99 | ||
99 | VCardLine adrLine( "ADR", address.join( ";" ) ); | 100 | VCardLine adrLine( "ADR", address.join( ";" ) ); |
100 | VCardLine labelLine( "LABEL", (*it).label() ); | 101 | VCardLine labelLine( "LABEL", (*it).label() ); |
101 | 102 | ||
102 | bool hasLabel = !(*it).label().isEmpty(); | 103 | bool hasLabel = !(*it).label().isEmpty(); |
103 | QMap<QString, int>::Iterator typeIt; | 104 | QMap<QString, int>::Iterator typeIt; |
104 | for ( typeIt = mAddressTypeMap.begin(); typeIt != mAddressTypeMap.end(); ++typeIt ) { | 105 | for ( typeIt = mAddressTypeMap.begin(); typeIt != mAddressTypeMap.end(); ++typeIt ) { |
105 | if ( typeIt.data() & (*it).type() ) { | 106 | if ( typeIt.data() & (*it).type() ) { |
106 | if ( version == VCard::v3_0 ) { | 107 | if ( version == VCard::v3_0 ) { |
107 | adrLine.addParameter( "TYPE", typeIt.key().lower() ); | 108 | adrLine.addParameter( "TYPE", typeIt.key().lower() ); |
108 | } | 109 | } |
109 | else { | 110 | else { |
110 | adrLine.addParameter( "TYPE", typeIt.key() ); | 111 | adrLine.addParameter( "TYPE", typeIt.key() ); |
111 | } | 112 | } |
112 | if ( hasLabel ) { | 113 | if ( hasLabel ) { |
113 | if ( version == VCard::v3_0 ) { | 114 | if ( version == VCard::v3_0 ) { |
114 | labelLine.addParameter( "TYPE", typeIt.key().lower() ); | 115 | labelLine.addParameter( "TYPE", typeIt.key().lower() ); |
115 | } | 116 | } |
116 | else { | 117 | else { |
117 | labelLine.addParameter( "TYPE", typeIt.key() ); | 118 | labelLine.addParameter( "TYPE", typeIt.key() ); |
118 | } | 119 | } |
119 | } | 120 | } |
120 | } | 121 | } |
121 | } | 122 | } |
122 | 123 | ||
123 | card.addLine( adrLine ); | 124 | card.addLine( adrLine ); |
124 | if ( hasLabel ) | 125 | if ( hasLabel ) |
125 | card.addLine( labelLine ); | 126 | card.addLine( labelLine ); |
126 | } | 127 | } |
127 | 128 | ||
128 | // AGENT | 129 | // AGENT |
129 | card.addLine( createAgent( version, (*addrIt).agent() ) ); | 130 | card.addLine( createAgent( version, (*addrIt).agent() ) ); |
130 | 131 | ||
131 | // BDAY | 132 | // BDAY |
132 | card.addLine( VCardLine( "BDAY", createDateTime( (*addrIt).birthday() ) ) ); | 133 | card.addLine( VCardLine( "BDAY", createDateTime( (*addrIt).birthday() ) ) ); |
133 | 134 | ||
134 | // CATEGORIES | 135 | // CATEGORIES |
135 | if ( version == VCard::v3_0 ) { | 136 | if ( version == VCard::v3_0 ) { |
136 | QStringList categories = (*addrIt).categories(); | 137 | QStringList categories = (*addrIt).categories(); |
137 | QStringList::Iterator catIt; | 138 | QStringList::Iterator catIt; |
138 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) | 139 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) |
139 | { | 140 | { |
140 | //US using the old implementation instead | 141 | //US using the old implementation instead |
141 | // qDebug("VCardTool::createVCards has to be verified"); | 142 | // qDebug("VCardTool::createVCards has to be verified"); |
142 | //US (*catIt).replace( ',', "\\," ); | 143 | //US (*catIt).replace( ',', "\\," ); |
143 | (*catIt).replace( QRegExp(","), "\\," ); | 144 | (*catIt).replace( QRegExp(","), "\\," ); |
144 | } | 145 | } |
145 | card.addLine( VCardLine( "CATEGORIES", categories.join( "," ) ) ); | 146 | card.addLine( VCardLine( "CATEGORIES", categories.join( "," ) ) ); |
146 | } | 147 | } |
147 | 148 | ||
148 | // CLASS | 149 | // CLASS |
149 | if ( version == VCard::v3_0 ) { | 150 | if ( version == VCard::v3_0 ) { |
150 | card.addLine( createSecrecy( (*addrIt).secrecy() ) ); | 151 | card.addLine( createSecrecy( (*addrIt).secrecy() ) ); |
151 | } | 152 | } |
152 | 153 | ||
153 | 154 | ||
154 | QStringList emails = (*addrIt).emails(); | 155 | QStringList emails = (*addrIt).emails(); |
155 | bool pref = true; | 156 | bool pref = true; |
156 | for ( strIt = emails.begin(); strIt != emails.end(); ++strIt ) { | 157 | for ( strIt = emails.begin(); strIt != emails.end(); ++strIt ) { |
157 | VCardLine line( "EMAIL", *strIt ); | 158 | VCardLine line( "EMAIL", *strIt ); |
158 | if ( pref == true ) { | 159 | if ( pref == true ) { |
159 | line.addParameter( "TYPE", "PREF" ); | 160 | line.addParameter( "TYPE", "PREF" ); |
160 | pref = false; | 161 | pref = false; |
161 | } | 162 | } |
162 | card.addLine( line ); | 163 | card.addLine( line ); |
163 | } | 164 | } |
164 | 165 | ||
165 | // FN | 166 | // FN |
166 | card.addLine( VCardLine( "FN", (*addrIt).formattedName() ) ); | 167 | card.addLine( VCardLine( "FN", (*addrIt).formattedName() ) ); |
167 | 168 | ||
168 | // GEO | 169 | // GEO |
169 | Geo geo = (*addrIt).geo(); | 170 | Geo geo = (*addrIt).geo(); |
170 | if ( geo.isValid() ) { | 171 | if ( geo.isValid() ) { |
171 | QString str; | 172 | QString str; |
172 | str.sprintf( "%.6f;%.6f", geo.latitude(), geo.longitude() ); | 173 | str.sprintf( "%.6f;%.6f", geo.latitude(), geo.longitude() ); |
173 | card.addLine( VCardLine( "GEO", str ) ); | 174 | card.addLine( VCardLine( "GEO", str ) ); |
174 | } | 175 | } |
175 | 176 | ||
176 | // KEY | 177 | // KEY |
177 | Key::List keys = (*addrIt).keys(); | 178 | Key::List keys = (*addrIt).keys(); |
178 | Key::List::ConstIterator keyIt; | 179 | Key::List::ConstIterator keyIt; |
179 | for ( keyIt = keys.begin(); keyIt != keys.end(); ++keyIt ) | 180 | for ( keyIt = keys.begin(); keyIt != keys.end(); ++keyIt ) |
180 | card.addLine( createKey( *keyIt ) ); | 181 | card.addLine( createKey( *keyIt ) ); |
181 | 182 | ||
182 | // LOGO | 183 | // LOGO |
183 | card.addLine( createPicture( "LOGO", (*addrIt).logo() ) ); | 184 | card.addLine( createPicture( "LOGO", (*addrIt).logo() ) ); |
184 | 185 | ||
185 | // MAILER | 186 | // MAILER |
186 | card.addLine( VCardLine( "MAILER", (*addrIt).mailer() ) ); | 187 | card.addLine( VCardLine( "MAILER", (*addrIt).mailer() ) ); |
187 | 188 | ||
188 | // N | 189 | // N |
189 | QStringList name; | 190 | QStringList name; |
190 | //US using the old implementation instead | 191 | //US using the old implementation instead |
191 | //qDebug("VCardTool::createVCards has to be verified"); | 192 | //qDebug("VCardTool::createVCards has to be verified"); |
192 | /*US | 193 | /*US |
193 | name.append( (*addrIt).familyName().replace( ';', "\\;" ) ); | 194 | name.append( (*addrIt).familyName().replace( ';', "\\;" ) ); |
194 | name.append( (*addrIt).givenName().replace( ';', "\\;" ) ); | 195 | name.append( (*addrIt).givenName().replace( ';', "\\;" ) ); |
195 | name.append( (*addrIt).additionalName().replace( ';', "\\;" ) ); | 196 | name.append( (*addrIt).additionalName().replace( ';', "\\;" ) ); |
196 | name.append( (*addrIt).prefix().replace( ';', "\\;" ) ); | 197 | name.append( (*addrIt).prefix().replace( ';', "\\;" ) ); |
197 | name.append( (*addrIt).suffix().replace( ';', "\\;" ) ); | 198 | name.append( (*addrIt).suffix().replace( ';', "\\;" ) ); |
198 | */ | 199 | */ |
199 | name.append( (*addrIt).familyName().replace( QRegExp(";"), "\\;" ) ); | 200 | name.append( (*addrIt).familyName().replace( QRegExp(";"), "\\;" ) ); |
200 | name.append( (*addrIt).givenName().replace( QRegExp(";"), "\\;" ) ); | 201 | name.append( (*addrIt).givenName().replace( QRegExp(";"), "\\;" ) ); |
201 | name.append( (*addrIt).additionalName().replace( QRegExp(";"), "\\;" ) ); | 202 | name.append( (*addrIt).additionalName().replace( QRegExp(";"), "\\;" ) ); |
202 | name.append( (*addrIt).prefix().replace( QRegExp(";"), "\\;" ) ); | 203 | name.append( (*addrIt).prefix().replace( QRegExp(";"), "\\;" ) ); |
203 | name.append( (*addrIt).suffix().replace( QRegExp(";"), "\\;" ) ); | 204 | name.append( (*addrIt).suffix().replace( QRegExp(";"), "\\;" ) ); |
204 | 205 | ||
205 | if ( !name.join( "" ).isEmpty() ) | 206 | if ( !name.join( "" ).isEmpty() ) |
206 | card.addLine( VCardLine( "N", name.join( ";" ) ) ); | 207 | card.addLine( VCardLine( "N", name.join( ";" ) ) ); |
207 | 208 | ||
208 | // NICKNAME | 209 | // NICKNAME |
209 | if ( version == VCard::v3_0 ) | 210 | if ( version == VCard::v3_0 ) |
210 | card.addLine( VCardLine( "NICKNAME", (*addrIt).nickName() ) ); | 211 | card.addLine( VCardLine( "NICKNAME", (*addrIt).nickName() ) ); |
211 | 212 | ||
212 | // NOTE | 213 | // NOTE |
213 | card.addLine( VCardLine( "NOTE", (*addrIt).note() ) ); | 214 | card.addLine( VCardLine( "NOTE", (*addrIt).note() ) ); |
214 | 215 | ||
215 | // ORG | 216 | // ORG |
216 | card.addLine( VCardLine( "ORG", (*addrIt).organization() ) ); | 217 | card.addLine( VCardLine( "ORG", (*addrIt).organization() ) ); |
217 | 218 | ||
218 | // PHOTO | 219 | // PHOTO |
219 | card.addLine( createPicture( "PHOTO", (*addrIt).photo() ) ); | 220 | card.addLine( createPicture( "PHOTO", (*addrIt).photo() ) ); |
220 | 221 | ||
221 | // PROID | 222 | // PROID |
222 | if ( version == VCard::v3_0 ) | 223 | if ( version == VCard::v3_0 ) |
223 | card.addLine( VCardLine( "PRODID", (*addrIt).productId() ) ); | 224 | card.addLine( VCardLine( "PRODID", (*addrIt).productId() ) ); |
224 | 225 | ||
225 | // REV | 226 | // REV |
226 | card.addLine( VCardLine( "REV", createDateTime( (*addrIt).revision() ) ) ); | 227 | card.addLine( VCardLine( "REV", createDateTime( (*addrIt).revision() ) ) ); |
227 | 228 | ||
228 | // ROLE | 229 | // ROLE |
229 | card.addLine( VCardLine( "ROLE", (*addrIt).role() ) ); | 230 | card.addLine( VCardLine( "ROLE", (*addrIt).role() ) ); |
230 | 231 | ||
231 | // SORT-STRING | 232 | // SORT-STRING |
232 | if ( version == VCard::v3_0 ) | 233 | if ( version == VCard::v3_0 ) |
233 | card.addLine( VCardLine( "SORT-STRING", (*addrIt).sortString() ) ); | 234 | card.addLine( VCardLine( "SORT-STRING", (*addrIt).sortString() ) ); |
234 | 235 | ||
235 | // SOUND | 236 | // SOUND |
236 | card.addLine( createSound( (*addrIt).sound() ) ); | 237 | card.addLine( createSound( (*addrIt).sound() ) ); |
237 | 238 | ||
238 | // TEL | 239 | // TEL |
239 | PhoneNumber::List phoneNumbers = (*addrIt).phoneNumbers(); | 240 | PhoneNumber::List phoneNumbers = (*addrIt).phoneNumbers(); |
240 | PhoneNumber::List::ConstIterator phoneIt; | 241 | PhoneNumber::List::ConstIterator phoneIt; |
241 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 242 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
242 | VCardLine line( "TEL", (*phoneIt).number() ); | 243 | VCardLine line( "TEL", (*phoneIt).number() ); |
243 | 244 | ||
244 | QMap<QString, int>::Iterator typeIt; | 245 | QMap<QString, int>::Iterator typeIt; |
245 | for ( typeIt = mPhoneTypeMap.begin(); typeIt != mPhoneTypeMap.end(); ++typeIt ) { | 246 | for ( typeIt = mPhoneTypeMap.begin(); typeIt != mPhoneTypeMap.end(); ++typeIt ) { |
246 | if ( typeIt.data() & (*phoneIt).type() ) | 247 | if ( typeIt.data() & (*phoneIt).type() ) |
247 | if ( version == VCard::v3_0 ) | 248 | if ( version == VCard::v3_0 ) |
248 | line.addParameter( "TYPE", typeIt.key().lower() ); | 249 | line.addParameter( "TYPE", typeIt.key().lower() ); |
249 | else | 250 | else |
250 | line.addParameter( "TYPE", typeIt.key() ); | 251 | line.addParameter( "TYPE", typeIt.key() ); |
251 | } | 252 | } |
252 | 253 | ||
253 | card.addLine( line ); | 254 | card.addLine( line ); |
254 | } | 255 | } |
255 | 256 | ||
256 | // TITLE | 257 | // TITLE |
257 | card.addLine( VCardLine( "TITLE", (*addrIt).title() ) ); | 258 | card.addLine( VCardLine( "TITLE", (*addrIt).title() ) ); |
258 | 259 | ||
259 | // TZ | 260 | // TZ |
260 | TimeZone timeZone = (*addrIt).timeZone(); | 261 | TimeZone timeZone = (*addrIt).timeZone(); |
261 | if ( timeZone.isValid() ) { | 262 | if ( timeZone.isValid() ) { |
262 | QString str; | 263 | QString str; |
263 | 264 | ||
264 | int neg = 1; | 265 | int neg = 1; |
265 | if ( timeZone.offset() < 0 ) | 266 | if ( timeZone.offset() < 0 ) |
266 | neg = -1; | 267 | neg = -1; |
267 | 268 | ||
268 | str.sprintf( "%c%02d:%02d", ( timeZone.offset() >= 0 ? '+' : '-' ), | 269 | str.sprintf( "%c%02d:%02d", ( timeZone.offset() >= 0 ? '+' : '-' ), |
269 | ( timeZone.offset() / 60 ) * neg, | 270 | ( timeZone.offset() / 60 ) * neg, |
270 | ( timeZone.offset() % 60 ) * neg ); | 271 | ( timeZone.offset() % 60 ) * neg ); |
271 | 272 | ||
272 | card.addLine( VCardLine( "TZ", str ) ); | 273 | card.addLine( VCardLine( "TZ", str ) ); |
273 | } | 274 | } |
274 | 275 | ||
275 | // UID | 276 | // UID |
276 | card.addLine( VCardLine( "UID", (*addrIt).uid() ) ); | 277 | card.addLine( VCardLine( "UID", (*addrIt).uid() ) ); |
277 | 278 | ||
278 | // URL | 279 | // URL |
279 | card.addLine( VCardLine( "URL", (*addrIt).url().url() ) ); | 280 | card.addLine( VCardLine( "URL", (*addrIt).url().url() ) ); |
280 | 281 | ||
281 | // VERSION | 282 | // VERSION |
282 | if ( version == VCard::v2_1 ) | 283 | if ( version == VCard::v2_1 ) |
283 | card.addLine( VCardLine( "VERSION", "2.1" ) ); | 284 | card.addLine( VCardLine( "VERSION", "2.1" ) ); |
284 | if ( version == VCard::v3_0 ) | 285 | if ( version == VCard::v3_0 ) |
285 | card.addLine( VCardLine( "VERSION", "3.0" ) ); | 286 | card.addLine( VCardLine( "VERSION", "3.0" ) ); |
286 | 287 | ||
287 | // X- | 288 | // X- |
288 | QStringList customs = (*addrIt).customs(); | 289 | QStringList customs = (*addrIt).customs(); |
289 | for ( strIt = customs.begin(); strIt != customs.end(); ++strIt ) { | 290 | for ( strIt = customs.begin(); strIt != customs.end(); ++strIt ) { |
290 | QString identifier = "X-" + (*strIt).left( (*strIt).find( ":" ) ); | 291 | QString identifier = "X-" + (*strIt).left( (*strIt).find( ":" ) ); |
291 | QString value = (*strIt).mid( (*strIt).find( ":" ) + 1 ); | 292 | QString value = (*strIt).mid( (*strIt).find( ":" ) + 1 ); |
292 | if ( value.isEmpty() ) | 293 | if ( value.isEmpty() ) |
293 | continue; | 294 | continue; |
294 | 295 | ||
295 | card.addLine( VCardLine( identifier, value ) ); | 296 | card.addLine( VCardLine( identifier, value ) ); |
296 | } | 297 | } |
297 | 298 | ||
298 | vCardList.append( card ); | 299 | vCardList.append( card ); |
299 | } | 300 | } |
300 | 301 | ||
301 | return VCardParser::createVCards( vCardList ); | 302 | return VCardParser::createVCards( vCardList ); |
302 | } | 303 | } |
303 | 304 | ||
304 | Addressee::List VCardTool::parseVCards( const QString& vcard ) | 305 | Addressee::List VCardTool::parseVCards( const QString& vcard ) |
305 | { | 306 | { |
306 | QChar semicolonSep( ';' ); | 307 | QChar semicolonSep( ';' ); |
307 | QChar commaSep( ',' ); | 308 | QChar commaSep( ',' ); |
308 | QString identifier; | 309 | QString identifier; |
309 | 310 | ||
310 | Addressee::List addrList; | 311 | Addressee::List addrList; |
311 | VCard::List vCardList = VCardParser::parseVCards( vcard ); | 312 | VCard::List vCardList = VCardParser::parseVCards( vcard ); |
312 | VCard::List::Iterator cardIt; | 313 | VCard::List::Iterator cardIt; |
313 | for ( cardIt = vCardList.begin(); cardIt != vCardList.end(); ++cardIt ) { | 314 | for ( cardIt = vCardList.begin(); cardIt != vCardList.end(); ++cardIt ) { |
314 | Addressee addr; | 315 | Addressee addr; |
315 | QStringList idents = (*cardIt).identifiers(); | 316 | QStringList idents = (*cardIt).identifiers(); |
316 | QStringList::ConstIterator identIt; | 317 | QStringList::ConstIterator identIt; |
317 | for ( identIt = idents.begin(); identIt != idents.end(); ++identIt ) { | 318 | for ( identIt = idents.begin(); identIt != idents.end(); ++identIt ) { |
318 | VCard card = (*cardIt); | 319 | VCard card = (*cardIt); |
319 | VCardLine::List lines = card.lines( (*identIt) ); | 320 | VCardLine::List lines = card.lines( (*identIt) ); |
320 | VCardLine::List::Iterator lineIt; | 321 | VCardLine::List::Iterator lineIt; |
321 | 322 | ||
322 | // iterate over the lines | 323 | // iterate over the lines |
323 | for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) { | 324 | for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) { |
324 | QStringList params = (*lineIt).parameterList(); | 325 | QStringList params = (*lineIt).parameterList(); |
325 | 326 | ||
326 | identifier = (*lineIt).identifier().lower(); | 327 | identifier = (*lineIt).identifier().lower(); |
327 | // ADR | 328 | // ADR |
328 | if ( identifier == "adr" ) { | 329 | if ( identifier == "adr" ) { |
329 | Address address; | 330 | Address address; |
330 | QStringList addrParts = splitString( semicolonSep, (*lineIt).value().asString() ); | 331 | QStringList addrParts = splitString( semicolonSep, (*lineIt).value().asString() ); |
331 | if ( addrParts.count() > 0 ) | 332 | if ( addrParts.count() > 0 ) |
332 | address.setPostOfficeBox( addrParts[ 0 ] ); | 333 | address.setPostOfficeBox( addrParts[ 0 ] ); |
333 | if ( addrParts.count() > 1 ) | 334 | if ( addrParts.count() > 1 ) |
334 | address.setExtended( addrParts[ 1 ] ); | 335 | address.setExtended( addrParts[ 1 ] ); |
335 | if ( addrParts.count() > 2 ) | 336 | if ( addrParts.count() > 2 ) |
336 | address.setStreet( addrParts[ 2 ].replace ( QRegExp("\\\\n") , "\n") ); | 337 | address.setStreet( addrParts[ 2 ].replace ( QRegExp("\\\\n") , "\n") ); |
337 | if ( addrParts.count() > 3 ) | 338 | if ( addrParts.count() > 3 ) |
338 | address.setLocality( addrParts[ 3 ] ); | 339 | address.setLocality( addrParts[ 3 ] ); |
339 | if ( addrParts.count() > 4 ) | 340 | if ( addrParts.count() > 4 ) |
340 | address.setRegion( addrParts[ 4 ] ); | 341 | address.setRegion( addrParts[ 4 ] ); |
341 | if ( addrParts.count() > 5 ) | 342 | if ( addrParts.count() > 5 ) |
342 | address.setPostalCode( addrParts[ 5 ] ); | 343 | address.setPostalCode( addrParts[ 5 ] ); |
343 | if ( addrParts.count() > 6 ) | 344 | if ( addrParts.count() > 6 ) |
344 | address.setCountry( addrParts[ 6 ] ); | 345 | address.setCountry( addrParts[ 6 ] ); |
345 | 346 | ||
346 | int type = 0; | 347 | int type = 0; |
347 | 348 | ||
348 | QStringList types = (*lineIt).parameters( "type" ); | 349 | QStringList types = (*lineIt).parameters( "type" ); |
349 | for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) | 350 | for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) |
350 | type += mAddressTypeMap[ (*it).lower() ]; | 351 | type += mAddressTypeMap[ (*it).lower() ]; |
351 | 352 | ||
352 | if ( !type ) | 353 | if ( !type ) |
353 | type = Address::Home; // default | 354 | type = Address::Home; // default |
354 | 355 | ||
355 | address.setType( type ); | 356 | address.setType( type ); |
356 | addr.insertAddress( address ); | 357 | addr.insertAddress( address ); |
357 | } | 358 | } |
358 | 359 | ||
359 | // AGENT | 360 | // AGENT |
360 | if ( identifier == "agent" ) | 361 | if ( identifier == "agent" ) |
361 | addr.setAgent( parseAgent( *lineIt ) ); | 362 | addr.setAgent( parseAgent( *lineIt ) ); |
362 | 363 | ||
363 | // BDAY | 364 | // BDAY |
364 | if ( identifier == "bday" ) | 365 | if ( identifier == "bday" ) |
365 | addr.setBirthday( parseDateTime( (*lineIt).value().asString() ) ); | 366 | addr.setBirthday( parseDateTime( (*lineIt).value().asString() ) ); |
366 | 367 | ||
367 | // CATEGORIES | 368 | // CATEGORIES |
368 | if ( identifier == "categories" ) { | 369 | if ( identifier == "categories" ) { |
369 | QStringList categories = splitString( commaSep, (*lineIt).value().asString() ); | 370 | QStringList categories = splitString( commaSep, (*lineIt).value().asString() ); |
370 | addr.setCategories( categories ); | 371 | addr.setCategories( categories ); |
371 | } | 372 | } |
372 | 373 | ||
373 | // CLASS | 374 | // CLASS |
374 | if ( identifier == "class" ) | 375 | if ( identifier == "class" ) |
375 | addr.setSecrecy( parseSecrecy( *lineIt ) ); | 376 | addr.setSecrecy( parseSecrecy( *lineIt ) ); |
376 | 377 | ||
377 | 378 | ||
378 | if ( identifier == "email" ) { | 379 | if ( identifier == "email" ) { |
379 | QStringList types = (*lineIt).parameters( "type" ); | 380 | QStringList types = (*lineIt).parameters( "type" ); |
380 | addr.insertEmail( (*lineIt).value().asString(), types.contains( "PREF" ) ); | 381 | addr.insertEmail( (*lineIt).value().asString(), types.contains( "PREF" ) ); |
381 | } | 382 | } |
382 | 383 | ||
383 | // FN | 384 | // FN |
384 | if ( identifier == "fn" ) | 385 | if ( identifier == "fn" ) |
385 | addr.setFormattedName( (*lineIt).value().asString() ); | 386 | addr.setFormattedName( (*lineIt).value().asString() ); |
386 | 387 | ||
387 | // GEO | 388 | // GEO |
388 | if ( identifier == "geo" ) { | 389 | if ( identifier == "geo" ) { |
389 | Geo geo; | 390 | Geo geo; |
390 | 391 | ||
391 | QStringList geoParts = QStringList::split( ';', (*lineIt).value().asString(), true ); | 392 | QStringList geoParts = QStringList::split( ';', (*lineIt).value().asString(), true ); |
392 | geo.setLatitude( geoParts[ 0 ].toFloat() ); | 393 | geo.setLatitude( geoParts[ 0 ].toFloat() ); |
393 | geo.setLongitude( geoParts[ 1 ].toFloat() ); | 394 | geo.setLongitude( geoParts[ 1 ].toFloat() ); |
394 | 395 | ||
395 | addr.setGeo( geo ); | 396 | addr.setGeo( geo ); |
396 | } | 397 | } |
397 | 398 | ||
398 | // KEY | 399 | // KEY |
399 | if ( identifier == "key" ) | 400 | if ( identifier == "key" ) |
400 | addr.insertKey( parseKey( *lineIt ) ); | 401 | addr.insertKey( parseKey( *lineIt ) ); |
401 | 402 | ||
402 | // LABEL | 403 | // LABEL |
403 | if ( identifier == "label" ) { | 404 | if ( identifier == "label" ) { |
404 | int type = 0; | 405 | int type = 0; |
405 | 406 | ||
406 | QStringList types = (*lineIt).parameters( "type" ); | 407 | QStringList types = (*lineIt).parameters( "type" ); |
407 | for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) | 408 | for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) |
408 | type += mAddressTypeMap[ (*it).lower() ]; | 409 | type += mAddressTypeMap[ (*it).lower() ]; |
409 | 410 | ||
410 | if ( !type ) | 411 | if ( !type ) |
411 | type = Address::Home; | 412 | type = Address::Home; |
412 | 413 | ||
413 | KABC::Address::List addressList = addr.addresses(); | 414 | KABC::Address::List addressList = addr.addresses(); |
414 | KABC::Address::List::Iterator it; | 415 | KABC::Address::List::Iterator it; |
415 | for ( it = addressList.begin(); it != addressList.end(); ++it ) { | 416 | for ( it = addressList.begin(); it != addressList.end(); ++it ) { |
416 | if ( (*it).type() == type ) { | 417 | if ( (*it).type() == type ) { |
417 | (*it).setLabel( (*lineIt).value().asString() ); | 418 | (*it).setLabel( (*lineIt).value().asString() ); |
418 | addr.insertAddress( *it ); | 419 | addr.insertAddress( *it ); |
419 | } | 420 | } |
420 | } | 421 | } |
421 | } | 422 | } |
422 | 423 | ||
423 | // LOGO | 424 | // LOGO |
424 | if ( identifier == "logo" ) | 425 | if ( identifier == "logo" ) |
425 | addr.setLogo( parsePicture( *lineIt ) ); | 426 | addr.setLogo( parsePicture( *lineIt ) ); |
426 | 427 | ||
427 | // MAILER | 428 | // MAILER |
428 | if ( identifier == "mailer" ) | 429 | if ( identifier == "mailer" ) |
429 | addr.setMailer( (*lineIt).value().asString() ); | 430 | addr.setMailer( (*lineIt).value().asString() ); |
430 | 431 | ||
431 | // N | 432 | // N |
432 | if ( identifier == "n" ) { | 433 | if ( identifier == "n" ) { |
433 | QStringList nameParts = splitString( semicolonSep, (*lineIt).value().asString() ); | 434 | QStringList nameParts = splitString( semicolonSep, (*lineIt).value().asString() ); |
434 | if ( nameParts.count() > 0 ) | 435 | if ( nameParts.count() > 0 ) |
435 | addr.setFamilyName( nameParts[ 0 ] ); | 436 | addr.setFamilyName( nameParts[ 0 ] ); |
436 | if ( nameParts.count() > 1 ) | 437 | if ( nameParts.count() > 1 ) |
437 | addr.setGivenName( nameParts[ 1 ] ); | 438 | addr.setGivenName( nameParts[ 1 ] ); |
438 | if ( nameParts.count() > 2 ) | 439 | if ( nameParts.count() > 2 ) |
439 | addr.setAdditionalName( nameParts[ 2 ] ); | 440 | addr.setAdditionalName( nameParts[ 2 ] ); |
440 | if ( nameParts.count() > 3 ) | 441 | if ( nameParts.count() > 3 ) |
441 | addr.setPrefix( nameParts[ 3 ] ); | 442 | addr.setPrefix( nameParts[ 3 ] ); |
442 | if ( nameParts.count() > 4 ) | 443 | if ( nameParts.count() > 4 ) |
443 | addr.setSuffix( nameParts[ 4 ] ); | 444 | addr.setSuffix( nameParts[ 4 ] ); |