diff --git a/channels/client/channels.c b/channels/client/channels.c index a9ea2b0dc..bf886dba4 100644 --- a/channels/client/channels.c +++ b/channels/client/channels.c @@ -441,10 +441,14 @@ int freerdp_channels_load_plugin(rdpChannels* channels, rdpSettings* settings, c int freerdp_drdynvc_on_channel_connected(DrdynvcClientContext* context, const char* name, void* pInterface) { int status = 0; + ChannelConnectedEventArgs e; rdpChannels* channels = (rdpChannels*) context->custom; freerdp* instance = channels->instance; - IFCALLRET(instance->OnChannelConnected, status, instance, name, pInterface); + EventArgsInit(&e, "freerdp"); + e.name = name; + e.pInterface = pInterface; + PubSub_OnChannelConnected(instance->context->pubSub, instance->context, &e); return status; } @@ -452,10 +456,14 @@ int freerdp_drdynvc_on_channel_connected(DrdynvcClientContext* context, const ch int freerdp_drdynvc_on_channel_disconnected(DrdynvcClientContext* context, const char* name, void* pInterface) { int status = 0; + ChannelDisconnectedEventArgs e; rdpChannels* channels = (rdpChannels*) context->custom; freerdp* instance = channels->instance; - IFCALLRET(instance->OnChannelDisconnected, status, instance, name, pInterface); + EventArgsInit(&e, "freerdp"); + e.name = name; + e.pInterface = pInterface; + PubSub_OnChannelDisconnected(instance->context->pubSub, instance->context, &e); return status; } diff --git a/channels/disp/client/disp_main.c b/channels/disp/client/disp_main.c index 1e7463c0a..5983c9d6f 100644 --- a/channels/disp/client/disp_main.c +++ b/channels/disp/client/disp_main.c @@ -78,6 +78,8 @@ int disp_send_display_control_monitor_layout_pdu(DISP_CHANNEL_CALLBACK* callback UINT32 type; UINT32 length; + fprintf(stderr, "DisplayControlMonitorLayout\n"); + length = 8 + 4 + NumMonitors * 32; type = DISPLAY_CONTROL_PDU_TYPE_MONITOR_LAYOUT; @@ -122,6 +124,9 @@ int disp_recv_display_control_caps_pdu(DISP_CHANNEL_CALLBACK* callback, wStream* Stream_Read_UINT32(s, disp->MaxMonitorWidth); /* MaxMonitorWidth (4 bytes) */ Stream_Read_UINT32(s, disp->MaxMonitorHeight); /* MaxMonitorHeight (4 bytes) */ + fprintf(stderr, "DisplayControlCapsPdu: MaxNumMonitors: %d MaxMonitorWidth: %d MaxMonitorHeight: %d\n", + disp->MaxNumMonitors, disp->MaxMonitorWidth, disp->MaxMonitorHeight); + return 0; } @@ -133,6 +138,8 @@ int disp_recv_pdu(DISP_CHANNEL_CALLBACK* callback, wStream* s) Stream_Read_UINT32(s, type); /* Type (4 bytes) */ Stream_Read_UINT32(s, length); /* Length (4 bytes) */ + fprintf(stderr, "Type: %d Length: %d\n", type, length); + switch (type) { case DISPLAY_CONTROL_PDU_TYPE_CAPS: @@ -152,6 +159,8 @@ static int disp_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, U int status = 0; DISP_CHANNEL_CALLBACK* callback = (DISP_CHANNEL_CALLBACK*) pChannelCallback; + fprintf(stderr, "DisplayControlOnDataReceived\n"); + s = Stream_New(pBuffer, cbSize); status = disp_recv_pdu(callback, s); @@ -192,6 +201,8 @@ static int disp_on_new_channel_connection(IWTSListenerCallback* pListenerCallbac *ppCallback = (IWTSVirtualChannelCallback*) callback; + fprintf(stderr, "DisplayControlNewChannelConnection\n"); + return 0; } diff --git a/client/X11/xf_channels.c b/client/X11/xf_channels.c index 91dda0b8e..24325046e 100644 --- a/client/X11/xf_channels.c +++ b/client/X11/xf_channels.c @@ -26,19 +26,17 @@ #include "xf_client.h" #include "xfreerdp.h" -int xf_on_channel_connected(freerdp* instance, const char* name, void* pInterface) +void xf_OnChannelConnectedEventHandler(rdpContext* context, ChannelConnectedEventArgs* e) { - xfContext* xfc = (xfContext*) instance->context; + xfContext* xfc = (xfContext*) context; - if (strcmp(name, RDPEI_DVC_CHANNEL_NAME) == 0) + if (strcmp(e->name, RDPEI_DVC_CHANNEL_NAME) == 0) { - xfc->rdpei = (RdpeiClientContext*) pInterface; + xfc->rdpei = (RdpeiClientContext*) e->pInterface; } - - return 0; } -int xf_on_channel_disconnected(freerdp* instance, const char* name, void* pInterface) +void xf_OnChannelDisconnectedEventHandler(rdpContext* context, ChannelDisconnectedEventArgs* e) { - return 0; + } diff --git a/client/X11/xf_channels.h b/client/X11/xf_channels.h index 1aeaf1a66..bb52d5e52 100644 --- a/client/X11/xf_channels.h +++ b/client/X11/xf_channels.h @@ -27,4 +27,7 @@ int xf_on_channel_connected(freerdp* instance, const char* name, void* pInterface); int xf_on_channel_disconnected(freerdp* instance, const char* name, void* pInterface); +void xf_OnChannelConnectedEventHandler(rdpContext* context, ChannelConnectedEventArgs* e); +void xf_OnChannelDisconnectedEventHandler(rdpContext* context, ChannelDisconnectedEventArgs* e); + #endif diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index 1bc990262..0bb180de3 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -666,8 +666,11 @@ BOOL xf_pre_connect(freerdp* instance) settings = instance->settings; channels = instance->context->channels; - instance->OnChannelConnected = xf_on_channel_connected; - instance->OnChannelDisconnected = xf_on_channel_disconnected; + PubSub_SubscribeChannelConnected(instance->context->pubSub, + (pChannelConnectedEventHandler) xf_OnChannelConnectedEventHandler); + + PubSub_SubscribeChannelDisconnected(instance->context->pubSub, + (pChannelDisconnectedEventHandler) xf_OnChannelDisconnectedEventHandler); freerdp_client_load_addins(channels, instance->settings); diff --git a/client/common/client.c b/client/common/client.c index acc47d064..778c41373 100644 --- a/client/common/client.c +++ b/client/common/client.c @@ -56,8 +56,8 @@ rdpContext* freerdp_client_context_new(RDP_CLIENT_ENTRY_POINTS* pEntryPoints) freerdp_context_new(instance); context = instance->context; - context->instance = instance; - context->settings = instance->settings; + context->instance = instance; + context->settings = instance->settings; return context; } diff --git a/include/freerdp/event.h b/include/freerdp/event.h index cd4c7e7f1..812609a36 100644 --- a/include/freerdp/event.h +++ b/include/freerdp/event.h @@ -77,6 +77,16 @@ DEFINE_EVENT_BEGIN(ConnectionResult) int result; DEFINE_EVENT_END(ConnectionResult) +DEFINE_EVENT_BEGIN(ChannelConnected) + const char* name; + void* pInterface; +DEFINE_EVENT_END(ChannelConnected) + +DEFINE_EVENT_BEGIN(ChannelDisconnected) + const char* name; + void* pInterface; +DEFINE_EVENT_END(ChannelDisconnected) + #ifdef __cplusplus } #endif diff --git a/include/freerdp/freerdp.h b/include/freerdp/freerdp.h index 214c2f719..e3ce2bf84 100644 --- a/include/freerdp/freerdp.h +++ b/include/freerdp/freerdp.h @@ -66,9 +66,6 @@ typedef int (*pLogonErrorInfo)(freerdp* instance, UINT32 data, UINT32 type); typedef int (*pSendChannelData)(freerdp* instance, int channelId, BYTE* data, int size); typedef int (*pReceiveChannelData)(freerdp* instance, int channelId, BYTE* data, int size, int flags, int total_size); -typedef int (*pOnChannelConnected)(freerdp* instance, const char* name, void* pInterface); -typedef int (*pOnChannelDisconnected)(freerdp* instance, const char* name, void* pInterface); - /** * Defines the context for a given instance of RDP connection. * It is embedded in the rdp_freerdp structure, and allocated by a call to freerdp_context_new(). @@ -208,9 +205,6 @@ struct rdp_freerdp This is called by freerdp_channel_process() (if not NULL). Clients will typically use a function that calls freerdp_channels_data() to perform the needed tasks. */ - ALIGN64 pOnChannelConnected OnChannelConnected; - ALIGN64 pOnChannelDisconnected OnChannelDisconnected; - UINT64 paddingE[80 - 66]; /* 66 */ }; diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 85f5c3235..396750081 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -338,6 +338,8 @@ static wEventType FreeRDP_Events[] = DEFINE_EVENT_ENTRY(ParamChange) DEFINE_EVENT_ENTRY(Terminate) DEFINE_EVENT_ENTRY(ConnectionResult) + DEFINE_EVENT_ENTRY(ChannelConnected) + DEFINE_EVENT_ENTRY(ChannelDisconnected) }; /** Allocator function for a rdp context.