コード例 #1
0
void VCardXXPort::addKey( KABC::Addressee &addr, KABC::Key::Types type )
{
  QString fingerprint = addr.custom( "KADDRESSBOOK",
                                     (type == KABC::Key::PGP ? "OPENPGPFP" : "SMIMEFP") );
  if ( fingerprint.isEmpty() )
    return;

  GpgME::Context * context = GpgME::Context::createForProtocol( GpgME::Context::OpenPGP );
  if ( !context ) {
    kdError() << "No context available" << endl;
    return;
  }

  context->setArmor( false );
  context->setTextMode( false );

  QGpgME::QByteArrayDataProvider dataProvider;
  GpgME::Data dataObj( &dataProvider );
  GpgME::Error error = context->exportPublicKeys( fingerprint.latin1(), dataObj );
  delete context;

  if ( error ) {
    kdError() << error.asString() << endl;
    return;
  }

  KABC::Key key;
  key.setType( type );
  key.setBinaryData( dataProvider.data() );

  addr.insertKey( key );
}
コード例 #2
0
Kleo::ExportJob *CryptPlugWrapper::publicKeyExportJob(bool armor) const
{
    if(!_cp)
        return 0;

    GpgME::Context *context = GpgME::Context::createForProtocol(_cp->mProtocol);
    if(!context)
        return 0;

    context->setArmor(armor);
    return new Kleo::QGpgMEExportJob(context);
}
コード例 #3
0
Kleo::EncryptJob *CryptPlugWrapper::encryptJob(bool armor, bool textmode) const
{
    if(!_cp)
        return 0;

    GpgME::Context *context = GpgME::Context::createForProtocol(_cp->mProtocol);
    if(!context)
        return 0;

    context->setArmor(armor);
    context->setTextMode(textmode);
    return new Kleo::QGpgMEEncryptJob(context);
}
コード例 #4
0
Kleo::DownloadJob *CryptPlugWrapper::downloadJob(bool armor) const
{
    if(!_cp)
        return 0;

    GpgME::Context *context = GpgME::Context::createForProtocol(_cp->mProtocol);
    if(!context)
        return 0;

    context->setArmor(armor);
    // this is the hackish interface for downloading from keyserers currently:
    context->setKeyListMode(GpgME::Context::Extern);

    return new Kleo::QGpgMEDownloadJob(context);
}