Exemple #1
0
static void xf_cliprdr_send_raw_format_list(xfInfo* xfi)
{
	Atom type;
	uint8* format_data;
	int format, result;
	unsigned long len, bytes_left;
	RDP_CB_FORMAT_LIST_EVENT* event;
	clipboardContext* cb = (clipboardContext*) xfi->clipboard_context;

	result = XGetWindowProperty(xfi->display, cb->root_window,
		cb->property_atom, 0, 3600, 0, XA_STRING,
		&type, &format, &len, &bytes_left, (unsigned char**) &format_data);
	if (result != Success)
	{
		DEBUG_WARN("XGetWindowProperty failed");
		return;
	}
	DEBUG_X11("format=%d len=%d bytes_left=%d", format, (int)len, (int)bytes_left);

	event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR,
		RDP_EVENT_TYPE_CB_FORMAT_LIST, NULL, NULL);

	event->raw_format_data = (uint8*) xmalloc(len);
	memcpy(event->raw_format_data, format_data, len);
	event->raw_format_data_size = len;
	XFree(format_data);

	freerdp_chanman_send_event(cb->chanman, (RDP_EVENT*) event);
}
Exemple #2
0
static void xf_cliprdr_get_requested_targets(xfInfo* xfi)
{
	int num;
	int i, j;
	Atom atom;
	int format;
	uint8* data = NULL;
	unsigned long len, bytes_left;
	RDP_CB_FORMAT_LIST_EVENT* event;
	clipboardContext* cb = (clipboardContext*) xfi->clipboard_context;

	XGetWindowProperty(xfi->display, xfi->window->handle, cb->property_atom,
		0, 200, 0, XA_ATOM,
		&atom, &format, &len, &bytes_left, &data);

	DEBUG_X11("type=%d format=%d len=%d bytes_left=%d",
		(int)atom, format, (int)len, (int)bytes_left);

	if (len > 0)
	{
		event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR,
			RDP_EVENT_TYPE_CB_FORMAT_LIST, NULL, NULL);

		event->formats = (uint32*) xmalloc(sizeof(uint32) * cb->num_format_mappings);
		num = 0;
		for (i = 0; i < len; i++)
		{
			atom = ((Atom*)data)[i];
			DEBUG_X11("atom %d", (int)atom);
			for (j = 0; j < cb->num_format_mappings; j++)
			{
				if (cb->format_mappings[j].target_format == atom)
				{
					DEBUG_X11("found format %d for atom %d",
						cb->format_mappings[j].format_id, (int)atom);
					event->formats[num++] = cb->format_mappings[j].format_id;
					break;
				}
			}
		}
		event->num_formats = num;
		XFree(data);

		freerdp_chanman_send_event(cb->chanman, (RDP_EVENT*) event);
	}
	else
	{
		if (data)
		{
			XFree(data);
		}
		xf_cliprdr_send_null_format_list(xfi);
	}
}
Exemple #3
0
static void xf_cliprdr_send_data_request(xfInfo* xfi, uint32 format)
{
	RDP_CB_DATA_REQUEST_EVENT* event;
	clipboardContext* cb = (clipboardContext*) xfi->clipboard_context;

	event = (RDP_CB_DATA_REQUEST_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR,
		RDP_EVENT_TYPE_CB_DATA_REQUEST, NULL, NULL);
	event->format = format;

	freerdp_chanman_send_event(cb->chanman, (RDP_EVENT*) event);
}
Exemple #4
0
void tf_process_cb_sync_event(rdpChanMan* chanman, freerdp* instance)
{
	RDP_EVENT* event;
	RDP_CB_FORMAT_LIST_EVENT* format_list_event;

	event = freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_FORMAT_LIST, NULL, NULL);

	format_list_event = (RDP_CB_FORMAT_LIST_EVENT*)event;
	format_list_event->num_formats = 0;

	freerdp_chanman_send_event(chanman, event);
}
Exemple #5
0
static void xf_cliprdr_send_data_response(xfInfo* xfi, uint8* data, int size)
{
	RDP_CB_DATA_RESPONSE_EVENT* event;
	clipboardContext* cb = (clipboardContext*) xfi->clipboard_context;

	event = (RDP_CB_DATA_RESPONSE_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR,
		RDP_EVENT_TYPE_CB_DATA_RESPONSE, NULL, NULL);
	event->data = data;
	event->size = size;

	freerdp_chanman_send_event(cb->chanman, (RDP_EVENT*) event);
}
Exemple #6
0
static void xf_cliprdr_send_null_format_list(xfInfo* xfi)
{
	RDP_CB_FORMAT_LIST_EVENT* event;
	clipboardContext* cb = (clipboardContext*) xfi->clipboard_context;

	event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR,
		RDP_EVENT_TYPE_CB_FORMAT_LIST, NULL, NULL);

	event->num_formats = 0;

	freerdp_chanman_send_event(cb->chanman, (RDP_EVENT*) event);
}
Exemple #7
0
static void xf_send_rail_client_event(rdpChanMan* chanman, uint16 event_type, void* param)
{
	RDP_EVENT* out_event = NULL;
	void * payload = NULL;

	payload = rail_clone_order(event_type, param);
	if (payload != NULL)
	{
		out_event = freerdp_event_new(RDP_EVENT_CLASS_RAIL, event_type,
			xf_on_free_rail_client_event, payload);
		freerdp_chanman_send_event(chanman, out_event);
	}
}
Exemple #8
0
//-----------------------------------------------------------------------------
static int send_ui_event2plugin(
	rdpChanMan* chan_man,
	RAIL_UI_EVENT* event
	)
{
	RAIL_UI_EVENT* payload = NULL;
	FRDP_EVENT* out_event = NULL;

	payload = xnew(RAIL_UI_EVENT);
	memset(payload, 0, sizeof(RAIL_UI_EVENT));
	memcpy(payload, event, sizeof(RAIL_UI_EVENT));

	out_event = freerdp_event_new(FRDP_EVENT_TYPE_RAIL_UI_2_VCHANNEL,
			on_free_rail_ui_event,
			payload);

	freerdp_chanman_send_event(chan_man, "rail", out_event);
}
Exemple #9
0
static void xf_cliprdr_send_supported_format_list(xfInfo* xfi)
{
	int i;
	RDP_CB_FORMAT_LIST_EVENT* event;
	clipboardContext* cb = (clipboardContext*) xfi->clipboard_context;

	DEBUG_X11("");

	event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR,
		RDP_EVENT_TYPE_CB_FORMAT_LIST, NULL, NULL);

	event->formats = (uint32*) xmalloc(sizeof(uint32) * cb->num_format_mappings);
	event->num_formats = cb->num_format_mappings;
	for (i = 0; i < cb->num_format_mappings; i++)
	{
		event->formats[i] = cb->format_mappings[i].format_id;
	}

	freerdp_chanman_send_event(cb->chanman, (RDP_EVENT*) event);
}
Exemple #10
0
void test_cliprdr(void)
{
	int i;
	rdpChanMan* chan_man;
	rdpSettings settings = { 0 };
	freerdp instance = { 0 };
	FRDP_EVENT* event;
	FRDP_CB_FORMAT_LIST_EVENT* format_list_event;
	FRDP_CB_DATA_REQUEST_EVENT* data_request_event;
	FRDP_CB_DATA_RESPONSE_EVENT* data_response_event;

	settings.hostname = "testhost";
	instance.settings = &settings;
	instance.SendChannelData = test_rdp_channel_data;

	chan_man = freerdp_chanman_new();

	freerdp_chanman_load_plugin(chan_man, &settings, "../channels/cliprdr/cliprdr.so", NULL);
	freerdp_chanman_pre_connect(chan_man, &instance);
	freerdp_chanman_post_connect(chan_man, &instance);

	/* server sends cliprdr capabilities and monitor ready PDU */
	freerdp_chanman_data(&instance, 0, (char*)test_clip_caps_data, sizeof(test_clip_caps_data) - 1,
		CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_clip_caps_data) - 1);

	freerdp_chanman_data(&instance, 0, (char*)test_monitor_ready_data, sizeof(test_monitor_ready_data) - 1,
		CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_monitor_ready_data) - 1);

	/* cliprdr sends clipboard_sync event to UI */
	while ((event = freerdp_chanman_pop_event(chan_man)) == NULL)
	{
		freerdp_chanman_check_fds(chan_man, &instance);
	}
	printf("Got event %d\n", event->event_type);
	CU_ASSERT(event->event_type == FRDP_EVENT_TYPE_CB_SYNC);
	freerdp_event_free(event);

	/* UI sends format_list event to cliprdr */
	event = freerdp_event_new(FRDP_EVENT_TYPE_CB_FORMAT_LIST, event_process_callback, NULL);
	format_list_event = (FRDP_CB_FORMAT_LIST_EVENT*)event;
	format_list_event->num_formats = 2;
	format_list_event->formats = (uint32*)xmalloc(sizeof(uint32) * 2);
	format_list_event->formats[0] = CB_FORMAT_TEXT;
	format_list_event->formats[1] = CB_FORMAT_HTML;
	event_processed = 0;
	freerdp_chanman_send_event(chan_man, "cliprdr", event);

	/* cliprdr sends format list PDU to server */
	while (!event_processed)
	{
		freerdp_chanman_check_fds(chan_man, &instance);
	}

	/* server sends format list response PDU to cliprdr */
	freerdp_chanman_data(&instance, 0, (char*)test_format_list_response_data, sizeof(test_format_list_response_data) - 1,
		CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_format_list_response_data) - 1);

	/* server sends format list PDU to cliprdr */
	freerdp_chanman_data(&instance, 0, (char*)test_format_list_data, sizeof(test_format_list_data) - 1,
		CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_format_list_data) - 1);

	/* cliprdr sends format_list event to UI */
	while ((event = freerdp_chanman_pop_event(chan_man)) == NULL)
	{
		freerdp_chanman_check_fds(chan_man, &instance);
	}
	printf("Got event %d\n", event->event_type);
	CU_ASSERT(event->event_type == FRDP_EVENT_TYPE_CB_FORMAT_LIST);
	if (event->event_type == FRDP_EVENT_TYPE_CB_FORMAT_LIST)
	{
		format_list_event = (FRDP_CB_FORMAT_LIST_EVENT*)event;
		for (i = 0; i < format_list_event->num_formats; i++)
			printf("Format: 0x%X\n", format_list_event->formats[i]);
	}
	freerdp_event_free(event);

	/* server sends data request PDU to cliprdr */
	freerdp_chanman_data(&instance, 0, (char*)test_data_request_data, sizeof(test_data_request_data) - 1,
		CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_data_request_data) - 1);

	/* cliprdr sends data request event to UI */
	while ((event = freerdp_chanman_pop_event(chan_man)) == NULL)
	{
		freerdp_chanman_check_fds(chan_man, &instance);
	}
	printf("Got event %d\n", event->event_type);
	CU_ASSERT(event->event_type == FRDP_EVENT_TYPE_CB_DATA_REQUEST);
	if (event->event_type == FRDP_EVENT_TYPE_CB_DATA_REQUEST)
	{
		data_request_event = (FRDP_CB_DATA_REQUEST_EVENT*)event;
		printf("Requested format: 0x%X\n", data_request_event->format);
	}
	freerdp_event_free(event);

	/* UI sends data response event to cliprdr */
	event = freerdp_event_new(FRDP_EVENT_TYPE_CB_DATA_RESPONSE, event_process_callback, NULL);
	data_response_event = (FRDP_CB_DATA_RESPONSE_EVENT*)event;
	data_response_event->data = (uint8*)xmalloc(6);
	strcpy((char*)data_response_event->data, "hello");
	data_response_event->size = 6;
	event_processed = 0;
	freerdp_chanman_send_event(chan_man, "cliprdr", event);

	/* cliprdr sends data response PDU to server */
	while (!event_processed)
	{
		freerdp_chanman_check_fds(chan_man, &instance);
	}

	/* UI sends data request event to cliprdr */
	event = freerdp_event_new(FRDP_EVENT_TYPE_CB_DATA_REQUEST, event_process_callback, NULL);
	data_request_event = (FRDP_CB_DATA_REQUEST_EVENT*)event;
	data_request_event->format = CB_FORMAT_UNICODETEXT;
	event_processed = 0;
	freerdp_chanman_send_event(chan_man, "cliprdr", event);

	/* cliprdr sends data request PDU to server */
	while (!event_processed)
	{
		freerdp_chanman_check_fds(chan_man, &instance);
	}

	/* server sends data response PDU to cliprdr */
	freerdp_chanman_data(&instance, 0, (char*)test_data_response_data, sizeof(test_data_response_data) - 1,
		CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_data_response_data) - 1);

	/* cliprdr sends data response event to UI */
	while ((event = freerdp_chanman_pop_event(chan_man)) == NULL)
	{
		freerdp_chanman_check_fds(chan_man, &instance);
	}
	printf("Got event %d\n", event->event_type);
	CU_ASSERT(event->event_type == FRDP_EVENT_TYPE_CB_DATA_RESPONSE);
	if (event->event_type == FRDP_EVENT_TYPE_CB_DATA_RESPONSE)
	{
		data_response_event = (FRDP_CB_DATA_RESPONSE_EVENT*)event;
		printf("Data response size: %d\n", data_response_event->size);
		freerdp_hexdump(data_response_event->data, data_response_event->size);
	}
	freerdp_event_free(event);

	freerdp_chanman_close(chan_man, &instance);
	freerdp_chanman_free(chan_man);
}