libfreerdp-client: propagate and export pInterface extended channel pointer
This commit is contained in:
parent
2f02ad3b68
commit
608f00b7df
@ -67,7 +67,8 @@
|
||||
* The current channel manager reference passes from VirtualChannelEntry to
|
||||
* VirtualChannelInit for the pInitHandle.
|
||||
*/
|
||||
extern rdpChannels* g_init_channels;
|
||||
|
||||
CHANNEL_INIT_DATA g_ChannelInitData;
|
||||
|
||||
static wArrayList* g_ChannelsList = NULL;
|
||||
|
||||
@ -138,7 +139,7 @@ rdpChannels* freerdp_channels_find_by_instance(freerdp* instance)
|
||||
return (found) ? channels : NULL;
|
||||
}
|
||||
|
||||
CHANNEL_OPEN_DATA* freerdp_channels_find_channel_data_by_name(rdpChannels* channels, const char* channel_name, int* pindex)
|
||||
CHANNEL_OPEN_DATA* freerdp_channels_find_channel_open_data_by_name(rdpChannels* channels, const char* channel_name)
|
||||
{
|
||||
int index;
|
||||
CHANNEL_OPEN_DATA* pChannelOpenData;
|
||||
@ -148,12 +149,7 @@ CHANNEL_OPEN_DATA* freerdp_channels_find_channel_data_by_name(rdpChannels* chann
|
||||
pChannelOpenData = &channels->openDataList[index];
|
||||
|
||||
if (strcmp(channel_name, pChannelOpenData->name) == 0)
|
||||
{
|
||||
if (pindex != 0)
|
||||
*pindex = index;
|
||||
|
||||
return pChannelOpenData;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -390,6 +386,7 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v
|
||||
ep.pVirtualChannelClose = FreeRDP_VirtualChannelClose;
|
||||
ep.pVirtualChannelWrite = FreeRDP_VirtualChannelWrite;
|
||||
|
||||
ep.pInterface = NULL;
|
||||
ep.pExtendedData = data;
|
||||
ep.pVirtualChannelEventPush = FreeRDP_VirtualChannelEventPush;
|
||||
|
||||
@ -399,9 +396,11 @@ int freerdp_channels_client_load(rdpChannels* channels, rdpSettings* settings, v
|
||||
|
||||
WaitForSingleObject(g_mutex_init, INFINITE);
|
||||
|
||||
g_init_channels = channels;
|
||||
g_ChannelInitData.channels = channels;
|
||||
g_ChannelInitData.pInterface = ep.pInterface;
|
||||
status = pChannelClientData->entry((PCHANNEL_ENTRY_POINTS) &ep);
|
||||
g_init_channels = NULL;
|
||||
g_ChannelInitData.channels = NULL;
|
||||
g_ChannelInitData.pInterface = NULL;
|
||||
|
||||
ReleaseMutex(g_mutex_init);
|
||||
|
||||
@ -471,12 +470,12 @@ int freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance)
|
||||
{
|
||||
int index;
|
||||
char* hostname;
|
||||
int hostname_len;
|
||||
int hostnameLength;
|
||||
CHANNEL_CLIENT_DATA* pChannelClientData;
|
||||
|
||||
channels->is_connected = 1;
|
||||
hostname = instance->settings->ServerHostname;
|
||||
hostname_len = strlen(hostname);
|
||||
hostnameLength = strlen(hostname);
|
||||
|
||||
DEBUG_CHANNELS("hostname [%s] channels->num_libs [%d]", hostname, channels->clientDataCount);
|
||||
|
||||
@ -484,8 +483,8 @@ int freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance)
|
||||
{
|
||||
pChannelClientData = &channels->clientDataList[index];
|
||||
|
||||
if (pChannelClientData->pChannelInitEventProc != 0)
|
||||
pChannelClientData->pChannelInitEventProc(pChannelClientData->pInitHandle, CHANNEL_EVENT_CONNECTED, hostname, hostname_len);
|
||||
if (pChannelClientData->pChannelInitEventProc)
|
||||
pChannelClientData->pChannelInitEventProc(pChannelClientData->pInitHandle, CHANNEL_EVENT_CONNECTED, hostname, hostnameLength);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -518,7 +517,7 @@ int freerdp_channels_data(freerdp* instance, int channel_id, void* data, int dat
|
||||
return 1;
|
||||
}
|
||||
|
||||
pChannelOpenData = freerdp_channels_find_channel_data_by_name(channels, channel->Name, &index);
|
||||
pChannelOpenData = freerdp_channels_find_channel_open_data_by_name(channels, channel->Name);
|
||||
|
||||
if (!pChannelOpenData)
|
||||
{
|
||||
@ -526,7 +525,7 @@ int freerdp_channels_data(freerdp* instance, int channel_id, void* data, int dat
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (pChannelOpenData->pChannelOpenEventProc != 0)
|
||||
if (pChannelOpenData->pChannelOpenEventProc)
|
||||
{
|
||||
pChannelOpenData->pChannelOpenEventProc(pChannelOpenData->OpenHandle,
|
||||
CHANNEL_EVENT_DATA_RECEIVED, data, data_size, total_size, flags);
|
||||
@ -543,7 +542,6 @@ int freerdp_channels_data(freerdp* instance, int channel_id, void* data, int dat
|
||||
*/
|
||||
FREERDP_API int freerdp_channels_send_event(rdpChannels* channels, wMessage* event)
|
||||
{
|
||||
int index;
|
||||
const char* name = NULL;
|
||||
CHANNEL_OPEN_DATA* pChannelOpenData;
|
||||
|
||||
@ -573,7 +571,7 @@ FREERDP_API int freerdp_channels_send_event(rdpChannels* channels, wMessage* eve
|
||||
return 1;
|
||||
}
|
||||
|
||||
pChannelOpenData = freerdp_channels_find_channel_data_by_name(channels, name, &index);
|
||||
pChannelOpenData = freerdp_channels_find_channel_open_data_by_name(channels, name);
|
||||
|
||||
if (!pChannelOpenData)
|
||||
{
|
||||
@ -661,6 +659,17 @@ BOOL freerdp_channels_get_fds(rdpChannels* channels, freerdp* instance, void** r
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void* freerdp_channels_get_static_channel_interface(freerdp* instance, const char* name)
|
||||
{
|
||||
rdpChannels* channels;
|
||||
CHANNEL_OPEN_DATA* pChannelOpenData;
|
||||
|
||||
channels = instance->context->channels;
|
||||
pChannelOpenData = freerdp_channels_find_channel_open_data_by_name(channels, name);
|
||||
|
||||
return pChannelOpenData->pInterface;
|
||||
}
|
||||
|
||||
HANDLE freerdp_channels_get_event_handle(freerdp* instance)
|
||||
{
|
||||
HANDLE event = NULL;
|
||||
|
@ -53,7 +53,8 @@ struct rdp_channel_open_data
|
||||
char name[8];
|
||||
int OpenHandle;
|
||||
int options;
|
||||
int flags; /* 0 nothing 1 init 2 open */
|
||||
int flags;
|
||||
void* pInterface;
|
||||
PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc;
|
||||
};
|
||||
typedef struct rdp_channel_open_data CHANNEL_OPEN_DATA;
|
||||
@ -76,6 +77,7 @@ typedef struct _CHANNEL_OPEN_EVENT CHANNEL_OPEN_EVENT;
|
||||
struct rdp_channel_init_data
|
||||
{
|
||||
rdpChannels* channels;
|
||||
void* pInterface;
|
||||
};
|
||||
typedef struct rdp_channel_init_data CHANNEL_INIT_DATA;
|
||||
|
||||
@ -110,6 +112,6 @@ struct rdp_channels
|
||||
#endif
|
||||
|
||||
rdpChannels* freerdp_channels_find_by_open_handle(int open_handle, int* pindex);
|
||||
CHANNEL_OPEN_DATA* freerdp_channels_find_channel_data_by_name(rdpChannels* channels, const char* channel_name, int* pindex);
|
||||
CHANNEL_OPEN_DATA* freerdp_channels_find_channel_open_data_by_name(rdpChannels* channels, const char* channel_name);
|
||||
|
||||
#endif /* FREERDP_PRIVATE_CLIENT_CHANNELS */
|
||||
|
@ -25,21 +25,18 @@
|
||||
|
||||
#include "init.h"
|
||||
|
||||
rdpChannels* g_init_channels;
|
||||
extern int g_open_handle_sequence;
|
||||
|
||||
/**
|
||||
* must be called by same thread that calls freerdp_chanman_load_plugin
|
||||
* according to MS docs. only called from main thread
|
||||
*/
|
||||
extern CHANNEL_INIT_DATA g_ChannelInitData;
|
||||
|
||||
UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel,
|
||||
int channelCount, UINT32 versionRequested, PCHANNEL_INIT_EVENT_FN pChannelInitEventProc)
|
||||
{
|
||||
int index;
|
||||
void* pInterface;
|
||||
rdpChannel* channel;
|
||||
rdpChannels* channels;
|
||||
PCHANNEL_DEF pChannelDef;
|
||||
CHANNEL_INIT_DATA* pChannelInitData;
|
||||
CHANNEL_OPEN_DATA* pChannelOpenData;
|
||||
CHANNEL_CLIENT_DATA* pChannelClientData;
|
||||
|
||||
@ -49,13 +46,16 @@ UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel,
|
||||
return CHANNEL_RC_BAD_INIT_HANDLE;
|
||||
}
|
||||
|
||||
channels = g_init_channels;
|
||||
|
||||
channels->initDataList[channels->initDataCount].channels = channels;
|
||||
*ppInitHandle = &channels->initDataList[channels->initDataCount];
|
||||
channels = g_ChannelInitData.channels;
|
||||
pInterface = g_ChannelInitData.pInterface;
|
||||
|
||||
pChannelInitData = &(channels->initDataList[channels->initDataCount]);
|
||||
*ppInitHandle = pChannelInitData;
|
||||
channels->initDataCount++;
|
||||
|
||||
pChannelInitData->channels = channels;
|
||||
pChannelInitData->pInterface = pInterface;
|
||||
|
||||
DEBUG_CHANNELS("enter");
|
||||
|
||||
if (!channels->can_call_init)
|
||||
@ -91,7 +91,7 @@ UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel,
|
||||
{
|
||||
pChannelDef = &pChannel[index];
|
||||
|
||||
if (freerdp_channels_find_channel_data_by_name(channels, pChannelDef->name, 0) != 0)
|
||||
if (freerdp_channels_find_channel_open_data_by_name(channels, pChannelDef->name) != 0)
|
||||
{
|
||||
DEBUG_CHANNELS("error channel already used");
|
||||
return CHANNEL_RC_BAD_CHANNEL;
|
||||
@ -114,7 +114,7 @@ UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel,
|
||||
strncpy(pChannelOpenData->name, pChannelDef->name, CHANNEL_NAME_LEN);
|
||||
pChannelOpenData->options = pChannelDef->options;
|
||||
|
||||
if (channels->settings->ChannelCount < 16)
|
||||
if (channels->settings->ChannelCount < CHANNEL_MAX_COUNT)
|
||||
{
|
||||
channel = channels->settings->ChannelDefArray + channels->settings->ChannelCount;
|
||||
strncpy(channel->Name, pChannelDef->name, 7);
|
||||
@ -123,7 +123,7 @@ UINT32 FreeRDP_VirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF pChannel,
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_CHANNELS("warning more than 16 channels");
|
||||
DEBUG_CHANNELS("warning more than %d channels", CHANNEL_MAX_COUNT);
|
||||
}
|
||||
|
||||
channels->openDataCount++;
|
||||
|
@ -22,13 +22,16 @@
|
||||
UINT32 FreeRDP_VirtualChannelOpen(void* pInitHandle, UINT32* pOpenHandle,
|
||||
char* pChannelName, PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc)
|
||||
{
|
||||
int index;
|
||||
void* pInterface;
|
||||
rdpChannels* channels;
|
||||
CHANNEL_INIT_DATA* pChannelInitData;
|
||||
CHANNEL_OPEN_DATA* pChannelOpenData;
|
||||
|
||||
DEBUG_CHANNELS("enter");
|
||||
|
||||
channels = ((CHANNEL_INIT_DATA*) pInitHandle)->channels;
|
||||
pChannelInitData = (CHANNEL_INIT_DATA*) pInitHandle;
|
||||
channels = pChannelInitData->channels;
|
||||
pInterface = pChannelInitData->pInterface;
|
||||
|
||||
if (!pOpenHandle)
|
||||
{
|
||||
@ -48,7 +51,7 @@ UINT32 FreeRDP_VirtualChannelOpen(void* pInitHandle, UINT32* pOpenHandle,
|
||||
return CHANNEL_RC_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
pChannelOpenData = freerdp_channels_find_channel_data_by_name(channels, pChannelName, &index);
|
||||
pChannelOpenData = freerdp_channels_find_channel_open_data_by_name(channels, pChannelName);
|
||||
|
||||
if (!pChannelOpenData)
|
||||
{
|
||||
@ -63,6 +66,7 @@ UINT32 FreeRDP_VirtualChannelOpen(void* pInitHandle, UINT32* pOpenHandle,
|
||||
}
|
||||
|
||||
pChannelOpenData->flags = 2; /* open */
|
||||
pChannelOpenData->pInterface = pInterface;
|
||||
pChannelOpenData->pChannelOpenEventProc = pChannelOpenEventProc;
|
||||
*pOpenHandle = pChannelOpenData->OpenHandle;
|
||||
|
||||
|
@ -48,6 +48,8 @@ FREERDP_API BOOL freerdp_channels_check_fds(rdpChannels* channels, freerdp* inst
|
||||
FREERDP_API wMessage* freerdp_channels_pop_event(rdpChannels* channels);
|
||||
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 HANDLE freerdp_channels_get_event_handle(freerdp* instance);
|
||||
FREERDP_API int freerdp_channels_process_pending_messages(freerdp* instance);
|
||||
|
||||
|
@ -35,9 +35,10 @@
|
||||
|
||||
struct _CHANNEL_DEF
|
||||
{
|
||||
char name[CHANNEL_NAME_LEN + 1];
|
||||
char name[8];
|
||||
UINT32 options;
|
||||
};
|
||||
|
||||
typedef struct _CHANNEL_DEF CHANNEL_DEF;
|
||||
typedef CHANNEL_DEF* PCHANNEL_DEF;
|
||||
typedef CHANNEL_DEF** PPCHANNEL_DEF;
|
||||
|
Loading…
Reference in New Issue
Block a user