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

kleopatra

  • sources
  • kde-4.12
  • 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 <QFileInfo>
61 #include <QPointer>
62 #include <QTextDocument> // for Qt::escape
63 
64 #include <boost/bind.hpp>
65 
66 using namespace Kleo;
67 using namespace Kleo::Crypto;
68 using namespace boost;
69 using namespace GpgME;
70 
71 namespace {
72 
73  QString formatInputOutputLabel( const QString & input, const QString & output, bool inputDeleted, bool outputDeleted ) {
74  return i18nc( "Input file --> Output file (rarr is arrow", "%1 &rarr; %2",
75  inputDeleted ? QString::fromLatin1("<s>%1</s>").arg( Qt::escape( input ) ) : Qt::escape( input ),
76  outputDeleted ? QString::fromLatin1("<s>%1</s>").arg( Qt::escape( output ) ) : Qt::escape( output ) );
77  }
78 
79  class ErrorResult : public Task::Result {
80  public:
81  ErrorResult( bool sign, bool encrypt, const Error & err, const QString & errStr, const QString & input, const QString & output, const AuditLog & auditLog )
82  : Task::Result(), m_sign( sign ), m_encrypt( encrypt ), m_error( err ), m_errString( errStr ), m_inputLabel( input ), m_outputLabel( output ), m_auditLog( auditLog ) {}
83 
84  /* reimp */ QString overview() const;
85  /* reimp */ QString details() const;
86  /* reimp */ int errorCode() const { return m_error.encodedError(); }
87  /* reimp */ QString errorString() const { return m_errString; }
88  /* reimp */ VisualCode code() const { return NeutralError; }
89  /* reimp */ AuditLog auditLog() const { return m_auditLog; }
90  private:
91  const bool m_sign;
92  const bool m_encrypt;
93  const Error m_error;
94  const QString m_errString;
95  const QString m_inputLabel;
96  const QString m_outputLabel;
97  const AuditLog m_auditLog;
98  };
99 
100  class SignEncryptFilesResult : public Task::Result {
101  public:
102  SignEncryptFilesResult( const SigningResult & sr, const shared_ptr<Input> & input, const shared_ptr<Output> & output, bool inputRemoved, bool outputCreated, const AuditLog & auditLog )
103  : Task::Result(),
104  m_sresult( sr ),
105  m_inputLabel( input ? input->label() : QString() ),
106  m_inputErrorString( input ? input->errorString() : QString() ),
107  m_outputLabel( output ? output->label() : QString() ),
108  m_outputErrorString( output ? output->errorString() : QString() ),
109  m_inputRemoved( inputRemoved ),
110  m_outputCreated( outputCreated ),
111  m_auditLog( auditLog )
112  {
113  kDebug() << endl
114  << "inputError :" << m_inputErrorString << endl
115  << "outputError:" << m_outputErrorString;
116  assert( !m_sresult.isNull() );
117  }
118  SignEncryptFilesResult( const EncryptionResult & er, const shared_ptr<Input> & input, const shared_ptr<Output> & output, bool inputRemoved, bool outputCreated, const AuditLog & auditLog )
119  : Task::Result(),
120  m_eresult( er ),
121  m_inputLabel( input ? input->label() : QString() ),
122  m_inputErrorString( input ? input->errorString() : QString() ),
123  m_outputLabel( output ? output->label() : QString() ),
124  m_outputErrorString( output ? output->errorString() : QString() ),
125  m_inputRemoved( inputRemoved ),
126  m_outputCreated( outputCreated ),
127  m_auditLog( auditLog )
128  {
129  kDebug() << endl
130  << "inputError :" << m_inputErrorString << endl
131  << "outputError:" << m_outputErrorString;
132  assert( !m_eresult.isNull() );
133  }
134  SignEncryptFilesResult( const SigningResult & sr, const EncryptionResult & er, const shared_ptr<Input> & input, const shared_ptr<Output> & output, bool inputRemoved, bool outputCreated, const AuditLog & auditLog )
135  : Task::Result(),
136  m_sresult( sr ),
137  m_eresult( er ),
138  m_inputLabel( input ? input->label() : QString() ),
139  m_inputErrorString( input ? input->errorString() : QString() ),
140  m_outputLabel( output ? output->label() : QString() ),
141  m_outputErrorString( output ? output->errorString() : QString() ),
142  m_inputRemoved( inputRemoved ),
143  m_outputCreated( outputCreated ),
144  m_auditLog( auditLog )
145  {
146  kDebug() << endl
147  << "inputError :" << m_inputErrorString << endl
148  << "outputError:" << m_outputErrorString;
149  assert( !m_sresult.isNull() || !m_eresult.isNull() );
150  }
151 
152  /* reimp */ QString overview() const;
153  /* reimp */ QString details() const;
154  /* reimp */ int errorCode() const;
155  /* reimp */ QString errorString() const;
156  /* reimp */ VisualCode code() const;
157  /* reimp */ AuditLog auditLog() const;
158 
159  private:
160  const SigningResult m_sresult;
161  const EncryptionResult m_eresult;
162  const QString m_inputLabel;
163  const QString m_inputErrorString;
164  const QString m_outputLabel;
165  const QString m_outputErrorString;
166  const bool m_inputRemoved;
167  const bool m_outputCreated;
168  const AuditLog m_auditLog;
169  };
170 
171  static QString makeSigningOverview( const Error & err ) {
172  if ( err.isCanceled() )
173  return i18n("Signing canceled.");
174 
175  if ( err )
176  return i18n("Signing failed." );
177  return i18n("Signing succeeded.");
178  }
179 
180  static QString makeResultOverview( const SigningResult & result ) {
181  return makeSigningOverview( result.error() );
182  }
183 
184  static QString makeEncryptionOverview( const Error & err ) {
185  if ( err.isCanceled() )
186  return i18n("Encryption canceled.");
187 
188  if ( err )
189  return i18n("Encryption failed." );
190 
191  return i18n("Encryption succeeded.");
192  }
193 
194 
195  static QString makeResultOverview( const EncryptionResult & result ) {
196  return makeEncryptionOverview( result.error() );
197  }
198 
199  static QString makeResultOverview( const SigningResult & sr, const EncryptionResult & er ) {
200  if ( er.isNull() && sr.isNull() )
201  return QString();
202  if ( er.isNull() )
203  return makeResultOverview( sr );
204  if ( sr.isNull() )
205  return makeResultOverview( er );
206  if ( sr.error().isCanceled() || sr.error() )
207  return makeResultOverview( sr );
208  if ( er.error().isCanceled() || er.error() )
209  return makeResultOverview( er );
210  return i18n( "Signing and encryption succeeded." );
211  }
212 
213  static QString escape( QString s ) {
214  s = Qt::escape( s );
215  s.replace( QLatin1Char( '\n' ), QLatin1String( "<br>" ) );
216  return s;
217  }
218 
219  static QString makeResultDetails( const SigningResult & result, const QString & inputError, const QString & outputError ) {
220  const Error err = result.error();
221  if ( err.code() == GPG_ERR_EIO )
222  if ( !inputError.isEmpty() )
223  return i18n( "Input error: %1", escape( inputError ) );
224  else if ( !outputError.isEmpty() )
225  return i18n( "Output error: %1", escape( outputError ) );
226  if ( err )
227  return Qt::escape( QString::fromLocal8Bit( err.asString() ) );
228  return QString();
229  }
230 
231  static QString makeResultDetails( const EncryptionResult & result, const QString & inputError, const QString & outputError ) {
232  const Error err = result.error();
233  if ( err.code() == GPG_ERR_EIO )
234  if ( !inputError.isEmpty() )
235  return i18n( "Input error: %1", escape( inputError ) );
236  else if ( !outputError.isEmpty() )
237  return i18n( "Output error: %1", escape( outputError ) );
238  if ( err )
239  return Qt::escape( QString::fromLocal8Bit( err.asString() ) );
240  return i18n(" Encryption succeeded." );
241  }
242 
243 }
244 
245 
246 QString ErrorResult::overview() const {
247  assert( m_error || m_error.isCanceled() );
248  assert( m_sign || m_encrypt );
249  const QString label = formatInputOutputLabel( m_inputLabel, m_outputLabel, false, true );
250  const bool canceled = m_error.isCanceled();
251  if ( m_sign && m_encrypt )
252  return canceled ? i18n( "%1: <b>Sign/encrypt canceled.</b>", label ) : i18n( " %1: Sign/encrypt failed.", label );
253  return i18nc( "label: result. Example: foo -> foo.gpg: Encryption failed.", "%1: <b>%2</b>", label,
254  m_sign ? makeSigningOverview( m_error ) :makeEncryptionOverview( m_error ) );
255 }
256 
257 QString ErrorResult::details() const {
258  return m_errString;
259 }
260 
261 class SignEncryptFilesTask::Private {
262  friend class ::Kleo::Crypto::SignEncryptFilesTask;
263  SignEncryptFilesTask * const q;
264 public:
265  explicit Private( SignEncryptFilesTask * qq );
266 
267 private:
268  std::auto_ptr<Kleo::SignJob> createSignJob( GpgME::Protocol proto );
269  std::auto_ptr<Kleo::SignEncryptJob> createSignEncryptJob( GpgME::Protocol proto );
270  std::auto_ptr<Kleo::EncryptJob> createEncryptJob( GpgME::Protocol proto );
271  shared_ptr<const Task::Result> makeErrorResult( const Error & err, const QString & errStr, const AuditLog & auditLog );
272 
273 private:
274  void slotResult( const SigningResult & );
275  void slotResult( const SigningResult &, const EncryptionResult & );
276  void slotResult( const EncryptionResult & );
277 
278 private:
279  shared_ptr<Input> input;
280  shared_ptr<Output> output;
281  QStringList inputFileNames;
282  QString outputFileName;
283  std::vector<Key> signers;
284  std::vector<Key> recipients;
285 
286  bool sign : 1;
287  bool encrypt : 1;
288  bool detached : 1;
289  bool removeInput : 1;
290 
291  QPointer<Kleo::Job> job;
292  shared_ptr<OverwritePolicy> m_overwritePolicy;
293 };
294 
295 SignEncryptFilesTask::Private::Private( SignEncryptFilesTask * qq )
296  : q( qq ),
297  input(),
298  output(),
299  inputFileNames(),
300  outputFileName(),
301  signers(),
302  recipients(),
303  sign( true ),
304  encrypt( true ),
305  detached( false ),
306  removeInput( false ),
307  job( 0 ),
308  m_overwritePolicy( new OverwritePolicy( 0 ) )
309 {
310  q->setAsciiArmor( true );
311 }
312 
313 shared_ptr<const Task::Result> SignEncryptFilesTask::Private::makeErrorResult( const Error & err, const QString & errStr, const AuditLog & auditLog )
314 {
315  return shared_ptr<const ErrorResult>( new ErrorResult( sign, encrypt, err, errStr, input->label(), output->label(), auditLog ) );
316 }
317 
318 SignEncryptFilesTask::SignEncryptFilesTask( QObject * p )
319  : Task( p ), d( new Private( this ) )
320 {
321 
322 }
323 
324 SignEncryptFilesTask::~SignEncryptFilesTask() {}
325 
326 void SignEncryptFilesTask::setInputFileName( const QString & fileName ) {
327  kleo_assert( !d->job );
328  kleo_assert( !fileName.isEmpty() );
329  d->inputFileNames = QStringList( fileName );
330 }
331 
332 void SignEncryptFilesTask::setInputFileNames( const QStringList & fileNames ) {
333  kleo_assert( !d->job );
334  kleo_assert( !fileNames.empty() );
335  d->inputFileNames = fileNames;
336 }
337 
338 void SignEncryptFilesTask::setInput( const shared_ptr<Input> & input ) {
339  kleo_assert( !d->job );
340  kleo_assert( input );
341  d->input = input;
342 }
343 
344 void SignEncryptFilesTask::setOutputFileName( const QString & fileName ) {
345  kleo_assert( !d->job );
346  kleo_assert( !fileName.isEmpty() );
347  d->outputFileName = fileName;
348 }
349 
350 void SignEncryptFilesTask::setSigners( const std::vector<Key> & signers ) {
351  kleo_assert( !d->job );
352  d->signers = signers;
353 }
354 
355 void SignEncryptFilesTask::setRecipients( const std::vector<Key> & recipients ) {
356  kleo_assert( !d->job );
357  d->recipients = recipients;
358 }
359 
360 
361 void SignEncryptFilesTask::setOverwritePolicy( const shared_ptr<OverwritePolicy> & policy ) {
362  kleo_assert( !d->job );
363  d->m_overwritePolicy = policy;
364 }
365 
366 void SignEncryptFilesTask::setSign( bool sign ) {
367  kleo_assert( !d->job );
368  d->sign = sign;
369 }
370 
371 void SignEncryptFilesTask::setEncrypt( bool encrypt ) {
372  kleo_assert( !d->job );
373  d->encrypt = encrypt;
374 }
375 
376 void SignEncryptFilesTask::setRemoveInputFileOnSuccess( bool remove )
377 {
378  kleo_assert( !d->job );
379  d->removeInput = remove;
380 }
381 
382 void SignEncryptFilesTask::setDetachedSignature( bool detached ) {
383  kleo_assert( !d->job );
384  d->detached = detached;
385 }
386 
387 Protocol SignEncryptFilesTask::protocol() const {
388  if ( d->sign && !d->signers.empty() )
389  return d->signers.front().protocol();
390  if ( d->encrypt ) {
391  if ( !d->recipients.empty() )
392  return d->recipients.front().protocol();
393  else
394  return GpgME::OpenPGP; // symmetric OpenPGP encryption
395  }
396  throw Kleo::Exception( gpg_error( GPG_ERR_INTERNAL ),
397  i18n("Cannot determine protocol for task") );
398 }
399 
400 QString SignEncryptFilesTask::label() const {
401  return d->input ? d->input->label() : QString();
402 }
403 
404 QString SignEncryptFilesTask::tag() const {
405  return Formatting::displayName( protocol() );
406 }
407 
408 unsigned long long SignEncryptFilesTask::inputSize() const
409 {
410  return d->input ? d->input->size() : 0U ;
411 }
412 
413 void SignEncryptFilesTask::doStart() {
414  kleo_assert( !d->job );
415  if ( d->sign ) {
416  kleo_assert( !d->signers.empty() );
417  }
418 
419  kleo_assert( d->input );
420  d->output = Output::createFromFile( d->outputFileName, d->m_overwritePolicy );
421 
422  if ( d->encrypt )
423  if ( d->sign ) {
424  std::auto_ptr<Kleo::SignEncryptJob> job = d->createSignEncryptJob( protocol() );
425  kleo_assert( job.get() );
426 
427  job->start( d->signers, d->recipients,
428  d->input->ioDevice(), d->output->ioDevice(), true );
429 
430  d->job = job.release();
431  } else {
432  std::auto_ptr<Kleo::EncryptJob> job = d->createEncryptJob( protocol() );
433  kleo_assert( job.get() );
434 
435  job->start( d->recipients, d->input->ioDevice(), d->output->ioDevice(), true );
436 
437  d->job = job.release();
438  }
439  else
440  if ( d->sign ) {
441  std::auto_ptr<Kleo::SignJob> job = d->createSignJob( protocol() );
442  kleo_assert( job.get() );
443 
444  job->start( d->signers,
445  d->input->ioDevice(), d->output->ioDevice(),
446  d->detached ? GpgME::Detached : GpgME::NormalSignatureMode );
447 
448  d->job = job.release();
449  } else {
450  kleo_assert( !"Either 'sign' or 'encrypt' must be set!" );
451  }
452 }
453 
454 void SignEncryptFilesTask::cancel() {
455  if ( d->job )
456  d->job->slotCancel();
457 }
458 
459 std::auto_ptr<Kleo::SignJob> SignEncryptFilesTask::Private::createSignJob( GpgME::Protocol proto ) {
460  const CryptoBackend::Protocol * const backend = CryptoBackendFactory::instance()->protocol( proto );
461  kleo_assert( backend );
462  std::auto_ptr<Kleo::SignJob> signJob( backend->signJob( q->asciiArmor(), /*textmode=*/false ) );
463  kleo_assert( signJob.get() );
464  connect( signJob.get(), SIGNAL(progress(QString,int,int)),
465  q, SLOT(setProgress(QString,int,int)) );
466  connect( signJob.get(), SIGNAL(result(GpgME::SigningResult,QByteArray)),
467  q, SLOT(slotResult(GpgME::SigningResult)) );
468  return signJob;
469 }
470 
471 std::auto_ptr<Kleo::SignEncryptJob> SignEncryptFilesTask::Private::createSignEncryptJob( GpgME::Protocol proto ) {
472  const CryptoBackend::Protocol * const backend = CryptoBackendFactory::instance()->protocol( proto );
473  kleo_assert( backend );
474  std::auto_ptr<Kleo::SignEncryptJob> signEncryptJob( backend->signEncryptJob( q->asciiArmor(), /*textmode=*/false ) );
475  kleo_assert( signEncryptJob.get() );
476  connect( signEncryptJob.get(), SIGNAL(progress(QString,int,int)),
477  q, SLOT(setProgress(QString,int,int)) );
478  connect( signEncryptJob.get(), SIGNAL(result(GpgME::SigningResult,GpgME::EncryptionResult,QByteArray)),
479  q, SLOT(slotResult(GpgME::SigningResult,GpgME::EncryptionResult)) );
480  return signEncryptJob;
481 }
482 
483 std::auto_ptr<Kleo::EncryptJob> SignEncryptFilesTask::Private::createEncryptJob( GpgME::Protocol proto ) {
484  const CryptoBackend::Protocol * const backend = CryptoBackendFactory::instance()->protocol( proto );
485  kleo_assert( backend );
486  std::auto_ptr<Kleo::EncryptJob> encryptJob( backend->encryptJob( q->asciiArmor(), /*textmode=*/false ) );
487  kleo_assert( encryptJob.get() );
488  connect( encryptJob.get(), SIGNAL(progress(QString,int,int)),
489  q, SLOT(setProgress(QString,int,int)) );
490  connect( encryptJob.get(), SIGNAL(result(GpgME::EncryptionResult,QByteArray)),
491  q, SLOT(slotResult(GpgME::EncryptionResult)) );
492  return encryptJob;
493 }
494 
495 void SignEncryptFilesTask::Private::slotResult( const SigningResult & result ) {
496  const Job * const job = qobject_cast<const Job*>( q->sender() );
497  const AuditLog auditLog = AuditLog::fromJob( job );
498  bool inputRemoved = false;
499  bool outputCreated = false;
500  if ( result.error().code() ) {
501  output->cancel();
502  } else {
503  try {
504  kleo_assert( !result.isNull() );
505  output->finalize();
506  outputCreated = true;
507  input->finalize();
508  if ( removeInput )
509  try {
510  kdtools::for_each( inputFileNames, recursivelyRemovePath );
511  inputRemoved = true;
512  } catch ( ... ) {}
513  } catch ( const GpgME::Exception & e ) {
514  q->emitResult( makeErrorResult( e.error(), QString::fromLocal8Bit( e.what() ), auditLog ) );
515  return;
516  }
517  }
518 
519  q->emitResult( shared_ptr<Result>( new SignEncryptFilesResult( result, input, output, inputRemoved, outputCreated, auditLog ) ) );
520 }
521 
522 void SignEncryptFilesTask::Private::slotResult( const SigningResult & sresult, const EncryptionResult & eresult ) {
523  const Job * const job = qobject_cast<const Job*>( q->sender() );
524  const AuditLog auditLog = AuditLog::fromJob( job );
525  bool inputRemoved = false;
526  bool outputCreated = false;
527  if ( sresult.error().code() || eresult.error().code() ) {
528  output->cancel();
529  } else {
530  try {
531  kleo_assert( !sresult.isNull() || !eresult.isNull() );
532  output->finalize();
533  outputCreated = true;
534  input->finalize();
535  if ( removeInput )
536  try {
537  kdtools::for_each( inputFileNames, recursivelyRemovePath );
538  inputRemoved = true;
539  } catch ( ... ) {}
540  } catch ( const GpgME::Exception & e ) {
541  q->emitResult( makeErrorResult( e.error(), QString::fromLocal8Bit( e.what() ), auditLog ) );
542  return;
543  }
544  }
545 
546  q->emitResult( shared_ptr<Result>( new SignEncryptFilesResult( sresult, eresult, input, output, inputRemoved, outputCreated, auditLog ) ) );
547 }
548 
549 void SignEncryptFilesTask::Private::slotResult( const EncryptionResult & result ) {
550  const Job * const job = qobject_cast<const Job*>( q->sender() );
551  const AuditLog auditLog = AuditLog::fromJob( job );
552  bool inputRemoved = false;
553  bool outputCreated = false;
554  if ( result.error().code() ) {
555  output->cancel();
556  } else {
557  try {
558  kleo_assert( !result.isNull() );
559  output->finalize();
560  outputCreated = true;
561  input->finalize();
562  if ( removeInput )
563  try {
564  kdtools::for_each( inputFileNames, recursivelyRemovePath );
565  inputRemoved = true;
566  } catch ( ... ) {}
567  } catch ( const GpgME::Exception & e ) {
568  q->emitResult( makeErrorResult( e.error(), QString::fromLocal8Bit( e.what() ), auditLog ) );
569  return;
570  }
571  }
572  q->emitResult( shared_ptr<Result>( new SignEncryptFilesResult( result, input, output, inputRemoved, outputCreated, auditLog ) ) );
573 }
574 
575 QString SignEncryptFilesResult::overview() const {
576  const QString files = formatInputOutputLabel( m_inputLabel, m_outputLabel, m_inputRemoved, !m_outputCreated );
577  return files + QLatin1String(": ") + makeOverview( makeResultOverview( m_sresult, m_eresult ) );
578 }
579 
580 QString SignEncryptFilesResult::details() const {
581  return errorString();
582 }
583 
584 int SignEncryptFilesResult::errorCode() const {
585  if ( m_sresult.error().code() )
586  return m_sresult.error().encodedError();
587  if ( m_eresult.error().code() )
588  return m_eresult.error().encodedError();
589  return 0;
590 }
591 
592 QString SignEncryptFilesResult::errorString() const {
593  const bool sign = !m_sresult.isNull();
594  const bool encrypt = !m_eresult.isNull();
595 
596  kleo_assert( sign || encrypt );
597 
598  if ( sign && encrypt ) {
599  return
600  m_sresult.error().code() ? makeResultDetails( m_sresult, m_inputErrorString, m_outputErrorString ) :
601  m_eresult.error().code() ? makeResultDetails( m_eresult, m_inputErrorString, m_outputErrorString ) :
602  QString();
603  }
604 
605  return
606  sign ? makeResultDetails( m_sresult, m_inputErrorString, m_outputErrorString ) :
607  /*else*/ makeResultDetails( m_eresult, m_inputErrorString, m_outputErrorString ) ;
608 }
609 
610 Task::Result::VisualCode SignEncryptFilesResult::code() const
611 {
612  if ( m_sresult.error().isCanceled() || m_eresult.error().isCanceled() )
613  return Warning;
614  return ( m_sresult.error().code() || m_eresult.error().code() ) ? NeutralError : NeutralSuccess;
615 }
616 
617 AuditLog SignEncryptFilesResult::auditLog() const {
618  return m_auditLog;
619 }
620 
621 #include "moc_signencryptfilestask.cpp"
Kleo::Detached
Definition: types.h:55
auditlog.h
output.h
input.h
path-helper.h
Kleo::Crypto::Task::Result::VisualCode
VisualCode
Definition: task.h:127
Kleo::Crypto::SignEncryptFilesTask::cancel
void cancel()
Definition: signencryptfilestask.cpp:454
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:361
Kleo::Crypto::Task
Definition: task.h:55
formatting.h
Kleo::OverwritePolicy
Definition: output.h:50
Kleo::Crypto::SignEncryptFilesTask::setRecipients
void setRecipients(const std::vector< GpgME::Key > &recipients)
Definition: signencryptfilestask.cpp:355
kleo_assert.h
boost::shared_ptr
Definition: encryptemailcontroller.h:51
Kleo::Crypto::SignEncryptFilesTask::tag
QString tag() const
Definition: signencryptfilestask.cpp:404
d
#define d
Definition: adduseridcommand.cpp:90
Kleo::Class::OpenPGP
Definition: classify.h:49
Kleo::Crypto::SignEncryptFilesTask::SignEncryptFilesTask
SignEncryptFilesTask(QObject *parent=0)
Definition: signencryptfilestask.cpp:318
Kleo::Crypto::SignEncryptFilesTask::label
QString label() const
Definition: signencryptfilestask.cpp:400
Kleo::Crypto::SignEncryptFilesTask::setSigners
void setSigners(const std::vector< GpgME::Key > &singners)
Definition: signencryptfilestask.cpp:350
Kleo::AuditLog::fromJob
static AuditLog fromJob(const Job *)
Definition: auditlog.cpp:45
Kleo::recursivelyRemovePath
void recursivelyRemovePath(const QString &path)
Definition: path-helper.cpp:94
Kleo::Crypto::SignEncryptFilesTask::setOutputFileName
void setOutputFileName(const QString &fileName)
Definition: signencryptfilestask.cpp:344
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:277
Kleo::Crypto::SignEncryptFilesTask::setEncrypt
void setEncrypt(bool encrypt)
Definition: signencryptfilestask.cpp:371
Kleo::Crypto::SignEncryptFilesTask::setInputFileNames
void setInputFileNames(const QStringList &fileNames)
Definition: signencryptfilestask.cpp:332
kleo_assert
#define kleo_assert(cond)
Definition: kleo_assert.h:84
Kleo::Crypto::Task::Result
Definition: task.h:117
q
#define q
Definition: adduseridcommand.cpp:91
Kleo::Crypto::SignEncryptFilesTask
Definition: signencryptfilestask.h:62
Kleo::Crypto::SignEncryptFilesTask::setRemoveInputFileOnSuccess
void setRemoveInputFileOnSuccess(bool)
Definition: signencryptfilestask.cpp:376
Kleo::Crypto::SignEncryptFilesTask::setSign
void setSign(bool sign)
Definition: signencryptfilestask.cpp:366
Kleo::Crypto::SignEncryptFilesTask::setInputFileName
void setInputFileName(const QString &fileName)
Definition: signencryptfilestask.cpp:326
signencryptfilestask.h
Kleo::Crypto::SignEncryptFilesTask::protocol
GpgME::Protocol protocol() const
Definition: signencryptfilestask.cpp:387
Kleo::Crypto::SignEncryptFilesTask::~SignEncryptFilesTask
~SignEncryptFilesTask()
Definition: signencryptfilestask.cpp:324
Kleo::Crypto::SignEncryptFilesTask::setInput
void setInput(const boost::shared_ptr< Input > &input)
Definition: signencryptfilestask.cpp:338
Kleo::Crypto::SignEncryptFilesTask::setDetachedSignature
void setDetachedSignature(bool detached)
Definition: signencryptfilestask.cpp:382
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:42 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

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