aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-07-30 18:42:12 +0000
committersaturneric <[email protected]>2024-07-30 18:42:12 +0000
commitdbb4a21931cd10a3caed3c446af0fe06de9873b1 (patch)
treeb3eb2e6fc3e67ea274472dfacfa3451848b43c80
parentfix: solve known issues on build (diff)
downloadGpgFrontend-dbb4a21931cd10a3caed3c446af0fe06de9873b1.tar.gz
GpgFrontend-dbb4a21931cd10a3caed3c446af0fe06de9873b1.zip
feat: simplify logging
-rw-r--r--.gitignore2
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/GpgCoreInit.cpp16
-rw-r--r--src/core/GpgFrontendCore.h21
-rw-r--r--src/core/function/ArchiveFileOperator.cpp36
-rw-r--r--src/core/function/CacheManager.cpp4
-rw-r--r--src/core/function/DataObjectOperator.cpp12
-rw-r--r--src/core/function/GlobalSettingStation.cpp10
-rw-r--r--src/core/function/KeyPackageOperator.cpp10
-rw-r--r--src/core/function/basic/SingletonStorage.cpp16
-rw-r--r--src/core/function/gpg/GpgAdvancedOperator.cpp41
-rw-r--r--src/core/function/gpg/GpgBasicOperator.cpp7
-rw-r--r--src/core/function/gpg/GpgCommandExecutor.cpp46
-rw-r--r--src/core/function/gpg/GpgContext.cpp48
-rw-r--r--src/core/function/gpg/GpgFileOpera.cpp16
-rw-r--r--src/core/function/gpg/GpgKeyGetter.cpp5
-rw-r--r--src/core/function/gpg/GpgKeyManager.cpp135
-rw-r--r--src/core/function/gpg/GpgKeyOpera.cpp68
-rw-r--r--src/core/function/gpg/GpgUIDOperator.cpp2
-rw-r--r--src/core/model/GpgGenKeyInfo.cpp2
-rw-r--r--src/core/model/SettingsObject.cpp2
-rw-r--r--src/core/module/Event.cpp5
-rw-r--r--src/core/module/GlobalModuleContext.cpp45
-rw-r--r--src/core/module/Module.cpp42
-rw-r--r--src/core/module/ModuleInit.cpp8
-rw-r--r--src/core/module/ModuleManager.cpp12
-rw-r--r--src/core/thread/FileReadTask.cpp2
-rw-r--r--src/core/thread/Task.cpp6
-rw-r--r--src/core/thread/TaskRunner.cpp4
-rw-r--r--src/core/utils/AsyncUtils.cpp8
-rw-r--r--src/core/utils/GpgUtils.cpp28
-rw-r--r--src/core/utils/IOUtils.cpp16
-rw-r--r--src/sdk/GFSDKExport.h42
-rw-r--r--src/test/CMakeLists.txt2
-rw-r--r--src/test/GpgFrontendCoreExport.h42
-rw-r--r--src/test/GpgFrontendTest.cpp4
-rw-r--r--src/test/GpgFrontendTest.h20
-rw-r--r--src/test/GpgFrontendTestExport.h42
-rw-r--r--src/ui/CMakeLists.txt2
-rw-r--r--src/ui/GpgFrontendApplication.cpp4
-rw-r--r--src/ui/GpgFrontendUI.h27
-rw-r--r--src/ui/GpgFrontendUIInit.cpp12
-rw-r--r--src/ui/UserInterfaceUtils.cpp12
-rw-r--r--src/ui/dialog/GeneralDialog.cpp4
-rw-r--r--src/ui/dialog/Wizard.cpp2
-rw-r--r--src/ui/dialog/import_export/KeyServerImportDialog.cpp2
-rw-r--r--src/ui/dialog/import_export/KeyUploadDialog.cpp2
-rw-r--r--src/ui/dialog/keypair_details/KeyPairOperaTab.cpp4
-rw-r--r--src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp2
-rw-r--r--src/ui/function/GenerateRevokeCertification.cpp4
-rw-r--r--src/ui/main_window/GeneralMainWindow.cpp4
-rw-r--r--src/ui/main_window/KeyMgmt.cpp2
-rw-r--r--src/ui/main_window/MainWindow.cpp2
-rw-r--r--src/ui/main_window/MainWindowSlotFunction.cpp12
-rw-r--r--src/ui/thread/KeyServerImportTask.cpp3
-rw-r--r--src/ui/widgets/KeyList.cpp10
-rw-r--r--src/ui/widgets/PlainTextEditorPage.cpp2
-rw-r--r--src/ui/widgets/TextEdit.cpp2
58 files changed, 424 insertions, 519 deletions
diff --git a/.gitignore b/.gitignore
index 4ec64539..017bab82 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,8 @@ src/GpgFrontendBuildInfo.h
src/GpgFrontendBuildInstallInfo.h
src/core/GpgFrontendCoreExport.h
src/ui/GpgFrontendUIExport.h
+src/test/GpgFrontendTestExport.h
+src/sdk/GFSDKExport.h
src/sdk/GFSDKBuildInfo.h
docs/
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 921e8944..81c3f08f 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -48,7 +48,7 @@ set(_export_file "${CMAKE_CURRENT_SOURCE_DIR}/GpgFrontendCoreExport.h")
generate_export_header(gpgfrontend_core EXPORT_FILE_NAME "${_export_file}")
# compile definitions
-target_compile_definitions(gpgfrontend_core PUBLIC GF_CORE)
+target_compile_definitions(gpgfrontend_core PRIVATE GF_CORE_PRIVATE)
# mimalloc (except apple macos)
if(NOT APPLE)
diff --git a/src/core/GpgCoreInit.cpp b/src/core/GpgCoreInit.cpp
index 3e03536a..d0f24824 100644
--- a/src/core/GpgCoreInit.cpp
+++ b/src/core/GpgCoreInit.cpp
@@ -177,7 +177,7 @@ auto InitGpgME(const QString& gpgconf_path, const QString& gnupg_path) -> bool {
// conditional check: only support gpg 2.1.x now
if (!(GFCompareSoftwareVersion(gnupg_version, "2.1.0") >= 0 && find_gpgconf &&
find_openpgp && find_cms)) {
- qCWarning(core, "gpgme env check failed, abort");
+ FLOG_W("gpgme env check failed, abort");
return false;
}
@@ -238,8 +238,8 @@ auto DetectGpgConfPath() -> QString {
#endif
if (!VerifyGpgconfPath(QFileInfo(gnupg_install_fs_path))) {
- qCWarning(core) << "core loaded custom gpgconf path is illegal: "
- << gnupg_install_fs_path;
+ LOG_W() << "core loaded custom gpgconf path is illegal: "
+ << gnupg_install_fs_path;
gnupg_install_fs_path = "";
}
}
@@ -279,8 +279,8 @@ void InitGpgFrontendCore(CoreInitArgs args) {
auto gpgconf_install_fs_path = DetectGpgConfPath();
auto gnupg_install_fs_path = DetectGnuPGPath(gpgconf_install_fs_path);
- qCInfo(core) << "detected gpgconf path: " << gpgconf_install_fs_path;
- qCInfo(core) << "detected gnupg path: " << gnupg_install_fs_path;
+ LOG_I() << "detected gpgconf path: " << gpgconf_install_fs_path;
+ LOG_I() << "detected gnupg path: " << gnupg_install_fs_path;
// initialize library gpgme
if (!InitGpgME(gpgconf_install_fs_path, gnupg_install_fs_path)) {
@@ -329,8 +329,8 @@ void InitGpgFrontendCore(CoreInitArgs args) {
key_database_fs_path =
QFileInfo(custom_gnupg_install_path).absoluteFilePath();
} else {
- qCWarning(core) << "custom gpg key database path is not suitable: "
- << key_database_fs_path;
+ LOG_W() << "custom gpg key database path is not suitable: "
+ << key_database_fs_path;
}
} else {
@@ -369,7 +369,7 @@ void InitGpgFrontendCore(CoreInitArgs args) {
// exit if failed
if (!ctx.Good()) {
- qCWarning(core, "default gnupg context init error, abort");
+ FLOG_W("default gnupg context init error, abort");
CoreSignalStation::GetInstance()->SignalBadGnupgEnv(
QCoreApplication::tr("GpgME Context initiation failed"));
return -1;
diff --git a/src/core/GpgFrontendCore.h b/src/core/GpgFrontendCore.h
index fbbab22e..1d5ae29f 100644
--- a/src/core/GpgFrontendCore.h
+++ b/src/core/GpgFrontendCore.h
@@ -28,13 +28,28 @@
#pragma once
-// Qt
+// project base header
+#include "GpgFrontend.h"
+
+// qt
#include <QtCore>
-// declare area of core
-#ifdef GF_CORE
+// private declare area of core
+#ifdef GF_CORE_PRIVATE
// declare logging category
Q_DECLARE_LOGGING_CATEGORY(core)
+#define LOG_D() qCDebug(core)
+#define LOG_I() qCInfo(core)
+#define LOG_W() qCWarning(core)
+#define LOG_E() qCCritical(core)
+#define LOG_F() qCFatal(core)
+
+#define FLOG_D(...) qCDebug(core, __VA_ARGS__)
+#define FLOG_I(...) qCInfo(core, __VA_ARGS__)
+#define FLOG_W(...) qCWarning(core, __VA_ARGS__)
+#define FLOG_E(...) qCCritical(core, __VA_ARGS__)
+#define FLOG_F(...) qCFatal(core, __VA_ARGS__)
+
#endif \ No newline at end of file
diff --git a/src/core/function/ArchiveFileOperator.cpp b/src/core/function/ArchiveFileOperator.cpp
index 2fc801ab..71c36d46 100644
--- a/src/core/function/ArchiveFileOperator.cpp
+++ b/src/core/function/ArchiveFileOperator.cpp
@@ -46,14 +46,14 @@ auto CopyData(struct archive *ar, struct archive *aw) -> int {
r = archive_read_data_block(ar, &buff, &size, &offset);
if (r == ARCHIVE_EOF) return (ARCHIVE_OK);
if (r != ARCHIVE_OK) {
- qCWarning(core) << "archive_read_data_block() failed: "
- << archive_error_string(ar);
+ LOG_W() << "archive_read_data_block() failed: "
+ << archive_error_string(ar);
return (r);
}
r = archive_write_data_block(aw, buff, size, offset);
if (r != ARCHIVE_OK) {
- qCWarning(core) << "archive_write_data_block() failed: "
- << archive_error_string(aw);
+ LOG_W() << "archive_write_data_block() failed: "
+ << archive_error_string(aw);
return (r);
}
}
@@ -113,8 +113,8 @@ void ArchiveFileOperator::NewArchive2DataExchanger(
#endif
if (r != ARCHIVE_OK) {
- qCWarning(core, "archive_read_disk_open() failed: %s, abort...",
- archive_error_string(disk));
+ FLOG_W("archive_read_disk_open() failed: %s, abort...",
+ archive_error_string(disk));
archive_read_free(disk);
archive_write_free(archive);
return -1;
@@ -227,8 +227,8 @@ void ArchiveFileOperator::ExtractArchiveFromDataExchanger(
nullptr);
if (r != ARCHIVE_OK) {
- qCWarning(core, "archive_read_open(), ret: %d, reason: %s", r,
- archive_error_string(archive));
+ FLOG_W("archive_read_open(), ret: %d, reason: %s", r,
+ archive_error_string(archive));
return r;
}
@@ -245,8 +245,8 @@ void ArchiveFileOperator::ExtractArchiveFromDataExchanger(
r = archive_read_next_header(archive, &entry);
if (r == ARCHIVE_EOF) break;
if (r != ARCHIVE_OK) {
- qCWarning(core, "archive_read_next_header(), ret: %d, reason: %s",
- r, archive_error_string(archive));
+ FLOG_W("archive_read_next_header(), ret: %d, reason: %s", r,
+ archive_error_string(archive));
break;
}
@@ -264,8 +264,8 @@ void ArchiveFileOperator::ExtractArchiveFromDataExchanger(
r = archive_write_header(ext, entry);
if (r != ARCHIVE_OK) {
- qCWarning(core, "archive_write_header(), ret: %d, reason: %s", r,
- archive_error_string(archive));
+ FLOG_W("archive_write_header(), ret: %d, reason: %s", r,
+ archive_error_string(archive));
} else {
r = CopyData(archive, ext);
}
@@ -273,13 +273,13 @@ void ArchiveFileOperator::ExtractArchiveFromDataExchanger(
r = archive_read_free(archive);
if (r != ARCHIVE_OK) {
- qCWarning(core, "archive_read_free(), ret: %d, reason: %s", r,
- archive_error_string(archive));
+ FLOG_W("archive_read_free(), ret: %d, reason: %s", r,
+ archive_error_string(archive));
}
r = archive_write_free(ext);
if (r != ARCHIVE_OK) {
- qCWarning(core, "archive_read_free(), ret: %d, reason: %s", r,
- archive_error_string(archive));
+ FLOG_W("archive_read_free(), ret: %d, reason: %s", r,
+ archive_error_string(archive));
}
return 0;
@@ -299,8 +299,8 @@ void ArchiveFileOperator::ListArchive(const QString &archive_path) {
10240); // Note 1
if (r != ARCHIVE_OK) return;
while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
- qCDebug(core, core, "File: %s", archive_entry_pathname(entry));
- qCDebug(core, core, "File Path: %s", archive_entry_pathname(entry));
+ FLOG_D("File: %s", archive_entry_pathname(entry));
+ FLOG_D("File Path: %s", archive_entry_pathname(entry));
archive_read_data_skip(a); // Note 2
}
r = archive_read_free(a); // Note 3
diff --git a/src/core/function/CacheManager.cpp b/src/core/function/CacheManager.cpp
index bbb52cc7..05138025 100644
--- a/src/core/function/CacheManager.cpp
+++ b/src/core/function/CacheManager.cpp
@@ -164,7 +164,7 @@ class CacheManager::Impl : public QObject {
*
*/
void slot_flush_cache_storage() {
- qCDebug(core, "write cache to file system...");
+ FLOG_D("write cache to file system...");
for (const auto& cache : durable_cache_storage_.mirror()) {
auto key = get_data_object_key(cache.first);
@@ -215,7 +215,7 @@ class CacheManager::Impl : public QObject {
*
*/
void load_all_cache_storage() {
- qCDebug(core, "start to load all cache from file system");
+ FLOG_D("start to load all cache from file system");
auto stored_data =
GpgFrontend::DataObjectOperator::GetInstance().GetDataObject(drk_key_);
diff --git a/src/core/function/DataObjectOperator.cpp b/src/core/function/DataObjectOperator.cpp
index 634228c9..b762b1c8 100644
--- a/src/core/function/DataObjectOperator.cpp
+++ b/src/core/function/DataObjectOperator.cpp
@@ -49,8 +49,7 @@ DataObjectOperator::DataObjectOperator(int channel)
QByteArray key;
if (!ReadFile(app_secure_key_path_, key)) {
- qCWarning(core) << "failed to read app secure key file: "
- << app_secure_key_path_;
+ LOG_W() << "failed to read app secure key file: " << app_secure_key_path_;
// unsafe mode
key = {};
}
@@ -91,7 +90,7 @@ auto DataObjectOperator::SaveDataObj(const QString& key,
}
if (!WriteFile(target_obj_path, encoded_data)) {
- qCWarning(core) << "failed to write data object to disk: " << key;
+ LOG_W() << "failed to write data object to disk: " << key;
}
return key.isEmpty() ? hash_obj_key : QString();
}
@@ -105,13 +104,13 @@ auto DataObjectOperator::GetDataObject(const QString& key)
const auto obj_path = app_data_objs_path_ + "/" + hash_obj_key;
if (!QFileInfo(obj_path).exists()) {
- qCWarning(core) << "data object not found from disk, key: " << key;
+ LOG_W() << "data object not found from disk, key: " << key;
return {};
}
QByteArray encoded_data;
if (!ReadFile(obj_path, encoded_data)) {
- qCWarning(core) << "failed to read data object from disk, key: " << key;
+ LOG_W() << "failed to read data object from disk, key: " << key;
return {};
}
@@ -123,8 +122,7 @@ auto DataObjectOperator::GetDataObject(const QString& key)
return QJsonDocument::fromJson(decoded_data);
} catch (...) {
- qCWarning(core) << "failed to get data object:" << key
- << " caught exception.";
+ LOG_W() << "failed to get data object:" << key << " caught exception.";
return {};
}
}
diff --git a/src/core/function/GlobalSettingStation.cpp b/src/core/function/GlobalSettingStation.cpp
index 68fc79d7..42aced01 100644
--- a/src/core/function/GlobalSettingStation.cpp
+++ b/src/core/function/GlobalSettingStation.cpp
@@ -40,8 +40,8 @@ class GlobalSettingStation::Impl {
*
*/
explicit Impl() noexcept {
- qCInfo(core) << "app path: " << GetAppDir();
- qCInfo(core) << "app working path: " << working_path_;
+ LOG_I() << "app path: " << GetAppDir();
+ LOG_I() << "app working path: " << working_path_;
auto portable_file_path = working_path_ + "/PORTABLE.txt";
if (QFileInfo(portable_file_path).exists()) {
@@ -54,11 +54,11 @@ class GlobalSettingStation::Impl {
portable_mode_ = true;
}
- qCInfo(core) << "app data path: " << app_data_path_;
- qCInfo(core) << "app log path: " << app_log_path_;
+ LOG_I() << "app data path: " << app_data_path_;
+ LOG_I() << "app log path: " << app_log_path_;
#if defined(_WIN32) || defined(WIN32)
- qCInfo(core) << "app config path: " << app_config_path_;
+ LOG_I() << "app config path: " << app_config_path_;
if (!QDir(app_config_path_).exists()) QDir(app_config_path_).mkpath(".");
#endif
diff --git a/src/core/function/KeyPackageOperator.cpp b/src/core/function/KeyPackageOperator.cpp
index ccba642c..c5c573ce 100644
--- a/src/core/function/KeyPackageOperator.cpp
+++ b/src/core/function/KeyPackageOperator.cpp
@@ -45,7 +45,7 @@ namespace GpgFrontend {
auto KeyPackageOperator::GeneratePassphrase(const QString& phrase_path,
QString& phrase) -> bool {
phrase = PassphraseGenerator::GetInstance().Generate(256);
- qCDebug(core, "generated passphrase: %lld bytes", phrase.size());
+ FLOG_D("generated passphrase: %lld bytes", phrase.size());
return WriteFile(phrase_path, phrase.toUtf8());
}
@@ -57,8 +57,8 @@ void KeyPackageOperator::GenerateKeyPackage(const QString& key_package_path,
GpgKeyImportExporter::GetInstance().ExportAllKeys(
keys, secret, true, [=](GpgError err, const DataObjectPtr& data_obj) {
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
- qCWarning(core) << "export keys error, reason: "
- << DescribeGpgErrCode(err).second;
+ LOG_W() << "export keys error, reason: "
+ << DescribeGpgErrCode(err).second;
cb(-1, data_obj);
return;
}
@@ -93,14 +93,14 @@ void KeyPackageOperator::ImportKeyPackage(const QString& key_package_path,
ReadFile(key_package_path, encrypted_data);
if (encrypted_data.isEmpty()) {
- qCWarning(core) << "failed to read key package: " << key_package_path;
+ LOG_W() << "failed to read key package: " << key_package_path;
return -1;
};
QByteArray passphrase;
ReadFile(phrase_path, passphrase);
if (passphrase.size() != 256) {
- qCWarning(core) << "passphrase size mismatch: " << phrase_path;
+ LOG_W() << "passphrase size mismatch: " << phrase_path;
return -1;
}
diff --git a/src/core/function/basic/SingletonStorage.cpp b/src/core/function/basic/SingletonStorage.cpp
index 4883c3a1..edc52b4a 100644
--- a/src/core/function/basic/SingletonStorage.cpp
+++ b/src/core/function/basic/SingletonStorage.cpp
@@ -53,7 +53,7 @@ class SingletonStorage::Impl {
std::shared_lock<std::shared_mutex> lock(instances_mutex_);
ins_it = instances_map_.find(channel);
if (ins_it == instances_map_.end()) {
- qCDebug(core, "cannot find channel object, channel: %d", channel);
+ FLOG_D("cannot find channel object, channel: %d", channel);
return nullptr;
}
return ins_it->second.get();
@@ -71,14 +71,14 @@ class SingletonStorage::Impl {
auto SetObjectInChannel(int channel, ChannelObjectPtr p_obj)
-> GpgFrontend::ChannelObject* {
- qCDebug(core, "set channel object, type: %s in channel: %d, address: %p",
- typeid(p_obj.get()).name(), channel,
- static_cast<void*>(p_obj.get()));
+ FLOG_D("set channel object, type: %s in channel: %d, address: %p",
+ typeid(p_obj.get()).name(), channel,
+ static_cast<void*>(p_obj.get()));
assert(p_obj != nullptr);
if (p_obj == nullptr) {
- qCWarning(core, "cannot set a nullptr as a channel object of channel: %d",
- channel);
+ FLOG_W("cannot set a nullptr as a channel object of channel: %d",
+ channel);
return nullptr;
}
@@ -94,8 +94,8 @@ class SingletonStorage::Impl {
instances_map_[channel] = std::move(p_obj);
}
- qCDebug(core, "set channel: %d success, current channel object address: %p",
- channel, static_cast<void*>(raw_obj));
+ FLOG_D("set channel: %d success, current channel object address: %p",
+ channel, static_cast<void*>(raw_obj));
return raw_obj;
}
diff --git a/src/core/function/gpg/GpgAdvancedOperator.cpp b/src/core/function/gpg/GpgAdvancedOperator.cpp
index 3d5a7b59..20d9aa4b 100644
--- a/src/core/function/gpg/GpgAdvancedOperator.cpp
+++ b/src/core/function/gpg/GpgAdvancedOperator.cpp
@@ -41,7 +41,7 @@ void GpgFrontend::GpgAdvancedOperator::ClearGpgPasswordCache(
"core", "gpgme.ctx.gpgconf_path", QString{});
if (gpgconf_path.isEmpty()) {
- qCWarning(core, "cannot get valid gpgconf path from rt, abort.");
+ FLOG_W("cannot get valid gpgconf path from rt, abort.");
cb(-1, TransferParams());
return;
}
@@ -60,7 +60,7 @@ void GpgFrontend::GpgAdvancedOperator::ReloadGpgComponents(
"core", "gpgme.ctx.gpgconf_path", QString{});
if (gpgconf_path.isEmpty()) {
- qCWarning(core, "cannot get valid gpgconf path from rt, abort.");
+ FLOG_W("cannot get valid gpgconf path from rt, abort.");
cb(-1, TransferParams());
return;
}
@@ -68,7 +68,7 @@ void GpgFrontend::GpgAdvancedOperator::ReloadGpgComponents(
GpgFrontend::GpgCommandExecutor::ExecuteSync(
{gpgconf_path, QStringList{"--reload"},
[=](int exit_code, const QString &, const QString &) {
- qCDebug(core, "gpgconf reload exit code: %d", exit_code);
+ FLOG_D("gpgconf reload exit code: %d", exit_code);
cb(exit_code == 0 ? 0 : -1, TransferParams());
}});
}
@@ -78,7 +78,7 @@ void GpgFrontend::GpgAdvancedOperator::KillAllGpgComponents() {
"core", "gpgme.ctx.gpgconf_path", QString{});
if (gpgconf_path.isEmpty()) {
- qCWarning(core, "cannot get valid gpgconf path from rt, abort.");
+ FLOG_W("cannot get valid gpgconf path from rt, abort.");
return;
}
@@ -88,12 +88,12 @@ void GpgFrontend::GpgAdvancedOperator::KillAllGpgComponents() {
bool success = true;
if (exit_code != 0) {
success = false;
- qCWarning(core) << "gpgconf execute error, process stderr: " << p_err
- << ", process stdout: " << p_out;
+ LOG_W() << "gpgconf execute error, process stderr: " << p_err
+ << ", process stdout: " << p_out;
return;
}
- qCDebug(core, "gpgconf --kill --all execute result: %d", success);
+ FLOG_D("gpgconf --kill --all execute result: %d", success);
}});
}
@@ -102,24 +102,23 @@ void GpgFrontend::GpgAdvancedOperator::RestartGpgComponents() {
"core", "gpgme.ctx.gpgconf_path", QString{});
if (gpgconf_path.isEmpty()) {
- qCWarning(core, "cannot get valid gpgconf path from rt, abort.");
+ FLOG_W("cannot get valid gpgconf path from rt, abort.");
return;
}
GpgFrontend::GpgCommandExecutor::ExecuteSync(
{gpgconf_path, QStringList{"--verbose", "--kill", "all"},
[=](int exit_code, const QString &p_out, const QString &p_err) {
- qCDebug(core, "gpgconf --kill all command got exit code: %d",
- exit_code);
+ FLOG_D("gpgconf --kill all command got exit code: %d", exit_code);
bool success = true;
if (exit_code != 0) {
success = false;
- qCWarning(core) << "gpgconf execute error, process stderr: " << p_err
- << ", process stdout: " << p_out;
+ LOG_W() << "gpgconf execute error, process stderr: " << p_err
+ << ", process stdout: " << p_out;
return;
}
- qCDebug(core, "gpgconf --kill --all execute result: %d", success);
+ FLOG_D("gpgconf --kill --all execute result: %d", success);
if (!success) {
qCWarning(core,
"restart all component after core initilized failed");
@@ -143,7 +142,7 @@ void GpgFrontend::GpgAdvancedOperator::ResetConfigures(OperationCallback cb) {
"core", "gpgme.ctx.gpgconf_path", QString{});
if (gpgconf_path.isEmpty()) {
- qCWarning(core, "cannot get valid gpgconf path from rt, abort.");
+ FLOG_W("cannot get valid gpgconf path from rt, abort.");
cb(-1, TransferParams());
return;
}
@@ -151,7 +150,7 @@ void GpgFrontend::GpgAdvancedOperator::ResetConfigures(OperationCallback cb) {
GpgFrontend::GpgCommandExecutor::ExecuteSync(
{gpgconf_path, QStringList{"--apply-defaults"},
[=](int exit_code, const QString &, const QString &) {
- qCDebug(core, "gpgconf apply-defaults exit code: %d", exit_code);
+ FLOG_D("gpgconf apply-defaults exit code: %d", exit_code);
cb(exit_code == 0 ? 0 : -1, TransferParams());
}});
}
@@ -169,7 +168,7 @@ void GpgFrontend::GpgAdvancedOperator::StartGpgAgent(OperationCallback cb) {
kGnuPGInfoGatheringModuleID, "gnupg.home_path", QString{});
if (gpg_agent_path.isEmpty()) {
- qCWarning(core, "cannot get valid gpg agent path from rt, abort.");
+ FLOG_W("cannot get valid gpg agent path from rt, abort.");
cb(-1, TransferParams());
return;
}
@@ -177,7 +176,7 @@ void GpgFrontend::GpgAdvancedOperator::StartGpgAgent(OperationCallback cb) {
GpgFrontend::GpgCommandExecutor::ExecuteSync(
{gpg_agent_path, QStringList{"--homedir", home_path, "--daemon"},
[=](int exit_code, const QString &, const QString &) {
- qCDebug(core, "gpgconf daemon exit code: %d", exit_code);
+ FLOG_D("gpgconf daemon exit code: %d", exit_code);
cb(exit_code >= 0 ? 0 : -1, TransferParams());
}});
}
@@ -195,7 +194,7 @@ void GpgFrontend::GpgAdvancedOperator::StartDirmngr(OperationCallback cb) {
kGnuPGInfoGatheringModuleID, "gnupg.home_path", QString{});
if (dirmngr_path.isEmpty()) {
- qCWarning(core, "cannot get valid dirmngr path from rt, abort.");
+ FLOG_W("cannot get valid dirmngr path from rt, abort.");
cb(-1, TransferParams());
return;
}
@@ -203,7 +202,7 @@ void GpgFrontend::GpgAdvancedOperator::StartDirmngr(OperationCallback cb) {
GpgFrontend::GpgCommandExecutor::ExecuteSync(
{dirmngr_path, QStringList{"--homedir", home_path, "--daemon"},
[=](int exit_code, const QString &, const QString &) {
- qCDebug(core, "gpgconf daemon exit code: %d", exit_code);
+ FLOG_D("gpgconf daemon exit code: %d", exit_code);
cb(exit_code >= 0 ? 0 : -1, TransferParams());
}});
}
@@ -221,7 +220,7 @@ void GpgFrontend::GpgAdvancedOperator::StartKeyBoxd(OperationCallback cb) {
kGnuPGInfoGatheringModuleID, "gnupg.home_path", QString{});
if (keyboxd_path.isEmpty()) {
- qCWarning(core, "cannot get valid keyboxd path from rt, abort.");
+ FLOG_W("cannot get valid keyboxd path from rt, abort.");
cb(-1, TransferParams());
return;
}
@@ -229,7 +228,7 @@ void GpgFrontend::GpgAdvancedOperator::StartKeyBoxd(OperationCallback cb) {
GpgFrontend::GpgCommandExecutor::ExecuteSync(
{keyboxd_path, QStringList{"--homedir", home_path, "--daemon"},
[=](int exit_code, const QString &, const QString &) {
- qCDebug(core, "gpgconf daemon exit code: %d", exit_code);
+ FLOG_D("gpgconf daemon exit code: %d", exit_code);
cb(exit_code >= 0 ? 0 : -1, TransferParams());
}});
}
diff --git a/src/core/function/gpg/GpgBasicOperator.cpp b/src/core/function/gpg/GpgBasicOperator.cpp
index eb4ac337..6443f242 100644
--- a/src/core/function/gpg/GpgBasicOperator.cpp
+++ b/src/core/function/gpg/GpgBasicOperator.cpp
@@ -390,14 +390,15 @@ void GpgBasicOperator::SetSigners(const KeyArgsList& signers, bool ascii) {
gpgme_signers_clear(ctx);
for (const GpgKey& key : signers) {
- qCDebug(core) << "signer's key fpr: " << key.GetFingerprint();
+ LOG_D() << "signer's key fpr: " << key.GetFingerprint();
if (key.IsHasActualSigningCapability()) {
auto error = gpgme_signers_add(ctx, gpgme_key_t(key));
CheckGpgError(error);
}
}
- if (signers.size() != gpgme_signers_count(ctx_.DefaultContext()))
- qCDebug(core, "not all signers added");
+ if (signers.size() != gpgme_signers_count(ctx_.DefaultContext())) {
+ FLOG_D("not all signers added");
+ }
}
auto GpgBasicOperator::GetSigners(bool ascii) -> std::unique_ptr<KeyArgsList> {
diff --git a/src/core/function/gpg/GpgCommandExecutor.cpp b/src/core/function/gpg/GpgCommandExecutor.cpp
index 6b65afc5..374d59d8 100644
--- a/src/core/function/gpg/GpgCommandExecutor.cpp
+++ b/src/core/function/gpg/GpgCommandExecutor.cpp
@@ -50,7 +50,7 @@ auto BuildTaskFromExecCtx(const GpgCommandExecutor::ExecuteContext &context)
data_object->GetObjectSize());
if (!data_object->Check<int, QString, GpgCommandExecutorCallback>()) {
- qCWarning(core, "data object checking failed");
+ FLOG_W("data object checking failed");
return;
}
@@ -64,12 +64,12 @@ auto BuildTaskFromExecCtx(const GpgCommandExecutor::ExecuteContext &context)
Thread::Task::TaskRunnable runner =
[](const DataObjectPtr &data_object) -> int {
- qCDebug(core, "process runner called, data object size: %lu",
- data_object->GetObjectSize());
+ FLOG_D("process runner called, data object size: %lu",
+ data_object->GetObjectSize());
if (!data_object->Check<QString, QStringList, GpgCommandExecutorInteractor,
GpgCommandExecutorCallback>()) {
- qCWarning(core, "data object checking failed");
+ FLOG_W("data object checking failed");
return -1;
}
@@ -100,23 +100,23 @@ auto BuildTaskFromExecCtx(const GpgCommandExecutor::ExecuteContext &context)
QObject::connect(
cmd_process, &QProcess::started, [cmd, joined_argument]() -> void {
- qCDebug(core) << "\n== Process Execute Started ==\nCommand: " << cmd
- << "\nArguments: " << joined_argument
- << " \n========================";
+ LOG_D() << "\n== Process Execute Started ==\nCommand: " << cmd
+ << "\nArguments: " << joined_argument
+ << " \n========================";
});
QObject::connect(
cmd_process, &QProcess::readyReadStandardOutput,
[interact_func, cmd_process]() { interact_func(cmd_process); });
QObject::connect(cmd_process, &QProcess::errorOccurred,
[=](QProcess::ProcessError error) {
- qCWarning(core)
+ LOG_W()
<< "caught error while executing command: " << cmd
<< joined_argument << ", error:" << error;
});
- qCDebug(core) << "\n== Process Execute Ready ==\nCommand: " << cmd
- << "\nArguments: " << joined_argument
- << "\n========================";
+ LOG_D() << "\n== Process Execute Ready ==\nCommand: " << cmd
+ << "\nArguments: " << joined_argument
+ << "\n========================";
cmd_process->start();
cmd_process->waitForFinished();
@@ -124,13 +124,13 @@ auto BuildTaskFromExecCtx(const GpgCommandExecutor::ExecuteContext &context)
QString process_stdout = cmd_process->readAllStandardOutput();
int exit_code = cmd_process->exitCode();
- qCDebug(core) << "\n==== Process Execution Summary ====\n"
- << "Command: " << cmd << "\n"
- << "Arguments: " << joined_argument << "\n"
- << "Exit Code: " << exit_code << "\n"
- << "---- Standard Output ----\n"
- << process_stdout << "\n"
- << "===============================";
+ LOG_D() << "\n==== Process Execution Summary ====\n"
+ << "Command: " << cmd << "\n"
+ << "Arguments: " << joined_argument << "\n"
+ << "Exit Code: " << exit_code << "\n"
+ << "---- Standard Output ----\n"
+ << process_stdout << "\n"
+ << "===============================";
cmd_process->close();
cmd_process->deleteLater();
@@ -166,7 +166,7 @@ void GpgCommandExecutor::ExecuteSync(ExecuteContext context) {
// to arvoid dead lock issue we need to check if current thread is the same as
// target thread. if it is, we can't call exec() because it will block the
// current thread.
- qCDebug(core, "blocking until gpg command finish...");
+ FLOG_D("blocking until gpg command finish...");
// block until task finished
// this is to keep reference vaild until task finished
looper.exec();
@@ -194,15 +194,15 @@ void GpgCommandExecutor::ExecuteConcurrentlySync(ExecuteContexts contexts) {
for (auto &context : contexts) {
const auto &cmd = context.cmd;
- qCDebug(core) << "gpg concurrently called cmd: " << cmd;
+ LOG_D() << "gpg concurrently called cmd: " << cmd;
Thread::Task *task = BuildTaskFromExecCtx(context);
QObject::connect(task, &Thread::Task::SignalTaskEnd, [&]() {
--remaining_tasks;
- qCDebug(core, "remaining tasks: %lld", remaining_tasks);
+ FLOG_D("remaining tasks: %lld", remaining_tasks);
if (remaining_tasks <= 0) {
- qCDebug(core, "no remaining task, quit");
+ FLOG_D("no remaining task, quit");
looper.quit();
}
});
@@ -218,7 +218,7 @@ void GpgCommandExecutor::ExecuteConcurrentlySync(ExecuteContexts contexts) {
target_task_runner->PostTask(task);
}
- qCDebug(core, "blocking until concurrent gpg commands finish...");
+ FLOG_D("blocking until concurrent gpg commands finish...");
// block until task finished
// this is to keep reference vaild until task finished
looper.exec();
diff --git a/src/core/function/gpg/GpgContext.cpp b/src/core/function/gpg/GpgContext.cpp
index 3058e33f..94a4f522 100644
--- a/src/core/function/gpg/GpgContext.cpp
+++ b/src/core/function/gpg/GpgContext.cpp
@@ -124,12 +124,12 @@ class GpgContext::Impl {
passphrase_info != nullptr ? passphrase_info : "",
prev_was_bad != 0, ask_for_new));
- qCDebug(core) << "custom passphrase cb called, uid: "
- << (uid_hint == nullptr ? "<empty>" : QString{uid_hint})
- << ", info: "
- << (passphrase_info == nullptr ? "<empty>"
- : QString{passphrase_info})
- << ", last_was_bad: " << prev_was_bad;
+ LOG_D() << "custom passphrase cb called, uid: "
+ << (uid_hint == nullptr ? "<empty>" : QString{uid_hint})
+ << ", info: "
+ << (passphrase_info == nullptr ? "<empty>"
+ : QString{passphrase_info})
+ << ", last_was_bad: " << prev_was_bad;
QEventLoop looper;
QString passphrase = "";
@@ -171,7 +171,7 @@ class GpgContext::Impl {
static auto TestStatusCb(void *hook, const char *keyword,
const char *args) -> gpgme_error_t {
- qCDebug(core, "keyword %s", keyword);
+ FLOG_D("keyword %s", keyword);
return GPG_ERR_NO_ERROR;
}
@@ -189,7 +189,7 @@ class GpgContext::Impl {
const auto gpgme_version = Module::RetrieveRTValueTypedOrDefault<>(
"core", "gpgme.version", QString{"0.0.0"});
- qCDebug(core) << "got gpgme version version from rt: " << gpgme_version;
+ LOG_D() << "got gpgme version version from rt: " << gpgme_version;
if (gpgme_get_keylist_mode(ctx) == 0) {
qCWarning(
@@ -212,8 +212,8 @@ class GpgContext::Impl {
const auto database_path = Module::RetrieveRTValueTypedOrDefault<>(
"core", "gpgme.ctx.database_path", QString{});
- qCDebug(core) << "ctx set engine info, db path: " << database_path
- << ", app path: " << app_path;
+ LOG_D() << "ctx set engine info, db path: " << database_path
+ << ", app path: " << app_path;
auto app_path_buffer = app_path.toUtf8();
auto database_path_buffer = database_path.toUtf8();
@@ -234,22 +234,22 @@ class GpgContext::Impl {
assert(ctx != nullptr);
if (args.custom_gpgconf && !args.custom_gpgconf_path.isEmpty()) {
- qCDebug(core) << "set custom gpgconf path: " << args.custom_gpgconf_path;
+ LOG_D() << "set custom gpgconf path: " << args.custom_gpgconf_path;
auto err =
gpgme_ctx_set_engine_info(ctx, GPGME_PROTOCOL_GPGCONF,
args.custom_gpgconf_path.toUtf8(), nullptr);
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
- qCWarning(core) << "set gpg context engine info error: "
- << DescribeGpgErrCode(err).second;
+ LOG_W() << "set gpg context engine info error: "
+ << DescribeGpgErrCode(err).second;
return false;
}
}
// set context offline mode
- qCDebug(core, "gpg context: offline mode: %d", args_.offline_mode);
- qCDebug(core, "gpg context: auto import missing key: %d",
- args_.auto_import_missing_key);
+ FLOG_D("gpg context: offline mode: %d", args_.offline_mode);
+ FLOG_D("gpg context: auto import missing key: %d",
+ args_.auto_import_missing_key);
gpgme_set_offline(ctx, args_.offline_mode ? 1 : 0);
// set option auto import missing key
@@ -261,20 +261,20 @@ class GpgContext::Impl {
}
if (!set_ctx_key_list_mode(ctx)) {
- qCDebug(core, "set ctx key list mode failed");
+ FLOG_D("set ctx key list mode failed");
return false;
}
// for unit test
if (args_.test_mode) {
if (!SetPassphraseCb(ctx, TestPassphraseCb)) {
- qCWarning(core, "set passphrase cb failed, test");
+ FLOG_W("set passphrase cb failed, test");
return false;
};
} else if (!args_.use_pinentry &&
Module::IsModuleActivate(kPinentryModuleID)) {
if (!SetPassphraseCb(ctx, CustomPassphraseCb)) {
- qCDebug(core, "set passphrase cb failed, custom");
+ FLOG_D("set passphrase cb failed, custom");
return false;
}
}
@@ -285,7 +285,7 @@ class GpgContext::Impl {
}
if (!set_ctx_openpgp_engine_info(ctx)) {
- qCWarning(core, "set gpgme context openpgp engine info failed");
+ FLOG_W("set gpgme context openpgp engine info failed");
return false;
}
@@ -295,15 +295,15 @@ class GpgContext::Impl {
auto binary_ctx_initialize(const GpgContextInitArgs &args) -> bool {
gpgme_ctx_t p_ctx;
if (auto err = CheckGpgError(gpgme_new(&p_ctx)); err != GPG_ERR_NO_ERROR) {
- qCWarning(core) << "get new gpg context error: "
- << DescribeGpgErrCode(err).second;
+ LOG_W() << "get new gpg context error: "
+ << DescribeGpgErrCode(err).second;
return false;
}
assert(p_ctx != nullptr);
binary_ctx_ref_ = p_ctx;
if (!common_ctx_initialize(binary_ctx_ref_, args)) {
- qCWarning(core, "get new ctx failed, binary");
+ FLOG_W("get new ctx failed, binary");
return false;
}
@@ -314,7 +314,7 @@ class GpgContext::Impl {
auto default_ctx_initialize(const GpgContextInitArgs &args) -> bool {
gpgme_ctx_t p_ctx;
if (CheckGpgError(gpgme_new(&p_ctx)) != GPG_ERR_NO_ERROR) {
- qCWarning(core, "get new ctx failed, default");
+ FLOG_W("get new ctx failed, default");
return false;
}
assert(p_ctx != nullptr);
diff --git a/src/core/function/gpg/GpgFileOpera.cpp b/src/core/function/gpg/GpgFileOpera.cpp
index ae9dce82..d2cdff9b 100644
--- a/src/core/function/gpg/GpgFileOpera.cpp
+++ b/src/core/function/gpg/GpgFileOpera.cpp
@@ -110,7 +110,7 @@ void GpgFileOpera::EncryptDirectory(const KeyArgsList& keys,
GpgData data_in(ex);
GpgData data_out(out_path, false);
- qCDebug(core, "encrypt directory start");
+ FLOG_D("encrypt directory start");
auto* ctx = ascii ? ctx_.DefaultContext() : ctx_.BinaryContext();
auto err = CheckGpgError(gpgme_op_encrypt(ctx, recipients.data(),
@@ -118,14 +118,14 @@ void GpgFileOpera::EncryptDirectory(const KeyArgsList& keys,
data_in, data_out));
data_object->Swap({GpgEncryptResult(gpgme_op_encrypt_result(ctx))});
- qCDebug(core, "encrypt directory finished, err: %d", err);
+ FLOG_D("encrypt directory finished, err: %d", err);
return err;
},
cb, "gpgme_op_encrypt", "2.1.0");
ArchiveFileOperator::NewArchive2DataExchanger(
in_path, ex, [=](GFError err, const DataObjectPtr&) {
- qCDebug(core, "new archive 2 data exchanger operation, err: %d", err);
+ FLOG_D("new archive 2 data exchanger operation, err: %d", err);
if (decltype(ex) p_ex = w_ex.lock(); err < 0 && p_ex != nullptr) {
ex->CloseWrite();
}
@@ -174,7 +174,7 @@ void GpgFileOpera::DecryptArchive(const QString& in_path,
ArchiveFileOperator::ExtractArchiveFromDataExchanger(
ex, out_path, [](GFError err, const DataObjectPtr&) {
- qCDebug(core, "extract archive from data exchanger operation, err: %d",
+ FLOG_D("extract archive from data exchanger operation, err: %d",
err);
});
@@ -396,7 +396,7 @@ void GpgFileOpera::EncryptSignDirectory(const KeyArgsList& keys,
ArchiveFileOperator::NewArchive2DataExchanger(
in_path, ex, [=](GFError err, const DataObjectPtr&) {
- qCDebug(core, "new archive 2 fd operation, err: %d", err);
+ FLOG_D("new archive 2 fd operation, err: %d", err);
if (decltype(ex) p_ex = w_ex.lock(); err < 0 && p_ex != nullptr) {
ex->CloseWrite();
}
@@ -456,7 +456,7 @@ void GpgFileOpera::DecryptVerifyArchive(const QString& in_path,
ArchiveFileOperator::ExtractArchiveFromDataExchanger(
ex, out_path, [](GFError err, const DataObjectPtr&) {
- qCDebug(core, "extract archive from ex operation, err: %d", err);
+ FLOG_D("extract archive from ex operation, err: %d", err);
});
RunGpgOperaAsync(
@@ -542,7 +542,7 @@ void GpgFileOpera::EncryptDerectorySymmetric(const QString& in_path, bool ascii,
ArchiveFileOperator::NewArchive2DataExchanger(
in_path, ex, [=](GFError err, const DataObjectPtr&) {
- qCDebug(core, "new archive 2 fd operation, err: %d", err);
+ FLOG_D("new archive 2 fd operation, err: %d", err);
});
}
@@ -553,7 +553,7 @@ auto GpgFileOpera::EncryptDerectorySymmetricSync(
ArchiveFileOperator::NewArchive2DataExchanger(
in_path, ex, [=](GFError err, const DataObjectPtr&) {
- qCDebug(core, "new archive 2 fd operation, err: %d", err);
+ FLOG_D("new archive 2 fd operation, err: %d", err);
});
return RunGpgOperaSync(
diff --git a/src/core/function/gpg/GpgKeyGetter.cpp b/src/core/function/gpg/GpgKeyGetter.cpp
index 60d3c418..af77b067 100644
--- a/src/core/function/gpg/GpgKeyGetter.cpp
+++ b/src/core/function/gpg/GpgKeyGetter.cpp
@@ -54,8 +54,7 @@ class GpgKeyGetter::Impl : public SingletonFunctionObject<GpgKeyGetter::Impl> {
gpgme_key_t p_key = nullptr;
gpgme_get_key(ctx_.DefaultContext(), fpr.toUtf8(), &p_key, 1);
if (p_key == nullptr) {
- qCWarning(core) << "GpgKeyGetter GetKey Private _p_key Null, fpr: "
- << fpr;
+ LOG_W() << "GpgKeyGetter GetKey Private _p_key Null, fpr: " << fpr;
return GetPubkey(fpr, true);
}
return GpgKey(std::move(p_key));
@@ -71,7 +70,7 @@ class GpgKeyGetter::Impl : public SingletonFunctionObject<GpgKeyGetter::Impl> {
gpgme_key_t p_key = nullptr;
gpgme_get_key(ctx_.DefaultContext(), fpr.toUtf8(), &p_key, 0);
if (p_key == nullptr)
- qCWarning(core) << "GpgKeyGetter GetKey _p_key Null, fpr: " << fpr;
+ LOG_W() << "GpgKeyGetter GetKey _p_key Null, fpr: " << fpr;
return GpgKey(std::move(p_key));
}
diff --git a/src/core/function/gpg/GpgKeyManager.cpp b/src/core/function/gpg/GpgKeyManager.cpp
index 66e28c4e..fda3173a 100644
--- a/src/core/function/gpg/GpgKeyManager.cpp
+++ b/src/core/function/gpg/GpgKeyManager.cpp
@@ -94,83 +94,82 @@ auto GpgFrontend::GpgKeyManager::SetExpire(
auto GpgFrontend::GpgKeyManager::SetOwnerTrustLevel(const GpgKey& key,
int trust_level) -> bool {
if (trust_level < 0 || trust_level > 5) {
- qCWarning(core, "illegal owner trust level: %d", trust_level);
+ FLOG_W("illegal owner trust level: %d", trust_level);
}
- AutomatonNextStateHandler next_state_handler =
- [](AutomatonState state, QString status, QString args) {
- qCDebug(core) << "next_state_handler state: "
- << static_cast<unsigned int>(state)
- << ", gpg_status: " << status << ", args: " << args;
+ AutomatonNextStateHandler next_state_handler = [](AutomatonState state,
+ QString status,
+ QString args) {
+ LOG_D() << "next_state_handler state: " << static_cast<unsigned int>(state)
+ << ", gpg_status: " << status << ", args: " << args;
- auto tokens = args.split(' ');
+ auto tokens = args.split(' ');
- switch (state) {
- case AS_START:
- if (status == "GET_LINE" && args == "keyedit.prompt") {
- return AS_COMMAND;
- }
- return AS_ERROR;
- case AS_COMMAND:
- if (status == "GET_LINE" && args == "edit_ownertrust.value") {
- return AS_VALUE;
- }
- return AS_ERROR;
- case AS_VALUE:
- if (status == "GET_LINE" && args == "keyedit.prompt") {
- return AS_QUIT;
- } else if (status == "GET_BOOL" &&
- args == "edit_ownertrust.set_ultimate.okay") {
- return AS_REALLY_ULTIMATE;
- }
- return AS_ERROR;
- case AS_REALLY_ULTIMATE:
- if (status == "GET_LINE" && args == "keyedit.prompt") {
- return AS_QUIT;
- }
- return AS_ERROR;
- case AS_QUIT:
- if (status == "GET_LINE" && args == "keyedit.save.okay") {
- return AS_SAVE;
- }
- return AS_ERROR;
- case AS_ERROR:
- if (status == "GET_LINE" && args == "keyedit.prompt") {
- return AS_QUIT;
- }
- return AS_ERROR;
- default:
- return AS_ERROR;
- };
- };
-
- AutomatonActionHandler action_handler = [trust_level](
- AutomatonHandelStruct& handler,
- AutomatonState state) {
- qCDebug(core, "action_handler state: %d", static_cast<unsigned int>(state));
switch (state) {
+ case AS_START:
+ if (status == "GET_LINE" && args == "keyedit.prompt") {
+ return AS_COMMAND;
+ }
+ return AS_ERROR;
case AS_COMMAND:
- return QString("trust");
+ if (status == "GET_LINE" && args == "edit_ownertrust.value") {
+ return AS_VALUE;
+ }
+ return AS_ERROR;
case AS_VALUE:
- handler.SetSuccess(true);
- return QString::number(trust_level);
+ if (status == "GET_LINE" && args == "keyedit.prompt") {
+ return AS_QUIT;
+ } else if (status == "GET_BOOL" &&
+ args == "edit_ownertrust.set_ultimate.okay") {
+ return AS_REALLY_ULTIMATE;
+ }
+ return AS_ERROR;
case AS_REALLY_ULTIMATE:
- handler.SetSuccess(true);
- return QString("Y");
+ if (status == "GET_LINE" && args == "keyedit.prompt") {
+ return AS_QUIT;
+ }
+ return AS_ERROR;
case AS_QUIT:
- return QString("quit");
- case AS_SAVE:
- handler.SetSuccess(true);
- return QString("Y");
- case AS_START:
+ if (status == "GET_LINE" && args == "keyedit.save.okay") {
+ return AS_SAVE;
+ }
+ return AS_ERROR;
case AS_ERROR:
- return QString("");
+ if (status == "GET_LINE" && args == "keyedit.prompt") {
+ return AS_QUIT;
+ }
+ return AS_ERROR;
default:
- return QString("");
- }
- return QString("");
+ return AS_ERROR;
+ };
};
+ AutomatonActionHandler action_handler =
+ [trust_level](AutomatonHandelStruct& handler, AutomatonState state) {
+ FLOG_D("action_handler state: %d", static_cast<unsigned int>(state));
+ switch (state) {
+ case AS_COMMAND:
+ return QString("trust");
+ case AS_VALUE:
+ handler.SetSuccess(true);
+ return QString::number(trust_level);
+ case AS_REALLY_ULTIMATE:
+ handler.SetSuccess(true);
+ return QString("Y");
+ case AS_QUIT:
+ return QString("quit");
+ case AS_SAVE:
+ handler.SetSuccess(true);
+ return QString("Y");
+ case AS_START:
+ case AS_ERROR:
+ return QString("");
+ default:
+ return QString("");
+ }
+ return QString("");
+ };
+
auto key_fpr = key.GetFingerprint();
AutomatonHandelStruct handel_struct(key_fpr);
handel_struct.SetHandler(next_state_handler, action_handler);
@@ -196,8 +195,8 @@ auto GpgFrontend::GpgKeyManager::interactor_cb_fnc(void* handle,
auto tokens = QString(args).split(' ');
if (tokens.empty() || tokens[0] != handle_struct->KeyFpr()) {
- qCWarning(core) << "handle struct key fpr " << handle_struct->KeyFpr()
- << "mismatch token: " << tokens[0] << ", exit...";
+ LOG_W() << "handle struct key fpr " << handle_struct->KeyFpr()
+ << "mismatch token: " << tokens[0] << ", exit...";
return -1;
}
@@ -206,13 +205,13 @@ auto GpgFrontend::GpgKeyManager::interactor_cb_fnc(void* handle,
}
if (status_s == "GOT_IT" || status_s.isEmpty()) {
- qCDebug(core, "status GOT_IT, continue...");
+ FLOG_D("status GOT_IT, continue...");
return 0;
}
AutomatonState next_state = handle_struct->NextState(status_s, args_s);
if (next_state == AS_ERROR) {
- qCDebug(core, "handle struct next state caught error, skipping...");
+ FLOG_D("handle struct next state caught error, skipping...");
return GPG_ERR_FALSE;
}
diff --git a/src/core/function/gpg/GpgKeyOpera.cpp b/src/core/function/gpg/GpgKeyOpera.cpp
index aa9bafaf..54c90182 100644
--- a/src/core/function/gpg/GpgKeyOpera.cpp
+++ b/src/core/function/gpg/GpgKeyOpera.cpp
@@ -61,7 +61,7 @@ void GpgKeyOpera::DeleteKeys(KeyIdArgsListPtr key_ids) {
GPGME_DELETE_ALLOW_SECRET | GPGME_DELETE_FORCE));
assert(gpg_err_code(err) == GPG_ERR_NO_ERROR);
} else {
- qCWarning(core) << "GpgKeyOpera DeleteKeys get key failed: " << tmp;
+ LOG_W() << "GpgKeyOpera DeleteKeys get key failed: " << tmp;
}
}
}
@@ -113,8 +113,8 @@ void GpgKeyOpera::GenerateRevokeCert(const GpgKey& key,
output_path, "--gen-revoke", key.GetFingerprint()},
[=](int exit_code, const QString& p_out, const QString& p_err) {
if (exit_code != 0) {
- qCWarning(core) << "gnupg gen revoke execute error, process stderr: "
- << p_err << ", process stdout: " << p_out;
+ LOG_W() << "gnupg gen revoke execute error, process stderr: "
+ << p_err << ", process stdout: " << p_out;
} else {
qCDebug(core,
"gnupg gen revoke exit_code: %d, process stdout size: %lld",
@@ -159,8 +159,7 @@ void GpgKeyOpera::GenerateKey(const std::shared_ptr<GenKeyInfo>& params,
auto userid = params->GetUserid();
auto algo = params->GetAlgo() + params->GetKeySizeStr();
- qCDebug(core) << "params: " << params->GetAlgo()
- << params->GetKeySizeStr();
+ LOG_D() << "params: " << params->GetAlgo() << params->GetKeySizeStr();
unsigned long expires =
QDateTime::currentDateTime().secsTo(params->GetExpireTime());
@@ -175,8 +174,8 @@ void GpgKeyOpera::GenerateKey(const std::shared_ptr<GenKeyInfo>& params,
if (params->IsNonExpired()) flags |= GPGME_CREATE_NOEXPIRE;
if (params->IsNoPassPhrase()) flags |= GPGME_CREATE_NOPASSWD;
- qCDebug(core) << "key generation args: " << userid << algo << expires
- << flags;
+ LOG_D() << "key generation args: " << userid << algo << expires
+ << flags;
err = gpgme_op_createkey(ctx.DefaultContext(), userid.toUtf8(),
algo.toUtf8(), 0, expires, nullptr, flags);
@@ -200,8 +199,7 @@ auto GpgKeyOpera::GenerateKeySync(const std::shared_ptr<GenKeyInfo>& params)
auto userid = params->GetUserid();
auto algo = params->GetAlgo() + params->GetKeySizeStr();
- qCDebug(core) << "params: " << params->GetAlgo()
- << params->GetKeySizeStr();
+ LOG_D() << "params: " << params->GetAlgo() << params->GetKeySizeStr();
unsigned long expires =
QDateTime::currentDateTime().secsTo(params->GetExpireTime());
@@ -216,8 +214,8 @@ auto GpgKeyOpera::GenerateKeySync(const std::shared_ptr<GenKeyInfo>& params)
if (params->IsNonExpired()) flags |= GPGME_CREATE_NOEXPIRE;
if (params->IsNoPassPhrase()) flags |= GPGME_CREATE_NOPASSWD;
- qCDebug(core) << "key generation args: " << userid << algo << expires
- << flags;
+ LOG_D() << "key generation args: " << userid << algo << expires
+ << flags;
err = gpgme_op_createkey(ctx.DefaultContext(), userid.toUtf8(),
algo.toUtf8(), 0, expires, nullptr, flags);
@@ -241,8 +239,8 @@ void GpgKeyOpera::GenerateSubkey(const GpgKey& key,
[key, &ctx = ctx_, params](const DataObjectPtr& data_object) -> GpgError {
if (!params->IsSubKey()) return GPG_ERR_CANCELED;
- qCDebug(core) << "generate subkey algo: " << params->GetAlgo()
- << "key size: " << params->GetKeySizeStr();
+ LOG_D() << "generate subkey algo: " << params->GetAlgo()
+ << "key size: " << params->GetKeySizeStr();
auto algo = params->GetAlgo() + params->GetKeySizeStr();
unsigned long expires =
@@ -256,8 +254,8 @@ void GpgKeyOpera::GenerateSubkey(const GpgKey& key,
if (params->IsNonExpired()) flags |= GPGME_CREATE_NOEXPIRE;
if (params->IsNoPassPhrase()) flags |= GPGME_CREATE_NOPASSWD;
- qCDebug(core) << "subkey generation args: " << key.GetId() << algo
- << expires << flags;
+ LOG_D() << "subkey generation args: " << key.GetId() << algo << expires
+ << flags;
auto err = gpgme_op_createsubkey(ctx.DefaultContext(),
static_cast<gpgme_key_t>(key),
@@ -281,8 +279,8 @@ auto GpgKeyOpera::GenerateSubkeySync(const GpgKey& key,
[key, &ctx = ctx_, params](const DataObjectPtr& data_object) -> GpgError {
if (!params->IsSubKey()) return GPG_ERR_CANCELED;
- qCDebug(core) << "generate subkey algo: " << params->GetAlgo()
- << " key size: " << params->GetKeySizeStr();
+ LOG_D() << "generate subkey algo: " << params->GetAlgo()
+ << " key size: " << params->GetKeySizeStr();
auto algo = params->GetAlgo() + params->GetKeySizeStr();
unsigned long expires =
@@ -296,7 +294,7 @@ auto GpgKeyOpera::GenerateSubkeySync(const GpgKey& key,
if (params->IsNonExpired()) flags |= GPGME_CREATE_NOEXPIRE;
if (params->IsNoPassPhrase()) flags |= GPGME_CREATE_NOPASSWD;
- qCDebug(core) << " args: " << key.GetId() << algo << expires << flags;
+ LOG_D() << " args: " << key.GetId() << algo << expires << flags;
auto err = gpgme_op_createsubkey(ctx.DefaultContext(),
static_cast<gpgme_key_t>(key),
@@ -336,8 +334,8 @@ void GpgKeyOpera::GenerateKeyWithSubkey(
if (params->IsNonExpired()) flags |= GPGME_CREATE_NOEXPIRE;
if (params->IsNoPassPhrase()) flags |= GPGME_CREATE_NOPASSWD;
- qCDebug(core) << "key generation args: " << userid << algo << expires
- << flags;
+ LOG_D() << "key generation args: " << userid << algo << expires
+ << flags;
err = gpgme_op_createkey(ctx.DefaultContext(), userid, algo, 0, expires,
nullptr, flags);
@@ -358,8 +356,8 @@ void GpgKeyOpera::GenerateKeyWithSubkey(
auto key =
GpgKeyGetter::GetInstance().GetKey(genkey_result.GetFingerprint());
if (!key.IsGood()) {
- qCWarning(core) << "cannot get key which has been generate, fpr: "
- << genkey_result.GetFingerprint();
+ LOG_W() << "cannot get key which has been generate, fpr: "
+ << genkey_result.GetFingerprint();
return err;
}
@@ -375,8 +373,8 @@ void GpgKeyOpera::GenerateKeyWithSubkey(
if (subkey_params->IsNonExpired()) flags |= GPGME_CREATE_NOEXPIRE;
if (subkey_params->IsNoPassPhrase()) flags |= GPGME_CREATE_NOPASSWD;
- qCDebug(core) << "subkey generation args: " << key.GetId() << algo
- << expires << flags;
+ LOG_D() << "subkey generation args: " << key.GetId() << algo << expires
+ << flags;
err = gpgme_op_createsubkey(ctx.DefaultContext(),
static_cast<gpgme_key_t>(key), algo, 0,
@@ -417,8 +415,8 @@ auto GpgKeyOpera::GenerateKeyWithSubkeySync(
if (params->IsNonExpired()) flags |= GPGME_CREATE_NOEXPIRE;
if (params->IsNoPassPhrase()) flags |= GPGME_CREATE_NOPASSWD;
- qCDebug(core) << "key generation args: " << userid << algo << expires
- << flags;
+ LOG_D() << "key generation args: " << userid << algo << expires
+ << flags;
err = gpgme_op_createkey(ctx.DefaultContext(), userid, algo, 0, expires,
nullptr, flags);
@@ -439,14 +437,14 @@ auto GpgKeyOpera::GenerateKeyWithSubkeySync(
auto key =
GpgKeyGetter::GetInstance().GetKey(genkey_result.GetFingerprint());
if (!key.IsGood()) {
- qCWarning(core) << "cannot get key which has been generate, fpr: "
- << genkey_result.GetFingerprint();
+ LOG_W() << "cannot get key which has been generate, fpr: "
+ << genkey_result.GetFingerprint();
return err;
}
- qCDebug(core) << "try to generate subkey of key: " << key.GetId()
- << ", algo :" << subkey_params->GetAlgo()
- << ", key size: " << subkey_params->GetKeySizeStr();
+ LOG_D() << "try to generate subkey of key: " << key.GetId()
+ << ", algo :" << subkey_params->GetAlgo()
+ << ", key size: " << subkey_params->GetKeySizeStr();
algo = (subkey_params->GetAlgo() + subkey_params->GetKeySizeStr())
.toUtf8();
@@ -460,8 +458,8 @@ auto GpgKeyOpera::GenerateKeyWithSubkeySync(
if (subkey_params->IsNonExpired()) flags |= GPGME_CREATE_NOEXPIRE;
if (subkey_params->IsNoPassPhrase()) flags |= GPGME_CREATE_NOPASSWD;
- qCDebug(core) << "subkey generation args: " << key.GetId() << algo
- << expires << flags;
+ LOG_D() << "subkey generation args: " << key.GetId() << algo << expires
+ << flags;
err = gpgme_op_createsubkey(ctx.DefaultContext(),
static_cast<gpgme_key_t>(key), algo, 0,
@@ -494,10 +492,10 @@ auto GpgKeyOpera::ModifyTOFUPolicy(
const GpgKey& key, gpgme_tofu_policy_t tofu_policy) -> GpgError {
const auto gnupg_version = Module::RetrieveRTValueTypedOrDefault<>(
"core", "gpgme.ctx.gnupg_version", QString{"2.0.0"});
- qCDebug(core) << "got gnupg version from rt: " << gnupg_version;
+ LOG_D() << "got gnupg version from rt: " << gnupg_version;
if (GFCompareSoftwareVersion(gnupg_version, "2.1.10") < 0) {
- qCWarning(core, "operator not support");
+ FLOG_W("operator not support");
return GPG_ERR_NOT_SUPPORTED;
}
diff --git a/src/core/function/gpg/GpgUIDOperator.cpp b/src/core/function/gpg/GpgUIDOperator.cpp
index cb9594f0..90034413 100644
--- a/src/core/function/gpg/GpgUIDOperator.cpp
+++ b/src/core/function/gpg/GpgUIDOperator.cpp
@@ -58,7 +58,7 @@ auto GpgUIDOperator::SetPrimaryUID(const GpgKey& key,
auto GpgUIDOperator::AddUID(const GpgKey& key, const QString& name,
const QString& comment,
const QString& email) -> bool {
- qCDebug(core) << "new uuid:" << name << comment << email;
+ LOG_D() << "new uuid:" << name << comment << email;
return AddUID(key, QString("%1(%2)<%3>").arg(name).arg(comment).arg(email));
}
diff --git a/src/core/model/GpgGenKeyInfo.cpp b/src/core/model/GpgGenKeyInfo.cpp
index 0553846f..0d0ab239 100644
--- a/src/core/model/GpgGenKeyInfo.cpp
+++ b/src/core/model/GpgGenKeyInfo.cpp
@@ -124,7 +124,7 @@ void GenKeyInfo::SetAlgo(const QString &t_algo_args) {
suggest_size_addition_step_ = -1;
SetKeyLength(-1);
} else {
- qCWarning(core) << "unsupported genkey algo arguments: " << algo_args;
+ LOG_W() << "unsupported genkey algo arguments: " << algo_args;
return;
}
diff --git a/src/core/model/SettingsObject.cpp b/src/core/model/SettingsObject.cpp
index 349c74c3..8e935e08 100644
--- a/src/core/model/SettingsObject.cpp
+++ b/src/core/model/SettingsObject.cpp
@@ -45,7 +45,7 @@ SettingsObject::SettingsObject(QString settings_name)
}
} catch (std::exception& e) {
- qCWarning(core) << "load setting object error: {}" << e.what();
+ LOG_W() << "load setting object error: {}" << e.what();
}
}
diff --git a/src/core/module/Event.cpp b/src/core/module/Event.cpp
index b6d31369..873e728d 100644
--- a/src/core/module/Event.cpp
+++ b/src/core/module/Event.cpp
@@ -86,9 +86,8 @@ class Event::Impl {
listener_id, data_object]() {
callback(event_identifier, listener_id, data_object);
})) {
- qCWarning(core) << "failed to invoke callback for event: "
- << event_identifier_
- << " with listener:" << listener_id;
+ LOG_W() << "failed to invoke callback for event: " << event_identifier_
+ << " with listener:" << listener_id;
}
}
}
diff --git a/src/core/module/GlobalModuleContext.cpp b/src/core/module/GlobalModuleContext.cpp
index 94165f88..08090d33 100644
--- a/src/core/module/GlobalModuleContext.cpp
+++ b/src/core/module/GlobalModuleContext.cpp
@@ -54,8 +54,7 @@ class GlobalModuleContext::Impl {
// Search for the module in the register table.
auto module_info_opt = search_module_register_table(module_id);
if (!module_info_opt.has_value()) {
- qCWarning(core) << "cannot find module id " << module_id
- << " at register table";
+ LOG_W() << "cannot find module id " << module_id << " at register table";
return nullptr;
}
@@ -67,10 +66,9 @@ class GlobalModuleContext::Impl {
auto module_info_opt =
search_module_register_table(module->GetModuleIdentifier());
if (!module_info_opt.has_value()) {
- qCWarning(core) << "cannot find module id "
- << module->GetModuleIdentifier()
- << " at register table, fallback to "
- "default channel";
+ LOG_W() << "cannot find module id " << module->GetModuleIdentifier()
+ << " at register table, fallback to "
+ "default channel";
return GetDefaultChannel(module);
}
@@ -103,13 +101,13 @@ class GlobalModuleContext::Impl {
if (module == nullptr ||
module_register_table_.find(module->GetModuleIdentifier()) !=
module_register_table_.end()) {
- qCWarning(core, "module is null or have already registered this module");
+ FLOG_W("module is null or have already registered this module");
return false;
}
if (module->Register() != 0) {
- qCWarning(core) << "register module " << module->GetModuleIdentifier()
- << " failed";
+ LOG_W() << "register module " << module->GetModuleIdentifier()
+ << " failed";
return false;
}
@@ -136,8 +134,7 @@ class GlobalModuleContext::Impl {
// Search for the module in the register table.
auto module_info_opt = search_module_register_table(module_id);
if (!module_info_opt.has_value()) {
- qCWarning(core) << "cannot find module id " << module_id
- << " at register table";
+ LOG_W() << "cannot find module id " << module_id << " at register table";
return false;
}
@@ -146,8 +143,8 @@ class GlobalModuleContext::Impl {
// try to get module from module info
auto module = module_info->module;
if (module == nullptr) {
- qCWarning(core) << "module id:" << module_id
- << " at register table is related to a null module";
+ LOG_W() << "module id:" << module_id
+ << " at register table is related to a null module";
return false;
}
@@ -164,8 +161,7 @@ class GlobalModuleContext::Impl {
// module -> event
auto module_info_opt = search_module_register_table(module_id);
if (!module_info_opt.has_value()) {
- qCWarning(core) << "cannot find module id" << module_id
- << "at register table";
+ LOG_W() << "cannot find module id" << module_id << "at register table";
return false;
}
@@ -191,8 +187,7 @@ class GlobalModuleContext::Impl {
// search for the module in the register table.
auto module_info_opt = search_module_register_table(module_id);
if (!module_info_opt.has_value()) {
- qCWarning(core) << "cannot find module id " << module_id
- << " at register table";
+ LOG_W() << "cannot find module id " << module_id << " at register table";
return false;
}
@@ -220,8 +215,8 @@ class GlobalModuleContext::Impl {
auto met_it = module_events_table_.find(event_id);
if (met_it == module_events_table_.end()) {
// Log a warning if the event is not registered and nobody is listening
- qCInfo(core) << "event: " << event_id
- << " is not listening by anyone and not registered as well.";
+ LOG_I() << "event: " << event_id
+ << " is not listening by anyone and not registered as well.";
return false;
}
@@ -231,7 +226,7 @@ class GlobalModuleContext::Impl {
// Check if the set of listeners is empty
if (listeners_set.empty()) {
// Log a warning if nobody is listening to this event
- qCInfo(core) << "event: " << event_id << " is not listening by anyone";
+ LOG_I() << "event: " << event_id << " is not listening by anyone";
return false;
}
@@ -245,8 +240,8 @@ class GlobalModuleContext::Impl {
// Log an error if the module is not found in the registration table
if (!module_info_opt.has_value()) {
- qCWarning(core) << "cannot find module id: " << listener_module_id
- << " at register table";
+ LOG_W() << "cannot find module id: " << listener_module_id
+ << " at register table";
continue;
}
@@ -264,9 +259,9 @@ class GlobalModuleContext::Impl {
[listener_module_id, event_id](int code, DataObjectPtr) {
if (code < 0) {
// Log an error if the module execution fails
- qCWarning(core) << "module " << listener_module_id
- << "execution failed of event " << event_id
- << ": exec return code: " << code;
+ LOG_W() << "module " << listener_module_id
+ << "execution failed of event " << event_id
+ << ": exec return code: " << code;
}
};
diff --git a/src/core/module/Module.cpp b/src/core/module/Module.cpp
index 2358d108..becda4b6 100644
--- a/src/core/module/Module.cpp
+++ b/src/core/module/Module.cpp
@@ -59,9 +59,9 @@ class Module::Impl {
*required_symbol.pointer =
reinterpret_cast<void*>(module_library.resolve(required_symbol.name));
if (*required_symbol.pointer == nullptr) {
- qCWarning(core) << "illegal module: " << module_library.fileName()
- << ", reason cannot load symbol: "
- << required_symbol.name << ", abort...";
+ LOG_W() << "illegal module: " << module_library.fileName()
+ << ", reason cannot load symbol: " << required_symbol.name
+ << ", abort...";
return;
}
}
@@ -72,38 +72,36 @@ class Module::Impl {
qt_env_ver_ = GFUnStrDup(get_qt_ver_api_());
if (!module_identifier_regex_exp_.match(identifier_).hasMatch()) {
- qCWarning(core) << "illegal module: " << identifier_
- << ", reason invalid module id, abort...";
+ LOG_W() << "illegal module: " << identifier_
+ << ", reason invalid module id, abort...";
return;
}
if (!module_version_regex_exp_.match(version_).hasMatch()) {
- qCWarning(core) << "illegal module: " << identifier_
- << ", reason invalid version: " << version_
- << ", abort...";
+ LOG_W() << "illegal module: " << identifier_
+ << ", reason invalid version: " << version_ << ", abort...";
return;
}
if (!module_version_regex_exp_.match(gf_sdk_ver_).hasMatch()) {
- qCWarning(core) << "illegal module: " << identifier_
- << ", reason invalid sdk version: " << gf_sdk_ver_
- << ", abort...";
+ LOG_W() << "illegal module: " << identifier_
+ << ", reason invalid sdk version: " << gf_sdk_ver_
+ << ", abort...";
return;
}
if (GFCompareSoftwareVersion(gf_sdk_ver_, GetProjectVersion()) > 0) {
- qCWarning(core) << "uncompatible module: " << identifier_
- << ", reason sdk version: " << gf_sdk_ver_
- << "current sdk version: " << GetProjectVersion()
- << ", abort...";
+ LOG_W() << "uncompatible module: " << identifier_
+ << ", reason sdk version: " << gf_sdk_ver_
+ << "current sdk version: " << GetProjectVersion() << ", abort...";
return;
}
auto qt_env_ver_regex_match = module_version_regex_exp_.match(qt_env_ver_);
if (!qt_env_ver_regex_match.hasMatch()) {
- qCWarning(core) << "illegal module: " << identifier_
- << ", reason invalid qt env version: " << qt_env_ver_
- << ", abort...";
+ LOG_W() << "illegal module: " << identifier_
+ << ", reason invalid qt env version: " << qt_env_ver_
+ << ", abort...";
return;
}
@@ -112,10 +110,10 @@ class Module::Impl {
if (qt_env_ver_major != QString::number(QT_VERSION_MAJOR) + "." ||
qt_env_ver_minor != QString::number(QT_VERSION_MINOR) + ".") {
- qCWarning(core) << "uncompatible module: " << identifier_
- << ", reason sdk version: " << qt_env_ver_
- << "current sdk version: "
- << QString::fromUtf8(QT_VERSION_STR) << ", abort...";
+ LOG_W() << "uncompatible module: " << identifier_
+ << ", reason sdk version: " << qt_env_ver_
+ << "current sdk version: " << QString::fromUtf8(QT_VERSION_STR)
+ << ", abort...";
return;
}
diff --git a/src/core/module/ModuleInit.cpp b/src/core/module/ModuleInit.cpp
index 4fedc6c7..3c71a45b 100644
--- a/src/core/module/ModuleInit.cpp
+++ b/src/core/module/ModuleInit.cpp
@@ -69,8 +69,8 @@ auto LoadIntegratedMods() -> bool {
#endif
if (!QDir(mods_path).exists()) {
- qCWarning(core) << "integrated module directory at path: " << mods_path
- << " not found, abort...";
+ LOG_W() << "integrated module directory at path: " << mods_path
+ << " not found, abort...";
return false;
}
@@ -84,8 +84,8 @@ auto LoadExternalMods() -> bool {
GpgFrontend::GlobalSettingStation::GetInstance().GetModulesDir();
if (!QDir(mods_path).exists()) {
- qCWarning(core) << "external module directory at path " << mods_path
- << " not found, abort...";
+ LOG_W() << "external module directory at path " << mods_path
+ << " not found, abort...";
return false;
}
diff --git a/src/core/module/ModuleManager.cpp b/src/core/module/ModuleManager.cpp
index f2318543..5f8895be 100644
--- a/src/core/module/ModuleManager.cpp
+++ b/src/core/module/ModuleManager.cpp
@@ -69,17 +69,17 @@ class ModuleManager::Impl {
[=](GpgFrontend::DataObjectPtr) -> int {
QLibrary module_library(module_library_path);
if (!module_library.load()) {
- qCWarning(core) << "module manager failed to load module: "
- << module_library.fileName()
- << ", reason: " << module_library.errorString();
+ LOG_W() << "module manager failed to load module: "
+ << module_library.fileName()
+ << ", reason: " << module_library.errorString();
return -1;
}
auto module = SecureCreateSharedObject<Module>(module_library);
if (!module->IsGood()) {
- qCWarning(core) << "module manager failed to load module, "
- "reason: illegal module: "
- << module_library.fileName();
+ LOG_W() << "module manager failed to load module, "
+ "reason: illegal module: "
+ << module_library.fileName();
return -1;
}
diff --git a/src/core/thread/FileReadTask.cpp b/src/core/thread/FileReadTask.cpp
index b4c6874f..d74f5a68 100644
--- a/src/core/thread/FileReadTask.cpp
+++ b/src/core/thread/FileReadTask.cpp
@@ -45,7 +45,7 @@ auto FileReadTask::Run() -> int {
target_file_.open(QIODevice::ReadOnly);
if (!(target_file_.isOpen() && target_file_.isReadable())) {
- qCWarning(core, "file not open or not readable");
+ FLOG_W("file not open or not readable");
if (target_file_.isOpen()) target_file_.close();
return -1;
}
diff --git a/src/core/thread/Task.cpp b/src/core/thread/Task.cpp
index f5c34dbd..7a0e76e8 100644
--- a/src/core/thread/Task.cpp
+++ b/src/core/thread/Task.cpp
@@ -144,8 +144,8 @@ class Task::Impl {
callback_(rtn_, data_object_);
}
} catch (...) {
- qCWarning(core) << "task: {}, " << GetFullID()
- << "callback caught exception, rtn: " << rtn;
+ LOG_W() << "task: {}, " << GetFullID()
+ << "callback caught exception, rtn: " << rtn;
}
emit parent_->SignalTaskEnd();
});
@@ -217,7 +217,7 @@ void Task::slot_exception_safe_run() noexcept {
rtn = this->Run();
} catch (...) {
- qCWarning(core) << "exception was caught at task: {}" << GetFullID();
+ LOG_W() << "exception was caught at task: {}" << GetFullID();
}
// raise signal to anounce after runnable returned
diff --git a/src/core/thread/TaskRunner.cpp b/src/core/thread/TaskRunner.cpp
index abf7b8dc..c7d92382 100644
--- a/src/core/thread/TaskRunner.cpp
+++ b/src/core/thread/TaskRunner.cpp
@@ -38,7 +38,7 @@ class TaskRunner::Impl : public QThread {
void PostTask(Task* task) {
if (task == nullptr) {
- qCWarning(core, "task posted is null");
+ FLOG_W("task posted is null");
return;
}
@@ -73,7 +73,7 @@ class TaskRunner::Impl : public QThread {
void PostConcurrentTask(Task* task) {
if (task == nullptr) {
- qCWarning(core, "task posted is null");
+ FLOG_W("task posted is null");
return;
}
diff --git a/src/core/utils/AsyncUtils.cpp b/src/core/utils/AsyncUtils.cpp
index a6fca88f..a4bc66fa 100644
--- a/src/core/utils/AsyncUtils.cpp
+++ b/src/core/utils/AsyncUtils.cpp
@@ -44,8 +44,8 @@ auto RunGpgOperaAsync(const GpgOperaRunnable& runnable,
"core", "gpgme.ctx.gnupg_version", minial_version);
if (GFCompareSoftwareVersion(gnupg_version, minial_version) < 0) {
- qCWarning(core) << "operation" << operation
- << " not support for gnupg version: " << gnupg_version;
+ LOG_W() << "operation" << operation
+ << " not support for gnupg version: " << gnupg_version;
callback(GPG_ERR_NOT_SUPPORTED, TransferParams());
return Thread::Task::TaskHandler(nullptr);
}
@@ -82,8 +82,8 @@ auto RunGpgOperaSync(const GpgOperaRunnable& runnable, const QString& operation,
"core", "gpgme.ctx.gnupg_version", minial_version);
if (GFCompareSoftwareVersion(gnupg_version, minial_version) < 0) {
- qCWarning(core) << "operation" << operation
- << " not support for gnupg version: " << gnupg_version;
+ LOG_W() << "operation" << operation
+ << " not support for gnupg version: " << gnupg_version;
return {GPG_ERR_NOT_SUPPORTED, TransferParams()};
}
diff --git a/src/core/utils/GpgUtils.cpp b/src/core/utils/GpgUtils.cpp
index 28892063..3d584b8f 100644
--- a/src/core/utils/GpgUtils.cpp
+++ b/src/core/utils/GpgUtils.cpp
@@ -50,9 +50,9 @@ auto GetGpgmeErrorString(gpgme_error_t err) -> QString {
auto CheckGpgError(GpgError err) -> GpgError {
auto err_code = gpg_err_code(err);
if (err_code != GPG_ERR_NO_ERROR) {
- qCWarning(core) << "gpg operation failed [error code: " << err_code
- << "], source: " << gpgme_strsource(err)
- << " description: " << GetGpgmeErrorString(err);
+ LOG_W() << "gpg operation failed [error code: " << err_code
+ << "], source: " << gpgme_strsource(err)
+ << " description: " << GetGpgmeErrorString(err);
}
return err_code;
}
@@ -61,15 +61,15 @@ auto CheckGpgError2ErrCode(GpgError err, GpgError predict) -> GpgErrorCode {
auto err_code = gpg_err_code(err);
if (err_code != gpg_err_code(predict)) {
if (err_code == GPG_ERR_NO_ERROR) {
- qCInfo(core) << "[Warning " << gpg_err_code(err)
- << "] Source: " << gpgme_strsource(err)
- << " description: " << GetGpgmeErrorString(err)
- << " predict: " << GetGpgmeErrorString(predict);
+ LOG_I() << "[Warning " << gpg_err_code(err)
+ << "] Source: " << gpgme_strsource(err)
+ << " description: " << GetGpgmeErrorString(err)
+ << " predict: " << GetGpgmeErrorString(predict);
} else {
- qCWarning(core) << "[Error " << gpg_err_code(err)
- << "] Source: " << gpgme_strsource(err)
- << " description: " << GetGpgmeErrorString(err)
- << " predict: " << GetGpgmeErrorString(predict);
+ LOG_W() << "[Error " << gpg_err_code(err)
+ << "] Source: " << gpgme_strsource(err)
+ << " description: " << GetGpgmeErrorString(err)
+ << " predict: " << GetGpgmeErrorString(predict);
}
}
return err_code;
@@ -81,9 +81,9 @@ auto DescribeGpgErrCode(GpgError err) -> GpgErrorDesc {
auto CheckGpgError(GpgError err, const QString& /*comment*/) -> GpgError {
if (gpg_err_code(err) != GPG_ERR_NO_ERROR) {
- qCWarning(core) << "[Error " << gpg_err_code(err)
- << "] Source: " << gpgme_strsource(err)
- << " description: " << GetGpgmeErrorString(err);
+ LOG_W() << "[Error " << gpg_err_code(err)
+ << "] Source: " << gpgme_strsource(err)
+ << " description: " << GetGpgmeErrorString(err);
}
return err;
}
diff --git a/src/core/utils/IOUtils.cpp b/src/core/utils/IOUtils.cpp
index 11f2b3e8..39f00d19 100644
--- a/src/core/utils/IOUtils.cpp
+++ b/src/core/utils/IOUtils.cpp
@@ -49,7 +49,7 @@ auto GetFileChecksum(const QString& file_name,
auto ReadFile(const QString& file_name, QByteArray& data) -> bool {
QFile file(file_name);
if (!file.open(QIODevice::ReadOnly)) {
- qCWarning(core) << "failed to open file: " << file_name;
+ LOG_W() << "failed to open file: " << file_name;
return false;
}
data = file.readAll();
@@ -60,7 +60,7 @@ auto ReadFile(const QString& file_name, QByteArray& data) -> bool {
auto WriteFile(const QString& file_name, const QByteArray& data) -> bool {
QFile file(file_name);
if (!file.open(QIODevice::WriteOnly)) {
- qCWarning(core) << "failed to open file for writing: " << file_name;
+ LOG_W() << "failed to open file for writing: " << file_name;
return false;
}
file.write(data);
@@ -181,16 +181,16 @@ auto CalculateBinaryChacksum(const QString& path) -> QString {
// check file info and access rights
QFileInfo info(path);
if (!info.exists() || !info.isFile() || !info.isReadable()) {
- qCWarning(core) << "get info for file: " << info.filePath()
- << " error, exists: " << info.exists();
+ LOG_W() << "get info for file: " << info.filePath()
+ << " error, exists: " << info.exists();
return {};
}
// open and read file
QFile f(info.filePath());
if (!f.open(QIODevice::ReadOnly)) {
- qCWarning(core) << "open " << path
- << "to calculate checksum error: " << f.errorString();
+ LOG_W() << "open " << path
+ << "to calculate checksum error: " << f.errorString();
return {};
}
@@ -201,8 +201,8 @@ auto CalculateBinaryChacksum(const QString& path) -> QString {
while (!f.atEnd()) {
QByteArray const buffer = f.read(buffer_size);
if (buffer.isEmpty()) {
- qCWarning(core) << "error reading file: " << path
- << " during checksum calculation";
+ LOG_W() << "error reading file: " << path
+ << " during checksum calculation";
return {};
}
hash_sha.addData(buffer);
diff --git a/src/sdk/GFSDKExport.h b/src/sdk/GFSDKExport.h
deleted file mode 100644
index a62168bc..00000000
--- a/src/sdk/GFSDKExport.h
+++ /dev/null
@@ -1,42 +0,0 @@
-
-#ifndef GPGFRONTEND_MODULE_SDK_EXPORT_H
-#define GPGFRONTEND_MODULE_SDK_EXPORT_H
-
-#ifdef GPGFRONTEND_MODULE_SDK_STATIC_DEFINE
-# define GPGFRONTEND_MODULE_SDK_EXPORT
-# define GPGFRONTEND_MODULE_SDK_NO_EXPORT
-#else
-# ifndef GPGFRONTEND_MODULE_SDK_EXPORT
-# ifdef gpgfrontend_module_sdk_EXPORTS
- /* We are building this library */
-# define GPGFRONTEND_MODULE_SDK_EXPORT __attribute__((visibility("default")))
-# else
- /* We are using this library */
-# define GPGFRONTEND_MODULE_SDK_EXPORT __attribute__((visibility("default")))
-# endif
-# endif
-
-# ifndef GPGFRONTEND_MODULE_SDK_NO_EXPORT
-# define GPGFRONTEND_MODULE_SDK_NO_EXPORT __attribute__((visibility("hidden")))
-# endif
-#endif
-
-#ifndef GPGFRONTEND_MODULE_SDK_DEPRECATED
-# define GPGFRONTEND_MODULE_SDK_DEPRECATED __attribute__ ((__deprecated__))
-#endif
-
-#ifndef GPGFRONTEND_MODULE_SDK_DEPRECATED_EXPORT
-# define GPGFRONTEND_MODULE_SDK_DEPRECATED_EXPORT GPGFRONTEND_MODULE_SDK_EXPORT GPGFRONTEND_MODULE_SDK_DEPRECATED
-#endif
-
-#ifndef GPGFRONTEND_MODULE_SDK_DEPRECATED_NO_EXPORT
-# define GPGFRONTEND_MODULE_SDK_DEPRECATED_NO_EXPORT GPGFRONTEND_MODULE_SDK_NO_EXPORT GPGFRONTEND_MODULE_SDK_DEPRECATED
-#endif
-
-#if 0 /* DEFINE_NO_DEPRECATED */
-# ifndef GPGFRONTEND_MODULE_SDK_NO_DEPRECATED
-# define GPGFRONTEND_MODULE_SDK_NO_DEPRECATED
-# endif
-#endif
-
-#endif /* GPGFRONTEND_MODULE_SDK_EXPORT_H */
diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt
index 53c99f11..c9690c2a 100644
--- a/src/test/CMakeLists.txt
+++ b/src/test/CMakeLists.txt
@@ -36,7 +36,7 @@ set(_export_file "${CMAKE_CURRENT_SOURCE_DIR}/GpgFrontendTestExport.h")
generate_export_header(gpgfrontend_test EXPORT_FILE_NAME "${_export_file}")
# compile definitions
-target_compile_definitions(gpgfrontend_test PUBLIC GF_TEST)
+target_compile_definitions(gpgfrontend_test PRIVATE GF_TEST_PRIVATE)
# link options
target_link_libraries(gpgfrontend_test PRIVATE GTest::gtest)
diff --git a/src/test/GpgFrontendCoreExport.h b/src/test/GpgFrontendCoreExport.h
deleted file mode 100644
index 4d1b2f0b..00000000
--- a/src/test/GpgFrontendCoreExport.h
+++ /dev/null
@@ -1,42 +0,0 @@
-
-#ifndef GPGFRONTEND_TEST_EXPORT_H
-#define GPGFRONTEND_TEST_EXPORT_H
-
-#ifdef GPGFRONTEND_TEST_STATIC_DEFINE
-# define GPGFRONTEND_TEST_EXPORT
-# define GPGFRONTEND_TEST_NO_EXPORT
-#else
-# ifndef GPGFRONTEND_TEST_EXPORT
-# ifdef gpgfrontend_test_EXPORTS
- /* We are building this library */
-# define GPGFRONTEND_TEST_EXPORT __attribute__((visibility("default")))
-# else
- /* We are using this library */
-# define GPGFRONTEND_TEST_EXPORT __attribute__((visibility("default")))
-# endif
-# endif
-
-# ifndef GPGFRONTEND_TEST_NO_EXPORT
-# define GPGFRONTEND_TEST_NO_EXPORT __attribute__((visibility("hidden")))
-# endif
-#endif
-
-#ifndef GPGFRONTEND_TEST_DEPRECATED
-# define GPGFRONTEND_TEST_DEPRECATED __attribute__ ((__deprecated__))
-#endif
-
-#ifndef GPGFRONTEND_TEST_DEPRECATED_EXPORT
-# define GPGFRONTEND_TEST_DEPRECATED_EXPORT GPGFRONTEND_TEST_EXPORT GPGFRONTEND_TEST_DEPRECATED
-#endif
-
-#ifndef GPGFRONTEND_TEST_DEPRECATED_NO_EXPORT
-# define GPGFRONTEND_TEST_DEPRECATED_NO_EXPORT GPGFRONTEND_TEST_NO_EXPORT GPGFRONTEND_TEST_DEPRECATED
-#endif
-
-#if 0 /* DEFINE_NO_DEPRECATED */
-# ifndef GPGFRONTEND_TEST_NO_DEPRECATED
-# define GPGFRONTEND_TEST_NO_DEPRECATED
-# endif
-#endif
-
-#endif /* GPGFRONTEND_TEST_EXPORT_H */
diff --git a/src/test/GpgFrontendTest.cpp b/src/test/GpgFrontendTest.cpp
index 6149ba04..ce026b19 100644
--- a/src/test/GpgFrontendTest.cpp
+++ b/src/test/GpgFrontendTest.cpp
@@ -96,8 +96,8 @@ void SetupGlobalTestEnv() {
auto test_config_path = test_path + "/conf/test.ini";
auto test_data_path = test_path + "/data";
- qCInfo(test) << "test config file path: " << test_config_path;
- qCInfo(test) << "test data file path: " << test_data_path;
+ LOG_I() << "test config file path: " << test_config_path;
+ LOG_I() << "test data file path: " << test_data_path;
ImportPrivateKeys(test_data_path,
QSettings(test_config_path, QSettings::IniFormat));
diff --git a/src/test/GpgFrontendTest.h b/src/test/GpgFrontendTest.h
index ee9dc01d..d78f6636 100644
--- a/src/test/GpgFrontendTest.h
+++ b/src/test/GpgFrontendTest.h
@@ -28,14 +28,30 @@
#pragma once
+// project base header
+#include "GpgFrontend.h"
+
+// symbol exports header
#include "GpgFrontendTestExport.h"
-// declare area of test
-#ifdef GF_TEST
+// private declare area of test
+#ifdef GF_TEST_PRIVATE
// declare logging category
Q_DECLARE_LOGGING_CATEGORY(test)
+#define LOG_D() qCDebug(test)
+#define LOG_I() qCInfo(test)
+#define LOG_W() qCWarning(test)
+#define LOG_E() qCCritical(test)
+#define LOG_F() qCFatal(test)
+
+#define FLOG_D(...) qCDebug(test, __VA_ARGS__)
+#define FLOG_I(...) qCInfo(test, __VA_ARGS__)
+#define FLOG_W(...) qCWarning(test, __VA_ARGS__)
+#define FLOG_E(...) qCCritical(test, __VA_ARGS__)
+#define FLOG_F(...) qCFatal(test, __VA_ARGS__)
+
#endif
namespace GpgFrontend::Test {
diff --git a/src/test/GpgFrontendTestExport.h b/src/test/GpgFrontendTestExport.h
deleted file mode 100644
index 4d1b2f0b..00000000
--- a/src/test/GpgFrontendTestExport.h
+++ /dev/null
@@ -1,42 +0,0 @@
-
-#ifndef GPGFRONTEND_TEST_EXPORT_H
-#define GPGFRONTEND_TEST_EXPORT_H
-
-#ifdef GPGFRONTEND_TEST_STATIC_DEFINE
-# define GPGFRONTEND_TEST_EXPORT
-# define GPGFRONTEND_TEST_NO_EXPORT
-#else
-# ifndef GPGFRONTEND_TEST_EXPORT
-# ifdef gpgfrontend_test_EXPORTS
- /* We are building this library */
-# define GPGFRONTEND_TEST_EXPORT __attribute__((visibility("default")))
-# else
- /* We are using this library */
-# define GPGFRONTEND_TEST_EXPORT __attribute__((visibility("default")))
-# endif
-# endif
-
-# ifndef GPGFRONTEND_TEST_NO_EXPORT
-# define GPGFRONTEND_TEST_NO_EXPORT __attribute__((visibility("hidden")))
-# endif
-#endif
-
-#ifndef GPGFRONTEND_TEST_DEPRECATED
-# define GPGFRONTEND_TEST_DEPRECATED __attribute__ ((__deprecated__))
-#endif
-
-#ifndef GPGFRONTEND_TEST_DEPRECATED_EXPORT
-# define GPGFRONTEND_TEST_DEPRECATED_EXPORT GPGFRONTEND_TEST_EXPORT GPGFRONTEND_TEST_DEPRECATED
-#endif
-
-#ifndef GPGFRONTEND_TEST_DEPRECATED_NO_EXPORT
-# define GPGFRONTEND_TEST_DEPRECATED_NO_EXPORT GPGFRONTEND_TEST_NO_EXPORT GPGFRONTEND_TEST_DEPRECATED
-#endif
-
-#if 0 /* DEFINE_NO_DEPRECATED */
-# ifndef GPGFRONTEND_TEST_NO_DEPRECATED
-# define GPGFRONTEND_TEST_NO_DEPRECATED
-# endif
-#endif
-
-#endif /* GPGFRONTEND_TEST_EXPORT_H */
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index b3cd0165..a253d0ee 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -50,7 +50,7 @@ set(_export_file "${CMAKE_CURRENT_SOURCE_DIR}/GpgFrontendUIExport.h")
generate_export_header(gpgfrontend_ui EXPORT_FILE_NAME "${_export_file}")
# compile definitions
-target_compile_definitions(gpgfrontend_ui PUBLIC GF_UI)
+target_compile_definitions(gpgfrontend_ui PRIVATE GF_UI_PRIVATE)
# link qt
target_link_libraries(gpgfrontend_ui
diff --git a/src/ui/GpgFrontendApplication.cpp b/src/ui/GpgFrontendApplication.cpp
index 5227e55a..a7e304d1 100644
--- a/src/ui/GpgFrontendApplication.cpp
+++ b/src/ui/GpgFrontendApplication.cpp
@@ -57,7 +57,7 @@ bool GpgFrontendApplication::notify(QObject *receiver, QEvent *event) {
try {
return QApplication::notify(receiver, event);
} catch (const std::exception &ex) {
- qCWarning(ui, "exception was caught in notify: {}", ex.what());
+ FLOG_W("exception was caught in notify: {}", ex.what());
QMessageBox::information(
nullptr, tr("Standard Exception Thrown"),
tr("Oops, an standard exception was thrown "
@@ -66,7 +66,7 @@ bool GpgFrontendApplication::notify(QObject *receiver, QEvent *event) {
"be the negligence of the programmer, "
"please report this problem if you can."));
} catch (...) {
- qCWarning(ui, "unknown exception was caught in notify");
+ FLOG_W("unknown exception was caught in notify");
QMessageBox::information(
nullptr, tr("Unhandled Exception Thrown"),
tr("Oops, an unhandled exception was thrown "
diff --git a/src/ui/GpgFrontendUI.h b/src/ui/GpgFrontendUI.h
index e69f1dc3..c3816469 100644
--- a/src/ui/GpgFrontendUI.h
+++ b/src/ui/GpgFrontendUI.h
@@ -28,18 +28,31 @@
#pragma once
-/**
- * Basic dependency
- */
+// project base header
+#include "GpgFrontend.h"
+
+// qt
#include <QtWidgets>
-// UI
-#include "ui/GpgFrontendUIExport.h"
+// ui symbol exports macro
+#include "GpgFrontendUIExport.h"
-// declare area of ui
-#ifdef GF_UI
+// private declare area of ui
+#ifdef GF_UI_PRIVATE
// declare logging category
Q_DECLARE_LOGGING_CATEGORY(ui)
+#define LOG_D() qCDebug(ui)
+#define LOG_I() qCInfo(ui)
+#define LOG_W() qCWarning(ui)
+#define LOG_E() qCCritical(ui)
+#define LOG_F() qCFatal(core)
+
+#define FLOG_D(...) qCDebug(ui, __VA_ARGS__)
+#define FLOG_I(...) qCInfo(ui, __VA_ARGS__)
+#define FLOG_W(...) qCWarning(ui, __VA_ARGS__)
+#define FLOG_E(...) qCCritical(ui, __VA_ARGS__)
+#define FLOG_F(...) qCFatal(ui, __VA_ARGS__)
+
#endif
diff --git a/src/ui/GpgFrontendUIInit.cpp b/src/ui/GpgFrontendUIInit.cpp
index f7ebfd29..0309ca1f 100644
--- a/src/ui/GpgFrontendUIInit.cpp
+++ b/src/ui/GpgFrontendUIInit.cpp
@@ -48,7 +48,7 @@ QList<QByteArray> loaded_qm_datum;
extern void InitUITranslations();
void WaitEnvCheckingProcess() {
- qCDebug(ui, "need to waiting for env checking process");
+ FLOG_D("need to waiting for env checking process");
// create and show loading window before starting the main window
auto* waiting_dialog = new QProgressDialog();
@@ -78,19 +78,19 @@ void WaitEnvCheckingProcess() {
&QEventLoop::quit);
QApplication::connect(waiting_dialog, &QProgressDialog::canceled, [=]() {
- qCDebug(ui, "cancel clicked on waiting dialog");
+ FLOG_D("cancel clicked on waiting dialog");
QApplication::quit();
exit(0);
});
auto env_state =
Module::RetrieveRTValueTypedOrDefault<>("core", "env.state.basic", 0);
- qCDebug(ui, "ui is ready to waiting for env initialized, env_state: %d",
+ FLOG_D("ui is ready to waiting for env initialized, env_state: %d",
env_state);
// check twice to avoid some unlucky sitations
if (env_state == 1) {
- qCDebug(ui, "env state turned initialized before the looper start");
+ FLOG_D("env state turned initialized before the looper start");
waiting_dialog->finished(0);
waiting_dialog->deleteLater();
return;
@@ -186,7 +186,7 @@ void InitGpgFrontendUI(QApplication* /*app*/) {
QNetworkProxy::setApplicationProxy(proxy);
} catch (...) {
- qCWarning(ui, "setting operation error: proxy setings");
+ FLOG_W("setting operation error: proxy setings");
// no proxy by default
QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
}
@@ -207,7 +207,7 @@ auto RunGpgFrontendUI(QApplication* app) -> int {
// pre-check, if application need to restart
if (CommonUtils::GetInstance()->isApplicationNeedRestart()) {
- qCDebug(ui, "application need to restart, before main window init.");
+ FLOG_D("application need to restart, before main window init.");
return kDeepRestartCode;
}
diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp
index acd89874..c6be2715 100644
--- a/src/ui/UserInterfaceUtils.cpp
+++ b/src/ui/UserInterfaceUtils.cpp
@@ -325,16 +325,16 @@ void CommonUtils::SlotExecuteCommand(
&QEventLoop::quit);
connect(cmd_process, &QProcess::errorOccurred, &looper, &QEventLoop::quit);
connect(cmd_process, &QProcess::started,
- []() -> void { qCDebug(ui, "process started"); });
+ []() -> void { FLOG_D("process started"); });
connect(cmd_process, &QProcess::readyReadStandardOutput,
[interact_func, cmd_process]() { interact_func(cmd_process); });
connect(cmd_process, &QProcess::errorOccurred, this,
- [=]() -> void { qCWarning(ui, "error in process"); });
+ [=]() -> void { FLOG_W("error in process"); });
connect(cmd_process,
qOverload<int, QProcess::ExitStatus>(&QProcess::finished), this,
[=](int, QProcess::ExitStatus status) {
if (status != QProcess::NormalExit) {
- qCWarning(ui) << "error in executing command: " << cmd;
+ LOG_W() << "error in executing command: " << cmd;
}
});
@@ -361,11 +361,11 @@ void CommonUtils::SlotExecuteGpgCommand(
&WaitingDialog::deleteLater);
connect(gpg_process, &QProcess::errorOccurred, &looper, &QEventLoop::quit);
connect(gpg_process, &QProcess::started,
- []() -> void { qCDebug(ui, "gpg process started"); });
+ []() -> void { FLOG_D("gpg process started"); });
connect(gpg_process, &QProcess::readyReadStandardOutput,
[interact_func, gpg_process]() { interact_func(gpg_process); });
connect(gpg_process, &QProcess::errorOccurred, this, [=]() -> void {
- qCWarning(ui, "Error in Process");
+ FLOG_W("Error in Process");
dialog->close();
QMessageBox::critical(nullptr, tr("Failure"),
tr("Failed to execute command."));
@@ -489,7 +489,7 @@ void CommonUtils::slot_update_key_from_server_finished(
bool success, QString err_msg, QByteArray buffer,
std::shared_ptr<GpgImportInformation> info) {
if (!success) {
- qCWarning(ui) << "get err from reply: " << buffer;
+ LOG_W() << "get err from reply: " << buffer;
QMessageBox::critical(nullptr, tr("Error"), err_msg);
return;
}
diff --git a/src/ui/dialog/GeneralDialog.cpp b/src/ui/dialog/GeneralDialog.cpp
index 63e67b72..7f9a9f92 100644
--- a/src/ui/dialog/GeneralDialog.cpp
+++ b/src/ui/dialog/GeneralDialog.cpp
@@ -69,7 +69,7 @@ void GpgFrontend::UI::GeneralDialog::slot_restore_settings() noexcept {
}
} catch (...) {
- qCWarning(ui, "error at restoring settings");
+ FLOG_W("error at restoring settings");
}
}
@@ -92,7 +92,7 @@ void GpgFrontend::UI::GeneralDialog::slot_save_settings() noexcept {
general_windows_state.Store(window_state.Json());
} catch (...) {
- qCWarning(ui) << "general dialog: " << name_ << ", caught exception";
+ LOG_W() << "general dialog: " << name_ << ", caught exception";
}
}
diff --git a/src/ui/dialog/Wizard.cpp b/src/ui/dialog/Wizard.cpp
index e66283fe..10b2c449 100644
--- a/src/ui/dialog/Wizard.cpp
+++ b/src/ui/dialog/Wizard.cpp
@@ -60,7 +60,7 @@ void Wizard::slot_wizard_accepted() {
auto settings = GlobalSettingStation::GetInstance().GetSettings();
settings.setValue("wizard/show_wizard", false);
} catch (...) {
- qCWarning(ui, "setting operation error");
+ FLOG_W("setting operation error");
}
if (field("openHelp").toBool()) {
emit SignalOpenHelp("docu.html#content");
diff --git a/src/ui/dialog/import_export/KeyServerImportDialog.cpp b/src/ui/dialog/import_export/KeyServerImportDialog.cpp
index 36491749..47d80090 100644
--- a/src/ui/dialog/import_export/KeyServerImportDialog.cpp
+++ b/src/ui/dialog/import_export/KeyServerImportDialog.cpp
@@ -132,7 +132,7 @@ auto KeyServerImportDialog::create_combo_box() -> QComboBox* {
}
combo_box->setCurrentText(key_server.GetTargetServer());
} catch (...) {
- qCWarning(ui, "setting operation error server_list default_server");
+ FLOG_W("setting operation error server_list default_server");
}
return combo_box;
diff --git a/src/ui/dialog/import_export/KeyUploadDialog.cpp b/src/ui/dialog/import_export/KeyUploadDialog.cpp
index 241548fd..a19f02f2 100644
--- a/src/ui/dialog/import_export/KeyUploadDialog.cpp
+++ b/src/ui/dialog/import_export/KeyUploadDialog.cpp
@@ -74,7 +74,7 @@ void KeyUploadDialog::SlotUpload() {
if (CheckGpgError(err) == GPG_ERR_USER_1 || data_obj == nullptr ||
!data_obj->Check<GFBuffer>()) {
- qCWarning(ui, "data object checking failed");
+ FLOG_W("data object checking failed");
QMessageBox::critical(this, tr("Error"),
tr("Unknown error occurred"));
// Done
diff --git a/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
index d641ff3b..f2efb037 100644
--- a/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
@@ -517,7 +517,7 @@ void KeyPairOperaTab::slot_export_paper_key() {
[this, file_name](Module::EventIdentifier i,
Module::Event::ListenerIdentifier ei,
Module::Event::Params p) {
- qCDebug(ui) << "REQUEST_TRANS_KEY_2_PAPER_KEY callback: " << i << ei;
+ LOG_D() << "REQUEST_TRANS_KEY_2_PAPER_KEY callback: " << i << ei;
if (p["ret"] != "0" || p["paper_key"].isEmpty()) {
QMessageBox::critical(
@@ -597,7 +597,7 @@ void KeyPairOperaTab::slot_import_paper_key() {
},
[this](Module::EventIdentifier i, Module::Event::ListenerIdentifier ei,
Module::Event::Params p) {
- qCDebug(ui) << "REQUEST_TRANS_PAPER_KEY_2_KEY callback: " << i << ei;
+ LOG_D() << "REQUEST_TRANS_PAPER_KEY_2_KEY callback: " << i << ei;
if (p["ret"] != "0" || p["secret_key"].isEmpty()) {
QMessageBox::critical(this, tr("Error"),
diff --git a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
index a06a6111..bb7972ae 100644
--- a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
@@ -211,7 +211,7 @@ void KeyPairSubkeyTab::slot_refresh_subkey_list() {
row++;
}
- qCDebug(ui, "subkey_list_ refreshed");
+ FLOG_D("subkey_list_ refreshed");
if (subkey_list_->rowCount() > 0) {
subkey_list_->selectRow(0);
diff --git a/src/ui/function/GenerateRevokeCertification.cpp b/src/ui/function/GenerateRevokeCertification.cpp
index ab7b039b..9522c125 100644
--- a/src/ui/function/GenerateRevokeCertification.cpp
+++ b/src/ui/function/GenerateRevokeCertification.cpp
@@ -48,8 +48,8 @@ auto GenerateRevokeCertification::Exec(const GpgKey& key,
output_path, "--gen-revoke", key.GetFingerprint()},
[=](int exit_code, const QString& p_out, const QString& p_err) {
if (exit_code != 0) {
- qCWarning(ui) << "gnupg gen revoke execute error, process stderr: "
- << p_err << ", process stdout: " << p_out;
+ LOG_W() << "gnupg gen revoke execute error, process stderr: "
+ << p_err << ", process stdout: " << p_out;
} else {
qCDebug(ui,
"gnupg gen revoke exit_code: %d, process stdout size: %lld",
diff --git a/src/ui/main_window/GeneralMainWindow.cpp b/src/ui/main_window/GeneralMainWindow.cpp
index d6d5240e..1cdb44e0 100644
--- a/src/ui/main_window/GeneralMainWindow.cpp
+++ b/src/ui/main_window/GeneralMainWindow.cpp
@@ -112,7 +112,7 @@ void GpgFrontend::UI::GeneralMainWindow::slot_restore_settings() noexcept {
icon_style_ = toolButtonStyle();
} catch (...) {
- qCWarning(ui) << "general main window: " << name_ << ", caught exception";
+ LOG_W() << "general main window: " << name_ << ", caught exception";
}
}
@@ -134,7 +134,7 @@ void GpgFrontend::UI::GeneralMainWindow::slot_save_settings() noexcept {
general_windows_state.Store(window_state.Json());
} catch (...) {
- qCWarning(ui) << "general main window: " << name_ << ", caught exception";
+ LOG_W() << "general main window: " << name_ << ", caught exception";
}
}
diff --git a/src/ui/main_window/KeyMgmt.cpp b/src/ui/main_window/KeyMgmt.cpp
index 76dc4925..bc677d04 100644
--- a/src/ui/main_window/KeyMgmt.cpp
+++ b/src/ui/main_window/KeyMgmt.cpp
@@ -413,7 +413,7 @@ void KeyMgmt::SlotExportKeyToClipboard() {
}
if (data_obj == nullptr || !data_obj->Check<GFBuffer>()) {
- qCWarning(ui, "data object checking failed");
+ FLOG_W("data object checking failed");
QMessageBox::critical(this, tr("Error"),
tr("Unknown error occurred"));
return;
diff --git a/src/ui/main_window/MainWindow.cpp b/src/ui/main_window/MainWindow.cpp
index 0de8d2dd..88c61218 100644
--- a/src/ui/main_window/MainWindow.cpp
+++ b/src/ui/main_window/MainWindow.cpp
@@ -151,7 +151,7 @@ void MainWindow::Init() noexcept {
if (show_wizard) slot_start_wizard();
} catch (...) {
- qCWarning(ui) << tr("Critical error occur while loading GpgFrontend.");
+ LOG_W() << tr("Critical error occur while loading GpgFrontend.");
QMessageBox::critical(
nullptr, tr("Loading Failed"),
tr("Critical error occur while loading GpgFrontend."));
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp
index 653a3991..fc63a585 100644
--- a/src/ui/main_window/MainWindowSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowSlotFunction.cpp
@@ -63,14 +63,14 @@ void MainWindow::slot_append_selected_keys() {
auto key_ids = m_key_list_->GetSelected();
if (key_ids->empty()) {
- qCWarning(ui, "no key is selected to export");
+ FLOG_W("no key is selected to export");
return;
}
auto key = GpgKeyGetter::GetInstance().GetKey(key_ids->front());
if (!key.IsGood()) {
- qCWarning(ui) << "selected key for exporting is invalid, key id: "
- << key_ids->front();
+ LOG_W() << "selected key for exporting is invalid, key id: "
+ << key_ids->front();
return;
}
@@ -88,7 +88,7 @@ void MainWindow::slot_append_keys_create_datetime() {
auto key_ids = m_key_list_->GetSelected();
if (key_ids->empty()) {
- qCWarning(ui, "no key is selected");
+ FLOG_W("no key is selected");
return;
}
@@ -112,7 +112,7 @@ void MainWindow::slot_append_keys_expire_datetime() {
auto key_ids = m_key_list_->GetSelected();
if (key_ids->empty()) {
- qCWarning(ui, "no key is selected");
+ FLOG_W("no key is selected");
return;
}
@@ -271,7 +271,7 @@ void MainWindow::slot_version_upgrade_notify() {
auto is_loading_done = Module::RetrieveRTValueTypedOrDefault<>(
kVersionCheckingModuleID, "version.loading_done", false);
if (!is_loading_done) {
- qCWarning(ui, "invalid version info from rt, loading hasn't done yet");
+ FLOG_W("invalid version info from rt, loading hasn't done yet");
return;
}
diff --git a/src/ui/thread/KeyServerImportTask.cpp b/src/ui/thread/KeyServerImportTask.cpp
index 5ff2bf3e..0abeb944 100644
--- a/src/ui/thread/KeyServerImportTask.cpp
+++ b/src/ui/thread/KeyServerImportTask.cpp
@@ -69,8 +69,7 @@ void GpgFrontend::UI::KeyServerImportTask::dealing_reply_from_server() {
auto buffer = reply_->readAll();
if (network_reply != QNetworkReply::NoError) {
- qCWarning(ui) << "key import error, message from key server reply: "
- << buffer;
+ LOG_W() << "key import error, message from key server reply: " << buffer;
QString err_msg;
switch (network_reply) {
diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp
index 28d95f31..c4a05edc 100644
--- a/src/ui/widgets/KeyList.cpp
+++ b/src/ui/widgets/KeyList.cpp
@@ -350,7 +350,7 @@ auto KeyList::GetSelected() -> KeyIdArgsListPtr {
auto* key_table = qobject_cast<KeyTable*>(ui_->keyGroupTab->currentWidget());
if (key_table == nullptr) {
- qCWarning(ui, "fail to get current key table, nullptr");
+ FLOG_W("fail to get current key table, nullptr");
return ret;
}
@@ -360,7 +360,7 @@ auto KeyList::GetSelected() -> KeyIdArgsListPtr {
}
if (ret->empty()) {
- qCWarning(ui, "nothing is selected at key list");
+ FLOG_W("nothing is selected at key list");
}
return ret;
}
@@ -389,8 +389,8 @@ void KeyList::contextMenuEvent(QContextMenuEvent* event) {
auto* key_table = qobject_cast<KeyTable*>(ui_->keyGroupTab->currentWidget());
if (key_table == nullptr) {
- qCDebug(ui, "m_key_list_ is nullptr, key group tab number: %d",
- ui_->keyGroupTab->count());
+ FLOG_D("m_key_list_ is nullptr, key group tab number: %d",
+ ui_->keyGroupTab->count());
return;
}
@@ -468,7 +468,7 @@ void KeyList::dropEvent(QDropEvent* event) {
QFile file;
file.setFileName(tmp.toLocalFile());
if (!file.open(QIODevice::ReadOnly)) {
- qCWarning(ui) << "couldn't open file: " << tmp.toString();
+ LOG_W() << "couldn't open file: " << tmp.toString();
}
auto in_buffer = file.readAll();
this->import_keys(in_buffer);
diff --git a/src/ui/widgets/PlainTextEditorPage.cpp b/src/ui/widgets/PlainTextEditorPage.cpp
index 2b24eb65..6e92b5b6 100644
--- a/src/ui/widgets/PlainTextEditorPage.cpp
+++ b/src/ui/widgets/PlainTextEditorPage.cpp
@@ -164,7 +164,7 @@ void PlainTextEditorPage::ReadFile() {
[=]() { emit read_task->SignalTaskShouldEnd(0); });
connect(read_task, &FileReadTask::SignalFileBytesReadEnd, this, [=]() {
// set the UI
- qCDebug(ui, "signal file bytes read end rised");
+ FLOG_D("signal file bytes read end rised");
this->read_done_ = true;
text_page->setEnabled(true);
text_page->document()->setModified(false);
diff --git a/src/ui/widgets/TextEdit.cpp b/src/ui/widgets/TextEdit.cpp
index 2c6a0ff3..4d83cff3 100644
--- a/src/ui/widgets/TextEdit.cpp
+++ b/src/ui/widgets/TextEdit.cpp
@@ -612,7 +612,7 @@ void TextEdit::slot_save_status_to_cache_for_revovery() {
bool restore_text_editor_page =
settings.value("basic/restore_text_editor_page", false).toBool();
if (!restore_text_editor_page) {
- qCDebug(ui, "restore_text_editor_page is false, ignoring...");
+ FLOG_D("restore_text_editor_page is false, ignoring...");
return;
}