diff options
Diffstat (limited to 'src/core/function/gpg/GpgKeyImportExporter.h')
-rw-r--r-- | src/core/function/gpg/GpgKeyImportExporter.h | 135 |
1 files changed, 23 insertions, 112 deletions
diff --git a/src/core/function/gpg/GpgKeyImportExporter.h b/src/core/function/gpg/GpgKeyImportExporter.h index 6e90f436..d0724f7b 100644 --- a/src/core/function/gpg/GpgKeyImportExporter.h +++ b/src/core/function/gpg/GpgKeyImportExporter.h @@ -1,5 +1,5 @@ /** - * Copyright (C) 2021 Saturneric + * Copyright (C) 2021 Saturneric <[email protected]> * * This file is part of GpgFrontend. * @@ -20,67 +20,22 @@ * the gpg4usb project, which is under GPL-3.0-or-later. * * All the source code of GpgFrontend was modified and released by - * Saturneric<[email protected]> starting on May 12, 2021. + * Saturneric <[email protected]> starting on May 12, 2021. * * SPDX-License-Identifier: GPL-3.0-or-later * */ -#ifndef _GPGKEYIMPORTEXPORTOR_H -#define _GPGKEYIMPORTEXPORTOR_H +#pragma once -#include <string> - -#include "core/GpgConstants.h" -#include "core/GpgContext.h" -#include "core/GpgFunctionObject.h" -#include "core/GpgModel.h" +#include "core/function/basic/GpgFunctionObject.h" +#include "core/function/gpg/GpgContext.h" +#include "core/model/GFBuffer.h" +#include "core/typedef/GpgTypedef.h" namespace GpgFrontend { -/** - * @brief - * - */ -class GpgImportedKey { - public: - std::string fpr; ///< - int import_status; ///< -}; - -typedef std::list<GpgImportedKey> GpgImportedKeyList; ///< - -/** - * @brief - * - */ -class GPGFRONTEND_CORE_EXPORT GpgImportInformation { - public: - GpgImportInformation(); - - /** - * @brief Construct a new Gpg Import Information object - * - * @param result - */ - explicit GpgImportInformation(gpgme_import_result_t result); - - int considered = 0; ///< - int no_user_id = 0; ///< - int imported = 0; ///< - int imported_rsa = 0; ///< - int unchanged = 0; ///< - int new_user_ids = 0; ///< - int new_sub_keys = 0; ///< - int new_signatures = 0; ///< - int new_revocations = 0; ///< - int secret_read = 0; ///< - int secret_imported = 0; ///< - int secret_unchanged = 0; ///< - int not_imported = 0; ///< - - GpgImportedKeyList importedKeys; ///< -}; +class GpgImportInformation; /** * @brief @@ -103,19 +58,19 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyImportExporter * @param inBuffer * @return GpgImportInformation */ - GpgImportInformation ImportKey(StdBypeArrayPtr inBuffer); + auto ImportKey(const GFBuffer&) -> std::shared_ptr<GpgImportInformation>; /** * @brief * - * @param uid_list - * @param out_buffer + * @param key * @param secret - * @return true - * @return false + * @param ascii + * @return std::tuple<GpgError, GFBuffer> */ - bool ExportKeys(KeyIdArgsListPtr& uid_list, ByteArrayPtr& out_buffer, - bool secret = false) const; + [[nodiscard]] auto ExportKey(const GpgKey& key, bool secret, bool ascii, + bool shortest, bool ssh_mode = false) const + -> std::tuple<GpgError, GFBuffer>; /** * @brief @@ -126,67 +81,23 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyImportExporter * @return true * @return false */ - bool ExportKeys(const KeyArgsList& keys, ByteArrayPtr& outBuffer, - bool secret = false) const; + void ExportKeys(const KeyArgsList& keys, bool secret, bool ascii, + bool shortest, bool ssh_mode, + const GpgOperationCallback& cb) const; /** * @brief * * @param keys - * @param outBuffer * @param secret - * @return true - * @return false - */ - bool ExportAllKeys(KeyIdArgsListPtr& uid_list, ByteArrayPtr& out_buffer, - bool secret) const; - - /** - * @brief - * - * @param key - * @param out_buffer - * @return true - * @return false - */ - bool ExportKey(const GpgKey& key, ByteArrayPtr& out_buffer) const; - - /** - * @brief - * - * @param key - * @param out_buffer - * @return true - * @return false + * @param ascii + * @param cb */ - bool ExportKeyOpenSSH(const GpgKey& key, ByteArrayPtr& out_buffer) const; - - /** - * @brief - * - * @param key - * @param outBuffer - * @return true - * @return false - */ - bool ExportSecretKey(const GpgKey& key, ByteArrayPtr& outBuffer) const; - - /** - * @brief - * - * @param key - * @param outBuffer - * @return true - * @return false - */ - bool ExportSecretKeyShortest(const GpgKey& key, - ByteArrayPtr& outBuffer) const; + void ExportAllKeys(const KeyArgsList& keys, bool secret, bool ascii, + const GpgOperationCallback& cb) const; private: - GpgContext& ctx_ = - GpgContext::GetInstance(SingletonFunctionObject::GetChannel()); ///< + GpgContext& ctx_; }; } // namespace GpgFrontend - -#endif // _GPGKEYIMPORTEXPORTOR_H
\ No newline at end of file |