GpgFrontend Project
A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.
GpgData.h
1 
29 #pragma once
30 
31 #include <gpgme.h>
32 
33 #include "core/GpgFrontendCoreExport.h"
34 #include "core/model/GFBuffer.h"
35 #include "core/typedef/CoreTypedef.h"
36 
37 namespace GpgFrontend {
38 
39 class GFDataExchanger;
40 
45 class GPGFRONTEND_CORE_EXPORT GpgData {
46  public:
51  GpgData();
52 
60  GpgData(const void* buffer, size_t size, bool copy = true);
61 
67  explicit GpgData(int fd);
68 
74  explicit GpgData(std::shared_ptr<GFDataExchanger>);
75 
81  explicit GpgData(const QString& path, bool read);
82 
87  explicit GpgData(GFBuffer);
88 
93  ~GpgData();
94 
100  operator gpgme_data_t();
101 
107  auto Read2GFBuffer() -> GFBuffer;
108 
109  private:
114  struct DataRefDeleter {
115  void operator()(gpgme_data_t _data) {
116  if (_data != nullptr) gpgme_data_release(_data);
117  }
118  };
119 
120  GFBuffer cached_buffer_;
121 
122  std::unique_ptr<struct gpgme_data, DataRefDeleter> data_ref_ = nullptr;
123  FILE* fp_ = nullptr;
124  int fd_ = -1;
125 
126  struct gpgme_data_cbs data_cbs_;
127  std::shared_ptr<GFDataExchanger> data_ex_;
128 };
129 
130 } // namespace GpgFrontend
Definition: GFBuffer.h:36
Definition: GpgData.h:45
Definition: app.cpp:39
Definition: GpgData.h:114