diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-08-26 14:32:09 -0600 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-08-26 14:32:09 -0600 |
commit | dd6348e1a98407b91f6758a38f42d849274866a3 (patch) | |
tree | 46770bfdfd92e92f53f3c95f4583a30d7f56134f /framework/src | |
parent | 66b8dcd5b49c63d0994dacb198972277d3d5063a (diff) | |
download | kube-dd6348e1a98407b91f6758a38f42d849274866a3.tar.gz kube-dd6348e1a98407b91f6758a38f42d849274866a3.zip |
Assign a color depending on the encryption/signature state.
Diffstat (limited to 'framework/src')
-rw-r--r-- | framework/src/domain/mime/partmodel.cpp | 31 | ||||
-rw-r--r-- | framework/src/domain/mime/partmodel.h | 4 |
2 files changed, 29 insertions, 6 deletions
diff --git a/framework/src/domain/mime/partmodel.cpp b/framework/src/domain/mime/partmodel.cpp index de6c89c3..9f802375 100644 --- a/framework/src/domain/mime/partmodel.cpp +++ b/framework/src/domain/mime/partmodel.cpp | |||
@@ -86,8 +86,8 @@ QHash<int, QByteArray> PartModel::roleNames() const | |||
86 | roles[IsEncryptedRole] = "encrypted"; | 86 | roles[IsEncryptedRole] = "encrypted"; |
87 | roles[IsSignedRole] = "signed"; | 87 | roles[IsSignedRole] = "signed"; |
88 | roles[SecurityLevelRole] = "securityLevel"; | 88 | roles[SecurityLevelRole] = "securityLevel"; |
89 | roles[EncryptionErrorType] = "errorType"; | 89 | roles[ErrorType] = "errorType"; |
90 | roles[EncryptionErrorString] = "errorString"; | 90 | roles[ErrorString] = "errorString"; |
91 | roles[IsErrorRole] = "error"; | 91 | roles[IsErrorRole] = "error"; |
92 | roles[SenderRole] = "sender"; | 92 | roles[SenderRole] = "sender"; |
93 | roles[DateRole] = "date"; | 93 | roles[DateRole] = "date"; |
@@ -209,9 +209,32 @@ QVariant PartModel::data(const QModelIndex &index, int role) const | |||
209 | return messagePart->encryptionState() != MimeTreeParser::KMMsgNotEncrypted; | 209 | return messagePart->encryptionState() != MimeTreeParser::KMMsgNotEncrypted; |
210 | case IsSignedRole: | 210 | case IsSignedRole: |
211 | return messagePart->signatureState() != MimeTreeParser::KMMsgNotSigned; | 211 | return messagePart->signatureState() != MimeTreeParser::KMMsgNotSigned; |
212 | case EncryptionErrorType: | 212 | case SecurityLevelRole: { |
213 | auto signature = messagePart->signatureState(); | ||
214 | auto encryption = messagePart->encryptionState(); | ||
215 | bool signatureIsOk = signature == MimeTreeParser::KMMsgPartiallySigned || | ||
216 | signature == MimeTreeParser::KMMsgFullySigned; | ||
217 | bool encryptionIsOk = encryption == MimeTreeParser::KMMsgPartiallyEncrypted || | ||
218 | encryption == MimeTreeParser::KMMsgFullyEncrypted; | ||
219 | bool isSigned = signature != MimeTreeParser::KMMsgNotSigned; | ||
220 | bool isEncrypted = encryption != MimeTreeParser::KMMsgNotEncrypted; | ||
221 | //Something is wonky | ||
222 | if ((isSigned && !signatureIsOk) || (isEncrypted && !encryptionIsOk)) { | ||
223 | if (signature == MimeTreeParser::KMMsgSignatureProblematic || encryption == MimeTreeParser::KMMsgEncryptionProblematic) { | ||
224 | return "bad"; | ||
225 | } | ||
226 | return "notsogood"; | ||
227 | } | ||
228 | //All good | ||
229 | if (signatureIsOk || encryptionIsOk) { | ||
230 | return "good"; | ||
231 | } | ||
232 | //No info | ||
233 | return "unknown"; | ||
234 | } | ||
235 | case ErrorType: | ||
213 | return messagePart->error(); | 236 | return messagePart->error(); |
214 | case EncryptionErrorString: { | 237 | case ErrorString: { |
215 | switch (messagePart->error()) { | 238 | switch (messagePart->error()) { |
216 | case MimeTreeParser::MessagePart::NoKeyError: | 239 | case MimeTreeParser::MessagePart::NoKeyError: |
217 | return tr("No key available."); | 240 | return tr("No key available."); |
diff --git a/framework/src/domain/mime/partmodel.h b/framework/src/domain/mime/partmodel.h index a0e14b61..318450a5 100644 --- a/framework/src/domain/mime/partmodel.h +++ b/framework/src/domain/mime/partmodel.h | |||
@@ -46,8 +46,8 @@ public: | |||
46 | IsSignedRole, | 46 | IsSignedRole, |
47 | IsErrorRole, | 47 | IsErrorRole, |
48 | SecurityLevelRole, | 48 | SecurityLevelRole, |
49 | EncryptionErrorType, | 49 | ErrorType, |
50 | EncryptionErrorString, | 50 | ErrorString, |
51 | SenderRole, | 51 | SenderRole, |
52 | DateRole | 52 | DateRole |
53 | }; | 53 | }; |