-rw-r--r-- | kabc/vcard21parser.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/kabc/vcard21parser.cpp b/kabc/vcard21parser.cpp index b02aac4..277de22 100644 --- a/kabc/vcard21parser.cpp +++ b/kabc/vcard21parser.cpp @@ -109,129 +109,130 @@ bool VCardLineX::isValid() const return true; if ( name == VCARD_LOGO ) return true; break; case 'm': if ( name == VCARD_MAILER ) return true; break; case 'n': if ( name == VCARD_N ) return true; if ( name == VCARD_NAME ) return true; if ( name == VCARD_NICKNAME ) return true; if ( name == VCARD_NOTE ) return true; break; case 'o': if ( name == VCARD_ORG ) return true; break; case 'p': if ( name == VCARD_PHOTO ) return true; if ( name == VCARD_PROFILE ) return true; if ( name == VCARD_PRODID ) return true; break; case 'r': if ( name == VCARD_ROLE ) return true; if ( name == VCARD_REV ) return true; break; case 's': if ( name == VCARD_SOURCE ) return true; if ( name == VCARD_SOUND ) return true; break; 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_PCS) || + qualifiers.contains(VCARD_TEL_SIP) ) ) 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': if ( name == VCARD_VERSION ) return true; break; default: break; } return false; } VCard21Parser::VCard21Parser() { } VCard21Parser::~VCard21Parser() { } void VCard21Parser::readFromString(KABC::AddressBook *addressbook, const QString &data) { KABC::Addressee mAddressee = readFromString(data); addressbook->insertAddressee(mAddressee); } KABC::Addressee VCard21Parser::readFromString( const QString &data) { KABC::Addressee addressee; VCard21ParserImpl *mVCard = VCard21ParserImpl::parseVCard(data); QString tmpStr; // Check if parsing failed if (mVCard == 0) { kdDebug() << "Parsing failed" << endl; return addressee; } //set the addressees name and formated name QStringList tmpList = mVCard->getValues(VCARD_N); QString formattedName = ""; if (tmpList.count() > 0) addressee.setFamilyName(tmpList[0]); if (tmpList.count() > 1) addressee.setGivenName(tmpList[1]); if (tmpList.count() > 2) addressee.setAdditionalName(tmpList[2]); if (tmpList.count() > 3) addressee.setPrefix(tmpList[3]); @@ -240,128 +241,130 @@ KABC::Addressee VCard21Parser::readFromString( const QString &data) tmpStr = (mVCard->getValue(VCARD_FN)); if (!tmpStr.isEmpty()) addressee.setFormattedName(tmpStr); //set the addressee's nick name tmpStr = mVCard->getValue(VCARD_NICKNAME); addressee.setNickName(tmpStr); //set the addressee's organisation tmpStr = mVCard->getValue(VCARD_ORG); addressee.setOrganization(tmpStr); //set the addressee's title tmpStr = mVCard->getValue(VCARD_TITLE); addressee.setTitle(tmpStr); //set the addressee's email - we can only deal with two. The preferenced one and one other. tmpStr = mVCard->getValue(VCARD_EMAIL, VCARD_EMAIL_INTERNET); addressee.insertEmail(tmpStr, false); tmpStr = mVCard->getValue(VCARD_EMAIL,VCARD_EMAIL_PREF); addressee.insertEmail(tmpStr, true); //set the addressee's url tmpStr = mVCard->getValue(VCARD_URL); if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_WORK); if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_HOME); if (!tmpStr.isEmpty()) { addressee.setUrl(KURL(tmpStr)); } //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; 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 ) ); } } //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 ) ) type |= Address::Work; if ( (*i).qualifiers.contains( VCARD_ADR_PREF ) ) type |= Address::Pref; } addressee.insertAddress( readAddressFromQStringList( (*i).parameters, type ) ); } } //set the addressee's delivery label tmpStr = mVCard->getValue(VCARD_LABEL); if (!tmpStr.isEmpty()) { qDebug("VCard21Parser::readFromString please verify if replace is correct"); //US tmpStr.replace("\r\n","\n"); tmpStr.replace( QRegExp("\r\n"), "\n" ); Address tmpAddress; tmpAddress.setLabel(tmpStr); addressee.insertAddress(tmpAddress); } //set the addressee's notes tmpStr = mVCard->getValue(VCARD_NOTE); qDebug("VCard21Parser::readFromString please verify if correct"); //US tmpStr.replace("\r\n","\n"); tmpStr.replace( QRegExp("\r\n"), "\n" ); addressee.setNote(tmpStr); //set the addressee's timezone tmpStr = mVCard->getValue(VCARD_TZ); TimeZone tmpZone(tmpStr.toInt()); addressee.setTimeZone(tmpZone); //set the addressee's geographical position tmpList = mVCard->getValues(VCARD_GEO); if (tmpList.count()==2) { tmpStr = tmpList[0]; float glat = tmpStr.toFloat(); tmpStr = tmpList[1]; float glong = tmpStr.toFloat(); Geo tmpGeo(glat,glong); addressee.setGeo(tmpGeo); } |