libfreerdp-client: use PubSub for OnChannelConnected/OnChannelDisconnected
This commit is contained in:
parent
f5c2181218
commit
5926fa36dd
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
};
|
||||
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user