198 |
/* We need to handle INCR as well */ |
/* We need to handle INCR as well */ |
199 |
|
|
200 |
out = sec_init(encryption ? SEC_ENCRYPT : 0, |
out = sec_init(encryption ? SEC_ENCRYPT : 0, |
201 |
20+nitems); |
20+nitems+1); |
202 |
out_uint32_le(out, 12+nitems); |
out_uint32_le(out, 12+nitems+1); |
203 |
out_uint32_le(out, 0x13); |
out_uint32_le(out, 0x13); |
204 |
out_uint16_le(out, 5); |
out_uint16_le(out, 5); |
205 |
out_uint16_le(out, 1); |
out_uint16_le(out, 1); |
206 |
out_uint32_le(out, nitems); |
out_uint32_le(out, nitems+1); |
207 |
out_uint8p(out, data, nitems); |
out_uint8p(out, data, nitems+1); |
208 |
/* Insert null string here? */ |
/* Insert null string here? */ |
209 |
out_uint32_le(out, 0); |
out_uint32_le(out, 0); |
210 |
s_mark_end(out); |
s_mark_end(out); |
488 |
|
|
489 |
void cliprdr_callback(STREAM s) |
void cliprdr_callback(STREAM s) |
490 |
{ |
{ |
491 |
|
static int failed_clipboard_acks = 0; |
492 |
|
struct timeval timeval; |
493 |
uint32 length, flags; |
uint32 length, flags; |
494 |
uint16 ptype0, ptype1; |
uint16 ptype0, ptype1; |
495 |
DEBUG_CLIPBOARD(("cliprdr_callback called, clipboard data:\n")); |
DEBUG_CLIPBOARD(("cliprdr_callback called, clipboard data:\n")); |
515 |
// 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, |
516 |
// but probably not. |
// but probably not. |
517 |
DEBUG_CLIPBOARD(("Received format announce ACK\n")); |
DEBUG_CLIPBOARD(("Received format announce ACK\n")); |
518 |
|
failed_clipboard_acks = 0; |
519 |
return; |
return; |
520 |
|
|
521 |
|
} else if (3 == ptype0 && 2 == ptype1) |
522 |
|
{ |
523 |
|
DEBUG_CLIPBOARD(("Received failed clipboard format announce ACK, retrying\n")); |
524 |
|
|
525 |
|
/* This is a fairly portable way to sleep 1/10 of |
526 |
|
a second.. */ |
527 |
|
timeval.tv_sec = 0; |
528 |
|
timeval.tv_usec = 100; |
529 |
|
select(0, NULL, NULL, NULL, &timeval); |
530 |
|
if (failed_clipboard_acks < 3) |
531 |
|
{ |
532 |
|
|
533 |
|
cliprdr_send_format_announce(); |
534 |
|
/* Make sure we don't get stuck in this loop */ |
535 |
|
failed_clipboard_acks++; |
536 |
|
} |
537 |
|
else |
538 |
|
{ |
539 |
|
warning("Reached maximum number of clipboard format announce attempts. Pasting in Windows probably won't work well now.\n"); |
540 |
|
} |
541 |
} else if (2 == ptype0 && 0 == ptype1) |
} else if (2 == ptype0 && 0 == ptype1) |
542 |
{ |
{ |
543 |
cliprdr_register_server_formats(s); |
cliprdr_register_server_formats(s); |