From b2b70fcf6dd3084e0e3ba9deca9b23deaffcbe69 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Wed, 19 Jan 2022 11:05:55 +0100 Subject: [PATCH] Use common client channel handling --- client/Android/android_freerdp.c | 38 +++++------------------- client/Mac/MRDPView.m | 26 ++++------------- client/Sample/tf_channels.c | 25 ++++------------ client/Sample/tf_freerdp.h | 2 -- client/Wayland/wlf_channels.c | 42 ++++----------------------- client/Wayland/wlf_input.c | 6 ++-- client/Wayland/wlfreerdp.h | 2 -- client/Windows/wf_channels.c | 50 ++++---------------------------- client/Windows/wf_client.c | 1 - client/X11/xf_channels.c | 26 ++++------------- client/X11/xf_input.c | 2 +- client/X11/xfreerdp.h | 1 - 12 files changed, 42 insertions(+), 179 deletions(-) diff --git a/client/Android/android_freerdp.c b/client/Android/android_freerdp.c index ed8812d00..9fb180bb2 100644 --- a/client/Android/android_freerdp.c +++ b/client/Android/android_freerdp.c @@ -73,23 +73,12 @@ static void android_OnChannelConnectedEventHandler(void* context, afc = (androidContext*)context; settings = afc->common.context.settings; - if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0) - { - if (settings->SoftwareGdi) - { - gdi_graphics_pipeline_init(afc->common.context.gdi, - (RdpgfxClientContext*)e->pInterface); - } - else - { - WLog_WARN(TAG, "GFX without software GDI requested. " - " This is not supported, add /gdi:sw"); - } - } - else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0) + if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0) { android_cliprdr_init(afc, (CliprdrClientContext*)e->pInterface); - } + } + else + freerdp_client_OnChannelConnectedEventHandler(context, e); } static void android_OnChannelDisconnectedEventHandler(void* context, @@ -107,23 +96,12 @@ static void android_OnChannelDisconnectedEventHandler(void* context, afc = (androidContext*)context; settings = afc->common.context.settings; - if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0) - { - if (settings->SoftwareGdi) - { - gdi_graphics_pipeline_uninit(afc->common.context.gdi, - (RdpgfxClientContext*)e->pInterface); - } - else - { - WLog_WARN(TAG, "GFX without software GDI requested. " - " This is not supported, add /gdi:sw"); - } - } - else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0) + if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0) { android_cliprdr_uninit(afc, (CliprdrClientContext*)e->pInterface); - } + } + else + freerdp_client_OnChannelDisconnectedEventHandler(context, e); } static BOOL android_begin_paint(rdpContext* context) diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index 87fab0318..d0e673867 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -826,22 +826,15 @@ static void mac_OnChannelConnectedEventHandler(void *context, const ChannelConne settings = mfc->common.context.settings; WINPR_ASSERT(settings); - if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0) - { - } - else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0) - { - if (settings->SoftwareGdi) - gdi_graphics_pipeline_init(mfc->common.context.gdi, - (RdpgfxClientContext *)e->pInterface); - } - else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0) + if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0) { mac_cliprdr_init(mfc, (CliprdrClientContext *)e->pInterface); } else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0) { } + else + freerdp_client_OnChannelConnectedEventHandler(context, e); } static void mac_OnChannelDisconnectedEventHandler(void *context, @@ -856,22 +849,15 @@ static void mac_OnChannelDisconnectedEventHandler(void *context, settings = mfc->common.context.settings; WINPR_ASSERT(settings); - if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0) - { - } - else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0) - { - if (settings->SoftwareGdi) - gdi_graphics_pipeline_uninit(mfc->common.context.gdi, - (RdpgfxClientContext *)e->pInterface); - } - else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0) + if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0) { mac_cliprdr_uninit(mfc, (CliprdrClientContext *)e->pInterface); } else if (strcmp(e->name, ENCOMSP_SVC_CHANNEL_NAME) == 0) { } + else + freerdp_client_OnChannelDisconnectedEventHandler(context, e); } BOOL mac_pre_connect(freerdp *instance) diff --git a/client/Sample/tf_channels.c b/client/Sample/tf_channels.c index ea9e691cd..f53798b2e 100644 --- a/client/Sample/tf_channels.c +++ b/client/Sample/tf_channels.c @@ -80,16 +80,7 @@ void tf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEven WINPR_ASSERT(tf); WINPR_ASSERT(e); - if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0) - { - tf->rdpei = (RdpeiClientContext*)e->pInterface; - } - else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0) - { - RdpgfxClientContext* gfx = (RdpgfxClientContext*)e->pInterface; - gdi_graphics_pipeline_init(tf->common.context.gdi, gfx); - } - else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0) + if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0) { } else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0) @@ -102,6 +93,8 @@ void tf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEven { tf_encomsp_init(tf, (EncomspClientContext*)e->pInterface); } + else + freerdp_client_OnChannelConnectedEventHandler(context, e); } void tf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnectedEventArgs* e) @@ -111,15 +104,7 @@ void tf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnect WINPR_ASSERT(tf); WINPR_ASSERT(e); - if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0) - { - tf->rdpei = NULL; - } - else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0) - { - gdi_graphics_pipeline_uninit(tf->common.context.gdi, (RdpgfxClientContext*)e->pInterface); - } - else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0) + if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0) { } else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0) @@ -132,4 +117,6 @@ void tf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnect { 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 41c79299f..e4bb94f65 100644 --- a/client/Sample/tf_freerdp.h +++ b/client/Sample/tf_freerdp.h @@ -33,8 +33,6 @@ typedef struct rdpClientContext common; /* Channels */ - RdpeiClientContext* rdpei; - RdpgfxClientContext* gfx; EncomspClientContext* encomsp; } tfContext; diff --git a/client/Wayland/wlf_channels.c b/client/Wayland/wlf_channels.c index 6fa2b6a2b..0f1a7eb36 100644 --- a/client/Wayland/wlf_channels.c +++ b/client/Wayland/wlf_channels.c @@ -108,13 +108,8 @@ void wlf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEve WINPR_ASSERT(wlf); WINPR_ASSERT(e); - if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0) + if (FALSE) { - wlf->rdpei = (RdpeiClientContext*)e->pInterface; - } - else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0) - { - gdi_graphics_pipeline_init(wlf->common.context.gdi, (RdpgfxClientContext*)e->pInterface); } else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0) { @@ -131,18 +126,8 @@ void wlf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEve { wlf_disp_init(wlf->disp, (DispClientContext*)e->pInterface); } - else if (strcmp(e->name, GEOMETRY_DVC_CHANNEL_NAME) == 0) - { - gdi_video_geometry_init(wlf->common.context.gdi, (GeometryClientContext*)e->pInterface); - } - else if (strcmp(e->name, VIDEO_CONTROL_DVC_CHANNEL_NAME) == 0) - { - gdi_video_control_init(wlf->common.context.gdi, (VideoClientContext*)e->pInterface); - } - else if (strcmp(e->name, VIDEO_DATA_DVC_CHANNEL_NAME) == 0) - { - gdi_video_data_init(wlf->common.context.gdi, (VideoClientContext*)e->pInterface); - } + else + freerdp_client_OnChannelConnectedEventHandler(context, e); } void wlf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnectedEventArgs* e) @@ -152,13 +137,8 @@ void wlf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnec WINPR_ASSERT(wlf); WINPR_ASSERT(e); - if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0) + if (FALSE) { - wlf->rdpei = NULL; - } - else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0) - { - gdi_graphics_pipeline_uninit(wlf->common.context.gdi, (RdpgfxClientContext*)e->pInterface); } else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0) { @@ -175,16 +155,6 @@ void wlf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnec { wlf_disp_uninit(wlf->disp, (DispClientContext*)e->pInterface); } - else if (strcmp(e->name, GEOMETRY_DVC_CHANNEL_NAME) == 0) - { - gdi_video_geometry_uninit(wlf->common.context.gdi, (GeometryClientContext*)e->pInterface); - } - else if (strcmp(e->name, VIDEO_CONTROL_DVC_CHANNEL_NAME) == 0) - { - gdi_video_control_uninit(wlf->common.context.gdi, (VideoClientContext*)e->pInterface); - } - else if (strcmp(e->name, VIDEO_DATA_DVC_CHANNEL_NAME) == 0) - { - gdi_video_data_uninit(wlf->common.context.gdi, (VideoClientContext*)e->pInterface); - } + else + freerdp_client_OnChannelDisconnectedEventHandler(context, e); } diff --git a/client/Wayland/wlf_input.c b/client/Wayland/wlf_input.c index 79f36366d..4fbe67e04 100644 --- a/client/Wayland/wlf_input.c +++ b/client/Wayland/wlf_input.c @@ -413,7 +413,7 @@ BOOL wlf_handle_touch_up(freerdp* instance, const UwacTouchUp* ev) if (!scale_signed_coordinates(instance->context, &x, &y, TRUE)) return FALSE; - RdpeiClientContext* rdpei = wlf->rdpei; + RdpeiClientContext* rdpei = wlf->common.rdpei; if (wlf->contacts[i].emulate_mouse == TRUE) { @@ -469,7 +469,7 @@ BOOL wlf_handle_touch_down(freerdp* instance, const UwacTouchDown* ev) if (!scale_signed_coordinates(instance->context, &x, &y, TRUE)) return FALSE; - RdpeiClientContext* rdpei = wlf->rdpei; + RdpeiClientContext* rdpei = wlf->common.rdpei; // Emulate mouse click if touch is not possible, like in login screen if (!rdpei) @@ -532,7 +532,7 @@ BOOL wlf_handle_touch_motion(freerdp* instance, const UwacTouchMotion* ev) if (!scale_signed_coordinates(instance->context, &x, &y, TRUE)) return FALSE; - RdpeiClientContext* rdpei = ((wlfContext*)instance->context)->rdpei; + RdpeiClientContext* rdpei = ((wlfContext*)instance->context)->common.rdpei; if (wlf->contacts[i].emulate_mouse == TRUE) { diff --git a/client/Wayland/wlfreerdp.h b/client/Wayland/wlfreerdp.h index e4e456aec..da91fe600 100644 --- a/client/Wayland/wlfreerdp.h +++ b/client/Wayland/wlfreerdp.h @@ -55,8 +55,6 @@ typedef struct BOOL focusing; /* Channels */ - RdpeiClientContext* rdpei; - RdpgfxClientContext* gfx; EncomspClientContext* encomsp; wfClipboard* clipboard; wlfDispContext* disp; diff --git a/client/Windows/wf_channels.c b/client/Windows/wf_channels.c index d1dd1648c..da1f81bb0 100644 --- a/client/Windows/wf_channels.c +++ b/client/Windows/wf_channels.c @@ -44,18 +44,7 @@ void wf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEven settings = wfc->common.context.settings; WINPR_ASSERT(settings); - if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0) - { - } - else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0) - { - if (!settings->SoftwareGdi) - WLog_WARN(TAG, "Channel " RDPGFX_DVC_CHANNEL_NAME - " does not support hardware acceleration, using fallback."); - - gdi_graphics_pipeline_init(wfc->common.context.gdi, (RdpgfxClientContext*)e->pInterface); - } - else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0) + if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0) { wf_rail_init(wfc, (RailClientContext*)e->pInterface); } @@ -70,18 +59,8 @@ void wf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEven { wfc->disp = (DispClientContext*)e->pInterface; } - else if (strcmp(e->name, GEOMETRY_DVC_CHANNEL_NAME) == 0) - { - gdi_video_geometry_init(wfc->common.context.gdi, (GeometryClientContext*)e->pInterface); - } - else if (strcmp(e->name, VIDEO_CONTROL_DVC_CHANNEL_NAME) == 0) - { - gdi_video_control_init(wfc->common.context.gdi, (VideoClientContext*)e->pInterface); - } - else if (strcmp(e->name, VIDEO_DATA_DVC_CHANNEL_NAME) == 0) - { - gdi_video_data_init(wfc->common.context.gdi, (VideoClientContext*)e->pInterface); - } + else + freerdp_client_OnChannelConnectedEventHandler(context, e); } void wf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnectedEventArgs* e) @@ -95,14 +74,7 @@ void wf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnect settings = wfc->common.context.settings; WINPR_ASSERT(settings); - if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0) - { - } - else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0) - { - gdi_graphics_pipeline_uninit(wfc->common.context.gdi, (RdpgfxClientContext*)e->pInterface); - } - else if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0) + if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0) { wf_rail_uninit(wfc, (RailClientContext*)e->pInterface); } @@ -117,16 +89,6 @@ void wf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnect { wfc->disp = NULL; } - else if (strcmp(e->name, GEOMETRY_DVC_CHANNEL_NAME) == 0) - { - gdi_video_geometry_uninit(wfc->common.context.gdi, (GeometryClientContext*)e->pInterface); - } - else if (strcmp(e->name, VIDEO_CONTROL_DVC_CHANNEL_NAME) == 0) - { - gdi_video_control_uninit(wfc->common.context.gdi, (VideoClientContext*)e->pInterface); - } - else if (strcmp(e->name, VIDEO_DATA_DVC_CHANNEL_NAME) == 0) - { - gdi_video_data_uninit(wfc->common.context.gdi, (VideoClientContext*)e->pInterface); - } + else + freerdp_client_OnChannelDisconnectedEventHandler(context, e); } diff --git a/client/Windows/wf_client.c b/client/Windows/wf_client.c index 4292b94cb..4755f8674 100644 --- a/client/Windows/wf_client.c +++ b/client/Windows/wf_client.c @@ -46,7 +46,6 @@ #endif #include -#include #include #include diff --git a/client/X11/xf_channels.c b/client/X11/xf_channels.c index c46ff3a88..00a62d6ed 100644 --- a/client/X11/xf_channels.c +++ b/client/X11/xf_channels.c @@ -49,9 +49,8 @@ void xf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEven settings = xfc->common.context.settings; WINPR_ASSERT(settings); - if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0) + if (FALSE) { - xfc->rdpei = (RdpeiClientContext*)e->pInterface; } #if defined(CHANNEL_TSMF_CLIENT) else if (strcmp(e->name, TSMF_DVC_CHANNEL_NAME) == 0) @@ -79,10 +78,6 @@ void xf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEven { xf_disp_init(xfc->xfDisp, (DispClientContext*)e->pInterface); } - else if (strcmp(e->name, GEOMETRY_DVC_CHANNEL_NAME) == 0) - { - gdi_video_geometry_init(xfc->common.context.gdi, (GeometryClientContext*)e->pInterface); - } else if (strcmp(e->name, VIDEO_CONTROL_DVC_CHANNEL_NAME) == 0) { if (settings->SoftwareGdi) @@ -90,10 +85,8 @@ void xf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEven else xf_video_control_init(xfc, (VideoClientContext*)e->pInterface); } - else if (strcmp(e->name, VIDEO_DATA_DVC_CHANNEL_NAME) == 0) - { - gdi_video_data_init(xfc->common.context.gdi, (VideoClientContext*)e->pInterface); - } + else + freerdp_client_OnChannelConnectedEventHandler(context, e); } void xf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnectedEventArgs* e) @@ -108,9 +101,8 @@ void xf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnect settings = xfc->common.context.settings; WINPR_ASSERT(settings); - if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0) + if (FALSE) { - xfc->rdpei = NULL; } else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0) { @@ -138,10 +130,6 @@ void xf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnect { xf_encomsp_uninit(xfc, (EncomspClientContext*)e->pInterface); } - else if (strcmp(e->name, GEOMETRY_DVC_CHANNEL_NAME) == 0) - { - gdi_video_geometry_uninit(xfc->common.context.gdi, (GeometryClientContext*)e->pInterface); - } else if (strcmp(e->name, VIDEO_CONTROL_DVC_CHANNEL_NAME) == 0) { if (settings->SoftwareGdi) @@ -149,8 +137,6 @@ void xf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnect else xf_video_control_uninit(xfc, (VideoClientContext*)e->pInterface); } - else if (strcmp(e->name, VIDEO_DATA_DVC_CHANNEL_NAME) == 0) - { - gdi_video_data_uninit(xfc->common.context.gdi, (VideoClientContext*)e->pInterface); - } + else + freerdp_client_OnChannelDisconnectedEventHandler(context, e); } diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index 65e8b3e0b..20fa2e135 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -561,7 +561,7 @@ static int xf_input_touch_remote(xfContext* xfc, XIDeviceEvent* event, int evtyp int x, y; int touchId; int contactId; - RdpeiClientContext* rdpei = xfc->rdpei; + RdpeiClientContext* rdpei = xfc->common.rdpei; if (!rdpei) return 0; diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h index f89b6bf70..a4eea0d96 100644 --- a/client/X11/xfreerdp.h +++ b/client/X11/xfreerdp.h @@ -271,7 +271,6 @@ struct xf_context xfClipboard* clipboard; CliprdrClientContext* cliprdr; xfVideoContext* xfVideo; - RdpeiClientContext* rdpei; EncomspClientContext* encomsp; xfDispContext* xfDisp;