Line data Source code
1 : /*
2 : vfsmountresult.cpp - wraps a gpgme vfs mount result
3 : Copyright (C) 2009 Klarälvdalens Datakonsult AB <info@kdab.com>
4 : Author: Marc Mutz <marc@kdab.com>, Volker Krause <volker@kdab.com>
5 :
6 : This file is part of GPGME++.
7 :
8 : GPGME++ is free software; you can redistribute it and/or
9 : modify it under the terms of the GNU Library General Public
10 : License as published by the Free Software Foundation; either
11 : version 2 of the License, or (at your option) any later version.
12 :
13 : GPGME++ is distributed in the hope that it will be useful,
14 : but WITHOUT ANY WARRANTY; without even the implied warranty of
15 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 : GNU Library General Public License for more details.
17 :
18 : You should have received a copy of the GNU Library General Public License
19 : along with GPGME++; see the file COPYING.LIB. If not, write to the
20 : Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 : Boston, MA 02110-1301, USA.
22 : */
23 :
24 : #include <vfsmountresult.h>
25 : #include "result_p.h"
26 :
27 : #include <gpgme.h>
28 :
29 : #include <istream>
30 : #include <string.h>
31 :
32 : using namespace GpgME;
33 :
34 : class VfsMountResult::Private
35 : {
36 : public:
37 0 : explicit Private(const gpgme_vfs_mount_result_t r) : mountDir(0)
38 : {
39 0 : if (r && r->mount_dir) {
40 0 : mountDir = strdup(r->mount_dir);
41 : }
42 0 : }
43 :
44 0 : ~Private()
45 : {
46 0 : std::free(mountDir);
47 0 : }
48 :
49 : char *mountDir;
50 : };
51 :
52 0 : VfsMountResult::VfsMountResult(gpgme_ctx_t ctx, const Error &error, const Error &opError)
53 0 : : Result(error ? error : opError), d()
54 : {
55 0 : init(ctx);
56 0 : }
57 :
58 0 : void VfsMountResult::init(gpgme_ctx_t ctx)
59 : {
60 : (void)ctx;
61 0 : if (!ctx) {
62 0 : return;
63 : }
64 0 : gpgme_vfs_mount_result_t res = gpgme_op_vfs_mount_result(ctx);
65 0 : if (!res) {
66 0 : return;
67 : }
68 0 : d.reset(new Private(res));
69 : }
70 :
71 0 : make_standard_stuff(VfsMountResult)
72 :
73 0 : const char *VfsMountResult::mountDir() const
74 : {
75 0 : if (d) {
76 0 : return d->mountDir;
77 : }
78 0 : return 0;
79 : }
80 :
81 0 : std::ostream &GpgME::operator<<(std::ostream &os, const VfsMountResult &result)
82 : {
83 0 : os << "GpgME::VfsMountResult(";
84 0 : if (!result.isNull()) {
85 0 : os << "\n error: " << result.error()
86 0 : << "\n mount dir: " << result.mountDir()
87 0 : << "\n";
88 : }
89 0 : return os << ')';
90 : }
|