示例#1
0
int cliprdr_send_request_filecontents(cliprdrContext *cliprdr, void *streamid,
		int index, int flag, DWORD positionhigh, DWORD positionlow, ULONG nreq)
{
	RDP_CB_FILECONTENTS_REQUEST_EVENT *cliprdr_event;
	int ret;

	cliprdr_event = (RDP_CB_FILECONTENTS_REQUEST_EVENT *)freerdp_event_new(CliprdrChannel_Class,
			CliprdrChannel_FilecontentsRequest, NULL, NULL);

	if (!cliprdr_event)
		return -1;

	cliprdr_event->streamId      = (UINT32)streamid;
	cliprdr_event->lindex        = index;
	cliprdr_event->dwFlags       = flag;
	cliprdr_event->nPositionLow  = positionlow;
	cliprdr_event->nPositionHigh = positionhigh;
	cliprdr_event->cbRequested   = nreq;
	cliprdr_event->clipDataId    = 0;

	ret = freerdp_channels_send_event(cliprdr->channels, (wMessage *)cliprdr_event);

	if (ret != 0)
		return -1;

	WaitForSingleObject(cliprdr->req_fevent, INFINITE);
	ResetEvent(cliprdr->req_fevent);

	return 0;
}
示例#2
0
static void xf_cliprdr_send_raw_format_list(xfInfo* xfi)
{
	Atom type;
	BYTE* format_data;
	int format, result;
	unsigned long length, 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, &length, &bytes_left, (BYTE**) &format_data);

	if (result != Success)
	{
		DEBUG_WARN("XGetWindowProperty failed");
		return;
	}
	DEBUG_X11_CLIPRDR("format=%d len=%d bytes_left=%d", format, (int) length, (int) bytes_left);

	event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(CliprdrChannel_Class,
			CliprdrChannel_FormatList, NULL, NULL);

	event->raw_format_data = (BYTE*) malloc(length);
	CopyMemory(event->raw_format_data, format_data, length);
	event->raw_format_data_size = length;
	XFree(format_data);

	freerdp_channels_send_event(cb->channels, (wMessage*) event);
}
示例#3
0
int cliprdr_send_data_request(cliprdrContext *cliprdr, UINT32 format)
{
	RDP_CB_DATA_REQUEST_EVENT *cliprdr_event;
	int ret;

	cliprdr_event = (RDP_CB_DATA_REQUEST_EVENT *)freerdp_event_new(CliprdrChannel_Class,
			CliprdrChannel_DataRequest, NULL, NULL);

	if (!cliprdr_event)
		return -1;

	cliprdr_event->format = get_remote_format_id(cliprdr, format);
	if (cliprdr_event->format == 0)
		return -1;

	ret = freerdp_channels_send_event(cliprdr->channels, (wMessage *)cliprdr_event);

	if (ret != 0)
		return -1;

	WaitForSingleObject(cliprdr->response_data_event, INFINITE);
	ResetEvent(cliprdr->response_data_event);

	return 0;
}
示例#4
0
void test_channels(void)
{
	rdpChannels* chan_man;
	rdpSettings settings = { 0 };
	freerdp instance = { 0 };
	RDP_EVENT* event;

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

	chan_man = freerdp_channels_new();

	freerdp_channels_load_plugin(chan_man, &settings, "../channels/rdpdbg/rdpdbg.so", NULL);
	freerdp_channels_pre_connect(chan_man, &instance);
	freerdp_channels_post_connect(chan_man, &instance);

	freerdp_channels_data(&instance, 0, "testdata", 8, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 8);
	freerdp_channels_data(&instance, 0, "testdata1", 9, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 9);
	freerdp_channels_data(&instance, 0, "testdata11", 10, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 10);
	freerdp_channels_data(&instance, 0, "testdata111", 11, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 11);

	event = freerdp_event_new(RDP_EVENT_CLASS_DEBUG, 0, NULL, NULL);
	freerdp_channels_send_event(chan_man, event);

	while ((event = freerdp_channels_pop_event(chan_man)) == NULL)
	{
		freerdp_channels_check_fds(chan_man, &instance);
	}
	printf("responded event_type %d\n", event->event_type);
	freerdp_event_free(event);

	freerdp_channels_close(chan_man, &instance);
	freerdp_channels_free(chan_man);
}
示例#5
0
void remmina_rdp_cliprdr_request_data(GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, RemminaProtocolWidget* gp)
{
	GdkAtom target;
	gpointer data;
	RDP_CB_DATA_REQUEST_EVENT* event;
	rfContext* rfi = GET_DATA(gp);

	target = gtk_selection_data_get_target(selection_data);
	rfi->format = remmina_rdp_cliprdr_get_format_from_gdkatom(target);
	rfi->clipboard_queue = g_async_queue_new();

	/* Request Clipboard data of the server */
	event = (RDP_CB_DATA_REQUEST_EVENT*)
		freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_DataRequest, NULL, NULL);
	event->format = rfi->format;
	freerdp_channels_send_event(rfi->instance->context->channels, (wMessage*) event);

	data = g_async_queue_timeout_pop(rfi->clipboard_queue, 1000000);
	if (data != NULL)
	{
		if (info == CB_FORMAT_PNG || info == CB_FORMAT_DIB || info == CB_FORMAT_JPEG)
		{
			gtk_selection_data_set_pixbuf(selection_data, data);
			g_object_unref(data);
		}
		else
		{
			gtk_selection_data_set_text(selection_data, data, -1);
		}
	}
}
示例#6
0
void urdp_ukbrdr_send_ime_preedit_string(urdp_context* context, const char* data, const long size) {
	RDP_EVENT *event = malloc(sizeof(RDP_EVENT));
	ukbrdrEvent *ukbrdr_ev = malloc(sizeof(ukbrdrEvent));
	struct ukb_header *ukbrdr_msg = malloc(sizeof(struct ukb_header) + size + 2);
	char *string = (char*) (ukbrdr_msg+1); /* Points to the byte following the structure */

	/* Generate Protocol message */
	memset(ukbrdr_msg, 0, sizeof(struct ukb_header) + size + 2);
	ukbrdr_msg->type = UKB_PUSH_COMPOSITION;
	ukbrdr_msg->flags = 0;
	ukbrdr_msg->len = size + 2;
	memcpy(string, data, size);

	/* Put the message in an ukbrdr event structure */
	ukbrdr_ev->size = sizeof(struct ukb_header) + size + 2;
	ukbrdr_ev->data = (char*) ukbrdr_msg;

	/* Put the ukbrdr event in an RDP event structure */
	event->event_class = RDP_EVENT_CLASS_UKBRDR;
	event->event_type = 0;
	event->on_event_free_callback = NULL;
	event->user_data = ukbrdr_ev;

	freerdp_channels_send_event(context->context.channels, (RDP_EVENT*) event);
}
示例#7
0
static void xf_cliprdr_get_requested_targets(xfInfo* xfi)
{
	int num;
	int i, j;
	Atom atom;
	int format;
	BYTE* data = NULL;
	unsigned long length, bytes_left;
	RDP_CB_FORMAT_LIST_EVENT* event;
	clipboardContext* cb = (clipboardContext*) xfi->clipboard_context;

	XGetWindowProperty(xfi->display, xfi->drawable, cb->property_atom,
		0, 200, 0, XA_ATOM, &atom, &format, &length, &bytes_left, &data);

	DEBUG_X11_CLIPRDR("type=%d format=%d length=%d bytes_left=%d",
		(int) atom, format, (int) length, (int) bytes_left);

	if (length > 0)
	{
		event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(CliprdrChannel_Class,
				CliprdrChannel_FormatList, NULL, NULL);

		event->formats = (UINT32*) malloc(sizeof(UINT32) * cb->num_format_mappings);
		num = 0;

		for (i = 0; i < length; 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_channels_send_event(cb->channels, (wMessage*) event);
	}
	else
	{
		if (data)
			XFree(data);

		xf_cliprdr_send_null_format_list(xfi);
	}
}
示例#8
0
static void android_cliprdr_send_data_request(clipboardContext* cb, UINT32 format)
{
	RDP_CB_DATA_REQUEST_EVENT* event;

	event = (RDP_CB_DATA_REQUEST_EVENT*) freerdp_event_new(CliprdrChannel_Class,
		CliprdrChannel_DataRequest, NULL, NULL);

	event->format = format;

	freerdp_channels_send_event(cb->channels, (wMessage*) event);
}
示例#9
0
static void android_cliprdr_send_null_format_list(clipboardContext* cb)
{
	RDP_CB_FORMAT_LIST_EVENT* event;

	event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(CliprdrChannel_Class,
		CliprdrChannel_FormatList, NULL, NULL);

	event->num_formats = 0;

	freerdp_channels_send_event(cb->channels, (wMessage*) event);
}
示例#10
0
static void android_cliprdr_send_data_response(clipboardContext* cb, BYTE* data, int size)
{
	RDP_CB_DATA_RESPONSE_EVENT* event;

	event = (RDP_CB_DATA_RESPONSE_EVENT*) freerdp_event_new(CliprdrChannel_Class,
		CliprdrChannel_DataResponse, NULL, NULL);

	event->data = data;
	event->size = size;

	freerdp_channels_send_event(cb->channels, (wMessage*) event);
}
示例#11
0
void tf_process_cb_monitor_ready_event(rdpChannels* channels, freerdp* instance)
{
	wMessage* event;
	RDP_CB_FORMAT_LIST_EVENT* format_list_event;

	event = freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_FormatList, NULL, NULL);

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

	freerdp_channels_send_event(channels, event);
}
示例#12
0
文件: freerdp.c 项目: felfert/FreeRDP
void tf_process_cb_monitor_ready_event(rdpChannels* channels, 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_channels_send_event(channels, event);
}
示例#13
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_channels_send_event(cb->channels, (RDP_EVENT*) event);
}
示例#14
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_channels_send_event(cb->channels, (RDP_EVENT*) event);
}
示例#15
0
static void xf_send_rail_client_event(rdpChannels* channels, 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_channels_send_event(channels, out_event);
	}
}
示例#16
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_channels_send_event(cb->channels, (RDP_EVENT*) event);
}
示例#17
0
static void xf_send_rail_client_event(rdpChannels* channels, UINT16 event_type, void* param)
{
	wMessage* out_event = NULL;
	void* payload = NULL;
	payload = rail_clone_order(event_type, param);

	if (payload != NULL)
	{
		out_event = freerdp_event_new(RailChannel_Class, event_type,
									  xf_on_free_rail_client_event, payload);
		freerdp_channels_send_event(channels, out_event);
	}
}
示例#18
0
int cliprdr_send_tempdir(cliprdrContext *cliprdr)
{
	RDP_CB_TEMPDIR_EVENT *cliprdr_event;

	cliprdr_event = (RDP_CB_TEMPDIR_EVENT *)freerdp_event_new(CliprdrChannel_Class,
			CliprdrChannel_TemporaryDirectory, NULL, NULL);

	if (!cliprdr_event)
		return -1;

	GetEnvironmentVariableW(L"TEMP", (LPWSTR)cliprdr_event->dirname, 260);

	return freerdp_channels_send_event(cliprdr->channels, (wMessage *)cliprdr_event);
}
示例#19
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;

	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_channels_send_event(cb->channels, (RDP_EVENT*) event);
}
示例#20
0
//-----------------------------------------------------------------------------
static void send_ui_event2plugin(
	rdpChannels* chan_man,
	uint16 event_type,
	void * data
	)
{
	RDP_EVENT* out_event = NULL;
	void * payload = NULL;

	payload = rail_clone_order(event_type, data);
	if (payload != NULL)
	{
		out_event = freerdp_event_new(RDP_EVENT_CLASS_RAIL, event_type,
				test_on_free_rail_client_event, payload);
		freerdp_channels_send_event(chan_man, out_event);
	}
}
示例#21
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;

	event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(CliprdrChannel_Class,
			CliprdrChannel_FormatList, NULL, NULL);

	event->formats = (UINT32*) malloc(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_channels_send_event(cb->channels, (wMessage*) event);
}
示例#22
0
static void android_cliprdr_send_supported_format_list(clipboardContext* cb)
{
	int i;
	RDP_CB_FORMAT_LIST_EVENT* event;

	event = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(CliprdrChannel_Class,
		CliprdrChannel_FormatList, NULL, NULL);

	event->formats = (UINT32*) malloc(sizeof(UINT32) * cb->android_num_formats);
	event->num_formats = cb->android_num_formats;

	for (i = 0; i < cb->android_num_formats; i++)
	{
		event->formats[i] = cb->android_formats[i];
	}

	freerdp_channels_send_event(cb->channels, (wMessage*) event);
}
示例#23
0
void guac_rdp_process_cb_data_request(guac_client* client,
        RDP_CB_DATA_REQUEST_EVENT* event) {

    rdpChannels* channels = 
        ((rdp_guac_client_data*) client->data)->rdp_inst->context->channels;

    /* If text requested, send clipboard text contents */
    if (event->format == CB_FORMAT_TEXT) {

        /* Get clipboard data */
        const char* clipboard =
            ((rdp_guac_client_data*) client->data)->clipboard;

        /* Create new data response */
        RDP_CB_DATA_RESPONSE_EVENT* data_response =
            (RDP_CB_DATA_RESPONSE_EVENT*) freerdp_event_new(
                    CliprdrChannel_Class,
                    CliprdrChannel_DataResponse,
                    NULL, NULL);

        /* Set data and length */
        if (clipboard != NULL) {
            data_response->data = (UINT8*) strdup(clipboard);
            data_response->size = strlen(clipboard) + 1;
        }
        else {
            data_response->data = (UINT8*) strdup("");
            data_response->size = 1;
        }

        /* Send response */
        freerdp_channels_send_event(channels, (wMessage*) data_response);

    }

    /* Otherwise ... failure */
    else
        guac_client_log_error(client, 
                "Server requested unsupported clipboard data type");

}
示例#24
0
int cliprdr_send_unlock(cliprdrContext *cliprdr)
{
	RDP_CB_UNLOCK_CLIPDATA_EVENT *cliprdr_event;
	int ret;

	if ((cliprdr->capabilities & CB_CAN_LOCK_CLIPDATA) == 1) {
		cliprdr_event = (RDP_CB_UNLOCK_CLIPDATA_EVENT *)freerdp_event_new(CliprdrChannel_Class,
			CliprdrChannel_UnLockClipdata, NULL, NULL);

		if (!cliprdr_event)
			return -1;

		cliprdr_event->clipDataId = 0;

		ret = freerdp_channels_send_event(cliprdr->channels, (wMessage *)cliprdr_event);

		if (ret != 0)
			return -1;
	}

	return 0;
}
示例#25
0
int cliprdr_send_response_filecontents(cliprdrContext *cliprdr, UINT32 streamid, UINT32 size, BYTE *data)
{
	RDP_CB_FILECONTENTS_RESPONSE_EVENT *cliprdr_event;
	int ret;

	cliprdr_event = (RDP_CB_FILECONTENTS_RESPONSE_EVENT *)freerdp_event_new(CliprdrChannel_Class,
			CliprdrChannel_FilecontentsResponse, NULL, NULL);

	if (!cliprdr_event)
		return -1;

	cliprdr_event->streamId = streamid;
	cliprdr_event->size = size;
	cliprdr_event->data = data;

	ret = freerdp_channels_send_event(cliprdr->channels, (wMessage *)cliprdr_event);

	if (ret != 0)
		return -1;

	return 0;
}
示例#26
0
int remmina_rdp_cliprdr_send_format_list(RemminaProtocolWidget* gp, RemminaPluginRdpUiObject* ui)
{
	GtkClipboard* clipboard;
	GdkAtom* targets;
	gboolean result = 0;
	gint count;
	RDP_CB_FORMAT_LIST_EVENT* event;

	rfContext* rfi = GET_DATA(gp);

	if (rfi->clipboard_wait)
	{
		rfi->clipboard_wait = FALSE;
		return 0;
	}

	/* Lets see if we have something in our clipboard */
	clipboard = gtk_widget_get_clipboard(rfi->drawing_area, GDK_SELECTION_CLIPBOARD);
	if (clipboard)
	{
		result = gtk_clipboard_wait_for_targets(clipboard, &targets, &count);
	}


	event = (RDP_CB_FORMAT_LIST_EVENT*)
		freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_FormatList, NULL, NULL);

	if (result)
	{
		remmina_rdp_cliprdr_get_target_types(&event->formats, &event->num_formats, targets, count);
		g_free(targets);
	}
	else
		event->num_formats = 0;
	

	return freerdp_channels_send_event(rfi->instance->context->channels, (wMessage*) event);
}
示例#27
0
void urdp_ukbrdr_send_ime_preedit_string_stop(urdp_context* context) {
	RDP_EVENT *event = malloc(sizeof(RDP_EVENT));
	ukbrdrEvent *ukbrdr_ev = malloc(sizeof(ukbrdrEvent));
	struct ukb_header *ukbrdr_msg = malloc(sizeof(struct ukb_header));
	
	/* Generate Protocol message */
	memset(ukbrdr_msg, 0, sizeof(struct ukb_header));
	ukbrdr_msg->type = UKB_STOP_COMPOSITION;
	ukbrdr_msg->flags = 0;
	ukbrdr_msg->len = 0;
	
	/* Put the message in an ukbrdr event structure */
	ukbrdr_ev->size = sizeof(struct ukb_header);
	ukbrdr_ev->data = (char*) ukbrdr_msg;
	
	/* Put the ukbrdr event in an RDP event structure */
	event->event_class = RDP_EVENT_CLASS_UKBRDR;
	event->event_type = 0;
	event->on_event_free_callback = NULL;
	event->user_data = ukbrdr_ev;
	
	freerdp_channels_send_event(context->context.channels, (RDP_EVENT*) event);
}
示例#28
0
int guac_rdp_clipboard_end_handler(guac_client* client, guac_stream* stream) {

    rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data;
    rdpChannels* channels = client_data->rdp_inst->context->channels;

    RDP_CB_FORMAT_LIST_EVENT* format_list =
        (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new(
            CliprdrChannel_Class,
            CliprdrChannel_FormatList,
            NULL, NULL);

    /* Terminate clipboard data with NULL */
    guac_common_clipboard_append(client_data->clipboard, "", 1);

    /* Notify server that text data is now available */
    format_list->formats = (UINT32*) malloc(sizeof(UINT32));
    format_list->formats[0] = CB_FORMAT_TEXT;
    format_list->formats[1] = CB_FORMAT_UNICODETEXT;
    format_list->num_formats = 2;

    freerdp_channels_send_event(channels, (wMessage*) format_list);

    return 0;
}
示例#29
0
void guac_rdp_process_cb_format_list(guac_client* client,
        RDP_CB_FORMAT_LIST_EVENT* event) {

    rdpChannels* channels = 
        ((rdp_guac_client_data*) client->data)->rdp_inst->context->channels;

    /* Received notification of available data */

    int i;
    for (i=0; i<event->num_formats; i++) {

        /* If plain text available, request it */
        if (event->formats[i] == CB_FORMAT_TEXT) {

            /* Create new data request */
            RDP_CB_DATA_REQUEST_EVENT* data_request =
                (RDP_CB_DATA_REQUEST_EVENT*) freerdp_event_new(
                        CliprdrChannel_Class,
                        CliprdrChannel_DataRequest,
                        NULL, NULL);

            /* We want plain text */
            data_request->format = CB_FORMAT_TEXT;

            /* Send request */
            freerdp_channels_send_event(channels, (wMessage*) data_request);
            return;

        }

    }

    /* Otherwise, no supported data available */
    guac_client_log_info(client, "Ignoring unsupported clipboard data");

}
示例#30
0
void test_cliprdr(void)
{
	int i;
	rdpChannels* channels;
	rdpSettings settings = { 0 };
	freerdp instance = { 0 };
	RDP_EVENT* event;
	RDP_CB_FORMAT_LIST_EVENT* format_list_event;
	RDP_CB_DATA_REQUEST_EVENT* data_request_event;
	RDP_CB_DATA_RESPONSE_EVENT* data_response_event;

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

	channels = freerdp_channels_new();

	freerdp_channels_load_plugin(channels, &settings, "../channels/cliprdr/cliprdr.so", NULL);
	freerdp_channels_pre_connect(channels, &instance);
	freerdp_channels_post_connect(channels, &instance);

	/* server sends cliprdr capabilities and monitor ready PDU */
	freerdp_channels_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_channels_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_channels_pop_event(channels)) == NULL)
	{
		freerdp_channels_check_fds(channels, &instance);
	}
	printf("Got event %d\n", event->event_type);
	CU_ASSERT(event->event_type == RDP_EVENT_TYPE_CB_MONITOR_READY);
	freerdp_event_free(event);

	/* UI sends format_list event to cliprdr */
	event = freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_FORMAT_LIST, event_process_callback, NULL);
	format_list_event = (RDP_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_channels_send_event(channels, event);

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

	/* server sends format list response PDU to cliprdr */
	freerdp_channels_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_channels_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_channels_pop_event(channels)) == NULL)
	{
		freerdp_channels_check_fds(channels, &instance);
	}
	printf("Got event %d\n", event->event_type);
	CU_ASSERT(event->event_type == RDP_EVENT_TYPE_CB_FORMAT_LIST);
	if (event->event_type == RDP_EVENT_TYPE_CB_FORMAT_LIST)
	{
		format_list_event = (RDP_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_channels_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_channels_pop_event(channels)) == NULL)
	{
		freerdp_channels_check_fds(channels, &instance);
	}
	printf("Got event %d\n", event->event_type);
	CU_ASSERT(event->event_type == RDP_EVENT_TYPE_CB_DATA_REQUEST);
	if (event->event_type == RDP_EVENT_TYPE_CB_DATA_REQUEST)
	{
		data_request_event = (RDP_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(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_DATA_RESPONSE, event_process_callback, NULL);
	data_response_event = (RDP_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_channels_send_event(channels, event);

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

	/* UI sends data request event to cliprdr */
	event = freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_DATA_REQUEST, event_process_callback, NULL);
	data_request_event = (RDP_CB_DATA_REQUEST_EVENT*)event;
	data_request_event->format = CB_FORMAT_UNICODETEXT;
	event_processed = 0;
	freerdp_channels_send_event(channels, event);

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

	/* server sends data response PDU to cliprdr */
	freerdp_channels_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_channels_pop_event(channels)) == NULL)
	{
		freerdp_channels_check_fds(channels, &instance);
	}
	printf("Got event %d\n", event->event_type);
	CU_ASSERT(event->event_type == RDP_EVENT_TYPE_CB_DATA_RESPONSE);
	if (event->event_type == RDP_EVENT_TYPE_CB_DATA_RESPONSE)
	{
		data_response_event = (RDP_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_channels_close(channels, &instance);
	freerdp_channels_free(channels);
}