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

Generated by: LCOV version 1.11