33 |
|
|
34 |
static VCHANNEL *cliprdr_channel; |
static VCHANNEL *cliprdr_channel; |
35 |
|
|
36 |
|
static uint8 *last_formats = NULL; |
37 |
|
static uint32 last_formats_length = 0; |
38 |
|
|
39 |
static void |
static void |
40 |
cliprdr_send_packet(uint16 type, uint16 status, uint8 * data, uint32 length) |
cliprdr_send_packet(uint16 type, uint16 status, uint8 * data, uint32 length) |
41 |
{ |
{ |
53 |
channel_send(s, cliprdr_channel); |
channel_send(s, cliprdr_channel); |
54 |
} |
} |
55 |
|
|
56 |
|
/* Helper which announces our readiness to supply clipboard data |
57 |
|
in a single format (such as CF_TEXT) to the RDP side. |
58 |
|
To announce more than one format at a time, use |
59 |
|
cliprdr_send_native_format_announce. |
60 |
|
*/ |
61 |
void |
void |
62 |
cliprdr_send_text_format_announce(void) |
cliprdr_send_simple_native_format_announce(uint32 format) |
63 |
{ |
{ |
64 |
uint8 buffer[36]; |
uint8 buffer[36]; |
65 |
|
|
66 |
buf_out_uint32(buffer, CF_TEXT); |
DEBUG_CLIPBOARD(("cliprdr_send_simple_native_format_announce\n")); |
67 |
|
|
68 |
|
buf_out_uint32(buffer, format); |
69 |
memset(buffer + 4, 0, sizeof(buffer) - 4); /* description */ |
memset(buffer + 4, 0, sizeof(buffer) - 4); /* description */ |
70 |
cliprdr_send_packet(CLIPRDR_FORMAT_ANNOUNCE, CLIPRDR_REQUEST, buffer, sizeof(buffer)); |
cliprdr_send_native_format_announce(buffer, sizeof(buffer)); |
71 |
} |
} |
72 |
|
|
73 |
|
/* Announces our readiness to supply clipboard data in multiple |
74 |
|
formats, each denoted by a 36-byte format descriptor of |
75 |
|
[ uint32 format + 32-byte description ]. |
76 |
|
*/ |
77 |
void |
void |
78 |
cliprdr_send_blah_format_announce(void) |
cliprdr_send_native_format_announce(uint8 * formats_data, uint32 formats_data_length) |
79 |
{ |
{ |
80 |
uint8 buffer[36]; |
DEBUG_CLIPBOARD(("cliprdr_send_native_format_announce\n")); |
81 |
|
|
82 |
buf_out_uint32(buffer, CF_OEMTEXT); |
cliprdr_send_packet(CLIPRDR_FORMAT_ANNOUNCE, CLIPRDR_REQUEST, formats_data, |
83 |
memset(buffer + 4, 0, sizeof(buffer) - 4); /* description */ |
formats_data_length); |
|
cliprdr_send_packet(CLIPRDR_FORMAT_ANNOUNCE, CLIPRDR_REQUEST, buffer, sizeof(buffer)); |
|
|
} |
|
84 |
|
|
85 |
void |
if (formats_data != last_formats) |
86 |
cliprdr_send_native_format_announce(uint8 * data, uint32 length) |
{ |
87 |
{ |
if (last_formats) |
88 |
cliprdr_send_packet(CLIPRDR_FORMAT_ANNOUNCE, CLIPRDR_REQUEST, data, length); |
xfree(last_formats); |
89 |
|
|
90 |
|
last_formats = xmalloc(formats_data_length); |
91 |
|
memcpy(last_formats, formats_data, formats_data_length); |
92 |
|
last_formats_length = formats_data_length; |
93 |
|
} |
94 |
} |
} |
95 |
|
|
96 |
void |
void |
98 |
{ |
{ |
99 |
uint8 buffer[4]; |
uint8 buffer[4]; |
100 |
|
|
101 |
|
DEBUG_CLIPBOARD(("cliprdr_send_data_request\n")); |
102 |
buf_out_uint32(buffer, format); |
buf_out_uint32(buffer, format); |
103 |
cliprdr_send_packet(CLIPRDR_DATA_REQUEST, CLIPRDR_REQUEST, buffer, sizeof(buffer)); |
cliprdr_send_packet(CLIPRDR_DATA_REQUEST, CLIPRDR_REQUEST, buffer, sizeof(buffer)); |
104 |
} |
} |
106 |
void |
void |
107 |
cliprdr_send_data(uint8 * data, uint32 length) |
cliprdr_send_data(uint8 * data, uint32 length) |
108 |
{ |
{ |
109 |
|
DEBUG_CLIPBOARD(("cliprdr_send_data\n")); |
110 |
cliprdr_send_packet(CLIPRDR_DATA_RESPONSE, CLIPRDR_RESPONSE, data, length); |
cliprdr_send_packet(CLIPRDR_DATA_RESPONSE, CLIPRDR_RESPONSE, data, length); |
111 |
} |
} |
112 |
|
|
130 |
{ |
{ |
131 |
/* FIXME: We seem to get this when we send an announce while the server is |
/* FIXME: We seem to get this when we send an announce while the server is |
132 |
still processing a paste. Try sending another announce. */ |
still processing a paste. Try sending another announce. */ |
133 |
cliprdr_send_text_format_announce(); |
cliprdr_send_native_format_announce(last_formats, last_formats_length); |
134 |
return; |
return; |
135 |
} |
} |
136 |
|
|
137 |
error("CLIPRDR error (type=%d)\n", type); |
DEBUG_CLIPBOARD(("CLIPRDR error (type=%d)\n", type)); |
138 |
return; |
return; |
139 |
} |
} |
140 |
|
|
156 |
case CLIPRDR_DATA_RESPONSE: |
case CLIPRDR_DATA_RESPONSE: |
157 |
ui_clip_handle_data(data, length); |
ui_clip_handle_data(data, length); |
158 |
break; |
break; |
159 |
|
case 7: /* TODO: W2K3 SP1 sends this on connect with a value of 1 */ |
160 |
|
break; |
161 |
default: |
default: |
162 |
unimpl("CLIPRDR packet type %d\n", type); |
unimpl("CLIPRDR packet type %d\n", type); |
163 |
} |
} |