From 5d97a03bf41ee808b43cf7a350c804abe0937af9 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 14 Feb 2023 19:44:18 +0100 Subject: [PATCH] [client] auto intialize callbacks initialize all message/user query callbacks with client_cli_* --- client/Sample/tf_freerdp.c | 3 --- client/Wayland/wlfreerdp.c | 5 ----- client/Windows/wf_client.c | 8 +------- client/X11/xf_client.c | 5 ----- client/common/client.c | 24 +++++++++++++++++++++++- include/freerdp/client.h | 2 ++ 6 files changed, 26 insertions(+), 21 deletions(-) diff --git a/client/Sample/tf_freerdp.c b/client/Sample/tf_freerdp.c index 191fea8d0..d81904d01 100644 --- a/client/Sample/tf_freerdp.c +++ b/client/Sample/tf_freerdp.c @@ -323,9 +323,6 @@ static BOOL tf_client_new(freerdp* instance, rdpContext* context) instance->PreConnect = tf_pre_connect; instance->PostConnect = tf_post_connect; instance->PostDisconnect = tf_post_disconnect; - instance->AuthenticateEx = client_cli_authenticate_ex; - instance->VerifyCertificateEx = client_cli_verify_certificate_ex; - instance->VerifyChangedCertificateEx = client_cli_verify_changed_certificate_ex; instance->LogonErrorInfo = tf_logon_error_info; /* TODO: Client display set up */ WINPR_UNUSED(tf); diff --git a/client/Wayland/wlfreerdp.c b/client/Wayland/wlfreerdp.c index 8c4b3f92c..d679f4c26 100644 --- a/client/Wayland/wlfreerdp.c +++ b/client/Wayland/wlfreerdp.c @@ -622,11 +622,6 @@ static BOOL wlf_client_new(freerdp* instance, rdpContext* context) instance->PreConnect = wl_pre_connect; instance->PostConnect = wl_post_connect; instance->PostDisconnect = wl_post_disconnect; - instance->AuthenticateEx = client_cli_authenticate_ex; - instance->ChooseSmartcard = client_cli_choose_smartcard; - instance->VerifyCertificateEx = client_cli_verify_certificate_ex; - instance->VerifyChangedCertificateEx = client_cli_verify_changed_certificate_ex; - instance->PresentGatewayMessage = client_cli_present_gateway_message; instance->LogonErrorInfo = wlf_logon_error_info; wfl->log = WLog_Get(TAG); wfl->display = UwacOpenDisplay(NULL, &status); diff --git a/client/Windows/wf_client.c b/client/Windows/wf_client.c index 038472eb5..b7587569a 100644 --- a/client/Windows/wf_client.c +++ b/client/Windows/wf_client.c @@ -1312,13 +1312,7 @@ static BOOL wfreerdp_client_new(freerdp* instance, rdpContext* context) freerdp_settings_set_bool(context->settings, FreeRDP_CertificateCallbackPreferPEM, TRUE); #endif - if (wfc->isConsole) - { - instance->VerifyCertificateEx = wf_cli_verify_certificate_ex; - instance->VerifyChangedCertificateEx = client_cli_verify_changed_certificate_ex; - instance->PresentGatewayMessage = client_cli_present_gateway_message; - } - else + if (!wfc->isConsole) { instance->VerifyCertificateEx = wf_verify_certificate_ex; instance->VerifyChangedCertificateEx = wf_verify_changed_certificate_ex; diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index d9e283445..1375e3fff 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -1875,11 +1875,6 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context) instance->PostConnect = xf_post_connect; instance->PostDisconnect = xf_post_disconnect; instance->PostFinalDisconnect = xf_post_final_disconnect; - instance->AuthenticateEx = client_cli_authenticate_ex; - instance->ChooseSmartcard = client_cli_choose_smartcard; - instance->VerifyCertificateEx = client_cli_verify_certificate_ex; - instance->VerifyChangedCertificateEx = client_cli_verify_changed_certificate_ex; - instance->PresentGatewayMessage = client_cli_present_gateway_message; instance->LogonErrorInfo = xf_logon_error_info; PubSub_SubscribeTerminate(context->pubSub, xf_TerminateEventHandler); #ifdef WITH_XRENDER diff --git a/client/common/client.c b/client/common/client.c index a19205ec3..9f40b226d 100644 --- a/client/common/client.c +++ b/client/common/client.c @@ -71,7 +71,17 @@ static BOOL freerdp_client_common_new(freerdp* instance, rdpContext* context) pEntryPoints = instance->pClientEntryPoints; WINPR_ASSERT(pEntryPoints); - return IFCALLRESULT(TRUE, pEntryPoints->ClientNew, instance, context); + const BOOL rc = IFCALLRESULT(TRUE, pEntryPoints->ClientNew, instance, context); + if (rc) + { + instance->AuthenticateEx = client_cli_authenticate_ex; + instance->ChooseSmartcard = client_cli_choose_smartcard; + instance->VerifyCertificateEx = client_cli_verify_certificate_ex; + instance->VerifyChangedCertificateEx = client_cli_verify_changed_certificate_ex; + instance->PresentGatewayMessage = client_cli_present_gateway_message; + instance->LogonErrorInfo = client_cli_logon_error_info; + } + return rc; } static void freerdp_client_common_free(freerdp* instance, rdpContext* context) @@ -1558,3 +1568,15 @@ BOOL freerdp_client_load_channels(freerdp* instance) } return TRUE; } + +int client_cli_logon_error_info(freerdp* instance, UINT32 data, UINT32 type) +{ + const char* str_data = freerdp_get_logon_error_info_data(data); + const char* str_type = freerdp_get_logon_error_info_type(type); + + if (!instance || !instance->context) + return -1; + + WLog_INFO(TAG, "Logon Error Info %s [%s]", str_data, str_type); + return 1; +} diff --git a/include/freerdp/client.h b/include/freerdp/client.h index 36005be7b..bfe6c054a 100644 --- a/include/freerdp/client.h +++ b/include/freerdp/client.h @@ -153,6 +153,8 @@ extern "C" FREERDP_API BOOL client_cli_choose_smartcard(SmartcardCertInfo** cert_list, DWORD count, DWORD* choice, BOOL gateway); + FREERDP_API int client_cli_logon_error_info(freerdp* instance, UINT32 data, UINT32 type); + FREERDP_API void freerdp_client_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEventArgs* e);