QGpgME 21.6.2.0000005
Qt API for GpgME
Loading...
Searching...
No Matches
dataprovider.h
1/* dataprovider.h
2
3 This file is part of qgpgme, the Qt API binding for gpgme
4 Copyright (C) 2004 Klarälvdalens Datakonsult AB
5 Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
6 Software engineering by Intevation GmbH
7
8 QGpgME is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version.
12
13 QGpgME 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 GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21*/
22
23// -*- c++ -*-
24#ifndef __QGPGME_DATAPROVIDER_H__
25#define __QGPGME_DATAPROVIDER_H__
26
27#include "qgpgme_export.h"
28
29#include <gpgme++/interfaces/dataprovider.h>
30
31#include <memory>
32
33#include <QtCore/QByteArray>
34
35
36class QIODevice;
37
38namespace QGpgME
39{
40
41class QGPGME_EXPORT QByteArrayDataProvider : public GpgME::DataProvider
42{
43public:
45 explicit QByteArrayDataProvider(const QByteArray &initialData);
47
48 const QByteArray &data() const
49 {
50 return mArray;
51 }
52
53private:
54 // these shall only be accessed through the dataprovider
55 // interface, where they're public:
56 bool isSupported(Operation) const override
57 {
58 return true;
59 }
60 ssize_t read(void *buffer, size_t bufSize) override;
61 ssize_t write(const void *buffer, size_t bufSize) override;
62 off_t seek(off_t offset, int whence) override;
63 void release() override;
64
65private:
66 QByteArray mArray;
67 off_t mOff;
68};
69
70class QGPGME_EXPORT QIODeviceDataProvider : public GpgME::DataProvider
71{
72public:
73 explicit QIODeviceDataProvider(const std::shared_ptr<QIODevice> &initialData);
75
76 const std::shared_ptr<QIODevice> &ioDevice() const
77 {
78 return mIO;
79 }
80
81private:
82 // these shall only be accessed through the dataprovider
83 // interface, where they're public:
84 bool isSupported(Operation) const override;
85 ssize_t read(void *buffer, size_t bufSize) override;
86 ssize_t write(const void *buffer, size_t bufSize) override;
87 off_t seek(off_t offset, int whence) override;
88 void release() override;
89
90private:
91 const std::shared_ptr<QIODevice> mIO;
92 bool mErrorOccurred : 1;
93 bool mHaveQProcess : 1;
94};
95
96} // namespace QGpgME
97
98#endif
Definition dataprovider.h:42
Definition dataprovider.h:71