Updated plugins to use new svc_plugin and OnDataReceived API.

This commit is contained in:
Armin Novak 2014-06-11 14:42:32 +02:00
parent 49f360521c
commit 15ce8c0552
13 changed files with 42 additions and 70 deletions

View File

@ -312,34 +312,31 @@ static int audin_process_format_change(IWTSVirtualChannelCallback* pChannelCallb
return 0;
}
static int audin_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, UINT32 cbSize, BYTE* pBuffer)
static int audin_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream *data)
{
int error;
wStream* s;
BYTE MessageId;
s = Stream_New(pBuffer, cbSize);
Stream_Read_UINT8(s, MessageId);
Stream_Read_UINT8(data, MessageId);
DEBUG_DVC("MessageId=0x%x", MessageId);
switch (MessageId)
{
case MSG_SNDIN_VERSION:
error = audin_process_version(pChannelCallback, s);
error = audin_process_version(pChannelCallback, data);
break;
case MSG_SNDIN_FORMATS:
error = audin_process_formats(pChannelCallback, s);
error = audin_process_formats(pChannelCallback, data);
break;
case MSG_SNDIN_OPEN:
error = audin_process_open(pChannelCallback, s);
error = audin_process_open(pChannelCallback, data);
break;
case MSG_SNDIN_FORMATCHANGE:
error = audin_process_format_change(pChannelCallback, s);
error = audin_process_format_change(pChannelCallback, data);
break;
default:
@ -348,8 +345,6 @@ static int audin_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
break;
}
Stream_Free(s, FALSE);
return error;
}

View File

@ -382,8 +382,6 @@ static void cliprdr_process_receive(rdpSvcPlugin* plugin, wStream* s)
DEBUG_WARN("unknown msgType %d", msgType);
break;
}
Stream_Free(s, TRUE);
}
static void cliprdr_process_filecontents_request_event(cliprdrPlugin* plugin, RDP_CB_FILECONTENTS_REQUEST_EVENT * event)
@ -506,6 +504,7 @@ static void cliprdr_process_event(rdpSvcPlugin* plugin, wMessage* event)
static void cliprdr_process_terminate(rdpSvcPlugin* plugin)
{
svc_plugin_terminate(plugin);
free(plugin);
}

View File

@ -201,17 +201,12 @@ int disp_recv_pdu(DISP_CHANNEL_CALLBACK* callback, wStream* s)
return 0;
}
static int disp_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, UINT32 cbSize, BYTE* pBuffer)
static int disp_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream *data)
{
wStream* s;
int status = 0;
DISP_CHANNEL_CALLBACK* callback = (DISP_CHANNEL_CALLBACK*) pChannelCallback;
s = Stream_New(pBuffer, cbSize);
status = disp_recv_pdu(callback, s);
Stream_Free(s, FALSE);
status = disp_recv_pdu(callback, data);
return status;
}

View File

@ -266,8 +266,7 @@ static int drdynvc_process_data_first(drdynvcPlugin* drdynvc, int Sp, int cbChId
if (status)
return status;
return dvcman_receive_channel_data(drdynvc->channel_mgr, ChannelId,
Stream_Pointer(s), Stream_GetRemainingLength(s));
return dvcman_receive_channel_data(drdynvc->channel_mgr, ChannelId, s);
}
static int drdynvc_process_data(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStream* s)
@ -277,8 +276,7 @@ static int drdynvc_process_data(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStr
ChannelId = drdynvc_read_variable_uint(s, cbChId);
DEBUG_DVC("ChannelId=%d", ChannelId);
return dvcman_receive_channel_data(drdynvc->channel_mgr, ChannelId,
Stream_Pointer(s), Stream_GetRemainingLength(s));
return dvcman_receive_channel_data(drdynvc->channel_mgr, ChannelId, s);
}
static int drdynvc_process_close_request(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStream* s)
@ -350,8 +348,6 @@ static void drdynvc_process_receive(rdpSvcPlugin* plugin, wStream* s)
DEBUG_WARN("unknown drdynvc cmd 0x%x", Cmd);
break;
}
Stream_Free(s, TRUE);
}
static void drdynvc_process_connect(rdpSvcPlugin* plugin)
@ -391,6 +387,7 @@ static void drdynvc_process_terminate(rdpSvcPlugin* plugin)
if (drdynvc->channel_mgr)
dvcman_free(drdynvc->channel_mgr);
svc_plugin_terminate(plugin);
free(drdynvc);
}
@ -413,8 +410,7 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
DrdynvcClientContext* context;
CHANNEL_ENTRY_POINTS_FREERDP* pEntryPointsEx;
_p = (drdynvcPlugin*) malloc(sizeof(drdynvcPlugin));
ZeroMemory(_p, sizeof(drdynvcPlugin));
_p = (drdynvcPlugin*) calloc(1, sizeof(drdynvcPlugin));
_p->plugin.channel_def.options =
CHANNEL_OPTION_INITIALIZED |

