void KeyGenerator::slotStartKeyGeneration() {
  QString params = "<GnupgKeyParms format=\"internal\">\n";
  for ( int i = 0 ; i < numKeyParams ; ++i )
    if ( mLineEdits[i] && !mLineEdits[i]->text().trimmed().isEmpty() )
      params += keyParams[i] + ( ": " + mLineEdits[i]->text().trimmed() ) + '\n';
  params += "</GnupgKeyParms>\n";

  const Kleo::CryptoBackend::Protocol * proto = 0;
  if(protocol)
  {
     proto = !strcmp( protocol, "openpgp" ) ? Kleo::CryptoBackendFactory::instance()->openpgp() : Kleo::CryptoBackendFactory::instance()->smime() ;
  }
  if ( !proto )
    proto = Kleo::CryptoBackendFactory::instance()->smime();
  assert( proto );

  kDebug(5150) <<"Using protocol" << proto->name();

  Kleo::KeyGenerationJob * job = proto->keyGenerationJob();
  assert( job );

  connect( job, SIGNAL(result(GpgME::KeyGenerationResult,QByteArray)),
	   SLOT(slotResult(GpgME::KeyGenerationResult,QByteArray)) );

  const GpgME::Error err = job->start( params );
  if ( err )
    showError( err );
#ifndef LIBKLEO_NO_PROGRESSDIALOG
  else
    (void)new Kleo::ProgressDialog( job, "Generating key", this );
#endif
}
Exemplo n.º 2
0
void KeyGenerator::slotStartKeyGeneration()
{
    QString params = "<GnupgKeyParms format=\"internal\">\n";
    for(int i = 0 ; i < numKeyParams ; ++i)
        if(mLineEdits[i] && !mLineEdits[i]->text().stripWhiteSpace().isEmpty())
            params += keyParams[i] + (": " + mLineEdits[i]->text().stripWhiteSpace()) + '\n';
    params += "</GnupgKeyParms>\n";

    const Kleo::CryptoBackend::Protocol *proto = protocol == "openpgp" ? Kleo::CryptoBackendFactory::instance()->openpgp() :
            Kleo::CryptoBackendFactory::instance()->smime() ;
    if(!proto)
        proto = Kleo::CryptoBackendFactory::instance()->smime();
    assert(proto);

    kdDebug() << "Using protocol " << proto->name() << endl;

    Kleo::KeyGenerationJob *job = proto->keyGenerationJob();
    assert(job);

    connect(job, SIGNAL(result(const GpgME::KeyGenerationResult &, const QByteArray &)),
            SLOT(slotResult(const GpgME::KeyGenerationResult &, const QByteArray &)));

    const GpgME::Error err = job->start(params);
    if(err)
        showError(err);
    else
        (void)new Kleo::ProgressDialog(job, "Generating key", this);
}