LCOV - code coverage report
Current view: top level - lang/cpp/src - gpgagentgetinfoassuantransaction.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 37 2.7 %
Date: 2018-11-15 08:49:49 Functions: 2 14 14.3 %

          Line data    Source code
       1             : /*
       2             :   gpgagentgetinfoassuantransaction.cpp - Assuan Transaction to get information from gpg-agent
       3             :   Copyright (C) 2009 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 "gpgagentgetinfoassuantransaction.h"
      30             : #include "error.h"
      31             : #include "data.h"
      32             : #include "util.h"
      33             : 
      34             : #include <assert.h>
      35             : 
      36             : #include <sstream>
      37             : 
      38             : using namespace GpgME;
      39             : 
      40           0 : GpgAgentGetInfoAssuanTransaction::GpgAgentGetInfoAssuanTransaction(InfoItem item)
      41             :     : AssuanTransaction(),
      42             :       m_item(item),
      43             :       m_command(),
      44           0 :       m_data()
      45             : {
      46             : 
      47           0 : }
      48             : 
      49           0 : GpgAgentGetInfoAssuanTransaction::~GpgAgentGetInfoAssuanTransaction() {}
      50             : 
      51           0 : std::string GpgAgentGetInfoAssuanTransaction::version() const
      52             : {
      53           0 :     if (m_item == Version) {
      54           0 :         return m_data;
      55             :     } else {
      56           0 :         return std::string();
      57             :     }
      58             : }
      59             : 
      60           0 : unsigned int GpgAgentGetInfoAssuanTransaction::pid() const
      61             : {
      62           0 :     if (m_item == Pid) {
      63           0 :         return to_pid(m_data);
      64             :     } else {
      65           0 :         return 0U;
      66             :     }
      67             : }
      68             : 
      69           0 : std::string GpgAgentGetInfoAssuanTransaction::socketName() const
      70             : {
      71           0 :     if (m_item == SocketName) {
      72           0 :         return m_data;
      73             :     } else {
      74           0 :         return std::string();
      75             :     }
      76             : }
      77             : 
      78           0 : std::string GpgAgentGetInfoAssuanTransaction::sshSocketName() const
      79             : {
      80           0 :     if (m_item == SshSocketName) {
      81           0 :         return m_data;
      82             :     } else {
      83           0 :         return std::string();
      84             :     }
      85             : }
      86             : 
      87             : static const char *const gpgagent_getinfo_tokens[] = {
      88             :     "version",
      89             :     "pid",
      90             :     "socket_name",
      91             :     "ssh_socket_name",
      92             :     "scd_running",
      93             : };
      94             : 
      95           0 : void GpgAgentGetInfoAssuanTransaction::makeCommand() const
      96             : {
      97           0 :     assert(m_item >= 0);
      98           0 :     assert(m_item < LastInfoItem);
      99           0 :     m_command = "GETINFO ";
     100           0 :     m_command += gpgagent_getinfo_tokens[m_item];
     101           0 : }
     102             : 
     103           0 : const char *GpgAgentGetInfoAssuanTransaction::command() const
     104             : {
     105           0 :     makeCommand();
     106           0 :     return m_command.c_str();
     107             : }
     108             : 
     109           0 : Error GpgAgentGetInfoAssuanTransaction::data(const char *data, size_t len)
     110             : {
     111           0 :     m_data.append(data, len);
     112           0 :     return Error();
     113             : }
     114             : 
     115           0 : Data GpgAgentGetInfoAssuanTransaction::inquire(const char *name, const char *args, Error &err)
     116             : {
     117             :     (void)name; (void)args; (void)err;
     118           0 :     return Data::null;
     119             : }
     120             : 
     121           0 : Error GpgAgentGetInfoAssuanTransaction::status(const char *status, const char *args)
     122             : {
     123             :     (void)status; (void)args;
     124           0 :     return Error();
     125          24 : }

Generated by: LCOV version 1.13