kleopatra
decryptverifytask.cpp
Go to the documentation of this file.
100 static bool addrspec_equal( const AddrSpec & lhs, const AddrSpec & rhs, Qt::CaseSensitivity cs ) {
101 return lhs.localPart.compare( rhs.localPart, cs ) == 0 && lhs.domain.compare( rhs.domain, Qt::CaseInsensitive ) == 0;
164 return std::find_if( mbxs.begin(), mbxs.end(), boost::bind( mailbox_equal, mbox, _1, Qt::CaseInsensitive ) ) != mbxs.end();
168 return std::find_if( keys.begin(), keys.end(), boost::bind( keyContainsMailbox, _1, mbox ) ) != keys.end();
211 return i18n( "The signature is valid but the trust in the certificate's validity is only marginal." );
217 return i18n( "The signature is valid but the certificate's validity is <em>not trusted</em>." );
256 const QDateTime dt = sig.creationTime() != 0 ? QDateTime::fromTime_t( sig.creationTime() ) : QDateTime();
263 return i18n( "Signed on %1 with unknown certificate %2.", formatDate( dt ), renderFingerprint( sig.fingerprint() ) );
284 return QString( strike ? QLatin1String("<s>%1</s>") : QLatin1String("%1") ).arg( Qt::escape( str ) );
287 static QString formatInputOutputLabel( const QString & input, const QString & output, bool inputDeleted, bool outputDeleted ) {
324 explicit SenderInfo( const Mailbox & infSender, const std::vector<Key> & signers_ ) : informativeSender( infSender ), signers( signers_ ) {}
328 bool conflicts() const { return hasInformativeSender() && hasKeys() && !keysContainMailbox( signers, informativeSender ); }
353 static QString formatVerificationResultOverview( const VerificationResult & res, const DecryptVerifyResult::SenderInfo & info ) {
362 return i18n( "<b>Verification failed: %1.</b>", Qt::escape( QString::fromLocal8Bit( err.asString() ) ) );
376 return i18np("<b>Not enough information to check signature validity.</b>", "<b>%1 signatures could not be verified.</b>", warn );
386 text += i18n( "<br/><b>Warning:</b> The sender's mail address is not stored in the %1 used for signing.",
392 text += i18n( "<br/><b>Warning:</b> The sender's mail address is not stored in the certificates used for signing." );
398 static QString formatDecryptionResultOverview( const DecryptionResult & result, const QString& errorString = QString() )
407 return i18n( "<b>Decryption failed: %1.</b>", Qt::escape( QString::fromLocal8Bit( err.asString() ) ) );
411 static QString formatSignature( const Signature & sig, const Key & key, const DecryptVerifyResult::SenderInfo & info ) {
431 std::transform( mbxs.begin(), mbxs.end(), std::back_inserter( res ), boost::bind( &Mailbox::prettyAddress, _1 ) );
435 static QString formatVerificationResultDetails( const VerificationResult & res, const DecryptVerifyResult::SenderInfo & info, const QString& errorString )
437 if( (res.error().code() == GPG_ERR_EIO || res.error().code() == GPG_ERR_NO_DATA) && !errorString.isEmpty() )
444 details += formatSignature( sig, DecryptVerifyResult::keyForSignature( sig, signers ), info ) + QLatin1Char('\n');
448 details += i18n( "<p>The sender's address %1 is not stored in the certificate. Stored: %2</p>", info.informativeSender.prettyAddress(), format( info.signerMailboxes() ).join( i18nc("separator for a list of e-mail addresses", ", " ) ) );
452 static QString formatDecryptionResultDetails( const DecryptionResult & res, const std::vector<Key> & recipients, const QString& errorString )
454 if( (res.error().code() == GPG_ERR_EIO || res.error().code() == GPG_ERR_NO_DATA) && !errorString.isEmpty() )
461 return QLatin1String( "<i>") + i18np( "One unknown recipient.", "%1 unknown recipients.", res.numRecipients() ) + QLatin1String("</i>");
482 static QString formatDecryptVerifyResultOverview( const DecryptionResult & dr, const VerificationResult & vr, const DecryptVerifyResult::SenderInfo & info )
498 return drDetails + ( drDetails.isEmpty() ? QString() : QLatin1String("<br/>") ) + formatVerificationResultDetails( vr, info, errorString );
553 return SenderInfo( m_informativeSender, KeyCache::instance()->findSigners( m_verificationResult ) );
556 shared_ptr<DecryptVerifyResult> AbstractDecryptVerifyTask::fromDecryptResult( const DecryptionResult & dr, const QByteArray & plaintext, const AuditLog & auditLog ) {
570 shared_ptr<DecryptVerifyResult> AbstractDecryptVerifyTask::fromDecryptResult( const GpgME::Error & err, const QString& what, const AuditLog & auditLog ) {
584 shared_ptr<DecryptVerifyResult> AbstractDecryptVerifyTask::fromDecryptVerifyResult( const DecryptionResult & dr, const VerificationResult & vr, const QByteArray & plaintext, const AuditLog & auditLog ) {
598 shared_ptr<DecryptVerifyResult> AbstractDecryptVerifyTask::fromDecryptVerifyResult( const GpgME::Error & err, const QString & details, const AuditLog & auditLog ) {
612 shared_ptr<DecryptVerifyResult> AbstractDecryptVerifyTask::fromVerifyOpaqueResult( const VerificationResult & vr, const QByteArray & plaintext, const AuditLog & auditLog ) {
625 shared_ptr<DecryptVerifyResult> AbstractDecryptVerifyTask::fromVerifyOpaqueResult( const GpgME::Error & err, const QString & details, const AuditLog & auditLog ) {
639 shared_ptr<DecryptVerifyResult> AbstractDecryptVerifyTask::fromVerifyDetachedResult( const VerificationResult & vr, const AuditLog & auditLog ) {
652 shared_ptr<DecryptVerifyResult> AbstractDecryptVerifyTask::fromVerifyDetachedResult( const GpgME::Error & err, const QString & details, const AuditLog & auditLog ) {
676 : Task::Result(), d( new Private( type, vr, dr, stuff, errCode, errString, inputLabel, outputLabel, auditLog, informativeSender, this ) )
688 ov = formatDecryptVerifyResultOverview( d->m_decryptionResult, d->m_verificationResult, d->makeSenderInfo() );
689 return i18nc( "label: result example: foo.sig: Verification failed. ", "%1: %2", d->label(), ov );
695 return formatDecryptionResultDetails( d->m_decryptionResult, KeyCache::instance()->findRecipients( d->m_decryptionResult ), errorString() );
697 return formatVerificationResultDetails( d->m_verificationResult, d->makeSenderInfo(), errorString() );
723 if ( ( d->m_type == DecryptVerify || d->m_type == Verify ) && relevantInDecryptVerifyContext( verificationResult() ) )
733 const Key & DecryptVerifyResult::keyForSignature( const Signature & sig, const std::vector<Key> & keys ) {
750 AbstractDecryptVerifyTask::AbstractDecryptVerifyTask( QObject * parent ) : Task( parent ), d( new Private ) {}
767 explicit Private( DecryptVerifyTask* qq ) : q( qq ), m_backend( 0 ), m_protocol( UnknownProtocol ) {}
793 void DecryptVerifyTask::Private::slotResult( const DecryptionResult& dr, const VerificationResult& vr, const QByteArray& plainText )
811 emitResult( q->fromDecryptResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught exception: %1", QString::fromLocal8Bit( e.what() ) ), auditLog ) );
814 emitResult( q->fromDecryptResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught unknown exception"), auditLog ) );
829 DecryptVerifyTask::DecryptVerifyTask( QObject* parent ) : AbstractDecryptVerifyTask( parent ), d( new Private( this ) )
863 throw Exception( gpg_error( GPG_ERR_NOTHING_FOUND ), i18n("Could not determine whether this is an S/MIME or an OpenPGP signature/ciphertext - maybe it is neither ciphertext nor a signature?"), Exception::MessageOnly );
906 d->emitResult( fromDecryptVerifyResult( e.error(), QString::fromLocal8Bit( e.what() ), AuditLog() ) );
908 d->emitResult( fromDecryptVerifyResult( make_error( GPG_ERR_INTERNAL ), i18n( "Caught exception: %1", QString::fromLocal8Bit( e.what() ) ), AuditLog() ) );
910 d->emitResult( fromDecryptVerifyResult( make_error( GPG_ERR_INTERNAL ), i18n( "Caught unknown exception" ), AuditLog() ) );
944 void DecryptTask::Private::slotResult( const DecryptionResult& result, const QByteArray& plainText )
962 emitResult( q->fromDecryptResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught exception: %1", QString::fromLocal8Bit( e.what() ) ), auditLog ) );
965 emitResult( q->fromDecryptResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught unknown exception"), auditLog ) );
980 DecryptTask::DecryptTask( QObject* parent ) : AbstractDecryptVerifyTask( parent ), d( new Private( this ) )
1014 throw Exception( gpg_error( GPG_ERR_NOTHING_FOUND ), i18n("Could not determine whether this was S/MIME- or OpenPGP-encrypted - maybe it is not ciphertext at all?"), Exception::MessageOnly );
1059 d->emitResult( fromDecryptResult( e.error(), QString::fromLocal8Bit( e.what() ), AuditLog() ) );
1061 d->emitResult( fromDecryptResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught exception: %1", QString::fromLocal8Bit( e.what() ) ), AuditLog() ) );
1063 d->emitResult( fromDecryptResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught unknown exception"), AuditLog() ) );
1070 explicit Private( VerifyOpaqueTask* qq ) : q( qq ), m_backend( 0 ), m_protocol( UnknownProtocol ) {}
1096 void VerifyOpaqueTask::Private::slotResult( const VerificationResult& result, const QByteArray& plainText )
1114 emitResult( q->fromDecryptResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught exception: %1", QString::fromLocal8Bit( e.what() ) ), auditLog ) );
1117 emitResult( q->fromDecryptResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught unknown exception"), auditLog ) );
1132 VerifyOpaqueTask::VerifyOpaqueTask( QObject* parent ) : AbstractDecryptVerifyTask( parent ), d( new Private( this ) )
1166 throw Exception( gpg_error( GPG_ERR_NOTHING_FOUND ), i18n("Could not determine whether this is an S/MIME or an OpenPGP signature - maybe it is not a signature at all?"), Exception::MessageOnly );
1208 job->start( d->m_input->ioDevice(), d->m_output ? d->m_output->ioDevice() : shared_ptr<QIODevice>() );
1210 d->emitResult( fromVerifyOpaqueResult( e.error(), QString::fromLocal8Bit( e.what() ), AuditLog() ) );
1212 d->emitResult( fromVerifyOpaqueResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught exception: %1", QString::fromLocal8Bit( e.what() ) ), AuditLog() ) );
1214 d->emitResult( fromVerifyOpaqueResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught unknown exception"), AuditLog() ) );
1221 explicit Private( VerifyDetachedTask* qq ) : q( qq ), m_backend( 0 ), m_protocol( UnknownProtocol ) {}
1258 emitResult( q->fromVerifyDetachedResult( e.error(), QString::fromLocal8Bit( e.what() ), auditLog ) );
1260 emitResult( q->fromVerifyDetachedResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught exception: %1", QString::fromLocal8Bit( e.what() ) ), auditLog ) );
1262 emitResult( q->fromVerifyDetachedResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught unknown exception"), auditLog ) );
1266 VerifyDetachedTask::VerifyDetachedTask( QObject* parent ) : AbstractDecryptVerifyTask( parent ), d( new Private( this ) )
1300 throw Exception( gpg_error( GPG_ERR_NOTHING_FOUND ), i18n("Could not determine whether this is an S/MIME or an OpenPGP signature - maybe it is not a signature at all?"), Exception::MessageOnly );
1344 d->emitResult( fromVerifyDetachedResult( e.error(), QString::fromLocal8Bit( e.what() ), AuditLog() ) );
1346 d->emitResult( fromVerifyDetachedResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught exception: %1", QString::fromLocal8Bit( e.what() ) ), AuditLog() ) );
1348 d->emitResult( fromVerifyDetachedResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught unknown exception"), AuditLog() ) );
void setOutput(const boost::shared_ptr< Output > &output)
Definition: decryptverifytask.cpp:843
void autodetectProtocolFromInput()
Definition: decryptverifytask.cpp:1008
DecryptVerifyTask(QObject *parent=0)
Definition: decryptverifytask.cpp:829
Definition: setinitialpindialog.cpp:55
GpgME::Protocol protocol() const
Definition: decryptverifytask.cpp:887
KMime::Types::Mailbox informativeSender() const
Definition: decryptverifytask.cpp:755
virtual ~AbstractDecryptVerifyTask()
Definition: decryptverifytask.cpp:752
QString type(const GpgME::Key &key)
~VerifyDetachedTask()
Definition: decryptverifytask.cpp:1270
Definition: auditlog.h:48
void autodetectProtocolFromInput()
Definition: decryptverifytask.cpp:857
Definition: task.h:130
int errorCode() const
Definition: decryptverifytask.cpp:708
QString details() const
Definition: decryptverifytask.cpp:692
Definition: task.h:55
DecryptTask(QObject *parent=0)
Definition: decryptverifytask.cpp:980
~VerifyOpaqueTask()
Definition: decryptverifytask.cpp:1136
void setInput(const boost::shared_ptr< Input > &input)
Definition: decryptverifytask.cpp:837
Definition: types.h:48
boost::shared_ptr< DecryptVerifyResult > fromVerifyOpaqueResult(const GpgME::VerificationResult &vr, const QByteArray &plaintext, const AuditLog &auditLog)
static bool is(const QListWidgetItem *item, bool(QFont::*func)() const )
Definition: appearanceconfigwidget.cpp:102
~DecryptVerifyTask()
Definition: decryptverifytask.cpp:833
VerifyOpaqueTask(QObject *parent=0)
Definition: decryptverifytask.cpp:1132
static const GpgME::Key & keyForSignature(const GpgME::Signature &sig, const std::vector< GpgME::Key > &keys)
Definition: decryptverifytask.cpp:733
GpgME::VerificationResult verificationResult() const
Definition: decryptverifytask.cpp:728
Definition: classify.h:49
void setOutput(const boost::shared_ptr< Output > &output)
Definition: decryptverifytask.cpp:994
boost::shared_ptr< DecryptVerifyResult > fromVerifyDetachedResult(const GpgME::VerificationResult &vr, const AuditLog &auditLog)
Definition: types.h:47
void setInput(const boost::shared_ptr< Input > &input)
Definition: decryptverifytask.cpp:1140
Definition: classify.h:48
void setProtocol(GpgME::Protocol prot)
Definition: decryptverifytask.cpp:849
VisualCode code() const
Definition: decryptverifytask.cpp:722
QString overview() const
Definition: decryptverifytask.cpp:680
QString prettyEMail(const char *email, const char *id)
Definition: formatting.cpp:184
void setSignedData(const boost::shared_ptr< Input > &signedData)
Definition: decryptverifytask.cpp:1280
QString errorString() const
Definition: decryptverifytask.cpp:713
bool hasError() const
Definition: decryptverifytask.cpp:703
Definition: decryptverifytask.h:99
void setProgress(const QString &msg, int processed, int total)
Definition: task.cpp:151
GpgME::Protocol protocol() const
Definition: decryptverifytask.cpp:1190
AbstractDecryptVerifyTask(QObject *parent=0)
Definition: decryptverifytask.cpp:750
void setOutput(const boost::shared_ptr< Output > &output)
Definition: decryptverifytask.cpp:1146
void setInput(const boost::shared_ptr< Input > &input)
Definition: decryptverifytask.cpp:1274
boost::shared_ptr< DecryptVerifyResult > fromDecryptResult(const GpgME::DecryptionResult &dr, const QByteArray &plaintext, const AuditLog &auditLog)
Definition: task.h:129
GpgME::Protocol protocol() const
Definition: decryptverifytask.cpp:1324
QString prettyName(int proto, const char *id, const char *name, const char *comment)
Definition: formatting.cpp:64
AuditLog auditLog() const
Definition: decryptverifytask.cpp:718
Definition: task.h:128
static boost::shared_ptr< const KeyCache > instance()
Definition: keycache.cpp:189
void setInput(const boost::shared_ptr< Input > &input)
Definition: decryptverifytask.cpp:988
Definition: types.h:46
boost::shared_ptr< DecryptVerifyResult > fromDecryptVerifyResult(const GpgME::DecryptionResult &dr, const GpgME::VerificationResult &vr, const QByteArray &plaintext, const AuditLog &auditLog)
void setInformativeSender(const KMime::Types::Mailbox &senders)
Definition: decryptverifytask.cpp:760
void setProtocol(GpgME::Protocol prot)
Definition: decryptverifytask.cpp:1286
void autodetectProtocolFromInput()
Definition: decryptverifytask.cpp:1160
void emitResult(const boost::shared_ptr< const Task::Result > &result)
Definition: task.cpp:178
GpgME::Protocol protocol() const
Definition: decryptverifytask.cpp:1038
VerifyDetachedTask(QObject *parent=0)
Definition: decryptverifytask.cpp:1266
void setProtocol(GpgME::Protocol prot)
Definition: decryptverifytask.cpp:1000
void setProtocol(GpgME::Protocol prot)
Definition: decryptverifytask.cpp:1152
ProtocolMask FormatMask TypeMask TypeMask TypeMask GpgME::Protocol findProtocol(const unsigned int classifcation)
Definition: classify.h:127
void autodetectProtocolFromInput()
Definition: decryptverifytask.cpp:1294
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:41 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:41 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.