summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/converter/opie/opieconverterE.pro2
-rw-r--r--kabc/formats/vcardformatplugin2.cpp4
-rw-r--r--kabc/vcardformatimpl.cpp48
-rw-r--r--kabc/vcardformatplugin.cpp4
-rw-r--r--kabc/vcardparser/vcardtool.cpp22
5 files changed, 53 insertions, 27 deletions
diff --git a/kabc/converter/opie/opieconverterE.pro b/kabc/converter/opie/opieconverterE.pro
index 85ba28f..e026f2a 100644
--- a/kabc/converter/opie/opieconverterE.pro
+++ b/kabc/converter/opie/opieconverterE.pro
@@ -1,32 +1,32 @@
1TEMPLATE = lib 1TEMPLATE = lib
2INCLUDEPATH += . ../.. ../../../microkde ../../../microkde/kdecore $(QPEDIR)/include $(OPIEDIR)/include 2INCLUDEPATH += . ../.. ../../../microkde ../../../microkde/kdecore $(OPIEDIR)/include $(OPEDIR)/include
3#CONFIG += staticlib 3#CONFIG += staticlib
4OBJECTS_DIR = obj/$(PLATFORM) 4OBJECTS_DIR = obj/$(PLATFORM)
5MOC_DIR = moc/$(PLATFORM) 5MOC_DIR = moc/$(PLATFORM)
6 6
7#for static linkage, put it here 7#for static linkage, put it here
8#DESTDIR=../../lib/$(PLATFORM) 8#DESTDIR=../../lib/$(PLATFORM)
9 9
10#for dynamic linkage, put it here 10#for dynamic linkage, put it here
11DESTDIR=$(QPEDIR)/lib 11DESTDIR=$(QPEDIR)/lib
12 12
13LIBS += -lmicrokde 13LIBS += -lmicrokde
14LIBS += -lmicrokabc 14LIBS += -lmicrokabc
15LIBS += -L$(QPEDIR)/lib 15LIBS += -L$(QPEDIR)/lib
16LIBS += -L$(OPIEDIR)/lib 16LIBS += -L$(OPIEDIR)/lib
17LIBS += -lopie 17LIBS += -lopie
18LIBS += -lqpe 18LIBS += -lqpe
19LIBS += -lqte 19LIBS += -lqte
20 20
21 21
22TARGET = microkabc_opieconverter 22TARGET = microkabc_opieconverter
23 23
24# Input 24# Input
25 25
26HEADERS += \ 26HEADERS += \
27 opieconverter.h \ 27 opieconverter.h \
28 28
29 29
30SOURCES += \ 30SOURCES += \
31 opieconverter.cpp \ 31 opieconverter.cpp \
32 32
diff --git a/kabc/formats/vcardformatplugin2.cpp b/kabc/formats/vcardformatplugin2.cpp
index f19e218..41b0c9a 100644
--- a/kabc/formats/vcardformatplugin2.cpp
+++ b/kabc/formats/vcardformatplugin2.cpp
@@ -1,120 +1,124 @@
1/* 1/*
2Enhanced Version of the file for platform independent KDE tools. 2Enhanced Version of the file for platform independent KDE tools.
3Copyright (c) 2004 Ulf Schenk 3Copyright (c) 2004 Ulf Schenk
4 4
5$Id$ 5$Id$
6*/ 6*/
7 7
8#include "vcardformatplugin2.h" 8#include "vcardformatplugin2.h"
9 9
10#include "address.h" 10#include "address.h"
11#include "addressee.h" 11#include "addressee.h"
12#include "vcardparser/vcardtool.h" 12#include "vcardparser/vcardtool.h"
13 13
14#include <qtextstream.h> 14#include <qtextstream.h>
15#include <qfile.h> 15#include <qfile.h>
16 16
17using namespace KABC; 17using namespace KABC;
18 18
19extern "C" 19extern "C"
20{ 20{
21 FormatPlugin *format() 21 FormatPlugin *format()
22 { 22 {
23 return new VCardFormatPlugin2(); 23 return new VCardFormatPlugin2();
24 } 24 }
25} 25}
26 26
27VCardFormatPlugin2::VCardFormatPlugin2() 27VCardFormatPlugin2::VCardFormatPlugin2()
28{ 28{
29} 29}
30 30
31VCardFormatPlugin2::~VCardFormatPlugin2() 31VCardFormatPlugin2::~VCardFormatPlugin2()
32{ 32{
33} 33}
34 34
35bool VCardFormatPlugin2::load( Addressee &addressee, QFile *file ) 35bool VCardFormatPlugin2::load( Addressee &addressee, QFile *file )
36{ 36{
37 qDebug("VCardFormatPlugin2::load");
37 QString data; 38 QString data;
38 39
39 QTextStream t( file ); 40 QTextStream t( file );
40 t.setEncoding( QTextStream::UnicodeUTF8 ); 41 t.setEncoding( QTextStream::UnicodeUTF8 );
41 data = t.read(); 42 data = t.read();
42 43
43 VCardTool tool; 44 VCardTool tool;
44 45
45 Addressee::List l = tool.parseVCards( data ); 46 Addressee::List l = tool.parseVCards( data );
46 47
47 if ( ! l.first().isEmpty() ) { 48 if ( ! l.first().isEmpty() ) {
48 addressee = l.first(); 49 addressee = l.first();
49 return true; 50 return true;
50 } 51 }
51 52
52 return false; 53 return false;
53} 54}
54 55
55bool VCardFormatPlugin2::loadAll( AddressBook *addressBook, Resource *resource, QFile *file ) 56bool VCardFormatPlugin2::loadAll( AddressBook *addressBook, Resource *resource, QFile *file )
56{ 57{
58 qDebug("VCardFormatPlugin2::loadAll");
57 QString data; 59 QString data;
58 60
59 QTextStream t( file ); 61 QTextStream t( file );
60 t.setEncoding( QTextStream::UnicodeUTF8 ); 62 t.setEncoding( QTextStream::UnicodeUTF8 );
61 data = t.read(); 63 data = t.read();
62 64
63 VCardTool tool; 65 VCardTool tool;
64 66
65 Addressee::List l = tool.parseVCards( data ); 67 Addressee::List l = tool.parseVCards( data );
66 68
67 Addressee::List::Iterator itr; 69 Addressee::List::Iterator itr;
68 70
69 for ( itr = l.begin(); itr != l.end(); ++itr) { 71 for ( itr = l.begin(); itr != l.end(); ++itr) {
70 Addressee addressee = *itr; 72 Addressee addressee = *itr;
71 addressee.setResource( resource ); 73 addressee.setResource( resource );
72 addressBook->insertAddressee( addressee ); 74 addressBook->insertAddressee( addressee );
73 } 75 }
74 76
75 return true; 77 return true;
76} 78}
77 79
78void VCardFormatPlugin2::save( const Addressee &addressee, QFile *file ) 80void VCardFormatPlugin2::save( const Addressee &addressee, QFile *file )
79{ 81{
82 qDebug("VCardFormatPlugin2::save");
80 VCardTool tool; 83 VCardTool tool;
81 Addressee::List vcardlist; 84 Addressee::List vcardlist;
82 85
83 86
84 vcardlist.append( addressee ); 87 vcardlist.append( addressee );
85 88
86 QTextStream t( file ); 89 QTextStream t( file );
87 t.setEncoding( QTextStream::UnicodeUTF8 ); 90 t.setEncoding( QTextStream::UnicodeUTF8 );
88 t << tool.createVCards( vcardlist ); 91 t << tool.createVCards( vcardlist );
89} 92}
90 93
91void VCardFormatPlugin2::saveAll( AddressBook *ab, Resource *resource, QFile *file ) 94void VCardFormatPlugin2::saveAll( AddressBook *ab, Resource *resource, QFile *file )
92{ 95{
96 qDebug("VCardFormatPlugin2::saveAll");
93 VCardTool tool; 97 VCardTool tool;
94 Addressee::List vcardlist; 98 Addressee::List vcardlist;
95 99
96 AddressBook::Iterator it; 100 AddressBook::Iterator it;
97 for ( it = ab->begin(); it != ab->end(); ++it ) { 101 for ( it = ab->begin(); it != ab->end(); ++it ) {
98 if ( (*it).resource() == resource ) { 102 if ( (*it).resource() == resource ) {
99 (*it).setChanged( false ); 103 (*it).setChanged( false );
100 vcardlist.append( *it ); 104 vcardlist.append( *it );
101 } 105 }
102 } 106 }
103 107
104 QTextStream t( file ); 108 QTextStream t( file );
105 t.setEncoding( QTextStream::UnicodeUTF8 ); 109 t.setEncoding( QTextStream::UnicodeUTF8 );
106 t << tool.createVCards( vcardlist ); 110 t << tool.createVCards( vcardlist );
107} 111}
108 112
109bool VCardFormatPlugin2::checkFormat( QFile *file ) const 113bool VCardFormatPlugin2::checkFormat( QFile *file ) const
110{ 114{
111 QString line; 115 QString line;
112 116
113 file->readLine( line, 1024 ); 117 file->readLine( line, 1024 );
114 line = line.stripWhiteSpace(); 118 line = line.stripWhiteSpace();
115 if ( line == "BEGIN:VCARD" ) 119 if ( line == "BEGIN:VCARD" )
116 return true; 120 return true;
117 else 121 else
118 return false; 122 return false;
119} 123}
120 124
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp
index f90f813..3fcaf94 100644
--- a/kabc/vcardformatimpl.cpp
+++ b/kabc/vcardformatimpl.cpp
@@ -463,221 +463,225 @@ void VCardFormatImpl::addGeoValue( VCard *vcard, const Geo &geo )
463} 463}
464 464
465void VCardFormatImpl::addUTCValue( VCard *vcard, const TimeZone &tz ) 465void VCardFormatImpl::addUTCValue( VCard *vcard, const TimeZone &tz )
466{ 466{
467 if ( !tz.isValid() ) return; 467 if ( !tz.isValid() ) return;
468 468
469 ContentLine cl; 469 ContentLine cl;
470 cl.setName( EntityTypeToParamName( EntityTimeZone ) ); 470 cl.setName( EntityTypeToParamName( EntityTimeZone ) );
471 471
472 UTCValue *v = new UTCValue; 472 UTCValue *v = new UTCValue;
473 473
474 v->setPositive( tz.offset() >= 0 ); 474 v->setPositive( tz.offset() >= 0 );
475 v->setHour( (tz.offset() / 60) * ( tz.offset() >= 0 ? 1 : -1 ) ); 475 v->setHour( (tz.offset() / 60) * ( tz.offset() >= 0 ? 1 : -1 ) );
476 v->setMinute( (tz.offset() % 60) * ( tz.offset() >= 0 ? 1 : -1 ) ); 476 v->setMinute( (tz.offset() % 60) * ( tz.offset() >= 0 ? 1 : -1 ) );
477 477
478 cl.setValue( v ); 478 cl.setValue( v );
479 vcard->add(cl); 479 vcard->add(cl);
480} 480}
481 481
482void VCardFormatImpl::addClassValue( VCard *vcard, const Secrecy &secrecy ) 482void VCardFormatImpl::addClassValue( VCard *vcard, const Secrecy &secrecy )
483{ 483{
484 ContentLine cl; 484 ContentLine cl;
485 cl.setName( EntityTypeToParamName( EntityClass ) ); 485 cl.setName( EntityTypeToParamName( EntityClass ) );
486 486
487 ClassValue *v = new ClassValue; 487 ClassValue *v = new ClassValue;
488 switch ( secrecy.type() ) { 488 switch ( secrecy.type() ) {
489 case Secrecy::Public: 489 case Secrecy::Public:
490 v->setType( (int)ClassValue::Public ); 490 v->setType( (int)ClassValue::Public );
491 break; 491 break;
492 case Secrecy::Private: 492 case Secrecy::Private:
493 v->setType( (int)ClassValue::Private ); 493 v->setType( (int)ClassValue::Private );
494 break; 494 break;
495 case Secrecy::Confidential: 495 case Secrecy::Confidential:
496 v->setType( (int)ClassValue::Confidential ); 496 v->setType( (int)ClassValue::Confidential );
497 break; 497 break;
498 } 498 }
499 499
500 cl.setValue( v ); 500 cl.setValue( v );
501 vcard->add(cl); 501 vcard->add(cl);
502} 502}
503 503
504 504
505Address VCardFormatImpl::readAddressValue( ContentLine *cl ) 505Address VCardFormatImpl::readAddressValue( ContentLine *cl )
506{ 506{
507 Address a; 507 Address a;
508 AdrValue *v = (AdrValue *)cl->value(); 508 AdrValue *v = (AdrValue *)cl->value();
509 a.setPostOfficeBox( QString::fromUtf8( v->poBox() ) ); 509 a.setPostOfficeBox( QString::fromUtf8( v->poBox() ) );
510 a.setExtended( QString::fromUtf8( v->extAddress() ) ); 510 a.setExtended( QString::fromUtf8( v->extAddress() ) );
511 a.setStreet( QString::fromUtf8( v->street() ) ); 511 a.setStreet( QString::fromUtf8( v->street() ) );
512 a.setLocality( QString::fromUtf8( v->locality() ) ); 512 a.setLocality( QString::fromUtf8( v->locality() ) );
513 a.setRegion( QString::fromUtf8( v->region() ) ); 513 a.setRegion( QString::fromUtf8( v->region() ) );
514 a.setPostalCode( QString::fromUtf8( v->postCode() ) ); 514 a.setPostalCode( QString::fromUtf8( v->postCode() ) );
515 a.setCountry( QString::fromUtf8( v->countryName() ) ); 515 a.setCountry( QString::fromUtf8( v->countryName() ) );
516 516
517 a.setType( readAddressParam( cl ) ); 517 a.setType( readAddressParam( cl ) );
518 518
519 return a; 519 return a;
520} 520}
521 521
522int VCardFormatImpl::readAddressParam( ContentLine *cl ) 522int VCardFormatImpl::readAddressParam( ContentLine *cl )
523{ 523{
524 int type = 0; 524 int type = 0;
525 ParamList params = cl->paramList(); 525 ParamList params = cl->paramList();
526 ParamListIterator it( params ); 526 ParamListIterator it( params );
527 QCString tmpStr;
527 for( ; it.current(); ++it ) { 528 for( ; it.current(); ++it ) {
528 if ( (*it)->name() == "TYPE" ) { 529 if ( (*it)->name().upper() == "TYPE" ) {
529 if ( (*it)->value() == "dom" ) type |= Address::Dom; 530 tmpStr = (*it)->value().lower();
530 else if ( (*it)->value() == "intl" ) type |= Address::Intl; 531 if ( tmpStr == "dom" ) type |= Address::Dom;
531 else if ( (*it)->value() == "parcel" ) type |= Address::Parcel; 532 else if ( tmpStr == "intl" ) type |= Address::Intl;
532 else if ( (*it)->value() == "postal" ) type |= Address::Postal; 533 else if ( tmpStr == "parcel" ) type |= Address::Parcel;
533 else if ( (*it)->value() == "work" ) type |= Address::Work; 534 else if ( tmpStr == "postal" ) type |= Address::Postal;
534 else if ( (*it)->value() == "home" ) type |= Address::Home; 535 else if ( tmpStr == "work" ) type |= Address::Work;
535 else if ( (*it)->value() == "pref" ) type |= Address::Pref; 536 else if ( tmpStr == "home" ) type |= Address::Home;
537 else if ( tmpStr == "pref" ) type |= Address::Pref;
536 } 538 }
537 } 539 }
538 return type; 540 return type;
539} 541}
540 542
541void VCardFormatImpl::addNValue( VCard *vcard, const Addressee &a ) 543void VCardFormatImpl::addNValue( VCard *vcard, const Addressee &a )
542{ 544{
543 ContentLine cl; 545 ContentLine cl;
544 cl.setName(EntityTypeToParamName( EntityN ) ); 546 cl.setName(EntityTypeToParamName( EntityN ) );
545 NValue *v = new NValue; 547 NValue *v = new NValue;
546 v->setFamily( a.familyName().utf8() ); 548 v->setFamily( a.familyName().utf8() );
547 v->setGiven( a.givenName().utf8() ); 549 v->setGiven( a.givenName().utf8() );
548 v->setMiddle( a.additionalName().utf8() ); 550 v->setMiddle( a.additionalName().utf8() );
549 v->setPrefix( a.prefix().utf8() ); 551 v->setPrefix( a.prefix().utf8() );
550 v->setSuffix( a.suffix().utf8() ); 552 v->setSuffix( a.suffix().utf8() );
551 553
552 cl.setValue( v ); 554 cl.setValue( v );
553 vcard->add(cl); 555 vcard->add(cl);
554} 556}
555 557
556void VCardFormatImpl::readNValue( ContentLine *cl, Addressee &a ) 558void VCardFormatImpl::readNValue( ContentLine *cl, Addressee &a )
557{ 559{
558 NValue *v = (NValue *)cl->value(); 560 NValue *v = (NValue *)cl->value();
559 a.setFamilyName( QString::fromUtf8( v->family() ) ); 561 a.setFamilyName( QString::fromUtf8( v->family() ) );
560 a.setGivenName( QString::fromUtf8( v->given() ) ); 562 a.setGivenName( QString::fromUtf8( v->given() ) );
561 a.setAdditionalName( QString::fromUtf8( v->middle() ) ); 563 a.setAdditionalName( QString::fromUtf8( v->middle() ) );
562 a.setPrefix( QString::fromUtf8( v->prefix() ) ); 564 a.setPrefix( QString::fromUtf8( v->prefix() ) );
563 a.setSuffix( QString::fromUtf8( v->suffix() ) ); 565 a.setSuffix( QString::fromUtf8( v->suffix() ) );
564} 566}
565 567
566void VCardFormatImpl::addTelephoneValue( VCard *v, const PhoneNumber &p ) 568void VCardFormatImpl::addTelephoneValue( VCard *v, const PhoneNumber &p )
567{ 569{
568 if ( p.number().isEmpty() ) 570 if ( p.number().isEmpty() )
569 return; 571 return;
570 572
571 ContentLine cl; 573 ContentLine cl;
572 cl.setName(EntityTypeToParamName(EntityTelephone)); 574 cl.setName(EntityTypeToParamName(EntityTelephone));
573 cl.setValue(new TelValue( p.number().utf8() )); 575 cl.setValue(new TelValue( p.number().utf8() ));
574 576
575 ParamList params; 577 ParamList params;
576 if( p.type() & PhoneNumber::Home ) params.append( new Param( "TYPE", "home" ) ); 578 if( p.type() & PhoneNumber::Home ) params.append( new Param( "TYPE", "home" ) );
577 if( p.type() & PhoneNumber::Work ) params.append( new Param( "TYPE", "work" ) ); 579 if( p.type() & PhoneNumber::Work ) params.append( new Param( "TYPE", "work" ) );
578 if( p.type() & PhoneNumber::Msg ) params.append( new Param( "TYPE", "msg" ) ); 580 if( p.type() & PhoneNumber::Msg ) params.append( new Param( "TYPE", "msg" ) );
579 if( p.type() & PhoneNumber::Pref ) params.append( new Param( "TYPE", "pref" ) ); 581 if( p.type() & PhoneNumber::Pref ) params.append( new Param( "TYPE", "pref" ) );
580 if( p.type() & PhoneNumber::Voice ) params.append( new Param( "TYPE", "voice" ) ); 582 if( p.type() & PhoneNumber::Voice ) params.append( new Param( "TYPE", "voice" ) );
581 if( p.type() & PhoneNumber::Fax ) params.append( new Param( "TYPE", "fax" ) ); 583 if( p.type() & PhoneNumber::Fax ) params.append( new Param( "TYPE", "fax" ) );
582 if( p.type() & PhoneNumber::Cell ) params.append( new Param( "TYPE", "cell" ) ); 584 if( p.type() & PhoneNumber::Cell ) params.append( new Param( "TYPE", "cell" ) );
583 if( p.type() & PhoneNumber::Video ) params.append( new Param( "TYPE", "video" ) ); 585 if( p.type() & PhoneNumber::Video ) params.append( new Param( "TYPE", "video" ) );
584 if( p.type() & PhoneNumber::Bbs ) params.append( new Param( "TYPE", "bbs" ) ); 586 if( p.type() & PhoneNumber::Bbs ) params.append( new Param( "TYPE", "bbs" ) );
585 if( p.type() & PhoneNumber::Modem ) params.append( new Param( "TYPE", "modem" ) ); 587 if( p.type() & PhoneNumber::Modem ) params.append( new Param( "TYPE", "modem" ) );
586 if( p.type() & PhoneNumber::Car ) params.append( new Param( "TYPE", "car" ) ); 588 if( p.type() & PhoneNumber::Car ) params.append( new Param( "TYPE", "car" ) );
587 if( p.type() & PhoneNumber::Isdn ) params.append( new Param( "TYPE", "isdn" ) ); 589 if( p.type() & PhoneNumber::Isdn ) params.append( new Param( "TYPE", "isdn" ) );
588 if( p.type() & PhoneNumber::Pcs ) params.append( new Param( "TYPE", "pcs" ) ); 590 if( p.type() & PhoneNumber::Pcs ) params.append( new Param( "TYPE", "pcs" ) );
589 if( p.type() & PhoneNumber::Pager ) params.append( new Param( "TYPE", "pager" ) ); 591 if( p.type() & PhoneNumber::Pager ) params.append( new Param( "TYPE", "pager" ) );
590 cl.setParamList( params ); 592 cl.setParamList( params );
591 593
592 v->add(cl); 594 v->add(cl);
593} 595}
594 596
595PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl ) 597PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl )
596{ 598{
597 PhoneNumber p; 599 PhoneNumber p;
598 TelValue *value = (TelValue *)cl->value(); 600 TelValue *value = (TelValue *)cl->value();
599 p.setNumber( QString::fromUtf8( value->asString() ) ); 601 p.setNumber( QString::fromUtf8( value->asString() ) );
600 602
601 int type = 0; 603 int type = 0;
602 ParamList params = cl->paramList(); 604 ParamList params = cl->paramList();
603 ParamListIterator it( params ); 605 ParamListIterator it( params );
606 QCString tmpStr;
604 for( ; it.current(); ++it ) { 607 for( ; it.current(); ++it ) {
605 if ( (*it)->name() == "TYPE" ) { 608 if ( (*it)->name() == "TYPE" ) {
606 if ( (*it)->value() == "home" ) type |= PhoneNumber::Home; 609 tmpStr = (*it)->value().lower();
607 else if ( (*it)->value() == "work" ) type |= PhoneNumber::Work; 610 if ( tmpStr == "home" ) type |= PhoneNumber::Home;
608 else if ( (*it)->value() == "msg" ) type |= PhoneNumber::Msg; 611 else if ( tmpStr == "work" ) type |= PhoneNumber::Work;
609 else if ( (*it)->value() == "pref" ) type |= PhoneNumber::Pref; 612 else if ( tmpStr == "msg" ) type |= PhoneNumber::Msg;
610 else if ( (*it)->value() == "voice" ) type |= PhoneNumber::Voice; 613 else if ( tmpStr == "pref" ) type |= PhoneNumber::Pref;
611 else if ( (*it)->value() == "fax" ) type |= PhoneNumber::Fax; 614 else if ( tmpStr == "voice" ) type |= PhoneNumber::Voice;
612 else if ( (*it)->value() == "cell" ) type |= PhoneNumber::Cell; 615 else if ( tmpStr == "fax" ) type |= PhoneNumber::Fax;
613 else if ( (*it)->value() == "video" ) type |= PhoneNumber::Video; 616 else if ( tmpStr == "cell" ) type |= PhoneNumber::Cell;
614 else if ( (*it)->value() == "bbs" ) type |= PhoneNumber::Bbs; 617 else if ( tmpStr == "video" ) type |= PhoneNumber::Video;
615 else if ( (*it)->value() == "modem" ) type |= PhoneNumber::Modem; 618 else if ( tmpStr == "bbs" ) type |= PhoneNumber::Bbs;
616 else if ( (*it)->value() == "car" ) type |= PhoneNumber::Car; 619 else if ( tmpStr == "modem" ) type |= PhoneNumber::Modem;
617 else if ( (*it)->value() == "isdn" ) type |= PhoneNumber::Isdn; 620 else if ( tmpStr == "car" ) type |= PhoneNumber::Car;
618 else if ( (*it)->value() == "pcs" ) type |= PhoneNumber::Pcs; 621 else if ( tmpStr == "isdn" ) type |= PhoneNumber::Isdn;
619 else if ( (*it)->value() == "pager" ) type |= PhoneNumber::Pager; 622 else if ( tmpStr == "pcs" ) type |= PhoneNumber::Pcs;
623 else if ( tmpStr == "pager" ) type |= PhoneNumber::Pager;
620 } 624 }
621 } 625 }
622 p.setType( type ); 626 p.setType( type );
623 627
624 return p; 628 return p;
625} 629}
626 630
627QString VCardFormatImpl::readTextValue( ContentLine *cl ) 631QString VCardFormatImpl::readTextValue( ContentLine *cl )
628{ 632{
629 VCARD::Value *value = cl->value(); 633 VCARD::Value *value = cl->value();
630 if ( value ) { 634 if ( value ) {
631 return QString::fromUtf8( value->asString() ); 635 return QString::fromUtf8( value->asString() );
632 } else { 636 } else {
633 kdDebug(5700) << "No value: " << cl->asString() << endl; 637 kdDebug(5700) << "No value: " << cl->asString() << endl;
634 return QString::null; 638 return QString::null;
635 } 639 }
636} 640}
637 641
638QDate VCardFormatImpl::readDateValue( ContentLine *cl ) 642QDate VCardFormatImpl::readDateValue( ContentLine *cl )
639{ 643{
640 DateValue *dateValue = (DateValue *)cl->value(); 644 DateValue *dateValue = (DateValue *)cl->value();
641 if ( dateValue ) 645 if ( dateValue )
642 return dateValue->qdate(); 646 return dateValue->qdate();
643 else 647 else
644 return QDate(); 648 return QDate();
645} 649}
646 650
647QDateTime VCardFormatImpl::readDateTimeValue( ContentLine *cl ) 651QDateTime VCardFormatImpl::readDateTimeValue( ContentLine *cl )
648{ 652{
649 DateValue *dateValue = (DateValue *)cl->value(); 653 DateValue *dateValue = (DateValue *)cl->value();
650 if ( dateValue ) 654 if ( dateValue )
651 return dateValue->qdt(); 655 return dateValue->qdt();
652 else 656 else
653 return QDateTime(); 657 return QDateTime();
654} 658}
655 659
656Geo VCardFormatImpl::readGeoValue( ContentLine *cl ) 660Geo VCardFormatImpl::readGeoValue( ContentLine *cl )
657{ 661{
658 GeoValue *geoValue = (GeoValue *)cl->value(); 662 GeoValue *geoValue = (GeoValue *)cl->value();
659 if ( geoValue ) { 663 if ( geoValue ) {
660 Geo geo( geoValue->latitude(), geoValue->longitude() ); 664 Geo geo( geoValue->latitude(), geoValue->longitude() );
661 return geo; 665 return geo;
662 } else 666 } else
663 return Geo(); 667 return Geo();
664} 668}
665 669
666TimeZone VCardFormatImpl::readUTCValue( ContentLine *cl ) 670TimeZone VCardFormatImpl::readUTCValue( ContentLine *cl )
667{ 671{
668 UTCValue *utcValue = (UTCValue *)cl->value(); 672 UTCValue *utcValue = (UTCValue *)cl->value();
669 if ( utcValue ) { 673 if ( utcValue ) {
670 TimeZone tz; 674 TimeZone tz;
671 tz.setOffset(((utcValue->hour()*60)+utcValue->minute())*(utcValue->positive() ? 1 : -1)); 675 tz.setOffset(((utcValue->hour()*60)+utcValue->minute())*(utcValue->positive() ? 1 : -1));
672 return tz; 676 return tz;
673 } else 677 } else
674 return TimeZone(); 678 return TimeZone();
675} 679}
676 680
677Secrecy VCardFormatImpl::readClassValue( ContentLine *cl ) 681Secrecy VCardFormatImpl::readClassValue( ContentLine *cl )
678{ 682{
679 ClassValue *classValue = (ClassValue *)cl->value(); 683 ClassValue *classValue = (ClassValue *)cl->value();
680 if ( classValue ) { 684 if ( classValue ) {
681 Secrecy secrecy; 685 Secrecy secrecy;
682 switch ( classValue->type() ) { 686 switch ( classValue->type() ) {
683 case ClassValue::Public: 687 case ClassValue::Public:
diff --git a/kabc/vcardformatplugin.cpp b/kabc/vcardformatplugin.cpp
index 3cba59a..bc18690 100644
--- a/kabc/vcardformatplugin.cpp
+++ b/kabc/vcardformatplugin.cpp
@@ -1,66 +1,70 @@
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#include "vcardformatplugin.h" 21#include "vcardformatplugin.h"
22#include "vcardformatimpl.h" 22#include "vcardformatimpl.h"
23 23
24using namespace KABC; 24using namespace KABC;
25 25
26VCardFormatPlugin::VCardFormatPlugin() 26VCardFormatPlugin::VCardFormatPlugin()
27{ 27{
28 mImpl = new VCardFormatImpl; 28 mImpl = new VCardFormatImpl;
29} 29}
30 30
31VCardFormatPlugin::~VCardFormatPlugin() 31VCardFormatPlugin::~VCardFormatPlugin()
32{ 32{
33 delete mImpl; 33 delete mImpl;
34} 34}
35 35
36bool VCardFormatPlugin::load( Addressee &addressee, QFile *file ) 36bool VCardFormatPlugin::load( Addressee &addressee, QFile *file )
37{ 37{
38 qDebug("VCardFormatPlugin::load");
38 return mImpl->load( addressee, file ); 39 return mImpl->load( addressee, file );
39} 40}
40 41
41bool VCardFormatPlugin::loadAll( AddressBook *addressBook, Resource *resource, QFile *file ) 42bool VCardFormatPlugin::loadAll( AddressBook *addressBook, Resource *resource, QFile *file )
42{ 43{
44 qDebug("VCardFormatPlugin::loadAll");
43 return mImpl->loadAll( addressBook, resource, file ); 45 return mImpl->loadAll( addressBook, resource, file );
44} 46}
45 47
46void VCardFormatPlugin::save( const Addressee &addressee, QFile *file ) 48void VCardFormatPlugin::save( const Addressee &addressee, QFile *file )
47{ 49{
50 qDebug("VCardFormatPlugin::save");
48 mImpl->save( addressee, file ); 51 mImpl->save( addressee, file );
49} 52}
50 53
51void VCardFormatPlugin::saveAll( AddressBook *addressBook, Resource *resource, QFile *file ) 54void VCardFormatPlugin::saveAll( AddressBook *addressBook, Resource *resource, QFile *file )
52{ 55{
56 qDebug("VCardFormatPlugin::saveAll");
53 mImpl->saveAll( addressBook, resource, file ); 57 mImpl->saveAll( addressBook, resource, file );
54} 58}
55 59
56bool VCardFormatPlugin::checkFormat( QFile *file ) const 60bool VCardFormatPlugin::checkFormat( QFile *file ) const
57{ 61{
58 QString line; 62 QString line;
59 63
60 file->readLine( line, 1024 ); 64 file->readLine( line, 1024 );
61 line = line.stripWhiteSpace(); 65 line = line.stripWhiteSpace();
62 if ( line == "BEGIN:VCARD" ) 66 if ( line == "BEGIN:VCARD" )
63 return true; 67 return true;
64 else 68 else
65 return false; 69 return false;
66} 70}
diff --git a/kabc/vcardparser/vcardtool.cpp b/kabc/vcardparser/vcardtool.cpp
index 01c5b3e..71f29d7 100644
--- a/kabc/vcardparser/vcardtool.cpp
+++ b/kabc/vcardparser/vcardtool.cpp
@@ -42,259 +42,273 @@ VCardTool::VCardTool()
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} 60}
61 61
62VCardTool::~VCardTool() 62VCardTool::~VCardTool()
63{ 63{
64} 64}
65 65
66QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) 66QString VCardTool::createVCards( Addressee::List list, VCard::Version version )
67{ 67{
68 VCard::List vCardList; 68 VCard::List vCardList;
69 69
70 Addressee::List::Iterator addrIt; 70 Addressee::List::Iterator addrIt;
71 for ( addrIt = list.begin(); addrIt != list.end(); ++addrIt ) { 71 for ( addrIt = list.begin(); addrIt != list.end(); ++addrIt ) {
72 VCard card; 72 VCard card;
73 QStringList::ConstIterator strIt; 73 QStringList::ConstIterator strIt;
74 74
75 // ADR + LABEL 75 // ADR + LABEL
76 Address::List addresses = (*addrIt).addresses(); 76 Address::List addresses = (*addrIt).addresses();
77 for ( Address::List::Iterator it = addresses.begin(); it != addresses.end(); ++it ) { 77 for ( Address::List::Iterator it = addresses.begin(); it != addresses.end(); ++it ) {
78 QStringList address; 78 QStringList address;
79 79
80/*US 80/*US
81 address.append( (*it).postOfficeBox().replace( ';', "\\;" ) ); 81 address.append( (*it).postOfficeBox().replace( ';', "\\;" ) );
82 address.append( (*it).extended().replace( ';', "\\;" ) ); 82 address.append( (*it).extended().replace( ';', "\\;" ) );
83 address.append( (*it).street().replace( ';', "\\;" ) ); 83 address.append( (*it).street().replace( ';', "\\;" ) );
84 address.append( (*it).locality().replace( ';', "\\;" ) ); 84 address.append( (*it).locality().replace( ';', "\\;" ) );
85 address.append( (*it).region().replace( ';', "\\;" ) ); 85 address.append( (*it).region().replace( ';', "\\;" ) );
86 address.append( (*it).postalCode().replace( ';', "\\;" ) ); 86 address.append( (*it).postalCode().replace( ';', "\\;" ) );
87 address.append( (*it).country().replace( ';', "\\;" ) ); 87 address.append( (*it).country().replace( ';', "\\;" ) );
88*/ 88*/
89//US using the old implementation instead 89//US using the old implementation instead
90 //qDebug("VCardTool::createVCards has to be verified"); 90 //qDebug("VCardTool::createVCards has to be verified");
91 address.append( (*it).postOfficeBox().replace( QRegExp(";"), "\\;" ) ); 91 address.append( (*it).postOfficeBox().replace( QRegExp(";"), "\\;" ) );
92 address.append( (*it).extended().replace( QRegExp(";"), "\\;" ) ); 92 address.append( (*it).extended().replace( QRegExp(";"), "\\;" ) );
93 address.append( (*it).street().replace( QRegExp(";"), "\\;" ) ); 93 address.append( (*it).street().replace( QRegExp(";"), "\\;" ) );
94 address.append( (*it).locality().replace( QRegExp(";"), "\\;" ) ); 94 address.append( (*it).locality().replace( QRegExp(";"), "\\;" ) );
95 address.append( (*it).region().replace( QRegExp(";"), "\\;" ) ); 95 address.append( (*it).region().replace( QRegExp(";"), "\\;" ) );
96 address.append( (*it).postalCode().replace( QRegExp(";"), "\\;" ) ); 96 address.append( (*it).postalCode().replace( QRegExp(";"), "\\;" ) );
97 address.append( (*it).country().replace( QRegExp(";"), "\\;" ) ); 97 address.append( (*it).country().replace( QRegExp(";"), "\\;" ) );
98 98
99 VCardLine adrLine( "ADR", address.join( ";" ) ); 99 VCardLine adrLine( "ADR", address.join( ";" ) );
100 VCardLine labelLine( "LABEL", (*it).label() ); 100 VCardLine labelLine( "LABEL", (*it).label() );
101 101
102 bool hasLabel = !(*it).label().isEmpty(); 102 bool hasLabel = !(*it).label().isEmpty();
103 QMap<QString, int>::Iterator typeIt; 103 QMap<QString, int>::Iterator typeIt;
104 for ( typeIt = mAddressTypeMap.begin(); typeIt != mAddressTypeMap.end(); ++typeIt ) { 104 for ( typeIt = mAddressTypeMap.begin(); typeIt != mAddressTypeMap.end(); ++typeIt ) {
105 if ( typeIt.data() & (*it).type() ) { 105 if ( typeIt.data() & (*it).type() ) {
106 adrLine.addParameter( "TYPE", typeIt.key() ); 106 if ( version == VCard::v3_0 ) {
107 if ( hasLabel ) 107 adrLine.addParameter( "TYPE", typeIt.key().lower() );
108 labelLine.addParameter( "TYPE", typeIt.key() ); 108 }
109 else {
110 adrLine.addParameter( "TYPE", typeIt.key() );
111 }
112 if ( hasLabel ) {
113 if ( version == VCard::v3_0 ) {
114 labelLine.addParameter( "TYPE", typeIt.key().lower() );
115 }
116 else {
117 labelLine.addParameter( "TYPE", typeIt.key() );
118 }
119 }
109 } 120 }
110 } 121 }
111 122
112 card.addLine( adrLine ); 123 card.addLine( adrLine );
113 if ( hasLabel ) 124 if ( hasLabel )
114 card.addLine( labelLine ); 125 card.addLine( labelLine );
115 } 126 }
116 127
117 // AGENT 128 // AGENT
118 card.addLine( createAgent( version, (*addrIt).agent() ) ); 129 card.addLine( createAgent( version, (*addrIt).agent() ) );
119 130
120 // BDAY 131 // BDAY
121 card.addLine( VCardLine( "BDAY", createDateTime( (*addrIt).birthday() ) ) ); 132 card.addLine( VCardLine( "BDAY", createDateTime( (*addrIt).birthday() ) ) );
122 133
123 // CATEGORIES 134 // CATEGORIES
124 if ( version == VCard::v3_0 ) { 135 if ( version == VCard::v3_0 ) {
125 QStringList categories = (*addrIt).categories(); 136 QStringList categories = (*addrIt).categories();
126 QStringList::Iterator catIt; 137 QStringList::Iterator catIt;
127 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) 138 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt )
128 { 139 {
129//US using the old implementation instead 140//US using the old implementation instead
130 // qDebug("VCardTool::createVCards has to be verified"); 141 // qDebug("VCardTool::createVCards has to be verified");
131//US (*catIt).replace( ',', "\\," ); 142//US (*catIt).replace( ',', "\\," );
132 (*catIt).replace( QRegExp(","), "\\," ); 143 (*catIt).replace( QRegExp(","), "\\," );
133 } 144 }
134 card.addLine( VCardLine( "CATEGORIES", categories.join( "," ) ) ); 145 card.addLine( VCardLine( "CATEGORIES", categories.join( "," ) ) );
135 } 146 }
136 147
137 // CLASS 148 // CLASS
138 if ( version == VCard::v3_0 ) { 149 if ( version == VCard::v3_0 ) {
139 card.addLine( createSecrecy( (*addrIt).secrecy() ) ); 150 card.addLine( createSecrecy( (*addrIt).secrecy() ) );
140 } 151 }
141 152
142 // EMAIL 153 // EMAIL
143 QStringList emails = (*addrIt).emails(); 154 QStringList emails = (*addrIt).emails();
144 bool pref = true; 155 bool pref = true;
145 for ( strIt = emails.begin(); strIt != emails.end(); ++strIt ) { 156 for ( strIt = emails.begin(); strIt != emails.end(); ++strIt ) {
146 VCardLine line( "EMAIL", *strIt ); 157 VCardLine line( "EMAIL", *strIt );
147 if ( pref == true ) { 158 if ( pref == true ) {
148 line.addParameter( "TYPE", "PREF" ); 159 line.addParameter( "TYPE", "PREF" );
149 pref = false; 160 pref = false;
150 } 161 }
151 card.addLine( line ); 162 card.addLine( line );
152 } 163 }
153 164
154 // FN 165 // FN
155 card.addLine( VCardLine( "FN", (*addrIt).formattedName() ) ); 166 card.addLine( VCardLine( "FN", (*addrIt).formattedName() ) );
156 167
157 // GEO 168 // GEO
158 Geo geo = (*addrIt).geo(); 169 Geo geo = (*addrIt).geo();
159 if ( geo.isValid() ) { 170 if ( geo.isValid() ) {
160 QString str; 171 QString str;
161 str.sprintf( "%.6f;%.6f", geo.latitude(), geo.longitude() ); 172 str.sprintf( "%.6f;%.6f", geo.latitude(), geo.longitude() );
162 card.addLine( VCardLine( "GEO", str ) ); 173 card.addLine( VCardLine( "GEO", str ) );
163 } 174 }
164 175
165 // KEY 176 // KEY
166 Key::List keys = (*addrIt).keys(); 177 Key::List keys = (*addrIt).keys();
167 Key::List::ConstIterator keyIt; 178 Key::List::ConstIterator keyIt;
168 for ( keyIt = keys.begin(); keyIt != keys.end(); ++keyIt ) 179 for ( keyIt = keys.begin(); keyIt != keys.end(); ++keyIt )
169 card.addLine( createKey( *keyIt ) ); 180 card.addLine( createKey( *keyIt ) );
170 181
171 // LOGO 182 // LOGO
172 card.addLine( createPicture( "LOGO", (*addrIt).logo() ) ); 183 card.addLine( createPicture( "LOGO", (*addrIt).logo() ) );
173 184
174 // MAILER 185 // MAILER
175 card.addLine( VCardLine( "MAILER", (*addrIt).mailer() ) ); 186 card.addLine( VCardLine( "MAILER", (*addrIt).mailer() ) );
176 187
177 // N 188 // N
178 QStringList name; 189 QStringList name;
179//US using the old implementation instead 190//US using the old implementation instead
180 //qDebug("VCardTool::createVCards has to be verified"); 191 //qDebug("VCardTool::createVCards has to be verified");
181/*US 192/*US
182 name.append( (*addrIt).familyName().replace( ';', "\\;" ) ); 193 name.append( (*addrIt).familyName().replace( ';', "\\;" ) );
183 name.append( (*addrIt).givenName().replace( ';', "\\;" ) ); 194 name.append( (*addrIt).givenName().replace( ';', "\\;" ) );
184 name.append( (*addrIt).additionalName().replace( ';', "\\;" ) ); 195 name.append( (*addrIt).additionalName().replace( ';', "\\;" ) );
185 name.append( (*addrIt).prefix().replace( ';', "\\;" ) ); 196 name.append( (*addrIt).prefix().replace( ';', "\\;" ) );
186 name.append( (*addrIt).suffix().replace( ';', "\\;" ) ); 197 name.append( (*addrIt).suffix().replace( ';', "\\;" ) );
187*/ 198*/
188 name.append( (*addrIt).familyName().replace( QRegExp(";"), "\\;" ) ); 199 name.append( (*addrIt).familyName().replace( QRegExp(";"), "\\;" ) );
189 name.append( (*addrIt).givenName().replace( QRegExp(";"), "\\;" ) ); 200 name.append( (*addrIt).givenName().replace( QRegExp(";"), "\\;" ) );
190 name.append( (*addrIt).additionalName().replace( QRegExp(";"), "\\;" ) ); 201 name.append( (*addrIt).additionalName().replace( QRegExp(";"), "\\;" ) );
191 name.append( (*addrIt).prefix().replace( QRegExp(";"), "\\;" ) ); 202 name.append( (*addrIt).prefix().replace( QRegExp(";"), "\\;" ) );
192 name.append( (*addrIt).suffix().replace( QRegExp(";"), "\\;" ) ); 203 name.append( (*addrIt).suffix().replace( QRegExp(";"), "\\;" ) );
193 204
194 if ( !name.join( "" ).isEmpty() ) 205 if ( !name.join( "" ).isEmpty() )
195 card.addLine( VCardLine( "N", name.join( ";" ) ) ); 206 card.addLine( VCardLine( "N", name.join( ";" ) ) );
196 207
197 // NICKNAME 208 // NICKNAME
198 if ( version == VCard::v3_0 ) 209 if ( version == VCard::v3_0 )
199 card.addLine( VCardLine( "NICKNAME", (*addrIt).nickName() ) ); 210 card.addLine( VCardLine( "NICKNAME", (*addrIt).nickName() ) );
200 211
201 // NOTE 212 // NOTE
202 card.addLine( VCardLine( "NOTE", (*addrIt).note() ) ); 213 card.addLine( VCardLine( "NOTE", (*addrIt).note() ) );
203 214
204 // ORG 215 // ORG
205 card.addLine( VCardLine( "ORG", (*addrIt).organization() ) ); 216 card.addLine( VCardLine( "ORG", (*addrIt).organization() ) );
206 217
207 // PHOTO 218 // PHOTO
208 card.addLine( createPicture( "PHOTO", (*addrIt).photo() ) ); 219 card.addLine( createPicture( "PHOTO", (*addrIt).photo() ) );
209 220
210 // PROID 221 // PROID
211 if ( version == VCard::v3_0 ) 222 if ( version == VCard::v3_0 )
212 card.addLine( VCardLine( "PRODID", (*addrIt).productId() ) ); 223 card.addLine( VCardLine( "PRODID", (*addrIt).productId() ) );
213 224
214 // REV 225 // REV
215 card.addLine( VCardLine( "REV", createDateTime( (*addrIt).revision() ) ) ); 226 card.addLine( VCardLine( "REV", createDateTime( (*addrIt).revision() ) ) );
216 227
217 // ROLE 228 // ROLE
218 card.addLine( VCardLine( "ROLE", (*addrIt).role() ) ); 229 card.addLine( VCardLine( "ROLE", (*addrIt).role() ) );
219 230
220 // SORT-STRING 231 // SORT-STRING
221 if ( version == VCard::v3_0 ) 232 if ( version == VCard::v3_0 )
222 card.addLine( VCardLine( "SORT-STRING", (*addrIt).sortString() ) ); 233 card.addLine( VCardLine( "SORT-STRING", (*addrIt).sortString() ) );
223 234
224 // SOUND 235 // SOUND
225 card.addLine( createSound( (*addrIt).sound() ) ); 236 card.addLine( createSound( (*addrIt).sound() ) );
226 237
227 // TEL 238 // TEL
228 PhoneNumber::List phoneNumbers = (*addrIt).phoneNumbers(); 239 PhoneNumber::List phoneNumbers = (*addrIt).phoneNumbers();
229 PhoneNumber::List::ConstIterator phoneIt; 240 PhoneNumber::List::ConstIterator phoneIt;
230 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { 241 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
231 VCardLine line( "TEL", (*phoneIt).number() ); 242 VCardLine line( "TEL", (*phoneIt).number() );
232 243
233 QMap<QString, int>::Iterator typeIt; 244 QMap<QString, int>::Iterator typeIt;
234 for ( typeIt = mPhoneTypeMap.begin(); typeIt != mPhoneTypeMap.end(); ++typeIt ) { 245 for ( typeIt = mPhoneTypeMap.begin(); typeIt != mPhoneTypeMap.end(); ++typeIt ) {
235 if ( typeIt.data() & (*phoneIt).type() ) 246 if ( typeIt.data() & (*phoneIt).type() )
236 line.addParameter( "TYPE", typeIt.key() ); 247 if ( version == VCard::v3_0 )
248 line.addParameter( "TYPE", typeIt.key().lower() );
249 else
250 line.addParameter( "TYPE", typeIt.key() );
237 } 251 }
238 252
239 card.addLine( line ); 253 card.addLine( line );
240 } 254 }
241 255
242 // TITLE 256 // TITLE
243 card.addLine( VCardLine( "TITLE", (*addrIt).title() ) ); 257 card.addLine( VCardLine( "TITLE", (*addrIt).title() ) );
244 258
245 // TZ 259 // TZ
246 TimeZone timeZone = (*addrIt).timeZone(); 260 TimeZone timeZone = (*addrIt).timeZone();
247 if ( timeZone.isValid() ) { 261 if ( timeZone.isValid() ) {
248 QString str; 262 QString str;
249 263
250 int neg = 1; 264 int neg = 1;
251 if ( timeZone.offset() < 0 ) 265 if ( timeZone.offset() < 0 )
252 neg = -1; 266 neg = -1;
253 267
254 str.sprintf( "%c%02d:%02d", ( timeZone.offset() >= 0 ? '+' : '-' ), 268 str.sprintf( "%c%02d:%02d", ( timeZone.offset() >= 0 ? '+' : '-' ),
255 ( timeZone.offset() / 60 ) * neg, 269 ( timeZone.offset() / 60 ) * neg,
256 ( timeZone.offset() % 60 ) * neg ); 270 ( timeZone.offset() % 60 ) * neg );
257 271
258 card.addLine( VCardLine( "TZ", str ) ); 272 card.addLine( VCardLine( "TZ", str ) );
259 } 273 }
260 274
261 // UID 275 // UID
262 card.addLine( VCardLine( "UID", (*addrIt).uid() ) ); 276 card.addLine( VCardLine( "UID", (*addrIt).uid() ) );
263 277
264 // URL 278 // URL
265 card.addLine( VCardLine( "URL", (*addrIt).url().url() ) ); 279 card.addLine( VCardLine( "URL", (*addrIt).url().url() ) );
266 280
267 // VERSION 281 // VERSION
268 if ( version == VCard::v2_1 ) 282 if ( version == VCard::v2_1 )
269 card.addLine( VCardLine( "VERSION", "2.1" ) ); 283 card.addLine( VCardLine( "VERSION", "2.1" ) );
270 if ( version == VCard::v3_0 ) 284 if ( version == VCard::v3_0 )
271 card.addLine( VCardLine( "VERSION", "3.0" ) ); 285 card.addLine( VCardLine( "VERSION", "3.0" ) );
272 286
273 // X- 287 // X-
274 QStringList customs = (*addrIt).customs(); 288 QStringList customs = (*addrIt).customs();
275 for ( strIt = customs.begin(); strIt != customs.end(); ++strIt ) { 289 for ( strIt = customs.begin(); strIt != customs.end(); ++strIt ) {
276 QString identifier = "X-" + (*strIt).left( (*strIt).find( ":" ) ); 290 QString identifier = "X-" + (*strIt).left( (*strIt).find( ":" ) );
277 QString value = (*strIt).mid( (*strIt).find( ":" ) + 1 ); 291 QString value = (*strIt).mid( (*strIt).find( ":" ) + 1 );
278 if ( value.isEmpty() ) 292 if ( value.isEmpty() )
279 continue; 293 continue;
280 294
281 card.addLine( VCardLine( identifier, value ) ); 295 card.addLine( VCardLine( identifier, value ) );
282 } 296 }
283 297
284 vCardList.append( card ); 298 vCardList.append( card );
285 } 299 }
286 300
287 return VCardParser::createVCards( vCardList ); 301 return VCardParser::createVCards( vCardList );
288} 302}
289 303
290Addressee::List VCardTool::parseVCards( const QString& vcard ) 304Addressee::List VCardTool::parseVCards( const QString& vcard )
291{ 305{
292 QChar semicolonSep( ';' ); 306 QChar semicolonSep( ';' );
293 QChar commaSep( ',' ); 307 QChar commaSep( ',' );
294 QString identifier; 308 QString identifier;
295 309
296 Addressee::List addrList; 310 Addressee::List addrList;
297 VCard::List vCardList = VCardParser::parseVCards( vcard ); 311 VCard::List vCardList = VCardParser::parseVCards( vcard );
298 VCard::List::Iterator cardIt; 312 VCard::List::Iterator cardIt;
299 for ( cardIt = vCardList.begin(); cardIt != vCardList.end(); ++cardIt ) { 313 for ( cardIt = vCardList.begin(); cardIt != vCardList.end(); ++cardIt ) {
300 Addressee addr; 314 Addressee addr;