View File

@ -195,8 +195,7 @@ IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin)
{
DVCMAN* dvcman;
dvcman = (DVCMAN*) malloc(sizeof(DVCMAN));
ZeroMemory(dvcman, sizeof(DVCMAN));
dvcman = (DVCMAN*) calloc(1, sizeof(DVCMAN));
dvcman->iface.CreateListener = dvcman_create_listener;
dvcman->iface.PushEvent = dvcman_push_event;
@ -278,6 +277,7 @@ void dvcman_free(IWTSVirtualChannelManager* pChannelMgr)
pPlugin->Terminated(pPlugin);
}
StreamPool_Free(dvcman->pool);
free(dvcman);
}
@ -402,7 +402,7 @@ int dvcman_close_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelI
if (channel->dvc_data)
{
Stream_Free(channel->dvc_data, TRUE);
Stream_Release(channel->dvc_data);
channel->dvc_data = NULL;
}
@ -435,17 +435,19 @@ int dvcman_receive_channel_data_first(IWTSVirtualChannelManager* pChannelMgr, UI
}
if (channel->dvc_data)
Stream_Free(channel->dvc_data, TRUE);
Stream_Release(channel->dvc_data);
channel->dvc_data = Stream_New(NULL, length);
channel->dvc_data = StreamPool_Take(channel->dvcman->pool, length);
Stream_AddRef(channel->dvc_data);
return 0;
}
int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelId, BYTE* data, UINT32 data_size)
int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelId, wStream *data)
{
int error = 0;
DVCMAN_CHANNEL* channel;
UINT32 data_size = Stream_GetRemainingLength(data);
channel = (DVCMAN_CHANNEL*) dvcman_find_channel_by_id(pChannelMgr, ChannelId);
@ -461,24 +463,23 @@ int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 C
if (Stream_GetPosition(channel->dvc_data) + data_size > (UINT32) Stream_Capacity(channel->dvc_data))
{
DEBUG_WARN("data exceeding declared length!");
Stream_Free(channel->dvc_data, TRUE);
Stream_Release(channel->dvc_data);
channel->dvc_data = NULL;
return 1;
}
Stream_Write(channel->dvc_data, data, data_size);
Stream_Write(channel->dvc_data, Stream_Pointer(data), data_size);
if (((size_t) Stream_GetPosition(channel->dvc_data)) >= Stream_Capacity(channel->dvc_data))
{
error = channel->channel_callback->OnDataReceived(channel->channel_callback,
Stream_Capacity(channel->dvc_data), Stream_Buffer(channel->dvc_data));
Stream_Free(channel->dvc_data, TRUE);
error = channel->channel_callback->OnDataReceived(channel->channel_callback, channel->dvc_data);
Stream_Release(channel->dvc_data);
channel->dvc_data = NULL;
}
}
else
{
error = channel->channel_callback->OnDataReceived(channel->channel_callback, data_size, data);
error = channel->channel_callback->OnDataReceived(channel->channel_callback, data);
}
return error;

View File

@ -43,6 +43,7 @@ struct _DVCMAN
int num_listeners;
wArrayList* channels;
wStreamPool* pool;
};
typedef struct _DVCMAN DVCMAN;
@ -89,7 +90,7 @@ int dvcman_init(IWTSVirtualChannelManager* pChannelMgr);
int dvcman_create_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelId, const char* ChannelName);
int dvcman_close_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelId);
int dvcman_receive_channel_data_first(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelId, UINT32 length);
int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelId, BYTE* data, UINT32 data_size);
int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelId, wStream *data);
void* dvcman_get_channel_interface_by_name(IWTSVirtualChannelManager* pChannelMgr, const char* ChannelName);

View File

