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; }
void cliprdr_process_format_list_response(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags) { CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr); /* http://msdn.microsoft.com/en-us/library/hh872154.aspx */ if (context->custom) { CLIPRDR_FORMAT_LIST_RESPONSE formatListResponse; formatListResponse.msgType = CB_FORMAT_LIST_RESPONSE; formatListResponse.msgFlags = msgFlags; formatListResponse.dataLen = dataLen; if (context->ServerFormatListResponse) context->ServerFormatListResponse(context, &formatListResponse); } else { if ((msgFlags & CB_RESPONSE_FAIL) != 0) { /* In case of an error the clipboard will not be synchronized with the server. * Post this event to restart format negotiation and data transfer. */ wMessage* event = freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_MonitorReady, NULL, NULL); svc_plugin_send_event((rdpSvcPlugin*) cliprdr, event); } } }
void cliprdr_process_format_data_request(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags) { CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr); if (context->custom) { CLIPRDR_FORMAT_DATA_REQUEST formatDataRequest; formatDataRequest.msgType = CB_FORMAT_DATA_REQUEST; formatDataRequest.msgFlags = msgFlags; formatDataRequest.dataLen = dataLen; Stream_Read_UINT32(s, formatDataRequest.requestedFormatId); /* requestedFormatId (4 bytes) */ if (context->ServerFormatDataRequest) context->ServerFormatDataRequest(context, &formatDataRequest); } else { RDP_CB_DATA_REQUEST_EVENT* cb_event; cb_event = (RDP_CB_DATA_REQUEST_EVENT*) freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_DataRequest, NULL, NULL); Stream_Read_UINT32(s, cb_event->format); svc_plugin_send_event((rdpSvcPlugin*) cliprdr, (wMessage*) cb_event); } }
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); } } }
static void tsmf_presentation_restore_last_video_frame(TSMF_PRESENTATION* presentation) { RDP_REDRAW_EVENT* revent; if (presentation->last_width && presentation->last_height) { revent = (RDP_REDRAW_EVENT*) freerdp_event_new(TsmfChannel_Class, TsmfChannel_Redraw, NULL, NULL); revent->x = presentation->last_x; revent->y = presentation->last_y; revent->width = presentation->last_width; revent->height = presentation->last_height; if (!tsmf_push_event(presentation->channel_callback, (wMessage*) revent)) { freerdp_event_free((wMessage*) revent); } presentation->last_x = 0; presentation->last_y = 0; presentation->last_width = 0; presentation->last_height = 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); }
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); }
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); }
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; }
static void cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr, wStream* s, UINT16 length, UINT16 flags) { CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr); if (context->custom) { CLIPRDR_MONITOR_READY monitorReady; monitorReady.msgType = CB_MONITOR_READY; monitorReady.msgFlags = flags; monitorReady.dataLen = length; if (context->MonitorReady) context->MonitorReady(context, &monitorReady); } else { RDP_CB_MONITOR_READY_EVENT* event; if (cliprdr->received_caps) cliprdr_send_clip_caps(cliprdr); event = (RDP_CB_MONITOR_READY_EVENT*) freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_MonitorReady, NULL, NULL); svc_plugin_send_event((rdpSvcPlugin*) cliprdr, (wMessage*) event); } }
static void cliprdr_process_general_capability(cliprdrPlugin* cliprdr, wStream* s) { UINT32 version; UINT32 generalFlags; RDP_CB_CLIP_CAPS *caps_event; Stream_Read_UINT32(s, version); /* version (4 bytes) */ Stream_Read_UINT32(s, generalFlags); /* generalFlags (4 bytes) */ DEBUG_CLIPRDR("Version: %d", version); #ifdef WITH_DEBUG_CLIPRDR cliprdr_print_general_capability_flags(generalFlags); #endif caps_event = (RDP_CB_CLIP_CAPS *)freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_ClipCaps, NULL, NULL); caps_event->capabilities = generalFlags; if (generalFlags & CB_USE_LONG_FORMAT_NAMES) cliprdr->use_long_format_names = TRUE; if (generalFlags & CB_STREAM_FILECLIP_ENABLED) cliprdr->stream_fileclip_enabled = TRUE; if (generalFlags & CB_FILECLIP_NO_FILE_PATHS) cliprdr->fileclip_no_file_paths = TRUE; if (generalFlags & CB_CAN_LOCK_CLIPDATA) cliprdr->can_lock_clipdata = TRUE; cliprdr->received_caps = TRUE; svc_plugin_send_event((rdpSvcPlugin *)cliprdr, (wMessage *)caps_event); }
void cliprdr_process_format_list(cliprdrPlugin* cliprdr, STREAM* data_in, uint32 dataLen) { FRDP_CB_FORMAT_LIST_EVENT* cb_event; uint32 format; int num_formats; int supported; int i; cb_event = (FRDP_CB_FORMAT_LIST_EVENT*)freerdp_event_new(FRDP_EVENT_CLASS_CLIPRDR, FRDP_EVENT_TYPE_CB_FORMAT_LIST, NULL, NULL); num_formats = dataLen / 36; cb_event->formats = (uint32*)xmalloc(sizeof(uint32) * num_formats); cb_event->num_formats = 0; if (num_formats * 36 != dataLen) DEBUG_WARN("dataLen %d not devided by 36!", dataLen); for (i = 0; i < num_formats; i++) { stream_read_uint32(data_in, format); supported = 1; switch (format) { case CB_FORMAT_TEXT: case CB_FORMAT_DIB: case CB_FORMAT_UNICODETEXT: break; default: if (memcmp(stream_get_tail(data_in), CFSTR_HTML, sizeof(CFSTR_HTML)) == 0) { format = CB_FORMAT_HTML; break; } if (memcmp(stream_get_tail(data_in), CFSTR_PNG, sizeof(CFSTR_PNG)) == 0) { format = CB_FORMAT_PNG; break; } if (memcmp(stream_get_tail(data_in), CFSTR_JPEG, sizeof(CFSTR_JPEG)) == 0) { format = CB_FORMAT_JPEG; break; } if (memcmp(stream_get_tail(data_in), CFSTR_GIF, sizeof(CFSTR_GIF)) == 0) { format = CB_FORMAT_GIF; break; } supported = 0; break; } stream_seek(data_in, 32); if (supported) cb_event->formats[cb_event->num_formats++] = format; } svc_plugin_send_event((rdpSvcPlugin*)cliprdr, (FRDP_EVENT*)cb_event); cliprdr_send_format_list_response(cliprdr); }
static void cliprdr_process_unlock_clipdata(cliprdrPlugin* cliprdr, wStream* s, UINT32 length, UINT16 flags) { RDP_CB_UNLOCK_CLIPDATA_EVENT* cb_event; cb_event = (RDP_CB_UNLOCK_CLIPDATA_EVENT*) freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_UnLockClipdata, NULL, NULL); Stream_Read_UINT32(s, cb_event->clipDataId); svc_plugin_send_event((rdpSvcPlugin*) cliprdr, (wMessage*) cb_event); }
void cliprdr_process_format_data_request(cliprdrPlugin* cliprdr, STREAM* data_in) { FRDP_CB_DATA_REQUEST_EVENT* cb_event; cb_event = (FRDP_CB_DATA_REQUEST_EVENT*)freerdp_event_new(FRDP_EVENT_TYPE_CB_DATA_REQUEST, NULL, NULL); stream_read_uint32(data_in, cb_event->format); svc_plugin_send_event((rdpSvcPlugin*)cliprdr, (FRDP_EVENT*)cb_event); }
static void rdpdbg_process_event(rdpSvcPlugin* plugin, FRDP_EVENT* event) { DEBUG_WARN("event_type %d", event->event_type); freerdp_event_free(event); event = freerdp_event_new(FRDP_EVENT_CLASS_DEBUG, 0, NULL, NULL); svc_plugin_send_event(plugin, event); }
static void cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr) { FRDP_EVENT* event; cliprdr_send_clip_caps(cliprdr); event = freerdp_event_new(FRDP_EVENT_TYPE_CB_SYNC, NULL, NULL); svc_plugin_send_event((rdpSvcPlugin*)cliprdr, event); }
void cliprdr_process_format_list_response(cliprdrPlugin* cliprdr, uint16 msgFlags) { RDP_EVENT* event; if ((msgFlags & CB_RESPONSE_FAIL) != 0) { event = freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_MONITOR_READY, NULL, NULL); svc_plugin_send_event((rdpSvcPlugin*) cliprdr, event); } }
void cliprdr_process_format_data_request(cliprdrPlugin* cliprdr, STREAM* s, uint32 dataLen, uint16 msgFlags) { RDP_CB_DATA_REQUEST_EVENT* cb_event; cb_event = (RDP_CB_DATA_REQUEST_EVENT*) freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_DATA_REQUEST, NULL, NULL); stream_read_uint32(s, cb_event->format); svc_plugin_send_event((rdpSvcPlugin*) cliprdr, (RDP_EVENT*) cb_event); }
void cliprdr_process_format_data_response(cliprdrPlugin* cliprdr, STREAM* data_in, uint32 dataLen) { FRDP_CB_DATA_RESPONSE_EVENT* cb_event; cb_event = (FRDP_CB_DATA_RESPONSE_EVENT*)freerdp_event_new(FRDP_EVENT_TYPE_CB_DATA_RESPONSE, NULL, NULL); cb_event->size = dataLen; cb_event->data = (uint8*)xmalloc(dataLen); memcpy(cb_event->data, stream_get_tail(data_in), dataLen); svc_plugin_send_event((rdpSvcPlugin*)cliprdr, (FRDP_EVENT*)cb_event); }
void cliprdr_process_format_data_request(cliprdrPlugin* cliprdr, wStream* s, UINT32 dataLen, UINT16 msgFlags) { RDP_CB_DATA_REQUEST_EVENT* cb_event; cb_event = (RDP_CB_DATA_REQUEST_EVENT*) freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_DataRequest, NULL, NULL); stream_read_UINT32(s, cb_event->format); svc_plugin_send_event((rdpSvcPlugin*) cliprdr, (wMessage*) cb_event); }
static void cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr, STREAM* s, uint16 length, uint16 flags) { RDP_EVENT* event; if (cliprdr->received_caps) cliprdr_send_clip_caps(cliprdr); event = freerdp_event_new(RDP_EVENT_CLASS_CLIPRDR, RDP_EVENT_TYPE_CB_MONITOR_READY, NULL, NULL); svc_plugin_send_event((rdpSvcPlugin*) cliprdr, event); }
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); } }
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); }
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); } }
static void cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr, wStream* s, UINT16 length, UINT16 flags) { wMessage* event; if (cliprdr->received_caps) cliprdr_send_clip_caps(cliprdr); event = freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_MonitorReady, NULL, NULL); svc_plugin_send_event((rdpSvcPlugin*) cliprdr, event); }
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); }
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); }
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); }
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); }
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); }