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

Generated by: LCOV version 1.11