diff options
Diffstat (limited to 'framework/src/domain/mime/mimetreeparser/messagepart.cpp')
-rw-r--r-- | framework/src/domain/mime/mimetreeparser/messagepart.cpp | 132 |
1 files changed, 65 insertions, 67 deletions
diff --git a/framework/src/domain/mime/mimetreeparser/messagepart.cpp b/framework/src/domain/mime/mimetreeparser/messagepart.cpp index 2c95864c..2f399226 100644 --- a/framework/src/domain/mime/mimetreeparser/messagepart.cpp +++ b/framework/src/domain/mime/mimetreeparser/messagepart.cpp | |||
@@ -819,81 +819,79 @@ QString prettifyDN(const char *uid) | |||
819 | void SignedMessagePart::sigStatusToMetaData() | 819 | void SignedMessagePart::sigStatusToMetaData() |
820 | { | 820 | { |
821 | GpgME::Key key; | 821 | GpgME::Key key; |
822 | if (mMetaData.isSigned) { | 822 | GpgME::Signature signature = mSignatures.front(); |
823 | GpgME::Signature signature = mSignatures.front(); | 823 | mMetaData.status_code = signatureToStatus(signature); |
824 | mMetaData.status_code = signatureToStatus(signature); | 824 | mMetaData.isGoodSignature = mMetaData.status_code & GPGME_SIG_STAT_GOOD; |
825 | mMetaData.isGoodSignature = mMetaData.status_code & GPGME_SIG_STAT_GOOD; | 825 | // save extended signature status flags |
826 | // save extended signature status flags | 826 | mMetaData.sigSummary = signature.summary(); |
827 | mMetaData.sigSummary = signature.summary(); | 827 | |
828 | 828 | if (mMetaData.isGoodSignature && !key.keyID()) { | |
829 | if (mMetaData.isGoodSignature && !key.keyID()) { | 829 | // Search for the key by its fingerprint so that we can check for |
830 | // Search for the key by its fingerprint so that we can check for | 830 | // trust etc. |
831 | // trust etc. | 831 | QGpgME::KeyListJob *job = mCryptoProto->keyListJob(false); // local, no sigs |
832 | QGpgME::KeyListJob *job = mCryptoProto->keyListJob(false); // local, no sigs | 832 | if (!job) { |
833 | if (!job) { | 833 | qCDebug(MIMETREEPARSER_LOG) << "The Crypto backend does not support listing keys. "; |
834 | qCDebug(MIMETREEPARSER_LOG) << "The Crypto backend does not support listing keys. "; | 834 | } else { |
835 | std::vector<GpgME::Key> found_keys; | ||
836 | // As we are local it is ok to make this synchronous | ||
837 | GpgME::KeyListResult res = job->exec(QStringList(QLatin1String(signature.fingerprint())), false, found_keys); | ||
838 | if (res.error()) { | ||
839 | qCDebug(MIMETREEPARSER_LOG) << "Error while searching key for Fingerprint: " << signature.fingerprint(); | ||
840 | } | ||
841 | if (found_keys.size() > 1) { | ||
842 | // Should not happen | ||
843 | qCDebug(MIMETREEPARSER_LOG) << "Oops: Found more then one Key for Fingerprint: " << signature.fingerprint(); | ||
844 | } | ||
845 | if (found_keys.empty()) { | ||
846 | // Should not happen at this point | ||
847 | qCWarning(MIMETREEPARSER_LOG) << "Oops: Found no Key for Fingerprint: " << signature.fingerprint(); | ||
835 | } else { | 848 | } else { |
836 | std::vector<GpgME::Key> found_keys; | 849 | key = found_keys[0]; |
837 | // As we are local it is ok to make this synchronous | ||
838 | GpgME::KeyListResult res = job->exec(QStringList(QLatin1String(signature.fingerprint())), false, found_keys); | ||
839 | if (res.error()) { | ||
840 | qCDebug(MIMETREEPARSER_LOG) << "Error while searching key for Fingerprint: " << signature.fingerprint(); | ||
841 | } | ||
842 | if (found_keys.size() > 1) { | ||
843 | // Should not Happen | ||
844 | qCDebug(MIMETREEPARSER_LOG) << "Oops: Found more then one Key for Fingerprint: " << signature.fingerprint(); | ||
845 | } | ||
846 | if (found_keys.size() != 1) { | ||
847 | // Should not Happen at this point | ||
848 | qCDebug(MIMETREEPARSER_LOG) << "Oops: Found no Key for Fingerprint: " << signature.fingerprint(); | ||
849 | } else { | ||
850 | key = found_keys[0]; | ||
851 | } | ||
852 | delete job; | ||
853 | } | 850 | } |
851 | delete job; | ||
854 | } | 852 | } |
853 | } | ||
855 | 854 | ||
856 | if (key.keyID()) { | 855 | if (key.keyID()) { |
857 | mMetaData.keyId = key.keyID(); | 856 | mMetaData.keyId = key.keyID(); |
858 | } | 857 | } |
859 | if (mMetaData.keyId.isEmpty()) { | 858 | if (mMetaData.keyId.isEmpty()) { |
860 | mMetaData.keyId = signature.fingerprint(); | 859 | mMetaData.keyId = signature.fingerprint(); |
861 | } | 860 | } |
862 | mMetaData.keyTrust = signature.validity(); | 861 | mMetaData.keyTrust = signature.validity(); |
863 | if (key.numUserIDs() > 0 && key.userID(0).id()) { | 862 | if (key.numUserIDs() > 0 && key.userID(0).id()) { |
864 | mMetaData.signer = prettifyDN(key.userID(0).id()); | 863 | mMetaData.signer = prettifyDN(key.userID(0).id()); |
865 | } | 864 | } |
866 | for (uint iMail = 0; iMail < key.numUserIDs(); ++iMail) { | 865 | for (uint iMail = 0; iMail < key.numUserIDs(); ++iMail) { |
867 | // The following if /should/ always result in TRUE but we | 866 | // The following if /should/ always result in TRUE but we |
868 | // won't trust implicitely the plugin that gave us these data. | 867 | // won't trust implicitely the plugin that gave us these data. |
869 | if (key.userID(iMail).email()) { | 868 | if (key.userID(iMail).email()) { |
870 | QString email = QString::fromUtf8(key.userID(iMail).email()); | 869 | QString email = QString::fromUtf8(key.userID(iMail).email()); |
871 | // ### work around gpgme 0.3.QString text() const Q_DECL_OVERRIDE;x / cryptplug bug where the | 870 | // ### work around gpgme 0.3.QString text() const Q_DECL_OVERRIDE;x / cryptplug bug where the |
872 | // ### email addresses are specified as angle-addr, not addr-spec: | 871 | // ### email addresses are specified as angle-addr, not addr-spec: |
873 | if (email.startsWith(QLatin1Char('<')) && email.endsWith(QLatin1Char('>'))) { | 872 | if (email.startsWith(QLatin1Char('<')) && email.endsWith(QLatin1Char('>'))) { |
874 | email = email.mid(1, email.length() - 2); | 873 | email = email.mid(1, email.length() - 2); |
875 | } | 874 | } |
876 | if (!email.isEmpty()) { | 875 | if (!email.isEmpty()) { |
877 | mMetaData.signerMailAddresses.append(email); | 876 | mMetaData.signerMailAddresses.append(email); |
878 | } | ||
879 | } | 877 | } |
880 | } | 878 | } |
879 | } | ||
881 | 880 | ||
882 | if (signature.creationTime()) { | 881 | if (signature.creationTime()) { |
883 | mMetaData.creationTime.setTime_t(signature.creationTime()); | 882 | mMetaData.creationTime.setTime_t(signature.creationTime()); |
884 | } else { | 883 | } else { |
885 | mMetaData.creationTime = QDateTime(); | 884 | mMetaData.creationTime = QDateTime(); |
885 | } | ||
886 | if (mMetaData.signer.isEmpty()) { | ||
887 | if (key.numUserIDs() > 0 && key.userID(0).name()) { | ||
888 | mMetaData.signer = prettifyDN(key.userID(0).name()); | ||
886 | } | 889 | } |
887 | if (mMetaData.signer.isEmpty()) { | 890 | if (!mMetaData.signerMailAddresses.empty()) { |
888 | if (key.numUserIDs() > 0 && key.userID(0).name()) { | 891 | if (mMetaData.signer.isEmpty()) { |
889 | mMetaData.signer = prettifyDN(key.userID(0).name()); | 892 | mMetaData.signer = mMetaData.signerMailAddresses.front(); |
890 | } | 893 | } else { |
891 | if (!mMetaData.signerMailAddresses.empty()) { | 894 | mMetaData.signer += QLatin1String(" <") + mMetaData.signerMailAddresses.front() + QLatin1Char('>'); |
892 | if (mMetaData.signer.isEmpty()) { | ||
893 | mMetaData.signer = mMetaData.signerMailAddresses.front(); | ||
894 | } else { | ||
895 | mMetaData.signer += QLatin1String(" <") + mMetaData.signerMailAddresses.front() + QLatin1Char('>'); | ||
896 | } | ||
897 | } | 895 | } |
898 | } | 896 | } |
899 | } | 897 | } |