diff options
Diffstat (limited to 'framework/src/domain/mime/mimetreeparser/messagepart.cpp')
-rw-r--r-- | framework/src/domain/mime/mimetreeparser/messagepart.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/framework/src/domain/mime/mimetreeparser/messagepart.cpp b/framework/src/domain/mime/mimetreeparser/messagepart.cpp index 995ea811..541efd7f 100644 --- a/framework/src/domain/mime/mimetreeparser/messagepart.cpp +++ b/framework/src/domain/mime/mimetreeparser/messagepart.cpp | |||
@@ -979,8 +979,6 @@ void EncryptedMessagePart::startDecryption(const QByteArray &text, const QTextCo | |||
979 | bool EncryptedMessagePart::okDecryptMIME(KMime::Content &data) | 979 | bool EncryptedMessagePart::okDecryptMIME(KMime::Content &data) |
980 | { | 980 | { |
981 | mError = NoError; | 981 | mError = NoError; |
982 | auto passphraseError = false; | ||
983 | auto noSecKey = false; | ||
984 | mMetaData.errorText.clear(); | 982 | mMetaData.errorText.clear(); |
985 | mMetaData.auditLogError = GpgME::Error(); | 983 | mMetaData.auditLogError = GpgME::Error(); |
986 | mMetaData.auditLog.clear(); | 984 | mMetaData.auditLog.clear(); |
@@ -1003,36 +1001,37 @@ bool EncryptedMessagePart::okDecryptMIME(KMime::Content &data) | |||
1003 | } | 1001 | } |
1004 | 1002 | ||
1005 | mDecryptRecipients = decryptResult.recipients(); | 1003 | mDecryptRecipients = decryptResult.recipients(); |
1006 | auto decryptionOk = !decryptResult.error(); | 1004 | if (decryptResult.error() && mMetaData.isSigned) { |
1007 | |||
1008 | if (!decryptionOk && mMetaData.isSigned) { | ||
1009 | //Only a signed part | 1005 | //Only a signed part |
1010 | mMetaData.isEncrypted = false; | 1006 | mMetaData.isEncrypted = false; |
1011 | mDecryptedData = plainText; | 1007 | mDecryptedData = plainText; |
1012 | return true; | 1008 | return true; |
1013 | } | 1009 | } |
1014 | 1010 | ||
1015 | passphraseError = decryptResult.error().isCanceled() || decryptResult.error().code() == GPG_ERR_NO_SECKEY; | ||
1016 | mMetaData.isEncrypted = decryptResult.error().code() != GPG_ERR_NO_DATA; | ||
1017 | mMetaData.errorText = QString::fromLocal8Bit(decryptResult.error().asString()); | ||
1018 | if (mMetaData.isEncrypted && decryptResult.numRecipients() > 0) { | 1011 | if (mMetaData.isEncrypted && decryptResult.numRecipients() > 0) { |
1019 | mMetaData.keyId = decryptResult.recipient(0).keyID(); | 1012 | mMetaData.keyId = decryptResult.recipient(0).keyID(); |
1020 | } | 1013 | } |
1021 | 1014 | ||
1022 | if (decryptionOk) { | 1015 | if (!decryptResult.error()) { |
1023 | mDecryptedData = plainText; | 1016 | mDecryptedData = plainText; |
1024 | setText(QString::fromUtf8(mDecryptedData.constData())); | 1017 | setText(QString::fromUtf8(mDecryptedData.constData())); |
1025 | } else { | 1018 | } else { |
1026 | noSecKey = true; | 1019 | mMetaData.isEncrypted = decryptResult.error().code() != GPG_ERR_NO_DATA; |
1020 | mMetaData.errorText = QString::fromLocal8Bit(decryptResult.error().asString()); | ||
1021 | |||
1022 | std::stringstream ss; | ||
1023 | ss << decryptResult << '\n' << verifyResult; | ||
1024 | qWarning() << "Decryption failed: " << ss.str().c_str(); | ||
1025 | |||
1026 | bool passphraseError = decryptResult.error().isCanceled() || decryptResult.error().code() == GPG_ERR_NO_SECKEY; | ||
1027 | |||
1028 | auto noSecKey = true; | ||
1027 | foreach (const GpgME::DecryptionResult::Recipient &recipient, decryptResult.recipients()) { | 1029 | foreach (const GpgME::DecryptionResult::Recipient &recipient, decryptResult.recipients()) { |
1028 | noSecKey &= (recipient.status().code() == GPG_ERR_NO_SECKEY); | 1030 | noSecKey &= (recipient.status().code() == GPG_ERR_NO_SECKEY); |
1029 | } | 1031 | } |
1030 | if (!passphraseError && !noSecKey) { // GpgME do not detect passphrase error correctly | 1032 | if (!passphraseError && !noSecKey) { // GpgME do not detect passphrase error correctly |
1031 | passphraseError = true; | 1033 | passphraseError = true; |
1032 | } | 1034 | } |
1033 | std::stringstream ss; | ||
1034 | ss << decryptResult << '\n' << verifyResult; | ||
1035 | qWarning() << "Decryption failed: " << ss.str().c_str(); | ||
1036 | 1035 | ||
1037 | if(noSecKey) { | 1036 | if(noSecKey) { |
1038 | mError = NoKeyError; | 1037 | mError = NoKeyError; |