diff options
Diffstat (limited to '')
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/gpg/GpgContext.cpp | 26 | ||||
-rw-r--r-- | src/gpg/GpgContext.h | 35 | ||||
-rw-r--r-- | src/gpg/function/BasicOperator.cpp | 2 | ||||
-rw-r--r-- | src/gpg/function/GpgCommandExecutor.cpp | 2 | ||||
-rw-r--r-- | src/gpg/function/GpgKeyImportExportor.cpp | 2 | ||||
-rw-r--r-- | src/gpg/model/GpgData.cpp | 2 |
8 files changed, 23 insertions, 52 deletions
@@ -1,6 +1,6 @@ # Project -include/GpgFrontend.h -include/GpgFrontendBuildInfo.h +src/GpgFrontend.h +src/GpgFrontendBuildInfo.h #Vscode .vscode/* diff --git a/CMakeLists.txt b/CMakeLists.txt index bef75b79..e40eb148 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,7 @@ if(${CMAKE_BUILD_TYPE} STREQUAL "Release") else() set(BUILD_FLAG 1) message(STATUS "Build Type DEBUG") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fprofile-instr-generate -fcoverage-mapping") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") endif() # Get Git Information diff --git a/src/gpg/GpgContext.cpp b/src/gpg/GpgContext.cpp index c956e126..db670938 100644 --- a/src/gpg/GpgContext.cpp +++ b/src/gpg/GpgContext.cpp @@ -41,9 +41,9 @@ namespace GpgFrontend { */ GpgContext::GpgContext() { - static bool __first = true; + static bool _first = true; - if (__first) { + if (_first) { /* Initialize the locale environment. */ setlocale(LC_ALL, ""); gpgme_check_version(nullptr); @@ -51,7 +51,7 @@ GpgContext::GpgContext() { #ifdef LC_MESSAGES gpgme_set_locale(nullptr, LC_MESSAGES, setlocale(LC_MESSAGES, nullptr)); #endif - __first = false; + _first = false; } gpgme_ctx_t _p_ctx; @@ -109,28 +109,12 @@ GpgContext::GpgContext() { bool GpgContext::good() const { return good_; } -void GpgContext::SetPassphraseCb(decltype(test_passphrase_cb) cb) { +void GpgContext::SetPassphraseCb(decltype(test_passphrase_cb) cb) const { gpgme_set_passphrase_cb(*this, cb, nullptr); } -/** return type should be gpgme_error_t*/ - -/* - * if there is no '\n' before the PGP-Begin-Block, but for example a whitespace, - * GPGME doesn't recognise the Message as encrypted. This function adds '\n' - * before the PGP-Begin-Block, if missing. - */ -void GpgContext::preventNoDataErr(BypeArrayPtr in) { - int block_start = in->find(GpgConstants::PGP_CRYPT_BEGIN); - if (block_start != std::string::npos && in->at(block_start - 1) != '\n') - in->insert(block_start, "\n"); - block_start = in->find(GpgConstants::PGP_SIGNED_BEGIN); - if (block_start != std::string::npos && in->at(block_start - 1) != '\n') - in->insert(block_start, "\n"); -} - std::string GpgContext::getGpgmeVersion() { return {gpgme_check_version(nullptr)}; } -} // namespace GpgFrontend +} // namespace GpgFrontend
\ No newline at end of file diff --git a/src/gpg/GpgContext.h b/src/gpg/GpgContext.h index e786c2b3..21fb5aee 100644 --- a/src/gpg/GpgContext.h +++ b/src/gpg/GpgContext.h @@ -39,21 +39,11 @@ class GpgContext : public SingletonFunctionObject<GpgContext> { public: GpgContext(); - ~GpgContext() = default; + ~GpgContext() override = default; [[nodiscard]] bool good() const; - const GpgInfo &GetInfo() const { return info; } - - void clearPasswordCache(); - - /** - * @details If text contains PGP-message, put a linebreak before the message, - * so that gpgme can decrypt correctly - * - * @param in Pointer to the QBytearray to check. - */ - static void preventNoDataErr(BypeArrayPtr in); + [[nodiscard]] const GpgInfo &GetInfo() const { return info; } static std::string getGpgmeVersion(); @@ -62,7 +52,7 @@ public: private: GpgInfo info; - struct __ctx_ref_deletor { + struct _ctx_ref_deletor { void operator()(gpgme_ctx_t _ctx) { if (_ctx != nullptr) gpgme_release(_ctx); @@ -70,24 +60,21 @@ private: }; using CtxRefHandler = - std::unique_ptr<struct gpgme_context, __ctx_ref_deletor>; + std::unique_ptr<struct gpgme_context, _ctx_ref_deletor>; CtxRefHandler _ctx_ref = nullptr; bool good_ = true; - gpgme_error_t passphrase(const char *uid_hint, const char *passphrase_info, - int last_was_bad, int fd); - public: static gpgme_error_t test_passphrase_cb(void *opaque, const char *uid_hint, const char *passphrase_info, int last_was_bad, int fd) { LOG(INFO) << "test_passphrase_cb Called"; - int res; + size_t res; char pass[] = "abcdefg\n"; - int passlen = strlen(pass); - int off = 0; + size_t pass_len = strlen(pass); + size_t off = 0; (void)opaque; (void)uid_hint; @@ -95,15 +82,15 @@ public: (void)last_was_bad; do { - res = gpgme_io_write(fd, &pass[off], passlen - off); + res = gpgme_io_write(fd, &pass[off], pass_len - off); if (res > 0) off += res; - } while (res > 0 && off != passlen); + } while (res > 0 && off != pass_len); - return off == passlen ? 0 : gpgme_error_from_errno(errno); + return off == pass_len ? 0 : gpgme_error_from_errno(errno); } - void SetPassphraseCb(decltype(test_passphrase_cb) func); + void SetPassphraseCb(decltype(test_passphrase_cb) func) const; }; } // namespace GpgFrontend diff --git a/src/gpg/function/BasicOperator.cpp b/src/gpg/function/BasicOperator.cpp index 268b7c6d..50a2e2e3 100644 --- a/src/gpg/function/BasicOperator.cpp +++ b/src/gpg/function/BasicOperator.cpp @@ -201,7 +201,7 @@ std::unique_ptr<std::vector<GpgFrontend::GpgKey>> GpgFrontend::BasicOperator::GetSigners() { auto count = gpgme_signers_count(ctx); auto signers = std::make_unique<std::vector<GpgKey>>(); - for (auto i = 0; i < count; i++) { + for (auto i = 0u; i < count; i++) { auto key = GpgKey(gpgme_signers_enum(ctx, i)); signers->push_back(GpgKey(std::move(key))); } diff --git a/src/gpg/function/GpgCommandExecutor.cpp b/src/gpg/function/GpgCommandExecutor.cpp index dc4750ef..b5e6ccae 100644 --- a/src/gpg/function/GpgCommandExecutor.cpp +++ b/src/gpg/function/GpgCommandExecutor.cpp @@ -51,5 +51,5 @@ void GpgFrontend::GpgCommandExecutor::Execute( ios.run(); child_process.wait(); - int result = child_process.exit_code(); + child_process.exit_code(); } diff --git a/src/gpg/function/GpgKeyImportExportor.cpp b/src/gpg/function/GpgKeyImportExportor.cpp index 79d0c36a..2ee261b4 100644 --- a/src/gpg/function/GpgKeyImportExportor.cpp +++ b/src/gpg/function/GpgKeyImportExportor.cpp @@ -44,7 +44,7 @@ bool GpgFrontend::GpgKeyImportExportor::ExportKeys( // Alleviate another crash problem caused by an unknown array out-of-bounds // access - for (int i = 0; i < uid_list->size(); i++) { + for (size_t i = 0; i < uid_list->size(); i++) { GpgData data_out; auto err = gpgme_op_export(ctx, (*uid_list)[i].c_str(), 0, data_out); assert(gpgme_err_code(err) == GPG_ERR_NO_ERROR); diff --git a/src/gpg/model/GpgData.cpp b/src/gpg/model/GpgData.cpp index 30b03069..44e5ae44 100644 --- a/src/gpg/model/GpgData.cpp +++ b/src/gpg/model/GpgData.cpp @@ -73,5 +73,5 @@ GpgFrontend::BypeArrayPtr GpgFrontend::GpgData::Read2Buffer() { assert(gpgme_err_code(err) == GPG_ERR_NO_ERROR); } } - return std::move(out_buffer); + return out_buffer; }
\ No newline at end of file |