GpgConstants.h
#ifndef GPG_CONSTANTS_H
#define GPG_CONSTANTS_H
#include "GpgFrontendCore.h"
const int RESTART_CODE = 1000;
namespace GpgFrontend {
using ByteArray = std::string;
using ByteArrayPtr = std::unique_ptr<ByteArray>;
using StdBypeArrayPtr = std::unique_ptr<ByteArray>;
using BypeArrayRef = ByteArray&;
using BypeArrayConstRef = const ByteArray&;
using StringArgsPtr = std::unique_ptr<std::vector<std::string>>;
using StringArgsRef = std::vector<std::string>&;
using GpgError = gpgme_error_t;
struct _result_ref_deletor {
void operator()(void* _result);
};
using GpgEncrResult = std::shared_ptr<struct _gpgme_op_encrypt_result>;
using GpgDecrResult = std::shared_ptr<struct _gpgme_op_decrypt_result>;
using GpgSignResult = std::shared_ptr<struct _gpgme_op_sign_result>;
using GpgVerifyResult = std::shared_ptr<struct _gpgme_op_verify_result>;
using GpgGenKeyResult = std::shared_ptr<struct _gpgme_op_genkey_result>;
// Convert from gpgme_xxx_result to GpgXXXResult
GPGFRONTEND_CORE_EXPORT GpgEncrResult
_new_result(gpgme_encrypt_result_t&& result);
GPGFRONTEND_CORE_EXPORT GpgDecrResult
_new_result(gpgme_decrypt_result_t&& result);
GPGFRONTEND_CORE_EXPORT GpgSignResult _new_result(gpgme_sign_result_t&& result);
GPGFRONTEND_CORE_EXPORT GpgVerifyResult
_new_result(gpgme_verify_result_t&& result);
GPGFRONTEND_CORE_EXPORT GpgGenKeyResult
_new_result(gpgme_genkey_result_t&& result);
// Error Info Printer
GPGFRONTEND_CORE_EXPORT GpgError check_gpg_error(GpgError err);
GPGFRONTEND_CORE_EXPORT GpgError check_gpg_error(GpgError gpgmeError,
const std::string& comment);
GPGFRONTEND_CORE_EXPORT gpg_err_code_t check_gpg_error_2_err_code(
gpgme_error_t err, gpgme_error_t predict = GPG_ERR_NO_ERROR);
// Fingerprint
GPGFRONTEND_CORE_EXPORT std::string beautify_fingerprint(
BypeArrayConstRef fingerprint);
// File Operation
std::string read_all_data_in_file(const std::string& path);
GPGFRONTEND_CORE_EXPORT bool write_buffer_to_file(
const std::string& path, const std::string& out_buffer);
std::string get_file_extension(const std::string& path);
std::string get_only_file_name_with_path(const std::string& path);
// Check
int text_is_signed(BypeArrayRef text);
// Channels
const int GPGFRONTEND_DEFAULT_CHANNEL = 0;
const int GPGFRONTEND_NON_ASCII_CHANNEL = 2;
class GPGFRONTEND_CORE_EXPORT GpgConstants {
public:
static const char* PGP_CRYPT_BEGIN;
static const char* PGP_CRYPT_END;
static const char* PGP_SIGNED_BEGIN;
static const char* PGP_SIGNED_END;
static const char* PGP_SIGNATURE_BEGIN;
static const char* PGP_SIGNATURE_END;
static const char* PGP_PUBLIC_KEY_BEGIN;
static const char* PGP_PRIVATE_KEY_BEGIN;
static const char* GPG_FRONTEND_SHORT_CRYPTO_HEAD;
};
} // namespace GpgFrontend
#endif // GPG_CONSTANTS_H
GpgFrontend::beautify_fingerprint
GPGFRONTEND_CORE_EXPORT std::string beautify_fingerprint(BypeArrayConstRef fingerprint)
Definition: GpgConstants.cpp:90
GpgFrontend::get_file_extension
std::string get_file_extension(const std::string &path)
Get the file extension object.
Definition: GpgConstants.cpp:133
GpgFrontend::write_buffer_to_file
GPGFRONTEND_CORE_EXPORT bool write_buffer_to_file(const std::string &path, const std::string &out_buffer)
Definition: GpgConstants.cpp:128
GpgFrontend
Definition: CoreCommonUtil.cpp:29
GpgFrontend::text_is_signed
int text_is_signed(BypeArrayRef text)
Definition: GpgConstants.cpp:158
GpgFrontend::check_gpg_error
GPGFRONTEND_CORE_EXPORT GpgError check_gpg_error(GpgError err)
Definition: GpgConstants.cpp:54
GpgFrontend::get_only_file_name_with_path
std::string get_only_file_name_with_path(const std::string &path)
Get the only file name with path object.
Definition: GpgConstants.cpp:146
GpgFrontend::_result_ref_deletor
Result Deleter.
Definition: GpgConstants.h:52
GpgFrontend::read_all_data_in_file
std::string read_all_data_in_file(const std::string &path)
Definition: GpgConstants.cpp:122
GpgFrontend::GpgConstants::PGP_CRYPT_BEGIN
static const char * PGP_CRYPT_BEGIN
Definition: GpgConstants.h:206
GpgFrontend::check_gpg_error_2_err_code
GPGFRONTEND_CORE_EXPORT gpg_err_code_t check_gpg_error_2_err_code(gpgme_error_t err, gpgme_error_t predict=GPG_ERR_NO_ERROR)
Definition: GpgConstants.cpp:63
GpgFrontend::GpgConstants
Definition: GpgConstants.h:204
GpgFrontend::_new_result
GPGFRONTEND_CORE_EXPORT GpgEncrResult _new_result(gpgme_encrypt_result_t &&result)
Definition: GpgConstants.cpp:173