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); } } }
CLIPRDR_FORMAT_LIST *remmina_rdp_cliprdr_get_client_format_list(RemminaProtocolWidget* gp) { TRACE_CALL(__func__); GtkClipboard* gtkClipboard; rfContext* rfi = GET_PLUGIN_DATA(gp); GdkAtom* targets; gboolean result = 0; gint loccount, srvcount; gint formatId, i; CLIPRDR_FORMAT *formats; struct retp_t { CLIPRDR_FORMAT_LIST pFormatList; CLIPRDR_FORMAT formats[]; } *retp; formats = NULL; retp = NULL; gtkClipboard = gtk_widget_get_clipboard(rfi->drawing_area, GDK_SELECTION_CLIPBOARD); if (gtkClipboard) { result = gtk_clipboard_wait_for_targets(gtkClipboard, &targets, &loccount); } if (result && loccount > 0) { formats = (CLIPRDR_FORMAT*)malloc(loccount * sizeof(CLIPRDR_FORMAT)); srvcount = 0; for (i = 0; i < loccount; i++) { formatId = remmina_rdp_cliprdr_get_format_from_gdkatom(targets[i]); if ( formatId != 0 ) { formats[srvcount].formatId = formatId; formats[srvcount].formatName = NULL; srvcount++; } } if (srvcount > 0) { retp = (struct retp_t *)malloc(sizeof(struct retp_t) + sizeof(CLIPRDR_FORMAT) * srvcount); retp->pFormatList.formats = retp->formats; retp->pFormatList.numFormats = srvcount; memcpy(retp->formats, formats, sizeof(CLIPRDR_FORMAT) * srvcount); } else { retp = (struct retp_t *)malloc(sizeof(struct retp_t)); retp->pFormatList.formats = NULL; retp->pFormatList.numFormats = 0; } free(formats); } else { retp = (struct retp_t *)malloc(sizeof(struct retp_t) + sizeof(CLIPRDR_FORMAT)); retp->pFormatList.formats = NULL; retp->pFormatList.numFormats = 0; } if (result) g_free(targets); retp->pFormatList.msgFlags = CB_RESPONSE_OK; return (CLIPRDR_FORMAT_LIST*)retp; }
void remmina_rdp_cliprdr_get_target_types(UINT32** formats, UINT16* size, GdkAtom* types, int count) { TRACE_CALL(__func__); int i; *size = 1; *formats = (UINT32*)malloc(sizeof(UINT32) * (count + 1)); *formats[0] = 0; for (i = 0; i < count; i++) { UINT32 format = remmina_rdp_cliprdr_get_format_from_gdkatom(types[i]); if (format != 0) { (*formats)[*size] = format; (*size)++; } } *formats = realloc(*formats, sizeof(UINT32) * (*size)); }