예제 #1
0
VCardLine VCardTool::createAgent(VCard::Version version, const Agent &agent)
{
    VCardLine line("AGENT");

    if(agent.isIntern())
    {
        if(agent.addressee() != 0)
        {
            Addressee::List list;
            list.append(*agent.addressee());

            QString str = createVCards(list, version);
            str.replace("\r\n", "\\n");
            str.replace(";", "\\;");
            str.replace(":", "\\:");
            str.replace(",", "\\,");
            line.setValue(str);
        }
    }
    else if(!agent.url().isEmpty())
    {
        line.setValue(agent.url());
        line.addParameter("value", "URI");
    }

    return line;
}
예제 #2
0
void VCardFormatImpl::addAgentValue( VCARD::VCard *vcard, const Agent &agent )
{
  if ( agent.isIntern() && !agent.addressee() )
    return;

  if ( !agent.isIntern() && agent.url().isEmpty() )
    return;

  ContentLine cl;
  cl.setName( EntityTypeToParamName( EntityAgent ) );

  ParamList params;
  if ( agent.isIntern() ) {
    QString vstr;
    Addressee *addr = agent.addressee();
    if ( addr ) {
      writeToString( (*addr), vstr );
      vstr.replace( ":", "\\:" );
      vstr.replace( ",", "\\," );
      vstr.replace( ";", "\\;" );
      vstr.replace( "\r\n", "\\n" );
      cl.setValue( new TextValue( vstr.utf8() ) );
    } else
      return;
  } else {
    cl.setValue( new TextValue( agent.url().utf8() ) );
    params.append( new Param( "VALUE", "uri" ) );
  }

  cl.setParamList( params );
  vcard->add( cl );
}