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