2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
Protocol services - Clipboard functions |
Protocol services - Clipboard functions |
4 |
Copyright (C) Erik Forsberg <forsberg@cendio.se> 2003 |
Copyright (C) Erik Forsberg <forsberg@cendio.se> 2003 |
5 |
|
Copyright (C) Matthew Chapman 2003 |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
8 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
19 |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 |
*/ |
*/ |
21 |
|
|
|
#include <X11/Xlib.h> |
|
|
#include <X11/Xatom.h> |
|
22 |
#include "rdesktop.h" |
#include "rdesktop.h" |
23 |
|
|
24 |
extern BOOL encryption; |
#define CLIPRDR_CONNECT 1 |
25 |
extern Display *display; |
#define CLIPRDR_FORMAT_ANNOUNCE 2 |
26 |
extern Window wnd; |
#define CLIPRDR_FORMAT_ACK 3 |
27 |
extern Time last_keyrelease; |
#define CLIPRDR_DATA_REQUEST 4 |
28 |
|
#define CLIPRDR_DATA_RESPONSE 5 |
|
static Atom clipboard_atom, primary_atom, targets_atom, timestamp_atom; |
|
|
static Atom rdesktop_clipboard_target_atom; |
|
|
static cliprdr_dataformat *server_formats = NULL; |
|
|
static uint16 num_server_formats = 0; |
|
|
static XSelectionEvent selection_event; |
|
29 |
|
|
30 |
static void |
#define CLIPRDR_REQUEST 0 |
31 |
cliprdr_print_server_formats(void) |
#define CLIPRDR_RESPONSE 1 |
32 |
{ |
#define CLIPRDR_ERROR 2 |
|
#ifdef WITH_DEBUG_CLIPBOARD |
|
|
cliprdr_dataformat *this; |
|
|
uint16 i = 0; |
|
|
this = server_formats; |
|
|
DEBUG_CLIPBOARD(("There should be %d server formats.\n", num_server_formats)); |
|
|
while (NULL != this) |
|
|
{ |
|
|
DEBUG_CLIPBOARD(("Format code %d\n", this->identifier)); |
|
|
i++; |
|
|
this = this->next; |
|
|
} |
|
|
DEBUG_CLIPBOARD(("There were %d server formats.\n", i)); |
|
|
#endif |
|
|
} |
|
|
|
|
|
static void |
|
|
cliprdr_send_empty_datapacket(void) |
|
|
{ |
|
|
STREAM out; |
|
|
out = sec_init(encryption ? SEC_ENCRYPT : 0, |
|
|
20); |
|
|
out_uint32_le(out, 12); |
|
|
out_uint32_le(out, 0x13); |
|
|
out_uint16_le(out, 5); |
|
|
out_uint16_le(out, 1); |
|
|
out_uint32_le(out, 0); |
|
|
/* Insert null string here? */ |
|
|
out_uint32_le(out, 0); |
|
|
s_mark_end(out); |
|
|
|
|
|
sec_send_to_channel(out, encryption ? SEC_ENCRYPT : 0, 1005); // FIXME: Don't hardcode channel! |
|
|
} |
|
33 |
|
|
34 |
|
static VCHANNEL *cliprdr_channel; |
35 |
|
|
36 |
void |
static void |
37 |
cliprdr_handle_SelectionNotify(XSelectionEvent *event) |
cliprdr_send_packet(uint16 type, uint16 status, uint8 * data, uint32 length) |
38 |
{ |
{ |
39 |
|
STREAM s; |
40 |
|
|
41 |
unsigned char *data; |
DEBUG_CLIPBOARD(("CLIPRDR send: type=%d, status=%d, length=%d\n", type, status, length)); |
|
unsigned long nitems, bytes_left; |
|
|
int res; |
|
|
|
|
|
int format; |
|
|
Atom type_return; |
|
|
Atom best_target; |
|
|
|
|
|
STREAM out; |
|
|
|
|
|
DEBUG_CLIPBOARD(("cliprdr_handle_SelectionNotify\n")); |
|
|
|
|
|
if (None == event->property) { |
|
|
cliprdr_send_empty_datapacket(); |
|
|
return; /* Selection failed */ |
|
|
} |
|
|
|
|
|
DEBUG_CLIPBOARD(("selection: %s, target: %s, property: %s\n", |
|
|
XGetAtomName(display, event->selection), |
|
|
XGetAtomName(display, event->target), |
|
|
XGetAtomName(display, event->property))); |
|
|
|
|
|
if (targets_atom == event->target) { |
|
|
/* Response to TARGETS request. Let's find the target |
|
|
we want and request that */ |
|
|
res = XGetWindowProperty(display, wnd, |
|
|
rdesktop_clipboard_target_atom, |
|
|
0L, 4096L, False, AnyPropertyType, |
|
|
&type_return, |
|
|
&format, &nitems, &bytes_left, &data); |
|
|
|
|
|
if (Success != res) |
|
|
{ |
|
|
DEBUG_CLIPBOARD(("XGetWindowProperty failed!\n")); |
|
|
cliprdr_send_empty_datapacket(); |
|
|
return; |
|
|
} |
|
|
|
|
|
if (None == type_return) |
|
|
/* The owner might no support TARGETS. Just try |
|
|
STRING */ |
|
|
best_target = XA_STRING; |
|
|
else |
|
|
{ |
|
|
/* FIXME: We should choose format here based |
|
|
on what the server wanted */ |
|
|
best_target = XInternAtom(display, "TEXT", False); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
XConvertSelection(display, primary_atom, |
|
|
best_target, |
|
|
rdesktop_clipboard_target_atom, |
|
|
wnd, event->time); |
|
|
|
|
|
} |
|
|
else /* Other clipboard data */ |
|
|
{ |
|
|
|
|
|
res = XGetWindowProperty(display, wnd, |
|
|
rdesktop_clipboard_target_atom, |
|
|
0L, 4096L, False, AnyPropertyType, |
|
|
&type_return, |
|
|
&format, &nitems, &bytes_left, &data); |
|
|
|
|
|
if (Success != res) |
|
|
{ |
|
|
DEBUG_CLIPBOARD(("XGetWindowProperty failed!\n")); |
|
|
cliprdr_send_empty_datapacket(); |
|
|
return; |
|
|
} |
|
|
|
|
|
/* We need to handle INCR as well */ |
|
42 |
|
|
43 |
out = sec_init(encryption ? SEC_ENCRYPT : 0, |
s = channel_init(cliprdr_channel, length + 12); |
44 |
20+nitems); |
out_uint16_le(s, type); |
45 |
out_uint32_le(out, 12+nitems); |
out_uint16_le(s, status); |
46 |
out_uint32_le(out, 0x13); |
out_uint32_le(s, length); |
47 |
out_uint16_le(out, 5); |
out_uint8p(s, data, length); |
48 |
out_uint16_le(out, 1); |
out_uint32(s, 0); /* pad? */ |
49 |
out_uint32_le(out, nitems); |
s_mark_end(s); |
50 |
out_uint8p(out, data, nitems); |
channel_send(s, cliprdr_channel); |
|
/* Insert null string here? */ |
|
|
out_uint32_le(out, 0); |
|
|
s_mark_end(out); |
|
|
|
|
|
sec_send_to_channel(out, encryption ? SEC_ENCRYPT : 0, 1005); // FIXME: Don't hardcode channel! |
|
|
|
|
|
} |
|
|
|
|
|
|
|
51 |
} |
} |
52 |
|
|
53 |
void |
void |
54 |
cliprdr_handle_SelectionClear(void) |
cliprdr_send_text_format_announce(void) |
55 |
{ |
{ |
56 |
DEBUG_CLIPBOARD(("cliprdr_handle_SelectionClear\n")); |
uint8 buffer[36]; |
|
} |
|
|
|
|
|
void print_X_error(int res) |
|
|
{ |
|
|
switch(res) { |
|
|
case Success: |
|
|
DEBUG_CLIPBOARD(("Success\n")); |
|
|
break; |
|
|
|
|
|
case BadAtom: |
|
|
DEBUG_CLIPBOARD(("BadAtom\n")); |
|
|
break; |
|
|
|
|
|
case BadRequest: |
|
|
DEBUG_CLIPBOARD(("BadRequest\n")); |
|
|
break; |
|
|
|
|
|
case BadAlloc: |
|
|
DEBUG_CLIPBOARD(("BadAlloc\n")); |
|
|
break; |
|
|
|
|
|
case BadMatch: |
|
|
DEBUG_CLIPBOARD(("BadMatch\n")); |
|
|
break; |
|
|
|
|
|
case BadValue: |
|
|
DEBUG_CLIPBOARD(("BadValue\n")); |
|
|
break; |
|
|
|
|
|
case BadWindow: |
|
|
DEBUG_CLIPBOARD(("BadWindow\n")); |
|
|
break; |
|
57 |
|
|
58 |
default: |
buf_out_uint32(buffer, CF_TEXT); |
59 |
DEBUG_CLIPBOARD(("Unknown X error code %d\n", res)); |
memset(buffer + 4, 0, sizeof(buffer) - 4); /* description */ |
60 |
} |
cliprdr_send_packet(CLIPRDR_FORMAT_ANNOUNCE, CLIPRDR_REQUEST, buffer, sizeof(buffer)); |
61 |
} |
} |
62 |
|
|
63 |
static void |
void |
64 |
cliprdr_request_clipboard_data(uint32 formatcode) |
cliprdr_send_blah_format_announce(void) |
65 |
{ |
{ |
66 |
STREAM s; |
uint8 buffer[36]; |
|
s = sec_init(encryption ? SEC_ENCRYPT : 0, 24); |
|
|
out_uint32_le(s, 16); |
|
|
out_uint32_le(s, 0x13); |
|
|
out_uint16_le(s, 4); |
|
|
out_uint16_le(s, 0); |
|
|
out_uint32_le(s, 4); // Remaining length |
|
|
out_uint32_le(s, formatcode); |
|
|
out_uint32_le(s, 0); // Unknown. Garbage pad? |
|
67 |
|
|
68 |
s_mark_end(s); |
buf_out_uint32(buffer, CF_OEMTEXT); |
69 |
|
memset(buffer + 4, 0, sizeof(buffer) - 4); /* description */ |
70 |
sec_send_to_channel(s, encryption ? SEC_ENCRYPT : 0, 1005); // FIXME: Don't hardcode channel! |
cliprdr_send_packet(CLIPRDR_FORMAT_ANNOUNCE, CLIPRDR_REQUEST, buffer, sizeof(buffer)); |
71 |
} |
} |
72 |
|
|
|
|
|
73 |
void |
void |
74 |
cliprdr_handle_SelectionRequest(XSelectionRequestEvent *xevent) |
cliprdr_send_native_format_announce(uint8 * data, uint32 length) |
75 |
{ |
{ |
76 |
|
cliprdr_send_packet(CLIPRDR_FORMAT_ANNOUNCE, CLIPRDR_REQUEST, data, length); |
|
Atom *targets; |
|
|
int res; |
|
|
|
|
|
XSelectionEvent xev; |
|
|
DEBUG_CLIPBOARD(("cliprdr_handle_SelectionRequest\n")); |
|
|
DEBUG_CLIPBOARD(("Requestor window id 0x%x ", |
|
|
(unsigned)xevent->requestor)); |
|
|
if (clipboard_atom == xevent->selection) { |
|
|
DEBUG_CLIPBOARD(("wants CLIPBOARD\n")); |
|
|
} |
|
|
if (primary_atom == xevent->selection) { |
|
|
DEBUG_CLIPBOARD(("wants PRIMARY\n")); |
|
|
} |
|
|
DEBUG_CLIPBOARD(("Target is %s (0x%x), property is %s (0x%x)\n", |
|
|
XGetAtomName(display, xevent->target), |
|
|
(unsigned)xevent->target, |
|
|
XGetAtomName(display, xevent->property), |
|
|
(unsigned)xevent->property)); |
|
|
|
|
|
xev.type = SelectionNotify; |
|
|
xev.serial = 0; |
|
|
xev.send_event = True; |
|
|
xev.requestor = xevent->requestor; |
|
|
xev.selection = xevent->selection; |
|
|
xev.target = xevent->target; |
|
|
xev.property = xevent->property; |
|
|
xev.time = xevent->time; |
|
|
|
|
|
if (targets_atom == xevent->target) |
|
|
{ |
|
|
DEBUG_CLIPBOARD(("TARGETS requested, sending list..\n")); |
|
|
targets = xmalloc(4*sizeof(Atom)); |
|
|
targets[0] = xevent->target; |
|
|
targets[1] = XInternAtom(display, "TEXT", True); |
|
|
targets[2] = XInternAtom(display, "UTF8_STRING", True); |
|
|
targets[3] = XInternAtom(display, "TIMESTAMP", True); |
|
|
res = XChangeProperty(display, |
|
|
xevent->requestor, |
|
|
xevent->property, |
|
|
XA_ATOM, |
|
|
32, |
|
|
PropModeAppend, |
|
|
(unsigned char *)targets, |
|
|
3); |
|
|
DEBUG_CLIPBOARD(("res after XChangeProperty is ")); |
|
|
print_X_error(res); |
|
|
|
|
|
res = XSendEvent(display, |
|
|
xevent->requestor, |
|
|
False, |
|
|
NoEventMask, |
|
|
(XEvent *)&xev); |
|
|
return; |
|
|
} else if (timestamp_atom == xevent->target) |
|
|
{ |
|
|
DEBUG_CLIPBOARD(("TIMESTAMP requested... sending 0x%x\n", |
|
|
(unsigned)last_keyrelease)); |
|
|
res = XChangeProperty(display, |
|
|
xevent->requestor, |
|
|
xevent->property, |
|
|
XA_INTEGER, |
|
|
32, |
|
|
PropModeAppend, |
|
|
(unsigned char *)&last_keyrelease, |
|
|
1); |
|
|
res = XSendEvent(display, |
|
|
xevent->requestor, |
|
|
False, |
|
|
NoEventMask, |
|
|
(XEvent *)&xev); |
|
|
} else /* Some other target */ |
|
|
{ |
|
|
cliprdr_request_clipboard_data(CF_TEXT); |
|
|
memcpy(&selection_event, &xev, sizeof(xev)); |
|
|
/* Return and wait for data, handled by |
|
|
cliprdr_handle_server_data */ |
|
|
} |
|
77 |
} |
} |
78 |
|
|
79 |
|
void |
80 |
static void |
cliprdr_send_data_request(uint32 format) |
|
cliprdr_ack_format_list(void) |
|
81 |
{ |
{ |
82 |
STREAM s; |
uint8 buffer[4]; |
|
s = sec_init(encryption ? SEC_ENCRYPT : 0, 20); |
|
|
out_uint32_le(s, 12); |
|
|
out_uint32_le(s, 0x13); |
|
|
out_uint16_le(s, 3); |
|
|
out_uint16_le(s, 1); |
|
|
out_uint32_le(s, 0); |
|
|
out_uint32_le(s, 0x0000c0da); |
|
|
|
|
|
s_mark_end(s); |
|
|
|
|
|
sec_send_to_channel(s, encryption ? SEC_ENCRYPT : 0, 1005); // FIXME: Don't hardcode channel! |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
|
84 |
static void |
buf_out_uint32(buffer, format); |
85 |
cliprdr_register_server_formats(STREAM s) |
cliprdr_send_packet(CLIPRDR_DATA_REQUEST, CLIPRDR_REQUEST, buffer, sizeof(buffer)); |
|
{ |
|
|
uint32 remaining_length, pad; |
|
|
uint16 num_formats; |
|
|
cliprdr_dataformat *this, *next; |
|
|
|
|
|
DEBUG_CLIPBOARD(("cliprdr_register_server_formats\n")); |
|
|
in_uint32_le(s, remaining_length); |
|
|
|
|
|
num_formats = remaining_length / 36; |
|
|
if (NULL != server_formats) { |
|
|
this = server_formats; |
|
|
next = this->next; |
|
|
while (NULL != next) { |
|
|
xfree(this); |
|
|
this = NULL; |
|
|
this = next; |
|
|
next = this->next; |
|
|
} |
|
|
} |
|
|
this = xmalloc(sizeof(cliprdr_dataformat)); |
|
|
this->next = NULL; |
|
|
server_formats = this; |
|
|
num_server_formats = num_formats; |
|
|
while (1 < num_formats) { |
|
|
in_uint32_le(s, this->identifier); |
|
|
in_uint8a(s, this->textual_description, 32); |
|
|
DEBUG_CLIPBOARD(("Stored format description with numeric id %d\n", |
|
|
this->identifier)); |
|
|
this-> next = xmalloc(sizeof(cliprdr_dataformat)); |
|
|
this = this->next; |
|
|
num_formats--; |
|
|
} |
|
|
in_uint32_le(s, this->identifier); |
|
|
DEBUG_CLIPBOARD(("Stored format description with numeric id %d\n", this->identifier)); |
|
|
in_uint8a(s, this->textual_description, 32); |
|
|
this -> next = NULL; |
|
|
in_uint32_le(s, pad); |
|
|
cliprdr_print_server_formats(); |
|
86 |
} |
} |
87 |
|
|
88 |
static void |
void |
89 |
cliprdr_select_X_clipboards(void) |
cliprdr_send_data(uint8 * data, uint32 length) |
90 |
{ |
{ |
91 |
XSetSelectionOwner(display, primary_atom, wnd, last_keyrelease); |
cliprdr_send_packet(CLIPRDR_DATA_RESPONSE, CLIPRDR_RESPONSE, data, length); |
|
if (wnd != XGetSelectionOwner(display, primary_atom)) |
|
|
{ |
|
|
warning("Failed to aquire ownership of PRIMARY clipboard\n"); |
|
|
} |
|
|
XSetSelectionOwner(display, clipboard_atom, wnd, CurrentTime); |
|
|
if (wnd != XGetSelectionOwner(display, clipboard_atom)) |
|
|
{ |
|
|
warning("Failed to aquire ownership of CLIPBOARD clipboard\n"); |
|
|
} |
|
|
|
|
92 |
} |
} |
93 |
|
|
|
|
|
|
|
|
94 |
static void |
static void |
95 |
cliprdr_send_format_announce(void) |
cliprdr_process(STREAM s) |
|
{ |
|
|
STREAM s; |
|
|
int number_of_formats = 1; |
|
|
s = sec_init(encryption ? SEC_ENCRYPT : 0, number_of_formats*36+12+4+4); |
|
|
out_uint32_le(s, number_of_formats*36+12); |
|
|
out_uint32_le(s, 0x13); |
|
|
out_uint16_le(s, 2); |
|
|
out_uint16_le(s, 0); |
|
|
out_uint32_le(s, number_of_formats*36); |
|
|
|
|
|
// out_uint32_le(s, 0xd); // FIXME: This is a rather bogus unicode text description.. |
|
|
// rdp_out_unistr(s, "", 16); |
|
|
// out_uint8s(s, 32); |
|
|
|
|
|
|
|
|
out_uint32_le(s, 1); // FIXME: This is a rather bogus text description.. |
|
|
out_uint8s(s, 32); |
|
|
|
|
|
out_uint32_le(s, 0); |
|
|
|
|
|
s_mark_end(s); |
|
|
sec_send_to_channel(s, encryption ? SEC_ENCRYPT : 0, 1005); // FIXME: Don't hardcode channel! |
|
|
} |
|
|
|
|
|
|
|
|
static void |
|
|
cliprdr_handle_first_handshake(STREAM s) |
|
96 |
{ |
{ |
97 |
uint32 remaining_length, pad; |
uint16 type, status; |
98 |
in_uint32_le(s, remaining_length); |
uint32 length, format; |
99 |
in_uint32_le(s, pad); |
uint8 *data; |
|
DEBUG_CLIPBOARD(("Remaining length in first handshake frm server is %d, pad is %d\n", |
|
|
remaining_length, pad)); |
|
|
cliprdr_send_format_announce(); |
|
|
} |
|
100 |
|
|
101 |
void cliprdr_handle_server_data(uint32 length, STREAM s) |
in_uint16_le(s, type); |
102 |
{ |
in_uint16_le(s, status); |
103 |
uint32 remaining_length; |
in_uint32_le(s, length); |
|
char *data; |
|
|
int res; |
|
|
in_uint32_le(s, remaining_length); |
|
104 |
data = s->p; |
data = s->p; |
|
res = XChangeProperty(display, |
|
|
selection_event.requestor, |
|
|
selection_event.property, |
|
|
XInternAtom(display, "STRING", False), |
|
|
8, |
|
|
PropModeAppend, |
|
|
data, |
|
|
remaining_length); |
|
|
|
|
|
DEBUG_CLIPBOARD(("res after XChangeProperty is ")); |
|
|
print_X_error(res); |
|
|
|
|
|
res = XSendEvent(display, |
|
|
selection_event.requestor, |
|
|
False, |
|
|
NoEventMask, |
|
|
(XEvent *)&selection_event); |
|
|
|
|
|
DEBUG_CLIPBOARD(("res after XSendEvent is ")); |
|
|
print_X_error(res); |
|
|
|
|
|
} |
|
|
|
|
|
void cliprdr_handle_server_data_request(STREAM s) |
|
|
{ |
|
|
Window selectionowner; |
|
|
uint32 remaining_length; |
|
|
uint32 wanted_formatcode, pad; |
|
|
|
|
|
in_uint32_le(s, remaining_length); |
|
|
in_uint32_le(s, wanted_formatcode); |
|
|
in_uint32_le(s, pad); |
|
105 |
|
|
106 |
/* FIXME: Check that we support this formatcode */ |
DEBUG_CLIPBOARD(("CLIPRDR recv: type=%d, status=%d, length=%d\n", type, status, length)); |
107 |
|
|
108 |
DEBUG_CLIPBOARD(("Request from server for format %d\n", |
if (status == CLIPRDR_ERROR) |
|
wanted_formatcode)); |
|
|
|
|
|
selectionowner = XGetSelectionOwner(display, primary_atom); |
|
|
|
|
|
if (None != selectionowner) |
|
109 |
{ |
{ |
110 |
|
if (type == CLIPRDR_FORMAT_ACK) |
111 |
/* FIXME: Perhaps we should check if we are the owner? */ |
{ |
112 |
|
/* FIXME: We seem to get this when we send an announce while the server is |
113 |
XConvertSelection(display, primary_atom, |
still processing a paste. Try sending another announce. */ |
114 |
targets_atom, |
cliprdr_send_text_format_announce(); |
115 |
rdesktop_clipboard_target_atom, |
return; |
116 |
wnd, CurrentTime); |
} |
|
|
|
|
/* The rest of the transfer is handled in |
|
|
cliprdr_handle_SelectionNotify */ |
|
|
|
|
|
} else |
|
|
{ |
|
|
DEBUG_CLIPBOARD(("There were no owner for PRIMARY, sending empty string\n")); // FIXME: Should we always send an empty string? |
|
117 |
|
|
118 |
cliprdr_send_empty_datapacket(); |
DEBUG_CLIPBOARD(("CLIPRDR error (type=%d)\n", type)); |
119 |
|
return; |
120 |
} |
} |
121 |
|
|
122 |
|
switch (type) |
|
} |
|
|
|
|
|
|
|
|
void cliprdr_callback(STREAM s) |
|
|
{ |
|
|
uint32 length, flags; |
|
|
uint16 ptype0, ptype1; |
|
|
DEBUG_CLIPBOARD(("cliprdr_callback called, clipboard data:\n")); |
|
|
#ifdef WITH_DEBUG_CLIPBOARD |
|
|
hexdump(s->p, s->end - s->p); |
|
|
#endif |
|
|
in_uint32_le(s, length); |
|
|
in_uint32_le(s, flags); |
|
|
|
|
|
DEBUG_CLIPBOARD(("length is %d, flags are %d\n", length, flags)); |
|
|
|
|
|
if (flags & 0x03 || flags & 0x01) /* Single-write op or first-packet-of-several op */ |
|
123 |
{ |
{ |
124 |
in_uint16_le(s, ptype0); |
case CLIPRDR_CONNECT: |
125 |
in_uint16_le(s, ptype1); |
ui_clip_sync(); |
126 |
DEBUG_CLIPBOARD(("ptype0 is %d, ptype1 is %d\n", ptype0, ptype1)); |
break; |
127 |
if (1 == ptype0 && 0 == ptype1) { |
case CLIPRDR_FORMAT_ANNOUNCE: |
128 |
cliprdr_handle_first_handshake(s); |
ui_clip_format_announce(data, length); |
129 |
return; |
cliprdr_send_packet(CLIPRDR_FORMAT_ACK, CLIPRDR_RESPONSE, NULL, 0); |
|
} else if (3 == ptype0 && 1 == ptype1) |
|
|
{ |
|
|
// Acknowledgment on our format announce. Do we care? Not right now. |
|
|
// There is a strange pad in this packet that we might need some time, |
|
|
// but probably not. |
|
|
DEBUG_CLIPBOARD(("Received format announce ACK\n")); |
|
|
return; |
|
|
|
|
|
} else if (2 == ptype0 && 0 == ptype1) |
|
|
{ |
|
|
cliprdr_register_server_formats(s); |
|
|
cliprdr_select_X_clipboards(); |
|
|
cliprdr_ack_format_list(); |
|
130 |
return; |
return; |
131 |
} else if (5 == ptype0 && 1 == ptype1) |
case CLIPRDR_FORMAT_ACK: |
132 |
{ |
break; |
133 |
cliprdr_handle_server_data(length, s); |
case CLIPRDR_DATA_REQUEST: |
134 |
} else if (4 == ptype0 && 0 == ptype1) |
in_uint32_le(s, format); |
135 |
{ |
ui_clip_request_data(format); |
136 |
cliprdr_handle_server_data_request(s); |
break; |
137 |
} |
case CLIPRDR_DATA_RESPONSE: |
138 |
|
ui_clip_handle_data(data, length); |
139 |
|
break; |
140 |
|
case 7: /* TODO: W2K3 SP1 sends this on connect with a value of 1 */ |
141 |
|
break; |
142 |
|
default: |
143 |
|
unimpl("CLIPRDR packet type %d\n", type); |
144 |
} |
} |
145 |
} |
} |
146 |
|
|
147 |
|
BOOL |
148 |
void cliprdr_init(void) |
cliprdr_init(void) |
149 |
{ |
{ |
150 |
primary_atom = XInternAtom(display, "PRIMARY", False); |
cliprdr_channel = |
151 |
clipboard_atom = XInternAtom(display, "CLIPBOARD", False); |
channel_register("cliprdr", |
152 |
targets_atom = XInternAtom(display, "TARGETS", False); |
CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP | |
153 |
timestamp_atom = XInternAtom(display, "TIMESTAMP", False); |
CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL, |
154 |
rdesktop_clipboard_target_atom = XInternAtom(display, "_RDESKTOP_CLIPBOARD_TARGET", False); |
cliprdr_process); |
155 |
|
return (cliprdr_channel != NULL); |
156 |
} |
} |