示例#1
0
Addressee
vcard2()
{
    Addressee addr;

    addr.setName( "Tim Howes" );
    addr.setOrganization( "Netscape Communications Corp." );
    addr.insertEmail( "*****@*****.**" );
    addr.insertPhoneNumber( PhoneNumber("+1-415-937-3419",PhoneNumber::Voice|PhoneNumber::Msg
                                        |PhoneNumber::Work) );
    addr.insertPhoneNumber( PhoneNumber("+1-415-528-4164",PhoneNumber::Fax |PhoneNumber::Work) );
    Address a( Address::Work );
    a.setStreet( "501 E. Middlefield Rd." );
    a.setLocality( "Mountain View" );
    a.setRegion( "CA" );
    a.setPostalCode( "94043" );
    a.setCountry( "U.S.A." );
    addr.insertAddress( a );
    return addr;
}
示例#2
0
Addressee
vcard1()
{
    Addressee addr;

    addr.setName( "Frank Dawson" );
    addr.setOrganization( "Lotus Development Corporation" );
    addr.setUrl( KURL( "http://home.earthlink.net/~fdawson") );
    addr.insertEmail( "*****@*****.**" );
    addr.insertEmail( "*****@*****.**", true );
    addr.insertPhoneNumber( PhoneNumber("+1-919-676-9515",PhoneNumber::Voice|PhoneNumber::Msg
                                        |PhoneNumber::Work ) );
    addr.insertPhoneNumber( PhoneNumber("+1-919-676-9564",PhoneNumber::Fax |PhoneNumber::Work ));
    Address a( Address::Work | Address::Postal | Address::Parcel );
    a.setStreet( "6544 Battleford Drive" );
    a.setLocality( "Raleigh" );
    a.setRegion( "NC" );
    a.setPostalCode( "27613-3502" );
    a.setCountry( "U.S.A." );
    addr.insertAddress( a );
    return addr;
}
示例#3
0
bool ResourceSql::load()
{
    QSqlQuery query(
        "select addressId, name, familyName, givenName, "
        "additionalName, prefix, suffix, nickname, birthday, "
        "mailer, timezone, geo_latitude, geo_longitude, title, "
        "role, organization, note, productId, revision, "
        "sortString, url from kaddressbook_main_"
        + mUser);

    while(query.next())
    {
        QString addrId = query.value(0).toString();

        Addressee addr;
        addr.setResource(this);
        addr.setUid(addrId);
        addr.setName(query.value(1).toString());
        addr.setFamilyName(query.value(2).toString());
        addr.setGivenName(query.value(3).toString());
        addr.setAdditionalName(query.value(4).toString());
        addr.setPrefix(query.value(5).toString());
        addr.setSuffix(query.value(6).toString());
        addr.setNickName(query.value(7).toString());
        addr.setBirthday(query.value(8).toDateTime());
        addr.setMailer(query.value(9).toString());
        addr.setTimeZone(TimeZone(query.value(10).toInt()));
        addr.setGeo(Geo(query.value(11).toDouble(), query.value(12).toDouble()));
        addr.setTitle(query.value(13).toString());
        addr.setRole(query.value(14).toString());
        addr.setOrganization(query.value(15).toString());
        addr.setNote(query.value(16).toString());
        addr.setProductId(query.value(17).toString());
        addr.setRevision(query.value(18).toDateTime());
        addr.setSortString(query.value(19).toString());
        addr.setUrl(query.value(20).toString());

        // emails
        {
            QSqlQuery emailsQuery(
                "select email, preferred from kaddressbook_emails "
                "where addressId = '"
                + addrId + "'");
            while(emailsQuery.next())
                addr.insertEmail(emailsQuery.value(0).toString(), emailsQuery.value(1).toInt());
        }

        // phones
        {
            QSqlQuery phonesQuery(
                "select number, type from kaddressbook_phones "
                "where addressId = '"
                + addrId + "'");
            while(phonesQuery.next())
                addr.insertPhoneNumber(PhoneNumber(phonesQuery.value(0).toString(), phonesQuery.value(1).toInt()));
        }

        // addresses
        {
            QSqlQuery addressesQuery(
                "select postOfficeBox, extended, street, "
                "locality, region, postalCode, country, label, type "
                "from kaddressbook_addresses where addressId = '"
                + addrId + "'");
            while(addressesQuery.next())
            {
                Address a;
                a.setPostOfficeBox(addressesQuery.value(0).toString());
                a.setExtended(addressesQuery.value(1).toString());
                a.setStreet(addressesQuery.value(2).toString());
                a.setLocality(addressesQuery.value(3).toString());
                a.setRegion(addressesQuery.value(4).toString());
                a.setPostalCode(addressesQuery.value(5).toString());
                a.setCountry(addressesQuery.value(6).toString());
                a.setLabel(addressesQuery.value(7).toString());
                a.setType(addressesQuery.value(8).toInt());

                addr.insertAddress(a);
            }
        }

        // categories
        {
            QSqlQuery categoriesQuery(
                "select category from kaddressbook_categories "
                "where addressId = '"
                + addrId + "'");
            while(categoriesQuery.next())
                addr.insertCategory(categoriesQuery.value(0).toString());
        }

        // customs
        {
            QSqlQuery customsQuery(
                "select app, name, value from kaddressbook_customs "
                "where addressId = '"
                + addrId + "'");
            while(customsQuery.next())
                addr.insertCustom(customsQuery.value(0).toString(), customsQuery.value(1).toString(), customsQuery.value(2).toString());
        }

        addressBook()->insertAddressee(addr);
    }

    return true;
}
示例#4
0
Addressee::List VCardTool::parseVCards(const QString &vcard)
{
    static const QChar semicolonSep(';');
    static const QChar commaSep(',');
    QString identifier;

    Addressee::List addrList;
    const VCard::List vCardList = VCardParser::parseVCards(vcard);

    VCard::List::ConstIterator cardIt;
    VCard::List::ConstIterator listEnd(vCardList.end());
    for(cardIt = vCardList.begin(); cardIt != listEnd; ++cardIt)
    {
        Addressee addr;

        const QStringList idents = (*cardIt).identifiers();
        QStringList::ConstIterator identIt;
        QStringList::ConstIterator identEnd(idents.end());
        for(identIt = idents.begin(); identIt != identEnd; ++identIt)
        {
            const VCardLine::List lines = (*cardIt).lines((*identIt));
            VCardLine::List::ConstIterator lineIt;

            // iterate over the lines
            for(lineIt = lines.begin(); lineIt != lines.end(); ++lineIt)
            {
                identifier = (*lineIt).identifier().lower();
                // ADR
                if(identifier == "adr")
                {
                    Address address;
                    const QStringList addrParts = splitString(semicolonSep, (*lineIt).value().asString());
                    if(addrParts.count() > 0)
                        address.setPostOfficeBox(addrParts[0]);
                    if(addrParts.count() > 1)
                        address.setExtended(addrParts[1]);
                    if(addrParts.count() > 2)
                        address.setStreet(addrParts[2]);
                    if(addrParts.count() > 3)
                        address.setLocality(addrParts[3]);
                    if(addrParts.count() > 4)
                        address.setRegion(addrParts[4]);
                    if(addrParts.count() > 5)
                        address.setPostalCode(addrParts[5]);
                    if(addrParts.count() > 6)
                        address.setCountry(addrParts[6]);

                    int type = 0;

                    const QStringList types = (*lineIt).parameters("type");
                    for(QStringList::ConstIterator it = types.begin(); it != types.end(); ++it)
                        type += mAddressTypeMap[(*it).lower()];

                    address.setType(type);
                    addr.insertAddress(address);
                }

                // AGENT
                else if(identifier == "agent")
                    addr.setAgent(parseAgent(*lineIt));

                // BDAY
                else if(identifier == "bday")
                    addr.setBirthday(parseDateTime((*lineIt).value().asString()));

                // CATEGORIES
                else if(identifier == "categories")
                {
                    const QStringList categories = splitString(commaSep, (*lineIt).value().asString());
                    addr.setCategories(categories);
                }

                // CLASS
                else if(identifier == "class")
                    addr.setSecrecy(parseSecrecy(*lineIt));

                // EMAIL
                else if(identifier == "email")
                {
                    const QStringList types = (*lineIt).parameters("type");
                    addr.insertEmail((*lineIt).value().asString(), types.findIndex("PREF") != -1);
                }

                // FN
                else if(identifier == "fn")
                    addr.setFormattedName((*lineIt).value().asString());

                // GEO
                else if(identifier == "geo")
                {
                    Geo geo;

                    const QStringList geoParts = QStringList::split(';', (*lineIt).value().asString(), true);
                    geo.setLatitude(geoParts[0].toFloat());
                    geo.setLongitude(geoParts[1].toFloat());

                    addr.setGeo(geo);
                }

                // KEY
                else if(identifier == "key")
                    addr.insertKey(parseKey(*lineIt));

                // LABEL
                else if(identifier == "label")
                {
                    int type = 0;

                    const QStringList types = (*lineIt).parameters("type");
                    for(QStringList::ConstIterator it = types.begin(); it != types.end(); ++it)
                        type += mAddressTypeMap[(*it).lower()];

                    bool available = false;
                    KABC::Address::List addressList = addr.addresses();
                    KABC::Address::List::Iterator it;
                    for(it = addressList.begin(); it != addressList.end(); ++it)
                    {
                        if((*it).type() == type)
                        {
                            (*it).setLabel((*lineIt).value().asString());
                            addr.insertAddress(*it);
                            available = true;
                            break;
                        }
                    }

                    if(!available)
                    { // a standalone LABEL tag
                        KABC::Address address(type);
                        address.setLabel((*lineIt).value().asString());
                        addr.insertAddress(address);
                    }
                }

                // LOGO
                else if(identifier == "logo")
                    addr.setLogo(parsePicture(*lineIt));

                // MAILER
                else if(identifier == "mailer")
                    addr.setMailer((*lineIt).value().asString());

                // N
                else if(identifier == "n")
                {
                    const QStringList nameParts = splitString(semicolonSep, (*lineIt).value().asString());
                    if(nameParts.count() > 0)
                        addr.setFamilyName(nameParts[0]);
                    if(nameParts.count() > 1)
                        addr.setGivenName(nameParts[1]);
                    if(nameParts.count() > 2)
                        addr.setAdditionalName(nameParts[2]);
                    if(nameParts.count() > 3)
                        addr.setPrefix(nameParts[3]);
                    if(nameParts.count() > 4)
                        addr.setSuffix(nameParts[4]);
                }

                // NAME
                else if(identifier == "name")
                    addr.setName((*lineIt).value().asString());

                // NICKNAME
                else if(identifier == "nickname")
                    addr.setNickName((*lineIt).value().asString());

                // NOTE
                else if(identifier == "note")
                    addr.setNote((*lineIt).value().asString());

                // ORGANIZATION
                else if(identifier == "org")
                {
                    const QStringList orgParts = splitString(semicolonSep, (*lineIt).value().asString());
                    if(orgParts.count() > 0)
                        addr.setOrganization(orgParts[0]);
                    if(orgParts.count() > 1)
                        addr.setDepartment(orgParts[1]);
                }

                // PHOTO
                else if(identifier == "photo")
                    addr.setPhoto(parsePicture(*lineIt));

                // PROID
                else if(identifier == "prodid")
                    addr.setProductId((*lineIt).value().asString());

                // REV
                else if(identifier == "rev")
                    addr.setRevision(parseDateTime((*lineIt).value().asString()));

                // ROLE
                else if(identifier == "role")
                    addr.setRole((*lineIt).value().asString());

                // SORT-STRING
                else if(identifier == "sort-string")
                    addr.setSortString((*lineIt).value().asString());

                // SOUND
                else if(identifier == "sound")
                    addr.setSound(parseSound(*lineIt));

                // TEL
                else if(identifier == "tel")
                {
                    PhoneNumber phone;
                    phone.setNumber((*lineIt).value().asString());

                    int type = 0;

                    const QStringList types = (*lineIt).parameters("type");
                    for(QStringList::ConstIterator it = types.begin(); it != types.end(); ++it)
                        type += mPhoneTypeMap[(*it).upper()];

                    phone.setType(type);

                    addr.insertPhoneNumber(phone);
                }

                // TITLE
                else if(identifier == "title")
                    addr.setTitle((*lineIt).value().asString());

                // TZ
                else if(identifier == "tz")
                {
                    TimeZone tz;
                    const QString date = (*lineIt).value().asString();

                    int hours = date.mid(1, 2).toInt();
                    int minutes = date.mid(4, 2).toInt();
                    int offset = (hours * 60) + minutes;
                    offset = offset * (date[0] == '+' ? 1 : -1);

                    tz.setOffset(offset);
                    addr.setTimeZone(tz);
                }

                // UID
                else if(identifier == "uid")
                    addr.setUid((*lineIt).value().asString());

                // URL
                else if(identifier == "url")
                    addr.setUrl(KURL((*lineIt).value().asString()));

                // 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).value().asString());
                }
            }
        }

        addrList.append(addr);
    }

    return addrList;
}
示例#5
0
void ResourceSlox::parseContactAttribute( const QDomElement &e, Addressee &a )
{
  QString text = decodeText( e.text() );
  if ( text.isEmpty() ) return;
  QString tag = e.tagName();
  int pnType = 0;

  if ( tag == fieldName( Birthday ) ) {
    QDateTime dt = WebdavHandler::sloxToQDateTime( text );
    a.setBirthday( dt.date() );
  } else if ( tag == fieldName( Role ) ) {
    a.setRole( text );
  } else if ( tag == "salutation" ) { // what's this in OX?
    a.setPrefix( text );
  } else if ( tag == fieldName( Title ) ) {
    a.setTitle( text );
  } else if ( tag == fieldName( Organization ) ) {
    a.setOrganization( text );
  } else if ( tag == fieldName( Department ) ) {
    a.insertCustom( "KADDRESSBOOK", "X-Department", text );
  } else if ( tag == fieldName( FamilyName ) ) {
    a.setFamilyName( text );
  } else if ( tag == fieldName( GivenName) ) {
    a.setGivenName( text );
  } else if ( tag == fieldName( SecondName ) ) {
    a.setAdditionalName( text );
  } else if ( tag == fieldName( DisplayName ) ) {
    a.setFormattedName( text );
  } else if ( tag == fieldName( Suffix ) ) {
    a.setSuffix( text );
  } else if ( tag == fieldName( PrimaryEmail ) ) {
    a.insertEmail( text, true );
  } else if ( (pnType = phoneNumberType( tag )) ) {
    a.insertPhoneNumber( PhoneNumber( text, pnType ) );
  } else if ( tag == fieldName( Comment ) ) {
    a.setNote( text );
  } else if ( tag == fieldName( SecondaryEmail1 ) || tag == fieldName( SecondaryEmail2 ) ||
              tag == fieldName( SecondaryEmail3 ) ) {
    a.insertEmail( text );
  } else if ( tag == fieldName( Url ) ) {
    a.setUrl( text );
  } else if ( tag == fieldName( Image ) ) {
    QByteArray decodedPicture;
    KCodecs::base64Decode( text.utf8(), decodedPicture );
    a.setPhoto( Picture( QImage( decodedPicture ) ) );
  } else if ( tag == fieldName( NickName ) ) {
    a.setNickName( text );
  } else if ( tag == fieldName( InstantMsg ) ) {
    a.insertCustom( "KADDRESSBOOK", "X-IMAddress", text );
  } else if ( tag == fieldName( Office ) ) {
    a.insertCustom( "KADDRESSBOOK", "X-Office", text );
  } else if ( tag == fieldName( Profession ) ) {
    a.insertCustom( "KADDRESSBOOK", "X-Profession", text );
  } else if ( tag == fieldName( ManagersName ) ) {
    a.insertCustom( "KADDRESSBOOK", "X-ManagersName", text );
  } else if ( tag == fieldName( AssistantsName ) ) {
    a.insertCustom( "KADDRESSBOOK", "X-AssistantsName", text );
  } else if ( tag == fieldName( SpousesName ) ) {
    a.insertCustom( "KADDRESSBOOK", "X-SpousesName", text );
  } else if ( tag == fieldName( Anniversary ) ) {
    QDateTime dt = WebdavHandler::sloxToQDateTime( text );
    a.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt.toString( Qt::ISODate ) );
  } else if ( tag == fieldName( Categories ) ) {
    a.setCategories( QStringList::split( QRegExp(",\\s*"), text ) );
  } else if ( type() == "ox" ) { // FIXME: Address reading is missing for SLOX
    // read addresses
    Address addr;
    if ( tag.startsWith( fieldName( BusinessPrefix ) ) ) {
      addr = a.address( KABC::Address::Work );
    } else if ( tag.startsWith( fieldName( OtherPrefix ) ) ) {
      addr = a.address( 0 );
    } else {
      addr = a.address( KABC::Address::Home );
    }
    if ( tag.endsWith( fieldName( Street ) ) ) {
      addr.setStreet( text );
    } else if ( tag.endsWith( fieldName( PostalCode ) ) ) {
      addr.setPostalCode( text );
    } else if ( tag.endsWith( fieldName( City ) ) ) {
      addr.setLocality( text );
    } else if ( tag.endsWith( fieldName( State ) ) ) {
      addr.setRegion( text );
    } else if ( tag.endsWith( fieldName( Country ) ) ) {
      addr.setCountry( text );
    }
    a.insertAddress( addr );
  }
}
示例#6
0
bool LDIFConverter::LDIFToAddressee( const QString &str, AddresseeList &addrList, QDateTime dt )
{
  if (str.isEmpty())
     return true;

  bool endldif = false, end = false;
  LDIF ldif;
  LDIF::ParseVal ret;
  const char *latinstr = str.latin1();
  int latinstrlen = qstrlen( latinstr );
  QByteArray data;
  Addressee a;
  Address homeAddr, workAddr;

  data.setRawData( latinstr, latinstrlen );
  ldif.setLDIF( data );
  if (!dt.isValid())
    dt = QDateTime::currentDateTime();
  a.setRevision(dt);
  homeAddr = Address( Address::Home );
  workAddr = Address( Address::Work );

  do {
    ret = ldif.nextItem();
    switch ( ret ) {
      case LDIF::Item: {
        QString fieldname = ldif.attr().lower();
        QString value = QString::fromUtf8( ldif.val(), ldif.val().size() );
        evaluatePair( a, homeAddr, workAddr, fieldname, value );
        break;
      }
      case LDIF::EndEntry:
      // if the new address is not empty, append it
        if ( !a.formattedName().isEmpty() || !a.name().isEmpty() ||
          !a.familyName().isEmpty() ) {
          if ( !homeAddr.isEmpty() )
            a.insertAddress( homeAddr );
          if ( !workAddr.isEmpty() )
            a.insertAddress( workAddr );
          addrList.append( a );
        }
        a = Addressee();
        a.setRevision(dt);
        homeAddr = Address( Address::Home );
        workAddr = Address( Address::Work );
        break;
      case LDIF::MoreData: {
        if ( endldif )
          end = true;
        else {
          ldif.endLDIF();
          endldif = true;
          break;
        }
      }
      default:
        break;
    }
  } while ( !end );

  data.resetRawData( latinstr, latinstrlen );

  return true;
}
示例#7
0
void readKAddressBookEntries(const QString &dataString, Addressee &a)
{
    // Strip "KMail:1.0" prefix and "[EOS]" suffix.
    QString str = dataString.mid(11, dataString.length() - 24);

    QStringList entries = QStringList::split("\n[EOR]\n ", str);

    Address homeAddress(Address::Home);
    Address businessAddress(Address::Work);
    Address otherAddress;

    QStringList::ConstIterator it;
    for(it = entries.begin(); it != entries.end(); ++it)
    {
        int pos = (*it).find("\n");
        QString fieldName = (*it).left(pos);
        QString fieldValue = (*it).mid(pos + 2);

        if(fieldName == "X-HomeFax")
        {
            a.insertPhoneNumber(PhoneNumber(fieldValue, PhoneNumber::Home | PhoneNumber::Fax));
        }
        else if(fieldName == "X-OtherPhone")
        {
            a.insertPhoneNumber(PhoneNumber(fieldValue, 0));
        }
        else if(fieldName == "X-PrimaryPhone")
        {
            a.insertPhoneNumber(PhoneNumber(fieldValue, PhoneNumber::Pref));
        }
        else if(fieldName == "X-BusinessFax")
        {
            a.insertPhoneNumber(PhoneNumber(fieldValue, PhoneNumber::Work | PhoneNumber::Fax));
        }
        else if(fieldName == "X-CarPhone")
        {
            a.insertPhoneNumber(PhoneNumber(fieldValue, PhoneNumber::Car));
        }
        else if(fieldName == "X-MobilePhone")
        {
            a.insertPhoneNumber(PhoneNumber(fieldValue, PhoneNumber::Cell));
        }
        else if(fieldName == "X-ISDN")
        {
            a.insertPhoneNumber(PhoneNumber(fieldValue, PhoneNumber::Isdn));
        }
        else if(fieldName == "X-OtherFax")
        {
            a.insertPhoneNumber(PhoneNumber(fieldValue, PhoneNumber::Fax));
        }
        else if(fieldName == "X-Pager")
        {
            a.insertPhoneNumber(PhoneNumber(fieldValue, PhoneNumber::Pager));
        }
        else if(fieldName == "X-BusinessPhone")
        {
            a.insertPhoneNumber(PhoneNumber(fieldValue, PhoneNumber::Work));
        }
        else if(fieldName == "X-HomePhone")
        {
            a.insertPhoneNumber(PhoneNumber(fieldValue, PhoneNumber::Home));
        }
        else if(fieldName == "X-HomeAddress")
        {
            homeAddress.setLabel(fieldValue);
        }
        else if(fieldName == "X-HomeAddressStreet")
        {
            homeAddress.setStreet(fieldValue);
        }
        else if(fieldName == "X-HomeAddressCity")
        {
            homeAddress.setLocality(fieldValue);
        }
        else if(fieldName == "X-HomeAddressPostalCode")
        {
            homeAddress.setPostalCode(fieldValue);
        }
        else if(fieldName == "X-HomeAddressState")
        {
            homeAddress.setRegion(fieldValue);
        }
        else if(fieldName == "X-HomeAddressCountry")
        {
            homeAddress.setCountry(fieldValue);
        }
        else if(fieldName == "X-BusinessAddress")
        {
            businessAddress.setLabel(fieldValue);
        }
        else if(fieldName == "X-BusinessAddressStreet")
        {
            businessAddress.setStreet(fieldValue);
        }
        else if(fieldName == "X-BusinessAddressCity")
        {
            businessAddress.setLocality(fieldValue);
        }
        else if(fieldName == "X-BusinessAddressPostalCode")
        {
            businessAddress.setPostalCode(fieldValue);
        }
        else if(fieldName == "X-BusinessAddressState")
        {
            businessAddress.setRegion(fieldValue);
        }
        else if(fieldName == "X-BusinessAddressCountry")
        {
            businessAddress.setCountry(fieldValue);
        }
        else if(fieldName == "X-OtherAddress")
        {
            otherAddress.setLabel(fieldValue);
        }
        else if(fieldName == "X-OtherAddressStreet")
        {
            otherAddress.setStreet(fieldValue);
        }
        else if(fieldName == "X-OtherAddressCity")
        {
            otherAddress.setLocality(fieldValue);
        }
        else if(fieldName == "X-OtherAddressPostalCode")
        {
            otherAddress.setPostalCode(fieldValue);
        }
        else if(fieldName == "X-OtherAddressState")
        {
            otherAddress.setRegion(fieldValue);
        }
        else if(fieldName == "X-OtherAddressCountry")
        {
            otherAddress.setCountry(fieldValue);
        }
        else if(fieldName == "NICKNAME")
        {
            a.setNickName(fieldValue);
        }
        else if(fieldName == "ORG")
        {
            a.setOrganization(fieldValue);
        }
        else if(fieldName == "ROLE")
        {
            a.setRole(fieldValue);
        }
        else if(fieldName == "BDAY")
        {
            a.setBirthday(KGlobal::locale()->readDate(fieldValue));
        }
        else if(fieldName == "WEBPAGE")
        {
            a.setUrl(KURL(fieldValue));
        }
        else if(fieldName == "N")
        {
        }
        else if(fieldName == "X-FirstName")
        {
        }
        else if(fieldName == "X-MiddleName")
        {
        }
        else if(fieldName == "X-LastName")
        {
        }
        else if(fieldName == "X-Title")
        {
        }
        else if(fieldName == "X-Suffix")
        {
        }
        else if(fieldName == "X-FileAs")
        {
        }
        else if(fieldName == "EMAIL")
        {
            a.insertEmail(fieldValue, true);
        }
        else if(fieldName == "X-E-mail2")
        {
            a.insertEmail(fieldValue);
        }
        else if(fieldName == "X-E-mail3")
        {
            a.insertEmail(fieldValue);
        }
        else if(fieldName == "X-Notes")
        {
        }
        else
        {
            a.insertCustom("KADDRESSBOOK", fieldName, fieldValue);
        }
    }

    if(!homeAddress.isEmpty())
        a.insertAddress(homeAddress);
    if(!businessAddress.isEmpty())
        a.insertAddress(businessAddress);
    if(!otherAddress.isEmpty())
        a.insertAddress(otherAddress);
}
示例#8
0
bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCARD::VCard &v )
{
  QPtrList<ContentLine> contentLines = v.contentLineList();
  ContentLine *cl;

  for( cl = contentLines.first(); cl; cl = contentLines.next() ) {
    QCString n = cl->name();
    if ( n.left( 2 ) == "X-" ) {
      n = n.mid( 2 );
      int posDash = n.find( "-" );
      addressee.insertCustom( QString::fromUtf8( n.left( posDash ) ),
                        QString::fromUtf8( n.mid( posDash + 1 ) ),
                        QString::fromUtf8( cl->value()->asString() ) );
        continue;
    }

    EntityType type = cl->entityType();
    switch( type ) {

      case EntityUID:
        addressee.setUid( readTextValue( cl ) );
        break;

      case EntityEmail:
        addressee.insertEmail( readTextValue( cl ) );
        break;

      case EntityName:
        addressee.setName( readTextValue( cl ) );
        break;

      case EntityFullName:
        addressee.setFormattedName( readTextValue( cl ) );
        break;

      case EntityURL:
        addressee.setUrl( KURL( readTextValue( cl ) ) );
        break;

      case EntityNickname:
        addressee.setNickName( readTextValue( cl ) );
        break;

      case EntityLabel:
        // not yet supported by kabc
        break;

      case EntityMailer:
        addressee.setMailer( readTextValue( cl ) );
        break;

      case EntityTitle:
        addressee.setTitle( readTextValue( cl ) );
        break;

      case EntityRole:
        addressee.setRole( readTextValue( cl ) );
        break;

      case EntityOrganisation:
        addressee.setOrganization( readTextValue( cl ) );
        break;

      case EntityNote:
        addressee.setNote( readTextValue( cl ) );
        break;

      case EntityProductID:
        addressee.setProductId( readTextValue( cl ) );
        break;

      case EntitySortString:
        addressee.setSortString( readTextValue( cl ) );
        break;

      case EntityN:
        readNValue( cl, addressee );
        break;

      case EntityAddress:
        addressee.insertAddress( readAddressValue( cl ) );
        break;

      case EntityTelephone:
        addressee.insertPhoneNumber( readTelephoneValue( cl ) );
        break;

      case EntityCategories:
        addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) );
        break;

      case EntityBirthday:
        addressee.setBirthday( readDateValue( cl ) );
        break;

      case EntityRevision:
        addressee.setRevision( readDateTimeValue( cl ) );
        break;

      case EntityGeo:
        addressee.setGeo( readGeoValue( cl ) );
        break;

      case EntityTimeZone:
        addressee.setTimeZone( readUTCValue( cl ) );
        break;

      case EntityVersion:
        break;

      case EntityClass:
        addressee.setSecrecy( readClassValue( cl ) );
        break;

      case EntityKey:
        addressee.insertKey( readKeyValue( cl ) );
        break;

      case EntityPhoto:
        addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) );
        break;

      case EntityLogo:
        addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) );
        break;

      case EntityAgent:
        addressee.setAgent( readAgentValue( cl ) );
        break;

      case EntitySound:
        addressee.setSound( readSoundValue( cl, addressee ) );
        break;

      default:
        kdDebug(5700) << "VCardFormat::load(): Unsupported entity: "
                    << int( type ) << ": " << cl->asString() << endl;
        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 );
    }
  }

  return true;
}