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

Generated by: LCOV version 1.13