-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 | |||
@@ -355,256 +355,260 @@ QDateTime Addressee::birthday() const | |||
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 | } |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 393d1cc..27782f9 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -208,256 +208,261 @@ class Addressee | |||
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 | */ |
diff --git a/kabc/field.cpp b/kabc/field.cpp index e27970e..d95cd19 100644 --- a/kabc/field.cpp +++ b/kabc/field.cpp | |||
@@ -1,548 +1,554 @@ | |||
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 | ||
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 | |||
@@ -45,387 +45,390 @@ bool VCardLineX::isValid() const | |||
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 { |
diff --git a/kabc/vcard21parser.h b/kabc/vcard21parser.h index 24b0eb2..77e69b6 100644 --- a/kabc/vcard21parser.h +++ b/kabc/vcard21parser.h | |||
@@ -1,222 +1,223 @@ | |||
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); |
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp index bffaa64..2d6eb3d 100644 --- a/kabc/vcardformatimpl.cpp +++ b/kabc/vcardformatimpl.cpp | |||
@@ -466,288 +466,290 @@ void VCardFormatImpl::addGeoValue( VCard *vcard, const Geo &geo ) | |||
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 ); |
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,187 +1,188 @@ | |||
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 | ||