diff --git a/client/Sample/tf_channels.c b/client/Sample/tf_channels.c index a6c187894..d1bfdb8bb 100644 --- a/client/Sample/tf_channels.c +++ b/client/Sample/tf_channels.c @@ -32,39 +32,6 @@ #include "tf_channels.h" #include "tf_freerdp.h" -/** - * Function description - * - * @return 0 on success, otherwise a Win32 error code - */ -static UINT -tf_encomsp_participant_created(EncomspClientContext* context, - const ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated) -{ - WINPR_UNUSED(context); - WINPR_UNUSED(participantCreated); - return CHANNEL_RC_OK; -} - -static void tf_encomsp_init(tfContext* tf, EncomspClientContext* encomsp) -{ - tf->encomsp = encomsp; - encomsp->custom = (void*)tf; - encomsp->ParticipantCreated = tf_encomsp_participant_created; -} - -static void tf_encomsp_uninit(tfContext* tf, EncomspClientContext* encomsp) -{ - if (encomsp) - { - encomsp->custom = NULL; - encomsp->ParticipantCreated = NULL; - } - - if (tf) - tf->encomsp = NULL; -} - static UINT tf_update_surfaces(RdpgfxClientContext* context) { WINPR_UNUSED(context); @@ -87,10 +54,6 @@ void tf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEven WINPR_ASSERT(clip); clip->custom = context; } - else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0) - { - tf_encomsp_init(tf, (EncomspClientContext*)e->pInterface); - } else freerdp_client_OnChannelConnectedEventHandler(context, e); } @@ -111,10 +74,6 @@ void tf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnect WINPR_ASSERT(clip); clip->custom = NULL; } - else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0) - { - tf_encomsp_uninit(tf, (EncomspClientContext*)e->pInterface); - } else freerdp_client_OnChannelDisconnectedEventHandler(context, e); } diff --git a/client/Sample/tf_freerdp.h b/client/Sample/tf_freerdp.h index e4bb94f65..c9b52951b 100644 --- a/client/Sample/tf_freerdp.h +++ b/client/Sample/tf_freerdp.h @@ -26,14 +26,12 @@ #include #include #include -#include typedef struct { rdpClientContext common; /* Channels */ - EncomspClientContext* encomsp; } tfContext; #endif /* FREERDP_CLIENT_SAMPLE_H */ diff --git a/client/Wayland/wlf_channels.c b/client/Wayland/wlf_channels.c index 63c254af3..3a11407e9 100644 --- a/client/Wayland/wlf_channels.c +++ b/client/Wayland/wlf_channels.c @@ -28,77 +28,6 @@ #include "wlf_disp.h" #include "wlfreerdp.h" -static BOOL encomsp_toggle_control(EncomspClientContext* encomsp, BOOL control) -{ - ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU pdu; - - if (!encomsp) - return FALSE; - - pdu.ParticipantId = 0; - pdu.Flags = ENCOMSP_REQUEST_VIEW; - - if (control) - pdu.Flags |= ENCOMSP_REQUEST_INTERACT; - - encomsp->ChangeParticipantControlLevel(encomsp, &pdu); - return TRUE; -} - -/** - * Function description - * - * @return 0 on success, otherwise a Win32 error code - */ -static UINT -wlf_encomsp_participant_created(EncomspClientContext* context, - const ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated) -{ - wlfContext* wlf; - rdpSettings* settings; - BOOL request; - - if (!context || !context->custom || !participantCreated) - return ERROR_INVALID_PARAMETER; - - wlf = (wlfContext*)context->custom; - WINPR_ASSERT(wlf); - - settings = wlf->common.context.settings; - - if (!settings) - return ERROR_INVALID_PARAMETER; - - request = freerdp_settings_get_bool(settings, FreeRDP_RemoteAssistanceRequestControl); - if (request && (participantCreated->Flags & ENCOMSP_MAY_VIEW) && - !(participantCreated->Flags & ENCOMSP_MAY_INTERACT)) - { - if (!encomsp_toggle_control(context, TRUE)) - return ERROR_INTERNAL_ERROR; - } - - return CHANNEL_RC_OK; -} - -static void wlf_encomsp_init(wlfContext* wlf, EncomspClientContext* encomsp) -{ - wlf->encomsp = encomsp; - encomsp->custom = (void*)wlf; - encomsp->ParticipantCreated = wlf_encomsp_participant_created; -} - -static void wlf_encomsp_uninit(wlfContext* wlf, EncomspClientContext* encomsp) -{ - if (encomsp) - { - encomsp->custom = NULL; - encomsp->ParticipantCreated = NULL; - } - - if (wlf) - wlf->encomsp = NULL; -} - void wlf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEventArgs* e) { wlfContext* wlf = (wlfContext*)context; @@ -116,10 +45,6 @@ void wlf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEve { wlf_cliprdr_init(wlf->clipboard, (CliprdrClientContext*)e->pInterface); } - else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0) - { - wlf_encomsp_init(wlf, (EncomspClientContext*)e->pInterface); - } else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0) { wlf_disp_init(wlf->disp, (DispClientContext*)e->pInterface); @@ -145,10 +70,6 @@ void wlf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnec { wlf_cliprdr_uninit(wlf->clipboard, (CliprdrClientContext*)e->pInterface); } - else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0) - { - wlf_encomsp_uninit(wlf, (EncomspClientContext*)e->pInterface); - } else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0) { wlf_disp_uninit(wlf->disp, (DispClientContext*)e->pInterface); diff --git a/client/Wayland/wlfreerdp.h b/client/Wayland/wlfreerdp.h index da91fe600..5573f13ab 100644 --- a/client/Wayland/wlfreerdp.h +++ b/client/Wayland/wlfreerdp.h @@ -20,7 +20,6 @@ #ifndef FREERDP_CLIENT_WAYLAND_FREERDP_H #define FREERDP_CLIENT_WAYLAND_FREERDP_H -#include #include #include #include @@ -55,7 +54,6 @@ typedef struct BOOL focusing; /* Channels */ - EncomspClientContext* encomsp; wfClipboard* clipboard; wlfDispContext* disp; wLog* log; diff --git a/client/Windows/wf_channels.c b/client/Windows/wf_channels.c index 31f5bb97e..69c99efef 100644 --- a/client/Windows/wf_channels.c +++ b/client/Windows/wf_channels.c @@ -31,70 +31,6 @@ #include #define TAG CLIENT_TAG("windows") -static BOOL encomsp_toggle_control(EncomspClientContext* encomsp, BOOL control) -{ - ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU pdu; - - if (!encomsp) - return FALSE; - - pdu.ParticipantId = 0; - pdu.Flags = ENCOMSP_REQUEST_VIEW; - - if (control) - pdu.Flags |= ENCOMSP_REQUEST_INTERACT; - - encomsp->ChangeParticipantControlLevel(encomsp, &pdu); - return TRUE; -} - -static UINT -wf_encomsp_participant_created(EncomspClientContext* context, - const ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated) -{ - wfContext* wf; - rdpSettings* settings; - BOOL request; - - if (!context || !context->custom || !participantCreated) - return ERROR_INVALID_PARAMETER; - - wf = (wfContext*)context->custom; - WINPR_ASSERT(wf); - - settings = wf->common.context.settings; - WINPR_ASSERT(settings); - - request = freerdp_settings_get_bool(settings, FreeRDP_RemoteAssistanceRequestControl); - if (request && (participantCreated->Flags & ENCOMSP_MAY_VIEW) && - !(participantCreated->Flags & ENCOMSP_MAY_INTERACT)) - { - if (!encomsp_toggle_control(context, TRUE)) - return ERROR_INTERNAL_ERROR; - } - - return CHANNEL_RC_OK; -} - -static void wf_encomsp_init(wfContext* wf, EncomspClientContext* encomsp) -{ - wf->encomsp = encomsp; - encomsp->custom = (void*)wf; - encomsp->ParticipantCreated = wf_encomsp_participant_created; -} - -static void wf_encomsp_uninit(wfContext* wf, EncomspClientContext* encomsp) -{ - if (encomsp) - { - encomsp->custom = NULL; - encomsp->ParticipantCreated = NULL; - } - - if (wf) - wf->encomsp = NULL; -} - void wf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEventArgs* e) { wfContext* wfc = (wfContext*)context; @@ -114,10 +50,6 @@ void wf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEven { wf_cliprdr_init(wfc, (CliprdrClientContext*)e->pInterface); } - else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0) - { - wf_encomsp_init(wfc, (EncomspClientContext*)e->pInterface); - } else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0) { wfc->disp = (DispClientContext*)e->pInterface; @@ -145,10 +77,6 @@ void wf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnect { wf_cliprdr_uninit(wfc, (CliprdrClientContext*)e->pInterface); } - else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0) - { - wf_encomsp_uninit(wfc, (EncomspClientContext*)e->pInterface); - } else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0) { wfc->disp = NULL; diff --git a/client/Windows/wf_client.h b/client/Windows/wf_client.h index f52642209..d78cb4426 100644 --- a/client/Windows/wf_client.h +++ b/client/Windows/wf_client.h @@ -130,8 +130,6 @@ extern "C" void* clipboard; CliprdrClientContext* cliprdr; - EncomspClientContext* encomsp; - wfFloatBar* floatbar; RailClientContext* rail; diff --git a/client/X11/xf_channels.c b/client/X11/xf_channels.c index 8c55add4d..0681a54e4 100644 --- a/client/X11/xf_channels.c +++ b/client/X11/xf_channels.c @@ -68,10 +68,6 @@ void xf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEven { xf_cliprdr_init(xfc, (CliprdrClientContext*)e->pInterface); } - else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0) - { - xf_encomsp_init(xfc, (EncomspClientContext*)e->pInterface); - } else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0) { xf_disp_init(xfc->xfDisp, (DispClientContext*)e->pInterface); @@ -124,10 +120,6 @@ void xf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnect { xf_cliprdr_uninit(xfc, (CliprdrClientContext*)e->pInterface); } - else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0) - { - xf_encomsp_uninit(xfc, (EncomspClientContext*)e->pInterface); - } else if (strcmp(e->name, VIDEO_CONTROL_DVC_CHANNEL_NAME) == 0) { if (settings->SoftwareGdi) diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index 725cd943f..8265c3580 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -822,71 +822,6 @@ void xf_toggle_fullscreen(xfContext* xfc) PubSub_OnWindowStateChange(context->pubSub, context, &e); } -BOOL xf_toggle_control(xfContext* xfc) -{ - EncomspClientContext* encomsp; - ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU pdu; - encomsp = xfc->encomsp; - - if (!encomsp) - return FALSE; - - pdu.ParticipantId = 0; - pdu.Flags = ENCOMSP_REQUEST_VIEW; - - if (!xfc->controlToggle) - pdu.Flags |= ENCOMSP_REQUEST_INTERACT; - - encomsp->ChangeParticipantControlLevel(encomsp, &pdu); - xfc->controlToggle = !xfc->controlToggle; - return TRUE; -} - -/** - * Function description - * - * @return 0 on success, otherwise a Win32 error code - */ -static UINT -xf_encomsp_participant_created(EncomspClientContext* context, - const ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated) -{ - xfContext* xfc; - rdpSettings* settings; - BOOL request; - - if (!context || !context->custom || !participantCreated) - return ERROR_INVALID_PARAMETER; - - xfc = context->custom; - WINPR_ASSERT(xfc); - - settings = xfc->common.context.settings; - - if (!settings) - return ERROR_INVALID_PARAMETER; - - request = freerdp_settings_get_bool(settings, FreeRDP_RemoteAssistanceRequestControl); - if (request && (participantCreated->Flags & ENCOMSP_MAY_VIEW) && - !(participantCreated->Flags & ENCOMSP_MAY_INTERACT)) - xf_toggle_control(xfc); - - return CHANNEL_RC_OK; -} - -void xf_encomsp_init(xfContext* xfc, EncomspClientContext* encomsp) -{ - xfc->encomsp = encomsp; - encomsp->custom = (void*)xfc; - encomsp->ParticipantCreated = xf_encomsp_participant_created; -} - -void xf_encomsp_uninit(xfContext* xfc, EncomspClientContext* encomsp) -{ - WINPR_UNUSED(encomsp); - xfc->encomsp = NULL; -} - void xf_lock_x11_(xfContext* xfc, const char* fkt) { diff --git a/client/X11/xf_keyboard.c b/client/X11/xf_keyboard.c index 6bed9b8af..96130fd8d 100644 --- a/client/X11/xf_keyboard.c +++ b/client/X11/xf_keyboard.c @@ -590,7 +590,7 @@ BOOL xf_keyboard_handle_special_keys(xfContext* xfc, KeySym keysym) if (mod.Ctrl && mod.Alt) { /* Ctrl-Alt-C: toggle control */ - if (xf_toggle_control(xfc)) + if (freerdp_client_encomsp_toggle_control(xfc->common.encomsp)) return TRUE; } } @@ -696,7 +696,7 @@ void xf_keyboard_handle_special_keys_release(xfContext* xfc, KeySym keysym) { if (!xfc->fullscreen) { - xf_toggle_control(xfc); + freerdp_client_encomsp_toggle_control(xfc->common.encomsp); } xfc->mouse_active = FALSE; diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h index 458622087..b40cf602a 100644 --- a/client/X11/xfreerdp.h +++ b/client/X11/xfreerdp.h @@ -203,7 +203,6 @@ struct xf_context BOOL focused; BOOL mouse_active; BOOL fullscreen_toggle; - BOOL controlToggle; UINT32 KeyboardLayout; BOOL KeyboardState[256]; XModifierKeymap* modifierMap; @@ -268,7 +267,6 @@ struct xf_context xfClipboard* clipboard; CliprdrClientContext* cliprdr; xfVideoContext* xfVideo; - EncomspClientContext* encomsp; xfDispContext* xfDisp; RailClientContext* rail; @@ -302,10 +300,6 @@ struct xf_context BOOL xf_create_window(xfContext* xfc); void xf_toggle_fullscreen(xfContext* xfc); -BOOL xf_toggle_control(xfContext* xfc); - -void xf_encomsp_init(xfContext* xfc, EncomspClientContext* encomsp); -void xf_encomsp_uninit(xfContext* xfc, EncomspClientContext* encomsp); enum XF_EXIT_CODE { diff --git a/client/common/client.c b/client/common/client.c index c69910078..cd3501f32 100644 --- a/client/common/client.c +++ b/client/common/client.c @@ -963,6 +963,87 @@ int freerdp_client_common_stop(rdpContext* context) return 0; } +BOOL freerdp_client_encomsp_toggle_control(EncomspClientContext* encomsp) +{ + rdpClientContext* cctx; + BOOL state; + + WINPR_ASSERT(encomsp); + cctx = (rdpClientContext*)encomsp->custom; + + state = cctx->controlToggle; + cctx->controlToggle = !cctx->controlToggle; + return freerdp_client_encomsp_set_control(encomsp, state); +} + +BOOL freerdp_client_encomsp_set_control(EncomspClientContext* encomsp, BOOL control) +{ +#if defined(CHANNEL_ENCOMSP_CLIENT) + ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU pdu = { 0 }; + + if (!encomsp) + return FALSE; + + pdu.ParticipantId = 0; + pdu.Flags = ENCOMSP_REQUEST_VIEW; + + if (control) + pdu.Flags |= ENCOMSP_REQUEST_INTERACT; + + encomsp->ChangeParticipantControlLevel(encomsp, &pdu); +#endif + return TRUE; +} + +#if defined(CHANNEL_ENCOMSP_CLIENT) +static UINT +client_encomsp_participant_created(EncomspClientContext* context, + const ENCOMSP_PARTICIPANT_CREATED_PDU* participantCreated) +{ + rdpClientContext* cctx; + rdpSettings* settings; + BOOL request; + + if (!context || !context->custom || !participantCreated) + return ERROR_INVALID_PARAMETER; + + cctx = (rdpClientContext*)context->custom; + WINPR_ASSERT(cctx); + + settings = cctx->context.settings; + WINPR_ASSERT(settings); + + request = freerdp_settings_get_bool(settings, FreeRDP_RemoteAssistanceRequestControl); + if (request && (participantCreated->Flags & ENCOMSP_MAY_VIEW) && + !(participantCreated->Flags & ENCOMSP_MAY_INTERACT)) + { + if (!freerdp_client_encomsp_set_control(context, TRUE)) + return ERROR_INTERNAL_ERROR; + } + + return CHANNEL_RC_OK; +} + +static void client_encomsp_init(rdpClientContext* cctx, EncomspClientContext* encomsp) +{ + cctx->encomsp = encomsp; + encomsp->custom = (void*)cctx; + encomsp->ParticipantCreated = client_encomsp_participant_created; +} + +static void client_encomsp_uninit(rdpClientContext* cctx, EncomspClientContext* encomsp) +{ + if (encomsp) + { + encomsp->custom = NULL; + encomsp->ParticipantCreated = NULL; + } + + if (cctx) + cctx->encomsp = NULL; +} +#endif + void freerdp_client_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEventArgs* e) { @@ -1006,6 +1087,12 @@ void freerdp_client_OnChannelConnectedEventHandler(void* context, gdi_video_data_init(cctx->context.gdi, (VideoClientContext*)e->pInterface); } #endif +#if defined(CHANNEL_ENCOMSP_CLIENT) + else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0) + { + client_encomsp_init(cctx, (EncomspClientContext*)e->pInterface); + } +#endif } void freerdp_client_OnChannelDisconnectedEventHandler(void* context, @@ -1051,6 +1138,12 @@ void freerdp_client_OnChannelDisconnectedEventHandler(void* context, gdi_video_data_uninit(cctx->context.gdi, (VideoClientContext*)e->pInterface); } #endif +#if defined(CHANNEL_ENCOMSP_CLIENT) + else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0) + { + client_encomsp_uninit(cctx, (EncomspClientContext*)e->pInterface); + } +#endif } BOOL freerdp_client_send_wheel_event(rdpClientContext* cctx, UINT16 mflags) diff --git a/include/freerdp/client.h b/include/freerdp/client.h index 2620d088b..75a4a52d3 100644 --- a/include/freerdp/client.h +++ b/include/freerdp/client.h @@ -33,6 +33,10 @@ #include #endif +#if defined(CHANNEL_ENCOMSP_CLIENT) +#include +#endif + #ifdef __cplusplus extern "C" { @@ -95,7 +99,14 @@ extern "C" ALIGN64 INT32 lastX; /**< (offset 3) */ ALIGN64 INT32 lastY; /**< (offset 4) */ ALIGN64 BOOL mouse_grabbed; /** < (offset 5) */ - UINT64 reserved[128 - 6]; /**< (offset 6) */ + +#if defined(CHANNEL_ENCOMSP_CLIENT) + ALIGN64 EncomspClientContext* encomsp; /** < (offset 6) */ + ALIGN64 BOOL controlToggle; /**< (offset 7) */ +#else + UINT64 reserved3[2]; +#endif + UINT64 reserved[128 - 8]; /**< (offset 8) */ }; /* Common client functions */ @@ -195,6 +206,10 @@ extern "C" FREERDP_API BOOL freerdp_client_load_channels(freerdp* instance); + FREERDP_API BOOL freerdp_client_encomsp_toggle_control(EncomspClientContext* encomsp); + FREERDP_API BOOL freerdp_client_encomsp_set_control(EncomspClientContext* encomsp, + BOOL control); + #ifdef __cplusplus } #endif