Esempio n. 1
0
Agent VCardTool::parseAgent(const VCardLine &line)
{
    Agent agent;

    const QStringList params = line.parameterList();
    if(params.findIndex("value") != -1)
    {
        if(line.parameter("value").lower() == "uri")
            agent.setUrl(line.value().asString());
    }
    else
    {
        QString str = line.value().asString();
        str.replace("\\n", "\r\n");
        str.replace("\\N", "\r\n");
        str.replace("\\;", ";");
        str.replace("\\:", ":");
        str.replace("\\,", ",");

        const Addressee::List list = parseVCards(str);
        if(list.count() > 0)
        {
            Addressee *addr = new Addressee;
            *addr = list[0];
            agent.setAddressee(addr);
        }
    }

    return agent;
}
Esempio n. 2
0
Key VCardTool::parseKey(const VCardLine &line)
{
    Key key;

    const QStringList params = line.parameterList();
    if(params.findIndex("encoding") != -1)
        key.setBinaryData(line.value().asByteArray());
    else
        key.setTextData(line.value().asString());

    if(params.findIndex("type") != -1)
    {
        if(line.parameter("type").lower() == "x509")
            key.setType(Key::X509);
        else if(line.parameter("type").lower() == "pgp")
            key.setType(Key::PGP);
        else
        {
            key.setType(Key::Custom);
            key.setCustomTypeString(line.parameter("type"));
        }
    }

    return key;
}
Esempio n. 3
0
Secrecy VCardTool::parseSecrecy(const VCardLine &line)
{
    Secrecy secrecy;

    if(line.value().asString().lower() == "public")
        secrecy.setType(Secrecy::Public);
    if(line.value().asString().lower() == "private")
        secrecy.setType(Secrecy::Private);
    if(line.value().asString().lower() == "confidential")
        secrecy.setType(Secrecy::Confidential);

    return secrecy;
}
Esempio n. 4
0
Sound VCardTool::parseSound(const VCardLine &line)
{
    Sound snd;

    const QStringList params = line.parameterList();
    if(params.findIndex("encoding") != -1)
        snd.setData(line.value().asByteArray());
    else if(params.findIndex("value") != -1)
    {
        if(line.parameter("value").lower() == "uri")
            snd.setUrl(line.value().asString());
    }

    /* TODO: support sound types
      if ( params.contains( "type" ) )
        snd.setType( line.parameter( "type" ) );
    */

    return snd;
}
Esempio n. 5
0
VCard::Version VCard::version() const
{
  LineMap::ConstIterator versionEntry = mLineMap.find( "VERSION" );
  if ( versionEntry == mLineMap.end() )
    return v3_0;

  VCardLine line = ( *versionEntry )[ 0 ];
  if ( line.value() == "2.1" )
    return v2_1;
  else
    return v3_0;
}
Esempio n. 6
0
Picture VCardTool::parsePicture(const VCardLine &line)
{
    Picture pic;

    const QStringList params = line.parameterList();
    if(params.findIndex("encoding") != -1)
    {
        QImage img;
        img.loadFromData(line.value().asByteArray());
        pic.setData(img);
    }
    else if(params.findIndex("value") != -1)
    {
        if(line.parameter("value").lower() == "uri")
            pic.setUrl(line.value().asString());
    }

    if(params.findIndex("type") != -1)
        pic.setType(line.parameter("type"));

    return pic;
}