summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandro Knauß <[email protected]>2016-04-10 14:50:11 +0200
committerSandro Knauß <[email protected]>2016-04-10 20:35:58 +0200
commit007b10e8fa682eea37765d2e6a7aa21ea17825d8 (patch)
tree0274141917d63f60354c35ffb3b4f4dd1252baa3
parentb2e3b990ca97edf36322dad9ea0c854f10545482 (diff)
Get rid of usage MessageCore::NodeHelper::nextSibling
-rw-r--r--mimetreeparser/src/CMakeLists.txt2
-rw-r--r--mimetreeparser/src/viewer/nodehelper.cpp60
2 files changed, 36 insertions, 26 deletions
diff --git a/mimetreeparser/src/CMakeLists.txt b/mimetreeparser/src/CMakeLists.txt
index 85f0e39..15a943e 100644
--- a/mimetreeparser/src/CMakeLists.txt
+++ b/mimetreeparser/src/CMakeLists.txt
@@ -160,7 +160,7 @@ add_library(KF5::MimeTreeParser ALIAS KF5MimeTreeParser)
target_link_libraries(KF5MimeTreeParser
PUBLIC
- KF5::MessageCore #NodeHelper, StringUtils
+ KF5::MessageCore #StringUtils
KF5::Libkleo
PRIVATE
KF5::Codecs
diff --git a/mimetreeparser/src/viewer/nodehelper.cpp b/mimetreeparser/src/viewer/nodehelper.cpp
index 321dc08..8c1eab5 100644
--- a/mimetreeparser/src/viewer/nodehelper.cpp
+++ b/mimetreeparser/src/viewer/nodehelper.cpp
@@ -355,20 +355,25 @@ KMMsgEncryptionState NodeHelper::overallEncryptionState(KMime::Content *node) co
return myState;
}
- if (encryptionState(node) == KMMsgNotEncrypted) {
+ KMime::Content *parent = node->parent();
+ auto contents = parent ? parent->contents(): KMime::Content::List();
+ if (contents.isEmpty()) {
+ contents.append(node);
+ }
+ int i = contents.indexOf(const_cast<KMime::Content *>(node));
+ for (; i < contents.size(); ++i) {
+ auto next = contents.at(i);
+ KMMsgEncryptionState otherState = encryptionState(next);
+
// NOTE: children are tested ONLY when parent is not encrypted
- if (!node->contents().isEmpty()) {
- myState = overallEncryptionState(node->contents().at(0));
- } else {
- myState = KMMsgNotEncrypted;
+ if (otherState == KMMsgNotEncrypted && !next->contents().isEmpty()) {
+ otherState = overallEncryptionState(next->contents().at(0));
}
- } else { // part is partially or fully encrypted
- myState = encryptionState(node);
- }
- // siblings are tested always
- KMime::Content *next = MessageCore::NodeHelper::nextSibling(node);
- if (next) {
- KMMsgEncryptionState otherState = overallEncryptionState(next);
+
+ if (next == node) {
+ myState = otherState;
+ }
+
switch (otherState) {
case KMMsgEncryptionStateUnknown:
break;
@@ -404,20 +409,25 @@ KMMsgSignatureState NodeHelper::overallSignatureState(KMime::Content *node) cons
return myState;
}
- if (signatureState(node) == KMMsgNotSigned) {
- // children are tested ONLY when parent is not signed
- if (!node->contents().isEmpty()) {
- myState = overallSignatureState(node->contents().at(0));
- } else {
- myState = KMMsgNotSigned;
- }
- } else { // part is partially or fully signed
- myState = signatureState(node);
+ KMime::Content *parent = node->parent();
+ auto contents = parent ? parent->contents(): KMime::Content::List();
+ if (contents.isEmpty()) {
+ contents.append(node);
}
- // siblings are tested always
- KMime::Content *next = MessageCore::NodeHelper::nextSibling(node);
- if (next) {
- KMMsgSignatureState otherState = overallSignatureState(next);
+ int i = contents.indexOf(const_cast<KMime::Content *>(node));
+ for (; i < contents.size(); ++i) {
+ auto next = contents.at(i);
+ KMMsgSignatureState otherState = signatureState(next);
+
+ // NOTE: children are tested ONLY when parent is not encrypted
+ if (otherState == KMMsgNotSigned && !next->contents().isEmpty()) {
+ otherState = overallSignatureState(next->contents().at(0));
+ }
+
+ if (next == node) {
+ myState = otherState;
+ }
+
switch (otherState) {
case KMMsgSignatureStateUnknown:
break;