kleopatra
decryptverifytask.cpp
Go to the documentation of this file.
102 static bool addrspec_equal( const AddrSpec & lhs, const AddrSpec & rhs, Qt::CaseSensitivity cs ) {
103 return lhs.localPart.compare( rhs.localPart, cs ) == 0 && lhs.domain.compare( rhs.domain, Qt::CaseInsensitive ) == 0;
166 return std::find_if( mbxs.begin(), mbxs.end(), boost::bind( mailbox_equal, mbox, _1, Qt::CaseInsensitive ) ) != mbxs.end();
170 return std::find_if( keys.begin(), keys.end(), boost::bind( keyContainsMailbox, _1, mbox ) ) != keys.end();
213 return i18n( "The signature is valid but the trust in the certificate's validity is only marginal." );
219 return i18n( "The signature is valid but the certificate's validity is <em>not trusted</em>." );
258 const QDateTime dt = sig.creationTime() != 0 ? QDateTime::fromTime_t( sig.creationTime() ) : QDateTime();
265 return i18n( "Signed on %1 with unknown certificate %2.", formatDate( dt ), renderFingerprint( sig.fingerprint() ) );
286 return QString( strike ? QLatin1String("<s>%1</s>") : QLatin1String("%1") ).arg( Qt::escape( str ) );
289 static QString formatInputOutputLabel( const QString & input, const QString & output, bool inputDeleted, bool outputDeleted ) {
326 explicit SenderInfo( const Mailbox & infSender, const std::vector<Key> & signers_ ) : informativeSender( infSender ), signers( signers_ ) {}
330 bool conflicts() const { return hasInformativeSender() && hasKeys() && !keysContainMailbox( signers, informativeSender ); }
355 static QString formatVerificationResultOverview( const VerificationResult & res, const DecryptVerifyResult::SenderInfo & info ) {
364 return i18n( "<b>Verification failed: %1.</b>", Qt::escape( QString::fromLocal8Bit( err.asString() ) ) );
378 return i18np("<b>Not enough information to check signature validity.</b>", "<b>%1 signatures could not be verified.</b>", warn );
388 text += i18n( "<br/><b>Warning:</b> The sender's mail address is not stored in the %1 used for signing.",
394 text += i18n( "<br/><b>Warning:</b> The sender's mail address is not stored in the certificates used for signing." );
400 static QString formatDecryptionResultOverview( const DecryptionResult & result, const QString& errorString = QString() )
409 return i18n( "<b>Decryption failed: %1.</b>", Qt::escape( QString::fromLocal8Bit( err.asString() ) ) );
413 static QString formatSignature( const Signature & sig, const Key & key, const DecryptVerifyResult::SenderInfo & info ) {
433 std::transform( mbxs.begin(), mbxs.end(), std::back_inserter( res ), boost::bind( &Mailbox::prettyAddress, _1 ) );
437 static QString formatVerificationResultDetails( const VerificationResult & res, const DecryptVerifyResult::SenderInfo & info, const QString& errorString )
439 if( (res.error().code() == GPG_ERR_EIO || res.error().code() == GPG_ERR_NO_DATA) && !errorString.isEmpty() )
446 details += formatSignature( sig, DecryptVerifyResult::keyForSignature( sig, signers ), info ) + QLatin1Char('\n');
450 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", ", " ) ) );
454 static QString formatDecryptionResultDetails( const DecryptionResult & res, const std::vector<Key> & recipients, const QString& errorString )
456 if( (res.error().code() == GPG_ERR_EIO || res.error().code() == GPG_ERR_NO_DATA) && !errorString.isEmpty() )
463 return QLatin1String( "<i>") + i18np( "One unknown recipient.", "%1 unknown recipients.", res.numRecipients() ) + QLatin1String("</i>");
484 static QString formatDecryptVerifyResultOverview( const DecryptionResult & dr, const VerificationResult & vr, const DecryptVerifyResult::SenderInfo & info )
500 return drDetails + ( drDetails.isEmpty() ? QString() : QLatin1String("<br/>") ) + formatVerificationResultDetails( vr, info, errorString );
555 return SenderInfo( m_informativeSender, KeyCache::instance()->findSigners( m_verificationResult ) );
558 shared_ptr<DecryptVerifyResult> AbstractDecryptVerifyTask::fromDecryptResult( const DecryptionResult & dr, const QByteArray & plaintext, const AuditLog & auditLog ) {
572 shared_ptr<DecryptVerifyResult> AbstractDecryptVerifyTask::fromDecryptResult( const GpgME::Error & err, const QString& what, const AuditLog & auditLog ) {
586 shared_ptr<DecryptVerifyResult> AbstractDecryptVerifyTask::fromDecryptVerifyResult( const DecryptionResult & dr, const VerificationResult & vr, const QByteArray & plaintext, const AuditLog & auditLog ) {
600 shared_ptr<DecryptVerifyResult> AbstractDecryptVerifyTask::fromDecryptVerifyResult( const GpgME::Error & err, const QString & details, const AuditLog & auditLog ) {
614 shared_ptr<DecryptVerifyResult> AbstractDecryptVerifyTask::fromVerifyOpaqueResult( const VerificationResult & vr, const QByteArray & plaintext, const AuditLog & auditLog ) {
627 shared_ptr<DecryptVerifyResult> AbstractDecryptVerifyTask::fromVerifyOpaqueResult( const GpgME::Error & err, const QString & details, const AuditLog & auditLog ) {
641 shared_ptr<DecryptVerifyResult> AbstractDecryptVerifyTask::fromVerifyDetachedResult( const VerificationResult & vr, const AuditLog & auditLog ) {
654 shared_ptr<DecryptVerifyResult> AbstractDecryptVerifyTask::fromVerifyDetachedResult( const GpgME::Error & err, const QString & details, const AuditLog & auditLog ) {
678 : Task::Result(), d( new Private( type, vr, dr, stuff, errCode, errString, inputLabel, outputLabel, auditLog, informativeSender, this ) )
690 ov = formatDecryptVerifyResultOverview( d->m_decryptionResult, d->m_verificationResult, d->makeSenderInfo() );
691 return i18nc( "label: result example: foo.sig: Verification failed. ", "%1: %2", d->label(), ov );
697 return formatDecryptionResultDetails( d->m_decryptionResult, KeyCache::instance()->findRecipients( d->m_decryptionResult ), errorString() );
699 return formatVerificationResultDetails( d->m_verificationResult, d->makeSenderInfo(), errorString() );
725 if ( ( d->m_type == DecryptVerify || d->m_type == Verify ) && relevantInDecryptVerifyContext( verificationResult() ) )
735 const Key & DecryptVerifyResult::keyForSignature( const Signature & sig, const std::vector<Key> & keys ) {
752 AbstractDecryptVerifyTask::AbstractDecryptVerifyTask( QObject * parent ) : Task( parent ), d( new Private ) {}
769 explicit Private( DecryptVerifyTask* qq ) : q( qq ), m_backend( 0 ), m_protocol( UnknownProtocol ) {}
795 void DecryptVerifyTask::Private::slotResult( const DecryptionResult& dr, const VerificationResult& vr, const QByteArray& plainText )
813 emitResult( q->fromDecryptResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught exception: %1", QString::fromLocal8Bit( e.what() ) ), auditLog ) );
816 emitResult( q->fromDecryptResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught unknown exception"), auditLog ) );
831 DecryptVerifyTask::DecryptVerifyTask( QObject* parent ) : AbstractDecryptVerifyTask( parent ), d( new Private( this ) )
865 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 );
908 d->emitResult( fromDecryptVerifyResult( e.error(), QString::fromLocal8Bit( e.what() ), AuditLog() ) );
910 d->emitResult( fromDecryptVerifyResult( make_error( GPG_ERR_INTERNAL ), i18n( "Caught exception: %1", QString::fromLocal8Bit( e.what() ) ), AuditLog() ) );
912 d->emitResult( fromDecryptVerifyResult( make_error( GPG_ERR_INTERNAL ), i18n( "Caught unknown exception" ), AuditLog() ) );
946 void DecryptTask::Private::slotResult( const DecryptionResult& result, const QByteArray& plainText )
964 emitResult( q->fromDecryptResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught exception: %1", QString::fromLocal8Bit( e.what() ) ), auditLog ) );
967 emitResult( q->fromDecryptResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught unknown exception"), auditLog ) );
982 DecryptTask::DecryptTask( QObject* parent ) : AbstractDecryptVerifyTask( parent ), d( new Private( this ) )
1016 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 );
1061 d->emitResult( fromDecryptResult( e.error(), QString::fromLocal8Bit( e.what() ), AuditLog() ) );
1063 d->emitResult( fromDecryptResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught exception: %1", QString::fromLocal8Bit( e.what() ) ), AuditLog() ) );
1065 d->emitResult( fromDecryptResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught unknown exception"), AuditLog() ) );
1072 explicit Private( VerifyOpaqueTask* qq ) : q( qq ), m_backend( 0 ), m_protocol( UnknownProtocol ) {}
1098 void VerifyOpaqueTask::Private::slotResult( const VerificationResult& result, const QByteArray& plainText )
1116 emitResult( q->fromDecryptResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught exception: %1", QString::fromLocal8Bit( e.what() ) ), auditLog ) );
1119 emitResult( q->fromDecryptResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught unknown exception"), auditLog ) );
1134 VerifyOpaqueTask::VerifyOpaqueTask( QObject* parent ) : AbstractDecryptVerifyTask( parent ), d( new Private( this ) )
1168 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 );
1210 job->start( d->m_input->ioDevice(), d->m_output ? d->m_output->ioDevice() : shared_ptr<QIODevice>() );
1212 d->emitResult( fromVerifyOpaqueResult( e.error(), QString::fromLocal8Bit( e.what() ), AuditLog() ) );
1214 d->emitResult( fromVerifyOpaqueResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught exception: %1", QString::fromLocal8Bit( e.what() ) ), AuditLog() ) );
1216 d->emitResult( fromVerifyOpaqueResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught unknown exception"), AuditLog() ) );
1223 explicit Private( VerifyDetachedTask* qq ) : q( qq ), m_backend( 0 ), m_protocol( UnknownProtocol ) {}
1260 emitResult( q->fromVerifyDetachedResult( e.error(), QString::fromLocal8Bit( e.what() ), auditLog ) );
1262 emitResult( q->fromVerifyDetachedResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught exception: %1", QString::fromLocal8Bit( e.what() ) ), auditLog ) );
1264 emitResult( q->fromVerifyDetachedResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught unknown exception"), auditLog ) );
1268 VerifyDetachedTask::VerifyDetachedTask( QObject* parent ) : AbstractDecryptVerifyTask( parent ), d( new Private( this ) )
1302 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 );
1346 d->emitResult( fromVerifyDetachedResult( e.error(), QString::fromLocal8Bit( e.what() ), AuditLog() ) );
1348 d->emitResult( fromVerifyDetachedResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught exception: %1", QString::fromLocal8Bit( e.what() ) ), AuditLog() ) );
1350 d->emitResult( fromVerifyDetachedResult( make_error( GPG_ERR_INTERNAL ), i18n("Caught unknown exception"), AuditLog() ) );
void setOutput(const boost::shared_ptr< Output > &output)
Definition: decryptverifytask.cpp:845
void autodetectProtocolFromInput()
Definition: decryptverifytask.cpp:1010
DecryptVerifyTask(QObject *parent=0)
Definition: decryptverifytask.cpp:831
Definition: setinitialpindialog.cpp:57
GpgME::Protocol protocol() const
Definition: decryptverifytask.cpp:889
KMime::Types::Mailbox informativeSender() const
Definition: decryptverifytask.cpp:757
virtual ~AbstractDecryptVerifyTask()
Definition: decryptverifytask.cpp:754
QString type(const GpgME::Key &key)
~VerifyDetachedTask()
Definition: decryptverifytask.cpp:1272
Definition: auditlog.h:48
QObject * sender() const
void autodetectProtocolFromInput()
Definition: decryptverifytask.cpp:859
Definition: task.h:132
int errorCode() const
Definition: decryptverifytask.cpp:710
QString details() const
Definition: decryptverifytask.cpp:694
Definition: task.h:57
DecryptTask(QObject *parent=0)
Definition: decryptverifytask.cpp:982
~VerifyOpaqueTask()
Definition: decryptverifytask.cpp:1138
void setInput(const boost::shared_ptr< Input > &input)
Definition: decryptverifytask.cpp:839
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:103
bool isNull() const
~DecryptVerifyTask()
Definition: decryptverifytask.cpp:835
QDateTime fromTime_t(uint seconds)
VerifyOpaqueTask(QObject *parent=0)
Definition: decryptverifytask.cpp:1134
QString fromLocal8Bit(const char *str, int size)
static const GpgME::Key & keyForSignature(const GpgME::Signature &sig, const std::vector< GpgME::Key > &keys)
Definition: decryptverifytask.cpp:735
GpgME::VerificationResult verificationResult() const
Definition: decryptverifytask.cpp:730
Definition: classify.h:49
void setOutput(const boost::shared_ptr< Output > &output)
Definition: decryptverifytask.cpp:996
bool isEmpty() const
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:1142
Definition: classify.h:48
void setProtocol(GpgME::Protocol prot)
Definition: decryptverifytask.cpp:851
VisualCode code() const
Definition: decryptverifytask.cpp:724
QString overview() const
Definition: decryptverifytask.cpp:682
QString prettyEMail(const char *email, const char *id)
Definition: formatting.cpp:184
void setSignedData(const boost::shared_ptr< Input > &signedData)
Definition: decryptverifytask.cpp:1282
QString errorString() const
Definition: decryptverifytask.cpp:715
bool hasError() const
Definition: decryptverifytask.cpp:705
Definition: decryptverifytask.h:101
void setProgress(const QString &msg, int processed, int total)
Definition: task.cpp:152
GpgME::Protocol protocol() const
Definition: decryptverifytask.cpp:1192
bool isValid() const
AbstractDecryptVerifyTask(QObject *parent=0)
Definition: decryptverifytask.cpp:752
void setOutput(const boost::shared_ptr< Output > &output)
Definition: decryptverifytask.cpp:1148
void setInput(const boost::shared_ptr< Input > &input)
Definition: decryptverifytask.cpp:1276
boost::shared_ptr< DecryptVerifyResult > fromDecryptResult(const GpgME::DecryptionResult &dr, const QByteArray &plaintext, const AuditLog &auditLog)
Definition: task.h:131
QString escape(const QString &plain)
GpgME::Protocol protocol() const
Definition: decryptverifytask.cpp:1326
QString prettyName(int proto, const char *id, const char *name, const char *comment)
Definition: formatting.cpp:64
AuditLog auditLog() const
Definition: decryptverifytask.cpp:720
Definition: task.h:130
static boost::shared_ptr< const KeyCache > instance()
Definition: keycache.cpp:190
QString fromLatin1(const char *str, int size)
void setInput(const boost::shared_ptr< Input > &input)
Definition: decryptverifytask.cpp:990
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:762
void setProtocol(GpgME::Protocol prot)
Definition: decryptverifytask.cpp:1288
void autodetectProtocolFromInput()
Definition: decryptverifytask.cpp:1162
void emitResult(const boost::shared_ptr< const Task::Result > &result)
Definition: task.cpp:179
GpgME::Protocol protocol() const
Definition: decryptverifytask.cpp:1040
VerifyDetachedTask(QObject *parent=0)
Definition: decryptverifytask.cpp:1268
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
void setProtocol(GpgME::Protocol prot)
Definition: decryptverifytask.cpp:1002
void setProtocol(GpgME::Protocol prot)
Definition: decryptverifytask.cpp:1154
ProtocolMask FormatMask TypeMask TypeMask TypeMask GpgME::Protocol findProtocol(const unsigned int classifcation)
Definition: classify.h:127
void autodetectProtocolFromInput()
Definition: decryptverifytask.cpp:1296
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:33:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:33:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.