示例#1
0
void VCardFormatImpl::addKeyValue( VCARD::VCard *vcard, const Key &key )
{
  ContentLine cl;
  cl.setName( EntityTypeToParamName( EntityKey ) );

  ParamList params;
  if ( key.isBinary() ) {
    cl.setValue( new TextValue( KCodecs::base64Encode( key.binaryData() ) ) );
    params.append( new Param( "ENCODING", "b" ) );
  } else {
    cl.setValue( new TextValue( key.textData().utf8() ) );
  }

  switch ( key.type() ) {
    case Key::X509:
      params.append( new Param( "TYPE", "X509" ) );
      break;
    case Key::PGP:
      params.append( new Param( "TYPE", "PGP" ) );
      break;
    case Key::Custom:
      params.append( new Param( "TYPE", key.customTypeString().utf8() ) );
      break;
  }

  cl.setParamList( params );
  vcard->add( cl );
}
示例#2
0
VCardLine VCardTool::createKey(const Key &key)
{
    VCardLine line("KEY");

    if(key.isBinary())
    {
        if(!key.binaryData().isEmpty())
        {
            line.setValue(key.binaryData());
            line.addParameter("encoding", "b");
        }
    }
    else if(!key.textData().isEmpty())
        line.setValue(key.textData());

    if(key.type() == Key::X509)
        line.addParameter("type", "X509");
    else if(key.type() == Key::PGP)
        line.addParameter("type", "PGP");
    else if(key.type() == Key::Custom)
        line.addParameter("type", key.customTypeString());

    return line;
}