From e49340e8676879d23b2f85f142571e0a70678706 Mon Sep 17 00:00:00 2001 From: Vitaly Zaitsev Date: Mon, 24 Jun 2019 16:27:15 +0200 Subject: [PATCH] Allow to forward custom API tokens for Kepka. You can obtain your tokens from https://core.telegram.org/api/obtaining_api_id. Export API_ID and API_TOKEN environment options with your tokens before running Cmake to use them. Signed-off-by: Vitaly Zaitsev --- Telegram/CMakeLists.txt | 12 ++++++++++++ Telegram/SourceFiles/config.h.in | 8 ++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index b22c56968..93553758e 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -7,6 +7,18 @@ if (LINUX) endif() endif() +##================================================ +## API tokens +##================================================ +if (DEFINED ENV{API_ID} AND DEFINED ENV{API_HASH}) + set(API_ID ENV{API_ID}) + set(API_HASH ENV{API_HASH}) +else() + message(WARNING "No custom API tokens detected. You must grab your own tokens from https://core.telegram.org/api/obtaining_api_id and export them using environment options. Will use default for testing purposes.") + set(API_ID 17349) + set(API_HASH "344583e45741c457fe1862106095a5eb") +endif() + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -H") set(CMAKE_INCLUDE_CURRENT_DIR ON) ##================================================ diff --git a/Telegram/SourceFiles/config.h.in b/Telegram/SourceFiles/config.h.in index d46fadc11..46fefa3d7 100644 --- a/Telegram/SourceFiles/config.h.in +++ b/Telegram/SourceFiles/config.h.in @@ -206,12 +206,8 @@ w/CVnbwQOw0g5GBwwFV3r0uTTvy44xx8XXxk+Qknu4eBCsmrAFNnAgMBAAE=\n\ -----END RSA PUBLIC KEY-----\ "; -#ifdef CUSTOM_API_ID -#include "../../../TelegramPrivate/custom_api_id.h" // Custom API id and API hash -#else -static const qint32 ApiId = 17349; -static const char *ApiHash = "344583e45741c457fe1862106095a5eb"; -#endif +constexpr auto ApiId = @API_ID@; +constexpr auto ApiHash = "@API_HASH@"; #if Q_BYTE_ORDER == Q_BIG_ENDIAN #warning "Big endian support in Kepka is experimental. Proceed with caution!"