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