LCOV - code coverage report
Current view: top level - lang/cpp/src - keygenerationresult.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 32 0.0 %
Date: 2017-03-02 17:11:10 Functions: 0 11 0.0 %

          Line data    Source code
       1             : /*
       2             :   keygenerationresult.cpp - wraps a gpgme keygen result
       3             :   Copyright (C) 2004 Klarälvdalens Datakonsult AB
       4             : 
       5             :   This file is part of GPGME++.
       6             : 
       7             :   GPGME++ is free software; you can redistribute it and/or
       8             :   modify it under the terms of the GNU Library General Public
       9             :   License as published by the Free Software Foundation; either
      10             :   version 2 of the License, or (at your option) any later version.
      11             : 
      12             :   GPGME++ is distributed in the hope that it will be useful,
      13             :   but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15             :   GNU Library General Public License for more details.
      16             : 
      17             :   You should have received a copy of the GNU Library General Public License
      18             :   along with GPGME++; see the file COPYING.LIB.  If not, write to the
      19             :   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
      20             :   Boston, MA 02110-1301, USA.
      21             : */
      22             : 
      23             : #ifdef HAVE_CONFIG_H
      24             :  #include "config.h"
      25             : #endif
      26             : 
      27             : #include <keygenerationresult.h>
      28             : #include "result_p.h"
      29             : 
      30             : #include <gpgme.h>
      31             : 
      32             : #include <cstring>
      33             : #include <cstdlib>
      34             : 
      35             : #include <string.h>
      36             : 
      37             : class GpgME::KeyGenerationResult::Private
      38             : {
      39             : public:
      40           0 :     Private(const _gpgme_op_genkey_result &r) : res(r)
      41             :     {
      42           0 :         if (res.fpr) {
      43           0 :             res.fpr = strdup(res.fpr);
      44             :         }
      45           0 :     }
      46           0 :     ~Private()
      47           0 :     {
      48           0 :         if (res.fpr) {
      49           0 :             std::free(res.fpr);
      50             :         }
      51           0 :         res.fpr = 0;
      52           0 :     }
      53             : 
      54             :     _gpgme_op_genkey_result res;
      55             : };
      56             : 
      57           0 : GpgME::KeyGenerationResult::KeyGenerationResult(gpgme_ctx_t ctx, int error)
      58           0 :     : GpgME::Result(error), d()
      59             : {
      60           0 :     init(ctx);
      61           0 : }
      62             : 
      63           0 : GpgME::KeyGenerationResult::KeyGenerationResult(gpgme_ctx_t ctx, const Error &error)
      64           0 :     : GpgME::Result(error), d()
      65             : {
      66           0 :     init(ctx);
      67           0 : }
      68             : 
      69           0 : void GpgME::KeyGenerationResult::init(gpgme_ctx_t ctx)
      70             : {
      71           0 :     if (!ctx) {
      72           0 :         return;
      73             :     }
      74           0 :     gpgme_genkey_result_t res = gpgme_op_genkey_result(ctx);
      75           0 :     if (!res) {
      76           0 :         return;
      77             :     }
      78           0 :     d.reset(new Private(*res));
      79             : }
      80             : 
      81           0 : make_standard_stuff(KeyGenerationResult)
      82             : 
      83           0 : bool GpgME::KeyGenerationResult::isPrimaryKeyGenerated() const
      84             : {
      85           0 :     return d && d->res.primary;
      86             : }
      87             : 
      88           0 : bool GpgME::KeyGenerationResult::isSubkeyGenerated() const
      89             : {
      90           0 :     return d && d->res.sub;
      91             : }
      92             : 
      93           0 : const char *GpgME::KeyGenerationResult::fingerprint() const
      94             : {
      95           0 :     return d ? d->res.fpr : 0 ;
      96             : }

Generated by: LCOV version 1.13