From 0a11b572c0a21f69909eee94d4b8cc552c13c8ca Mon Sep 17 00:00:00 2001 From: Saturneric Date: Thu, 17 Jun 2021 22:16:18 +0800 Subject: [PATCH] Make it possible to compile and run on Windows. --- CMakeLists.txt | 2 ++ src/gpg/CMakeLists.txt | 13 ++++++++++--- src/gpg/GpgContext.cpp | 16 ++++++++++------ 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a62d6a0f..1e12853e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,8 @@ IF (MINGW) message("OS Platform Microsoft Windows") message("Envrinoment MINGW") + + set(CMAKE_EXE_LINKER_FLAGS "-static") include_directories( include diff --git a/src/gpg/CMakeLists.txt b/src/gpg/CMakeLists.txt index 3359f662..3213c457 100644 --- a/src/gpg/CMakeLists.txt +++ b/src/gpg/CMakeLists.txt @@ -7,6 +7,13 @@ set(UTILS_DIR ${CMAKE_SOURCE_DIR}/utils) set(GPGME_LIB_DIR ${UTILS_DIR}/gpgme/lib) -target_link_libraries(gpg - gpgme gpg-error assuan - Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core) +IF (MINGW) + target_link_libraries(gpg + gpgme gpg-error assuan + Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core + wsock32) +else() + target_link_libraries(gpg + gpgme gpg-error assuan + Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core) +endif() \ No newline at end of file diff --git a/src/gpg/GpgContext.cpp b/src/gpg/GpgContext.cpp index 4366d967..d0cf30d5 100644 --- a/src/gpg/GpgContext.cpp +++ b/src/gpg/GpgContext.cpp @@ -29,7 +29,9 @@ #include #ifdef _WIN32 + #include + #endif namespace GpgME { @@ -69,7 +71,8 @@ namespace GpgME { engineInfo = gpgme_ctx_get_engine_info(mCtx); while (engineInfo != nullptr) { - qDebug() << gpgme_get_protocol_name(engineInfo->protocol); + qDebug() << gpgme_get_protocol_name(engineInfo->protocol) << engineInfo->file_name << engineInfo->protocol + << engineInfo->home_dir << engineInfo->version; engineInfo = engineInfo->next; } @@ -418,8 +421,9 @@ namespace GpgME { bool show_ma_dock = false; Mime *mime = new Mime(message); - for(MimePart tmp : mime->parts()) { - if (tmp.header.getValue("Content-Type") == "text/plain" && tmp.header.getValue("Content-Transfer-Encoding") != "base64") { + for (MimePart tmp : mime->parts()) { + if (tmp.header.getValue("Content-Type") == "text/plain" && + tmp.header.getValue("Content-Transfer-Encoding") != "base64") { QByteArray body; if (tmp.header.getValue("Content-Transfer-Encoding") == "quoted-printable") { Mime::quotedPrintableDecode(tmp.body, body); @@ -549,7 +553,7 @@ namespace GpgME { #ifdef _WIN32 DWORD written; - HANDLE hd = (HANDLE)fd; + HANDLE hd = (HANDLE) fd; #endif if (last_was_bad) { @@ -595,8 +599,8 @@ namespace GpgME { WriteFile(hd, "\n", 1, &written, 0); /* program will hang on cancel if hd not closed */ - if(!result) { - CloseHandle(hd); + if (!result) { + CloseHandle(hd); } #endif