• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kleopatra

  • sources
  • kde-4.14
  • kdepim
  • kleopatra
  • crypto
signencryptfilestask.cpp
Go to the documentation of this file.
1 /* -*- mode: c++; c-basic-offset:4 -*-
2  crypto/signencryptfilestask.cpp
3 
4  This file is part of Kleopatra, the KDE keymanager
5  Copyright (c) 2007 Klarälvdalens Datakonsult AB
6 
7  Kleopatra is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  Kleopatra is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  In addition, as a special exception, the copyright holders give
22  permission to link the code of this program with any edition of
23  the Qt library by Trolltech AS, Norway (or with modified versions
24  of Qt that use the same license as Qt), and distribute linked
25  combinations including the two. You must obey the GNU General
26  Public License in all respects for all of the code used other than
27  Qt. If you modify this file, you may extend this exception to
28  your version of the file, but you are not obligated to do so. If
29  you do not wish to do so, delete this exception statement from
30  your version.
31 */
32 
33 #include <config-kleopatra.h>
34 
35 #include "signencryptfilestask.h"
36 
37 #include <utils/formatting.h>
38 #include <utils/input.h>
39 #include <utils/output.h>
40 #include <utils/path-helper.h>
41 #include <utils/kleo_assert.h>
42 #include <utils/auditlog.h>
43 
44 #include <kleo/stl_util.h>
45 #include <kleo/exception.h>
46 #include <kleo/cryptobackendfactory.h>
47 #include <kleo/cryptobackend.h>
48 #include <kleo/signjob.h>
49 #include <kleo/signencryptjob.h>
50 #include <kleo/encryptjob.h>
51 
52 #include <gpgme++/signingresult.h>
53 #include <gpgme++/encryptionresult.h>
54 #include <gpgme++/key.h>
55 
56 #include <KLocalizedString>
57 #include <KDebug>
58 
59 #include <QFile>
60 #include <QPointer>
61 #include <QTextDocument> // for Qt::escape
62 
63 #ifndef Q_MOC_RUN
64 #include <boost/bind.hpp>
65 #endif
66 
67 using namespace Kleo;
68 using namespace Kleo::Crypto;
69 using namespace boost;
70 using namespace GpgME;
71 
72 namespace {
73 
74  QString formatInputOutputLabel( const QString & input, const QString & output, bool inputDeleted, bool outputDeleted ) {
75  return i18nc( "Input file --> Output file (rarr is arrow", "%1 &rarr; %2",
76  inputDeleted ? QString::fromLatin1("<s>%1</s>").arg( Qt::escape( input ) ) : Qt::escape( input ),
77  outputDeleted ? QString::fromLatin1("<s>%1</s>").arg( Qt::escape( output ) ) : Qt::escape( output ) );
78  }
79 
80  class ErrorResult : public Task::Result {
81  public:
82  ErrorResult( bool sign, bool encrypt, const Error & err, const QString & errStr, const QString & input, const QString & output, const AuditLog & auditLog )
83  : Task::Result(), m_sign( sign ), m_encrypt( encrypt ), m_error( err ), m_errString( errStr ), m_inputLabel( input ), m_outputLabel( output ), m_auditLog( auditLog ) {}
84 
85  /* reimp */ QString overview() const;
86  /* reimp */ QString details() const;
87  /* reimp */ int errorCode() const { return m_error.encodedError(); }
88  /* reimp */ QString errorString() const { return m_errString; }
89  /* reimp */ VisualCode code() const { return NeutralError; }
90  /* reimp */ AuditLog auditLog() const { return m_auditLog; }
91  private:
92  const bool m_sign;
93  const bool m_encrypt;
94  const Error m_error;
95  const QString m_errString;
96  const QString m_inputLabel;
97  const QString m_outputLabel;
98  const AuditLog m_auditLog;
99  };
100 
101  class SignEncryptFilesResult : public Task::Result {
102  public:
103  SignEncryptFilesResult( const SigningResult & sr, const shared_ptr<Input> & input, const shared_ptr<Output> & output, bool inputRemoved, bool outputCreated, const AuditLog & auditLog )
104  : Task::Result(),
105  m_sresult( sr ),
106  m_inputLabel( input ? input->label() : QString() ),
107  m_inputErrorString( input ? input->errorString() : QString() ),
108  m_outputLabel( output ? output->label() : QString() ),
109  m_outputErrorString( output ? output->errorString() : QString() ),
110  m_inputRemoved( inputRemoved ),
111  m_outputCreated( outputCreated ),
112  m_auditLog( auditLog )
113  {
114  kDebug() << endl
115  << "inputError :" << m_inputErrorString << endl
116  << "outputError:" << m_outputErrorString;
117  assert( !m_sresult.isNull() );
118  }
119  SignEncryptFilesResult( const EncryptionResult & er, const shared_ptr<Input> & input, const shared_ptr<Output> & output, bool inputRemoved, bool outputCreated, const AuditLog & auditLog )
120  : Task::Result(),
121  m_eresult( er ),
122  m_inputLabel( input ? input->label() : QString() ),
123  m_inputErrorString( input ? input->errorString() : QString() ),
124  m_outputLabel( output ? output->label() : QString() ),
125  m_outputErrorString( output ? output->errorString() : QString() ),
126  m_inputRemoved( inputRemoved ),
127  m_outputCreated( outputCreated ),
128  m_auditLog( auditLog )
129  {
130  kDebug() << endl
131  << "inputError :" << m_inputErrorString << endl
132  << "outputError:" << m_outputErrorString;
133  assert( !m_eresult.isNull() );
134  }
135  SignEncryptFilesResult( const SigningResult & sr, const EncryptionResult & er, const shared_ptr<Input> & input, const shared_ptr<Output> & output, bool inputRemoved, bool outputCreated, const AuditLog & auditLog )
136  : Task::Result(),
137  m_sresult( sr ),
138  m_eresult( er ),
139  m_inputLabel( input ? input->label() : QString() ),
140  m_inputErrorString( input ? input->errorString() : QString() ),
141  m_outputLabel( output ? output->label() : QString() ),
142  m_outputErrorString( output ? output->errorString() : QString() ),
143  m_inputRemoved( inputRemoved ),
144  m_outputCreated( outputCreated ),
145  m_auditLog( auditLog )
146  {
147  kDebug() << endl
148  << "inputError :" << m_inputErrorString << endl
149  << "outputError:" << m_outputErrorString;
150  assert( !m_sresult.isNull() || !m_eresult.isNull() );
151  }
152 
153  /* reimp */ QString overview() const;
154  /* reimp */ QString details() const;
155  /* reimp */ int errorCode() const;
156  /* reimp */ QString errorString() const;
157  /* reimp */ VisualCode code() const;
158  /* reimp */ AuditLog auditLog() const;
159 
160  private:
161  const SigningResult m_sresult;
162  const EncryptionResult m_eresult;
163  const QString m_inputLabel;
164  const QString m_inputErrorString;
165  const QString m_outputLabel;
166  const QString m_outputErrorString;
167  const bool m_inputRemoved;
168  const bool m_outputCreated;
169  const AuditLog m_auditLog;
170  };
171 
172  static QString makeSigningOverview( const Error & err ) {
173  if ( err.isCanceled() )
174  return i18n("Signing canceled.");
175 
176  if ( err )
177  return i18n("Signing failed." );
178  return i18n("Signing succeeded.");
179  }
180 
181  static QString makeResultOverview( const SigningResult & result ) {
182  return makeSigningOverview( result.error() );
183  }
184 
185  static QString makeEncryptionOverview( const Error & err ) {
186  if ( err.isCanceled() )
187  return i18n("Encryption canceled.");
188 
189  if ( err )
190  return i18n("Encryption failed." );
191 
192  return i18n("Encryption succeeded.");
193  }
194 
195 
196  static QString makeResultOverview( const EncryptionResult & result ) {
197  return makeEncryptionOverview( result.error() );
198  }
199 
200  static QString makeResultOverview( const SigningResult & sr, const EncryptionResult & er ) {
201  if ( er.isNull() && sr.isNull() )
202  return QString();
203  if ( er.isNull() )
204  return makeResultOverview( sr );
205  if ( sr.isNull() )
206  return makeResultOverview( er );
207  if ( sr.error().isCanceled() || sr.error() )
208  return makeResultOverview( sr );
209  if ( er.error().isCanceled() || er.error() )
210  return makeResultOverview( er );
211  return i18n( "Signing and encryption succeeded." );
212  }
213 
214  static QString escape( QString s ) {
215  s = Qt::escape( s );
216  s.replace( QLatin1Char( '\n' ), QLatin1String( "<br>" ) );
217  return s;
218  }
219 
220  static QString makeResultDetails( const SigningResult & result, const QString & inputError, const QString & outputError ) {
221  const Error err = result.error();
222  if ( err.code() == GPG_ERR_EIO )
223  if ( !inputError.isEmpty() )
224  return i18n( "Input error: %1", escape( inputError ) );
225  else if ( !outputError.isEmpty() )
226  return i18n( "Output error: %1", escape( outputError ) );
227  if ( err )
228  return Qt::escape( QString::fromLocal8Bit( err.asString() ) );
229  return QString();
230  }
231 
232  static QString makeResultDetails( const EncryptionResult & result, const QString & inputError, const QString & outputError ) {
233  const Error err = result.error();
234  if ( err.code() == GPG_ERR_EIO )
235  if ( !inputError.isEmpty() )
236  return i18n( "Input error: %1", escape( inputError ) );
237  else if ( !outputError.isEmpty() )
238  return i18n( "Output error: %1", escape( outputError ) );
239  if ( err )
240  return Qt::escape( QString::fromLocal8Bit( err.asString() ) );
241  return i18n(" Encryption succeeded." );
242  }
243 
244 }
245 
246 
247 QString ErrorResult::overview() const {
248  assert( m_error || m_error.isCanceled() );
249  assert( m_sign || m_encrypt );
250  const QString label = formatInputOutputLabel( m_inputLabel, m_outputLabel, false, true );
251  const bool canceled = m_error.isCanceled();
252  if ( m_sign && m_encrypt )
253  return canceled ? i18n( "%1: <b>Sign/encrypt canceled.</b>", label ) : i18n( " %1: Sign/encrypt failed.", label );
254  return i18nc( "label: result. Example: foo -> foo.gpg: Encryption failed.", "%1: <b>%2</b>", label,
255  m_sign ? makeSigningOverview( m_error ) :makeEncryptionOverview( m_error ) );
256 }
257 
258 QString ErrorResult::details() const {
259  return m_errString;
260 }
261 
262 class SignEncryptFilesTask::Private {
263  friend class ::Kleo::Crypto::SignEncryptFilesTask;
264  SignEncryptFilesTask * const q;
265 public:
266  explicit Private( SignEncryptFilesTask * qq );
267 
268 private:
269  std::auto_ptr<Kleo::SignJob> createSignJob( GpgME::Protocol proto );
270  std::auto_ptr<Kleo::SignEncryptJob> createSignEncryptJob( GpgME::Protocol proto );
271  std::auto_ptr<Kleo::EncryptJob> createEncryptJob( GpgME::Protocol proto );
272  shared_ptr<const Task::Result> makeErrorResult( const Error & err, const QString & errStr, const AuditLog & auditLog );
273 
274 private:
275  void slotResult( const SigningResult & );
276  void slotResult( const SigningResult &, const EncryptionResult & );
277  void slotResult( const EncryptionResult & );
278 
279 private:
280  shared_ptr<Input> input;
281  shared_ptr<Output> output;
282  QStringList inputFileNames;
283  QString outputFileName;
284  std::vector<Key> signers;
285  std::vector<Key> recipients;
286 
287  bool sign : 1;
288  bool encrypt : 1;
289  bool detached : 1;
290  bool removeInput : 1;
291 
292  QPointer<Kleo::Job> job;
293  shared_ptr<OverwritePolicy> m_overwritePolicy;
294 };
295 
296 SignEncryptFilesTask::Private::Private( SignEncryptFilesTask * qq )
297  : q( qq ),
298  input(),
299  output(),
300  inputFileNames(),
301  outputFileName(),
302  signers(),
303  recipients(),
304  sign( true ),
305  encrypt( true ),
306  detached( false ),
307  removeInput( false ),
308  job( 0 ),
309  m_overwritePolicy( new OverwritePolicy( 0 ) )
310 {
311  q->setAsciiArmor( true );
312 }
313 
314 shared_ptr<const Task::Result> SignEncryptFilesTask::Private::makeErrorResult( const Error & err, const QString & errStr, const AuditLog & auditLog )
315 {
316  return shared_ptr<const ErrorResult>( new ErrorResult( sign, encrypt, err, errStr, input->label(), output->label(), auditLog ) );
317 }
318 
319 SignEncryptFilesTask::SignEncryptFilesTask( QObject * p )
320  : Task( p ), d( new Private( this ) )
321 {
322 
323 }
324 
325 SignEncryptFilesTask::~SignEncryptFilesTask() {}
326 
327 void SignEncryptFilesTask::setInputFileName( const QString & fileName ) {
328  kleo_assert( !d->job );
329  kleo_assert( !fileName.isEmpty() );
330  d->inputFileNames = QStringList( fileName );
331 }
332 
333 void SignEncryptFilesTask::setInputFileNames( const QStringList & fileNames ) {
334  kleo_assert( !d->job );
335  kleo_assert( !fileNames.empty() );
336  d->inputFileNames = fileNames;
337 }
338 
339 void SignEncryptFilesTask::setInput( const shared_ptr<Input> & input ) {
340  kleo_assert( !d->job );
341  kleo_assert( input );
342  d->input = input;
343 }
344 
345 void SignEncryptFilesTask::setOutputFileName( const QString & fileName ) {
346  kleo_assert( !d->job );
347  kleo_assert( !fileName.isEmpty() );
348  d->outputFileName = fileName;
349 }
350 
351 void SignEncryptFilesTask::setSigners( const std::vector<Key> & signers ) {
352  kleo_assert( !d->job );
353  d->signers = signers;
354 }
355 
356 void SignEncryptFilesTask::setRecipients( const std::vector<Key> & recipients ) {
357  kleo_assert( !d->job );
358  d->recipients = recipients;
359 }
360 
361 
362 void SignEncryptFilesTask::setOverwritePolicy( const shared_ptr<OverwritePolicy> & policy ) {
363  kleo_assert( !d->job );
364  d->m_overwritePolicy = policy;
365 }
366 
367 void SignEncryptFilesTask::setSign( bool sign ) {
368  kleo_assert( !d->job );
369  d->sign = sign;
370 }
371 
372 void SignEncryptFilesTask::setEncrypt( bool encrypt ) {
373  kleo_assert( !d->job );
374  d->encrypt = encrypt;
375 }
376 
377 void SignEncryptFilesTask::setRemoveInputFileOnSuccess( bool remove )
378 {
379  kleo_assert( !d->job );
380  d->removeInput = remove;
381 }
382 
383 void SignEncryptFilesTask::setDetachedSignature( bool detached ) {
384  kleo_assert( !d->job );
385  d->detached = detached;
386 }
387 
388 Protocol SignEncryptFilesTask::protocol() const {
389  if ( d->sign && !d->signers.empty() )
390  return d->signers.front().protocol();
391  if ( d->encrypt ) {
392  if ( !d->recipients.empty() )
393  return d->recipients.front().protocol();
394  else
395  return GpgME::OpenPGP; // symmetric OpenPGP encryption
396  }
397  throw Kleo::Exception( gpg_error( GPG_ERR_INTERNAL ),
398  i18n("Cannot determine protocol for task") );
399 }
400 
401 QString SignEncryptFilesTask::label() const {
402  return d->input ? d->input->label() : QString();
403 }
404 
405 QString SignEncryptFilesTask::tag() const {
406  return Formatting::displayName( protocol() );
407 }
408 
409 unsigned long long SignEncryptFilesTask::inputSize() const
410 {
411  return d->input ? d->input->size() : 0U ;
412 }
413 
414 void SignEncryptFilesTask::doStart() {
415  kleo_assert( !d->job );
416  if ( d->sign ) {
417  kleo_assert( !d->signers.empty() );
418  }
419 
420  kleo_assert( d->input );
421  d->output = Output::createFromFile( d->outputFileName, d->m_overwritePolicy );
422 
423  if ( d->encrypt )
424  if ( d->sign ) {
425  std::auto_ptr<Kleo::SignEncryptJob> job = d->createSignEncryptJob( protocol() );
426  kleo_assert( job.get() );
427 
428  job->start( d->signers, d->recipients,
429  d->input->ioDevice(), d->output->ioDevice(), true );
430 
431  d->job = job.release();
432  } else {
433  std::auto_ptr<Kleo::EncryptJob> job = d->createEncryptJob( protocol() );
434  kleo_assert( job.get() );
435 
436  job->start( d->recipients, d->input->ioDevice(), d->output->ioDevice(), true );
437 
438  d->job = job.release();
439  }
440  else
441  if ( d->sign ) {
442  std::auto_ptr<Kleo::SignJob> job = d->createSignJob( protocol() );
443  kleo_assert( job.get() );
444 
445  job->start( d->signers,
446  d->input->ioDevice(), d->output->ioDevice(),
447  d->detached ? GpgME::Detached : GpgME::NormalSignatureMode );
448 
449  d->job = job.release();
450  } else {
451  kleo_assert( !"Either 'sign' or 'encrypt' must be set!" );
452  }
453 }
454 
455 void SignEncryptFilesTask::cancel() {
456  if ( d->job )
457  d->job->slotCancel();
458 }
459 
460 std::auto_ptr<Kleo::SignJob> SignEncryptFilesTask::Private::createSignJob( GpgME::Protocol proto ) {
461  const CryptoBackend::Protocol * const backend = CryptoBackendFactory::instance()->protocol( proto );
462  kleo_assert( backend );
463  std::auto_ptr<Kleo::SignJob> signJob( backend->signJob( q->asciiArmor(), /*textmode=*/false ) );
464  kleo_assert( signJob.get() );
465  connect( signJob.get(), SIGNAL(progress(QString,int,int)),
466  q, SLOT(setProgress(QString,int,int)) );
467  connect( signJob.get(), SIGNAL(result(GpgME::SigningResult,QByteArray)),
468  q, SLOT(slotResult(GpgME::SigningResult)) );
469  return signJob;
470 }
471 
472 std::auto_ptr<Kleo::SignEncryptJob> SignEncryptFilesTask::Private::createSignEncryptJob( GpgME::Protocol proto ) {
473  const CryptoBackend::Protocol * const backend = CryptoBackendFactory::instance()->protocol( proto );
474  kleo_assert( backend );
475  std::auto_ptr<Kleo::SignEncryptJob> signEncryptJob( backend->signEncryptJob( q->asciiArmor(), /*textmode=*/false ) );
476  kleo_assert( signEncryptJob.get() );
477  connect( signEncryptJob.get(), SIGNAL(progress(QString,int,int)),
478  q, SLOT(setProgress(QString,int,int)) );
479  connect( signEncryptJob.get(), SIGNAL(result(GpgME::SigningResult,GpgME::EncryptionResult,QByteArray)),
480  q, SLOT(slotResult(GpgME::SigningResult,GpgME::EncryptionResult)) );
481  return signEncryptJob;
482 }
483 
484 std::auto_ptr<Kleo::EncryptJob> SignEncryptFilesTask::Private::createEncryptJob( GpgME::Protocol proto ) {
485  const CryptoBackend::Protocol * const backend = CryptoBackendFactory::instance()->protocol( proto );
486  kleo_assert( backend );
487  std::auto_ptr<Kleo::EncryptJob> encryptJob( backend->encryptJob( q->asciiArmor(), /*textmode=*/false ) );
488  kleo_assert( encryptJob.get() );
489  connect( encryptJob.get(), SIGNAL(progress(QString,int,int)),
490  q, SLOT(setProgress(QString,int,int)) );
491  connect( encryptJob.get(), SIGNAL(result(GpgME::EncryptionResult,QByteArray)),
492  q, SLOT(slotResult(GpgME::EncryptionResult)) );
493  return encryptJob;
494 }
495 
496 void SignEncryptFilesTask::Private::slotResult( const SigningResult & result ) {
497  const Job * const job = qobject_cast<const Job*>( q->sender() );
498  const AuditLog auditLog = AuditLog::fromJob( job );
499  bool inputRemoved = false;
500  bool outputCreated = false;
501  if ( result.error().code() ) {
502  output->cancel();
503  } else {
504  try {
505  kleo_assert( !result.isNull() );
506  output->finalize();
507  outputCreated = true;
508  input->finalize();
509  if ( removeInput )
510  try {
511  kdtools::for_each( inputFileNames, recursivelyRemovePath );
512  inputRemoved = true;
513  } catch ( ... ) {}
514  } catch ( const GpgME::Exception & e ) {
515  q->emitResult( makeErrorResult( e.error(), QString::fromLocal8Bit( e.what() ), auditLog ) );
516  return;
517  }
518  }
519 
520  q->emitResult( shared_ptr<Result>( new SignEncryptFilesResult( result, input, output, inputRemoved, outputCreated, auditLog ) ) );
521 }
522 
523 void SignEncryptFilesTask::Private::slotResult( const SigningResult & sresult, const EncryptionResult & eresult ) {
524  const Job * const job = qobject_cast<const Job*>( q->sender() );
525  const AuditLog auditLog = AuditLog::fromJob( job );
526  bool inputRemoved = false;
527  bool outputCreated = false;
528  if ( sresult.error().code() || eresult.error().code() ) {
529  output->cancel();
530  } else {
531  try {
532  kleo_assert( !sresult.isNull() || !eresult.isNull() );
533  output->finalize();
534  outputCreated = true;
535  input->finalize();
536  if ( removeInput )
537  try {
538  kdtools::for_each( inputFileNames, recursivelyRemovePath );
539  inputRemoved = true;
540  } catch ( ... ) {}
541  } catch ( const GpgME::Exception & e ) {
542  q->emitResult( makeErrorResult( e.error(), QString::fromLocal8Bit( e.what() ), auditLog ) );
543  return;
544  }
545  }
546 
547  q->emitResult( shared_ptr<Result>( new SignEncryptFilesResult( sresult, eresult, input, output, inputRemoved, outputCreated, auditLog ) ) );
548 }
549 
550 void SignEncryptFilesTask::Private::slotResult( const EncryptionResult & result ) {
551  const Job * const job = qobject_cast<const Job*>( q->sender() );
552  const AuditLog auditLog = AuditLog::fromJob( job );
553  bool inputRemoved = false;
554  bool outputCreated = false;
555  if ( result.error().code() ) {
556  output->cancel();
557  } else {
558  try {
559  kleo_assert( !result.isNull() );
560  output->finalize();
561  outputCreated = true;
562  input->finalize();
563  if ( removeInput )
564  try {
565  kdtools::for_each( inputFileNames, recursivelyRemovePath );
566  inputRemoved = true;
567  } catch ( ... ) {}
568  } catch ( const GpgME::Exception & e ) {
569  q->emitResult( makeErrorResult( e.error(), QString::fromLocal8Bit( e.what() ), auditLog ) );
570  return;
571  }
572  }
573  q->emitResult( shared_ptr<Result>( new SignEncryptFilesResult( result, input, output, inputRemoved, outputCreated, auditLog ) ) );
574 }
575 
576 QString SignEncryptFilesResult::overview() const {
577  const QString files = formatInputOutputLabel( m_inputLabel, m_outputLabel, m_inputRemoved, !m_outputCreated );
578  return files + QLatin1String(": ") + makeOverview( makeResultOverview( m_sresult, m_eresult ) );
579 }
580 
581 QString SignEncryptFilesResult::details() const {
582  return errorString();
583 }
584 
585 int SignEncryptFilesResult::errorCode() const {
586  if ( m_sresult.error().code() )
587  return m_sresult.error().encodedError();
588  if ( m_eresult.error().code() )
589  return m_eresult.error().encodedError();
590  return 0;
591 }
592 
593 QString SignEncryptFilesResult::errorString() const {
594  const bool sign = !m_sresult.isNull();
595  const bool encrypt = !m_eresult.isNull();
596 
597  kleo_assert( sign || encrypt );
598 
599  if ( sign && encrypt ) {
600  return
601  m_sresult.error().code() ? makeResultDetails( m_sresult, m_inputErrorString, m_outputErrorString ) :
602  m_eresult.error().code() ? makeResultDetails( m_eresult, m_inputErrorString, m_outputErrorString ) :
603  QString();
604  }
605 
606  return
607  sign ? makeResultDetails( m_sresult, m_inputErrorString, m_outputErrorString ) :
608  /*else*/ makeResultDetails( m_eresult, m_inputErrorString, m_outputErrorString ) ;
609 }
610 
611 Task::Result::VisualCode SignEncryptFilesResult::code() const
612 {
613  if ( m_sresult.error().isCanceled() || m_eresult.error().isCanceled() )
614  return Warning;
615  return ( m_sresult.error().code() || m_eresult.error().code() ) ? NeutralError : NeutralSuccess;
616 }
617 
618 AuditLog SignEncryptFilesResult::auditLog() const {
619  return m_auditLog;
620 }
621 
622 #include "moc_signencryptfilestask.cpp"
Kleo::Detached
Definition: types.h:55
auditlog.h
output.h
input.h
QByteArray
path-helper.h
Kleo::Crypto::Task::Result::VisualCode
VisualCode
Definition: task.h:129
Kleo::Crypto::SignEncryptFilesTask::cancel
void cancel()
Definition: signencryptfilestask.cpp:455
Kleo::AuditLog
Definition: auditlog.h:48
Kleo::Formatting::displayName
QString displayName(GpgME::Protocol prot)
Kleo::Crypto::SignEncryptFilesTask::setOverwritePolicy
void setOverwritePolicy(const boost::shared_ptr< OverwritePolicy > &policy)
Definition: signencryptfilestask.cpp:362
QPointer< Kleo::Job >
Kleo::Crypto::Task
Definition: task.h:57
formatting.h
Kleo::OverwritePolicy
Definition: output.h:52
Kleo::Crypto::SignEncryptFilesTask::setRecipients
void setRecipients(const std::vector< GpgME::Key > &recipients)
Definition: signencryptfilestask.cpp:356
QString::isNull
bool isNull() const
kleo_assert.h
boost::shared_ptr
Definition: encryptemailcontroller.h:51
Kleo::Crypto::SignEncryptFilesTask::tag
QString tag() const
Definition: signencryptfilestask.cpp:405
QString::fromLocal8Bit
QString fromLocal8Bit(const char *str, int size)
d
#define d
Definition: adduseridcommand.cpp:89
QList::empty
bool empty() const
QObject
Kleo::Class::OpenPGP
Definition: classify.h:49
Kleo::Crypto::SignEncryptFilesTask::SignEncryptFilesTask
SignEncryptFilesTask(QObject *parent=0)
Definition: signencryptfilestask.cpp:319
Kleo::Crypto::SignEncryptFilesTask::label
QString label() const
Definition: signencryptfilestask.cpp:401
QString::isEmpty
bool isEmpty() const
Kleo::Crypto::SignEncryptFilesTask::setSigners
void setSigners(const std::vector< GpgME::Key > &singners)
Definition: signencryptfilestask.cpp:351
Kleo::AuditLog::fromJob
static AuditLog fromJob(const Job *)
Definition: auditlog.cpp:45
QString
Kleo::recursivelyRemovePath
void recursivelyRemovePath(const QString &path)
Definition: path-helper.cpp:96
Kleo::Crypto::SignEncryptFilesTask::setOutputFileName
void setOutputFileName(const QString &fileName)
Definition: signencryptfilestask.cpp:345
QStringList
Kleo::Output::createFromFile
static boost::shared_ptr< Output > createFromFile(const QString &fileName, const boost::shared_ptr< OverwritePolicy > &)
Definition: output.cpp:343
Kleo::outputFileName
QString outputFileName(const QString &input)
Definition: classify.cpp:279
QLatin1Char
Kleo::Crypto::SignEncryptFilesTask::setEncrypt
void setEncrypt(bool encrypt)
Definition: signencryptfilestask.cpp:372
Kleo::Crypto::SignEncryptFilesTask::setInputFileNames
void setInputFileNames(const QStringList &fileNames)
Definition: signencryptfilestask.cpp:333
kleo_assert
#define kleo_assert(cond)
Definition: kleo_assert.h:86
QString::replace
QString & replace(int position, int n, QChar after)
Kleo::Crypto::Task::Result
Definition: task.h:119
QLatin1String
Qt::escape
QString escape(const QString &plain)
q
#define q
Definition: adduseridcommand.cpp:90
Kleo::Crypto::SignEncryptFilesTask
Definition: signencryptfilestask.h:62
Kleo::Crypto::SignEncryptFilesTask::setRemoveInputFileOnSuccess
void setRemoveInputFileOnSuccess(bool)
Definition: signencryptfilestask.cpp:377
QString::fromLatin1
QString fromLatin1(const char *str, int size)
Kleo::Crypto::SignEncryptFilesTask::setSign
void setSign(bool sign)
Definition: signencryptfilestask.cpp:367
Kleo::Crypto::SignEncryptFilesTask::setInputFileName
void setInputFileName(const QString &fileName)
Definition: signencryptfilestask.cpp:327
signencryptfilestask.h
Kleo::Crypto::SignEncryptFilesTask::protocol
GpgME::Protocol protocol() const
Definition: signencryptfilestask.cpp:388
Kleo::Crypto::SignEncryptFilesTask::~SignEncryptFilesTask
~SignEncryptFilesTask()
Definition: signencryptfilestask.cpp:325
Kleo::Crypto::SignEncryptFilesTask::setInput
void setInput(const boost::shared_ptr< Input > &input)
Definition: signencryptfilestask.cpp:339
Kleo::Crypto::SignEncryptFilesTask::setDetachedSignature
void setDetachedSignature(bool detached)
Definition: signencryptfilestask.cpp:383
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:33:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kleopatra

Skip menu "kleopatra"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal