LCOV - code coverage report
Current view: top level - lang/cpp/src - keygenerationresult.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 31 0.0 %
Date: 2016-09-12 13:07:23 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             : #include <keygenerationresult.h>
      24             : #include "result_p.h"
      25             : 
      26             : #include <gpgme.h>
      27             : 
      28             : #include <cstring>
      29             : #include <cstdlib>
      30             : 
      31             : #include <string.h>
      32             : 
      33             : class GpgME::KeyGenerationResult::Private
      34             : {
      35             : public:
      36           0 :     Private(const _gpgme_op_genkey_result &r) : res(r)
      37             :     {
      38           0 :         if (res.fpr) {
      39           0 :             res.fpr = strdup(res.fpr);
      40             :         }
      41           0 :     }
      42           0 :     ~Private()
      43             :     {
      44           0 :         if (res.fpr) {
      45           0 :             std::free(res.fpr);
      46             :         }
      47           0 :         res.fpr = 0;
      48           0 :     }
      49             : 
      50             :     _gpgme_op_genkey_result res;
      51             : };
      52             : 
      53           0 : GpgME::KeyGenerationResult::KeyGenerationResult(gpgme_ctx_t ctx, int error)
      54           0 :     : GpgME::Result(error), d()
      55             : {
      56           0 :     init(ctx);
      57           0 : }
      58             : 
      59           0 : GpgME::KeyGenerationResult::KeyGenerationResult(gpgme_ctx_t ctx, const Error &error)
      60           0 :     : GpgME::Result(error), d()
      61             : {
      62           0 :     init(ctx);
      63           0 : }
      64             : 
      65           0 : void GpgME::KeyGenerationResult::init(gpgme_ctx_t ctx)
      66             : {
      67           0 :     if (!ctx) {
      68           0 :         return;
      69             :     }
      70           0 :     gpgme_genkey_result_t res = gpgme_op_genkey_result(ctx);
      71           0 :     if (!res) {
      72           0 :         return;
      73             :     }
      74           0 :     d.reset(new Private(*res));
      75             : }
      76             : 
      77           0 : make_standard_stuff(KeyGenerationResult)
      78             : 
      79           0 : bool GpgME::KeyGenerationResult::isPrimaryKeyGenerated() const
      80             : {
      81           0 :     return d && d->res.primary;
      82             : }
      83             : 
      84           0 : bool GpgME::KeyGenerationResult::isSubkeyGenerated() const
      85             : {
      86           0 :     return d && d->res.sub;
      87             : }
      88             : 
      89           0 : const char *GpgME::KeyGenerationResult::fingerprint() const
      90             : {
      91           0 :     return d ? d->res.fpr : 0 ;
      92             : }

Generated by: LCOV version 1.11