34 |
static VCHANNEL *cliprdr_channel; |
static VCHANNEL *cliprdr_channel; |
35 |
|
|
36 |
static void |
static void |
37 |
cliprdr_send_packet(uint16 type, uint16 status, uint8 *data, uint32 length) |
cliprdr_send_packet(uint16 type, uint16 status, uint8 * data, uint32 length) |
38 |
{ |
{ |
39 |
STREAM s; |
STREAM s; |
40 |
|
|
45 |
out_uint16_le(s, status); |
out_uint16_le(s, status); |
46 |
out_uint32_le(s, length); |
out_uint32_le(s, length); |
47 |
out_uint8p(s, data, length); |
out_uint8p(s, data, length); |
48 |
out_uint32(s, 0); /* pad? */ |
out_uint32(s, 0); /* pad? */ |
49 |
s_mark_end(s); |
s_mark_end(s); |
50 |
channel_send(s, cliprdr_channel); |
channel_send(s, cliprdr_channel); |
51 |
} |
} |
52 |
|
|
53 |
|
/* Helper which announces our readiness to supply clipboard data |
54 |
|
in a single format (such as CF_TEXT) to the RDP side. |
55 |
|
To announce more than one format at a time, use |
56 |
|
cliprdr_send_native_format_announce. |
57 |
|
*/ |
58 |
void |
void |
59 |
cliprdr_send_text_format_announce(void) |
cliprdr_send_simple_native_format_announce(uint32 format) |
60 |
{ |
{ |
61 |
uint8 buffer[36]; |
uint8 buffer[36]; |
62 |
|
|
63 |
buf_out_uint32(buffer, CF_TEXT); |
buf_out_uint32(buffer, format); |
64 |
memset(buffer+4, 0, sizeof(buffer)-4); /* description */ |
memset(buffer + 4, 0, sizeof(buffer) - 4); /* description */ |
65 |
cliprdr_send_packet(CLIPRDR_FORMAT_ANNOUNCE, CLIPRDR_REQUEST, buffer, sizeof(buffer)); |
cliprdr_send_native_format_announce(buffer, sizeof(buffer)); |
|
} |
|
|
|
|
|
void |
|
|
cliprdr_send_blah_format_announce(void) |
|
|
{ |
|
|
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)); |
|
66 |
} |
} |
67 |
|
|
68 |
|
/* Announces our readiness to supply clipboard data in multiple |
69 |
|
formats, each denoted by a 36-byte format descriptor of |
70 |
|
[ uint32 format + 32-byte description ]. |
71 |
|
*/ |
72 |
void |
void |
73 |
cliprdr_send_native_format_announce(uint8 *data, uint32 length) |
cliprdr_send_native_format_announce(uint8 * formats_data, uint32 formats_data_length) |
74 |
{ |
{ |
75 |
cliprdr_send_packet(CLIPRDR_FORMAT_ANNOUNCE, CLIPRDR_REQUEST, data, length); |
cliprdr_send_packet(CLIPRDR_FORMAT_ANNOUNCE, CLIPRDR_REQUEST, formats_data, |
76 |
|
formats_data_length); |
77 |
} |
} |
78 |
|
|
79 |
void |
void |
86 |
} |
} |
87 |
|
|
88 |
void |
void |
89 |
cliprdr_send_data(uint8 *data, uint32 length) |
cliprdr_send_data(uint8 * data, uint32 length) |
90 |
{ |
{ |
91 |
cliprdr_send_packet(CLIPRDR_DATA_RESPONSE, CLIPRDR_RESPONSE, data, length); |
cliprdr_send_packet(CLIPRDR_DATA_RESPONSE, CLIPRDR_RESPONSE, data, length); |
92 |
} |
} |
96 |
{ |
{ |
97 |
uint16 type, status; |
uint16 type, status; |
98 |
uint32 length, format; |
uint32 length, format; |
99 |
char *data; |
uint8 *data; |
100 |
|
|
101 |
in_uint16_le(s, type); |
in_uint16_le(s, type); |
102 |
in_uint16_le(s, status); |
in_uint16_le(s, status); |
111 |
{ |
{ |
112 |
/* 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 |
113 |
still processing a paste. Try sending another announce. */ |
still processing a paste. Try sending another announce. */ |
114 |
cliprdr_send_text_format_announce(); |
cliprdr_send_simple_native_format_announce(CF_TEXT); |
115 |
return; |
return; |
116 |
} |
} |
117 |
|
|
118 |
error("CLIPRDR error (type=%d)\n", type); |
DEBUG_CLIPBOARD(("CLIPRDR error (type=%d)\n", type)); |
119 |
return; |
return; |
120 |
} |
} |
121 |
|
|
137 |
case CLIPRDR_DATA_RESPONSE: |
case CLIPRDR_DATA_RESPONSE: |
138 |
ui_clip_handle_data(data, length); |
ui_clip_handle_data(data, length); |
139 |
break; |
break; |
140 |
|
case 7: /* TODO: W2K3 SP1 sends this on connect with a value of 1 */ |
141 |
|
break; |
142 |
default: |
default: |
143 |
unimpl("CLIPRDR packet type %d\n", type); |
unimpl("CLIPRDR packet type %d\n", type); |
144 |
} |
} |
147 |
BOOL |
BOOL |
148 |
cliprdr_init(void) |
cliprdr_init(void) |
149 |
{ |
{ |
150 |
cliprdr_channel = channel_register("cliprdr", CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP \ |
cliprdr_channel = |
151 |
| CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL, cliprdr_process); |
channel_register("cliprdr", |
152 |
|
CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP | |
153 |
|
CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL, |
154 |
|
cliprdr_process); |
155 |
return (cliprdr_channel != NULL); |
return (cliprdr_channel != NULL); |
156 |
} |
} |