From 95f19ad20960011a75409e1cb42106795b38e907 Mon Sep 17 00:00:00 2001 From: Erik Forsberg Date: Mon, 7 Nov 2005 13:15:19 +0000 Subject: [PATCH] Applied patch 1349027 by Ilya Konstantinov. Generalizes code for sending clipboard format announces to RDP side, and uses new code in appropriate places. git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@1024 423420c4-83ab-492f-b58f-81f9feb106b5 --- cliprdr.c | 31 +++++++++++++++---------------- proto.h | 5 ++--- xclip.c | 10 +++++----- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/cliprdr.c b/cliprdr.c index 1713e5d..1a1e7bb 100644 --- a/cliprdr.c +++ b/cliprdr.c @@ -50,30 +50,29 @@ cliprdr_send_packet(uint16 type, uint16 status, uint8 * data, uint32 length) channel_send(s, cliprdr_channel); } +/* Helper which announces our readiness to supply clipboard data + in a single format (such as CF_TEXT) to the RDP side. + To announce more than one format at a time, use + cliprdr_send_native_format_announce. + */ void -cliprdr_send_text_format_announce(void) +cliprdr_send_simple_native_format_announce(uint32 format) { uint8 buffer[36]; - buf_out_uint32(buffer, CF_TEXT); + buf_out_uint32(buffer, format); memset(buffer + 4, 0, sizeof(buffer) - 4); /* description */ - cliprdr_send_packet(CLIPRDR_FORMAT_ANNOUNCE, CLIPRDR_REQUEST, buffer, sizeof(buffer)); + cliprdr_send_native_format_announce(buffer, sizeof(buffer)); } +/* Announces our readiness to supply clipboard data in multiple + formats, each denoted by a 36-byte format descriptor of + [ uint32 format + 32-byte description ]. + */ void -cliprdr_send_blah_format_announce(void) +cliprdr_send_native_format_announce(uint8 * formats_data, uint32 formats_data_length) { - uint8 buffer[36]; - - buf_out_uint32(buffer, CF_OEMTEXT); - memset(buffer + 4, 0, sizeof(buffer) - 4); /* description */ - cliprdr_send_packet(CLIPRDR_FORMAT_ANNOUNCE, CLIPRDR_REQUEST, buffer, sizeof(buffer)); -} - -void -cliprdr_send_native_format_announce(uint8 * data, uint32 length) -{ - cliprdr_send_packet(CLIPRDR_FORMAT_ANNOUNCE, CLIPRDR_REQUEST, data, length); + cliprdr_send_packet(CLIPRDR_FORMAT_ANNOUNCE, CLIPRDR_REQUEST, formats_data, formats_data_length); } void @@ -111,7 +110,7 @@ cliprdr_process(STREAM s) { /* FIXME: We seem to get this when we send an announce while the server is still processing a paste. Try sending another announce. */ - cliprdr_send_text_format_announce(); + cliprdr_send_simple_native_format_announce(CF_TEXT); return; } diff --git a/proto.h b/proto.h index 1d50e11..f6d4ee5 100644 --- a/proto.h +++ b/proto.h @@ -50,9 +50,8 @@ STREAM channel_init(VCHANNEL * channel, uint32 length); void channel_send(STREAM s, VCHANNEL * channel); void channel_process(STREAM s, uint16 mcs_channel); /* cliprdr.c */ -void cliprdr_send_text_format_announce(void); -void cliprdr_send_blah_format_announce(void); -void cliprdr_send_native_format_announce(uint8 * data, uint32 length); +void cliprdr_send_native_format_announce(uint8 * formats_data, uint32 formats_data_length); +void cliprdr_send_simple_native_format_announce(uint32 format); void cliprdr_send_data_request(uint32 format); void cliprdr_send_data(uint8 * data, uint32 length); BOOL cliprdr_init(void); diff --git a/xclip.c b/xclip.c index 6b097d4..84779a8 100644 --- a/xclip.c +++ b/xclip.c @@ -220,7 +220,7 @@ xclip_handle_SelectionNotify(XSelectionEvent * event) XFree(data); if (!rdesktop_is_selection_owner) - cliprdr_send_text_format_announce(); + cliprdr_send_simple_native_format_announce(CF_TEXT); return; fail: @@ -276,7 +276,7 @@ xclip_handle_SelectionClear(void) DEBUG_CLIPBOARD(("xclip_handle_SelectionClear\n")); have_primary = 0; XDeleteProperty(g_display, DefaultRootWindow(g_display), rdesktop_clipboard_formats_atom); - cliprdr_send_text_format_announce(); + cliprdr_send_simple_native_format_announce(CF_TEXT); } void @@ -311,7 +311,7 @@ xclip_handle_PropertyNotify(XPropertyEvent * event) cliprdr_send_data(g_clip_buffer, g_clip_buflen + 1); if (!rdesktop_is_selection_owner) - cliprdr_send_text_format_announce(); + cliprdr_send_simple_native_format_announce(CF_TEXT); xfree(g_clip_buffer); g_clip_buffer = 0; @@ -364,7 +364,7 @@ xclip_handle_PropertyNotify(XPropertyEvent * event) } /* PropertyDelete, or XGetWindowProperty failed */ - cliprdr_send_text_format_announce(); + cliprdr_send_simple_native_format_announce(CF_TEXT); rdesktop_is_selection_owner = 0; } #endif @@ -453,7 +453,7 @@ ui_clip_request_data(uint32 format) void ui_clip_sync(void) { - cliprdr_send_text_format_announce(); + cliprdr_send_simple_native_format_announce(CF_TEXT); }