diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp index d99c5ec9..68d7685f 100644 --- a/lang/cpp/src/key.cpp +++ b/lang/cpp/src/key.cpp @@ -23,6 +23,7 @@ #include #include "util.h" +#include "tofuinfo.h" #include @@ -625,6 +626,14 @@ bool UserID::isInvalid() const return uid && uid->invalid; } +TofuInfo UserID::tofuInfo() const +{ + if (!uid) { + return TofuInfo(); + } + return TofuInfo(uid->tofu); +} + // // // class Signature diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h index bb0487b9..e8d7ee23 100644 --- a/lang/cpp/src/key.h +++ b/lang/cpp/src/key.h @@ -43,6 +43,7 @@ class Context; class Subkey; class UserID; +class TofuInfo; typedef std::shared_ptr< std::remove_pointer::type > shared_gpgme_key_t; @@ -309,6 +310,10 @@ public: bool isRevoked() const; bool isInvalid() const; + /** TOFU info for this userid. + * @returns The TOFU stats or a null TofuInfo. + */ + GpgME::TofuInfo tofuInfo() const; private: shared_gpgme_key_t key; gpgme_user_id_t uid; diff --git a/lang/cpp/src/tofuinfo.cpp b/lang/cpp/src/tofuinfo.cpp index c27a59ed..fe8f051f 100644 --- a/lang/cpp/src/tofuinfo.cpp +++ b/lang/cpp/src/tofuinfo.cpp @@ -31,12 +31,6 @@ public: Private(gpgme_tofu_info_t info) : mInfo(info ? new _gpgme_tofu_info(*info) : nullptr) { - if (mInfo && mInfo->fpr) { - mInfo->fpr = strdup(mInfo->fpr); - } - if (mInfo && mInfo->address) { - mInfo->address = strdup(mInfo->address); - } if (mInfo && mInfo->description) { mInfo->description = strdup(mInfo->description); } @@ -45,12 +39,6 @@ public: Private(const Private &other) : mInfo(other.mInfo) { - if (mInfo && mInfo->fpr) { - mInfo->fpr = strdup(mInfo->fpr); - } - if (mInfo && mInfo->address) { - mInfo->address = strdup(mInfo->address); - } if (mInfo && mInfo->description) { mInfo->description = strdup(mInfo->description); } @@ -59,10 +47,6 @@ public: ~Private() { if (mInfo) { - std::free(mInfo->fpr); - mInfo->fpr = nullptr; - std::free(mInfo->address); - mInfo->address = nullptr; std::free(mInfo->description); mInfo->description = nullptr; @@ -129,16 +113,6 @@ GpgME::TofuInfo::Policy GpgME::TofuInfo::policy() const } } -const char *GpgME::TofuInfo::fingerprint() const -{ - return isNull() ? nullptr : d->mInfo->fpr; -} - -const char *GpgME::TofuInfo::address() const -{ - return isNull() ? nullptr : d->mInfo->address; -} - const char *GpgME::TofuInfo::description() const { return isNull() ? nullptr : d->mInfo->description; @@ -163,9 +137,7 @@ std::ostream &GpgME::operator<<(std::ostream &os, const GpgME::TofuInfo &info) { os << "GpgME::Signature::TofuInfo("; if (!info.isNull()) { - os << "\n address: " << protect(info.address()) - << "\n fpr: " << protect(info.fingerprint()) - << "\n desc: " << protect(info.description()) + os << "\n desc: " << protect(info.description()) << "\n validity: " << info.validity() << "\n policy: " << info.policy() << "\n signcount: "<< info.signCount() diff --git a/lang/cpp/src/tofuinfo.h b/lang/cpp/src/tofuinfo.h index c698360f..48351205 100644 --- a/lang/cpp/src/tofuinfo.h +++ b/lang/cpp/src/tofuinfo.h @@ -99,20 +99,9 @@ public: /* Number of seconds since the last message was verified. */ unsigned int lastSeen() const; - /* Finterprint of the key for this entry. */ - const char *fingerprint() const; - /* If non-NULL a human readable string summarizing the TOFU data. */ const char *description() const; - /* The address of the tofu binding. - * - * If no mail address is set for a User ID this is the name used - * for the user ID. Can be ambiguous when the same mail address or - * name is used in multiple user ids. - */ - const char *address() const; - private: class Private; std::shared_ptr d; diff --git a/lang/cpp/src/verificationresult.cpp b/lang/cpp/src/verificationresult.cpp index 3eb8a850..c32c8964 100644 --- a/lang/cpp/src/verificationresult.cpp +++ b/lang/cpp/src/verificationresult.cpp @@ -24,7 +24,6 @@ #include #include "result_p.h" #include "util.h" -#include "tofuinfo.h" #include @@ -82,11 +81,6 @@ public: } nota.back().push_back(n); } - // copy tofu info: - tinfos.push_back(std::vector()); - for (gpgme_tofu_info_t in = is->tofu; in ; in = in->next) { - tinfos.back().push_back(TofuInfo(in)); - } } } ~Private() @@ -113,7 +107,6 @@ public: std::vector sigs; std::vector< std::vector > nota; - std::vector< std::vector > tinfos; std::vector purls; std::string file_name; }; @@ -373,15 +366,6 @@ std::vector GpgME::Signature::notations() const return result; } -std::vector GpgME::Signature::tofuInfo() const -{ - if (isNull()) { - return std::vector(); - } - - return d->tinfos[idx]; -} - class GpgME::Notation::Private { public: @@ -550,9 +534,6 @@ std::ostream &GpgME::operator<<(std::ostream &os, const Signature &sig) const std::vector nota = sig.notations(); std::copy(nota.begin(), nota.end(), std::ostream_iterator(os, "\n")); - const std::vector tinfos = sig.tofuInfo(); - std::copy(tinfos.begin(), tinfos.end(), - std::ostream_iterator(os, "\n")); } return os << ')'; } diff --git a/lang/cpp/src/verificationresult.h b/lang/cpp/src/verificationresult.h index f5fbc2ec..3394a474 100644 --- a/lang/cpp/src/verificationresult.h +++ b/lang/cpp/src/verificationresult.h @@ -40,7 +40,6 @@ namespace GpgME class Error; class Signature; class Notation; -class TofuInfo; class GPGMEPP_EXPORT VerificationResult : public Result { @@ -158,18 +157,6 @@ public: GpgME::Notation notation(unsigned int index) const; std::vector notations() const; - /** List of TOFU stats for this signature. - * - * For each UserID of the key used to create this - * signature a tofu entry is returned. - * - * Warning: Addresses can be ambigous if there are multiple UserID's - * with the same mailbox in a key. - * - * @returns The list of TOFU stats. - */ - std::vector tofuInfo() const; - private: std::shared_ptr d; unsigned int idx; diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp index 3072f0fc..2f2ed437 100644 --- a/lang/qt/tests/t-tofuinfo.cpp +++ b/lang/qt/tests/t-tofuinfo.cpp @@ -57,6 +57,7 @@ static const char testMsg1[] = class TofuInfoTest: public QGpgMETest { +#if 0 Q_OBJECT void testTofuCopy(TofuInfo other, const TofuInfo &orig) @@ -235,6 +236,7 @@ private /* FIXME Disabled until GnuPG-Bug-Id 2405 is fixed Q_SLOTS */: mDir.path() + QStringLiteral("/secring.gpg"))); } +#endif }; QTEST_MAIN(TofuInfoTest)