From dd6348e1a98407b91f6758a38f42d849274866a3 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 26 Aug 2017 14:32:09 -0600 Subject: Assign a color depending on the encryption/signature state. --- framework/src/domain/mime/partmodel.cpp | 31 +++++++++++++++++++++++++++---- framework/src/domain/mime/partmodel.h | 4 ++-- 2 files changed, 29 insertions(+), 6 deletions(-) (limited to 'framework/src/domain') 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 PartModel::roleNames() const roles[IsEncryptedRole] = "encrypted"; roles[IsSignedRole] = "signed"; roles[SecurityLevelRole] = "securityLevel"; - roles[EncryptionErrorType] = "errorType"; - roles[EncryptionErrorString] = "errorString"; + roles[ErrorType] = "errorType"; + roles[ErrorString] = "errorString"; roles[IsErrorRole] = "error"; roles[SenderRole] = "sender"; roles[DateRole] = "date"; @@ -209,9 +209,32 @@ QVariant PartModel::data(const QModelIndex &index, int role) const return messagePart->encryptionState() != MimeTreeParser::KMMsgNotEncrypted; case IsSignedRole: return messagePart->signatureState() != MimeTreeParser::KMMsgNotSigned; - case EncryptionErrorType: + case SecurityLevelRole: { + auto signature = messagePart->signatureState(); + auto encryption = messagePart->encryptionState(); + bool signatureIsOk = signature == MimeTreeParser::KMMsgPartiallySigned || + signature == MimeTreeParser::KMMsgFullySigned; + bool encryptionIsOk = encryption == MimeTreeParser::KMMsgPartiallyEncrypted || + encryption == MimeTreeParser::KMMsgFullyEncrypted; + bool isSigned = signature != MimeTreeParser::KMMsgNotSigned; + bool isEncrypted = encryption != MimeTreeParser::KMMsgNotEncrypted; + //Something is wonky + if ((isSigned && !signatureIsOk) || (isEncrypted && !encryptionIsOk)) { + if (signature == MimeTreeParser::KMMsgSignatureProblematic || encryption == MimeTreeParser::KMMsgEncryptionProblematic) { + return "bad"; + } + return "notsogood"; + } + //All good + if (signatureIsOk || encryptionIsOk) { + return "good"; + } + //No info + return "unknown"; + } + case ErrorType: return messagePart->error(); - case EncryptionErrorString: { + case ErrorString: { switch (messagePart->error()) { case MimeTreeParser::MessagePart::NoKeyError: 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: IsSignedRole, IsErrorRole, SecurityLevelRole, - EncryptionErrorType, - EncryptionErrorString, + ErrorType, + ErrorString, SenderRole, DateRole }; -- cgit v1.2.3