[Pkg-gnupg-commit] [gpgme] 299/412: Cpp: Move tofuinfo from signature to userid

Daniel Kahn Gillmor dkg at fifthhorseman.net
Thu Sep 22 21:27:07 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gpgme.

commit 799b168243e6499ac01bf59e0656547f353a2589
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Aug 23 16:40:21 2016 +0200

    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.
---
 lang/cpp/src/key.cpp                |  9 +++++++++
 lang/cpp/src/key.h                  |  5 +++++
 lang/cpp/src/tofuinfo.cpp           | 30 +-----------------------------
 lang/cpp/src/tofuinfo.h             | 11 -----------
 lang/cpp/src/verificationresult.cpp | 19 -------------------
 lang/cpp/src/verificationresult.h   | 13 -------------
 lang/qt/tests/t-tofuinfo.cpp        |  2 ++
 7 files changed, 17 insertions(+), 72 deletions(-)

diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index d99c5ec..68d7685 100644
--- a/lang/cpp/src/key.cpp
+++ b/lang/cpp/src/key.cpp
@@ -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
diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h
index bb0487b..e8d7ee2 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<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;
diff --git a/lang/cpp/src/tofuinfo.cpp b/lang/cpp/src/tofuinfo.cpp
index c27a59e..fe8f051 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 c698360..4835120 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<Private> d;
diff --git a/lang/cpp/src/verificationresult.cpp b/lang/cpp/src/verificationresult.cpp
index 3eb8a85..c32c896 100644
--- a/lang/cpp/src/verificationresult.cpp
+++ b/lang/cpp/src/verificationresult.cpp
@@ -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 << ')';
 }
diff --git a/lang/cpp/src/verificationresult.h b/lang/cpp/src/verificationresult.h
index f5fbc2e..3394a47 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<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;
diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp
index 3072f0f..2f2ed43 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)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gpgme.git



More information about the Pkg-gnupg-commit mailing list