1 | /* |
2 | defaultassuantransaction.cpp - default Assuan Transaction that just stores data and status lines |
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 <config-gpgme++.h> |
24 | |
25 | #include "defaultassuantransaction.h" |
26 | #include "error.h" |
27 | #include "data.h" |
28 | |
29 | #include <sstream> |
30 | |
31 | using namespace GpgME; |
32 | using namespace boost; |
33 | |
34 | DefaultAssuanTransaction::DefaultAssuanTransaction() |
35 | : AssuanTransaction(), |
36 | m_status(), |
37 | m_data() |
38 | { |
39 | |
40 | } |
41 | |
42 | DefaultAssuanTransaction::~DefaultAssuanTransaction() {} |
43 | |
44 | Error DefaultAssuanTransaction::data( const char * data, size_t len ) { |
45 | m_data.append( data, len ); |
46 | return Error(); |
47 | } |
48 | |
49 | Data DefaultAssuanTransaction::inquire( const char * name, const char * args, Error & err ) { |
50 | (void)name; (void)args; (void)err; |
51 | return Data::null; |
52 | } |
53 | |
54 | Error DefaultAssuanTransaction::status( const char * status, const char * args ) { |
55 | m_status.push_back( std::pair<std::string,std::string>( status, args ) ); |
56 | return Error(); |
57 | } |
58 | |
59 | std::vector<std::string> DefaultAssuanTransaction::statusLine( const char * tag ) const { |
60 | std::vector<std::string> result; |
61 | for ( std::vector< std::pair<std::string,std::string> >::const_iterator it = m_status.begin(), end = m_status.end() ; it != end ; ++it ) { |
62 | if ( it->first == tag ) { |
63 | result.push_back( it->second ); |
64 | } |
65 | } |
66 | return result; |
67 | } |
68 | |
69 | std::string DefaultAssuanTransaction::firstStatusLine( const char * tag ) const { |
70 | for ( std::vector< std::pair<std::string,std::string> >::const_iterator it = m_status.begin(), end = m_status.end() ; it != end ; ++it ) { |
71 | if ( it->first == tag ) { |
72 | return it->second; |
73 | } |
74 | } |
75 | return std::string(); |
76 | } |
77 | |