summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-07-16 10:51:03 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-07-16 10:51:03 +0200
commitcd087aad3182b7cd34f5a45cee4864cf54a69057 (patch)
treedc9cac71c6c62e3ef9af74f0dfa446bf74c356c9
parent0f5eb0a41164177715667e271b01015d4348ab69 (diff)
downloadkube-cd087aad3182b7cd34f5a45cee4864cf54a69057.tar.gz
kube-cd087aad3182b7cd34f5a45cee4864cf54a69057.zip
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.
-rw-r--r--components/mailviewer/qml/MailDataModel.qml4
-rw-r--r--framework/src/domain/mime/partmodel.cpp31
-rw-r--r--framework/src/domain/mime/partmodel.h2
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 {
82 width: Kube.Units.gridUnit 82 width: Kube.Units.gridUnit
83 height: width 83 height: width
84 iconName: Kube.Icons.secure 84 iconName: Kube.Icons.secure
85 color: getColor(model.securityLevel) 85 color: getColor(model.encryptionSecurityLevel)
86 backgroundOpacity: 0.5 86 backgroundOpacity: 0.5
87 visible: model.encrypted 87 visible: model.encrypted
88 tooltip: qsTr("This message is encrypted to the key: %1").arg(model.encryptionDetails.keyId); 88 tooltip: qsTr("This message is encrypted to the key: %1").arg(model.encryptionDetails.keyId);
@@ -98,7 +98,7 @@ DelegateModel {
98 width: Kube.Units.gridUnit 98 width: Kube.Units.gridUnit
99 height: width 99 height: width
100 iconName: Kube.Icons.signed 100 iconName: Kube.Icons.signed
101 color: getColor(model.securityLevel) 101 color: getColor(model.signatureSecurityLevel)
102 backgroundOpacity: 0.5 102 backgroundOpacity: 0.5
103 visible: model.signed 103 visible: model.signed
104 tooltip: getDetails(model.signatureDetails) 104 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<int, QByteArray> PartModel::roleNames() const
85 roles[IsEncryptedRole] = "encrypted"; 85 roles[IsEncryptedRole] = "encrypted";
86 roles[IsSignedRole] = "signed"; 86 roles[IsSignedRole] = "signed";
87 roles[SecurityLevelRole] = "securityLevel"; 87 roles[SecurityLevelRole] = "securityLevel";
88 roles[EncryptionSecurityLevelRole] = "encryptionSecurityLevel";
89 roles[SignatureSecurityLevelRole] = "signatureSecurityLevel";
88 roles[ErrorType] = "errorType"; 90 roles[ErrorType] = "errorType";
89 roles[ErrorString] = "errorString"; 91 roles[ErrorString] = "errorString";
90 roles[IsErrorRole] = "error"; 92 roles[IsErrorRole] = "error";
@@ -281,6 +283,35 @@ QVariant PartModel::data(const QModelIndex &index, int role) const
281 //No info 283 //No info
282 return "unknown"; 284 return "unknown";
283 } 285 }
286 case EncryptionSecurityLevelRole: {
287 auto encryption = messagePart->encryptionState();
288 bool messageIsEncrypted = encryption == MimeTreeParser::KMMsgPartiallyEncrypted ||
289 encryption == MimeTreeParser::KMMsgFullyEncrypted;
290 //All good
291 if (messageIsEncrypted) {
292 return "good";
293 }
294 //No info
295 return "unknown";
296 }
297 case SignatureSecurityLevelRole: {
298 auto signature = messagePart->signatureState();
299 bool messageIsSigned = signature == MimeTreeParser::KMMsgPartiallySigned ||
300 signature == MimeTreeParser::KMMsgFullySigned;
301 if (messageIsSigned) {
302 auto sigInfo = std::unique_ptr<SignatureInfo>{signatureInfo(messagePart)};
303 if (!sigInfo->signatureIsGood) {
304 if (sigInfo->keyMissing || sigInfo->keyExpired) {
305 return "notsogood";
306 }
307 return "bad";
308 }
309 return "good";
310 }
311 //No info
312 return "unknown";
313
314 }
284 case SignatureDetails: 315 case SignatureDetails:
285 return QVariant::fromValue(signatureInfo(messagePart)); 316 return QVariant::fromValue(signatureInfo(messagePart));
286 case EncryptionDetails: 317 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:
45 IsSignedRole, 45 IsSignedRole,
46 IsErrorRole, 46 IsErrorRole,
47 SecurityLevelRole, 47 SecurityLevelRole,
48 EncryptionSecurityLevelRole,
49 SignatureSecurityLevelRole,
48 SignatureDetails, 50 SignatureDetails,
49 EncryptionDetails, 51 EncryptionDetails,
50 ErrorType, 52 ErrorType,