Пример #1
0
static int read_touch_event(RdpeiServerContext *context, wStream *s)
{
	UINT32 frameCount;
	int i, ret;
	RDPINPUT_TOUCH_EVENT *event = &context->priv->touchEvent;
	RDPINPUT_TOUCH_FRAME *frame;

	ret = -1;
	if (!rdpei_read_4byte_unsigned(s, &event->encodeTime) || !rdpei_read_2byte_unsigned(s, &frameCount))
		return -1;

	event->frameCount = frameCount;
	event->frames = frame = calloc(event->frameCount, sizeof(RDPINPUT_TOUCH_FRAME));
	if (!event->frames)
		return -1;

	for (i = 0; i < frameCount; i++, frame++)
	{
		if (read_touch_frame(context, s, frame) < 0)
		{
			event->frameCount = i;
			goto out_cleanup;
		}
	}

	if (context->onTouchEvent)
		context->onTouchEvent(context, event);

	ret = 0;

out_cleanup:
	touch_event_reset(event);
	return ret;
}
Пример #2
0
/**
 * Function description
 *
 * @return 0 on success, otherwise a Win32 error code
 */
static UINT read_touch_event(RdpeiServerContext *context, wStream *s)
{
	UINT32 frameCount;
	int i;
	RDPINPUT_TOUCH_EVENT *event = &context->priv->touchEvent;
	RDPINPUT_TOUCH_FRAME *frame;
	UINT error = CHANNEL_RC_OK;

	if (!rdpei_read_4byte_unsigned(s, &event->encodeTime) || !rdpei_read_2byte_unsigned(s, &frameCount))
	{
		WLog_ERR(TAG, "rdpei_read_ failed!");
		return ERROR_INTERNAL_ERROR;
	}

	event->frameCount = frameCount;
	event->frames = frame = calloc(event->frameCount, sizeof(RDPINPUT_TOUCH_FRAME));
	if (!event->frames)
	{
		WLog_ERR(TAG, "calloc failed!");
		return CHANNEL_RC_NO_MEMORY;
	}

	for (i = 0; i < frameCount; i++, frame++)
	{
		if ((error = read_touch_frame(context, s, frame)))
		{
			WLog_ERR(TAG, "read_touch_contact_data failed with error %lu!", error);
			event->frameCount = i;
			goto out_cleanup;
		}
	}


	IFCALLRET(context->onTouchEvent, error, context, event);
	if (error)
		WLog_ERR(TAG, "context->onTouchEvent failed with error %lu", error);

out_cleanup:
	touch_event_reset(event);
	return error;
}