-rw-r--r-- | kabc/addressee.cpp | 74 | ||||
-rw-r--r-- | kabc/addressee.h | 2 | ||||
-rw-r--r-- | kabc/field.cpp | 10 | ||||
-rw-r--r-- | kabc/phonenumber.cpp | 112 | ||||
-rw-r--r-- | kabc/phonenumber.h | 5 | ||||
-rw-r--r-- | kabc/vcard21parser.cpp | 14 | ||||
-rw-r--r-- | kabc/vcardformatimpl.cpp | 4 | ||||
-rw-r--r-- | kabc/vcardparser/vcardtool.cpp | 2 |
8 files changed, 196 insertions, 27 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 7e1e414..661bdf6 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -573,33 +573,85 @@ void Addressee::simplifyAddresses() } for( it = list.begin(); it != list.end(); ++it ) { removeAddress( (*it) ); } } // removes all emails but the first // needed by phone sync void Addressee::simplifyEmails() { if ( mData->emails.count() == 0 ) return ; QString email = mData->emails.first(); detach(); mData->emails.clear(); mData->emails.append( email ); } +void Addressee::makePhoneNumbersOLcompatible() +{ + KABC::PhoneNumber::List::Iterator phoneIter; + KABC::PhoneNumber::List::Iterator phoneIter2; + for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); + ++phoneIter ) { + ( *phoneIter ).makeCompat(); + } + int hasHome = hasPhoneNumberType( PhoneNumber::Home | PhoneNumber::Pref ); + int hasHome2 = hasPhoneNumberType( PhoneNumber::Home ); + int hasWork = hasPhoneNumberType( PhoneNumber::Work | PhoneNumber::Pref ); + int hasWork2 = hasPhoneNumberType( PhoneNumber::Work ); + int hasCell = hasPhoneNumberType( PhoneNumber::Cell ); + int hasCell2 = hasPhoneNumberType( PhoneNumber::Car ); + for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); + ++phoneIter ) { + if ( (*phoneIter).type() == PhoneNumber::Home && ! hasHome ) { + (*phoneIter).setType( PhoneNumber::Home | PhoneNumber::Pref ); + ++hasHome; + if ( hasHome2 ) --hasHome2; + } else if ( ( (*phoneIter).type() == PhoneNumber::Home | PhoneNumber::Pref) && hasHome>1 && !hasHome2 ) { + (*phoneIter).setType( PhoneNumber::Home ); + --hasHome; + ++hasHome2; + } else if ( (*phoneIter).type() == PhoneNumber::Work && ! hasWork ) { + (*phoneIter).setType( PhoneNumber::Work | PhoneNumber::Pref ); + ++hasWork; + if ( hasWork2 ) --hasWork2; + } else if ( ( (*phoneIter).type() == PhoneNumber::Work | PhoneNumber::Pref) && hasWork > 1 && ! hasWork2 ) { + (*phoneIter).setType( PhoneNumber::Work ); + --hasWork; + ++hasWork2; + } else if ( (*phoneIter).type() == PhoneNumber::Cell && hasCell > 1 && !hasCell2) { + (*phoneIter).setType( PhoneNumber::Car ); + ++hasCell2; + --hasCell; + } else if ( (*phoneIter).type() == PhoneNumber::Car && hasCell2 > 1 && !hasCell) { + (*phoneIter).setType( PhoneNumber::Cell ); + ++hasCell; + --hasCell2; + } else{ + phoneIter2 = phoneIter; + ++phoneIter2; + for ( ; phoneIter2 != mData->phoneNumbers.end(); + ++phoneIter2 ) { + if ( (*phoneIter2).type() == (*phoneIter).type() ) { + (*phoneIter2).setType( PhoneNumber::Voice ); + } + } + } + } +} void Addressee::simplifyPhoneNumbers() { int max = 4; int inList = mData->phoneNumbers.count(); KABC::PhoneNumber::List removeNumbers; KABC::PhoneNumber::List::Iterator phoneIter; if ( inList > max ) { // delete non-preferred numbers for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) { if ( inList > max ) { if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { removeNumbers.append( ( *phoneIter ) ); --inList; } } else @@ -984,65 +1036,65 @@ QString Addressee::businessAddressCountryLabel() QString Addressee::businessAddressLabelLabel() { return i18n("Business Address Label"); } QString Addressee::homePhoneLabel() { return i18n("Home Phone"); } QString Addressee::businessPhoneLabel() { - return i18n("Business Phone"); + return i18n("Work Phone"); } QString Addressee::mobilePhoneLabel() { return i18n("Mobile Phone"); } QString Addressee::mobileWorkPhoneLabel() { - return i18n("Mobile (work)"); + return i18n("Mobile2 (work)"); } QString Addressee::mobileHomePhoneLabel() { - return i18n("Mobile (home)"); + return i18n("Mobile"); } QString Addressee::homeFaxLabel() { - return i18n("Home Fax"); + return i18n("Fax (Home)"); } QString Addressee::businessFaxLabel() { - return i18n("Business Fax"); + return i18n("Fax (Work)"); } QString Addressee::carPhoneLabel() { - return i18n("Car Phone"); + return i18n("Mobile2 (work)"); } QString Addressee::isdnLabel() { return i18n("ISDN"); } QString Addressee::pagerLabel() { return i18n("Pager"); } QString Addressee::sipLabel() { @@ -1639,32 +1691,42 @@ PhoneNumber Addressee::phoneNumber( int type ) const if ( matchBinaryPatternP( (*it).type(), type ) ) { if ( (*it).type() & PhoneNumber::Pref ) return (*it); else if ( phoneNumber.number().isEmpty() ) phoneNumber = (*it); } } return phoneNumber; } PhoneNumber::List Addressee::phoneNumbers() const { return mData->phoneNumbers; } +int Addressee::hasPhoneNumberType( int type ) +{ + int retval = 0; + PhoneNumber::List::ConstIterator it; + for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { + if ( (*it).type() == type ) + ++retval; + } + return retval; +} PhoneNumber::List Addressee::phoneNumbers( int type ) const { PhoneNumber::List list; PhoneNumber::List::ConstIterator it; for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { if ( matchBinaryPattern( (*it).type(), type ) ) { list.append( *it ); } } return list; } PhoneNumber Addressee::findPhoneNumber( const QString &id ) const { PhoneNumber::List::ConstIterator it; diff --git a/kabc/addressee.h b/kabc/addressee.h index d1c07cb..0c488eb 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h @@ -109,32 +109,34 @@ class Addressee void removeID(const QString &); void computeCsum(const QString &dev); ulong getCsum4List( const QStringList & attList); /** Return, if the address book entry is empty. */ bool isEmpty() const; void setExternalUID( const QString &id ); const QString externalUID() const; void setOriginalExternalUID( const QString &id ); QString originalExternalUID() const; void mergeContact( const Addressee& ad, bool isSubSet ); void simplifyEmails(); void simplifyAddresses(); void simplifyPhoneNumbers(); void simplifyPhoneNumberTypes(); + void makePhoneNumbersOLcompatible(); + int hasPhoneNumberType( int type ); bool removeVoice(); bool containsAdr(const Addressee& addr ); /** Set unique identifier. */ void setUid( const QString &uid ); /** Return unique identifier. */ const QString uid() const; /** Return translated label for uid field. */ static QString uidLabel(); diff --git a/kabc/field.cpp b/kabc/field.cpp index fd51026..20885de 100644 --- a/kabc/field.cpp +++ b/kabc/field.cpp @@ -276,53 +276,53 @@ QString Field::value( const KABC::Addressee &a ) // QString _oldFormat = KGlobal::locale()->dateFormat(); // KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate); // KGlobal::locale()->setDateFormat(_oldFormat); return dt; } else return QString::null; case FieldImpl::Url: return a.url().prettyURL(); //US case FieldImpl::Resource: return a.resource()->resourceName(); case FieldImpl::Category: return a.categories().join(","); case FieldImpl::HomePhone: - return a.phoneNumber( PhoneNumber::Home ).number(); + return a.phoneNumber( PhoneNumber::Home| PhoneNumber::Pref ).number(); case FieldImpl::BusinessPhone: - return a.phoneNumber( PhoneNumber::Work ).number(); + return a.phoneNumber( PhoneNumber::Work| PhoneNumber::Pref ).number(); case FieldImpl::MobilePhone: return a.phoneNumber( PhoneNumber::Cell ).number(); case FieldImpl::MobileWorkPhone: - return a.phoneNumber( PhoneNumber::Cell | PhoneNumber::Work ).number(); + return a.phoneNumber( PhoneNumber::Car ).number(); case FieldImpl::MobileHomePhone: - return a.phoneNumber( PhoneNumber::Cell | PhoneNumber::Home ).number(); + return a.phoneNumber( PhoneNumber::Cell ).number(); case FieldImpl::HomeFax: return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); case FieldImpl::BusinessFax: return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); case FieldImpl::CarPhone: return a.phoneNumber( PhoneNumber::Car ).number(); case FieldImpl::Isdn: return a.phoneNumber( PhoneNumber::Isdn ).number(); case FieldImpl::Pager: return a.phoneNumber( PhoneNumber::Pager ).number(); case FieldImpl::Sip: - return a.phoneNumber( PhoneNumber::Sip ).number(); + return a.phoneNumber( PhoneNumber::Pcs | PhoneNumber::Pref ).number(); case FieldImpl::HomeAddressStreet: return a.address( Address::Home ).street(); case FieldImpl::HomeAddressLocality: return a.address( Address::Home ).locality(); case FieldImpl::HomeAddressRegion: return a.address( Address::Home ).region(); case FieldImpl::HomeAddressPostalCode: return a.address( Address::Home ).postalCode(); case FieldImpl::HomeAddressCountry: return a.address( Address::Home ).country(); case FieldImpl::BusinessAddressStreet: return a.address( Address::Work ).street(); case FieldImpl::BusinessAddressLocality: return a.address( Address::Work ).locality(); case FieldImpl::BusinessAddressRegion: return a.address( Address::Work ).region(); diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index 4c6231d..0d46ba7 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp @@ -52,33 +52,88 @@ void PhoneNumber::init() { mId = KApplication::randomString( 8 ); } bool PhoneNumber::operator==( const PhoneNumber &p ) const { if ( mNumber != p.mNumber ) return false; if ( mType != p.mType ) return false; return true; } bool PhoneNumber::operator!=( const PhoneNumber &p ) const { return !( p == *this ); } +void PhoneNumber::makeCompat() +{ + mType = getCompatType( mType ); +} +int PhoneNumber::getCompatType( int type ) +{ + + if ((type & Cell) == Cell) { + if ((type & Work) == Work) + return Car; + return Cell; + } + if ((type & Home) == Home) { + if ((type & Pref) == Pref) + return (Home | Pref); + if ((type & Fax) == Fax) + return (Home | Fax); + return (Home); + } + if ((type & Work) == Work) { + if ((type & Pref) == Pref) + return (Work| Pref); + if ((type & Fax) == Fax) + return (Fax |Work); + if ((type & Msg) == Msg) { + if ((type & Voice) == Voice) + return ( Msg | Voice |Work); + return ( Msg | Work); + } + return Work; + } + if ((type & Pcs) == Pcs) { + if ((type & Pref) == Pref) + return Pcs | Pref; + return Pcs; + } + if ((type & Car) == Car) + return Car; + if ((type & Pager) == Pager) + return Pager; + if ((type & Isdn) == Isdn) + return Isdn; + if ((type & Video) == Video) + return Video; + + if ((type & Msg) == Msg) + return Msg; + if ((type & Fax) == Fax) + return Fax; + + if ((type & Pref) == Pref) + return Pref; + return Voice; + +} bool PhoneNumber::simplifyNumber() { QString Number; int i; Number = mNumber.stripWhiteSpace (); mNumber = ""; for ( i = 0; i < Number.length(); ++i) { if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) mNumber += Number.at(i); } return ( mNumber.length() > 0 ); } // make cellphone compatible void PhoneNumber::simplifyType() { if ( mType & Fax ) mType = Fax; @@ -150,46 +205,98 @@ QString PhoneNumber::typeLabel() const } } return label; } QString PhoneNumber::label() const { return typeLabel( type() ); } PhoneNumber::TypeList PhoneNumber::typeList() { TypeList list; list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video - << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip; + << Bbs << Modem << Car << Isdn << Pcs << Pager; return list; } QString PhoneNumber::label( int type ) { return typeLabel( type ); } QString PhoneNumber::typeLabel( int type ) { - QString typeString; + if ((type & Cell) == Cell) + return i18n("Mobile"); + if ((type & Home) == Home) { + if ((type & Pref) == Pref) + return i18n("Home"); + if ((type & Fax) == Fax) + return i18n("Fax (Home)"); + return i18n("Home2"); + } + if ((type & Work) == Work) { + if ((type & Pref) == Pref) + return i18n("Work"); + if ((type & Fax) == Fax) + return i18n("Fax (Work)"); + if ((type & Msg) == Msg) { + if ((type & Voice) == Voice) + return i18n("Assistent"); + return i18n("Company"); + } + return i18n("Work2"); + } + if ((type & Pcs) == Pcs) { + if ((type & Pref) == Pref) + return i18n("SIP"); + return i18n("VoIP"); + } + if ((type & Car) == Car) + return i18n("Mobile2 (Work)"); + if ((type & Pager) == Pager) + return i18n("Pager"); + if ((type & Isdn) == Isdn) + return i18n("ISDN"); + if ((type & Video) == Video) + return i18n("Video"); + + if ((type & Msg) == Msg) + return i18n("Callback"); + if ((type & Fax) == Fax) + return i18n("Fax (Other)"); + + if ((type & Pref) == Pref) + return i18n("Primary"); + + + return i18n("Other"); + + +#if 0 + + + + QString typeString; + if ((type & Cell) == Cell) typeString += i18n("Mobile") +" "; if ((type & Home) == Home) typeString += i18n("Home")+" "; else if ((type & Work) == Work) typeString += i18n("Work")+" "; if ((type & Sip) == Sip) typeString += i18n("SIP")+" "; if ((type & Car) == Car) typeString += i18n("Car")+" "; if ((type & Fax) == Fax) typeString += i18n("Fax"); else if ((type & Msg) == Msg) @@ -207,29 +314,30 @@ QString PhoneNumber::typeLabel( int type ) else if ((type & Pager) == Pager) typeString += i18n("Pager"); // add the prefered flag /* if ((type & Pref) == Pref) typeString += i18n("(p)"); */ //if we still have no match, return "other" if (typeString.isEmpty()) { if ((type & Voice) == Voice) return i18n("Voice"); else return i18n("Other"); } return typeString.stripWhiteSpace(); +#endif } QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) { return s << phone.mId << phone.mType << phone.mNumber; } QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) { s >> phone.mId >> phone.mType >> phone.mNumber; return s; } diff --git a/kabc/phonenumber.h b/kabc/phonenumber.h index 2d4d3e0..b9d6a17 100644 --- a/kabc/phonenumber.h +++ b/kabc/phonenumber.h @@ -51,37 +51,36 @@ class PhoneNumber /** @li @p Home - Home number @li @p Work - Office number @li @p Msg - Messaging @li @p Pref - Preferred number @li @p Voice - Voice @li @p Fax - Fax machine @li @p Cell - Cell phone @li @p Video - Video phone @li @p Bbs - Mailbox @li @p Modem - Modem @li @p Car - Car phone @li @p Isdn - ISDN connection @li @p Pcs - Personal Communication Service @li @p Pager - Pager - @li @p SIP - VoIP */ enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32, Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024, - Isdn = 2048, Pcs = 4096, Pager = 8192, Sip = 16384 }; + Isdn = 2048, Pcs = 4096, Pager = 8192 }; /** Create an empty phone number object. */ PhoneNumber(); /** Create a phonenumber object. @param number Number @param type Type as defined in enum. Multiple types can be specified by combining them by a logical or. */ PhoneNumber( const QString &number, int type = Home ); /** @@ -138,32 +137,34 @@ class PhoneNumber Returns a list of all available types */ static TypeList typeList(); /** Returns the translated label for phone number type. */ static QString typeLabel( int type ); /** Returns the translated label for phone number type. @obsolete */ static QString label( int type ); bool simplifyNumber(); void simplifyType(); + void makeCompat(); + int getCompatType( int type ); private: void init(); QString mId; int mType; QString mNumber; }; QDataStream &operator<<( QDataStream &, const PhoneNumber & ); QDataStream &operator>>( QDataStream &, PhoneNumber & ); } #endif diff --git a/kabc/vcard21parser.cpp b/kabc/vcard21parser.cpp index 277de22..60d02b8 100644 --- a/kabc/vcard21parser.cpp +++ b/kabc/vcard21parser.cpp @@ -157,34 +157,33 @@ bool VCardLineX::isValid() const case 't': if ( name == VCARD_TEL && qualified && (qualifiers.contains(VCARD_TEL_HOME) || qualifiers.contains(VCARD_TEL_WORK) || qualifiers.contains(VCARD_TEL_PREF) || qualifiers.contains(VCARD_TEL_VOICE) || qualifiers.contains(VCARD_TEL_FAX) || qualifiers.contains(VCARD_TEL_MSG) || qualifiers.contains(VCARD_TEL_CELL) || qualifiers.contains(VCARD_TEL_PAGER) || qualifiers.contains(VCARD_TEL_BBS) || qualifiers.contains(VCARD_TEL_MODEM) || qualifiers.contains(VCARD_TEL_CAR) || qualifiers.contains(VCARD_TEL_ISDN) || qualifiers.contains(VCARD_TEL_VIDEO) || - qualifiers.contains(VCARD_TEL_PCS) || - qualifiers.contains(VCARD_TEL_SIP) + qualifiers.contains(VCARD_TEL_PCS) ) ) return true; if ( name == VCARD_TZ ) return true; if ( name == VCARD_TITLE ) return true; break; case 'u': if ( name == VCARD_URL ) return true; if ( name == VCARD_UID ) return true; break; case 'v': @@ -266,62 +265,61 @@ KABC::Addressee VCard21Parser::readFromString( const QString &data) } //set the addressee's birthday tmpStr = mVCard->getValue(VCARD_BDAY); addressee.setBirthday(VCardStringToDate(tmpStr)); //set the addressee's phone numbers for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { if ( (*i).name == VCARD_TEL ) { int type = 0; if ( (*i).qualified ) { if ( (*i).qualifiers.contains( VCARD_TEL_HOME ) ) type |= PhoneNumber::Home; if ( (*i).qualifiers.contains( VCARD_TEL_WORK ) ) type |= PhoneNumber::Work; if ( (*i).qualifiers.contains( VCARD_TEL_PREF ) ) - type |= PhoneNumber::Pref; - // if ( (*i).qualifiers.contains( VCARD_TEL_VOICE ) ) - // type |= PhoneNumber::Voice; + type |= PhoneNumber::Pref; + if ( (*i).qualifiers.contains( VCARD_TEL_VOICE ) ) + type |= PhoneNumber::Voice; if ( (*i).qualifiers.contains( VCARD_TEL_FAX ) ) type |= PhoneNumber::Fax; if ( (*i).qualifiers.contains( VCARD_TEL_MSG ) ) type |= PhoneNumber::Msg; if ( (*i).qualifiers.contains( VCARD_TEL_CELL ) ) type |= PhoneNumber::Cell; if ( (*i).qualifiers.contains( VCARD_TEL_PAGER ) ) type |= PhoneNumber::Pager; if ( (*i).qualifiers.contains( VCARD_TEL_BBS ) ) type |= PhoneNumber::Bbs; if ( (*i).qualifiers.contains( VCARD_TEL_MODEM ) ) type |= PhoneNumber::Modem; if ( (*i).qualifiers.contains( VCARD_TEL_CAR ) ) type |= PhoneNumber::Car; if ( (*i).qualifiers.contains( VCARD_TEL_ISDN ) ) type |= PhoneNumber::Isdn; if ( (*i).qualifiers.contains( VCARD_TEL_VIDEO ) ) type |= PhoneNumber::Video; if ( (*i).qualifiers.contains( VCARD_TEL_PCS ) ) type |= PhoneNumber::Pcs; - if ( (*i).qualifiers.contains( VCARD_TEL_SIP ) ) - type |= PhoneNumber::Sip; + } addressee.insertPhoneNumber( PhoneNumber( (*i).parameters[ 0 ], type ) ); } } - + addressee.makePhoneNumbersOLcompatible(); //set the addressee's addresses for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { if ( (*i).name == VCARD_ADR ) { int type = 0; if ( (*i).qualified ) { if ( (*i).qualifiers.contains( VCARD_ADR_DOM ) ) type |= Address::Dom; if ( (*i).qualifiers.contains( VCARD_ADR_INTL ) ) type |= Address::Intl; if ( (*i).qualifiers.contains( VCARD_ADR_POSTAL ) ) type |= Address::Postal; if ( (*i).qualifiers.contains( VCARD_ADR_PARCEL ) ) type |= Address::Parcel; if ( (*i).qualifiers.contains( VCARD_ADR_HOME ) ) type |= Address::Home; if ( (*i).qualifiers.contains( VCARD_ADR_WORK ) ) diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp index ec5ed80..26fd4f0 100644 --- a/kabc/vcardformatimpl.cpp +++ b/kabc/vcardformatimpl.cpp @@ -268,33 +268,33 @@ bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) break; } } for( cl = contentLines.first(); cl; cl = contentLines.next() ) { EntityType type = cl->entityType(); if ( type == EntityLabel ) { int type = readAddressParam( cl ); Address address = addressee.address( type ); if ( address.isEmpty() ) address.setType( type ); address.setLabel( QString::fromUtf8( cl->value()->asString() ) ); addressee.insertAddress( address ); } } - + addressee.makePhoneNumbersOLcompatible(); return true; } void VCardFormatImpl::saveAddressee( const Addressee &addressee, VCard *v, bool intern ) { //US ContentLine cl; //US QString value; addTextValue( v, EntityName, addressee.name() ); addTextValue( v, EntityUID, addressee.uid() ); addTextValue( v, EntityFullName, addressee.formattedName() ); QStringList emails = addressee.emails(); QStringList::ConstIterator it4; for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) { addTextValue( v, EntityEmail, *it4 ); @@ -582,66 +582,64 @@ void VCardFormatImpl::addTelephoneValue( VCard *v, const PhoneNumber &p ) ParamList params; if( p.type() & PhoneNumber::Home ) params.append( new Param( "TYPE", "home" ) ); if( p.type() & PhoneNumber::Work ) params.append( new Param( "TYPE", "work" ) ); if( p.type() & PhoneNumber::Msg ) params.append( new Param( "TYPE", "msg" ) ); if( p.type() & PhoneNumber::Pref ) params.append( new Param( "TYPE", "pref" ) ); if( p.type() & PhoneNumber::Voice ) params.append( new Param( "TYPE", "voice" ) ); if( p.type() & PhoneNumber::Fax ) params.append( new Param( "TYPE", "fax" ) ); if( p.type() & PhoneNumber::Cell ) params.append( new Param( "TYPE", "cell" ) ); if( p.type() & PhoneNumber::Video ) params.append( new Param( "TYPE", "video" ) ); if( p.type() & PhoneNumber::Bbs ) params.append( new Param( "TYPE", "bbs" ) ); if( p.type() & PhoneNumber::Modem ) params.append( new Param( "TYPE", "modem" ) ); if( p.type() & PhoneNumber::Car ) params.append( new Param( "TYPE", "car" ) ); if( p.type() & PhoneNumber::Isdn ) params.append( new Param( "TYPE", "isdn" ) ); if( p.type() & PhoneNumber::Pcs ) params.append( new Param( "TYPE", "pcs" ) ); if( p.type() & PhoneNumber::Pager ) params.append( new Param( "TYPE", "pager" ) ); - if( p.type() & PhoneNumber::Sip ) params.append( new Param( "TYPE", "sip" ) ); 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" ) { 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; - else if ( tmpStr == "sip" ) type |= PhoneNumber::Sip; } } 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; qDebug("No value: %s", (const char*)(cl->asString())); return QString::null; diff --git a/kabc/vcardparser/vcardtool.cpp b/kabc/vcardparser/vcardtool.cpp index c3d92b6..204326e 100644 --- a/kabc/vcardparser/vcardtool.cpp +++ b/kabc/vcardparser/vcardtool.cpp @@ -563,33 +563,33 @@ Addressee::List VCardTool::parseVCards( const QString& vcard ) // UID else if ( identifier == "uid" ) addr.setUid( (*lineIt).valueString() ); // URL else if ( identifier == "url" ) addr.setUrl( KURL( (*lineIt).valueString() ) ); // X- else if ( identifier.startsWith( "x-" ) ) { const QString key = (*lineIt).identifier().mid( 2 ); int dash = key.find( "-" ); addr.insertCustom( key.left( dash ), key.mid( dash + 1 ), (*lineIt).valueString() ); } } } - + addr.makePhoneNumbersOLcompatible(); addrList.append( addr ); } return addrList; } QDateTime VCardTool::parseDateTime( const QString &str ) { QDateTime dateTime; if ( str.find( '-' ) == -1 ) { // is base format (yyyymmdd) dateTime.setDate( QDate( str.left( 4 ).toInt(), str.mid( 4, 2 ).toInt(), str.mid( 6, 2 ).toInt() ) ); if ( str.find( 'T' ) ) // has time information yyyymmddThh:mm:ss dateTime.setTime( QTime( str.mid( 11, 2 ).toInt(), str.mid( 14, 2 ).toInt(), |