1
0

Make it possible to compile and run on Windows.

This commit is contained in:
Saturneric 2021-06-17 22:16:18 +08:00
parent 58927593ce
commit 0a11b572c0
3 changed files with 22 additions and 9 deletions

View File

@ -23,6 +23,8 @@ IF (MINGW)
message("OS Platform Microsoft Windows") message("OS Platform Microsoft Windows")
message("Envrinoment MINGW") message("Envrinoment MINGW")
set(CMAKE_EXE_LINKER_FLAGS "-static")
include_directories( include_directories(
include include
/mingw64/include /mingw64/include

View File

@ -7,6 +7,13 @@ set(UTILS_DIR ${CMAKE_SOURCE_DIR}/utils)
set(GPGME_LIB_DIR ${UTILS_DIR}/gpgme/lib) set(GPGME_LIB_DIR ${UTILS_DIR}/gpgme/lib)
target_link_libraries(gpg IF (MINGW)
gpgme gpg-error assuan target_link_libraries(gpg
Qt5::Network Qt5::PrintSupport Qt5::Widgets Qt5::Test Qt5::Core) 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()

View File

@ -29,7 +29,9 @@
#include <Mime.h> #include <Mime.h>
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#endif #endif
namespace GpgME { namespace GpgME {
@ -69,7 +71,8 @@ namespace GpgME {
engineInfo = gpgme_ctx_get_engine_info(mCtx); engineInfo = gpgme_ctx_get_engine_info(mCtx);
while (engineInfo != nullptr) { 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; engineInfo = engineInfo->next;
} }
@ -418,8 +421,9 @@ namespace GpgME {
bool show_ma_dock = false; bool show_ma_dock = false;
Mime *mime = new Mime(message); Mime *mime = new Mime(message);
for(MimePart tmp : mime->parts()) { for (MimePart tmp : mime->parts()) {
if (tmp.header.getValue("Content-Type") == "text/plain" && tmp.header.getValue("Content-Transfer-Encoding") != "base64") { if (tmp.header.getValue("Content-Type") == "text/plain" &&
tmp.header.getValue("Content-Transfer-Encoding") != "base64") {
QByteArray body; QByteArray body;
if (tmp.header.getValue("Content-Transfer-Encoding") == "quoted-printable") { if (tmp.header.getValue("Content-Transfer-Encoding") == "quoted-printable") {
Mime::quotedPrintableDecode(tmp.body, body); Mime::quotedPrintableDecode(tmp.body, body);
@ -549,7 +553,7 @@ namespace GpgME {
#ifdef _WIN32 #ifdef _WIN32
DWORD written; DWORD written;
HANDLE hd = (HANDLE)fd; HANDLE hd = (HANDLE) fd;
#endif #endif
if (last_was_bad) { if (last_was_bad) {
@ -595,8 +599,8 @@ namespace GpgME {
WriteFile(hd, "\n", 1, &written, 0); WriteFile(hd, "\n", 1, &written, 0);
/* program will hang on cancel if hd not closed */ /* program will hang on cancel if hd not closed */
if(!result) { if (!result) {
CloseHandle(hd); CloseHandle(hd);
} }
#endif #endif