From 5702b323c988aa2a390b0481f5bf029ac20a18e3 Mon Sep 17 00:00:00 2001 From: LAGonauta Date: Sun, 25 Oct 2020 12:52:49 -0300 Subject: [PATCH] Use dynamic linking instead of runtime loading Also made me notice that the signature of the function with the callback was wrong. Oops. --- plugins/windows-notification/CMakeLists.txt | 13 +++- .../src/DinoWinToastLib.h | 27 ++++++++ .../src/DinoWinToastLib.lib | Bin 0 -> 2196 bytes plugins/windows-notification/src/plugin.vala | 2 +- .../windows-notification/src/wintoast.vala | 63 +++--------------- 5 files changed, 48 insertions(+), 57 deletions(-) create mode 100644 plugins/windows-notification/src/DinoWinToastLib.h create mode 100644 plugins/windows-notification/src/DinoWinToastLib.lib diff --git a/plugins/windows-notification/CMakeLists.txt b/plugins/windows-notification/CMakeLists.txt index 3be2a506..ee2115c1 100644 --- a/plugins/windows-notification/CMakeLists.txt +++ b/plugins/windows-notification/CMakeLists.txt @@ -20,9 +20,18 @@ PACKAGES ${WINDOWS_NOTIFICATION_PACKAGES} ) +add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/exports/DinoWinToastLib.h" +COMMAND + cp "${CMAKE_CURRENT_SOURCE_DIR}/src/DinoWinToastLib.h" "${CMAKE_BINARY_DIR}/exports/DinoWinToastLib.h" +DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/src/DinoWinToastLib.h" +COMMENT + Copy header file DinoWinToastLib.h +) + add_definitions(${VALA_CFLAGS}) -add_library(windows-notification SHARED ${WINDOWS_NOTIFICATION_VALA_C} src/wintoast.c) -target_link_libraries(windows-notification libdino ${WINDOWS_NOTIFICATION_PACKAGES}) +add_library(windows-notification SHARED ${WINDOWS_NOTIFICATION_VALA_C} ${CMAKE_BINARY_DIR}/exports/DinoWinToastLib.h) +target_link_libraries(windows-notification libdino ${WINDOWS_NOTIFICATION_PACKAGES} "${CMAKE_CURRENT_SOURCE_DIR}/src/DinoWinToastLib.lib") set_target_properties(windows-notification PROPERTIES PREFIX "") set_target_properties(windows-notification PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins/) diff --git a/plugins/windows-notification/src/DinoWinToastLib.h b/plugins/windows-notification/src/DinoWinToastLib.h new file mode 100644 index 00000000..b0fe9ace --- /dev/null +++ b/plugins/windows-notification/src/DinoWinToastLib.h @@ -0,0 +1,27 @@ +#pragma once + +#ifdef _WIN32 +#ifdef DINOWINTOASTLIB_EXPORTS +#define DINOWINTOASTLIB_API __declspec(dllexport) +#else +#define DINOWINTOASTLIB_API __declspec(dllimport) +#endif +#else +#define DINOWINTOASTLIB_API +#endif + +#ifdef __cplusplus +extern "C" { +#endif + int DINOWINTOASTLIB_API dinoWinToastLibInit(); +#ifdef __cplusplus +} // extern "C" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + int DINOWINTOASTLIB_API dinoWinToastLibShowMessage(const char* sender, const char* message, const char* imagePath, int conv_id, void(*click_callback)(int conv_id, void* callback_target), void* callback_target); +#ifdef __cplusplus +} // extern "C" +#endif \ No newline at end of file diff --git a/plugins/windows-notification/src/DinoWinToastLib.lib b/plugins/windows-notification/src/DinoWinToastLib.lib new file mode 100644 index 0000000000000000000000000000000000000000..bca01f66b55aa1414463d08817c5bd87ebd9c66d GIT binary patch literal 2196 zcmcIlOKTHR6#nvPQwNb?yU`*>sI-D6aq`fG$V5|UXp)vB#pN`~#Acw)v`s{Ccv2MN3)tb%nRt+Pj zT-RnAW@~Vft(zF5co(B70_o5TocjTF8km~_+JqW?@W6{H`0eVW{agX9;Tv+D83B_U z3ccoI&m}Sd*H}hLYK1nHfin*q+uMkA<{jdV`(Hv$bQo$J_;CNr^3Qn>@sbed5;kg; zcUucZM*=c5_$&p{YY4syn?|`+ULaOGg{X}as=tNoqh3SwSlA_n8f+IJf6|Wi8bZfJ z0^G$77BTCx(M8M#nH4{53*Z*!akO_kXIA&EruDWJS}HsWWi$CzG2hqSB#8s!O6h2i zg48nod~opwt!nM;QtU^29?!)^?@C%i#N;X=&;UF9y42X4b^HmNINQ)7bZin`4eOV< z5rzK_q=dws7Zqx+lmcUksZ7cwHSxTMNnU)YB>#T5gXNIjnPfOqowkQbF{xyRe3gRe znMv2mkjtF+Jql*%g*+*Gv1s=eMovQXpfAIw{i0&JD?LGAFZfa3}uw%t<-F>zn3wB~0x1nMe=1xuxGv Ujc;cW+N6grA!GR4?B-ti2hpIz