author | ulf69 <ulf69> | 2004-07-09 08:10:08 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-07-09 08:10:08 (UTC) |
commit | de99e22a7093e857ee3c08a67ccc389d6374099a (patch) (side-by-side diff) | |
tree | 511c309f9df3ae71d43c194cc41f27bdb1966a05 /kabc/vcardformatimpl.cpp | |
parent | d56bb523048598245ac4ffcb16689687e082f831 (diff) | |
download | kdepimpi-de99e22a7093e857ee3c08a67ccc389d6374099a.zip kdepimpi-de99e22a7093e857ee3c08a67ccc389d6374099a.tar.gz kdepimpi-de99e22a7093e857ee3c08a67ccc389d6374099a.tar.bz2 |
support of caseinsensitive phone and adress types, as required by the vcard spec
-rw-r--r-- | kabc/vcardformatimpl.cpp | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp index f90f813..3fcaf94 100644 --- a/kabc/vcardformatimpl.cpp +++ b/kabc/vcardformatimpl.cpp @@ -511,41 +511,43 @@ Address VCardFormatImpl::readAddressValue( ContentLine *cl ) a.setStreet( QString::fromUtf8( v->street() ) ); a.setLocality( QString::fromUtf8( v->locality() ) ); a.setRegion( QString::fromUtf8( v->region() ) ); a.setPostalCode( QString::fromUtf8( v->postCode() ) ); a.setCountry( QString::fromUtf8( v->countryName() ) ); a.setType( readAddressParam( cl ) ); return a; } int VCardFormatImpl::readAddressParam( ContentLine *cl ) { int type = 0; ParamList params = cl->paramList(); ParamListIterator it( params ); + QCString tmpStr; for( ; it.current(); ++it ) { - if ( (*it)->name() == "TYPE" ) { - if ( (*it)->value() == "dom" ) type |= Address::Dom; - else if ( (*it)->value() == "intl" ) type |= Address::Intl; - else if ( (*it)->value() == "parcel" ) type |= Address::Parcel; - else if ( (*it)->value() == "postal" ) type |= Address::Postal; - else if ( (*it)->value() == "work" ) type |= Address::Work; - else if ( (*it)->value() == "home" ) type |= Address::Home; - else if ( (*it)->value() == "pref" ) type |= Address::Pref; + if ( (*it)->name().upper() == "TYPE" ) { + tmpStr = (*it)->value().lower(); + if ( tmpStr == "dom" ) type |= Address::Dom; + else if ( tmpStr == "intl" ) type |= Address::Intl; + else if ( tmpStr == "parcel" ) type |= Address::Parcel; + else if ( tmpStr == "postal" ) type |= Address::Postal; + else if ( tmpStr == "work" ) type |= Address::Work; + else if ( tmpStr == "home" ) type |= Address::Home; + else if ( tmpStr == "pref" ) type |= Address::Pref; } } return type; } void VCardFormatImpl::addNValue( VCard *vcard, const Addressee &a ) { ContentLine cl; cl.setName(EntityTypeToParamName( EntityN ) ); NValue *v = new NValue; v->setFamily( a.familyName().utf8() ); v->setGiven( a.givenName().utf8() ); v->setMiddle( a.additionalName().utf8() ); v->setPrefix( a.prefix().utf8() ); v->setSuffix( a.suffix().utf8() ); @@ -588,48 +590,50 @@ void VCardFormatImpl::addTelephoneValue( VCard *v, const PhoneNumber &p ) if( p.type() & PhoneNumber::Pcs ) params.append( new Param( "TYPE", "pcs" ) ); if( p.type() & PhoneNumber::Pager ) params.append( new Param( "TYPE", "pager" ) ); cl.setParamList( params ); v->add(cl); } PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl ) { PhoneNumber p; TelValue *value = (TelValue *)cl->value(); p.setNumber( QString::fromUtf8( value->asString() ) ); int type = 0; ParamList params = cl->paramList(); ParamListIterator it( params ); + QCString tmpStr; for( ; it.current(); ++it ) { if ( (*it)->name() == "TYPE" ) { - if ( (*it)->value() == "home" ) type |= PhoneNumber::Home; - else if ( (*it)->value() == "work" ) type |= PhoneNumber::Work; - else if ( (*it)->value() == "msg" ) type |= PhoneNumber::Msg; - else if ( (*it)->value() == "pref" ) type |= PhoneNumber::Pref; - else if ( (*it)->value() == "voice" ) type |= PhoneNumber::Voice; - else if ( (*it)->value() == "fax" ) type |= PhoneNumber::Fax; - else if ( (*it)->value() == "cell" ) type |= PhoneNumber::Cell; - else if ( (*it)->value() == "video" ) type |= PhoneNumber::Video; - else if ( (*it)->value() == "bbs" ) type |= PhoneNumber::Bbs; - else if ( (*it)->value() == "modem" ) type |= PhoneNumber::Modem; - else if ( (*it)->value() == "car" ) type |= PhoneNumber::Car; - else if ( (*it)->value() == "isdn" ) type |= PhoneNumber::Isdn; - else if ( (*it)->value() == "pcs" ) type |= PhoneNumber::Pcs; - else if ( (*it)->value() == "pager" ) type |= PhoneNumber::Pager; + tmpStr = (*it)->value().lower(); + if ( tmpStr == "home" ) type |= PhoneNumber::Home; + else if ( tmpStr == "work" ) type |= PhoneNumber::Work; + else if ( tmpStr == "msg" ) type |= PhoneNumber::Msg; + else if ( tmpStr == "pref" ) type |= PhoneNumber::Pref; + else if ( tmpStr == "voice" ) type |= PhoneNumber::Voice; + else if ( tmpStr == "fax" ) type |= PhoneNumber::Fax; + else if ( tmpStr == "cell" ) type |= PhoneNumber::Cell; + else if ( tmpStr == "video" ) type |= PhoneNumber::Video; + else if ( tmpStr == "bbs" ) type |= PhoneNumber::Bbs; + else if ( tmpStr == "modem" ) type |= PhoneNumber::Modem; + else if ( tmpStr == "car" ) type |= PhoneNumber::Car; + else if ( tmpStr == "isdn" ) type |= PhoneNumber::Isdn; + else if ( tmpStr == "pcs" ) type |= PhoneNumber::Pcs; + else if ( tmpStr == "pager" ) type |= PhoneNumber::Pager; } } p.setType( type ); return p; } QString VCardFormatImpl::readTextValue( ContentLine *cl ) { VCARD::Value *value = cl->value(); if ( value ) { return QString::fromUtf8( value->asString() ); } else { kdDebug(5700) << "No value: " << cl->asString() << endl; return QString::null; } |