Esempio n. 1
0
Kleo::KeyListJob *CryptPlugWrapper::keyListJob(bool remote, bool includeSigs, bool validate) const
{
    if(!_cp)
        return 0;

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

    unsigned int mode = context->keyListMode();
    if(remote)
    {
        mode |= GpgME::Context::Extern;
        mode &= ~GpgME::Context::Local;
    }
    else
    {
        mode |= GpgME::Context::Local;
        mode &= ~GpgME::Context::Extern;
    }
    if(includeSigs) mode |= GpgME::Context::Signatures;
    if(validate) mode |= GpgME::Context::Validate;
    context->setKeyListMode(mode);
    return new Kleo::QGpgMEKeyListJob(context);
}
Esempio n. 2
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 );
}
Esempio n. 3
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);
}
Esempio n. 4
0
Kleo::DecryptVerifyJob *CryptPlugWrapper::decryptVerifyJob(bool textMode) const
{
    if(!_cp)
        return 0;

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

    context->setTextMode(textMode);

    return new Kleo::QGpgMEDecryptVerifyJob(context);
}
Esempio n. 5
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);
}
Esempio n. 6
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);
}