2011-07-11 08:04:13 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol client.
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2011-07-13 18:31:26 +04:00
|
|
|
#include <freerdp/utils/memory.h>
|
2011-07-11 08:04:13 +04:00
|
|
|
#include <freerdp/utils/event.h>
|
|
|
|
|
2011-07-11 19:11:03 +04:00
|
|
|
FRDP_EVENT* freerdp_event_new(uint32 event_type, FRDP_EVENT_CALLBACK on_event_free_callback, void* user_data)
|
2011-07-11 08:04:13 +04:00
|
|
|
{
|
|
|
|
FRDP_EVENT* event = NULL;
|
|
|
|
|
|
|
|
switch (event_type)
|
|
|
|
{
|
|
|
|
case FRDP_EVENT_TYPE_DEBUG:
|
2011-07-13 18:23:55 +04:00
|
|
|
event = xnew(FRDP_EVENT);
|
2011-07-11 08:04:13 +04:00
|
|
|
break;
|
|
|
|
case FRDP_EVENT_TYPE_VIDEO_FRAME:
|
2011-07-13 18:23:55 +04:00
|
|
|
event = (FRDP_EVENT*)xnew(FRDP_VIDEO_FRAME_EVENT);
|
2011-07-11 08:04:13 +04:00
|
|
|
break;
|
|
|
|
case FRDP_EVENT_TYPE_REDRAW:
|
2011-07-13 18:23:55 +04:00
|
|
|
event = (FRDP_EVENT*)xnew(FRDP_REDRAW_EVENT);
|
2011-07-11 08:04:13 +04:00
|
|
|
break;
|
2011-07-12 18:03:09 +04:00
|
|
|
case FRDP_EVENT_TYPE_CB_SYNC:
|
2011-07-13 18:23:55 +04:00
|
|
|
event = (FRDP_EVENT*)xnew(FRDP_CB_SYNC_EVENT);
|
2011-07-12 18:03:09 +04:00
|
|
|
break;
|
|
|
|
case FRDP_EVENT_TYPE_CB_FORMAT_LIST:
|
2011-07-13 18:23:55 +04:00
|
|
|
event = (FRDP_EVENT*)xnew(FRDP_CB_FORMAT_LIST_EVENT);
|
2011-07-12 18:03:09 +04:00
|
|
|
break;
|
|
|
|
case FRDP_EVENT_TYPE_CB_DATA_REQUEST:
|
2011-07-13 18:23:55 +04:00
|
|
|
event = (FRDP_EVENT*)xnew(FRDP_CB_DATA_REQUEST_EVENT);
|
2011-07-12 18:03:09 +04:00
|
|
|
break;
|
|
|
|
case FRDP_EVENT_TYPE_CB_DATA_RESPONSE:
|
2011-07-13 18:23:55 +04:00
|
|
|
event = (FRDP_EVENT*)xnew(FRDP_CB_DATA_RESPONSE_EVENT);
|
2011-07-12 18:03:09 +04:00
|
|
|
break;
|
2011-07-11 08:04:13 +04:00
|
|
|
}
|
|
|
|
if (event != NULL)
|
|
|
|
{
|
|
|
|
event->event_type = event_type;
|
2011-07-11 19:11:03 +04:00
|
|
|
event->on_event_free_callback = on_event_free_callback;
|
2011-07-11 08:04:13 +04:00
|
|
|
event->user_data = user_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
|
|
|
void freerdp_event_free(FRDP_EVENT* event)
|
|
|
|
{
|
|
|
|
if (event != NULL)
|
|
|
|
{
|
2011-07-11 19:11:03 +04:00
|
|
|
if (event->on_event_free_callback != NULL)
|
|
|
|
event->on_event_free_callback(event);
|
2011-07-11 08:04:13 +04:00
|
|
|
|
|
|
|
switch (event->event_type)
|
|
|
|
{
|
|
|
|
case FRDP_EVENT_TYPE_VIDEO_FRAME:
|
|
|
|
{
|
|
|
|
FRDP_VIDEO_FRAME_EVENT* vevent = (FRDP_VIDEO_FRAME_EVENT*)event;
|
|
|
|
|
|
|
|
xfree(vevent->frame_data);
|
|
|
|
xfree(vevent->visible_rects);
|
|
|
|
}
|
|
|
|
break;
|
2011-07-12 18:03:09 +04:00
|
|
|
case FRDP_EVENT_TYPE_CB_FORMAT_LIST:
|
|
|
|
{
|
|
|
|
FRDP_CB_FORMAT_LIST_EVENT* cb_event = (FRDP_CB_FORMAT_LIST_EVENT*)event;
|
|
|
|
|
|
|
|
xfree(cb_event->formats);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FRDP_EVENT_TYPE_CB_DATA_RESPONSE:
|
|
|
|
{
|
|
|
|
FRDP_CB_DATA_RESPONSE_EVENT* cb_event = (FRDP_CB_DATA_RESPONSE_EVENT*)event;
|
|
|
|
|
|
|
|
xfree(cb_event->data);
|
|
|
|
}
|
|
|
|
break;
|
2011-07-11 08:04:13 +04:00
|
|
|
}
|
|
|
|
xfree(event);
|
|
|
|
}
|
|
|
|
}
|