2011-07-11 08:04:13 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-07-11 08:04:13 +04:00
|
|
|
* Events
|
|
|
|
*
|
|
|
|
* Copyright 2011 Vic Lee
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:09:01 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2011-07-11 08:04:13 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2012-08-15 01:09:01 +04:00
|
|
|
|
2012-11-22 05:21:08 +04:00
|
|
|
#include <winpr/crt.h>
|
|
|
|
|
2013-03-29 02:29:57 +04:00
|
|
|
#include <freerdp/message.h>
|
2011-07-11 08:04:13 +04:00
|
|
|
#include <freerdp/utils/event.h>
|
2012-10-09 04:33:58 +04:00
|
|
|
#include <freerdp/client/cliprdr.h>
|
|
|
|
#include <freerdp/client/tsmf.h>
|
2011-08-11 09:33:13 +04:00
|
|
|
#include <freerdp/rail.h>
|
2011-07-11 08:04:13 +04:00
|
|
|
|
2013-03-29 05:13:56 +04:00
|
|
|
static wMessage* freerdp_cliprdr_event_new(UINT16 event_type)
|
2011-07-11 08:04:13 +04:00
|
|
|
{
|
2013-09-05 17:40:09 +04:00
|
|
|
union
|
|
|
|
{
|
|
|
|
wMessage* m;
|
|
|
|
void *v;
|
|
|
|
} event;
|
2011-07-11 08:04:13 +04:00
|
|
|
|
2013-09-05 17:40:09 +04:00
|
|
|
event.m = NULL;
|
2011-07-11 08:04:13 +04:00
|
|
|
switch (event_type)
|
|
|
|
{
|
2013-03-29 02:29:57 +04:00
|
|
|
case CliprdrChannel_MonitorReady:
|
2013-09-05 17:40:09 +04:00
|
|
|
event.v = malloc(sizeof(RDP_CB_MONITOR_READY_EVENT));
|
|
|
|
ZeroMemory(event.v, sizeof(RDP_CB_MONITOR_READY_EVENT));
|
|
|
|
event.m->id = MakeMessageId(CliprdrChannel, MonitorReady);
|
2011-07-12 18:03:09 +04:00
|
|
|
break;
|
2012-11-22 05:21:08 +04:00
|
|
|
|
2013-03-29 02:29:57 +04:00
|
|
|
case CliprdrChannel_FormatList:
|
2013-09-05 17:40:09 +04:00
|
|
|
event.v = malloc(sizeof(RDP_CB_FORMAT_LIST_EVENT));
|
|
|
|
ZeroMemory(event.v, sizeof(RDP_CB_FORMAT_LIST_EVENT));
|
|
|
|
event.m->id = MakeMessageId(CliprdrChannel, FormatList);
|
2011-07-12 18:03:09 +04:00
|
|
|
break;
|
2012-11-22 05:21:08 +04:00
|
|
|
|
2013-03-29 02:29:57 +04:00
|
|
|
case CliprdrChannel_DataRequest:
|
2013-09-05 17:40:09 +04:00
|
|
|
event.v = malloc(sizeof(RDP_CB_DATA_REQUEST_EVENT));
|
|
|
|
ZeroMemory(event.v, sizeof(RDP_CB_DATA_REQUEST_EVENT));
|
|
|
|
event.m->id = MakeMessageId(CliprdrChannel, DataRequest);
|
2011-07-12 18:03:09 +04:00
|
|
|
break;
|
2012-11-22 05:21:08 +04:00
|
|
|
|
2013-03-29 02:29:57 +04:00
|
|
|
case CliprdrChannel_DataResponse:
|
2013-09-05 17:40:09 +04:00
|
|
|
event.v = malloc(sizeof(RDP_CB_DATA_RESPONSE_EVENT));
|
|
|
|
ZeroMemory(event.v, sizeof(RDP_CB_DATA_RESPONSE_EVENT));
|
|
|
|
event.m->id = MakeMessageId(CliprdrChannel, DataResponse);
|
2011-07-12 18:03:09 +04:00
|
|
|
break;
|
2013-11-05 06:52:17 +04:00
|
|
|
|
|
|
|
case CliprdrChannel_ClipCaps:
|
|
|
|
event.v = malloc(sizeof(RDP_CB_CLIP_CAPS));
|
|
|
|
ZeroMemory(event.v, sizeof(RDP_CB_CLIP_CAPS));
|
|
|
|
event.m->id = MakeMessageId(CliprdrChannel, ClipCaps);
|
|
|
|
break;
|
2011-08-11 07:07:03 +04:00
|
|
|
}
|
|
|
|
|
2013-09-05 17:40:09 +04:00
|
|
|
return event.v;
|
2011-08-11 07:07:03 +04:00
|
|
|
}
|
|
|
|
|
2013-03-29 05:13:56 +04:00
|
|
|
static wMessage* freerdp_tsmf_event_new(UINT16 event_type)
|
2011-08-11 07:07:03 +04:00
|
|
|
{
|
2013-09-05 17:40:09 +04:00
|
|
|
union
|
|
|
|
{
|
|
|
|
void *v;
|
|
|
|
wMessage* m;
|
|
|
|
} event;
|
2011-08-11 07:07:03 +04:00
|
|
|
|
2013-09-05 17:40:09 +04:00
|
|
|
event.m = NULL;
|
2011-08-11 07:07:03 +04:00
|
|
|
switch (event_type)
|
|
|
|
{
|
2013-03-29 03:33:31 +04:00
|
|
|
case TsmfChannel_VideoFrame:
|
2013-09-05 17:40:09 +04:00
|
|
|
event.v = malloc(sizeof(RDP_VIDEO_FRAME_EVENT));
|
|
|
|
ZeroMemory(event.v, sizeof(RDP_VIDEO_FRAME_EVENT));
|
|
|
|
event.m->id = MakeMessageId(TsmfChannel, VideoFrame);
|
2011-08-11 07:07:03 +04:00
|
|
|
break;
|
2012-11-22 05:21:08 +04:00
|
|
|
|
2013-03-29 03:33:31 +04:00
|
|
|
case TsmfChannel_Redraw:
|
2013-09-05 17:40:09 +04:00
|
|
|
event.v = malloc(sizeof(RDP_REDRAW_EVENT));
|
|
|
|
ZeroMemory(event.v, sizeof(RDP_REDRAW_EVENT));
|
|
|
|
event.m->id = MakeMessageId(TsmfChannel, Redraw);
|
2011-08-11 07:07:03 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-09-05 17:40:09 +04:00
|
|
|
return event.v;
|
2011-08-11 07:07:03 +04:00
|
|
|
}
|
|
|
|
|
2013-03-29 05:13:56 +04:00
|
|
|
static wMessage* freerdp_rail_event_new(UINT16 event_type)
|
2011-08-11 07:07:03 +04:00
|
|
|
{
|
2013-03-29 05:13:56 +04:00
|
|
|
wMessage* event = NULL;
|
2012-11-22 05:21:08 +04:00
|
|
|
|
2013-03-29 05:13:56 +04:00
|
|
|
event = (wMessage*) malloc(sizeof(wMessage));
|
|
|
|
ZeroMemory(event, sizeof(wMessage));
|
2012-11-22 05:21:08 +04:00
|
|
|
|
2011-08-18 05:33:22 +04:00
|
|
|
return event;
|
2011-08-11 07:07:03 +04:00
|
|
|
}
|
|
|
|
|
2013-03-29 05:13:56 +04:00
|
|
|
wMessage* freerdp_event_new(UINT16 event_class, UINT16 event_type,
|
|
|
|
MESSAGE_FREE_FN on_event_free_callback, void* user_data)
|
2011-08-11 07:07:03 +04:00
|
|
|
{
|
2013-03-29 05:13:56 +04:00
|
|
|
wMessage* event = NULL;
|
2011-08-11 07:07:03 +04:00
|
|
|
|
|
|
|
switch (event_class)
|
|
|
|
{
|
2013-03-29 03:33:31 +04:00
|
|
|
case DebugChannel_Class:
|
2013-03-29 05:13:56 +04:00
|
|
|
event = (wMessage*) malloc(sizeof(wMessage));
|
|
|
|
ZeroMemory(event, sizeof(wMessage));
|
2011-08-10 01:42:10 +04:00
|
|
|
break;
|
2012-11-22 05:21:08 +04:00
|
|
|
|
2013-03-29 02:29:57 +04:00
|
|
|
case CliprdrChannel_Class:
|
2011-08-11 07:07:03 +04:00
|
|
|
event = freerdp_cliprdr_event_new(event_type);
|
|
|
|
break;
|
2012-11-22 05:21:08 +04:00
|
|
|
|
2013-03-29 03:33:31 +04:00
|
|
|
case TsmfChannel_Class:
|
2011-08-11 07:07:03 +04:00
|
|
|
event = freerdp_tsmf_event_new(event_type);
|
|
|
|
break;
|
2012-11-22 05:21:08 +04:00
|
|
|
|
2013-03-29 03:33:31 +04:00
|
|
|
case RailChannel_Class:
|
2011-08-11 07:07:03 +04:00
|
|
|
event = freerdp_rail_event_new(event_type);
|
|
|
|
break;
|
2011-07-11 08:04:13 +04:00
|
|
|
}
|
2011-08-18 05:33:22 +04:00
|
|
|
|
2013-02-21 11:56:57 +04:00
|
|
|
if (event)
|
2011-07-11 08:04:13 +04:00
|
|
|
{
|
2013-03-29 05:13:56 +04:00
|
|
|
event->wParam = user_data;
|
|
|
|
event->Free = (void*) on_event_free_callback;
|
2013-03-29 02:29:57 +04:00
|
|
|
event->id = GetMessageId(event_class, event_type);
|
2011-07-11 08:04:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
2013-03-29 05:13:56 +04:00
|
|
|
static void freerdp_cliprdr_event_free(wMessage* event)
|
2011-08-11 07:07:03 +04:00
|
|
|
{
|
2013-03-29 02:29:57 +04:00
|
|
|
switch (GetMessageType(event->id))
|
2011-08-11 07:07:03 +04:00
|
|
|
{
|
2013-03-29 02:29:57 +04:00
|
|
|
case CliprdrChannel_FormatList:
|
2011-08-11 07:07:03 +04:00
|
|
|
{
|
2013-03-29 02:29:57 +04:00
|
|
|
RDP_CB_FORMAT_LIST_EVENT* cb_event = (RDP_CB_FORMAT_LIST_EVENT*) event;
|
2012-10-09 07:21:26 +04:00
|
|
|
free(cb_event->formats);
|
|
|
|
free(cb_event->raw_format_data);
|
2011-08-11 07:07:03 +04:00
|
|
|
}
|
|
|
|
break;
|
2013-03-29 02:29:57 +04:00
|
|
|
|
|
|
|
case CliprdrChannel_DataResponse:
|
2011-08-11 07:07:03 +04:00
|
|
|
{
|
2013-03-29 02:29:57 +04:00
|
|
|
RDP_CB_DATA_RESPONSE_EVENT* cb_event = (RDP_CB_DATA_RESPONSE_EVENT*) event;
|
2012-10-09 07:21:26 +04:00
|
|
|
free(cb_event->data);
|
2011-08-11 07:07:03 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-29 05:13:56 +04:00
|
|
|
static void freerdp_tsmf_event_free(wMessage* event)
|
2011-08-11 07:07:03 +04:00
|
|
|
{
|
2013-03-29 03:33:31 +04:00
|
|
|
switch (GetMessageType(event->id))
|
2011-08-11 07:07:03 +04:00
|
|
|
{
|
2013-03-29 03:33:31 +04:00
|
|
|
case TsmfChannel_VideoFrame:
|
2011-08-11 07:07:03 +04:00
|
|
|
{
|
2011-08-18 01:28:26 +04:00
|
|
|
RDP_VIDEO_FRAME_EVENT* vevent = (RDP_VIDEO_FRAME_EVENT*)event;
|
2012-10-09 07:21:26 +04:00
|
|
|
free(vevent->frame_data);
|
|
|
|
free(vevent->visible_rects);
|
2011-08-11 07:07:03 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-29 05:13:56 +04:00
|
|
|
static void freerdp_rail_event_free(wMessage* event)
|
2011-08-11 07:07:03 +04:00
|
|
|
{
|
2013-03-29 02:29:57 +04:00
|
|
|
|
2011-08-11 07:07:03 +04:00
|
|
|
}
|
|
|
|
|
2013-03-29 05:13:56 +04:00
|
|
|
void freerdp_event_free(wMessage* event)
|
2011-07-11 08:04:13 +04:00
|
|
|
{
|
2013-02-21 11:56:57 +04:00
|
|
|
if (event)
|
2011-07-11 08:04:13 +04:00
|
|
|
{
|
2013-03-29 05:13:56 +04:00
|
|
|
if (event->Free)
|
|
|
|
event->Free(event);
|
2011-07-11 08:04:13 +04:00
|
|
|
|
2013-03-29 02:29:57 +04:00
|
|
|
switch (GetMessageClass(event->id))
|
2011-07-11 08:04:13 +04:00
|
|
|
{
|
2013-03-29 02:29:57 +04:00
|
|
|
case CliprdrChannel_Class:
|
2011-08-11 07:07:03 +04:00
|
|
|
freerdp_cliprdr_event_free(event);
|
2011-07-11 08:04:13 +04:00
|
|
|
break;
|
2013-03-29 02:29:57 +04:00
|
|
|
|
2013-03-29 03:33:31 +04:00
|
|
|
case TsmfChannel_Class:
|
2011-08-11 07:07:03 +04:00
|
|
|
freerdp_tsmf_event_free(event);
|
2011-07-12 18:03:09 +04:00
|
|
|
break;
|
2013-03-29 02:29:57 +04:00
|
|
|
|
2013-03-29 03:33:31 +04:00
|
|
|
case RailChannel_Class:
|
2011-08-11 07:07:03 +04:00
|
|
|
freerdp_rail_event_free(event);
|
2011-07-12 18:03:09 +04:00
|
|
|
break;
|
2011-07-11 08:04:13 +04:00
|
|
|
}
|
2013-02-21 11:56:57 +04:00
|
|
|
|
2012-10-09 07:21:26 +04:00
|
|
|
free(event);
|
2011-07-11 08:04:13 +04:00
|
|
|
}
|
|
|
|
}
|