Cpp: Move tofuinfo from signature to userid

* lang/cpp/src/key.cpp (UserID::tofuInfo): New.
* lang/cpp/src/key.h: Update accordingly.
* lang/cpp/src/tofuinfo.cpp: Remove dropped fields.
* lang/cpp/src/tofuinfo.h: Update accordingly.
* lang/cpp/src/verificationresult.cpp,
lang/cpp/src/verificationresult.h: Remove tofu info.
* lang/qt/tests/t-tofuinfo.cpp: Disable for now.

--
With be4ff75d7 Tofu info now lives with a UserID
Object. While this breaks API it was not yet released.
This commit is contained in:
Andre Heinecke 2016-08-23 16:40:21 +02:00
parent 2972c44bd7
commit 799b168243
7 changed files with 17 additions and 72 deletions

View File

@ -23,6 +23,7 @@
#include <key.h>
#include "util.h"
#include "tofuinfo.h"
#include <gpgme.h>
@ -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

View File

@ -43,6 +43,7 @@ class Context;
class Subkey;
class UserID;
class TofuInfo;
typedef std::shared_ptr< std::remove_pointer<gpgme_key_t>::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;

View File

@ -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()

View File

@ -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<Private> d;

View File

@ -24,7 +24,6 @@
#include <notation.h>
#include "result_p.h"
#include "util.h"
#include "tofuinfo.h"
#include <gpgme.h>
@ -82,11 +81,6 @@ public:
}
nota.back().push_back(n);
}
// copy tofu info:
tinfos.push_back(std::vector<TofuInfo>());
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<gpgme_signature_t> sigs;
std::vector< std::vector<Nota> > nota;
std::vector< std::vector<TofuInfo> > tinfos;
std::vector<char *> purls;
std::string file_name;
};
@ -373,15 +366,6 @@ std::vector<GpgME::Notation> GpgME::Signature::notations() const
return result;
}
std::vector<GpgME::TofuInfo> GpgME::Signature::tofuInfo() const
{
if (isNull()) {
return std::vector<GpgME::TofuInfo>();
}
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<Notation> nota = sig.notations();
std::copy(nota.begin(), nota.end(),
std::ostream_iterator<Notation>(os, "\n"));
const std::vector<TofuInfo> tinfos = sig.tofuInfo();
std::copy(tinfos.begin(), tinfos.end(),
std::ostream_iterator<TofuInfo>(os, "\n"));
}
return os << ')';
}

View File

@ -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<GpgME::Notation> 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<GpgME::TofuInfo> tofuInfo() const;
private:
std::shared_ptr<VerificationResult::Private> d;
unsigned int idx;

View File

@ -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)