33 |
static cliprdr_dataformat *server_formats = NULL; |
static cliprdr_dataformat *server_formats = NULL; |
34 |
static uint16 num_server_formats = 0; |
static uint16 num_server_formats = 0; |
35 |
static XSelectionEvent selection_event; |
static XSelectionEvent selection_event; |
36 |
|
static uint16 clipboard_channelno; |
37 |
|
|
38 |
static void |
static void |
39 |
cliprdr_print_server_formats(void) |
cliprdr_print_server_formats(void) |
96 |
out_uint32_le(s, 0); |
out_uint32_le(s, 0); |
97 |
|
|
98 |
s_mark_end(s); |
s_mark_end(s); |
99 |
sec_send_to_channel(s, encryption ? SEC_ENCRYPT : 0, 1005); // FIXME: Don't hardcode channel! |
sec_send_to_channel(s, encryption ? SEC_ENCRYPT : 0, |
100 |
|
clipboard_channelno); |
101 |
} |
} |
102 |
|
|
103 |
|
|
116 |
out_uint32_le(out, 0); |
out_uint32_le(out, 0); |
117 |
s_mark_end(out); |
s_mark_end(out); |
118 |
|
|
119 |
sec_send_to_channel(out, encryption ? SEC_ENCRYPT : 0, 1005); // FIXME: Don't hardcode channel! |
sec_send_to_channel(out, encryption ? SEC_ENCRYPT : 0, |
120 |
|
clipboard_channelno); |
121 |
} |
} |
122 |
|
|
123 |
|
|
201 |
/* We need to handle INCR as well */ |
/* We need to handle INCR as well */ |
202 |
|
|
203 |
out = sec_init(encryption ? SEC_ENCRYPT : 0, |
out = sec_init(encryption ? SEC_ENCRYPT : 0, |
204 |
20+nitems); |
20+nitems+1); |
205 |
out_uint32_le(out, 12+nitems); |
out_uint32_le(out, 12+nitems+1); |
206 |
out_uint32_le(out, 0x13); |
out_uint32_le(out, 0x13); |
207 |
out_uint16_le(out, 5); |
out_uint16_le(out, 5); |
208 |
out_uint16_le(out, 1); |
out_uint16_le(out, 1); |
209 |
out_uint32_le(out, nitems); |
out_uint32_le(out, nitems+1); |
210 |
out_uint8p(out, data, nitems); |
out_uint8p(out, data, nitems+1); |
211 |
/* Insert null string here? */ |
/* Insert null string here? */ |
212 |
out_uint32_le(out, 0); |
out_uint32_le(out, 0); |
213 |
s_mark_end(out); |
s_mark_end(out); |
214 |
|
|
215 |
sec_send_to_channel(out, encryption ? SEC_ENCRYPT : 0, 1005); // FIXME: Don't hardcode channel! |
sec_send_to_channel(out, encryption ? SEC_ENCRYPT : 0, |
216 |
|
clipboard_channelno); |
217 |
|
|
218 |
cliprdr_send_format_announce(); |
cliprdr_send_format_announce(); |
219 |
|
|
245 |
|
|
246 |
s_mark_end(s); |
s_mark_end(s); |
247 |
|
|
248 |
sec_send_to_channel(s, encryption ? SEC_ENCRYPT : 0, 1005); // FIXME: Don't hardcode channel! |
sec_send_to_channel(s, encryption ? SEC_ENCRYPT : 0, |
249 |
|
clipboard_channelno); |
250 |
} |
} |
251 |
|
|
252 |
|
|
346 |
|
|
347 |
s_mark_end(s); |
s_mark_end(s); |
348 |
|
|
349 |
sec_send_to_channel(s, encryption ? SEC_ENCRYPT : 0, 1005); // FIXME: Don't hardcode channel! |
sec_send_to_channel(s, encryption ? SEC_ENCRYPT : 0, |
350 |
|
clipboard_channelno); |
351 |
} |
} |
352 |
|
|
353 |
|
|
492 |
} |
} |
493 |
|
|
494 |
|
|
495 |
void cliprdr_callback(STREAM s) |
void cliprdr_callback(STREAM s, uint16 channelno) |
496 |
{ |
{ |
497 |
|
static int failed_clipboard_acks = 0; |
498 |
|
struct timeval timeval; |
499 |
uint32 length, flags; |
uint32 length, flags; |
500 |
uint16 ptype0, ptype1; |
uint16 ptype0, ptype1; |
501 |
DEBUG_CLIPBOARD(("cliprdr_callback called, clipboard data:\n")); |
clipboard_channelno = channelno; |
502 |
|
DEBUG_CLIPBOARD(("cliprdr_callback called with channelno %d, clipboard data:\n", channelno)); |
503 |
#ifdef WITH_DEBUG_CLIPBOARD |
#ifdef WITH_DEBUG_CLIPBOARD |
504 |
hexdump(s->p, s->end - s->p); |
hexdump(s->p, s->end - s->p); |
505 |
#endif |
#endif |
522 |
// There is a strange pad in this packet that we might need some time, |
// There is a strange pad in this packet that we might need some time, |
523 |
// but probably not. |
// but probably not. |
524 |
DEBUG_CLIPBOARD(("Received format announce ACK\n")); |
DEBUG_CLIPBOARD(("Received format announce ACK\n")); |
525 |
|
failed_clipboard_acks = 0; |
526 |
return; |
return; |
527 |
|
|
528 |
|
} else if (3 == ptype0 && 2 == ptype1) |
529 |
|
{ |
530 |
|
DEBUG_CLIPBOARD(("Received failed clipboard format announce ACK, retrying\n")); |
531 |
|
|
532 |
|
/* This is a fairly portable way to sleep 1/10 of |
533 |
|
a second.. */ |
534 |
|
timeval.tv_sec = 0; |
535 |
|
timeval.tv_usec = 100; |
536 |
|
select(0, NULL, NULL, NULL, &timeval); |
537 |
|
if (failed_clipboard_acks < 3) |
538 |
|
{ |
539 |
|
|
540 |
|
cliprdr_send_format_announce(); |
541 |
|
/* Make sure we don't get stuck in this loop */ |
542 |
|
failed_clipboard_acks++; |
543 |
|
} |
544 |
|
else |
545 |
|
{ |
546 |
|
warning("Reached maximum number of clipboard format announce attempts. Pasting in Windows probably won't work well now.\n"); |
547 |
|
} |
548 |
} else if (2 == ptype0 && 0 == ptype1) |
} else if (2 == ptype0 && 0 == ptype1) |
549 |
{ |
{ |
550 |
cliprdr_register_server_formats(s); |
cliprdr_register_server_formats(s); |