@ -61,10 +61,12 @@ struct _ECHO_PLUGIN
ECHO_LISTENER_CALLBACK* listener_callback;
};
static int echo_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, UINT32 cbSize, BYTE* pBuffer)
static int echo_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream *data)
{
int error;
ECHO_CHANNEL_CALLBACK* callback = (ECHO_CHANNEL_CALLBACK*) pChannelCallback;
BYTE *pBuffer = Stream_Pointer(data);
UINT32 cbSize = Stream_GetRemainingLength(data);
#ifdef WITH_DEBUG_DVC
int i = 0;

View File

@ -95,13 +95,13 @@ static void rail_process_terminate(rdpSvcPlugin* plugin)
railPlugin* rail = (railPlugin*) plugin;
WLog_Print(rail->log, WLOG_DEBUG, "Terminate");
svc_plugin_terminate(plugin);
}
static void rail_process_receive(rdpSvcPlugin* plugin, wStream* s)
{
railPlugin* rail = (railPlugin*) plugin;
rail_order_recv(rail, s);
Stream_Free(s, TRUE);
}
static void rail_process_addin_args(rdpRailOrder* railOrder, rdpSettings* settings)
@ -507,8 +507,7 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
RailClientContext* context;
CHANNEL_ENTRY_POINTS_FREERDP* pEntryPointsEx;
rail = (railPlugin*) malloc(sizeof(railPlugin));
ZeroMemory(rail, sizeof(railPlugin));
rail = (railPlugin*) calloc(1, sizeof(railPlugin));
rail->plugin.channel_def.options =
CHANNEL_OPTION_INITIALIZED |

View File

@ -434,17 +434,12 @@ int rdpei_recv_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s)
return 0;
}
static int rdpei_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, UINT32 cbSize, BYTE* pBuffer)
static int rdpei_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream *data)
{
wStream* s;
int status = 0;
RDPEI_CHANNEL_CALLBACK* callback = (RDPEI_CHANNEL_CALLBACK*) pChannelCallback;
s = Stream_New(pBuffer, cbSize);
status = rdpei_recv_pdu(callback, s);
Stream_Free(s, FALSE);
status = rdpei_recv_pdu(callback, data);
return status;
}

View File

@ -75,19 +75,14 @@ int rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
return 0;
}
static int rdpgfx_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, UINT32 cbSize, BYTE* pBuffer)
static int rdpgfx_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream *data)
{
wStream* s;
int status = 0;
RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*) pChannelCallback;
fprintf(stderr, "RdpGfxOnDataReceived\n");
s = Stream_New(pBuffer, cbSize);
status = rdpgfx_recv_pdu(callback, s);
Stream_Free(s, FALSE);
status = rdpgfx_recv_pdu(callback, data);
return status;
}

View File

@ -78,8 +78,6 @@ static void sample_process_receive(rdpSvcPlugin* plugin, wStream* data_in)
svc_plugin_send(plugin, data_out);
}
Stream_Free(data_in, TRUE);
}
static void sample_process_connect(rdpSvcPlugin* plugin)
@ -113,7 +111,7 @@ static void sample_process_terminate(rdpSvcPlugin* plugin)
return;
/* put your cleanup here */
svc_plugin_terminate(plugin);
free(plugin);
}
@ -123,8 +121,7 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
{
samplePlugin* _p;
_p = (samplePlugin*) malloc(sizeof(samplePlugin));
ZeroMemory(_p, sizeof(samplePlugin));
_p = (samplePlugin*) calloc(1, sizeof(samplePlugin));
_p->plugin.channel_def.options =
CHANNEL_OPTION_INITIALIZED |

View File

@ -117,8 +117,7 @@ BOOL tsmf_push_event(IWTSVirtualChannelCallback* pChannelCallback, wMessage* eve
}
static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
UINT32 cbSize,
BYTE* pBuffer)
wStream *data)
{
int length;
wStream* input;
@ -129,6 +128,7 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
UINT32 FunctionId;
UINT32 InterfaceId;
TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*) pChannelCallback;
UINT32 cbSize = Stream_GetRemainingLength(data);
/* 2.2.1 Shared Message Header (SHARED_MSG_HEADER) */
if (cbSize < 12)
@ -137,7 +137,7 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
return 1;
}
input = Stream_New((BYTE*) pBuffer, cbSize);
input = data;
output = Stream_New(NULL, 256);
Stream_Seek(output, 8);
@ -286,7 +286,6 @@ static int tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
break;
}
Stream_Free(input, FALSE);
input = NULL;
ifman.input = NULL;

View File

@ -169,8 +169,6 @@ BOOL freerdp_connect(freerdp* instance)
update_recv_surfcmds(update, Stream_Length(s) , s);
update->EndPaint(update->context);
Stream_Release(s);
StreamPool_Return(rdp->transport->ReceivePool, s);
}
pcap_close(update->pcap_rfx);