astyle formatting for sesman config.h and chansrv clipboard

This commit is contained in:
Jaroslaw Osmanski 2019-02-26 07:40:10 +01:00
parent 0cd13e7e86
commit 0d8a49ab13
2 changed files with 141 additions and 140 deletions

View File

@ -185,38 +185,38 @@ x-special/gnome-copied-files
#define LOG_LEVEL LOG_ERROR #define LOG_LEVEL LOG_ERROR
#define log_error(_params...) \ #define log_error(_params...) \
{ \ { \
g_write("[%10.10u]: CLIPBOARD %s: %d : ERROR: ", \ g_write("[%10.10u]: CLIPBOARD %s: %d : ERROR: ", \
g_time3(), __func__, __LINE__); \ g_time3(), __func__, __LINE__); \
g_writeln (_params); \ g_writeln (_params); \
} }
#define log_always(_params...) \ #define log_always(_params...) \
{ \ { \
g_write("[%10.10u]: CLIPBOARD %s: %d : ALWAYS: ", \ g_write("[%10.10u]: CLIPBOARD %s: %d : ALWAYS: ", \
g_time3(), __func__, __LINE__); \ g_time3(), __func__, __LINE__); \
g_writeln (_params); \ g_writeln (_params); \
} }
#define log_info(_params...) \ #define log_info(_params...) \
{ \ { \
if (LOG_INFO <= LOG_LEVEL) \ if (LOG_INFO <= LOG_LEVEL) \
{ \ { \
g_write("[%10.10u]: CLIPBOARD %s: %d : ", \ g_write("[%10.10u]: CLIPBOARD %s: %d : ", \
g_time3(), __func__, __LINE__); \ g_time3(), __func__, __LINE__); \
g_writeln (_params); \ g_writeln (_params); \
} \ } \
} }
#define log_debug(_params...) \ #define log_debug(_params...) \
{ \ { \
if (LOG_DEBUG <= LOG_LEVEL) \ if (LOG_DEBUG <= LOG_LEVEL) \
{ \ { \
g_write("[%10.10u]: CLIPBOARD %s: %d : ", \ g_write("[%10.10u]: CLIPBOARD %s: %d : ", \
g_time3(), __func__, __LINE__); \ g_time3(), __func__, __LINE__); \
g_writeln (_params); \ g_writeln (_params); \
} \ } \
} }
static char g_bmp_image_header[] = static char g_bmp_image_header[] =
{ {
@ -286,10 +286,10 @@ static int g_file_format_id = -1;
static char g_last_atom_name[256] = ""; static char g_last_atom_name[256] = "";
/*****************************************************************************/ /*****************************************************************************/
static char* static char *
get_atom_text(Atom atom) get_atom_text(Atom atom)
{ {
char* name; char *name;
int failed; int failed;
failed = 0; failed = 0;
@ -405,10 +405,10 @@ clipboard_init(void)
if (rv == 0) if (rv == 0)
{ {
log_debug("clipboard_init: g_xfixes_event_base %d", log_debug("clipboard_init: g_xfixes_event_base %d",
g_xfixes_event_base); g_xfixes_event_base);
st = XFixesQueryVersion(g_display, &ver_maj, &ver_min); st = XFixesQueryVersion(g_display, &ver_maj, &ver_min);
log_debug("clipboard_init st %d, maj %d min %d", st, log_debug("clipboard_init st %d, maj %d min %d", st,
ver_maj, ver_min); ver_maj, ver_min);
g_clip_property_atom = XInternAtom(g_display, "XRDP_CLIP_PROPERTY_ATOM", g_clip_property_atom = XInternAtom(g_display, "XRDP_CLIP_PROPERTY_ATOM",
False); False);
g_get_time_atom = XInternAtom(g_display, "XRDP_GET_TIME_ATOM", g_get_time_atom = XInternAtom(g_display, "XRDP_GET_TIME_ATOM",
@ -428,7 +428,7 @@ clipboard_init(void)
if (g_image_bmp_atom == None) if (g_image_bmp_atom == None)
{ {
log_error("clipboard_init: g_image_bmp_atom was " log_error("clipboard_init: g_image_bmp_atom was "
"not allocated"); "not allocated");
} }
g_wnd = XCreateSimpleWindow(g_display, RootWindowOfScreen(g_screen), g_wnd = XCreateSimpleWindow(g_display, RootWindowOfScreen(g_screen),
@ -463,12 +463,12 @@ clipboard_init(void)
s_mark_end(s); s_mark_end(s);
size = (int)(s->end - s->data); size = (int)(s->end - s->data);
log_debug("clipboard_init: data out, sending " log_debug("clipboard_init: data out, sending "
"CB_CLIP_CAPS (clip_msg_id = 1)"); "CB_CLIP_CAPS (clip_msg_id = 1)");
rv = send_channel_data(g_cliprdr_chan_id, s->data, size); rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
if (rv != 0) if (rv != 0)
{ {
log_error("clipboard_init: send_channel_data failed " log_error("clipboard_init: send_channel_data failed "
"rv = %d", rv); "rv = %d", rv);
rv = 4; rv = 4;
} }
} }
@ -484,12 +484,12 @@ clipboard_init(void)
s_mark_end(s); s_mark_end(s);
size = (int)(s->end - s->data); size = (int)(s->end - s->data);
log_debug("clipboard_init: data out, sending " log_debug("clipboard_init: data out, sending "
"CB_MONITOR_READY (clip_msg_id = 1)"); "CB_MONITOR_READY (clip_msg_id = 1)");
rv = send_channel_data(g_cliprdr_chan_id, s->data, size); rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
if (rv != 0) if (rv != 0)
{ {
log_error("clipboard_init: send_channel_data failed " log_error("clipboard_init: send_channel_data failed "
"rv = %d", rv); "rv = %d", rv);
rv = 4; rv = 4;
} }
} }
@ -554,7 +554,7 @@ clipboard_send_data_request(int format_id)
s_mark_end(s); s_mark_end(s);
size = (int)(s->end - s->data); size = (int)(s->end - s->data);
log_debug("clipboard_send_data_request: data out, sending " log_debug("clipboard_send_data_request: data out, sending "
"CLIPRDR_DATA_REQUEST (clip_msg_id = 4)"); "CLIPRDR_DATA_REQUEST (clip_msg_id = 4)");
rv = send_channel_data(g_cliprdr_chan_id, s->data, size); rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
free_stream(s); free_stream(s);
return rv; return rv;
@ -577,7 +577,7 @@ clipboard_send_format_ack(void)
s_mark_end(s); s_mark_end(s);
size = (int)(s->end - s->data); size = (int)(s->end - s->data);
log_debug("clipboard_send_format_ack: data out, sending " log_debug("clipboard_send_format_ack: data out, sending "
"CLIPRDR_FORMAT_ACK (clip_msg_id = 3)"); "CLIPRDR_FORMAT_ACK (clip_msg_id = 3)");
rv = send_channel_data(g_cliprdr_chan_id, s->data, size); rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
free_stream(s); free_stream(s);
return rv; return rv;
@ -715,7 +715,7 @@ clipboard_send_format_announce(int xrdp_clip_type)
break; break;
default: default:
log_debug("clipboard_send_format_announce: unknown " log_debug("clipboard_send_format_announce: unknown "
"xrdp_clip_type %d", xrdp_clip_type); "xrdp_clip_type %d", xrdp_clip_type);
break; break;
} }
} }
@ -759,7 +759,7 @@ clipboard_send_format_announce(int xrdp_clip_type)
break; break;
default: default:
log_debug("clipboard_send_format_announce: unknown " log_debug("clipboard_send_format_announce: unknown "
"xrdp_clip_type %d", xrdp_clip_type); "xrdp_clip_type %d", xrdp_clip_type);
break; break;
} }
} }
@ -774,7 +774,7 @@ clipboard_send_format_announce(int xrdp_clip_type)
size = (int)(s->end - s->data); size = (int)(s->end - s->data);
//g_hexdump(s->data, size); //g_hexdump(s->data, size);
log_debug("clipboard_send_format_announce: data out, sending " log_debug("clipboard_send_format_announce: data out, sending "
"CLIPRDR_FORMAT_ANNOUNCE (clip_msg_id = 2)"); "CLIPRDR_FORMAT_ANNOUNCE (clip_msg_id = 2)");
rv = send_channel_data(g_cliprdr_chan_id, s->data, size); rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
free_stream(s); free_stream(s);
return rv; return rv;
@ -789,7 +789,7 @@ clipboard_send_data_response_for_image(const char *data, int data_size)
int rv; int rv;
log_debug("clipboard_send_data_response_for_image: data_size %d", log_debug("clipboard_send_data_response_for_image: data_size %d",
data_size); data_size);
make_stream(s); make_stream(s);
init_stream(s, 64 + data_size); init_stream(s, 64 + data_size);
out_uint16_le(s, CB_FORMAT_DATA_RESPONSE); /* 5 CLIPRDR_DATA_RESPONSE */ out_uint16_le(s, CB_FORMAT_DATA_RESPONSE); /* 5 CLIPRDR_DATA_RESPONSE */
@ -814,17 +814,17 @@ clipboard_send_data_response_for_text(const char *data, int data_size)
int num_chars; int num_chars;
log_debug("clipboard_send_data_response_for_text: data_size %d", log_debug("clipboard_send_data_response_for_text: data_size %d",
data_size); data_size);
//g_hexdump(data, data_size); //g_hexdump(data, data_size);
num_chars = g_mbstowcs(0, data, 0); num_chars = g_mbstowcs(0, data, 0);
if (num_chars < 0) if (num_chars < 0)
{ {
log_error("clipboard_send_data_response_for_text: " log_error("clipboard_send_data_response_for_text: "
"bad string"); "bad string");
num_chars = 0; num_chars = 0;
} }
log_debug("clipboard_send_data_response_for_text: data_size %d " log_debug("clipboard_send_data_response_for_text: data_size %d "
"num_chars %d", data_size, num_chars); "num_chars %d", data_size, num_chars);
make_stream(s); make_stream(s);
init_stream(s, 64 + num_chars * 2); init_stream(s, 64 + num_chars * 2);
out_uint16_le(s, CB_FORMAT_DATA_RESPONSE); /* 5 CLIPRDR_DATA_RESPONSE */ out_uint16_le(s, CB_FORMAT_DATA_RESPONSE); /* 5 CLIPRDR_DATA_RESPONSE */
@ -833,15 +833,15 @@ clipboard_send_data_response_for_text(const char *data, int data_size)
if (clipboard_out_unicode(s, data, num_chars) != num_chars * 2) if (clipboard_out_unicode(s, data, num_chars) != num_chars * 2)
{ {
log_error("clipboard_send_data_response_for_text: error " log_error("clipboard_send_data_response_for_text: error "
"clipboard_out_unicode didn't write right number of bytes"); "clipboard_out_unicode didn't write right number of bytes");
} }
out_uint16_le(s, 0); /* nil for string */ out_uint16_le(s, 0); /* nil for string */
out_uint32_le(s, 0); out_uint32_le(s, 0);
s_mark_end(s); s_mark_end(s);
size = (int)(s->end - s->data); size = (int)(s->end - s->data);
log_debug("clipboard_send_data_response_for_text: data out, " log_debug("clipboard_send_data_response_for_text: data out, "
"sending CLIPRDR_DATA_RESPONSE (clip_msg_id = 5) size %d " "sending CLIPRDR_DATA_RESPONSE (clip_msg_id = 5) size %d "
"num_chars %d", size, num_chars); "num_chars %d", size, num_chars);
rv = send_channel_data(g_cliprdr_chan_id, s->data, size); rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
free_stream(s); free_stream(s);
return rv; return rv;
@ -869,7 +869,7 @@ clipboard_send_data_response(int xrdp_clip_type, const char *data, int data_size
else else
{ {
log_debug("clipboard_send_data_response: unknown " log_debug("clipboard_send_data_response: unknown "
"xrdp_clip_type %d", xrdp_clip_type); "xrdp_clip_type %d", xrdp_clip_type);
} }
} }
else else
@ -908,7 +908,7 @@ clipboard_provide_selection_c2s(XSelectionRequestEvent *req, Atom type)
long val1[2]; long val1[2];
log_debug("clipboard_provide_selection_c2s: bytes %d", log_debug("clipboard_provide_selection_c2s: bytes %d",
g_clip_c2s.total_bytes); g_clip_c2s.total_bytes);
if (g_clip_c2s.total_bytes < g_incr_max_req_size) if (g_clip_c2s.total_bytes < g_incr_max_req_size)
{ {
XChangeProperty(g_display, req->requestor, req->property, XChangeProperty(g_display, req->requestor, req->property,
@ -934,8 +934,8 @@ clipboard_provide_selection_c2s(XSelectionRequestEvent *req, Atom type)
g_clip_c2s.property = req->property; g_clip_c2s.property = req->property;
g_clip_c2s.window = req->requestor; g_clip_c2s.window = req->requestor;
log_debug("clipboard_provide_selection_c2s: start INCR property %s " log_debug("clipboard_provide_selection_c2s: start INCR property %s "
"type %s", get_atom_text(req->property), "type %s", get_atom_text(req->property),
get_atom_text(type)); get_atom_text(type));
val1[0] = g_clip_c2s.total_bytes; val1[0] = g_clip_c2s.total_bytes;
val1[1] = 0; val1[1] = 0;
XChangeProperty(g_display, req->requestor, req->property, XChangeProperty(g_display, req->requestor, req->property,
@ -1020,7 +1020,7 @@ clipboard_process_format_announce(struct stream *s, int clip_msg_status,
char *holdp; char *holdp;
log_debug("clipboard_process_format_announce: " log_debug("clipboard_process_format_announce: "
"CLIPRDR_FORMAT_ANNOUNCE"); "CLIPRDR_FORMAT_ANNOUNCE");
log_debug("clipboard_process_format_announce %d", clip_msg_len); log_debug("clipboard_process_format_announce %d", clip_msg_len);
clipboard_send_format_ack(); clipboard_send_format_ack();
@ -1052,8 +1052,8 @@ clipboard_process_format_announce(struct stream *s, int clip_msg_status,
clip_msg_len -= 32; clip_msg_len -= 32;
} }
log_debug("clipboard_process_format_announce: formatId 0x%8.8x " log_debug("clipboard_process_format_announce: formatId 0x%8.8x "
"wszFormatName [%s] clip_msg_len %d", formatId, desc, "wszFormatName [%s] clip_msg_len %d", formatId, desc,
clip_msg_len); clip_msg_len);
if (g_num_formatIds <= 15) if (g_num_formatIds <= 15)
{ {
g_formatIds[g_num_formatIds] = formatId; g_formatIds[g_num_formatIds] = formatId;
@ -1073,13 +1073,13 @@ clipboard_process_format_announce(struct stream *s, int clip_msg_status,
} }
if ((g_num_formatIds > 0) && if ((g_num_formatIds > 0) &&
(g_clip_c2s.incr_in_progress == 0) && /* don't interrupt incr */ (g_clip_c2s.incr_in_progress == 0) && /* don't interrupt incr */
(g_clip_s2c.incr_in_progress == 0)) (g_clip_s2c.incr_in_progress == 0))
{ {
if (clipboard_set_selection_owner() != 0) if (clipboard_set_selection_owner() != 0)
{ {
log_error("clipboard_process_format_announce: " log_error("clipboard_process_format_announce: "
"XSetSelectionOwner failed"); "XSetSelectionOwner failed");
} }
} }
@ -1130,7 +1130,7 @@ clipboard_process_data_request(struct stream *s, int clip_msg_status,
int requestedFormatId; int requestedFormatId;
log_debug("clipboard_process_data_request: " log_debug("clipboard_process_data_request: "
"CLIPRDR_DATA_REQUEST"); "CLIPRDR_DATA_REQUEST");
log_debug("clipboard_process_data_request:"); log_debug("clipboard_process_data_request:");
log_debug(" %d", g_clip_s2c.xrdp_clip_type); log_debug(" %d", g_clip_s2c.xrdp_clip_type);
in_uint32_le(s, requestedFormatId); in_uint32_le(s, requestedFormatId);
@ -1146,7 +1146,7 @@ clipboard_process_data_request(struct stream *s, int clip_msg_status,
else else
{ {
log_debug("clipboard_process_data_request: CB_FORMAT_FILE, " log_debug("clipboard_process_data_request: CB_FORMAT_FILE, "
"calling XConvertSelection to g_utf8_atom"); "calling XConvertSelection to g_utf8_atom");
g_clip_s2c.xrdp_clip_type = XRDP_CB_FILE; g_clip_s2c.xrdp_clip_type = XRDP_CB_FILE;
XConvertSelection(g_display, g_clipboard_atom, g_clip_s2c.type, XConvertSelection(g_display, g_clipboard_atom, g_clip_s2c.type,
g_clip_property_atom, g_wnd, CurrentTime); g_clip_property_atom, g_wnd, CurrentTime);
@ -1162,7 +1162,7 @@ clipboard_process_data_request(struct stream *s, int clip_msg_status,
else else
{ {
log_debug("clipboard_process_data_request: CB_FORMAT_DIB, " log_debug("clipboard_process_data_request: CB_FORMAT_DIB, "
"calling XConvertSelection to g_image_bmp_atom"); "calling XConvertSelection to g_image_bmp_atom");
g_clip_s2c.xrdp_clip_type = XRDP_CB_BITMAP; g_clip_s2c.xrdp_clip_type = XRDP_CB_BITMAP;
XConvertSelection(g_display, g_clipboard_atom, g_image_bmp_atom, XConvertSelection(g_display, g_clipboard_atom, g_image_bmp_atom,
g_clip_property_atom, g_wnd, CurrentTime); g_clip_property_atom, g_wnd, CurrentTime);
@ -1178,7 +1178,7 @@ clipboard_process_data_request(struct stream *s, int clip_msg_status,
else else
{ {
log_debug("clipboard_process_data_request: CB_FORMAT_UNICODETEXT, " log_debug("clipboard_process_data_request: CB_FORMAT_UNICODETEXT, "
"calling XConvertSelection to g_utf8_atom"); "calling XConvertSelection to g_utf8_atom");
g_clip_s2c.xrdp_clip_type = XRDP_CB_TEXT; g_clip_s2c.xrdp_clip_type = XRDP_CB_TEXT;
XConvertSelection(g_display, g_clipboard_atom, g_utf8_atom, XConvertSelection(g_display, g_clipboard_atom, g_utf8_atom,
g_clip_property_atom, g_wnd, CurrentTime); g_clip_property_atom, g_wnd, CurrentTime);
@ -1186,7 +1186,7 @@ clipboard_process_data_request(struct stream *s, int clip_msg_status,
break; break;
default: default:
log_debug("clipboard_process_data_request: unknown type %d", log_debug("clipboard_process_data_request: unknown type %d",
requestedFormatId); requestedFormatId);
clipboard_send_data_response_failed(); clipboard_send_data_response_failed();
break; break;
} }
@ -1201,14 +1201,14 @@ clipboard_process_data_request(struct stream *s, int clip_msg_status,
clipboard data. */ clipboard data. */
static int static int
clipboard_process_data_response_for_image(struct stream *s, clipboard_process_data_response_for_image(struct stream *s,
int clip_msg_status, int clip_msg_status,
int clip_msg_len) int clip_msg_len)
{ {
XSelectionRequestEvent *lxev; XSelectionRequestEvent *lxev;
int len; int len;
log_debug("clipboard_process_data_response_for_image: " log_debug("clipboard_process_data_response_for_image: "
"CLIPRDR_DATA_RESPONSE_FOR_IMAGE"); "CLIPRDR_DATA_RESPONSE_FOR_IMAGE");
lxev = &g_saved_selection_req_event; lxev = &g_saved_selection_req_event;
len = (int)(s->end - s->p); len = (int)(s->end - s->p);
if (len < 1) if (len < 1)
@ -1231,7 +1231,7 @@ clipboard_process_data_response_for_image(struct stream *s,
g_memcpy(g_clip_c2s.data, g_bmp_image_header, 14); g_memcpy(g_clip_c2s.data, g_bmp_image_header, 14);
in_uint8a(s, g_clip_c2s.data + 14, len); in_uint8a(s, g_clip_c2s.data + 14, len);
log_debug("clipboard_process_data_response_for_image: calling " log_debug("clipboard_process_data_response_for_image: calling "
"clipboard_provide_selection_c2s"); "clipboard_provide_selection_c2s");
clipboard_provide_selection_c2s(lxev, lxev->target); clipboard_provide_selection_c2s(lxev, lxev->target);
return 0; return 0;
} }
@ -1259,7 +1259,7 @@ clipboard_process_data_response(struct stream *s, int clip_msg_status,
if (g_clip_c2s.xrdp_clip_type == XRDP_CB_BITMAP) if (g_clip_c2s.xrdp_clip_type == XRDP_CB_BITMAP)
{ {
clipboard_process_data_response_for_image(s, clip_msg_status, clipboard_process_data_response_for_image(s, clip_msg_status,
clip_msg_len); clip_msg_len);
return 0; return 0;
} }
if (g_clip_c2s.xrdp_clip_type == XRDP_CB_FILE) if (g_clip_c2s.xrdp_clip_type == XRDP_CB_FILE)
@ -1287,7 +1287,7 @@ clipboard_process_data_response(struct stream *s, int clip_msg_status,
return 0; return 0;
} }
log_debug("clipboard_process_data_response: " log_debug("clipboard_process_data_response: "
"CLIPRDR_DATA_RESPONSE"); "CLIPRDR_DATA_RESPONSE");
len = (int)(s->end - s->p); len = (int)(s->end - s->p);
if (len < 1) if (len < 1)
{ {
@ -1362,10 +1362,10 @@ clipboard_process_clip_caps(struct stream *s, int clip_msg_status,
in_uint32_le(s, version); /* version */ in_uint32_le(s, version); /* version */
in_uint32_le(s, flags); /* generalFlags */ in_uint32_le(s, flags); /* generalFlags */
log_debug("clipboard_process_clip_caps: " log_debug("clipboard_process_clip_caps: "
"g_cliprdr_version %d version %d " "g_cliprdr_version %d version %d "
"g_cliprdr_flags 0x%x flags 0x%x", "g_cliprdr_flags 0x%x flags 0x%x",
g_cliprdr_version, version, g_cliprdr_version, version,
g_cliprdr_flags, flags); g_cliprdr_flags, flags);
if (version < g_cliprdr_version) if (version < g_cliprdr_version)
{ {
g_cliprdr_version = version; g_cliprdr_version = version;
@ -1374,7 +1374,7 @@ clipboard_process_clip_caps(struct stream *s, int clip_msg_status,
break; break;
default: default:
log_debug("clipboard_process_clip_caps: unknown " log_debug("clipboard_process_clip_caps: unknown "
"capabilitySetType %d", capabilitySetType); "capabilitySetType %d", capabilitySetType);
break; break;
} }
s->p = holdp + lengthCapability; s->p = holdp + lengthCapability;
@ -1552,16 +1552,16 @@ clipboard_data_in(struct stream *s, int chan_id, int chan_flags, int length,
if (!g_clip_up) if (!g_clip_up)
{ {
log_error("aborting clipboard_data_in - clipboard has not " log_error("aborting clipboard_data_in - clipboard has not "
"been initialized"); "been initialized");
/* we return 0 here to indicate no protocol problem occurred */ /* we return 0 here to indicate no protocol problem occurred */
return 0; return 0;
} }
log_debug("clipboard_data_in: chan_id %d " log_debug("clipboard_data_in: chan_id %d "
"chan_flags 0x%x length %d total_length %d " "chan_flags 0x%x length %d total_length %d "
"in_request %d g_ins->size %d", "in_request %d g_ins->size %d",
chan_id, chan_flags, length, total_length, chan_id, chan_flags, length, total_length,
g_clip_c2s.in_request, g_ins->size); g_clip_c2s.in_request, g_ins->size);
if (g_clip_c2s.doing_response_ss) if (g_clip_c2s.doing_response_ss)
{ {
@ -1621,37 +1621,37 @@ clipboard_data_in(struct stream *s, int chan_id, int chan_flags, int length,
in_uint32_le(ls, clip_msg_len); in_uint32_le(ls, clip_msg_len);
log_debug("clipboard_data_in: clip_msg_id %d " log_debug("clipboard_data_in: clip_msg_id %d "
"clip_msg_status %d clip_msg_len %d", "clip_msg_status %d clip_msg_len %d",
clip_msg_id, clip_msg_status, clip_msg_len); clip_msg_id, clip_msg_status, clip_msg_len);
rv = 0; rv = 0;
log_debug("clipboard_data_in: %d", clip_msg_id); log_debug("clipboard_data_in: %d", clip_msg_id);
switch (clip_msg_id) switch (clip_msg_id)
{ {
/* sent by client or server when its local system clipboard is */ /* sent by client or server when its local system clipboard is */
/* updated with new clipboard data; contains Clipboard Format ID */ /* updated with new clipboard data; contains Clipboard Format ID */
/* and name pairs of new Clipboard Formats on the clipboard. */ /* and name pairs of new Clipboard Formats on the clipboard. */
case CB_FORMAT_LIST: /* 2 CLIPRDR_FORMAT_ANNOUNCE */ case CB_FORMAT_LIST: /* 2 CLIPRDR_FORMAT_ANNOUNCE */
rv = clipboard_process_format_announce(ls, clip_msg_status, rv = clipboard_process_format_announce(ls, clip_msg_status,
clip_msg_len); clip_msg_len);
break; break;
/* response to CB_FORMAT_LIST; used to indicate whether */ /* response to CB_FORMAT_LIST; used to indicate whether */
/* processing of the Format List PDU was successful */ /* processing of the Format List PDU was successful */
case CB_FORMAT_LIST_RESPONSE: /* 3 CLIPRDR_FORMAT_ACK */ case CB_FORMAT_LIST_RESPONSE: /* 3 CLIPRDR_FORMAT_ACK */
rv = clipboard_process_format_ack(ls, clip_msg_status, rv = clipboard_process_format_ack(ls, clip_msg_status,
clip_msg_len); clip_msg_len);
break; break;
/* sent by recipient of CB_FORMAT_LIST; used to request data for one */ /* sent by recipient of CB_FORMAT_LIST; used to request data for one */
/* of the formats that was listed in CB_FORMAT_LIST */ /* of the formats that was listed in CB_FORMAT_LIST */
case CB_FORMAT_DATA_REQUEST: /* 4 CLIPRDR_DATA_REQUEST */ case CB_FORMAT_DATA_REQUEST: /* 4 CLIPRDR_DATA_REQUEST */
rv = clipboard_process_data_request(ls, clip_msg_status, rv = clipboard_process_data_request(ls, clip_msg_status,
clip_msg_len); clip_msg_len);
break; break;
/* sent as a reply to CB_FORMAT_DATA_REQUEST; used to indicate */ /* sent as a reply to CB_FORMAT_DATA_REQUEST; used to indicate */
/* whether processing of the CB_FORMAT_DATA_REQUEST was */ /* whether processing of the CB_FORMAT_DATA_REQUEST was */
/* successful; if processing was successful, */ /* successful; if processing was successful, */
/* CB_FORMAT_DATA_RESPONSE includes contents of requested */ /* CB_FORMAT_DATA_RESPONSE includes contents of requested */
/* clipboard data. */ /* clipboard data. */
case CB_FORMAT_DATA_RESPONSE: /* 5 CLIPRDR_DATA_RESPONSE */ case CB_FORMAT_DATA_RESPONSE: /* 5 CLIPRDR_DATA_RESPONSE */
rv = clipboard_process_data_response(ls, clip_msg_status, rv = clipboard_process_data_response(ls, clip_msg_status,
clip_msg_len); clip_msg_len);
@ -1671,7 +1671,7 @@ clipboard_data_in(struct stream *s, int chan_id, int chan_flags, int length,
default: default:
log_debug("clipboard_data_in: unknown clip_msg_id %d", clip_msg_id); log_debug("clipboard_data_in: unknown clip_msg_id %d", clip_msg_id);
log_error("clipboard_data_in: unknown clip_msg_id %d", log_error("clipboard_data_in: unknown clip_msg_id %d",
clip_msg_id); clip_msg_id);
break; break;
} }
@ -1703,21 +1703,22 @@ clipboard_event_selection_owner_notify(XEvent *xevent)
lxevent = (XFixesSelectionNotifyEvent *)xevent; lxevent = (XFixesSelectionNotifyEvent *)xevent;
log_debug("clipboard_event_selection_owner_notify: 0x%lx", lxevent->owner); log_debug("clipboard_event_selection_owner_notify: 0x%lx", lxevent->owner);
log_debug("clipboard_event_selection_owner_notify: " log_debug("clipboard_event_selection_owner_notify: "
"window %ld subtype %d owner %ld g_wnd %ld", "window %ld subtype %d owner %ld g_wnd %ld",
lxevent->window, lxevent->subtype, lxevent->owner, g_wnd); lxevent->window, lxevent->subtype, lxevent->owner, g_wnd);
if (lxevent->owner == g_wnd) if (lxevent->owner == g_wnd)
{ {
log_debug("clipboard_event_selection_owner_notify: matches g_wnd"); log_debug("clipboard_event_selection_owner_notify: matches g_wnd");
log_debug("clipboard_event_selection_owner_notify: skipping, " log_debug("clipboard_event_selection_owner_notify: skipping, "
"owner == g_wnd"); "owner == g_wnd");
g_got_selection = 1; g_got_selection = 1;
return 0; return 0;
} }
g_got_selection = 0; g_got_selection = 0;
if (lxevent->owner != 0) /* nil owner comes when selection */ if (lxevent->owner != 0) /* nil owner comes when selection */
{ /* window is closed */ {
/* window is closed */
XConvertSelection(g_display, g_clipboard_atom, g_targets_atom, XConvertSelection(g_display, g_clipboard_atom, g_targets_atom,
g_clip_property_atom, g_wnd, lxevent->timestamp); g_clip_property_atom, g_wnd, lxevent->timestamp);
} }
@ -1871,22 +1872,22 @@ clipboard_event_selection_notify(XEvent *xevent)
if (lxevent->property == None) if (lxevent->property == None)
{ {
log_error("clipboard_event_selection_notify: clip could " log_error("clipboard_event_selection_notify: clip could "
"not be converted"); "not be converted");
rv = 1; rv = 1;
} }
if (rv == 0) if (rv == 0)
{ {
log_debug("clipboard_event_selection_notify: wnd 0x%lx prop %s", log_debug("clipboard_event_selection_notify: wnd 0x%lx prop %s",
lxevent->requestor, lxevent->requestor,
get_atom_text(lxevent->property)); get_atom_text(lxevent->property));
rv = clipboard_get_window_property(lxevent->requestor, lxevent->property, rv = clipboard_get_window_property(lxevent->requestor, lxevent->property,
&type, &fmt, &type, &fmt,
&n_items, &data, &data_size); &n_items, &data, &data_size);
if (rv != 0) if (rv != 0)
{ {
log_error("clipboard_event_selection_notify: " log_error("clipboard_event_selection_notify: "
"clipboard_get_window_property failed error %d", rv); "clipboard_get_window_property failed error %d", rv);
return 0; return 0;
} }
//g_hexdump(data, data_size); //g_hexdump(data, data_size);
@ -1896,9 +1897,9 @@ clipboard_event_selection_notify(XEvent *xevent)
/* nothing more to do here, the data is coming in through /* nothing more to do here, the data is coming in through
PropertyNotify */ PropertyNotify */
log_debug("clipboard_event_selection_notify: type is INCR " log_debug("clipboard_event_selection_notify: type is INCR "
"data_size %d property name %s type %s", data_size, "data_size %d property name %s type %s", data_size,
get_atom_text(lxevent->property), get_atom_text(lxevent->property),
get_atom_text(lxevent->type)); get_atom_text(lxevent->type));
g_clip_s2c.incr_in_progress = 1; g_clip_s2c.incr_in_progress = 1;
g_clip_s2c.property = lxevent->property; g_clip_s2c.property = lxevent->property;
g_clip_s2c.type = lxevent->target; g_clip_s2c.type = lxevent->target;
@ -1928,7 +1929,7 @@ clipboard_event_selection_notify(XEvent *xevent)
"clipboard_event_selection_notify: 0x%lx %s 0x%lx", "clipboard_event_selection_notify: 0x%lx %s 0x%lx",
atom, get_atom_text(atom), XA_STRING)); atom, get_atom_text(atom), XA_STRING));
log_debug("clipboard_event_selection_notify: 0x%lx %s", log_debug("clipboard_event_selection_notify: 0x%lx %s",
atom, get_atom_text(atom)); atom, get_atom_text(atom));
if (atom == g_utf8_atom) if (atom == g_utf8_atom)
{ {
got_utf8 = 1; got_utf8 = 1;
@ -1955,16 +1956,16 @@ clipboard_event_selection_notify(XEvent *xevent)
else else
{ {
log_error("clipboard_event_selection_notify: error, " log_error("clipboard_event_selection_notify: error, "
"target is 'TARGETS' and type[%ld] or fmt[%d] not right, " "target is 'TARGETS' and type[%ld] or fmt[%d] not right, "
"should be type[%ld], fmt[%d]", type, fmt, XA_ATOM, 32); "should be type[%ld], fmt[%d]", type, fmt, XA_ATOM, 32);
} }
} }
else if (lxevent->target == g_utf8_atom) else if (lxevent->target == g_utf8_atom)
{ {
log_debug("clipboard_event_selection_notify: UTF8_STRING " log_debug("clipboard_event_selection_notify: UTF8_STRING "
"data_size %d", data_size); "data_size %d", data_size);
log_debug("clipboard_event_selection_notify: UTF8_STRING " log_debug("clipboard_event_selection_notify: UTF8_STRING "
"data_size %d", data_size); "data_size %d", data_size);
if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 0)) if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 0))
{ {
g_free(g_clip_s2c.data); g_free(g_clip_s2c.data);
@ -1987,9 +1988,9 @@ clipboard_event_selection_notify(XEvent *xevent)
else if (lxevent->target == XA_STRING) else if (lxevent->target == XA_STRING)
{ {
log_debug("clipboard_event_selection_notify: XA_STRING " log_debug("clipboard_event_selection_notify: XA_STRING "
"data_size %d", data_size); "data_size %d", data_size);
log_debug("clipboard_event_selection_notify: XA_STRING " log_debug("clipboard_event_selection_notify: XA_STRING "
"data_size %d", data_size); "data_size %d", data_size);
if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 0)) if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 0))
{ {
g_free(g_clip_s2c.data); g_free(g_clip_s2c.data);
@ -2004,9 +2005,9 @@ clipboard_event_selection_notify(XEvent *xevent)
else if (lxevent->target == g_image_bmp_atom) else if (lxevent->target == g_image_bmp_atom)
{ {
log_debug("clipboard_event_selection_notify: image/bmp " log_debug("clipboard_event_selection_notify: image/bmp "
"data_size %d", data_size); "data_size %d", data_size);
log_debug("clipboard_event_selection_notify: image/bmp " log_debug("clipboard_event_selection_notify: image/bmp "
"data_size %d", data_size); "data_size %d", data_size);
if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 14)) if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 14))
{ {
g_free(g_clip_s2c.data); g_free(g_clip_s2c.data);
@ -2020,9 +2021,9 @@ clipboard_event_selection_notify(XEvent *xevent)
else if (lxevent->target == g_file_atom1) else if (lxevent->target == g_file_atom1)
{ {
log_debug("clipboard_event_selection_notify: text/uri-list " log_debug("clipboard_event_selection_notify: text/uri-list "
"data_size %d", data_size); "data_size %d", data_size);
log_debug("clipboard_event_selection_notify: text/uri-list " log_debug("clipboard_event_selection_notify: text/uri-list "
"data_size %d", data_size); "data_size %d", data_size);
if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 0)) if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 0))
{ {
g_free(g_clip_s2c.data); g_free(g_clip_s2c.data);
@ -2037,9 +2038,9 @@ clipboard_event_selection_notify(XEvent *xevent)
else if (lxevent->target == g_file_atom2) else if (lxevent->target == g_file_atom2)
{ {
log_debug("clipboard_event_selection_notify: text/uri-list " log_debug("clipboard_event_selection_notify: text/uri-list "
"data_size %d", data_size); "data_size %d", data_size);
log_debug("clipboard_event_selection_notify: text/uri-list " log_debug("clipboard_event_selection_notify: text/uri-list "
"data_size %d", data_size); "data_size %d", data_size);
if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 0)) if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 0))
{ {
g_free(g_clip_s2c.data); g_free(g_clip_s2c.data);
@ -2054,13 +2055,13 @@ clipboard_event_selection_notify(XEvent *xevent)
else else
{ {
log_error("clipboard_event_selection_notify: " log_error("clipboard_event_selection_notify: "
"unknown target"); "unknown target");
} }
} }
else else
{ {
log_error("clipboard_event_selection_notify: " log_error("clipboard_event_selection_notify: "
"unknown selection"); "unknown selection");
} }
} }
@ -2145,24 +2146,24 @@ clipboard_event_selection_request(XEvent *xevent)
lxev = (XSelectionRequestEvent *)xevent; lxev = (XSelectionRequestEvent *)xevent;
log_debug("clipboard_event_selection_request: 0x%lx", lxev->property); log_debug("clipboard_event_selection_request: 0x%lx", lxev->property);
log_debug("clipboard_event_selection_request: g_wnd %ld, " log_debug("clipboard_event_selection_request: g_wnd %ld, "
".requestor %ld .owner %ld .selection %ld '%s' .target %ld .property %ld", ".requestor %ld .owner %ld .selection %ld '%s' .target %ld .property %ld",
g_wnd, lxev->requestor, lxev->owner, lxev->selection, g_wnd, lxev->requestor, lxev->owner, lxev->selection,
get_atom_text(lxev->selection), get_atom_text(lxev->selection),
lxev->target, lxev->property); lxev->target, lxev->property);
if (lxev->property == None) if (lxev->property == None)
{ {
log_debug("clipboard_event_selection_request: lxev->property " log_debug("clipboard_event_selection_request: lxev->property "
"is None"); "is None");
log_debug("clipboard_event_selection_request: " log_debug("clipboard_event_selection_request: "
"lxev->property is None"); "lxev->property is None");
} }
else if (lxev->target == g_targets_atom) else if (lxev->target == g_targets_atom)
{ {
log_debug("clipboard_event_selection_request: g_targets_atom"); log_debug("clipboard_event_selection_request: g_targets_atom");
/* requestor is asking what the selection can be converted to */ /* requestor is asking what the selection can be converted to */
log_debug("clipboard_event_selection_request: " log_debug("clipboard_event_selection_request: "
"g_targets_atom"); "g_targets_atom");
atom_buf[0] = g_targets_atom; atom_buf[0] = g_targets_atom;
atom_buf[1] = g_timestamp_atom; atom_buf[1] = g_timestamp_atom;
atom_buf[2] = g_multiple_atom; atom_buf[2] = g_multiple_atom;
@ -2193,7 +2194,7 @@ clipboard_event_selection_request(XEvent *xevent)
{ {
/* requestor is asking the time I got the selection */ /* requestor is asking the time I got the selection */
log_debug("clipboard_event_selection_request: " log_debug("clipboard_event_selection_request: "
"g_timestamp_atom"); "g_timestamp_atom");
atom_buf[0] = g_selection_time; atom_buf[0] = g_selection_time;
atom_buf[1] = 0; atom_buf[1] = 0;
return clipboard_provide_selection(lxev, XA_INTEGER, 32, return clipboard_provide_selection(lxev, XA_INTEGER, 32,
@ -2203,7 +2204,7 @@ clipboard_event_selection_request(XEvent *xevent)
{ {
/* target, property pairs */ /* target, property pairs */
log_debug("clipboard_event_selection_request: " log_debug("clipboard_event_selection_request: "
"g_multiple_atom"); "g_multiple_atom");
xdata = 0; xdata = 0;
if (clipboard_get_window_property(lxev->requestor, lxev->property, if (clipboard_get_window_property(lxev->requestor, lxev->property,
@ -2211,7 +2212,7 @@ clipboard_event_selection_request(XEvent *xevent)
&xdata_size) == 0) &xdata_size) == 0)
{ {
log_debug("clipboard_event_selection_request: g_multiple_atom " log_debug("clipboard_event_selection_request: g_multiple_atom "
"n_items %d", n_items); "n_items %d", n_items);
/* todo */ /* todo */
g_free(xdata); g_free(xdata);
} }
@ -2276,7 +2277,7 @@ clipboard_event_selection_request(XEvent *xevent)
else else
{ {
log_debug("clipboard_event_selection_request: unknown " log_debug("clipboard_event_selection_request: unknown "
"target %s", get_atom_text(lxev->target)); "target %s", get_atom_text(lxev->target));
LOGM((LOG_LEVEL_ERROR, "clipboard_event_selection_request: unknown " LOGM((LOG_LEVEL_ERROR, "clipboard_event_selection_request: unknown "
"target %s", get_atom_text(lxev->target))); "target %s", get_atom_text(lxev->target)));
} }
@ -2332,9 +2333,9 @@ clipboard_event_property_notify(XEvent *xevent)
log_debug("clipboard_event_property_notify:"); log_debug("clipboard_event_property_notify:");
log_debug("clipboard_event_property_notify: PropertyNotify .window %ld " log_debug("clipboard_event_property_notify: PropertyNotify .window %ld "
".state %d .atom %ld %s", xevent->xproperty.window, ".state %d .atom %ld %s", xevent->xproperty.window,
xevent->xproperty.state, xevent->xproperty.atom, xevent->xproperty.state, xevent->xproperty.atom,
get_atom_text(xevent->xproperty.atom)); get_atom_text(xevent->xproperty.atom));
if (g_clip_c2s.incr_in_progress && if (g_clip_c2s.incr_in_progress &&
(xevent->xproperty.window == g_clip_c2s.window) && (xevent->xproperty.window == g_clip_c2s.window) &&
@ -2353,7 +2354,7 @@ clipboard_event_property_notify(XEvent *xevent)
data = (tui8 *)(g_clip_c2s.data + g_clip_c2s.incr_bytes_done); data = (tui8 *)(g_clip_c2s.data + g_clip_c2s.incr_bytes_done);
data_bytes = g_clip_c2s.read_bytes_done - g_clip_c2s.incr_bytes_done; data_bytes = g_clip_c2s.read_bytes_done - g_clip_c2s.incr_bytes_done;
if ((data_bytes < 1) && if ((data_bytes < 1) &&
(g_clip_c2s.read_bytes_done < g_clip_c2s.total_bytes)) (g_clip_c2s.read_bytes_done < g_clip_c2s.total_bytes))
{ {
g_clip_c2s.incr_in_progress = 0; g_clip_c2s.incr_in_progress = 0;
return 0; return 0;
@ -2423,7 +2424,7 @@ clipboard_event_property_notify(XEvent *xevent)
else else
{ {
log_error("clipboard_event_property_notify: error unknown type %ld", log_error("clipboard_event_property_notify: error unknown type %ld",
g_clip_s2c.type); g_clip_s2c.type);
clipboard_send_data_response_failed(); clipboard_send_data_response_failed();
} }

View File

@ -481,7 +481,7 @@ config_dump(struct config_sesman *config)
g_writeln(" DefaultWindowManager: %s", config->default_wm); g_writeln(" DefaultWindowManager: %s", config->default_wm);
g_writeln(" ReconnectScript: %s", config->reconnect_sh); g_writeln(" ReconnectScript: %s", config->reconnect_sh);
g_writeln(" AuthFilePath: %s", g_writeln(" AuthFilePath: %s",
((config->auth_file_path) ? (config->auth_file_path) : ("disabled"))); ((config->auth_file_path) ? (config->auth_file_path) : ("disabled")));
/* Session configuration */ /* Session configuration */
g_writeln("Session configuration:"); g_writeln("Session configuration:");
@ -530,7 +530,7 @@ config_dump(struct config_sesman *config)
for (i = 0; i < config->xorg_params->count; i++) for (i = 0; i < config->xorg_params->count; i++)
{ {
g_writeln(" Parameter %02d %s", g_writeln(" Parameter %02d %s",
i, (char *) list_get_item(config->xorg_params, i)); i, (char *) list_get_item(config->xorg_params, i));
} }
/* Xvnc */ /* Xvnc */
@ -542,7 +542,7 @@ config_dump(struct config_sesman *config)
for (i = 0; i < config->vnc_params->count; i++) for (i = 0; i < config->vnc_params->count; i++)
{ {
g_writeln(" Parameter %02d %s", g_writeln(" Parameter %02d %s",
i, (char *)list_get_item(config->vnc_params, i)); i, (char *)list_get_item(config->vnc_params, i));
} }
/* X11rdp */ /* X11rdp */
@ -554,7 +554,7 @@ config_dump(struct config_sesman *config)
for (i = 0; i < config->rdp_params->count; i++) for (i = 0; i < config->rdp_params->count; i++)
{ {
g_writeln(" Parameter %02d %s", g_writeln(" Parameter %02d %s",
i, (char *)list_get_item(config->rdp_params, i)); i, (char *)list_get_item(config->rdp_params, i));
} }
/* SessionVariables */ /* SessionVariables */
@ -567,7 +567,7 @@ config_dump(struct config_sesman *config)
{ {
g_writeln(" Parameter %02d %s=%s", g_writeln(" Parameter %02d %s=%s",
i, (char *) list_get_item(config->env_names, i), i, (char *) list_get_item(config->env_names, i),
(char *) list_get_item(config->env_values, i)); (char *) list_get_item(config->env_values, i));
} }
} }