From cd087aad3182b7cd34f5a45cee4864cf54a69057 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 16 Jul 2018 10:51:03 +0200 Subject: Separated colors for encryption and signature. Typically we have a good encryption and potentialyl a problem with the signature. It's weird if there is a problem with the encryption indicated, while there isn't actually one. --- components/mailviewer/qml/MailDataModel.qml | 4 ++-- framework/src/domain/mime/partmodel.cpp | 31 +++++++++++++++++++++++++++++ framework/src/domain/mime/partmodel.h | 2 ++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/components/mailviewer/qml/MailDataModel.qml b/components/mailviewer/qml/MailDataModel.qml index ab63e8f5..279c0e95 100644 --- a/components/mailviewer/qml/MailDataModel.qml +++ b/components/mailviewer/qml/MailDataModel.qml @@ -82,7 +82,7 @@ DelegateModel { width: Kube.Units.gridUnit height: width iconName: Kube.Icons.secure - color: getColor(model.securityLevel) + color: getColor(model.encryptionSecurityLevel) backgroundOpacity: 0.5 visible: model.encrypted tooltip: qsTr("This message is encrypted to the key: %1").arg(model.encryptionDetails.keyId); @@ -98,7 +98,7 @@ DelegateModel { width: Kube.Units.gridUnit height: width iconName: Kube.Icons.signed - color: getColor(model.securityLevel) + color: getColor(model.signatureSecurityLevel) backgroundOpacity: 0.5 visible: model.signed tooltip: getDetails(model.signatureDetails) diff --git a/framework/src/domain/mime/partmodel.cpp b/framework/src/domain/mime/partmodel.cpp index ca8856fd..02ef2f6d 100644 --- a/framework/src/domain/mime/partmodel.cpp +++ b/framework/src/domain/mime/partmodel.cpp @@ -85,6 +85,8 @@ QHash PartModel::roleNames() const roles[IsEncryptedRole] = "encrypted"; roles[IsSignedRole] = "signed"; roles[SecurityLevelRole] = "securityLevel"; + roles[EncryptionSecurityLevelRole] = "encryptionSecurityLevel"; + roles[SignatureSecurityLevelRole] = "signatureSecurityLevel"; roles[ErrorType] = "errorType"; roles[ErrorString] = "errorString"; roles[IsErrorRole] = "error"; @@ -281,6 +283,35 @@ QVariant PartModel::data(const QModelIndex &index, int role) const //No info return "unknown"; } + case EncryptionSecurityLevelRole: { + auto encryption = messagePart->encryptionState(); + bool messageIsEncrypted = encryption == MimeTreeParser::KMMsgPartiallyEncrypted || + encryption == MimeTreeParser::KMMsgFullyEncrypted; + //All good + if (messageIsEncrypted) { + return "good"; + } + //No info + return "unknown"; + } + case SignatureSecurityLevelRole: { + auto signature = messagePart->signatureState(); + bool messageIsSigned = signature == MimeTreeParser::KMMsgPartiallySigned || + signature == MimeTreeParser::KMMsgFullySigned; + if (messageIsSigned) { + auto sigInfo = std::unique_ptr{signatureInfo(messagePart)}; + if (!sigInfo->signatureIsGood) { + if (sigInfo->keyMissing || sigInfo->keyExpired) { + return "notsogood"; + } + return "bad"; + } + return "good"; + } + //No info + return "unknown"; + + } case SignatureDetails: return QVariant::fromValue(signatureInfo(messagePart)); case EncryptionDetails: diff --git a/framework/src/domain/mime/partmodel.h b/framework/src/domain/mime/partmodel.h index 0c8a133d..945fda12 100644 --- a/framework/src/domain/mime/partmodel.h +++ b/framework/src/domain/mime/partmodel.h @@ -45,6 +45,8 @@ public: IsSignedRole, IsErrorRole, SecurityLevelRole, + EncryptionSecurityLevelRole, + SignatureSecurityLevelRole, SignatureDetails, EncryptionDetails, ErrorType, -- cgit v1.2.3