summaryrefslogtreecommitdiffstats
path: root/framework
diff options
context:
space:
mode:
Diffstat (limited to 'framework')
-rw-r--r--framework/qml/MailViewer.qml2
-rw-r--r--framework/src/domain/mime/mimetreeparser/enums.h20
-rw-r--r--framework/src/domain/mime/mimetreeparser/messagepart.cpp28
-rw-r--r--framework/src/domain/mime/mimetreeparser/messagepart.h7
-rw-r--r--framework/src/domain/mime/mimetreeparser/tests/interfacetest.cpp9
-rw-r--r--framework/src/domain/mime/partmodel.cpp4
6 files changed, 52 insertions, 18 deletions
diff --git a/framework/qml/MailViewer.qml b/framework/qml/MailViewer.qml
index ad1ad734..9e14fc7f 100644
--- a/framework/qml/MailViewer.qml
+++ b/framework/qml/MailViewer.qml
@@ -436,7 +436,7 @@ Rectangle {
436 role: "content" 436 role: "content"
437 title: "Content" 437 title: "Content"
438 } 438 }
439 model: messageParser.newTree 439 model: messageParser.parts
440 itemDelegate: Item { 440 itemDelegate: Item {
441 property variant currentData: styleData.value 441 property variant currentData: styleData.value
442 Text { 442 Text {
diff --git a/framework/src/domain/mime/mimetreeparser/enums.h b/framework/src/domain/mime/mimetreeparser/enums.h
index bec5a028..db3af165 100644
--- a/framework/src/domain/mime/mimetreeparser/enums.h
+++ b/framework/src/domain/mime/mimetreeparser/enums.h
@@ -33,20 +33,20 @@ enum UpdateMode {
33 33
34/** Flags for the encryption state. */ 34/** Flags for the encryption state. */
35typedef enum { 35typedef enum {
36 KMMsgEncryptionStateUnknown = ' ', 36 KMMsgEncryptionStateUnknown,
37 KMMsgNotEncrypted = 'N', 37 KMMsgNotEncrypted,
38 KMMsgPartiallyEncrypted = 'P', 38 KMMsgPartiallyEncrypted,
39 KMMsgFullyEncrypted = 'F', 39 KMMsgFullyEncrypted,
40 KMMsgEncryptionProblematic = 'X' 40 KMMsgEncryptionProblematic
41} KMMsgEncryptionState; 41} KMMsgEncryptionState;
42 42
43/** Flags for the signature state. */ 43/** Flags for the signature state. */
44typedef enum { 44typedef enum {
45 KMMsgSignatureStateUnknown = ' ', 45 KMMsgSignatureStateUnknown,
46 KMMsgNotSigned = 'N', 46 KMMsgNotSigned,
47 KMMsgPartiallySigned = 'P', 47 KMMsgPartiallySigned,
48 KMMsgFullySigned = 'F', 48 KMMsgFullySigned,
49 KMMsgSignatureProblematic = 'X' 49 KMMsgSignatureProblematic
50} KMMsgSignatureState; 50} KMMsgSignatureState;
51 51
52} 52}
diff --git a/framework/src/domain/mime/mimetreeparser/messagepart.cpp b/framework/src/domain/mime/mimetreeparser/messagepart.cpp
index b4db4016..00abb003 100644
--- a/framework/src/domain/mime/mimetreeparser/messagepart.cpp
+++ b/framework/src/domain/mime/mimetreeparser/messagepart.cpp
@@ -312,6 +312,22 @@ QVector<EncryptedMessagePart*> MessagePart::encryptions() const
312 return list; 312 return list;
313} 313}
314 314
315KMMsgEncryptionState MessagePart::encryptionState() const
316{
317 if (!encryptions().isEmpty()) {
318 return KMMsgFullyEncrypted;
319 }
320 return KMMsgNotEncrypted;
321}
322
323KMMsgSignatureState MessagePart::signatureState() const
324{
325 if (!signatures().isEmpty()) {
326 return KMMsgFullySigned;
327 }
328 return KMMsgNotSigned;
329}
330
315void MessagePart::bindLifetime(KMime::Content *node) 331void MessagePart::bindLifetime(KMime::Content *node)
316{ 332{
317 mNodesToDelete << node; 333 mNodesToDelete << node;
@@ -346,7 +362,9 @@ QString MessagePartList::htmlContent() const
346//-----TextMessageBlock---------------------- 362//-----TextMessageBlock----------------------
347 363
348TextMessagePart::TextMessagePart(ObjectTreeParser *otp, KMime::Content *node) 364TextMessagePart::TextMessagePart(ObjectTreeParser *otp, KMime::Content *node)
349 : MessagePartList(otp, node) 365 : MessagePartList(otp, node),
366 mSignatureState(KMMsgSignatureStateUnknown),
367 mEncryptionState(KMMsgEncryptionStateUnknown)
350{ 368{
351 if (!mNode) { 369 if (!mNode) {
352 qCWarning(MIMETREEPARSER_LOG) << "not a valid node"; 370 qCWarning(MIMETREEPARSER_LOG) << "not a valid node";
@@ -401,7 +419,6 @@ void TextMessagePart::parseContent()
401 mp->bindLifetime(content); 419 mp->bindLifetime(content);
402 mp->setIsEncrypted(true); 420 mp->setIsEncrypted(true);
403 appendSubPart(mp); 421 appendSubPart(mp);
404 continue;
405 } else if (block.type() == ClearsignedBlock) { 422 } else if (block.type() == ClearsignedBlock) {
406 KMime::Content *content = new KMime::Content; 423 KMime::Content *content = new KMime::Content;
407 content->setBody(block.text()); 424 content->setBody(block.text());
@@ -410,7 +427,6 @@ void TextMessagePart::parseContent()
410 mp->bindLifetime(content); 427 mp->bindLifetime(content);
411 mp->setIsSigned(true); 428 mp->setIsSigned(true);
412 appendSubPart(mp); 429 appendSubPart(mp);
413 continue;
414 } else { 430 } else {
415 continue; 431 continue;
416 } 432 }
@@ -445,11 +461,17 @@ void TextMessagePart::parseContent()
445 461
446KMMsgEncryptionState TextMessagePart::encryptionState() const 462KMMsgEncryptionState TextMessagePart::encryptionState() const
447{ 463{
464 if (mEncryptionState == KMMsgNotEncrypted) {
465 return MessagePart::encryptionState();
466 }
448 return mEncryptionState; 467 return mEncryptionState;
449} 468}
450 469
451KMMsgSignatureState TextMessagePart::signatureState() const 470KMMsgSignatureState TextMessagePart::signatureState() const
452{ 471{
472 if (mSignatureState == KMMsgNotSigned) {
473 return MessagePart::signatureState();
474 }
453 return mSignatureState; 475 return mSignatureState;
454} 476}
455 477
diff --git a/framework/src/domain/mime/mimetreeparser/messagepart.h b/framework/src/domain/mime/mimetreeparser/messagepart.h
index 9fe34c3b..dd3a842f 100644
--- a/framework/src/domain/mime/mimetreeparser/messagepart.h
+++ b/framework/src/domain/mime/mimetreeparser/messagepart.h
@@ -112,6 +112,9 @@ public:
112 112
113 KMime::Content *node() const; 113 KMime::Content *node() const;
114 114
115 virtual KMMsgSignatureState signatureState() const;
116 virtual KMMsgEncryptionState encryptionState() const;
117
115 QVector<SignedMessagePart*> signatures() const; 118 QVector<SignedMessagePart*> signatures() const;
116 QVector<EncryptedMessagePart*> encryptions() const; 119 QVector<EncryptedMessagePart*> encryptions() const;
117 120
@@ -178,8 +181,8 @@ public:
178 TextMessagePart(MimeTreeParser::ObjectTreeParser *otp, KMime::Content *node); 181 TextMessagePart(MimeTreeParser::ObjectTreeParser *otp, KMime::Content *node);
179 virtual ~TextMessagePart(); 182 virtual ~TextMessagePart();
180 183
181 KMMsgSignatureState signatureState() const; 184 KMMsgSignatureState signatureState() const Q_DECL_OVERRIDE;
182 KMMsgEncryptionState encryptionState() const; 185 KMMsgEncryptionState encryptionState() const Q_DECL_OVERRIDE;
183 186
184private: 187private:
185 void parseContent(); 188 void parseContent();
diff --git a/framework/src/domain/mime/mimetreeparser/tests/interfacetest.cpp b/framework/src/domain/mime/mimetreeparser/tests/interfacetest.cpp
index 74f12eec..f9b557c9 100644
--- a/framework/src/domain/mime/mimetreeparser/tests/interfacetest.cpp
+++ b/framework/src/domain/mime/mimetreeparser/tests/interfacetest.cpp
@@ -125,16 +125,22 @@ private slots:
125 QCOMPARE(part->charset(), QStringLiteral("us-ascii").toLocal8Bit()); 125 QCOMPARE(part->charset(), QStringLiteral("us-ascii").toLocal8Bit());
126 QCOMPARE(part->encryptions().size(), 1); 126 QCOMPARE(part->encryptions().size(), 1);
127 QCOMPARE(part->signatures().size(), 1); 127 QCOMPARE(part->signatures().size(), 1);
128 QCOMPARE(part->encryptionState(), MimeTreeParser::KMMsgFullyEncrypted);
129 QCOMPARE(part->signatureState(), MimeTreeParser::KMMsgFullySigned);
128 auto contentAttachmentList = otp.collectAttachmentParts(); 130 auto contentAttachmentList = otp.collectAttachmentParts();
129 QCOMPARE(contentAttachmentList.size(), 2); 131 QCOMPARE(contentAttachmentList.size(), 2);
130 // QCOMPARE(contentAttachmentList[0]->availableContents(), QVector<QByteArray>() << "text/plain"); 132 // QCOMPARE(contentAttachmentList[0]->availableContents(), QVector<QByteArray>() << "text/plain");
131 // QCOMPARE(contentAttachmentList[0]->content().size(), 1); 133 // QCOMPARE(contentAttachmentList[0]->content().size(), 1);
132 QCOMPARE(contentAttachmentList[0]->encryptions().size(), 1); 134 QCOMPARE(contentAttachmentList[0]->encryptions().size(), 1);
133 QCOMPARE(contentAttachmentList[0]->signatures().size(), 1); 135 QCOMPARE(contentAttachmentList[0]->signatures().size(), 1);
136 QCOMPARE(contentAttachmentList[0]->encryptionState(), MimeTreeParser::KMMsgFullyEncrypted);
137 QCOMPARE(contentAttachmentList[0]->signatureState(), MimeTreeParser::KMMsgFullySigned);
134 // QCOMPARE(contentAttachmentList[1]->availableContents(), QVector<QByteArray>() << "image/png"); 138 // QCOMPARE(contentAttachmentList[1]->availableContents(), QVector<QByteArray>() << "image/png");
135 // QCOMPARE(contentAttachmentList[1]->content().size(), 1); 139 // QCOMPARE(contentAttachmentList[1]->content().size(), 1);
136 QCOMPARE(contentAttachmentList[1]->encryptions().size(), 0); 140 QCOMPARE(contentAttachmentList[1]->encryptions().size(), 0);
137 QCOMPARE(contentAttachmentList[1]->signatures().size(), 0); 141 QCOMPARE(contentAttachmentList[1]->signatures().size(), 0);
142 QCOMPARE(contentAttachmentList[1]->encryptionState(), MimeTreeParser::KMMsgNotEncrypted);
143 QCOMPARE(contentAttachmentList[1]->signatureState(), MimeTreeParser::KMMsgNotSigned);
138 } 144 }
139 145
140 void testOpenPGPInline() 146 void testOpenPGPInline()
@@ -173,6 +179,9 @@ private slots:
173 //TODO test if we get the proper subparts with the appropriate encryptions 179 //TODO test if we get the proper subparts with the appropriate encryptions
174 QCOMPARE(part1->charset(), QStringLiteral("us-ascii").toLocal8Bit()); 180 QCOMPARE(part1->charset(), QStringLiteral("us-ascii").toLocal8Bit());
175 181
182 QCOMPARE(part1->encryptionState(), MimeTreeParser::KMMsgPartiallyEncrypted);
183 QCOMPARE(part1->signatureState(), MimeTreeParser::KMMsgNotSigned);
184
176 // QCOMPARE(part1->text(), QStringLiteral("Not encrypted not signed :(\n\n")); 185 // QCOMPARE(part1->text(), QStringLiteral("Not encrypted not signed :(\n\n"));
177 // QCOMPARE(part1->charset(), QStringLiteral("us-ascii").toLocal8Bit()); 186 // QCOMPARE(part1->charset(), QStringLiteral("us-ascii").toLocal8Bit());
178 // QCOMPARE(contentList[1]->content(), QStringLiteral("some random text").toLocal8Bit()); 187 // QCOMPARE(contentList[1]->content(), QStringLiteral("some random text").toLocal8Bit());
diff --git a/framework/src/domain/mime/partmodel.cpp b/framework/src/domain/mime/partmodel.cpp
index b86251ef..ea3e90e1 100644
--- a/framework/src/domain/mime/partmodel.cpp
+++ b/framework/src/domain/mime/partmodel.cpp
@@ -151,9 +151,9 @@ QVariant PartModel::data(const QModelIndex &index, int role) const
151 return text; 151 return text;
152 } 152 }
153 case IsEncryptedRole: 153 case IsEncryptedRole:
154 return messagePart->encryptions().size() > 0; 154 return messagePart->encryptionState() != MimeTreeParser::KMMsgNotEncrypted;
155 case IsSignedRole: 155 case IsSignedRole:
156 return messagePart->signatures().size() > 0; 156 return messagePart->signatureState() != MimeTreeParser::KMMsgNotSigned;
157 case EncryptionErrorType: 157 case EncryptionErrorType:
158 return messagePart->error(); 158 return messagePart->error();
159 case EncryptionErrorString: 159 case EncryptionErrorString: