Skip to content

Commit

Permalink
fix: qt5 compile issues
Browse files Browse the repository at this point in the history
  • Loading branch information
saturneric committed Feb 3, 2025
1 parent e2fa8ab commit 37d5b7e
Show file tree
Hide file tree
Showing 44 changed files with 114 additions and 101 deletions.
2 changes: 1 addition & 1 deletion .gitea/workflows/develop-qt6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
sudo apt-get update
sudo apt-get -y install build-essential binutils git cmake
sudo apt-get -y install autoconf automake gettext texinfo
sudo apt-get -y install gcc g++ ninja-build gnupg qt6-base-dev qt6-base-dev-tools qt6-l10n-tools qt6-tools-dev qt6-tools-dev-tools libqt6svg6
sudo apt-get -y install gcc g++ ninja-build gnupg qtchooser qt6-base-dev qt6-base-dev-tools qt6-l10n-tools qt6-tools-dev qt6-tools-dev-tools libqt6svg6
sudo apt-get -y install libarchive-dev libssl-dev libgpgme-dev libgl1-mesa-dev libfuse2
- name: Build GpgME
Expand Down
2 changes: 1 addition & 1 deletion src/core/function/KeyPackageOperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace GpgFrontend {
auto KeyPackageOperator::GeneratePassphrase(const QString& phrase_path,
QString& phrase) -> bool {
phrase = PassphraseGenerator::GetInstance().Generate(256);
FLOG_D("generated passphrase: %lld bytes", phrase.size());
FLOG_D() << "generated passphrase: " << phrase.size() << "bytes";
return WriteFile(phrase_path, phrase.toUtf8());
}

Expand Down
1 change: 1 addition & 0 deletions src/core/function/basic/GpgFunctionObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "core/function/basic/ChannelObject.h"
#include "core/function/basic/SingletonStorage.h"
#include "core/function/basic/SingletonStorageCollection.h"
#include "core/typedef/CoreTypedef.h"
#include "core/utils/MemoryUtils.h"

namespace GpgFrontend {
Expand Down
6 changes: 4 additions & 2 deletions src/core/function/gpg/GpgBasicOperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ void SetSignersImpl(GpgContext& ctx_, const KeyArgsList& signers, bool ascii) {
CheckGpgError(error);
}
}
if (signers.size() != gpgme_signers_count(ctx_.DefaultContext())) {

auto count = gpgme_signers_count(ctx_.DefaultContext());
if (static_cast<unsigned int>(signers.size()) != count) {
FLOG_D("not all signers added");
}
}
Expand Down Expand Up @@ -286,7 +288,7 @@ auto EncryptSignImpl(GpgContext& ctx_, const KeyArgsList& keys,
QContainer<gpgme_key_t> recipients(keys.begin(), keys.end());

// Last entry data_in array has to be nullptr
recipients.emplace_back(nullptr);
recipients.push_back(nullptr);

SetSignersImpl(ctx_, signers, ascii);

Expand Down
2 changes: 1 addition & 1 deletion src/core/function/gpg/GpgCommandExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void GpgCommandExecutor::ExecuteConcurrentlySync(ExecuteContexts contexts) {

QObject::connect(task, &Thread::Task::SignalTaskEnd, [&]() {
--remaining_tasks;
FLOG_D("remaining tasks: %lld", remaining_tasks);
LOG_D() << "remaining tasks: " << remaining_tasks;
if (remaining_tasks <= 0) {
FLOG_D("no remaining task, quit");
looper.quit();
Expand Down
2 changes: 1 addition & 1 deletion src/core/function/gpg/GpgCommandExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class GPGFRONTEND_CORE_EXPORT GpgCommandExecutor {
GpgCommandExecutorInterator int_func = [](QProcess *) {});
};

using ExecuteContexts = QList<ExecuteContext>;
using ExecuteContexts = QContainer<ExecuteContext>;

/**
* @brief Excuting a command
Expand Down
4 changes: 2 additions & 2 deletions src/core/function/gpg/GpgFileOpera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ auto GpgFileOpera::EncryptDirectorySymmetricSync(
const QString& out_path) -> std::tuple<GpgError, DataObjectPtr> {
auto ex = CreateStandardGFDataExchanger();

CreateArchiveHelper(in_path, ex);

return RunGpgOperaSync(
[=](const DataObjectPtr& data_object) -> GpgError {
GpgData data_in(ex);
Expand All @@ -470,8 +472,6 @@ auto GpgFileOpera::EncryptDirectorySymmetricSync(
data_object);
},
"gpgme_op_encrypt_symmetric", "2.1.0");

CreateArchiveHelper(in_path, ex);
}

} // namespace GpgFrontend
6 changes: 3 additions & 3 deletions src/core/function/gpg/GpgKeyGetter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@ class GpgKeyGetter::Impl : public SingletonFunctionObject<GpgKeyGetter::Impl> {

auto GetKeys(const KeyIdArgsList& ids) -> GpgKeyList {
auto keys = GpgKeyList{};
for (const auto& key_id : ids) keys.emplace_back(GetKey(key_id, true));
for (const auto& key_id : ids) keys.push_back(GetKey(key_id, true));
return keys;
}

auto GetKeysCopy(const GpgKeyList& keys) -> GpgKeyList {
// get the lock
std::lock_guard<std::mutex> lock(ctx_mutex_);
auto keys_copy = GpgKeyList{};
for (const auto& key : keys) keys_copy.emplace_back(key);
for (const auto& key : keys) keys_copy.push_back(key);
return keys_copy;
}

Expand Down Expand Up @@ -192,7 +192,7 @@ class GpgKeyGetter::Impl : public SingletonFunctionObject<GpgKeyGetter::Impl> {
* @brief
*
*/
QList<GpgKey> keys_cache_;
QContainer<GpgKey> keys_cache_;

/**
* @brief shared mutex for the keys cache
Expand Down
10 changes: 5 additions & 5 deletions src/core/function/gpg/GpgKeyImportExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ auto GpgKeyImportExporter::ImportKey(const GFBuffer& in_buffer)
GpgImportInformation::GpgImportedKey key;
key.import_status = static_cast<int>(status->status);
key.fpr = status->fpr;
import_info->imported_keys.emplace_back(key);
import_info->imported_keys.push_back(key);
status = status->next;
}
return import_info;
Expand All @@ -85,8 +85,8 @@ auto GpgKeyImportExporter::ExportKey(const GpgKey& key, bool secret, bool ascii,
QContainer<gpgme_key_t> keys_array;

// Last entry data_in array has to be nullptr
keys_array.emplace_back(key);
keys_array.emplace_back(nullptr);
keys_array.push_back(static_cast<gpgme_key_t>(key));
keys_array.push_back(nullptr);

GpgData data_out;
auto* ctx = ascii ? ctx_.DefaultContext() : ctx_.BinaryContext();
Expand Down Expand Up @@ -117,7 +117,7 @@ void GpgKeyImportExporter::ExportKeys(const KeyArgsList& keys, bool secret,
QContainer<gpgme_key_t> keys_array(keys.begin(), keys.end());

// Last entry data_in array has to be nullptr
keys_array.emplace_back(nullptr);
keys_array.push_back(nullptr);

GpgData data_out;
auto* ctx = ascii ? ctx_.DefaultContext() : ctx_.BinaryContext();
Expand Down Expand Up @@ -147,7 +147,7 @@ void GpgKeyImportExporter::ExportAllKeys(const KeyArgsList& keys, bool secret,
QContainer<gpgme_key_t> keys_array(keys.begin(), keys.end());

// Last entry data_in array has to be nullptr
keys_array.emplace_back(nullptr);
keys_array.push_back(nullptr);

GpgData data_out;
auto* ctx = ascii ? ctx_.DefaultContext() : ctx_.BinaryContext();
Expand Down
2 changes: 1 addition & 1 deletion src/core/function/gpg/GpgKeyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ auto GpgKeyManager::RevokeSubkey(const GpgKey& key, int subkey_index,

// dealing with reason text
auto reason_text_lines = SecureCreateSharedObject<QStringList>(
reason_text.split('\n', Qt::SkipEmptyParts).toVector());
reason_text.split('\n', Qt::SkipEmptyParts));

AutomatonNextStateHandler next_state_handler =
[](AutomatonState state, QString status, QString args) {
Expand Down
8 changes: 4 additions & 4 deletions src/core/function/gpg/GpgKeyOpera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void GpgKeyOpera::GenerateRevokeCert(const GpgKey& key,

// dealing with reason text
auto reason_text_lines = GpgFrontend::SecureCreateSharedObject<QStringList>(
revocation_reason_text.split('\n', Qt::SkipEmptyParts).toVector());
revocation_reason_text.split('\n', Qt::SkipEmptyParts));

const auto app_path = Module::RetrieveRTValueTypedOrDefault<>(
"core", "gpgme.ctx.app_path", QString{});
Expand All @@ -124,10 +124,10 @@ void GpgKeyOpera::GenerateRevokeCert(const GpgKey& key,
if (exit_code != 0) {
LOG_W() << "gnupg gen revoke execute error, process stderr: "
<< p_err << ", process stdout: " << p_out;
} else {
FLOG_D("gnupg gen revoke exit_code: %d, process stdout size: %lld",
exit_code, p_out.size());
return;
}
LOG_D() << "gnupg gen revoke exit_code: " << exit_code
<< "process stdout size: " << p_out.size();
},
nullptr,
[revocation_reason_code, reason_text_lines](QProcess* proc) -> void {
Expand Down
2 changes: 1 addition & 1 deletion src/core/function/gpg/GpgUIDOperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ auto GpgUIDOperator::RevokeUID(const GpgKey& key, int uid_index,

// dealing with reason text
auto reason_text_lines = GpgFrontend::SecureCreateSharedObject<QStringList>(
reason_text.split('\n', Qt::SkipEmptyParts).toVector());
reason_text.split('\n', Qt::SkipEmptyParts));

AutomatonNextStateHandler next_state_handler = [](AutomatonState state,
QString status,
Expand Down
2 changes: 1 addition & 1 deletion src/core/model/DataObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DataObject::Impl {
void AppendObject(const std::any& obj) { params_.push_back(obj); }

auto GetParameter(size_t index) -> std::any {
if (index >= params_.size()) {
if (index >= static_cast<size_t>(params_.size())) {
throw std::out_of_range("index out of range");
}
return params_[index];
Expand Down
2 changes: 1 addition & 1 deletion src/core/model/DataObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class GPGFRONTEND_CORE_EXPORT DataObject {
if (sizeof...(Args) != GetObjectSize()) return false;

QContainer<std::type_info const*> type_list = {&typeid(Args)...};
for (size_t i = 0; i < type_list.size(); ++i) {
for (qsizetype i = 0; i < static_cast<qsizetype>(type_list.size()); ++i) {
if (std::type_index(*type_list[i]) !=
std::type_index((*this)[i].type())) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/core/model/GpgDecryptResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ auto GpgDecryptResult::Recipients() -> QContainer<GpgRecipient> {
for (auto* reci = result_ref_->recipients; reci != nullptr;
reci = reci->next) {
try {
result.emplace_back(reci);
result.push_back(GpgRecipient{reci});
} catch (...) {
FLOG_W(
"caught exception when processing invalid_recipients, "
Expand Down
5 changes: 4 additions & 1 deletion src/core/model/GpgEncryptResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ auto GpgEncryptResult::InvalidRecipients()
for (auto* invalid_key = result_ref_->invalid_recipients;
invalid_key != nullptr; invalid_key = invalid_key->next) {
try {
result.emplace_back(QString{invalid_key->fpr}, invalid_key->reason);
result.push_back({
QString{invalid_key->fpr},
invalid_key->reason,
});
} catch (...) {
FLOG_W(
"caught exception when processing invalid_recipients, "
Expand Down
8 changes: 2 additions & 6 deletions src/core/model/GpgKey.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,8 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
*/
auto operator<=(const GpgKey&) const -> bool;

/**
* @brief
*
* @return gpgme_key_t
*/
explicit operator gpgme_key_t() const;
// NOLINTNEXTLINE(google-explicit-constructor)
operator gpgme_key_t() const;

private:
/**
Expand Down
5 changes: 4 additions & 1 deletion src/core/model/GpgSignResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ auto GpgSignResult::InvalidSigners()
for (auto* invalid_key = result_ref_->invalid_signers; invalid_key != nullptr;
invalid_key = invalid_key->next) {
try {
result.emplace_back(QString{invalid_key->fpr}, invalid_key->reason);
result.push_back({
QString{invalid_key->fpr},
invalid_key->reason,
});
} catch (...) {
FLOG_W(
"caught exception when processing invalid_signers, "
Expand Down
6 changes: 3 additions & 3 deletions src/core/model/GpgVerifyResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ auto GpgVerifyResult::GetRaw() const -> gpgme_verify_result_t {
}

auto GpgVerifyResult::GetSignature() const -> QContainer<GpgSignature> {
QContainer<GpgSignature> sigatures;
QContainer<GpgSignature> signatures;

auto* signature = result_ref_->signatures;
while (signature != nullptr) {
sigatures.emplace_back(signature);
signatures.push_back(GpgSignature{signature});
signature = signature->next;
}
return sigatures;
return signatures;
}
} // namespace GpgFrontend
12 changes: 5 additions & 7 deletions src/core/module/GlobalModuleContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,17 +325,16 @@ class GlobalModuleContext::Impl {
return m.has_value() && m->get()->integrated;
}

auto ListAllRegisteredModuleID() -> QList<ModuleIdentifier> {
QList<ModuleIdentifier> module_ids;
auto ListAllRegisteredModuleID() -> QStringList {
QStringList module_ids;
for (const auto& module : module_register_table_) {
module_ids.append(module.first);
}
module_ids.sort();
return module_ids;
}

auto GetModuleListening(const ModuleIdentifier& module_id)
-> QList<EventIdentifier> {
auto GetModuleListening(const ModuleIdentifier& module_id) -> QStringList {
auto module_info = search_module_register_table(module_id);
if (!module_info.has_value()) return {};
return module_info->get()->listening_event_ids;
Expand Down Expand Up @@ -464,13 +463,12 @@ auto GlobalModuleContext::IsIntegratedModule(ModuleIdentifier m_id) -> bool {
return p_->IsIntegratedModule(m_id);
}

auto GlobalModuleContext::ListAllRegisteredModuleID()
-> QList<ModuleIdentifier> {
auto GlobalModuleContext::ListAllRegisteredModuleID() -> QStringList {
return p_->ListAllRegisteredModuleID();
}

auto GlobalModuleContext::GetModuleListening(ModuleIdentifier module_id)
-> QList<EventIdentifier> {
-> QStringList {
return p_->GetModuleListening(module_id);
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/module/GlobalModuleContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ class GPGFRONTEND_CORE_EXPORT GlobalModuleContext : public QObject {

auto SearchEvent(EventTriggerIdentifier) -> std::optional<EventReference>;

auto GetModuleListening(ModuleIdentifier) -> QList<EventIdentifier>;
auto GetModuleListening(ModuleIdentifier) -> QStringList;

auto IsModuleActivated(ModuleIdentifier) -> bool;

auto IsIntegratedModule(ModuleIdentifier) -> bool;

auto ListAllRegisteredModuleID() -> QList<ModuleIdentifier>;
auto ListAllRegisteredModuleID() -> QStringList;

[[nodiscard]] auto GetRegisteredModuleNum() const -> int;

Expand Down
2 changes: 1 addition & 1 deletion src/core/module/GlobalRegisterTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class GlobalRegisterTable::Impl {
current = it.value();
}

for (auto& key : current->children.keys()) rtn.emplace_back(key);
for (auto& key : current->children.keys()) rtn.push_back(key);
}
return rtn;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/module/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class Module::Impl {
void** pointer;
};

QList<Symbol> module_required_symbols_ = {
QContainer<Symbol> module_required_symbols_ = {
{"GFGetModuleGFSDKVersion", reinterpret_cast<void**>(&get_sdk_ver_api_)},
{"GFGetModuleQtEnvVersion", reinterpret_cast<void**>(&get_qt_ver_api_)},
{"GFGetModuleID", reinterpret_cast<void**>(&get_id_api_)},
Expand Down
11 changes: 5 additions & 6 deletions src/core/module/ModuleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class ModuleManager::Impl {
return gmc_->SearchModule(std::move(module_id));
}

auto ListAllRegisteredModuleID() -> QList<ModuleIdentifier> {
auto ListAllRegisteredModuleID() -> QStringList {
return gmc_->ListAllRegisteredModuleID();
}

Expand Down Expand Up @@ -176,8 +176,7 @@ class ModuleManager::Impl {
return gmc_->SearchEvent(std::move(trigger_id));
}

auto GetModuleListening(ModuleIdentifier module_id)
-> QList<EventIdentifier> {
auto GetModuleListening(ModuleIdentifier module_id) -> QStringList {
return gmc_->GetModuleListening(std::move(module_id));
}

Expand Down Expand Up @@ -246,7 +245,7 @@ class ModuleManager::Impl {
static ModuleMangerPtr global_module_manager;
SecureUniquePtr<GlobalModuleContext> gmc_;
SecureUniquePtr<GlobalRegisterTable> grt_;
QList<QLibrary> module_libraries_;
QContainer<QLibrary> module_libraries_;
int need_register_modules_ = -1;
};

Expand Down Expand Up @@ -300,7 +299,7 @@ void ModuleManager::ListenEvent(ModuleIdentifier module,
}

auto ModuleManager::GetModuleListening(ModuleIdentifier module_id)
-> QList<EventIdentifier> {
-> QStringList {
return p_->GetModuleListening(module_id);
}

Expand Down Expand Up @@ -353,7 +352,7 @@ auto ModuleManager::IsIntegratedModule(ModuleIdentifier id) -> bool {
return p_->IsIntegratedModule(id);
}

auto ModuleManager::ListAllRegisteredModuleID() -> QList<ModuleIdentifier> {
auto ModuleManager::ListAllRegisteredModuleID() -> QStringList {
return p_->ListAllRegisteredModuleID();
};

Expand Down
Loading

0 comments on commit 37d5b7e

Please sign in to comment.