summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-08-26 14:32:09 -0600
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-08-26 14:32:09 -0600
commitdd6348e1a98407b91f6758a38f42d849274866a3 (patch)
tree46770bfdfd92e92f53f3c95f4583a30d7f56134f
parent66b8dcd5b49c63d0994dacb198972277d3d5063a (diff)
downloadkube-dd6348e1a98407b91f6758a38f42d849274866a3.tar.gz
kube-dd6348e1a98407b91f6758a38f42d849274866a3.zip
Assign a color depending on the encryption/signature state.
-rw-r--r--components/mailviewer/contents/ui/MailDataModel.qml16
-rw-r--r--components/mailviewer/contents/ui/MailPart.qml2
-rw-r--r--framework/qml/Colors.qml1
-rw-r--r--framework/src/domain/mime/partmodel.cpp31
-rw-r--r--framework/src/domain/mime/partmodel.h4
5 files changed, 46 insertions, 8 deletions
diff --git a/components/mailviewer/contents/ui/MailDataModel.qml b/components/mailviewer/contents/ui/MailDataModel.qml
index 0f64972c..bc2fdc58 100644
--- a/components/mailviewer/contents/ui/MailDataModel.qml
+++ b/components/mailviewer/contents/ui/MailDataModel.qml
@@ -29,6 +29,20 @@ DelegateModel {
29 width: parent.width 29 width: parent.width
30 height: childrenRect.height 30 height: childrenRect.height
31 31
32 function getColor(securityLevel)
33 {
34 if (securityLevel == "good") {
35 return Kube.Colors.positiveColor
36 }
37 if (securityLevel == "bad") {
38 return Kube.Colors.negativeColor
39 }
40 if (securityLevel == "notsogood") {
41 return Kube.Colors.warningColor
42 }
43 return Kube.Colors.lightgrey
44 }
45
32 Row { 46 Row {
33 anchors { 47 anchors {
34 top: parent.top 48 top: parent.top
@@ -45,7 +59,7 @@ DelegateModel {
45 bottom: parent.bottom 59 bottom: parent.bottom
46 } 60 }
47 width: Kube.Units.smallSpacing 61 width: Kube.Units.smallSpacing
48 color: Kube.Colors.positiveColor 62 color: getColor(model.securityLevel)
49 opacity: 0.5 63 opacity: 0.5
50 } 64 }
51 65
diff --git a/components/mailviewer/contents/ui/MailPart.qml b/components/mailviewer/contents/ui/MailPart.qml
index 3dbca1d4..4fa2bd73 100644
--- a/components/mailviewer/contents/ui/MailPart.qml
+++ b/components/mailviewer/contents/ui/MailPart.qml
@@ -39,7 +39,7 @@ Item {
39 left: parent.left 39 left: parent.left
40 leftMargin: Kube.Units.smallSpacing 40 leftMargin: Kube.Units.smallSpacing
41 } 41 }
42 color: "lightgrey" 42 color: Kube.Colors.lightgrey
43 height: partListView.height 43 height: partListView.height
44 width: Kube.Units.smallSpacing 44 width: Kube.Units.smallSpacing
45 } 45 }
diff --git a/framework/qml/Colors.qml b/framework/qml/Colors.qml
index b0be7569..ec9a09bf 100644
--- a/framework/qml/Colors.qml
+++ b/framework/qml/Colors.qml
@@ -34,6 +34,7 @@ Item {
34 property string bewareOrange: "#f67400" 34 property string bewareOrange: "#f67400"
35 property string dangerRed: "#ed1515" 35 property string dangerRed: "#ed1515"
36 property string darkCharcoalGrey: "#232629" 36 property string darkCharcoalGrey: "#232629"
37 property string lightgrey: "lightgrey"
37 38
38 //Colorusage: 39 //Colorusage:
39 property string textColor: charcoalGrey 40 property string textColor: charcoalGrey
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 };