From 15dabd5a142b868806cfb66fdac7ecb2fc9c2c13 Mon Sep 17 00:00:00 2001 From: Fela Ameghino Date: Thu, 6 Jul 2017 17:33:47 +0200 Subject: [PATCH] SetProxy on RT too, other small fixes --- logging.h | 8 ++++---- os/windows/CXWrapper.cpp | 16 ++++++++++++++-- os/windows/CXWrapper.h | 6 ++++++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/logging.h b/logging.h index b777756..cbe811b 100644 --- a/logging.h +++ b/logging.h @@ -16,10 +16,6 @@ void tgvoip_log_file_printf(char level, const char* msg, ...); void tgvoip_log_file_write_header(); -#if !defined(snprintf) && defined(_WIN32) && defined(__cplusplus_winrt) -#define snprintf _snprintf -#endif - #if defined(__ANDROID__) #include @@ -48,6 +44,10 @@ void tgvoip_log_file_write_header(); #include #include +#if !defined(snprintf) && defined(_WIN32) && defined(__cplusplus_winrt) +#define snprintf _snprintf +#endif + #define _TGVOIP_W32_LOG_PRINT(verb, msg, ...){ char __log_buf[1024]; snprintf(__log_buf, 1024, "%c/tgvoip: " msg "\n", verb, ##__VA_ARGS__); OutputDebugStringA(__log_buf); tgvoip_log_file_printf((char)verb, msg, __VA_ARGS__);} #define LOGV(msg, ...) _TGVOIP_W32_LOG_PRINT('V', msg, ##__VA_ARGS__) diff --git a/os/windows/CXWrapper.cpp b/os/windows/CXWrapper.cpp index 424623b..5f71f3b 100644 --- a/os/windows/CXWrapper.cpp +++ b/os/windows/CXWrapper.cpp @@ -149,15 +149,27 @@ void VoIPControllerWrapper::SetConfig(double initTimeout, double recvTimeout, Da config.enableAEC=enableAEC; config.enableAGC=enableAGC; config.enableNS=enableNS; - if(logFilePath!=nullptr){ + if(logFilePath!=nullptr&&!logFilePath->IsEmpty()){ WideCharToMultiByte(CP_UTF8, 0, logFilePath->Data(), -1, config.logFilePath, sizeof(config.logFilePath), NULL, NULL); } - if(statsDumpFilePath!=nullptr){ + if(statsDumpFilePath!=nullptr&&!statsDumpFilePath->IsEmpty()){ WideCharToMultiByte(CP_UTF8, 0, statsDumpFilePath->Data(), -1, config.statsDumpFilePath, sizeof(config.statsDumpFilePath), NULL, NULL); } controller->SetConfig(&config); } +void VoIPControllerWrapper::SetProxy(ProxyProtocol protocol, Platform::String^ address, uint16_t port, Platform::String^ username, Platform::String^ password){ + char _address[2000]; + char _username[256]; + char _password[256]; + + WideCharToMultiByte(CP_UTF8, 0, address->Data(), -1, _address, sizeof(_address), NULL, NULL); + WideCharToMultiByte(CP_UTF8, 0, username->Data(), -1, _username, sizeof(_username), NULL, NULL); + WideCharToMultiByte(CP_UTF8, 0, password->Data(), -1, _password, sizeof(_password), NULL, NULL); + + controller->SetProxy((int)protocol, _address, port, _username, _password); +} + void VoIPControllerWrapper::UpdateServerConfig(Platform::String^ json){ JsonObject^ jconfig=JsonValue::Parse(json)->GetObject(); std::map config; diff --git a/os/windows/CXWrapper.h b/os/windows/CXWrapper.h index 4d36c8a..d00d5fb 100644 --- a/os/windows/CXWrapper.h +++ b/os/windows/CXWrapper.h @@ -53,6 +53,11 @@ namespace libtgvoip{ Always }; + public enum class ProxyProtocol{ + None=0, + SOCKS5 + }; + public interface class IStateCallback{ void OnCallStateChanged(CallState newState); }; @@ -69,6 +74,7 @@ namespace libtgvoip{ void SetMicMute(bool mute); void SetEncryptionKey(const Platform::Array^ key, bool isOutgoing); void SetConfig(double initTimeout, double recvTimeout, DataSavingMode dataSavingMode, bool enableAEC, bool enableNS, bool enableAGC, Platform::String^ logFilePath, Platform::String^ statsDumpFilePath); + void SetProxy(ProxyProtocol protocol, Platform::String^ address, uint16_t port, Platform::String^ username, Platform::String^ password); Platform::String^ GetDebugString(); Platform::String^ GetDebugLog(); Error GetLastError();