diff --git a/channels/ainput/client/ainput_main.c b/channels/ainput/client/ainput_main.c index d7acd4bab..a064af254 100644 --- a/channels/ainput/client/ainput_main.c +++ b/channels/ainput/client/ainput_main.c @@ -30,6 +30,7 @@ #include "ainput_main.h" #include +#include #include #include @@ -37,32 +38,13 @@ #define TAG CHANNELS_TAG("ainput.client") -typedef struct AINPUT_CHANNEL_CALLBACK_ AINPUT_CHANNEL_CALLBACK; -struct AINPUT_CHANNEL_CALLBACK_ -{ - IWTSVirtualChannelCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; - IWTSVirtualChannel* channel; -}; - -typedef struct AINPUT_LISTENER_CALLBACK_ AINPUT_LISTENER_CALLBACK; -struct AINPUT_LISTENER_CALLBACK_ -{ - IWTSListenerCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; - AINPUT_CHANNEL_CALLBACK* channel_callback; -}; typedef struct AINPUT_PLUGIN_ AINPUT_PLUGIN; struct AINPUT_PLUGIN_ { IWTSPlugin iface; - AINPUT_LISTENER_CALLBACK* listener_callback; + GENERIC_LISTENER_CALLBACK* listener_callback; IWTSListener* listener; UINT32 MajorVersion; UINT32 MinorVersion; @@ -78,7 +60,7 @@ static UINT ainput_on_data_received(IWTSVirtualChannelCallback* pChannelCallback { UINT16 type; AINPUT_PLUGIN* ainput; - AINPUT_CHANNEL_CALLBACK* callback = (AINPUT_CHANNEL_CALLBACK*)pChannelCallback; + GENERIC_CHANNEL_CALLBACK* callback = (GENERIC_CHANNEL_CALLBACK*)pChannelCallback; WINPR_ASSERT(callback); WINPR_ASSERT(data); @@ -108,7 +90,7 @@ static UINT ainput_on_data_received(IWTSVirtualChannelCallback* pChannelCallback static UINT ainput_send_input_event(AInputClientContext* context, UINT64 flags, INT32 x, INT32 y) { AINPUT_PLUGIN* ainput; - AINPUT_CHANNEL_CALLBACK* callback; + GENERIC_CHANNEL_CALLBACK* callback; BYTE buffer[32] = { 0 }; UINT64 time; wStream sbuffer = { 0 }; @@ -161,7 +143,7 @@ static UINT ainput_send_input_event(AInputClientContext* context, UINT64 flags, */ static UINT ainput_on_close(IWTSVirtualChannelCallback* pChannelCallback) { - AINPUT_CHANNEL_CALLBACK* callback = (AINPUT_CHANNEL_CALLBACK*)pChannelCallback; + GENERIC_CHANNEL_CALLBACK* callback = (GENERIC_CHANNEL_CALLBACK*)pChannelCallback; free(callback); @@ -178,14 +160,14 @@ static UINT ainput_on_new_channel_connection(IWTSListenerCallback* pListenerCall BOOL* pbAccept, IWTSVirtualChannelCallback** ppCallback) { - AINPUT_CHANNEL_CALLBACK* callback; - AINPUT_LISTENER_CALLBACK* listener_callback = (AINPUT_LISTENER_CALLBACK*)pListenerCallback; + GENERIC_CHANNEL_CALLBACK* callback; + GENERIC_LISTENER_CALLBACK* listener_callback = (GENERIC_LISTENER_CALLBACK*)pListenerCallback; WINPR_ASSERT(listener_callback); WINPR_UNUSED(Data); WINPR_UNUSED(pbAccept); - callback = (AINPUT_CHANNEL_CALLBACK*)calloc(1, sizeof(AINPUT_CHANNEL_CALLBACK)); + callback = (GENERIC_CHANNEL_CALLBACK*)calloc(1, sizeof(GENERIC_CHANNEL_CALLBACK)); if (!callback) { @@ -223,7 +205,7 @@ static UINT ainput_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMana return ERROR_INVALID_DATA; } ainput->listener_callback = - (AINPUT_LISTENER_CALLBACK*)calloc(1, sizeof(AINPUT_LISTENER_CALLBACK)); + (GENERIC_LISTENER_CALLBACK*)calloc(1, sizeof(GENERIC_LISTENER_CALLBACK)); if (!ainput->listener_callback) { diff --git a/channels/audin/client/audin_main.c b/channels/audin/client/audin_main.c index 69d118060..90cf9052f 100644 --- a/channels/audin/client/audin_main.c +++ b/channels/audin/client/audin_main.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include "audin_main.h" @@ -49,14 +50,6 @@ #define MSG_SNDIN_DATA 0x06 #define MSG_SNDIN_FORMATCHANGE 0x07 -typedef struct -{ - IWTSListenerCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; -} AUDIN_LISTENER_CALLBACK; - typedef struct { IWTSVirtualChannelCallback iface; @@ -78,7 +71,7 @@ typedef struct { IWTSPlugin iface; - AUDIN_LISTENER_CALLBACK* listener_callback; + GENERIC_LISTENER_CALLBACK* listener_callback; /* Parsed plugin data */ AUDIO_FORMAT* fixed_format; @@ -638,7 +631,7 @@ static UINT audin_on_new_channel_connection(IWTSListenerCallback* pListenerCallb { AUDIN_CHANNEL_CALLBACK* callback; AUDIN_PLUGIN* audin; - AUDIN_LISTENER_CALLBACK* listener_callback = (AUDIN_LISTENER_CALLBACK*)pListenerCallback; + GENERIC_LISTENER_CALLBACK* listener_callback = (GENERIC_LISTENER_CALLBACK*)pListenerCallback; if (!listener_callback || !listener_callback->plugin) return ERROR_INTERNAL_ERROR; @@ -685,7 +678,7 @@ static UINT audin_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManag } WLog_Print(audin->log, WLOG_TRACE, "..."); - audin->listener_callback = (AUDIN_LISTENER_CALLBACK*)calloc(1, sizeof(AUDIN_LISTENER_CALLBACK)); + audin->listener_callback = (GENERIC_LISTENER_CALLBACK*)calloc(1, sizeof(GENERIC_LISTENER_CALLBACK)); if (!audin->listener_callback) { diff --git a/channels/disp/client/disp_main.c b/channels/disp/client/disp_main.c index 3bd8ec640..c4b7b2da4 100644 --- a/channels/disp/client/disp_main.c +++ b/channels/disp/client/disp_main.c @@ -37,34 +37,17 @@ #include #include +#include #include "disp_main.h" #include "../disp_common.h" -typedef struct -{ - IWTSVirtualChannelCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; - IWTSVirtualChannel* channel; -} DISP_CHANNEL_CALLBACK; - -typedef struct -{ - IWTSListenerCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; - DISP_CHANNEL_CALLBACK* channel_callback; -} DISP_LISTENER_CALLBACK; - typedef struct { IWTSPlugin iface; IWTSListener* listener; - DISP_LISTENER_CALLBACK* listener_callback; + GENERIC_LISTENER_CALLBACK* listener_callback; UINT32 MaxNumMonitors; UINT32 MaxMonitorAreaFactorA; @@ -78,7 +61,7 @@ typedef struct * @return 0 on success, otherwise a Win32 error code */ static UINT -disp_send_display_control_monitor_layout_pdu(DISP_CHANNEL_CALLBACK* callback, UINT32 NumMonitors, +disp_send_display_control_monitor_layout_pdu(GENERIC_CHANNEL_CALLBACK* callback, UINT32 NumMonitors, const DISPLAY_CONTROL_MONITOR_LAYOUT* Monitors) { UINT status; @@ -172,7 +155,7 @@ out: * * @return 0 on success, otherwise a Win32 error code */ -static UINT disp_recv_display_control_caps_pdu(DISP_CHANNEL_CALLBACK* callback, wStream* s) +static UINT disp_recv_display_control_caps_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { DISP_PLUGIN* disp; DispClientContext* context; @@ -206,7 +189,7 @@ static UINT disp_recv_display_control_caps_pdu(DISP_CHANNEL_CALLBACK* callback, * * @return 0 on success, otherwise a Win32 error code */ -static UINT disp_recv_pdu(DISP_CHANNEL_CALLBACK* callback, wStream* s) +static UINT disp_recv_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { UINT32 error; DISPLAY_CONTROL_HEADER header = { 0 }; @@ -247,7 +230,7 @@ static UINT disp_recv_pdu(DISP_CHANNEL_CALLBACK* callback, wStream* s) */ static UINT disp_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data) { - DISP_CHANNEL_CALLBACK* callback = (DISP_CHANNEL_CALLBACK*)pChannelCallback; + GENERIC_CHANNEL_CALLBACK* callback = (GENERIC_CHANNEL_CALLBACK*)pChannelCallback; return disp_recv_pdu(callback, data); } @@ -271,15 +254,15 @@ static UINT disp_on_new_channel_connection(IWTSListenerCallback* pListenerCallba IWTSVirtualChannel* pChannel, BYTE* Data, BOOL* pbAccept, IWTSVirtualChannelCallback** ppCallback) { - DISP_CHANNEL_CALLBACK* callback; - DISP_LISTENER_CALLBACK* listener_callback = (DISP_LISTENER_CALLBACK*)pListenerCallback; + GENERIC_CHANNEL_CALLBACK* callback; + GENERIC_LISTENER_CALLBACK* listener_callback = (GENERIC_LISTENER_CALLBACK*)pListenerCallback; WINPR_ASSERT(listener_callback); WINPR_ASSERT(pChannel); WINPR_ASSERT(pbAccept); WINPR_ASSERT(ppCallback); - callback = (DISP_CHANNEL_CALLBACK*)calloc(1, sizeof(DISP_CHANNEL_CALLBACK)); + callback = (GENERIC_CHANNEL_CALLBACK*)calloc(1, sizeof(GENERIC_CHANNEL_CALLBACK)); if (!callback) { @@ -315,7 +298,7 @@ static UINT disp_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManage WLog_ERR(TAG, "[%s] channel initialized twice, aborting", DISP_DVC_CHANNEL_NAME); return ERROR_INVALID_DATA; } - disp->listener_callback = (DISP_LISTENER_CALLBACK*)calloc(1, sizeof(DISP_LISTENER_CALLBACK)); + disp->listener_callback = (GENERIC_LISTENER_CALLBACK*)calloc(1, sizeof(GENERIC_LISTENER_CALLBACK)); if (!disp->listener_callback) { @@ -371,7 +354,7 @@ static UINT disp_send_monitor_layout(DispClientContext* context, UINT32 NumMonit DISPLAY_CONTROL_MONITOR_LAYOUT* Monitors) { DISP_PLUGIN* disp; - DISP_CHANNEL_CALLBACK* callback; + GENERIC_CHANNEL_CALLBACK* callback; WINPR_ASSERT(context); diff --git a/channels/geometry/client/geometry_main.c b/channels/geometry/client/geometry_main.c index f713882c5..f2cf231c3 100644 --- a/channels/geometry/client/geometry_main.c +++ b/channels/geometry/client/geometry_main.c @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -38,30 +39,12 @@ #include "geometry_main.h" -typedef struct -{ - IWTSVirtualChannelCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; - IWTSVirtualChannel* channel; -} GEOMETRY_CHANNEL_CALLBACK; - -typedef struct -{ - IWTSListenerCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; - GEOMETRY_CHANNEL_CALLBACK* channel_callback; -} GEOMETRY_LISTENER_CALLBACK; - typedef struct { IWTSPlugin iface; IWTSListener* listener; - GEOMETRY_LISTENER_CALLBACK* listener_callback; + GENERIC_LISTENER_CALLBACK* listener_callback; GeometryClientContext* context; BOOL initialized; @@ -175,7 +158,7 @@ static UINT32 geometry_read_RGNDATA(wStream* s, UINT32 len, FREERDP_RGNDATA* rgn * * @return 0 on success, otherwise a Win32 error code */ -static UINT geometry_recv_pdu(GEOMETRY_CHANNEL_CALLBACK* callback, wStream* s) +static UINT geometry_recv_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { UINT32 length, cbGeometryBuffer; MAPPED_GEOMETRY* mappedGeometry; @@ -315,7 +298,7 @@ static UINT geometry_recv_pdu(GEOMETRY_CHANNEL_CALLBACK* callback, wStream* s) */ static UINT geometry_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data) { - GEOMETRY_CHANNEL_CALLBACK* callback = (GEOMETRY_CHANNEL_CALLBACK*)pChannelCallback; + GENERIC_CHANNEL_CALLBACK* callback = (GENERIC_CHANNEL_CALLBACK*)pChannelCallback; return geometry_recv_pdu(callback, data); } @@ -340,13 +323,13 @@ static UINT geometry_on_new_channel_connection(IWTSListenerCallback* pListenerCa BOOL* pbAccept, IWTSVirtualChannelCallback** ppCallback) { - GEOMETRY_CHANNEL_CALLBACK* callback; - GEOMETRY_LISTENER_CALLBACK* listener_callback = (GEOMETRY_LISTENER_CALLBACK*)pListenerCallback; + GENERIC_CHANNEL_CALLBACK* callback; + GENERIC_LISTENER_CALLBACK* listener_callback = (GENERIC_LISTENER_CALLBACK*)pListenerCallback; WINPR_UNUSED(Data); WINPR_UNUSED(pbAccept); - callback = (GEOMETRY_CHANNEL_CALLBACK*)calloc(1, sizeof(GEOMETRY_CHANNEL_CALLBACK)); + callback = (GENERIC_CHANNEL_CALLBACK*)calloc(1, sizeof(GENERIC_CHANNEL_CALLBACK)); if (!callback) { @@ -379,7 +362,7 @@ static UINT geometry_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMa return ERROR_INVALID_DATA; } geometry->listener_callback = - (GEOMETRY_LISTENER_CALLBACK*)calloc(1, sizeof(GEOMETRY_LISTENER_CALLBACK)); + (GENERIC_LISTENER_CALLBACK*)calloc(1, sizeof(GENERIC_LISTENER_CALLBACK)); if (!geometry->listener_callback) { diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index c9fddd82c..5fa362d96 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -35,6 +35,7 @@ #include #include +#include #include "rdpei_common.h" @@ -63,30 +64,12 @@ #define MAX_CONTACTS 64 #define MAX_PEN_CONTACTS 4 -typedef struct -{ - IWTSVirtualChannelCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; - IWTSVirtualChannel* channel; -} RDPEI_CHANNEL_CALLBACK; - -typedef struct -{ - IWTSListenerCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; - RDPEI_CHANNEL_CALLBACK* channel_callback; -} RDPEI_LISTENER_CALLBACK; - typedef struct { IWTSPlugin iface; IWTSListener* listener; - RDPEI_LISTENER_CALLBACK* listener_callback; + GENERIC_LISTENER_CALLBACK* listener_callback; RdpeiClientContext* context; @@ -232,7 +215,7 @@ static UINT rdpei_add_frame(RdpeiClientContext* context) * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpei_send_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s, UINT16 eventId, +static UINT rdpei_send_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT16 eventId, UINT32 pduLength) { UINT status; @@ -308,7 +291,7 @@ static UINT rdpei_write_pen_frame(wStream* s, const RDPINPUT_PEN_FRAME* frame) return CHANNEL_RC_OK; } -static UINT rdpei_send_pen_event_pdu(RDPEI_CHANNEL_CALLBACK* callback, UINT32 frameOffset, +static UINT rdpei_send_pen_event_pdu(GENERIC_CHANNEL_CALLBACK* callback, UINT32 frameOffset, const RDPINPUT_PEN_FRAME* frames, UINT16 count) { UINT status; @@ -354,7 +337,7 @@ static UINT rdpei_send_pen_frame(RdpeiClientContext* context, RDPINPUT_PEN_FRAME { const UINT64 currentTime = GetTickCount64(); RDPEI_PLUGIN* rdpei; - RDPEI_CHANNEL_CALLBACK* callback; + GENERIC_CHANNEL_CALLBACK* callback; UINT error; if (!context) @@ -509,7 +492,7 @@ out: * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpei_send_cs_ready_pdu(RDPEI_CHANNEL_CALLBACK* callback) +static UINT rdpei_send_cs_ready_pdu(GENERIC_CHANNEL_CALLBACK* callback) { UINT status; wStream* s; @@ -657,7 +640,7 @@ static UINT rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpei_send_touch_event_pdu(RDPEI_CHANNEL_CALLBACK* callback, +static UINT rdpei_send_touch_event_pdu(GENERIC_CHANNEL_CALLBACK* callback, RDPINPUT_TOUCH_FRAME* frame) { UINT status; @@ -713,7 +696,7 @@ static UINT rdpei_send_touch_event_pdu(RDPEI_CHANNEL_CALLBACK* callback, * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpei_recv_sc_ready_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpei_recv_sc_ready_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { UINT32 features = 0; UINT32 protocolVersion; @@ -757,7 +740,7 @@ static UINT rdpei_recv_sc_ready_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpei_recv_suspend_touch_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpei_recv_suspend_touch_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { UINT error = CHANNEL_RC_OK; RdpeiClientContext* rdpei; @@ -783,7 +766,7 @@ static UINT rdpei_recv_suspend_touch_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStre * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpei_recv_resume_touch_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpei_recv_resume_touch_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { RdpeiClientContext* rdpei; UINT error = CHANNEL_RC_OK; @@ -806,7 +789,7 @@ static UINT rdpei_recv_resume_touch_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStrea * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpei_recv_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpei_recv_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { UINT16 eventId; UINT32 pduLength; @@ -872,7 +855,7 @@ static UINT rdpei_recv_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s) */ static UINT rdpei_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data) { - RDPEI_CHANNEL_CALLBACK* callback = (RDPEI_CHANNEL_CALLBACK*)pChannelCallback; + GENERIC_CHANNEL_CALLBACK* callback = (GENERIC_CHANNEL_CALLBACK*)pChannelCallback; return rdpei_recv_pdu(callback, data); } @@ -883,7 +866,7 @@ static UINT rdpei_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, */ static UINT rdpei_on_close(IWTSVirtualChannelCallback* pChannelCallback) { - RDPEI_CHANNEL_CALLBACK* callback = (RDPEI_CHANNEL_CALLBACK*)pChannelCallback; + GENERIC_CHANNEL_CALLBACK* callback = (GENERIC_CHANNEL_CALLBACK*)pChannelCallback; if (callback) { RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*)callback->plugin; @@ -906,11 +889,11 @@ static UINT rdpei_on_new_channel_connection(IWTSListenerCallback* pListenerCallb IWTSVirtualChannel* pChannel, BYTE* Data, BOOL* pbAccept, IWTSVirtualChannelCallback** ppCallback) { - RDPEI_CHANNEL_CALLBACK* callback; - RDPEI_LISTENER_CALLBACK* listener_callback = (RDPEI_LISTENER_CALLBACK*)pListenerCallback; + GENERIC_CHANNEL_CALLBACK* callback; + GENERIC_LISTENER_CALLBACK* listener_callback = (GENERIC_LISTENER_CALLBACK*)pListenerCallback; if (!listener_callback) return ERROR_INTERNAL_ERROR; - callback = (RDPEI_CHANNEL_CALLBACK*)calloc(1, sizeof(RDPEI_CHANNEL_CALLBACK)); + callback = (GENERIC_CHANNEL_CALLBACK*)calloc(1, sizeof(GENERIC_CHANNEL_CALLBACK)); WINPR_UNUSED(Data); WINPR_UNUSED(pbAccept); @@ -987,7 +970,7 @@ static UINT rdpei_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManag WLog_ERR(TAG, "[%s] channel initialized twice, aborting", RDPEI_DVC_CHANNEL_NAME); return ERROR_INVALID_DATA; } - rdpei->listener_callback = (RDPEI_LISTENER_CALLBACK*)calloc(1, sizeof(RDPEI_LISTENER_CALLBACK)); + rdpei->listener_callback = (GENERIC_LISTENER_CALLBACK*)calloc(1, sizeof(GENERIC_LISTENER_CALLBACK)); if (!rdpei->listener_callback) { @@ -1053,7 +1036,7 @@ UINT rdpei_send_frame(RdpeiClientContext* context, RDPINPUT_TOUCH_FRAME* frame) { UINT64 currentTime = GetTickCount64(); RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*)context->handle; - RDPEI_CHANNEL_CALLBACK* callback; + GENERIC_CHANNEL_CALLBACK* callback; UINT error; callback = rdpei->listener_callback->channel_callback; diff --git a/channels/rdpgfx/client/rdpgfx_main.c b/channels/rdpgfx/client/rdpgfx_main.c index 2222ee438..a07a84c85 100644 --- a/channels/rdpgfx/client/rdpgfx_main.c +++ b/channels/rdpgfx/client/rdpgfx_main.c @@ -107,7 +107,7 @@ static UINT rdpgfx_send_caps_advertise_pdu(RdpgfxClientContext* context, RDPGFX_HEADER header; RDPGFX_CAPSET* capsSet; RDPGFX_PLUGIN* gfx; - RDPGFX_CHANNEL_CALLBACK* callback; + GENERIC_CHANNEL_CALLBACK* callback; wStream* s; gfx = (RDPGFX_PLUGIN*)context->handle; @@ -183,7 +183,7 @@ static BOOL rdpgfx_is_capability_filtered(RDPGFX_PLUGIN* gfx, UINT32 caps) * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_send_supported_caps(RDPGFX_CHANNEL_CALLBACK* callback) +static UINT rdpgfx_send_supported_caps(GENERIC_CHANNEL_CALLBACK* callback) { RDPGFX_PLUGIN* gfx; RdpgfxClientContext* context; @@ -351,7 +351,7 @@ static UINT rdpgfx_send_supported_caps(RDPGFX_CHANNEL_CALLBACK* callback) * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_caps_confirm_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_caps_confirm_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_CAPSET capsSet; RDPGFX_CAPS_CONFIRM_PDU pdu; @@ -387,7 +387,7 @@ static UINT rdpgfx_send_frame_acknowledge_pdu(RdpgfxClientContext* context, wStream* s; RDPGFX_HEADER header; RDPGFX_PLUGIN* gfx; - RDPGFX_CHANNEL_CALLBACK* callback; + GENERIC_CHANNEL_CALLBACK* callback; if (!context || !pdu) return ERROR_BAD_ARGUMENTS; @@ -438,7 +438,7 @@ static UINT rdpgfx_send_qoe_frame_acknowledge_pdu(RdpgfxClientContext* context, UINT error; wStream* s; RDPGFX_HEADER header; - RDPGFX_CHANNEL_CALLBACK* callback; + GENERIC_CHANNEL_CALLBACK* callback; RDPGFX_PLUGIN* gfx; header.flags = 0; header.cmdId = RDPGFX_CMDID_QOEFRAMEACKNOWLEDGE; @@ -486,7 +486,7 @@ fail: * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_reset_graphics_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_reset_graphics_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { int pad; UINT32 index; @@ -572,7 +572,7 @@ static UINT rdpgfx_recv_reset_graphics_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wS * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_evict_cache_entry_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_evict_cache_entry_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_EVICT_CACHE_ENTRY_PDU pdu; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin; @@ -736,7 +736,7 @@ static UINT rdpgfx_send_cache_import_offer_pdu(RdpgfxClientContext* context, UINT error = CHANNEL_RC_OK; wStream* s; RDPGFX_HEADER header; - RDPGFX_CHANNEL_CALLBACK* callback; + GENERIC_CHANNEL_CALLBACK* callback; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)context->handle; if (!context || !pdu) @@ -937,7 +937,7 @@ fail: * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_cache_import_reply_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_cache_import_reply_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { UINT16 idx; RDPGFX_CACHE_IMPORT_REPLY_PDU pdu; @@ -989,7 +989,7 @@ static UINT rdpgfx_recv_cache_import_reply_pdu(RDPGFX_CHANNEL_CALLBACK* callback * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_create_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_create_surface_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_CREATE_SURFACE_PDU pdu; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin; @@ -1025,7 +1025,7 @@ static UINT rdpgfx_recv_create_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wS * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_delete_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_delete_surface_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_DELETE_SURFACE_PDU pdu; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin; @@ -1055,7 +1055,7 @@ static UINT rdpgfx_recv_delete_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wS * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_start_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_start_frame_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_START_FRAME_PDU pdu; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin; @@ -1089,7 +1089,7 @@ static UINT rdpgfx_recv_start_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStre * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_end_frame_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_END_FRAME_PDU pdu; RDPGFX_FRAME_ACKNOWLEDGE_PDU ack; @@ -1186,7 +1186,7 @@ static UINT rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_wire_to_surface_1_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_wire_to_surface_1_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_SURFACE_COMMAND cmd; RDPGFX_WIRE_TO_SURFACE_PDU_1 pdu; @@ -1274,7 +1274,7 @@ static UINT rdpgfx_recv_wire_to_surface_1_pdu(RDPGFX_CHANNEL_CALLBACK* callback, * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_wire_to_surface_2_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_wire_to_surface_2_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_SURFACE_COMMAND cmd; RDPGFX_WIRE_TO_SURFACE_PDU_2 pdu; @@ -1345,7 +1345,7 @@ static UINT rdpgfx_recv_wire_to_surface_2_pdu(RDPGFX_CHANNEL_CALLBACK* callback, * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_delete_encoding_context_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_delete_encoding_context_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_DELETE_ENCODING_CONTEXT_PDU pdu; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin; @@ -1379,7 +1379,7 @@ static UINT rdpgfx_recv_delete_encoding_context_pdu(RDPGFX_CHANNEL_CALLBACK* cal * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_solid_fill_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_solid_fill_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { UINT16 index; RECTANGLE_16* fillRect; @@ -1446,7 +1446,7 @@ static UINT rdpgfx_recv_solid_fill_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStrea * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_surface_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_surface_to_surface_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { UINT16 index; RDPGFX_POINT16* destPt; @@ -1519,7 +1519,7 @@ static UINT rdpgfx_recv_surface_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_surface_to_cache_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_surface_to_cache_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_SURFACE_TO_CACHE_PDU pdu; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin; @@ -1564,7 +1564,7 @@ static UINT rdpgfx_recv_surface_to_cache_pdu(RDPGFX_CHANNEL_CALLBACK* callback, * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_cache_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_cache_to_surface_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { UINT16 index; RDPGFX_POINT16* destPt; @@ -1627,7 +1627,7 @@ static UINT rdpgfx_recv_cache_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_map_surface_to_output_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_map_surface_to_output_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU pdu; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin; @@ -1658,7 +1658,7 @@ static UINT rdpgfx_recv_map_surface_to_output_pdu(RDPGFX_CHANNEL_CALLBACK* callb return error; } -static UINT rdpgfx_recv_map_surface_to_scaled_output_pdu(RDPGFX_CHANNEL_CALLBACK* callback, +static UINT rdpgfx_recv_map_surface_to_scaled_output_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_MAP_SURFACE_TO_SCALED_OUTPUT_PDU pdu; @@ -1698,7 +1698,7 @@ static UINT rdpgfx_recv_map_surface_to_scaled_output_pdu(RDPGFX_CHANNEL_CALLBACK * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_map_surface_to_window_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_map_surface_to_window_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_MAP_SURFACE_TO_WINDOW_PDU pdu; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin; @@ -1729,7 +1729,7 @@ static UINT rdpgfx_recv_map_surface_to_window_pdu(RDPGFX_CHANNEL_CALLBACK* callb return error; } -static UINT rdpgfx_recv_map_surface_to_scaled_window_pdu(RDPGFX_CHANNEL_CALLBACK* callback, +static UINT rdpgfx_recv_map_surface_to_scaled_window_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_MAP_SURFACE_TO_SCALED_WINDOW_PDU pdu; @@ -1770,7 +1770,7 @@ static UINT rdpgfx_recv_map_surface_to_scaled_window_pdu(RDPGFX_CHANNEL_CALLBACK * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +static UINT rdpgfx_recv_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { size_t beg, end; RDPGFX_HEADER header; @@ -1979,7 +1979,7 @@ static UINT rdpgfx_on_data_received(IWTSVirtualChannelCallback* pChannelCallback int status = 0; UINT32 DstSize = 0; BYTE* pDstData = NULL; - RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*)pChannelCallback; + GENERIC_CHANNEL_CALLBACK* callback = (GENERIC_CHANNEL_CALLBACK*)pChannelCallback; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin; UINT error = CHANNEL_RC_OK; status = zgfx_decompress(gfx->zgfx, Stream_Pointer(data), @@ -2021,7 +2021,7 @@ static UINT rdpgfx_on_data_received(IWTSVirtualChannelCallback* pChannelCallback */ static UINT rdpgfx_on_open(IWTSVirtualChannelCallback* pChannelCallback) { - RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*)pChannelCallback; + GENERIC_CHANNEL_CALLBACK* callback = (GENERIC_CHANNEL_CALLBACK*)pChannelCallback; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin; RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface; UINT error = CHANNEL_RC_OK; @@ -2051,7 +2051,7 @@ static UINT rdpgfx_on_open(IWTSVirtualChannelCallback* pChannelCallback) static UINT rdpgfx_on_close(IWTSVirtualChannelCallback* pChannelCallback) { UINT error = CHANNEL_RC_OK; - RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*)pChannelCallback; + GENERIC_CHANNEL_CALLBACK* callback = (GENERIC_CHANNEL_CALLBACK*)pChannelCallback; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin; RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface; @@ -2089,9 +2089,9 @@ static UINT rdpgfx_on_new_channel_connection(IWTSListenerCallback* pListenerCall BOOL* pbAccept, IWTSVirtualChannelCallback** ppCallback) { - RDPGFX_CHANNEL_CALLBACK* callback; - RDPGFX_LISTENER_CALLBACK* listener_callback = (RDPGFX_LISTENER_CALLBACK*)pListenerCallback; - callback = (RDPGFX_CHANNEL_CALLBACK*)calloc(1, sizeof(RDPGFX_CHANNEL_CALLBACK)); + GENERIC_CHANNEL_CALLBACK* callback; + GENERIC_LISTENER_CALLBACK* listener_callback = (GENERIC_LISTENER_CALLBACK*)pListenerCallback; + callback = (GENERIC_CHANNEL_CALLBACK*)calloc(1, sizeof(GENERIC_CHANNEL_CALLBACK)); if (!callback) { @@ -2124,7 +2124,7 @@ static UINT rdpgfx_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMana WLog_ERR(TAG, "[%s] channel initialized twice, aborting", RDPGFX_DVC_CHANNEL_NAME); return ERROR_INVALID_DATA; } - gfx->listener_callback = (RDPGFX_LISTENER_CALLBACK*)calloc(1, sizeof(RDPGFX_LISTENER_CALLBACK)); + gfx->listener_callback = (GENERIC_LISTENER_CALLBACK*)calloc(1, sizeof(GENERIC_LISTENER_CALLBACK)); if (!gfx->listener_callback) { diff --git a/channels/rdpgfx/client/rdpgfx_main.h b/channels/rdpgfx/client/rdpgfx_main.h index 887bb1452..f8e28a39d 100644 --- a/channels/rdpgfx/client/rdpgfx_main.h +++ b/channels/rdpgfx/client/rdpgfx_main.h @@ -27,36 +27,19 @@ #include #include +#include #include #include #include #include #include -typedef struct -{ - IWTSVirtualChannelCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; - IWTSVirtualChannel* channel; -} RDPGFX_CHANNEL_CALLBACK; - -typedef struct -{ - IWTSListenerCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; - RDPGFX_CHANNEL_CALLBACK* channel_callback; -} RDPGFX_LISTENER_CALLBACK; - typedef struct { IWTSPlugin iface; IWTSListener* listener; - RDPGFX_LISTENER_CALLBACK* listener_callback; + GENERIC_LISTENER_CALLBACK* listener_callback; rdpSettings* settings; diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index 8cc0aa623..3387baa0b 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -45,33 +45,17 @@ #include #include #include +#include + #include "rdpsnd_common.h" #include "rdpsnd_main.h" -typedef struct -{ - IWTSVirtualChannelCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; - IWTSVirtualChannel* channel; -} RDPSND_CHANNEL_CALLBACK; - -typedef struct -{ - IWTSListenerCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; - RDPSND_CHANNEL_CALLBACK* channel_callback; -} RDPSND_LISTENER_CALLBACK; - struct rdpsnd_plugin { IWTSPlugin iface; IWTSListener* listener; - RDPSND_LISTENER_CALLBACK* listener_callback; + GENERIC_LISTENER_CALLBACK* listener_callback; CHANNEL_DEF channelDef; CHANNEL_ENTRY_POINTS_FREERDP_EX channelEntryPoints; @@ -1569,7 +1553,7 @@ BOOL VCAPITYPE rdpsnd_VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, static UINT rdpsnd_on_open(IWTSVirtualChannelCallback* pChannelCallback) { - RDPSND_CHANNEL_CALLBACK* callback = (RDPSND_CHANNEL_CALLBACK*)pChannelCallback; + GENERIC_CHANNEL_CALLBACK* callback = (GENERIC_CHANNEL_CALLBACK*)pChannelCallback; rdpsndPlugin* rdpsnd; WINPR_ASSERT(callback); @@ -1585,7 +1569,7 @@ static UINT rdpsnd_on_open(IWTSVirtualChannelCallback* pChannelCallback) static UINT rdpsnd_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data) { - RDPSND_CHANNEL_CALLBACK* callback = (RDPSND_CHANNEL_CALLBACK*)pChannelCallback; + GENERIC_CHANNEL_CALLBACK* callback = (GENERIC_CHANNEL_CALLBACK*)pChannelCallback; rdpsndPlugin* plugin; wStream* copy; size_t len; @@ -1615,7 +1599,7 @@ static UINT rdpsnd_on_data_received(IWTSVirtualChannelCallback* pChannelCallback static UINT rdpsnd_on_close(IWTSVirtualChannelCallback* pChannelCallback) { - RDPSND_CHANNEL_CALLBACK* callback = (RDPSND_CHANNEL_CALLBACK*)pChannelCallback; + GENERIC_CHANNEL_CALLBACK* callback = (GENERIC_CHANNEL_CALLBACK*)pChannelCallback; rdpsndPlugin* rdpsnd; WINPR_ASSERT(callback); @@ -1644,12 +1628,12 @@ static UINT rdpsnd_on_new_channel_connection(IWTSListenerCallback* pListenerCall BOOL* pbAccept, IWTSVirtualChannelCallback** ppCallback) { - RDPSND_CHANNEL_CALLBACK* callback; - RDPSND_LISTENER_CALLBACK* listener_callback = (RDPSND_LISTENER_CALLBACK*)pListenerCallback; + GENERIC_CHANNEL_CALLBACK* callback; + GENERIC_LISTENER_CALLBACK* listener_callback = (GENERIC_LISTENER_CALLBACK*)pListenerCallback; WINPR_ASSERT(listener_callback); WINPR_ASSERT(pChannel); WINPR_ASSERT(ppCallback); - callback = (RDPSND_CHANNEL_CALLBACK*)calloc(1, sizeof(RDPSND_CHANNEL_CALLBACK)); + callback = (GENERIC_CHANNEL_CALLBACK*)calloc(1, sizeof(GENERIC_CHANNEL_CALLBACK)); WINPR_UNUSED(Data); WINPR_UNUSED(pbAccept); @@ -1683,7 +1667,7 @@ static UINT rdpsnd_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMana return ERROR_INVALID_DATA; } rdpsnd->listener_callback = - (RDPSND_LISTENER_CALLBACK*)calloc(1, sizeof(RDPSND_LISTENER_CALLBACK)); + (GENERIC_LISTENER_CALLBACK*)calloc(1, sizeof(GENERIC_LISTENER_CALLBACK)); if (!rdpsnd->listener_callback) { diff --git a/channels/sshagent/client/sshagent_main.c b/channels/sshagent/client/sshagent_main.c index 60a782ea0..c7c999c8e 100644 --- a/channels/sshagent/client/sshagent_main.c +++ b/channels/sshagent/client/sshagent_main.c @@ -52,6 +52,7 @@ #include #include "sshagent_main.h" +#include #include #define TAG CHANNELS_TAG("sshagent.client") @@ -69,11 +70,7 @@ typedef struct typedef struct { - IWTSVirtualChannelCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; - IWTSVirtualChannel* channel; + GENERIC_CHANNEL_CALLBACK generic; rdpContext* rdpcontext; int agent_fd; @@ -159,7 +156,8 @@ static DWORD WINAPI sshagent_read_thread(LPVOID data) else { /* Something read: forward to virtual channel */ - status = callback->channel->Write(callback->channel, bytes_read, buffer, NULL); + IWTSVirtualChannel* channel = callback->generic.channel; + status = channel->Write(channel, bytes_read, buffer, NULL); if (status != CHANNEL_RC_OK) { @@ -253,6 +251,7 @@ static UINT sshagent_on_new_channel_connection(IWTSListenerCallback* pListenerCa IWTSVirtualChannelCallback** ppCallback) { SSHAGENT_CHANNEL_CALLBACK* callback; + GENERIC_CHANNEL_CALLBACK* generic; SSHAGENT_LISTENER_CALLBACK* listener_callback = (SSHAGENT_LISTENER_CALLBACK*)pListenerCallback; callback = (SSHAGENT_CHANNEL_CALLBACK*)calloc(1, sizeof(SSHAGENT_CHANNEL_CALLBACK)); @@ -273,11 +272,12 @@ static UINT sshagent_on_new_channel_connection(IWTSListenerCallback* pListenerCa } InitializeCriticalSection(&callback->lock); - callback->iface.OnDataReceived = sshagent_on_data_received; - callback->iface.OnClose = sshagent_on_close; - callback->plugin = listener_callback->plugin; - callback->channel_mgr = listener_callback->channel_mgr; - callback->channel = pChannel; + generic = &callback->generic; + generic->iface.OnDataReceived = sshagent_on_data_received; + generic->iface.OnClose = sshagent_on_close; + generic->plugin = listener_callback->plugin; + generic->channel_mgr = listener_callback->channel_mgr; + generic->channel = pChannel; callback->rdpcontext = listener_callback->rdpcontext; callback->thread = CreateThread(NULL, 0, sshagent_read_thread, (void*)callback, 0, NULL); diff --git a/channels/urbdrc/client/data_transfer.c b/channels/urbdrc/client/data_transfer.c index a4f7e6cc5..d5da7e6a0 100644 --- a/channels/urbdrc/client/data_transfer.c +++ b/channels/urbdrc/client/data_transfer.c @@ -53,7 +53,7 @@ static void usb_process_get_port_status(IUDEVICE* pdev, wStream* out) } } -static UINT urb_write_completion(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, BOOL noAck, +static UINT urb_write_completion(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, BOOL noAck, wStream* out, UINT32 InterfaceId, UINT32 MessageId, UINT32 RequestId, UINT32 usbd_status, UINT32 OutputBufferSize) { @@ -113,7 +113,7 @@ static wStream* urb_create_iocompletion(UINT32 InterfaceField, UINT32 MessageId, } static UINT urbdrc_process_register_request_callback(IUDEVICE* pdev, - URBDRC_CHANNEL_CALLBACK* callback, wStream* s, + GENERIC_CHANNEL_CALLBACK* callback, wStream* s, IUDEVMAN* udevman) { UINT32 NumRequestCompletion = 0; @@ -207,7 +207,7 @@ static UINT urbdrc_process_retract_device_request(IUDEVICE* pdev, wStream* s, IU return ERROR_SUCCESS; } -static UINT urbdrc_process_io_control(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, wStream* s, +static UINT urbdrc_process_io_control(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 MessageId, IUDEVMAN* udevman) { UINT32 InterfaceId; @@ -304,7 +304,7 @@ static UINT urbdrc_process_io_control(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* c return stream_write_and_free(callback->plugin, callback->channel, out); } -static UINT urbdrc_process_internal_io_control(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, +static UINT urbdrc_process_internal_io_control(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 MessageId, IUDEVMAN* udevman) { wStream* out; @@ -339,7 +339,7 @@ static UINT urbdrc_process_internal_io_control(IUDEVICE* pdev, URBDRC_CHANNEL_CA return stream_write_and_free(callback->plugin, callback->channel, out); } -static UINT urbdrc_process_query_device_text(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, +static UINT urbdrc_process_query_device_text(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 MessageId, IUDEVMAN* udevman) { UINT32 out_size; @@ -398,7 +398,7 @@ static void func_select_all_interface_for_msconfig(IUDEVICE* pdev, } } -static UINT urb_select_configuration(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, wStream* s, +static UINT urb_select_configuration(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 RequestField, UINT32 MessageId, IUDEVMAN* udevman, int transferDir) { @@ -515,7 +515,7 @@ static UINT urb_select_configuration(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* ca return ERROR_SUCCESS; } -static UINT urb_select_interface(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, wStream* s, +static UINT urb_select_interface(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 RequestField, UINT32 MessageId, IUDEVMAN* udevman, int transferDir) { @@ -604,7 +604,7 @@ static UINT urb_select_interface(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callba return ERROR_SUCCESS; } -static UINT urb_control_transfer(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, wStream* s, +static UINT urb_control_transfer(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 RequestField, UINT32 MessageId, IUDEVMAN* udevman, int transferDir, int External) { @@ -692,7 +692,7 @@ static UINT urb_control_transfer(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callba usbd_status, OutputBufferSize); } -static void urb_bulk_transfer_cb(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, wStream* out, +static void urb_bulk_transfer_cb(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* out, UINT32 InterfaceId, BOOL noAck, UINT32 MessageId, UINT32 RequestId, UINT32 NumberOfPackets, UINT32 status, UINT32 StartFrame, UINT32 ErrorCount, UINT32 OutputBufferSize) @@ -704,7 +704,7 @@ static void urb_bulk_transfer_cb(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callba Stream_Free(out, TRUE); } -static UINT urb_bulk_or_interrupt_transfer(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, +static UINT urb_bulk_or_interrupt_transfer(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 RequestField, UINT32 MessageId, IUDEVMAN* udevman, int transferDir) { @@ -730,7 +730,7 @@ static UINT urb_bulk_or_interrupt_transfer(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBA urb_bulk_transfer_cb, 10000); } -static void urb_isoch_transfer_cb(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, wStream* out, +static void urb_isoch_transfer_cb(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* out, UINT32 InterfaceId, BOOL noAck, UINT32 MessageId, UINT32 RequestId, UINT32 NumberOfPackets, UINT32 status, UINT32 StartFrame, UINT32 ErrorCount, UINT32 OutputBufferSize) @@ -777,7 +777,7 @@ static void urb_isoch_transfer_cb(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callb } } -static UINT urb_isoch_transfer(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, wStream* s, +static UINT urb_isoch_transfer(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 RequestField, UINT32 MessageId, IUDEVMAN* udevman, int transferDir) { @@ -819,7 +819,7 @@ static UINT urb_isoch_transfer(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback return (UINT)rc; } -static UINT urb_control_descriptor_request(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, +static UINT urb_control_descriptor_request(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 RequestField, UINT32 MessageId, IUDEVMAN* udevman, BYTE func_recipient, int transferDir) { @@ -899,7 +899,7 @@ static UINT urb_control_descriptor_request(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBA usbd_status, OutputBufferSize); } -static UINT urb_control_get_status_request(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, +static UINT urb_control_get_status_request(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 RequestField, UINT32 MessageId, IUDEVMAN* udevman, BYTE func_recipient, int transferDir) { @@ -958,7 +958,7 @@ static UINT urb_control_get_status_request(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBA usbd_status, OutputBufferSize); } -static UINT urb_control_vendor_or_class_request(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, +static UINT urb_control_vendor_or_class_request(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 RequestField, UINT32 MessageId, IUDEVMAN* udevman, BYTE func_type, BYTE func_recipient, int transferDir) @@ -1041,7 +1041,7 @@ static UINT urb_control_vendor_or_class_request(IUDEVICE* pdev, URBDRC_CHANNEL_C usbd_status, OutputBufferSize); } -static UINT urb_os_feature_descriptor_request(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, +static UINT urb_os_feature_descriptor_request(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 RequestField, UINT32 MessageId, IUDEVMAN* udevman, int transferDir) { @@ -1126,7 +1126,7 @@ static UINT urb_os_feature_descriptor_request(IUDEVICE* pdev, URBDRC_CHANNEL_CAL usbd_status, OutputBufferSize); } -static UINT urb_pipe_request(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, wStream* s, +static UINT urb_pipe_request(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 RequestField, UINT32 MessageId, IUDEVMAN* udevman, int transferDir, int action) { @@ -1205,7 +1205,7 @@ static UINT urb_pipe_request(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, 0); } -static UINT urb_get_current_frame_number(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, +static UINT urb_get_current_frame_number(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 RequestField, UINT32 MessageId, IUDEVMAN* udevman, int transferDir) { @@ -1267,7 +1267,7 @@ static UINT urb_get_current_frame_number(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK } /* Unused function for current server */ -static UINT urb_control_get_configuration_request(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, +static UINT urb_control_get_configuration_request(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 RequestField, UINT32 MessageId, IUDEVMAN* udevman, int transferDir) { @@ -1323,7 +1323,7 @@ static UINT urb_control_get_configuration_request(IUDEVICE* pdev, URBDRC_CHANNEL } /* Unused function for current server */ -static UINT urb_control_get_interface_request(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, +static UINT urb_control_get_interface_request(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 RequestField, UINT32 MessageId, IUDEVMAN* udevman, int transferDir) { @@ -1380,7 +1380,7 @@ static UINT urb_control_get_interface_request(IUDEVICE* pdev, URBDRC_CHANNEL_CAL usbd_status, OutputBufferSize); } -static UINT urb_control_feature_request(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, +static UINT urb_control_feature_request(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 RequestField, UINT32 MessageId, IUDEVMAN* udevman, BYTE func_recipient, BYTE command, int transferDir) @@ -1474,7 +1474,7 @@ static UINT urb_control_feature_request(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* usbd_status, OutputBufferSize); } -static UINT urbdrc_process_transfer_request(IUDEVICE* pdev, URBDRC_CHANNEL_CALLBACK* callback, +static UINT urbdrc_process_transfer_request(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 MessageId, IUDEVMAN* udevman, int transferDir) { @@ -1767,7 +1767,7 @@ static UINT urbdrc_process_transfer_request(IUDEVICE* pdev, URBDRC_CHANNEL_CALLB return error; } -UINT urbdrc_process_udev_data_transfer(URBDRC_CHANNEL_CALLBACK* callback, URBDRC_PLUGIN* urbdrc, +UINT urbdrc_process_udev_data_transfer(GENERIC_CHANNEL_CALLBACK* callback, URBDRC_PLUGIN* urbdrc, IUDEVMAN* udevman, wStream* data) { UINT32 InterfaceId; diff --git a/channels/urbdrc/client/data_transfer.h b/channels/urbdrc/client/data_transfer.h index d63f82ec7..1d7126d2e 100644 --- a/channels/urbdrc/client/data_transfer.h +++ b/channels/urbdrc/client/data_transfer.h @@ -30,7 +30,7 @@ #define TRANSFER_CTX(transfer) (HANDLE_CTX((transfer)->dev_handle)) #define ITRANSFER_CTX(transfer) (TRANSFER_CTX(__USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer))) -UINT urbdrc_process_udev_data_transfer(URBDRC_CHANNEL_CALLBACK* callback, URBDRC_PLUGIN* urbdrc, +UINT urbdrc_process_udev_data_transfer(GENERIC_CHANNEL_CALLBACK* callback, URBDRC_PLUGIN* urbdrc, IUDEVMAN* udevman, wStream* data); #endif /* FREERDP_CHANNEL_URBDRC_CLIENT_DATA_TRANSFER_H */ diff --git a/channels/urbdrc/client/libusb/libusb_udevice.c b/channels/urbdrc/client/libusb/libusb_udevice.c index d0bfe8667..141482bb1 100644 --- a/channels/urbdrc/client/libusb/libusb_udevice.c +++ b/channels/urbdrc/client/libusb/libusb_udevice.c @@ -71,7 +71,7 @@ typedef struct UINT32 ErrorCount; IUDEVICE* idev; UINT32 OutputBufferSize; - URBDRC_CHANNEL_CALLBACK* callback; + GENERIC_CHANNEL_CALLBACK* callback; t_isoch_transfer_cb cb; wArrayList* queue; #if !defined(HAVE_STREAM_ID_API) @@ -200,7 +200,7 @@ static ASYNC_TRANSFER_USER_DATA* async_transfer_user_data_new(IUDEVICE* idev, UI size_t offset, size_t BufferSize, const BYTE* data, size_t packetSize, BOOL NoAck, t_isoch_transfer_cb cb, - URBDRC_CHANNEL_CALLBACK* callback) + GENERIC_CHANNEL_CALLBACK* callback) { ASYNC_TRANSFER_USER_DATA* user_data; UDEVICE* pdev = (UDEVICE*)idev; @@ -1199,7 +1199,7 @@ static int libusb_udev_query_device_port_status(IUDEVICE* idev, UINT32* UsbdStat return success; } -static int libusb_udev_isoch_transfer(IUDEVICE* idev, URBDRC_CHANNEL_CALLBACK* callback, +static int libusb_udev_isoch_transfer(IUDEVICE* idev, GENERIC_CHANNEL_CALLBACK* callback, UINT32 MessageId, UINT32 RequestId, UINT32 EndpointAddress, UINT32 TransferFlags, UINT32 StartFrame, UINT32 ErrorCount, BOOL NoAck, const BYTE* packetDescriptorData, @@ -1290,7 +1290,7 @@ static BOOL libusb_udev_control_transfer(IUDEVICE* idev, UINT32 RequestId, UINT3 return TRUE; } -static int libusb_udev_bulk_or_interrupt_transfer(IUDEVICE* idev, URBDRC_CHANNEL_CALLBACK* callback, +static int libusb_udev_bulk_or_interrupt_transfer(IUDEVICE* idev, GENERIC_CHANNEL_CALLBACK* callback, UINT32 MessageId, UINT32 RequestId, UINT32 EndpointAddress, UINT32 TransferFlags, BOOL NoAck, UINT32 BufferSize, const BYTE* data, diff --git a/channels/urbdrc/client/urbdrc_main.c b/channels/urbdrc/client/urbdrc_main.c index 8a5bcf9bc..bd8c7a753 100644 --- a/channels/urbdrc/client/urbdrc_main.c +++ b/channels/urbdrc/client/urbdrc_main.c @@ -132,7 +132,7 @@ static int func_instance_id_generate(IUDEVICE* pdev, char* strInstanceId, size_t * * @return 0 on success, otherwise a Win32 error code */ -static UINT urbdrc_process_capability_request(URBDRC_CHANNEL_CALLBACK* callback, wStream* s, +static UINT urbdrc_process_capability_request(GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 MessageId) { UINT32 InterfaceId; @@ -170,7 +170,7 @@ static UINT urbdrc_process_capability_request(URBDRC_CHANNEL_CALLBACK* callback, * * @return 0 on success, otherwise a Win32 error code */ -static UINT urbdrc_process_channel_create(URBDRC_CHANNEL_CALLBACK* callback, wStream* s, +static UINT urbdrc_process_channel_create(GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT32 MessageId) { UINT32 InterfaceId; @@ -239,7 +239,7 @@ static UINT urdbrc_send_virtual_channel_add(IWTSPlugin* plugin, IWTSVirtualChann * * @return 0 on success, otherwise a Win32 error code */ -static UINT urdbrc_send_usb_device_add(URBDRC_CHANNEL_CALLBACK* callback, IUDEVICE* pdev) +static UINT urdbrc_send_usb_device_add(GENERIC_CHANNEL_CALLBACK* callback, IUDEVICE* pdev) { wStream* out; UINT32 InterfaceId; @@ -375,7 +375,7 @@ static UINT urdbrc_send_usb_device_add(URBDRC_CHANNEL_CALLBACK* callback, IUDEVI * * @return 0 on success, otherwise a Win32 error code */ -static UINT urbdrc_exchange_capabilities(URBDRC_CHANNEL_CALLBACK* callback, wStream* data) +static UINT urbdrc_exchange_capabilities(GENERIC_CHANNEL_CALLBACK* callback, wStream* data) { UINT32 MessageId; UINT32 FunctionId; @@ -437,7 +437,7 @@ static BOOL urbdrc_announce_devices(IUDEVMAN* udevman) return error == ERROR_SUCCESS; } -static UINT urbdrc_device_control_channel(URBDRC_CHANNEL_CALLBACK* callback, wStream* s) +static UINT urbdrc_device_control_channel(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*)callback->plugin; IUDEVMAN* udevman = urbdrc->udevman; @@ -504,7 +504,7 @@ fail: * * @return 0 on success, otherwise a Win32 error code */ -static UINT urbdrc_process_channel_notification(URBDRC_CHANNEL_CALLBACK* callback, wStream* data) +static UINT urbdrc_process_channel_notification(GENERIC_CHANNEL_CALLBACK* callback, wStream* data) { UINT32 MessageId; UINT32 FunctionId; @@ -557,7 +557,7 @@ static UINT urbdrc_process_channel_notification(URBDRC_CHANNEL_CALLBACK* callbac */ static UINT urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data) { - URBDRC_CHANNEL_CALLBACK* callback = (URBDRC_CHANNEL_CALLBACK*)pChannelCallback; + GENERIC_CHANNEL_CALLBACK* callback = (GENERIC_CHANNEL_CALLBACK*)pChannelCallback; URBDRC_PLUGIN* urbdrc; IUDEVMAN* udevman; UINT32 InterfaceId; @@ -610,7 +610,7 @@ static UINT urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback */ static UINT urbdrc_on_close(IWTSVirtualChannelCallback* pChannelCallback) { - URBDRC_CHANNEL_CALLBACK* callback = (URBDRC_CHANNEL_CALLBACK*)pChannelCallback; + GENERIC_CHANNEL_CALLBACK* callback = (GENERIC_CHANNEL_CALLBACK*)pChannelCallback; if (callback) { URBDRC_PLUGIN* urbdrc = (URBDRC_PLUGIN*)callback->plugin; @@ -645,13 +645,13 @@ static UINT urbdrc_on_new_channel_connection(IWTSListenerCallback* pListenerCall BOOL* pbAccept, IWTSVirtualChannelCallback** ppCallback) { - URBDRC_LISTENER_CALLBACK* listener_callback = (URBDRC_LISTENER_CALLBACK*)pListenerCallback; - URBDRC_CHANNEL_CALLBACK* callback; + GENERIC_LISTENER_CALLBACK* listener_callback = (GENERIC_LISTENER_CALLBACK*)pListenerCallback; + GENERIC_CHANNEL_CALLBACK* callback; if (!ppCallback) return ERROR_INVALID_PARAMETER; - callback = (URBDRC_CHANNEL_CALLBACK*)calloc(1, sizeof(URBDRC_CHANNEL_CALLBACK)); + callback = (GENERIC_CHANNEL_CALLBACK*)calloc(1, sizeof(GENERIC_CHANNEL_CALLBACK)); if (!callback) return ERROR_OUTOFMEMORY; @@ -687,7 +687,7 @@ static UINT urbdrc_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMana } udevman = urbdrc->udevman; urbdrc->listener_callback = - (URBDRC_LISTENER_CALLBACK*)calloc(1, sizeof(URBDRC_LISTENER_CALLBACK)); + (GENERIC_LISTENER_CALLBACK*)calloc(1, sizeof(GENERIC_LISTENER_CALLBACK)); if (!urbdrc->listener_callback) return CHANNEL_RC_NO_MEMORY; diff --git a/channels/urbdrc/client/urbdrc_main.h b/channels/urbdrc/client/urbdrc_main.h index 6fdb50786..d89318e2b 100644 --- a/channels/urbdrc/client/urbdrc_main.h +++ b/channels/urbdrc/client/urbdrc_main.h @@ -23,6 +23,7 @@ #include #include +#include #define DEVICE_HARDWARE_ID_SIZE 32 #define DEVICE_COMPATIBILITY_ID_SIZE 36 @@ -50,28 +51,12 @@ typedef struct S_IUDEVMAN IUDEVMAN; _type (*get_##_arg)(IUDEVMAN * udevman); \ void (*set_##_arg)(IUDEVMAN * udevman, _type _arg) -typedef struct -{ - IWTSListenerCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; -} URBDRC_LISTENER_CALLBACK; - -typedef struct -{ - IWTSVirtualChannelCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; - IWTSVirtualChannel* channel; -} URBDRC_CHANNEL_CALLBACK; typedef struct { IWTSPlugin iface; - URBDRC_LISTENER_CALLBACK* listener_callback; + GENERIC_LISTENER_CALLBACK* listener_callback; IUDEVMAN* udevman; UINT32 vchannel_status; @@ -95,14 +80,14 @@ typedef int (*PFREERDP_URBDRC_DEVICE_ENTRY)(PFREERDP_URBDRC_SERVICE_ENTRY_POINTS typedef struct { - URBDRC_CHANNEL_CALLBACK* callback; + GENERIC_CHANNEL_CALLBACK* callback; URBDRC_PLUGIN* urbdrc; IUDEVMAN* udevman; IWTSVirtualChannel* channel; wStream* s; } TRANSFER_DATA; -typedef void (*t_isoch_transfer_cb)(IUDEVICE* idev, URBDRC_CHANNEL_CALLBACK* callback, wStream* out, +typedef void (*t_isoch_transfer_cb)(IUDEVICE* idev, GENERIC_CHANNEL_CALLBACK* callback, wStream* out, UINT32 InterfaceId, BOOL noAck, UINT32 MessageId, UINT32 RequestId, UINT32 NumberOfPackets, UINT32 status, UINT32 StartFrame, UINT32 ErrorCount, UINT32 OutputBufferSize); @@ -110,7 +95,7 @@ typedef void (*t_isoch_transfer_cb)(IUDEVICE* idev, URBDRC_CHANNEL_CALLBACK* cal struct S_IUDEVICE { /* Transfer */ - int (*isoch_transfer)(IUDEVICE* idev, URBDRC_CHANNEL_CALLBACK* callback, UINT32 MessageId, + int (*isoch_transfer)(IUDEVICE* idev, GENERIC_CHANNEL_CALLBACK* callback, UINT32 MessageId, UINT32 RequestId, UINT32 EndpointAddress, UINT32 TransferFlags, UINT32 StartFrame, UINT32 ErrorCount, BOOL NoAck, const BYTE* packetDescriptorData, UINT32 NumberOfPackets, @@ -122,7 +107,7 @@ struct S_IUDEVICE BYTE bmRequestType, BYTE Request, UINT16 Value, UINT16 Index, UINT32* UrbdStatus, UINT32* BufferSize, BYTE* Buffer, UINT32 Timeout); - int (*bulk_or_interrupt_transfer)(IUDEVICE* idev, URBDRC_CHANNEL_CALLBACK* callback, + int (*bulk_or_interrupt_transfer)(IUDEVICE* idev, GENERIC_CHANNEL_CALLBACK* callback, UINT32 MessageId, UINT32 RequestId, UINT32 EndpointAddress, UINT32 TransferFlags, BOOL NoAck, UINT32 BufferSize, const BYTE* data, t_isoch_transfer_cb cb, UINT32 Timeout); diff --git a/channels/video/client/video_main.c b/channels/video/client/video_main.c index 79d49e2a1..e37e8e3e8 100644 --- a/channels/video/client/video_main.c +++ b/channels/video/client/video_main.c @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -45,32 +46,14 @@ #include "video_main.h" -typedef struct -{ - IWTSVirtualChannelCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; - IWTSVirtualChannel* channel; -} VIDEO_CHANNEL_CALLBACK; - -typedef struct -{ - IWTSListenerCallback iface; - - IWTSPlugin* plugin; - IWTSVirtualChannelManager* channel_mgr; - VIDEO_CHANNEL_CALLBACK* channel_callback; -} VIDEO_LISTENER_CALLBACK; - typedef struct { IWTSPlugin wtsPlugin; IWTSListener* controlListener; IWTSListener* dataListener; - VIDEO_LISTENER_CALLBACK* control_callback; - VIDEO_LISTENER_CALLBACK* data_callback; + GENERIC_LISTENER_CALLBACK* control_callback; + GENERIC_LISTENER_CALLBACK* data_callback; VideoClientContext* context; BOOL initialized; @@ -570,7 +553,7 @@ static UINT video_read_tsmm_presentation_req(VideoClientContext* context, wStrea */ static UINT video_control_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* s) { - VIDEO_CHANNEL_CALLBACK* callback = (VIDEO_CHANNEL_CALLBACK*)pChannelCallback; + GENERIC_CHANNEL_CALLBACK* callback = (GENERIC_CHANNEL_CALLBACK*)pChannelCallback; VIDEO_PLUGIN* video; VideoClientContext* context; UINT ret = CHANNEL_RC_OK; @@ -928,7 +911,7 @@ static UINT video_VideoData(VideoClientContext* context, const TSMM_VIDEO_DATA* static UINT video_data_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* s) { - VIDEO_CHANNEL_CALLBACK* callback = (VIDEO_CHANNEL_CALLBACK*)pChannelCallback; + GENERIC_CHANNEL_CALLBACK* callback = (GENERIC_CHANNEL_CALLBACK*)pChannelCallback; VIDEO_PLUGIN* video; VideoClientContext* context; UINT32 cbSize, packetType; @@ -1010,13 +993,13 @@ static UINT video_control_on_new_channel_connection(IWTSListenerCallback* listen BOOL* pbAccept, IWTSVirtualChannelCallback** ppCallback) { - VIDEO_CHANNEL_CALLBACK* callback; - VIDEO_LISTENER_CALLBACK* listener_callback = (VIDEO_LISTENER_CALLBACK*)listenerCallback; + GENERIC_CHANNEL_CALLBACK* callback; + GENERIC_LISTENER_CALLBACK* listener_callback = (GENERIC_LISTENER_CALLBACK*)listenerCallback; WINPR_UNUSED(Data); WINPR_UNUSED(pbAccept); - callback = (VIDEO_CHANNEL_CALLBACK*)calloc(1, sizeof(VIDEO_CHANNEL_CALLBACK)); + callback = (GENERIC_CHANNEL_CALLBACK*)calloc(1, sizeof(GENERIC_CHANNEL_CALLBACK)); if (!callback) { WLog_ERR(TAG, "calloc failed!"); @@ -1040,13 +1023,13 @@ static UINT video_data_on_new_channel_connection(IWTSListenerCallback* pListener BOOL* pbAccept, IWTSVirtualChannelCallback** ppCallback) { - VIDEO_CHANNEL_CALLBACK* callback; - VIDEO_LISTENER_CALLBACK* listener_callback = (VIDEO_LISTENER_CALLBACK*)pListenerCallback; + GENERIC_CHANNEL_CALLBACK* callback; + GENERIC_LISTENER_CALLBACK* listener_callback = (GENERIC_LISTENER_CALLBACK*)pListenerCallback; WINPR_UNUSED(Data); WINPR_UNUSED(pbAccept); - callback = (VIDEO_CHANNEL_CALLBACK*)calloc(1, sizeof(VIDEO_CHANNEL_CALLBACK)); + callback = (GENERIC_CHANNEL_CALLBACK*)calloc(1, sizeof(GENERIC_CHANNEL_CALLBACK)); if (!callback) { WLog_ERR(TAG, "calloc failed!"); @@ -1074,7 +1057,7 @@ static UINT video_plugin_initialize(IWTSPlugin* plugin, IWTSVirtualChannelManage { UINT status; VIDEO_PLUGIN* video = (VIDEO_PLUGIN*)plugin; - VIDEO_LISTENER_CALLBACK* callback; + GENERIC_LISTENER_CALLBACK* callback; if (video->initialized) { @@ -1082,7 +1065,7 @@ static UINT video_plugin_initialize(IWTSPlugin* plugin, IWTSVirtualChannelManage return ERROR_INVALID_DATA; } video->control_callback = callback = - (VIDEO_LISTENER_CALLBACK*)calloc(1, sizeof(VIDEO_LISTENER_CALLBACK)); + (GENERIC_LISTENER_CALLBACK*)calloc(1, sizeof(GENERIC_LISTENER_CALLBACK)); if (!callback) { WLog_ERR(TAG, "calloc for control callback failed!"); @@ -1101,7 +1084,7 @@ static UINT video_plugin_initialize(IWTSPlugin* plugin, IWTSVirtualChannelManage video->controlListener->pInterface = video->wtsPlugin.pInterface; video->data_callback = callback = - (VIDEO_LISTENER_CALLBACK*)calloc(1, sizeof(VIDEO_LISTENER_CALLBACK)); + (GENERIC_LISTENER_CALLBACK*)calloc(1, sizeof(GENERIC_LISTENER_CALLBACK)); if (!callback) { WLog_ERR(TAG, "calloc for data callback failed!"); diff --git a/include/freerdp/client/channels.h b/include/freerdp/client/channels.h index baf82adc0..ff46e9575 100644 --- a/include/freerdp/client/channels.h +++ b/include/freerdp/client/channels.h @@ -24,6 +24,25 @@ #include #include + +typedef struct +{ + IWTSVirtualChannelCallback iface; + IWTSPlugin* plugin; + IWTSVirtualChannelManager* channel_mgr; + IWTSVirtualChannel* channel; +} GENERIC_CHANNEL_CALLBACK; + +typedef struct +{ + IWTSListenerCallback iface; + IWTSPlugin* plugin; + IWTSVirtualChannelManager* channel_mgr; + IWTSVirtualChannel* channel; + GENERIC_CHANNEL_CALLBACK* channel_callback; +} GENERIC_LISTENER_CALLBACK; + + #ifdef __cplusplus extern "C" {