libfreerdp-client: export and register successfully interface pointer for channel

This commit is contained in:
Marc-André Moreau 2013-05-12 21:23:12 -04:00
parent 608f00b7df
commit 8e151409be
6 changed files with 29 additions and 19 deletions

View File

@ -68,6 +68,7 @@
* VirtualChannelInit for the pInitHandle. * VirtualChannelInit for the pInitHandle.
*/ */
void* g_pInterface;
CHANNEL_INIT_DATA g_ChannelInitData; CHANNEL_INIT_DATA g_ChannelInitData;
static wArrayList* g_ChannelsList = NULL; static wArrayList* g_ChannelsList = NULL;
@ -386,7 +387,9 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v
ep.pVirtualChannelClose = FreeRDP_VirtualChannelClose; ep.pVirtualChannelClose = FreeRDP_VirtualChannelClose;
ep.pVirtualChannelWrite = FreeRDP_VirtualChannelWrite; ep.pVirtualChannelWrite = FreeRDP_VirtualChannelWrite;
ep.pInterface = NULL; g_pInterface = NULL;
ep.MagicNumber = FREERDP_CHANNEL_MAGIC_NUMBER;
ep.ppInterface = &g_pInterface;
ep.pExtendedData = data; ep.pExtendedData = data;
ep.pVirtualChannelEventPush = FreeRDP_VirtualChannelEventPush; ep.pVirtualChannelEventPush = FreeRDP_VirtualChannelEventPush;
@ -397,10 +400,7 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v
WaitForSingleObject(g_mutex_init, INFINITE); WaitForSingleObject(g_mutex_init, INFINITE);
g_ChannelInitData.channels = channels; g_ChannelInitData.channels = channels;
g_ChannelInitData.pInterface = ep.pInterface;
status = pChannelClientData->entry((PCHANNEL_ENTRY_POINTS) &ep); status = pChannelClientData->entry((PCHANNEL_ENTRY_POINTS) &ep);
g_ChannelInitData.channels = NULL;
g_ChannelInitData.pInterface = NULL;
ReleaseMutex(g_mutex_init); ReleaseMutex(g_mutex_init);
@ -659,12 +659,10 @@ BOOL freerdp_channels_get_fds(rdpChannels* channels, freerdp* instance, void** r
return TRUE; return TRUE;
} }
void* freerdp_channels_get_static_channel_interface(freerdp* instance, const char* name) void* freerdp_channels_get_static_channel_interface(rdpChannels* channels, const char* name)
{ {
rdpChannels* channels;
CHANNEL_OPEN_DATA* pChannelOpenData; CHANNEL_OPEN_DATA* pChannelOpenData;
channels = instance->context->channels;
pChannelOpenData = freerdp_channels_find_channel_open_data_by_name(channels, name); pChannelOpenData = freerdp_channels_find_channel_open_data_by_name(channels, name);
return pChannelOpenData->pInterface; return pChannelOpenData->pInterface;

View File

@ -26,6 +26,8 @@
#include "init.h" #include "init.h"
extern int g_open_handle_sequence; extern int g_open_handle_sequence;
extern void* g_pInterface;
extern CHANNEL_INIT_DATA g_ChannelInitData; extern CHANNEL_INIT_DATA g_ChannelInitData;
UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel, UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel,
@ -47,7 +49,7 @@ UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel,
} }
channels = g_ChannelInitData.channels; channels = g_ChannelInitData.channels;
pInterface = g_ChannelInitData.pInterface; pInterface = g_pInterface;
pChannelInitData = &(channels->initDataList[channels->initDataCount]); pChannelInitData = &(channels->initDataList[channels->initDataCount]);
*ppInitHandle = pChannelInitData; *ppInitHandle = pChannelInitData;

View File

