| 176 | } |
| 177 | |
| 178 | std::pair<KMessageWidget::MessageType, QString> documentSignatureMessageWidgetText(const Okular::Document *doc) |
| 179 | { |
| 180 | uint curPage = 0; |
| 181 | const uint numPages = doc->pages(); |
| 182 | bool isDigitallySigned = false; |
| 183 | while (curPage < numPages && !isDigitallySigned) { |
| 184 | const QList<Okular::FormField *> formFields = doc->page(curPage++)->formFields(); |
| 185 | for (const Okular::FormField *f : formFields) { |
| 186 | if (f->type() == Okular::FormField::FormSignature) { |
| 187 | isDigitallySigned = true; |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | if (isDigitallySigned) { |
| 193 | const QList<const Okular::FormFieldSignature *> signatureFormFields = SignatureGuiUtils::getSignatureFormFields(doc); |
| 194 | bool allSignaturesValid = true; |
| 195 | bool anySignatureUnsigned = false; |
| 196 | for (const Okular::FormFieldSignature *signature : signatureFormFields) { |
| 197 | if (signature->signatureType() == Okular::FormFieldSignature::UnsignedSignature) { |
| 198 | anySignatureUnsigned = true; |
| 199 | } else { |
| 200 | const Okular::SignatureInfo &info = signature->signatureInfo(); |
| 201 | if (info.signatureStatus() != Okular::SignatureInfo::SignatureValid) { |
| 202 | allSignaturesValid = false; |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | if (anySignatureUnsigned) { |
| 208 | return {KMessageWidget::Information, i18nc("Digital signature", "This document has signature placeholder fields.")}; |
| 209 | } else if (allSignaturesValid) { |
| 210 | if (signatureFormFields.last()->signatureInfo().signsTotalDocument()) { |
| 211 | return {KMessageWidget::Information, i18n("This document is digitally signed.")}; |
| 212 | } else { |
| 213 | return {KMessageWidget::Warning, i18n("This document is digitally signed. There have been changes since last signed.")}; |
| 214 | } |
| 215 | } else { |
| 216 | return {KMessageWidget::Warning, i18n("This document is digitally signed. Some of the signatures could not be validated properly.")}; |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | return {KMessageWidget::Information, QString()}; |
| 221 | } |
| 222 | } |
no test coverage detected