diff options
author | Saturneric <[email protected]> | 2022-05-19 19:00:46 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2022-05-19 19:00:46 +0000 |
commit | c80f04424b43814bdaed20ae166304f3d1bd1d2b (patch) | |
tree | cce93b5e345c4cde2d7a40bf65757465be82e9cc | |
parent | refactor: change log level for task system (diff) | |
download | GpgFrontend-c80f04424b43814bdaed20ae166304f3d1bd1d2b.tar.gz GpgFrontend-c80f04424b43814bdaed20ae166304f3d1bd1d2b.zip |
pref: improve pch for compiling speed
-rw-r--r-- | src/core/CMakeLists.txt | 8 | ||||
-rw-r--r-- | src/core/GpgConstants.cpp | 29 | ||||
-rw-r--r-- | src/core/GpgConstants.h | 9 | ||||
-rw-r--r-- | src/core/GpgFrontendCore.h | 74 | ||||
-rw-r--r-- | src/core/function/CharsetOperator.h | 2 | ||||
-rw-r--r-- | src/core/function/GlobalSettingStation.h | 5 | ||||
-rw-r--r-- | src/core/model/GpgKey.h | 3 | ||||
-rwxr-xr-x | src/ui/KeyMgmt.h | 4 |
8 files changed, 68 insertions, 66 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index c69c325d..f9c354a2 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -40,9 +40,6 @@ add_library(gpgfrontend_core SHARED ${GPG_SOURCE}) set(_export_file "${CMAKE_CURRENT_SOURCE_DIR}/GpgFrontendCoreExport.h") generate_export_header(gpgfrontend_core EXPORT_FILE_NAME "${_export_file}") -set(UTILS_DIR ${CMAKE_SOURCE_DIR}/utils) -set(GPGME_LIB_DIR ${UTILS_DIR}/gpgme/lib) - # link third-party libraries target_link_libraries(gpgfrontend_core PUBLIC config++) if (NOT LINUX) @@ -75,7 +72,7 @@ else () endif () # link gnupg libraries -target_link_libraries(gpgfrontend_core PUBLIC gpgme assuan gpg-error) +target_link_libraries(gpgfrontend_core PRIVATE gpgme assuan gpg-error) # link openssl target_link_libraries(gpgfrontend_core PUBLIC OpenSSL::SSL OpenSSL::Crypto) # link boost libraries @@ -97,7 +94,8 @@ target_link_libraries(gpgfrontend_core PUBLIC Qt5::Core) # set up pch target_precompile_headers(gpgfrontend_core PUBLIC ${CMAKE_SOURCE_DIR}/src/GpgFrontend.h - PUBLIC GpgFrontendCore.h) + PUBLIC GpgFrontendCore.h + PUBLIC GpgConstants.h) # using std c++ 17 target_compile_features(gpgfrontend_core PUBLIC cxx_std_17) diff --git a/src/core/GpgConstants.cpp b/src/core/GpgConstants.cpp index 88068f37..ff783872 100644 --- a/src/core/GpgConstants.cpp +++ b/src/core/GpgConstants.cpp @@ -28,10 +28,7 @@ #include "core/GpgConstants.h" -#include <gpg-error.h> - #include <boost/algorithm/string/predicate.hpp> -#include <string> #include "function/FileOperator.h" @@ -56,9 +53,9 @@ const char* GpgFrontend::GpgConstants::GPG_FRONTEND_SHORT_CRYPTO_HEAD = gpgme_error_t GpgFrontend::check_gpg_error(gpgme_error_t err) { if (gpg_err_code(err) != GPG_ERR_NO_ERROR) { - LOG(ERROR) << "[" << _("Error") << " " << gpg_err_code(err) << "] " - << _("Source: ") << gpgme_strsource(err) << " " - << _("Description: ") << gpgme_strerror(err); + LOG(ERROR) << "[" << _("Error") << gpg_err_code(err) << "]" << _("Source: ") + << gpgme_strsource(err) << _("Description: ") + << gpgme_strerror(err); } return err; } @@ -66,10 +63,16 @@ gpgme_error_t GpgFrontend::check_gpg_error(gpgme_error_t err) { gpg_err_code_t GpgFrontend::check_gpg_error_2_err_code(gpgme_error_t err, gpgme_error_t predict) { auto err_code = gpg_err_code(err); - if (err_code != predict) { - LOG(ERROR) << "[" << _("Error") << " " << gpg_err_code(err) << "] " - << _("Source: ") << gpgme_strsource(err) << " " - << _("Description: ") << gpgme_strerror(err); + if (err_code != gpg_err_code(predict)) { + if (err_code == GPG_ERR_NO_ERROR) + LOG(WARNING) << "[" << _("Warning") << gpg_err_code(err) << "]" + << _("Source: ") << gpgme_strsource(err) + << _("Description: ") << gpgme_strerror(err) << _("Predict") + << gpgme_strerror(err); + else + LOG(ERROR) << "[" << _("Error") << gpg_err_code(err) << "]" + << _("Source: ") << gpgme_strsource(err) << _("Description: ") + << gpgme_strerror(err) << _("Predict") << gpgme_strerror(err); } return err_code; } @@ -77,9 +80,9 @@ gpg_err_code_t GpgFrontend::check_gpg_error_2_err_code(gpgme_error_t err, gpgme_error_t GpgFrontend::check_gpg_error(gpgme_error_t err, const std::string& comment) { if (gpg_err_code(err) != GPG_ERR_NO_ERROR) { - LOG(ERROR) << "[" << _("Error") << " " << gpg_err_code(err) << "] " - << _("Source: ") << gpgme_strsource(err) << " " - << _("Description: ") << gpgme_strerror(err); + LOG(ERROR) << "[" << _("Error") << gpg_err_code(err) << "]" << _("Source: ") + << gpgme_strsource(err) << _("Description: ") + << gpgme_strerror(err); } return err; } diff --git a/src/core/GpgConstants.h b/src/core/GpgConstants.h index f3f0c6e6..06f8e20d 100644 --- a/src/core/GpgConstants.h +++ b/src/core/GpgConstants.h @@ -29,14 +29,7 @@ #ifndef GPG_CONSTANTS_H #define GPG_CONSTANTS_H -#include <GpgFrontend.h> -#include <gpgme.h> - -#include <cassert> -#include <functional> - -// dll export macro -#include "GpgFrontendCoreExport.h" +#include "GpgFrontendCore.h" const int RESTART_CODE = 1000; ///< diff --git a/src/core/GpgFrontendCore.h b/src/core/GpgFrontendCore.h index 90bc36be..db3339c3 100644 --- a/src/core/GpgFrontendCore.h +++ b/src/core/GpgFrontendCore.h @@ -1,29 +1,29 @@ /** -* Copyright (C) 2021 Saturneric -* -* This file is part of GpgFrontend. -* -* GpgFrontend is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* GpgFrontend is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>. -* -* The initial version of the source code is inherited from -* 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. -* -* SPDX-License-Identifier: GPL-3.0-or-later -* + * Copyright (C) 2021 Saturneric + * + * This file is part of GpgFrontend. + * + * GpgFrontend is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GpgFrontend is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>. + * + * The initial version of the source code is inherited from + * 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. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * */ #ifndef GPGFRONTEND_GPGFRONTENDCORE_H @@ -31,11 +31,29 @@ #include "GpgFrontend.h" +// gnupg +#include <gpgme.h> + // std includes -#include <random> +#include <cassert> #include <filesystem> +#include <functional> +#include <map> +#include <memory> +#include <mutex> +#include <random> +#include <shared_mutex> +#include <stdexcept> +#include <string> +#include <typeinfo> +#include <utility> +#include <vector> // boost includes +#include <boost/date_time.hpp> +#include <boost/date_time/posix_time/conversion.hpp> +#include <boost/filesystem/operations.hpp> +#include <boost/filesystem/path.hpp> #include <boost/format.hpp> // Qt includes @@ -48,7 +66,7 @@ #include <libarchive/libarchive/archive.h> #include <libarchive/libarchive/archive_entry.h> -#include "GpgConstants.h" - +// dll export macro +#include "GpgFrontendCoreExport.h" #endif // GPGFRONTEND_GPGFRONTENDCORE_H diff --git a/src/core/function/CharsetOperator.h b/src/core/function/CharsetOperator.h index c04430f2..41ce62f4 100644 --- a/src/core/function/CharsetOperator.h +++ b/src/core/function/CharsetOperator.h @@ -29,8 +29,6 @@ #ifndef GPGFRONTEND_CHARSETDETECTOR_H #define GPGFRONTEND_CHARSETDETECTOR_H -#include <string> - #include "core/GpgFrontendCore.h" namespace GpgFrontend { diff --git a/src/core/function/GlobalSettingStation.h b/src/core/function/GlobalSettingStation.h index 0df6bd21..ee0b6b12 100644 --- a/src/core/function/GlobalSettingStation.h +++ b/src/core/function/GlobalSettingStation.h @@ -29,11 +29,6 @@ #ifndef GPGFRONTEND_GLOBALSETTINGSTATION_H #define GPGFRONTEND_GLOBALSETTINGSTATION_H -#include <openssl/x509.h> - -#include <boost/filesystem/operations.hpp> -#include <boost/filesystem/path.hpp> - #include "GpgFrontendBuildInstallInfo.h" #include "core/GpgFrontendCore.h" #include "core/GpgFunctionObject.h" diff --git a/src/core/model/GpgKey.h b/src/core/model/GpgKey.h index 457b6540..4761f8a5 100644 --- a/src/core/model/GpgKey.h +++ b/src/core/model/GpgKey.h @@ -29,9 +29,6 @@ #ifndef GPGFRONTEND_GPGKEY_H #define GPGFRONTEND_GPGKEY_H -#include <boost/date_time.hpp> -#include <boost/date_time/posix_time/conversion.hpp> - #include "GpgSubKey.h" #include "GpgUID.h" diff --git a/src/ui/KeyMgmt.h b/src/ui/KeyMgmt.h index ad58a5aa..25ee80c5 100755 --- a/src/ui/KeyMgmt.h +++ b/src/ui/KeyMgmt.h @@ -29,9 +29,9 @@ #ifndef __KEYMGMT_H__ #define __KEYMGMT_H__ -#include "import_export/KeyImportDetailDialog.h" -#include "import_export/KeyServerImportDialog.h" #include "ui/GpgFrontendUI.h" +#include "ui/import_export/KeyImportDetailDialog.h" +#include "ui/import_export/KeyServerImportDialog.h" #include "ui/key_generate/KeygenDialog.h" #include "ui/keypair_details/KeyDetailsDialog.h" #include "ui/widgets/KeyList.h" |