@ -301,6 +301,7 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
{ {
cliprdrPlugin* _p; cliprdrPlugin* _p;
CliprdrClientContext* context; CliprdrClientContext* context;
CHANNEL_ENTRY_POINTS_EX* pEntryPointsEx;
_p = (cliprdrPlugin*) malloc(sizeof(cliprdrPlugin)); _p = (cliprdrPlugin*) malloc(sizeof(cliprdrPlugin));
ZeroMemory(_p, sizeof(cliprdrPlugin)); ZeroMemory(_p, sizeof(cliprdrPlugin));
@ -318,14 +319,20 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
_p->plugin.event_callback = cliprdr_process_event; _p->plugin.event_callback = cliprdr_process_event;
_p->plugin.terminate_callback = cliprdr_process_terminate; _p->plugin.terminate_callback = cliprdr_process_terminate;
context = (CliprdrClientContext*) malloc(sizeof(CliprdrClientContext)); pEntryPointsEx = (CHANNEL_ENTRY_POINTS_EX*) pEntryPoints;
context->MonitorReady = cliprdr_monitor_ready; if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_EX)) &&
context->FormatList = cliprdr_format_list; (pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
context->DataRequest = cliprdr_data_request; {
context->DataResponse = cliprdr_data_response; context = (CliprdrClientContext*) malloc(sizeof(CliprdrClientContext));
_p->plugin.channel_entry_points.pInterface = (void*) context; context->MonitorReady = cliprdr_monitor_ready;
context->FormatList = cliprdr_format_list;
context->DataRequest = cliprdr_data_request;
context->DataResponse = cliprdr_data_response;
*(pEntryPointsEx->ppInterface) = (void*) context;
}
svc_plugin_init((rdpSvcPlugin*) _p, pEntryPoints); svc_plugin_init((rdpSvcPlugin*) _p, pEntryPoints);

View File

@ -30,6 +30,7 @@
#include <freerdp/utils/event.h> #include <freerdp/utils/event.h>
#include <freerdp/client/cliprdr.h> #include <freerdp/client/cliprdr.h>
#include <freerdp/channels/channels.h>
#include "xf_cliprdr.h" #include "xf_cliprdr.h"
@ -89,7 +90,7 @@ struct clipboard_context
int incr_data_length; int incr_data_length;
}; };
void xf_cliprdr_init(xfInfo* xfi, rdpChannels* chanman) void xf_cliprdr_init(xfInfo* xfi, rdpChannels* channels)
{ {
int n; int n;
UINT32 id; UINT32 id;
@ -100,7 +101,7 @@ void xf_cliprdr_init(xfInfo* xfi, rdpChannels* chanman)
xfi->clipboard_context = cb; xfi->clipboard_context = cb;
cb->channels = chanman; cb->channels = channels;
cb->request_index = -1; cb->request_index = -1;
cb->root_window = DefaultRootWindow(xfi->display); cb->root_window = DefaultRootWindow(xfi->display);

View File

@ -48,7 +48,7 @@ FREERDP_API BOOL freerdp_channels_check_fds(rdpChannels* channels, freerdp* inst
FREERDP_API wMessage* freerdp_channels_pop_event(rdpChannels* channels); FREERDP_API wMessage* freerdp_channels_pop_event(rdpChannels* channels);
FREERDP_API void freerdp_channels_close(rdpChannels* channels, freerdp* instance); FREERDP_API void freerdp_channels_close(rdpChannels* channels, freerdp* instance);
FREERDP_API void* freerdp_channels_get_static_channel_interface(freerdp* instance, const char* name); FREERDP_API void* freerdp_channels_get_static_channel_interface(rdpChannels* channels, const char* name);
FREERDP_API HANDLE freerdp_channels_get_event_handle(freerdp* instance); FREERDP_API HANDLE freerdp_channels_get_event_handle(freerdp* instance);
FREERDP_API int freerdp_channels_process_pending_messages(freerdp* instance); FREERDP_API int freerdp_channels_process_pending_messages(freerdp* instance);

View File

@ -95,6 +95,8 @@ typedef CHANNEL_ENTRY_POINTS* PCHANNEL_ENTRY_POINTS;
typedef int (FREERDP_CC * PVIRTUALCHANNELENTRY)(PCHANNEL_ENTRY_POINTS pEntryPoints); typedef int (FREERDP_CC * PVIRTUALCHANNELENTRY)(PCHANNEL_ENTRY_POINTS pEntryPoints);
#define FREERDP_CHANNEL_MAGIC_NUMBER 0x46524450
struct _CHANNEL_ENTRY_POINTS_EX struct _CHANNEL_ENTRY_POINTS_EX
{ {
UINT32 cbSize; UINT32 cbSize;
@ -105,9 +107,9 @@ struct _CHANNEL_ENTRY_POINTS_EX
PVIRTUALCHANNELWRITE pVirtualChannelWrite; PVIRTUALCHANNELWRITE pVirtualChannelWrite;
/* Extended Fields */ /* Extended Fields */
UINT32 MagicNumber; /* identifies FreeRDP */
void* pExtendedData; /* extended initial data */ void* pExtendedData; /* extended initial data */
void* pInterface; /* channel callback interface */ void** ppInterface; /* channel callback interface */
PVIRTUALCHANNELEVENTPUSH pVirtualChannelEventPush; PVIRTUALCHANNELEVENTPUSH pVirtualChannelEventPush;
}; };
typedef struct _CHANNEL_ENTRY_POINTS_EX CHANNEL_ENTRY_POINTS_EX; typedef struct _CHANNEL_ENTRY_POINTS_EX CHANNEL_ENTRY_POINTS_EX;