From eee5085e9b903f92293045f64c2464b48a18c2f1 Mon Sep 17 00:00:00 2001 From: Nicolas Adamoglou Date: Fri, 2 Feb 2018 01:42:17 +0100 Subject: [PATCH] Exported Discord_Register and Discord_RegisterSteam (#109) * Update CMakeLists.txt * Update and rename src/discord_register.h to include/discord_register.h * Update CMakeLists.txt * Update discord_register_win.cpp * Update discord_register_linux.cpp --- include/discord_register.h | 26 ++++++++++++++++++++++++++ src/CMakeLists.txt | 3 ++- src/discord_register.h | 12 ------------ src/discord_register_linux.cpp | 4 ++-- src/discord_register_win.cpp | 4 ++-- 5 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 include/discord_register.h delete mode 100644 src/discord_register.h diff --git a/include/discord_register.h b/include/discord_register.h new file mode 100644 index 0000000..4c16b68 --- /dev/null +++ b/include/discord_register.h @@ -0,0 +1,26 @@ +#pragma once + +#if defined(DISCORD_DYNAMIC_LIB) +# if defined(_WIN32) +# if defined(DISCORD_BUILDING_SDK) +# define DISCORD_EXPORT __declspec(dllexport) +# else +# define DISCORD_EXPORT __declspec(dllimport) +# endif +# else +# define DISCORD_EXPORT __attribute__((visibility("default"))) +# endif +#else +# define DISCORD_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +DISCORD_EXPORT void Discord_Register(const char* applicationId, const char* command); +DISCORD_EXPORT void Discord_RegisterSteamGame(const char* applicationId, const char* steamId); + +#ifdef __cplusplus +} +#endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c3dab48..c83b394 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_CXX_STANDARD 14) set(BASE_RPC_SRC ${PROJECT_SOURCE_DIR}/include/discord-rpc.h discord-rpc.cpp - discord_register.h + ${PROJECT_SOURCE_DIR}/include/discord_register.h rpc_connection.h rpc_connection.cpp serialization.h @@ -130,5 +130,6 @@ install( install( FILES "../include/discord-rpc.h" + "../include/discord_register.h" DESTINATION "include" ) diff --git a/src/discord_register.h b/src/discord_register.h deleted file mode 100644 index 4eb3c3c..0000000 --- a/src/discord_register.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -void Discord_Register(const char* applicationId, const char* command); -void Discord_RegisterSteamGame(const char* applicationId, const char* steamId); - -#ifdef __cplusplus -} -#endif diff --git a/src/discord_register_linux.cpp b/src/discord_register_linux.cpp index a696ac2..68b85c3 100644 --- a/src/discord_register_linux.cpp +++ b/src/discord_register_linux.cpp @@ -21,7 +21,7 @@ bool Mkdir(const char* path) } // we want to register games so we can run them from Discord client as discord-:// -extern "C" void Discord_Register(const char* applicationId, const char* command) +extern "C" DISCORD_EXPORT void Discord_Register(const char* applicationId, const char* command) { // Add a desktop file and update some mime handlers so that xdg-open does the right thing. @@ -90,7 +90,7 @@ extern "C" void Discord_Register(const char* applicationId, const char* command) } } -extern "C" void Discord_RegisterSteamGame(const char* applicationId, const char* steamId) +extern "C" DISCORD_EXPORT void Discord_RegisterSteamGame(const char* applicationId, const char* steamId) { char command[256]; sprintf(command, "xdg-open steam://rungameid/%s", steamId); diff --git a/src/discord_register_win.cpp b/src/discord_register_win.cpp index 4e1a458..89406ba 100644 --- a/src/discord_register_win.cpp +++ b/src/discord_register_win.cpp @@ -115,7 +115,7 @@ void Discord_RegisterW(const wchar_t* applicationId, const wchar_t* command) RegCloseKey(key); } -extern "C" void Discord_Register(const char* applicationId, const char* command) +extern "C" DISCORD_EXPORT void Discord_Register(const char* applicationId, const char* command) { wchar_t appId[32]; MultiByteToWideChar(CP_UTF8, 0, applicationId, -1, appId, 32); @@ -131,7 +131,7 @@ extern "C" void Discord_Register(const char* applicationId, const char* command) Discord_RegisterW(appId, wcommand); } -extern "C" void Discord_RegisterSteamGame(const char* applicationId, const char* steamId) +extern "C" DISCORD_EXPORT void Discord_RegisterSteamGame(const char* applicationId, const char* steamId) { wchar_t appId[32]; MultiByteToWideChar(CP_UTF8, 0, applicationId, -1, appId, 32);