40 #include <gpgme++/context.h> 
   41 #include <gpgme++/data.h> 
   43 #include <QStringList> 
   45 #include <gpg-error.h> 
   65   assert( mKeyData.isEmpty() );
 
   67   if ( patterns.size() != 1 || patterns.front().isEmpty() ) {
 
   69     return mError = GpgME::Error::fromCode( GPG_ERR_INV_VALUE, GPG_ERR_SOURCE_GPGSM );
 
   74   mProcess->setObjectName( QLatin1String(
"gpgsm --export-secret-key-p12") );
 
   77   *mProcess << QLatin1String(
"gpgsm") << QLatin1String(
"--export-secret-key-p12");
 
   79     *mProcess << QLatin1String(
"--armor");
 
   80   if ( !mCharset.isEmpty() )
 
   81     *mProcess << QLatin1String(
"--p12-charset") << mCharset;
 
   82   *mProcess << QLatin1String(patterns.front().toUtf8());
 
   84   mProcess->setUseStatusFD( 
true );
 
   86   connect( mProcess, SIGNAL(finished(
int,QProcess::ExitStatus)),
 
   87            SLOT(slotProcessExited(
int,QProcess::ExitStatus)) );
 
   88   connect( mProcess, SIGNAL(readyReadStandardOutput()),
 
   90   connect( mProcess, SIGNAL(readyReadStandardError()),
 
   96   mProcess->setOutputChannelMode( KProcess::SeparateChannels );
 
   98   if ( !mProcess->waitForStarted() ) {
 
   99     mError = GpgME::Error::fromCode( GPG_ERR_ENOENT, GPG_ERR_SOURCE_GPGSM ); 
 
  103     return GpgME::Error();
 
  106 void Kleo::QGpgMESecretKeyExportJob::slotCancel() {
 
  110   mError = GpgME::Error::fromCode( GPG_ERR_CANCELED, GPG_ERR_SOURCE_GPGSM );
 
  113 void Kleo::QGpgMESecretKeyExportJob::slotStatus( GnuPGProcessBase * proc, 
const QString & type, 
const QStringList & args ) {
 
  114   if ( proc != mProcess )
 
  116   QStringList::const_iterator it = args.begin();
 
  119   if ( type == QLatin1String(
"ERROR") ) {
 
  122     if ( args.size() < 2 ) {
 
  123       kDebug( 5150 ) <<
"Kleo::QGpgMESecretKeyExportJob::slotStatus() not recognising ERROR with < 2 args!";
 
  126     const int source = (*++it).toInt( &ok );
 
  128       kDebug( 5150 ) <<
"Kleo::QGpgMESecretKeyExportJob::slotStatus() expected number for first ERROR arg, got something else";
 
  132     const int code = (*++it).toInt( &ok );
 
  134       kDebug( 5150 ) <<
"expected number for second ERROR arg, got something else";
 
  137     mError = GpgME::Error::fromCode( code, source );
 
  140   } 
else if ( type == QLatin1String(
"PROGRESS") ) {
 
  143     if ( args.size() < 4 ) {
 
  144       kDebug( 5150 ) <<
"not recognising PROGRESS with < 4 args!";
 
  149     const int typ = (*++it).toInt( &ok );
 
  151         kDebug( 5150 ) << 
"expected number for \"type\", got something else";
 
  155     const int cur = (*++it).toInt( &ok );
 
  157       kDebug( 5150 ) <<
"expected number for \"cur\", got something else";
 
  161     const int total = (*++it).toInt( &ok );
 
  163       kDebug( 5150 ) <<
"expected number for \"total\", got something else";
 
  171 void Kleo::QGpgMESecretKeyExportJob::slotStdout() {
 
  172   QString line = QString::fromLocal8Bit( mProcess->readLine() );
 
  173   if ( !line.isEmpty() )
 
  175   const unsigned int oldlen = mKeyData.size();
 
  176   mKeyData.resize( oldlen + line.length() );
 
  177   memcpy( mKeyData.data() + oldlen, line.toLatin1(), line.length() );
 
  180 void Kleo::QGpgMESecretKeyExportJob::slotStderr() {
 
  184 void Kleo::QGpgMESecretKeyExportJob::slotProcessExited(
int exitCode, QProcess::ExitStatus exitStatus) {
 
  187        ( exitStatus != QProcess::NormalExit || exitCode != 0 ) )
 
  188       mError = GpgME::Error::fromCode( GPG_ERR_GENERAL, GPG_ERR_SOURCE_GPGSM );
 
  189   emit result( mError, mKeyData );
 
  193 #include "qgpgmesecretkeyexportjob.moc" 
GpgME::Error start(const QStringList &patterns)
 
QString map(const char *token, int subtoken)
 
QGpgMESecretKeyExportJob(bool armour, const QString &charset)
 
An abstract base class for asynchronous exporters. 
 
~QGpgMESecretKeyExportJob()
 
a base class for GPG and GPGSM processes.