summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Sorg <jay.sorg@gmail.com>2013-08-16 10:54:06 -0700
committerJay Sorg <jay.sorg@gmail.com>2013-08-16 10:54:06 -0700
commitfa40106a697611a35b57459c9403cc440a0cc865 (patch)
tree6d606a46f9d52dd7945b88566818704e226e013a
parent9357addde5ba04fda9edea8e8ae6be7f6b7aa7b3 (diff)
parent9ee39bf8f3eead40d9b67e730f19cae1864a16ae (diff)
downloadxrdp-proprietary-fa40106a697611a35b57459c9403cc440a0cc865.tar.gz
xrdp-proprietary-fa40106a697611a35b57459c9403cc440a0cc865.zip
Merge branch 'master' of github.com:neutrinolabs/xrdp
-rw-r--r--sesman/chansrv/clipboard.c483
-rw-r--r--sesman/chansrv/clipboard_file.c142
2 files changed, 340 insertions, 285 deletions
diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c
index 3aac8dbc..c2062605 100644
--- a/sesman/chansrv/clipboard.c
+++ b/sesman/chansrv/clipboard.c
@@ -172,17 +172,45 @@ x-special/gnome-copied-files
#include "xcommon.h"
#include "chansrv_fuse.h"
-#define LLOG_LEVEL 11
-#define LLOGLN(_level, _args) \
- do \
- { \
- if (_level < LLOG_LEVEL) \
- { \
- g_write("chansrv:clip [%10.10u]: ", g_time3()); \
- g_writeln _args ; \
- } \
- } \
- while (0)
+/* module based logging */
+#define LOG_ERROR 0
+#define LOG_INFO 1
+#define LOG_DEBUG 2
+#define LOG_LEVEL LOG_ERROR
+
+#define log_error(_params...) \
+{ \
+ g_write("[%10.10u]: CLIPBOARD %s: %d : ERROR: ", \
+ g_time3(), __func__, __LINE__); \
+ g_writeln (_params); \
+}
+
+#define log_always(_params...) \
+{ \
+ g_write("[%10.10u]: CLIPBOARD %s: %d : ALWAYS: ", \
+ g_time3(), __func__, __LINE__); \
+ g_writeln (_params); \
+}
+
+#define log_info(_params...) \
+{ \
+ if (LOG_INFO <= LOG_LEVEL) \
+ { \
+ g_write("[%10.10u]: CLIPBOARD %s: %d : ", \
+ g_time3(), __func__, __LINE__); \
+ g_writeln (_params); \
+ } \
+}
+
+#define log_debug(_params...) \
+{ \
+ if (LOG_DEBUG <= LOG_LEVEL) \
+ { \
+ g_write("[%10.10u]: CLIPBOARD %s: %d : ", \
+ g_time3(), __func__, __LINE__); \
+ g_writeln (_params); \
+ } \
+}
static char g_bmp_image_header[] =
{
@@ -302,7 +330,7 @@ clipboard_init(void)
int ver_min;
Status st;
- LOGM((LOG_LEVEL_DEBUG, "xrdp-chansrv: in clipboard_init"));
+ log_debug("xrdp-chansrv: in clipboard_init");
if (g_clip_up)
{
@@ -321,7 +349,7 @@ clipboard_init(void)
if (g_clipboard_atom == None)
{
- LOGM((LOG_LEVEL_ERROR, "clipboard_init: XInternAtom failed"));
+ log_error("clipboard_init: XInternAtom failed");
rv = 3;
}
}
@@ -330,18 +358,18 @@ clipboard_init(void)
{
if (!XFixesQueryExtension(g_display, &g_xfixes_event_base, &dummy))
{
- LOGM((LOG_LEVEL_ERROR, "clipboard_init: no xfixes"));
+ log_error("clipboard_init: no xfixes");
rv = 5;
}
}
if (rv == 0)
{
- LOGM((LOG_LEVEL_DEBUG, "clipboard_init: g_xfixes_event_base %d",
- g_xfixes_event_base));
+ log_debug("clipboard_init: g_xfixes_event_base %d",
+ g_xfixes_event_base);
st = XFixesQueryVersion(g_display, &ver_maj, &ver_min);
- LOGM((LOG_LEVEL_DEBUG, "clipboard_init st %d, maj %d min %d", st,
- ver_maj, ver_min));
+ log_debug("clipboard_init st %d, maj %d min %d", st,
+ ver_maj, ver_min);
g_clip_property_atom = XInternAtom(g_display, "XRDP_CLIP_PROPERTY_ATOM",
False);
g_get_time_atom = XInternAtom(g_display, "XRDP_GET_TIME_ATOM",
@@ -360,8 +388,8 @@ clipboard_init(void)
if (g_image_bmp_atom == None)
{
- LOGM((LOG_LEVEL_ERROR, "clipboard_init: g_image_bmp_atom was "
- "not allocated"));
+ log_error("clipboard_init: g_image_bmp_atom was "
+ "not allocated");
}
g_wnd = XCreateSimpleWindow(g_display, RootWindowOfScreen(g_screen),
@@ -395,13 +423,13 @@ clipboard_init(void)
out_uint32_le(s, 0); /* extra 4 bytes ? */
s_mark_end(s);
size = (int)(s->end - s->data);
- LOGM((LOG_LEVEL_DEBUG, "clipboard_init: data out, sending "
- "CB_CLIP_CAPS (clip_msg_id = 1)"));
+ log_debug("clipboard_init: data out, sending "
+ "CB_CLIP_CAPS (clip_msg_id = 1)");
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
if (rv != 0)
{
- LOGM((LOG_LEVEL_ERROR, "clipboard_init: send_channel_data failed "
- "rv = %d", rv));
+ log_error("clipboard_init: send_channel_data failed "
+ "rv = %d", rv);
rv = 4;
}
}
@@ -416,13 +444,13 @@ clipboard_init(void)
out_uint32_le(s, 0); /* extra 4 bytes ? */
s_mark_end(s);
size = (int)(s->end - s->data);
- LOGM((LOG_LEVEL_DEBUG, "clipboard_init: data out, sending "
- "CB_MONITOR_READY (clip_msg_id = 1)"));
+ log_debug("clipboard_init: data out, sending "
+ "CB_MONITOR_READY (clip_msg_id = 1)");
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
if (rv != 0)
{
- LOGM((LOG_LEVEL_ERROR, "clipboard_init: send_channel_data failed "
- "rv = %d", rv));
+ log_error("clipboard_init: send_channel_data failed "
+ "rv = %d", rv);
rv = 4;
}
}
@@ -436,7 +464,7 @@ clipboard_init(void)
}
else
{
- LOGM((LOG_LEVEL_ERROR, "xrdp-chansrv: clipboard_init: error on exit"));
+ log_error("xrdp-chansrv: clipboard_init: error on exit");
}
return rv;
@@ -446,7 +474,7 @@ clipboard_init(void)
int APP_CC
clipboard_deinit(void)
{
- LLOGLN(10, ("clipboard_deinit:"));
+ log_debug("clipboard_deinit:");
if (g_wnd != 0)
{
XDestroyWindow(g_display, g_wnd);
@@ -474,8 +502,8 @@ clipboard_send_data_request(int format_id)
int size;
int rv;
- LOGM((LOG_LEVEL_DEBUG, "clipboard_send_data_request:"));
- LLOGLN(0, ("clipboard_send_data_request: %d", format_id));
+ log_debug("clipboard_send_data_request:");
+ log_debug("clipboard_send_data_request: %d", format_id);
g_clip_c2s.in_request = 1;
make_stream(s);
init_stream(s, 8192);
@@ -486,8 +514,8 @@ clipboard_send_data_request(int format_id)
out_uint32_le(s, 0);
s_mark_end(s);
size = (int)(s->end - s->data);
- LOGM((LOG_LEVEL_DEBUG, "clipboard_send_data_request: data out, sending "
- "CLIPRDR_DATA_REQUEST (clip_msg_id = 4)"));
+ log_debug("clipboard_send_data_request: data out, sending "
+ "CLIPRDR_DATA_REQUEST (clip_msg_id = 4)");
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
free_stream(s);
return rv;
@@ -509,8 +537,8 @@ clipboard_send_format_ack(void)
out_uint32_le(s, 0); /* extra 4 bytes */
s_mark_end(s);
size = (int)(s->end - s->data);
- LOGM((LOG_LEVEL_DEBUG, "clipboard_send_format_ack: data out, sending "
- "CLIPRDR_FORMAT_ACK (clip_msg_id = 3)"));
+ log_debug("clipboard_send_format_ack: data out, sending "
+ "CLIPRDR_FORMAT_ACK (clip_msg_id = 3)");
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
free_stream(s);
return rv;
@@ -601,7 +629,7 @@ clipboard_send_format_announce(int xrdp_clip_type)
int rv;
char *holdp;
- LLOGLN(10, ("clipboard_send_format_announce:"));
+ log_debug("clipboard_send_format_announce:");
make_stream(s);
init_stream(s, 8192);
out_uint16_le(s, CB_FORMAT_LIST); /* 2 CLIPRDR_FORMAT_ANNOUNCE */
@@ -613,7 +641,7 @@ clipboard_send_format_announce(int xrdp_clip_type)
switch (xrdp_clip_type)
{
case XRDP_CB_FILE:
- LLOGLN(10, ("clipboard_send_format_announce: XRDP_CB_FILE"));
+ log_debug("clipboard_send_format_announce: XRDP_CB_FILE");
/* canned response for "file" */
out_uint32_le(s, 0x0000c0bc);
clipboard_out_unicode(s, "FileGroupDescriptorW", 21);
@@ -623,7 +651,7 @@ clipboard_send_format_announce(int xrdp_clip_type)
clipboard_out_unicode(s, "DropEffect", 11);
break;
case XRDP_CB_BITMAP:
- LLOGLN(10, ("clipboard_send_format_announce: XRDP_CB_BITMAP"));
+ log_debug("clipboard_send_format_announce: XRDP_CB_BITMAP");
/* canned response for "bitmap" */
out_uint32_le(s, 0x0000c004);
clipboard_out_unicode(s, "Native", 7);
@@ -635,7 +663,7 @@ clipboard_send_format_announce(int xrdp_clip_type)
clipboard_out_unicode(s, "", 1);
break;
case XRDP_CB_TEXT:
- LLOGLN(10, ("clipboard_send_format_announce: XRDP_CB_TEXT"));
+ log_debug("clipboard_send_format_announce: XRDP_CB_TEXT");
/* canned response for "bitmap" */
out_uint32_le(s, 0x0000000d);
clipboard_out_unicode(s, "", 1);
@@ -647,8 +675,8 @@ clipboard_send_format_announce(int xrdp_clip_type)
clipboard_out_unicode(s, "", 1);
break;
default:
- LLOGLN(10, ("clipboard_send_format_announce: unknown "
- "xrdp_clip_type %d", xrdp_clip_type));
+ log_debug("clipboard_send_format_announce: unknown "
+ "xrdp_clip_type %d", xrdp_clip_type);
break;
}
}
@@ -657,7 +685,7 @@ clipboard_send_format_announce(int xrdp_clip_type)
switch (xrdp_clip_type)
{
case XRDP_CB_FILE:
- LLOGLN(10, ("clipboard_send_format_announce: XRDP_CB_FILE"));
+ log_debug("clipboard_send_format_announce: XRDP_CB_FILE");
/* canned response for "file" */
out_uint32_le(s, 0x0000c0bc);
out_uint8p(s, windows_native_format, sizeof(windows_native_format));
@@ -667,7 +695,7 @@ clipboard_send_format_announce(int xrdp_clip_type)
out_uint8p(s, windows_native_format, sizeof(windows_native_format));
break;
case XRDP_CB_BITMAP:
- LLOGLN(10, ("clipboard_send_format_announce: XRDP_CB_BITMAP"));
+ log_debug("clipboard_send_format_announce: XRDP_CB_BITMAP");
/* canned response for "bitmap" */
out_uint32_le(s, 0x0000c004);
out_uint8p(s, windows_native_format, sizeof(windows_native_format));
@@ -679,7 +707,7 @@ clipboard_send_format_announce(int xrdp_clip_type)
out_uint8p(s, windows_native_format, sizeof(windows_native_format));
break;
case XRDP_CB_TEXT:
- LLOGLN(10, ("clipboard_send_format_announce: XRDP_CB_TEXT"));
+ log_debug("clipboard_send_format_announce: XRDP_CB_TEXT");
/* canned response for "bitmap" */
out_uint32_le(s, 0x0000000d);
out_uint8p(s, windows_native_format, sizeof(windows_native_format));
@@ -691,8 +719,8 @@ clipboard_send_format_announce(int xrdp_clip_type)
out_uint8p(s, windows_native_format, sizeof(windows_native_format));
break;
default:
- LLOGLN(10, ("clipboard_send_format_announce: unknown "
- "xrdp_clip_type %d", xrdp_clip_type));
+ log_debug("clipboard_send_format_announce: unknown "
+ "xrdp_clip_type %d", xrdp_clip_type);
break;
}
}
@@ -706,8 +734,8 @@ clipboard_send_format_announce(int xrdp_clip_type)
s_mark_end(s);
size = (int)(s->end - s->data);
//g_hexdump(s->data, size);
- LOGM((LOG_LEVEL_DEBUG, "clipboard_send_format_announce: data out, sending "
- "CLIPRDR_FORMAT_ANNOUNCE (clip_msg_id = 2)"));
+ log_debug("clipboard_send_format_announce: data out, sending "
+ "CLIPRDR_FORMAT_ANNOUNCE (clip_msg_id = 2)");
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
free_stream(s);
return rv;
@@ -721,8 +749,8 @@ clipboard_send_data_response_for_image(char* data, int data_size)
int size;
int rv;
- LLOGLN(10, ("clipboard_send_data_response_for_image: data_size %d",
- data_size));
+ log_debug("clipboard_send_data_response_for_image: data_size %d",
+ data_size);
make_stream(s);
init_stream(s, 64 + data_size);
out_uint16_le(s, CB_FORMAT_DATA_RESPONSE); /* 5 CLIPRDR_DATA_RESPONSE */
@@ -746,18 +774,18 @@ clipboard_send_data_response_for_text(char* data, int data_size)
int rv;
int num_chars;
- LLOGLN(10, ("clipboard_send_data_response_for_text: data_size %d",
- data_size));
+ log_debug("clipboard_send_data_response_for_text: data_size %d",
+ data_size);
//g_hexdump(data, data_size);
num_chars = g_mbstowcs(0, data, 0);
if (num_chars < 0)
{
- LOGM((LOG_LEVEL_ERROR, "clipboard_send_data_response_for_text: "
- "bad string"));
+ log_error("clipboard_send_data_response_for_text: "
+ "bad string");
num_chars = 0;
}
- LLOGLN(10, ("clipboard_send_data_response_for_text: data_size %d "
- "num_chars %d", data_size, num_chars));
+ log_debug("clipboard_send_data_response_for_text: data_size %d "
+ "num_chars %d", data_size, num_chars);
make_stream(s);
init_stream(s, 64 + num_chars * 2);
out_uint16_le(s, CB_FORMAT_DATA_RESPONSE); /* 5 CLIPRDR_DATA_RESPONSE */
@@ -765,16 +793,16 @@ clipboard_send_data_response_for_text(char* data, int data_size)
out_uint32_le(s, num_chars * 2 + 2); /* length */
if (clipboard_out_unicode(s, data, num_chars) != num_chars * 2)
{
- LOGM((LOG_LEVEL_ERROR, "clipboard_send_data_response_for_text: error "
- "clipboard_out_unicode didn't write right number of bytes"));
+ log_error("clipboard_send_data_response_for_text: error "
+ "clipboard_out_unicode didn't write right number of bytes");
}
out_uint16_le(s, 0); /* nil for string */
out_uint32_le(s, 0);
s_mark_end(s);
size = (int)(s->end - s->data);
- LOGM((LOG_LEVEL_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 "
- "num_chars %d", size, num_chars));
+ "num_chars %d", size, num_chars);
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
free_stream(s);
return rv;
@@ -784,7 +812,7 @@ clipboard_send_data_response_for_text(char* data, int data_size)
static int APP_CC
clipboard_send_data_response(int xrdp_clip_type, char *data, int data_size)
{
- LLOGLN(10, ("clipboard_send_data_response:"));
+ log_debug("clipboard_send_data_response:");
if (data != 0)
{
if (xrdp_clip_type == XRDP_CB_FILE)
@@ -801,13 +829,13 @@ clipboard_send_data_response(int xrdp_clip_type, char *data, int data_size)
}
else
{
- LLOGLN(0, ("clipboard_send_data_response: unknown "
- "xrdp_clip_type %d", xrdp_clip_type));
+ log_debug("clipboard_send_data_response: unknown "
+ "xrdp_clip_type %d", xrdp_clip_type);
}
}
else
{
- LLOGLN(0, ("clipboard_send_data_response: data is nil"));
+ log_error("clipboard_send_data_response: data is nil");
}
return 0;
}
@@ -818,7 +846,7 @@ clipboard_set_selection_owner(void)
{
Window owner;
- LLOGLN(10, ("clipboard_set_selection_owner:"));
+ log_debug("clipboard_set_selection_owner:");
g_selection_time = clipboard_get_server_time();
XSetSelectionOwner(g_display, g_clipboard_atom, g_wnd, g_selection_time);
owner = XGetSelectionOwner(g_display, g_clipboard_atom);
@@ -840,8 +868,8 @@ clipboard_provide_selection_c2s(XSelectionRequestEvent *req, Atom type)
XEvent xev;
long val1[2];
- LLOGLN(10, ("clipboard_provide_selection_c2s: bytes %d",
- g_clip_c2s.total_bytes));
+ log_debug("clipboard_provide_selection_c2s: bytes %d",
+ g_clip_c2s.total_bytes);
if (g_clip_c2s.total_bytes < g_incr_max_req_size)
{
XChangeProperty(g_display, req->requestor, req->property,
@@ -866,9 +894,9 @@ clipboard_provide_selection_c2s(XSelectionRequestEvent *req, Atom type)
g_clip_c2s.type = type;
g_clip_c2s.property = req->property;
g_clip_c2s.window = req->requestor;
- LLOGLN(10, ("clipboard_provide_selection_c2s: start INCR property %s "
+ log_debug("clipboard_provide_selection_c2s: start INCR property %s "
"type %s", XGetAtomName(g_display, req->property),
- XGetAtomName(g_display, type)));
+ XGetAtomName(g_display, type));
val1[0] = g_clip_c2s.total_bytes;
val1[1] = 0;
XChangeProperty(g_display, req->requestor, req->property,
@@ -899,7 +927,7 @@ clipboard_provide_selection(XSelectionRequestEvent *req, Atom type, int format,
bytes = FORMAT_TO_BYTES(format);
bytes *= length;
- LLOGLN(10, ("clipboard_provide_selection: bytes %d", bytes));
+ log_debug("clipboard_provide_selection: bytes %d", bytes);
if (bytes < g_incr_max_req_size)
{
XChangeProperty(g_display, req->requestor, req->property,
@@ -952,9 +980,9 @@ clipboard_process_format_announce(struct stream *s, int clip_msg_status,
char desc[256];
char *holdp;
- LOGM((LOG_LEVEL_DEBUG, "clipboard_process_format_announce: "
- "CLIPRDR_FORMAT_ANNOUNCE"));
- LLOGLN(10, ("clipboard_process_format_announce %d", clip_msg_len));
+ log_debug("clipboard_process_format_announce: "
+ "CLIPRDR_FORMAT_ANNOUNCE");
+ log_debug("clipboard_process_format_announce %d", clip_msg_len);
clipboard_send_format_ack();
xfuse_clear_clip_dir();
@@ -984,14 +1012,14 @@ clipboard_process_format_announce(struct stream *s, int clip_msg_status,
desc[15] = 0;
clip_msg_len -= 32;
}
- LLOGLN(10, ("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,
- clip_msg_len));
+ clip_msg_len);
g_formatIds[g_num_formatIds] = formatId;
g_num_formatIds++;
if (g_num_formatIds > 15)
{
- LLOGLN(10, ("clipboard_process_format_announce: max formats"));
+ log_debug("clipboard_process_format_announce: max formats");
}
/* format id for file copy copy seems to keep changing */
@@ -1008,8 +1036,8 @@ clipboard_process_format_announce(struct stream *s, int clip_msg_status,
{
if (clipboard_set_selection_owner() != 0)
{
- LOGM((LOG_LEVEL_ERROR, "clipboard_process_format_announce: "
- "XSetSelectionOwner failed"));
+ log_error("clipboard_process_format_announce: "
+ "XSetSelectionOwner failed");
}
}
@@ -1023,8 +1051,8 @@ static int APP_CC
clipboard_prcoess_format_ack(struct stream *s, int clip_msg_status,
int clip_msg_len)
{
- LOGM((LOG_LEVEL_DEBUG, "clipboard_prcoess_format_ack: CLIPRDR_FORMAT_ACK"));
- LLOGLN(10, ("clipboard_prcoess_format_ack:"));
+ log_debug("clipboard_prcoess_format_ack: CLIPRDR_FORMAT_ACK");
+ log_debug("clipboard_prcoess_format_ack:");
return 0;
}
@@ -1036,7 +1064,7 @@ clipboard_send_data_response_failed(void)
int size;
int rv;
- LLOGLN(10, ("clipboard_send_data_response_failed:"));
+ log_error("clipboard_send_data_response_failed:");
make_stream(s);
init_stream(s, 64);
out_uint16_le(s, CB_FORMAT_DATA_RESPONSE); /* 5 CLIPRDR_DATA_RESPONSE */
@@ -1059,24 +1087,24 @@ clipboard_process_data_request(struct stream *s, int clip_msg_status,
{
int requestedFormatId;
- LOGM((LOG_LEVEL_DEBUG, "clipboard_process_data_request: "
- "CLIPRDR_DATA_REQUEST"));
- LLOGLN(10, ("clipboard_process_data_request:"));
- LLOGLN(10, (" %d", g_clip_s2c.xrdp_clip_type));
+ log_debug("clipboard_process_data_request: "
+ "CLIPRDR_DATA_REQUEST");
+ log_debug("clipboard_process_data_request:");
+ log_debug(" %d", g_clip_s2c.xrdp_clip_type);
in_uint32_le(s, requestedFormatId);
switch (requestedFormatId)
{
case CB_FORMAT_FILE: /* 0xC0BC */
if ((g_clip_s2c.xrdp_clip_type == XRDP_CB_FILE) && g_clip_s2c.converted)
{
- LLOGLN(10, ("clipboard_process_data_request: CB_FORMAT_FILE"));
+ log_debug("clipboard_process_data_request: CB_FORMAT_FILE");
clipboard_send_data_response(XRDP_CB_FILE, g_clip_s2c.data,
g_clip_s2c.total_bytes);
}
else
{
- LLOGLN(10, ("clipboard_process_data_request: CB_FORMAT_FILE, "
- "calling XConvertSelection to g_utf8_atom"));
+ log_debug("clipboard_process_data_request: CB_FORMAT_FILE, "
+ "calling XConvertSelection to g_utf8_atom");
g_clip_s2c.xrdp_clip_type = XRDP_CB_FILE;
XConvertSelection(g_display, g_clipboard_atom, g_clip_s2c.type,
g_clip_property_atom, g_wnd, CurrentTime);
@@ -1085,14 +1113,14 @@ clipboard_process_data_request(struct stream *s, int clip_msg_status,
case CB_FORMAT_DIB: /* 0x0008 */
if ((g_clip_s2c.xrdp_clip_type == XRDP_CB_BITMAP) && g_clip_s2c.converted)
{
- LLOGLN(10, ("clipboard_process_data_request: CB_FORMAT_DIB"));
+ log_debug("clipboard_process_data_request: CB_FORMAT_DIB");
clipboard_send_data_response(XRDP_CB_BITMAP, g_clip_s2c.data,
g_clip_s2c.total_bytes);
}
else
{
- LLOGLN(10, ("clipboard_process_data_request: CB_FORMAT_DIB, "
- "calling XConvertSelection to g_image_bmp_atom"));
+ log_debug("clipboard_process_data_request: CB_FORMAT_DIB, "
+ "calling XConvertSelection to g_image_bmp_atom");
g_clip_s2c.xrdp_clip_type = XRDP_CB_BITMAP;
XConvertSelection(g_display, g_clipboard_atom, g_image_bmp_atom,
g_clip_property_atom, g_wnd, CurrentTime);
@@ -1101,22 +1129,22 @@ clipboard_process_data_request(struct stream *s, int clip_msg_status,
case CB_FORMAT_UNICODETEXT: /* 0x000D */
if ((g_clip_s2c.xrdp_clip_type == XRDP_CB_TEXT) && g_clip_s2c.converted)
{
- LLOGLN(10, ("clipboard_process_data_request: CB_FORMAT_UNICODETEXT"));
+ log_debug("clipboard_process_data_request: CB_FORMAT_UNICODETEXT");
clipboard_send_data_response(XRDP_CB_TEXT, g_clip_s2c.data,
g_clip_s2c.total_bytes);
}
else
{
- LLOGLN(10, ("clipboard_process_data_request: CB_FORMAT_UNICODETEXT, "
- "calling XConvertSelection to g_utf8_atom"));
+ log_debug("clipboard_process_data_request: CB_FORMAT_UNICODETEXT, "
+ "calling XConvertSelection to g_utf8_atom");
g_clip_s2c.xrdp_clip_type = XRDP_CB_TEXT;
XConvertSelection(g_display, g_clipboard_atom, g_utf8_atom,
g_clip_property_atom, g_wnd, CurrentTime);
}
break;
default:
- LLOGLN(10, ("clipboard_process_data_request: unknown type %d",
- requestedFormatId));
+ log_debug("clipboard_process_data_request: unknown type %d",
+ requestedFormatId);
clipboard_send_data_response_failed();
break;
}
@@ -1137,8 +1165,8 @@ clipboard_process_data_response_for_image(struct stream *s,
XSelectionRequestEvent *lxev;
int len;
- LOGM((LOG_LEVEL_DEBUG, "clipboard_process_data_response_for_image: "
- "CLIPRDR_DATA_RESPONSE_FOR_IMAGE"));
+ log_debug("clipboard_process_data_response_for_image: "
+ "CLIPRDR_DATA_RESPONSE_FOR_IMAGE");
lxev = &g_saved_selection_req_event;
len = (int)(s->end - s->p);
if (len < 1)
@@ -1160,8 +1188,8 @@ clipboard_process_data_response_for_image(struct stream *s,
g_clip_c2s.read_bytes_done = g_clip_c2s.total_bytes;
g_memcpy(g_clip_c2s.data, g_bmp_image_header, 14);
in_uint8a(s, g_clip_c2s.data + 14, len);
- LLOGLN(10, ("clipboard_process_data_response_for_image: calling "
- "clipboard_provide_selection_c2s"));
+ log_debug("clipboard_process_data_response_for_image: calling "
+ "clipboard_provide_selection_c2s");
clipboard_provide_selection_c2s(lxev, lxev->target);
return 0;
}
@@ -1183,7 +1211,7 @@ clipboard_process_data_response(struct stream *s, int clip_msg_status,
int len;
int index;
- LLOGLN(10, ("clipboard_process_data_response:"));
+ log_debug("clipboard_process_data_response:");
lxev = &g_saved_selection_req_event;
g_clip_c2s.in_request = 0;
if (g_clip_c2s.xrdp_clip_type == XRDP_CB_BITMAP)
@@ -1209,15 +1237,15 @@ clipboard_process_data_response(struct stream *s, int clip_msg_status,
}
else
{
- LLOGLN(0, ("clipboard_process_data_response: error"));
+ log_error("clipboard_process_data_response: error");
}
g_clip_c2s.total_bytes = g_strlen(g_clip_c2s.data);
g_clip_c2s.read_bytes_done = g_clip_c2s.total_bytes;
clipboard_provide_selection_c2s(lxev, lxev->target);
return 0;
}
- LOGM((LOG_LEVEL_DEBUG, "clipboard_process_data_response: "
- "CLIPRDR_DATA_RESPONSE"));
+ log_debug("clipboard_process_data_response: "
+ "CLIPRDR_DATA_RESPONSE");
len = (int)(s->end - s->p);
if (len < 1)
{
@@ -1277,7 +1305,7 @@ clipboard_process_clip_caps(struct stream *s, int clip_msg_status,
int flags;
char *holdp;
- LLOGLN(10, ("clipboard_process_clip_caps:"));
+ log_debug("clipboard_process_clip_caps:");
//g_hexdump(s->p, s->end - s->p);
in_uint16_le(s, cCapabilitiesSets);
in_uint8s(s, 2); /* pad */
@@ -1291,11 +1319,11 @@ clipboard_process_clip_caps(struct stream *s, int clip_msg_status,
case CB_CAPSTYPE_GENERAL:
in_uint32_le(s, version); /* version */
in_uint32_le(s, flags); /* generalFlags */
- LLOGLN(0, ("clipboard_process_clip_caps: "
+ log_debug("clipboard_process_clip_caps: "
"g_cliprdr_version %d version %d "
"g_cliprdr_flags 0x%x flags 0x%x",
g_cliprdr_version, version,
- g_cliprdr_flags, flags));
+ g_cliprdr_flags, flags);
if (version < g_cliprdr_version)
{
g_cliprdr_version = version;
@@ -1303,8 +1331,8 @@ clipboard_process_clip_caps(struct stream *s, int clip_msg_status,
g_cliprdr_flags &= flags;
break;
default:
- LLOGLN(0, ("clipboard_process_clip_caps: unknown "
- "capabilitySetType %d", capabilitySetType));
+ log_debug("clipboard_process_clip_caps: unknown "
+ "capabilitySetType %d", capabilitySetType);
break;
}
s->p = holdp + lengthCapability;
@@ -1319,10 +1347,10 @@ ss_part(char *data, int data_bytes)
int index;
char *text;
- LLOGLN(10, ("ss_part: data_bytes %d read_bytes_done %d "
+ log_debug("ss_part: data_bytes %d read_bytes_done %d "
"incr_bytes_done %d", data_bytes,
g_clip_c2s.read_bytes_done,
- g_clip_c2s.incr_bytes_done));
+ g_clip_c2s.incr_bytes_done);
/* copy to buffer */
if (g_clip_c2s.type == g_utf8_atom)
{
@@ -1347,12 +1375,12 @@ ss_part(char *data, int data_bytes)
}
if (g_clip_c2s.incr_in_progress)
{
- LLOGLN(10, ("ss_part: incr_in_progress set"));
+ log_debug("ss_part: incr_in_progress set");
return 0;
}
if (g_clip_c2s.read_bytes_done <= g_clip_c2s.incr_bytes_done)
{
- LLOGLN(10, ("ss_part: read_bytes_done < incr_bytes_done"));
+ log_debug("ss_part: read_bytes_done < incr_bytes_done");
return 0;
}
data = g_clip_c2s.data + g_clip_c2s.incr_bytes_done;
@@ -1376,18 +1404,18 @@ ss_end(void)
char *data;
int data_bytes;
- LLOGLN(10, ("ss_end:"));
+ log_debug("ss_end:");
g_clip_c2s.doing_response_ss = 0;
g_clip_c2s.in_request = 0;
if (g_clip_c2s.incr_in_progress)
{
- LLOGLN(10, ("ss_end: incr_in_progress set"));
+ log_debug("ss_end: incr_in_progress set");
return 0;
}
if (g_clip_c2s.read_bytes_done <= g_clip_c2s.incr_bytes_done)
{
- LLOGLN(10, ("ss_end: read_bytes_done < incr_bytes_done"));
+ log_debug("ss_end: read_bytes_done < incr_bytes_done");
return 0;
}
data = g_clip_c2s.data + g_clip_c2s.incr_bytes_done;
@@ -1413,8 +1441,8 @@ ss_start(char *data, int data_bytes, int total_bytes)
long val1[2];
int incr_bytes;
- LLOGLN(10, ("ss_start: data_bytes %d total_bytes %d",
- data_bytes, total_bytes));
+ log_debug("ss_start: data_bytes %d total_bytes %d",
+ data_bytes, total_bytes);
req = &g_saved_selection_req_event;
incr_bytes = total_bytes;
@@ -1481,24 +1509,24 @@ clipboard_data_in(struct stream *s, int chan_id, int chan_flags, int length,
if (!g_clip_up)
{
- LOG(10, ("aborting clipboard_data_in - clipboard has not "
- "been initialized"));
+ log_error("aborting clipboard_data_in - clipboard has not "
+ "been initialized");
/* we return 0 here to indicate no protocol problem occured */
return 0;
}
- LLOGLN(10, ("clipboard_data_in: chan_id %d "
+ log_debug("clipboard_data_in: chan_id %d "
"chan_flags 0x%x length %d total_length %d "
"in_request %d g_ins->size %d",
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)
{
ss_part(s->p, length);
if ((chan_flags & 3) == 2)
{
- LLOGLN(10, ("clipboard_data_in: calling ss_end"));
+ log_debug("clipboard_data_in: calling ss_end");
ss_end();
}
return 0;
@@ -1550,12 +1578,12 @@ clipboard_data_in(struct stream *s, int chan_id, int chan_flags, int length,
in_uint16_le(ls, clip_msg_status);
in_uint32_le(ls, clip_msg_len);
- LOG(10, ("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_id, clip_msg_status, clip_msg_len));
+ clip_msg_id, clip_msg_status, clip_msg_len);
rv = 0;
- LLOGLN(0, ("clipboard_data_in: %d", clip_msg_id));
+ log_debug("clipboard_data_in: %d", clip_msg_id);
switch (clip_msg_id)
{
/* sent by client or server when its local system clipboard is */
@@ -1599,9 +1627,9 @@ clipboard_data_in(struct stream *s, int chan_id, int chan_flags, int length,
clip_msg_len);
break;
default:
- LLOGLN(0, ("clipboard_data_in: unknown clip_msg_id %d", clip_msg_id));
- LOGM((LOG_LEVEL_ERROR, "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",
+ clip_msg_id);
break;
}
@@ -1631,16 +1659,16 @@ clipboard_event_selection_owner_notify(XEvent *xevent)
XFixesSelectionNotifyEvent *lxevent;
lxevent = (XFixesSelectionNotifyEvent *)xevent;
- LLOGLN(10, ("clipboard_event_selection_owner_notify: %p", lxevent->owner));
- LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_owner_notify: "
+ log_debug("clipboard_event_selection_owner_notify: %p", lxevent->owner);
+ log_debug("clipboard_event_selection_owner_notify: "
"window %d subtype %d owner %d g_wnd %d",
- lxevent->window, lxevent->subtype, lxevent->owner, g_wnd));
+ lxevent->window, lxevent->subtype, lxevent->owner, g_wnd);
if (lxevent->owner == g_wnd)
{
- LLOGLN(10, ("clipboard_event_selection_owner_notify: matches g_wnd"));
- LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_owner_notify: skipping, "
- "onwer == g_wnd"));
+ log_debug("clipboard_event_selection_owner_notify: matches g_wnd");
+ log_debug("clipboard_event_selection_owner_notify: skipping, "
+ "onwer == g_wnd");
g_got_selection = 1;
return 0;
}
@@ -1668,8 +1696,8 @@ clipboard_get_window_property(Window wnd, Atom prop, Atom *type, int *fmt,
tui8 *lxdata;
Atom ltype;
- LLOGLN(10, ("clipboard_get_window_property:"));
- LLOGLN(10, (" prop %d name %s", prop, XGetAtomName(g_display, prop)));
+ log_debug("clipboard_get_window_property:");
+ log_debug(" prop %d name %s", prop, XGetAtomName(g_display, prop));
lxdata = 0;
ltype = 0;
XGetWindowProperty(g_display, wnd, prop, 0, 0, 0,
@@ -1784,8 +1812,7 @@ clipboard_event_selection_notify(XEvent *xevent)
Atom *atoms;
Atom type;
- LLOGLN(10, ("clipboard_event_selection_notify:"));
- LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_notify:"));
+ log_debug("clipboard_event_selection_notify:");
data_size = 0;
n_items = 0;
fmt = 0;
@@ -1801,23 +1828,23 @@ clipboard_event_selection_notify(XEvent *xevent)
if (lxevent->property == None)
{
- LOGM((LOG_LEVEL_ERROR, "clipboard_event_selection_notify: clip could "
- "not be converted"));
+ log_error("clipboard_event_selection_notify: clip could "
+ "not be converted");
rv = 1;
}
if (rv == 0)
{
- LLOGLN(10, ("clipboard_event_selection_notify: wnd %p prop %s",
+ log_debug("clipboard_event_selection_notify: wnd %p prop %s",
lxevent->requestor,
- XGetAtomName(g_display, lxevent->property)));
+ XGetAtomName(g_display, lxevent->property));
rv = clipboard_get_window_property(lxevent->requestor, lxevent->property,
&type, &fmt,
&n_items, &data, &data_size);
if (rv != 0)
{
- LOGM((LOG_LEVEL_ERROR, "clipboard_event_selection_notify: "
- "clipboard_get_window_property failed error %d", rv));
+ log_error("clipboard_event_selection_notify: "
+ "clipboard_get_window_property failed error %d", rv);
return 0;
}
//g_hexdump(data, data_size);
@@ -1826,10 +1853,10 @@ clipboard_event_selection_notify(XEvent *xevent)
{
/* nothing more to do here, the data is comming in through
PropertyNotify */
- LLOGLN(10, ("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,
XGetAtomName(g_display, lxevent->property),
- XGetAtomName(g_display, lxevent->type)));
+ XGetAtomName(g_display, lxevent->type));
g_clip_s2c.incr_in_progress = 1;
g_clip_s2c.property = lxevent->property;
g_clip_s2c.type = lxevent->target;
@@ -1855,10 +1882,10 @@ clipboard_event_selection_notify(XEvent *xevent)
for (index = 0; index < n_items; index++)
{
atom = atoms[index];
- LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_notify: %d %s %d",
- atom, XGetAtomName(g_display, atom), XA_STRING));
- LLOGLN(10, ("clipboard_event_selection_notify: 0x%x %s",
- atom, XGetAtomName(g_display, atom)));
+ log_debug("clipboard_event_selection_notify: %d %s %d",
+ atom, XGetAtomName(g_display, atom), XA_STRING);
+ log_debug("clipboard_event_selection_notify: 0x%x %s",
+ atom, XGetAtomName(g_display, atom));
if (atom == g_utf8_atom)
{
got_utf8 = 1;
@@ -1873,28 +1900,28 @@ clipboard_event_selection_notify(XEvent *xevent)
}
else if ((atom == g_file_atom1) || (atom == g_file_atom2))
{
- LLOGLN(10, ("clipboard_event_selection_notify: file"));
+ log_debug("clipboard_event_selection_notify: file");
got_file_atom = atom;
}
else
{
- LLOGLN(10, ("clipboard_event_selection_notify: unknown atom 0x%x", atom));
+ log_error("clipboard_event_selection_notify: unknown atom 0x%x", atom);
}
}
}
else
{
- LOGM((LOG_LEVEL_ERROR, "clipboard_event_selection_notify: error, "
+ log_error("clipboard_event_selection_notify: error, "
"target is 'TARGETS' and type[%d] or fmt[%d] not right, "
- "should be type[%d], fmt[%d]", type, fmt, XA_ATOM, 32));
+ "should be type[%d], fmt[%d]", type, fmt, XA_ATOM, 32);
}
}
else if (lxevent->target == g_utf8_atom)
{
- LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_notify: UTF8_STRING "
- "data_size %d", data_size));
- LLOGLN(10, ("clipboard_event_selection_notify: UTF8_STRING "
- "data_size %d", data_size));
+ log_debug("clipboard_event_selection_notify: UTF8_STRING "
+ "data_size %d", data_size);
+ log_debug("clipboard_event_selection_notify: UTF8_STRING "
+ "data_size %d", data_size);
if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 0))
{
g_free(g_clip_s2c.data);
@@ -1916,10 +1943,10 @@ clipboard_event_selection_notify(XEvent *xevent)
}
else if (lxevent->target == XA_STRING)
{
- LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_notify: XA_STRING "
- "data_size %d", data_size));
- LLOGLN(10, ("clipboard_event_selection_notify: XA_STRING "
- "data_size %d", data_size));
+ log_debug("clipboard_event_selection_notify: XA_STRING "
+ "data_size %d", data_size);
+ log_debug("clipboard_event_selection_notify: XA_STRING "
+ "data_size %d", data_size);
if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 0))
{
g_free(g_clip_s2c.data);
@@ -1933,10 +1960,10 @@ clipboard_event_selection_notify(XEvent *xevent)
}
else if (lxevent->target == g_image_bmp_atom)
{
- LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_notify: image/bmp "
- "data_size %d", data_size));
- LLOGLN(10, ("clipboard_event_selection_notify: image/bmp "
- "data_size %d", data_size));
+ log_debug("clipboard_event_selection_notify: image/bmp "
+ "data_size %d", data_size);
+ log_debug("clipboard_event_selection_notify: image/bmp "
+ "data_size %d", data_size);
if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 14))
{
g_free(g_clip_s2c.data);
@@ -1949,10 +1976,10 @@ clipboard_event_selection_notify(XEvent *xevent)
}
else if (lxevent->target == g_file_atom1)
{
- LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_notify: text/uri-list "
- "data_size %d", data_size));
- LLOGLN(10, ("clipboard_event_selection_notify: text/uri-list "
- "data_size %d", data_size));
+ log_debug("clipboard_event_selection_notify: text/uri-list "
+ "data_size %d", data_size);
+ log_debug("clipboard_event_selection_notify: text/uri-list "
+ "data_size %d", data_size);
if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 0))
{
g_free(g_clip_s2c.data);
@@ -1966,10 +1993,10 @@ clipboard_event_selection_notify(XEvent *xevent)
}
else if (lxevent->target == g_file_atom2)
{
- LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_notify: text/uri-list "
- "data_size %d", data_size));
- LLOGLN(10, ("clipboard_event_selection_notify: text/uri-list "
- "data_size %d", data_size));
+ log_debug("clipboard_event_selection_notify: text/uri-list "
+ "data_size %d", data_size);
+ log_debug("clipboard_event_selection_notify: text/uri-list "
+ "data_size %d", data_size);
if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 0))
{
g_free(g_clip_s2c.data);
@@ -1983,14 +2010,14 @@ clipboard_event_selection_notify(XEvent *xevent)
}
else
{
- LOGM((LOG_LEVEL_ERROR, "clipboard_event_selection_notify: "
- "unknown target"));
+ log_error("clipboard_event_selection_notify: "
+ "unknown target");
}
}
else
{
- LOGM((LOG_LEVEL_ERROR, "clipboard_event_selection_notify: "
- "unknown selection"));
+ log_error("clipboard_event_selection_notify: "
+ "unknown selection");
}
}
@@ -2074,26 +2101,26 @@ clipboard_event_selection_request(XEvent *xevent)
char *xdata;
lxev = (XSelectionRequestEvent *)xevent;
- LLOGLN(10, ("clipboard_event_selection_request: %p", lxev->property));
- LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_request: g_wnd %d, "
+ log_debug("clipboard_event_selection_request: %p", lxev->property);
+ log_debug("clipboard_event_selection_request: g_wnd %d, "
".requestor %d .owner %d .selection %d '%s' .target %d .property %d",
g_wnd, lxev->requestor, lxev->owner, lxev->selection,
XGetAtomName(g_display, lxev->selection),
- lxev->target, lxev->property));
+ lxev->target, lxev->property);
if (lxev->property == None)
{
- LLOGLN(10, ("clipboard_event_selection_request: lxev->property "
- "is None"));
- LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_request: "
- "lxev->property is None"));
+ log_debug("clipboard_event_selection_request: lxev->property "
+ "is None");
+ log_debug("clipboard_event_selection_request: "
+ "lxev->property is None");
}
else if (lxev->target == g_targets_atom)
{
- LLOGLN(10, ("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 */
- LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_request: "
- "g_targets_atom"));
+ log_debug("clipboard_event_selection_request: "
+ "g_targets_atom");
atom_buf[0] = g_targets_atom;
atom_buf[1] = g_timestamp_atom;
atom_buf[2] = g_multiple_atom;
@@ -2102,29 +2129,29 @@ clipboard_event_selection_request(XEvent *xevent)
atom_count = 5;
if (clipboard_find_format_id(CB_FORMAT_DIB) >= 0)
{
- LLOGLN(10, (" reporting image/bmp"));
+ log_debug(" reporting image/bmp");
atom_buf[atom_count] = g_image_bmp_atom;
atom_count++;
}
if (clipboard_find_format_id(g_file_format_id) >= 0)
{
- LLOGLN(10, (" reporting text/uri-list"));
+ log_debug(" reporting text/uri-list");
atom_buf[atom_count] = g_file_atom1;
atom_count++;
- LLOGLN(10, (" reporting x-special/gnome-copied-files"));
+ log_debug(" reporting x-special/gnome-copied-files");
atom_buf[atom_count] = g_file_atom2;
atom_count++;
}
atom_buf[atom_count] = 0;
- LLOGLN(10, (" reporting %d formats", atom_count));
+ log_debug(" reporting %d formats", atom_count);
return clipboard_provide_selection(lxev, XA_ATOM, 32,
(char *)atom_buf, atom_count);
}
else if (lxev->target == g_timestamp_atom)
{
/* requestor is asking the time I got the selection */
- LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_request: "
- "g_timestamp_atom"));
+ log_debug("clipboard_event_selection_request: "
+ "g_timestamp_atom");
atom_buf[0] = g_selection_time;
atom_buf[1] = 0;
return clipboard_provide_selection(lxev, XA_INTEGER, 32,
@@ -2133,8 +2160,8 @@ clipboard_event_selection_request(XEvent *xevent)
else if (lxev->target == g_multiple_atom)
{
/* target, property pairs */
- LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_request: "
- "g_multiple_atom"));
+ log_debug("clipboard_event_selection_request: "
+ "g_multiple_atom");
xdata = 0;
if (clipboard_get_window_property(xev.xselection.requestor,
@@ -2142,8 +2169,8 @@ clipboard_event_selection_request(XEvent *xevent)
&type, &fmt, &n_items, &xdata,
&xdata_size) == 0)
{
- LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_request: g_multiple_atom "
- "n_items %d", n_items));
+ log_debug("clipboard_event_selection_request: g_multiple_atom "
+ "n_items %d", n_items);
/* todo */
g_free(xdata);
}
@@ -2159,10 +2186,10 @@ clipboard_event_selection_request(XEvent *xevent)
}
else if (lxev->target == g_image_bmp_atom)
{
- LLOGLN(10, ("clipboard_event_selection_request: image/bmp"));
+ log_debug("clipboard_event_selection_request: image/bmp");
if ((g_clip_c2s.type == lxev->target) && g_clip_c2s.converted)
{
- LLOGLN(10, ("clipboard_event_selection_request: -------------------------------------------"));
+ log_debug("clipboard_event_selection_request: -------------------------------------------");
clipboard_provide_selection_c2s(lxev, lxev->target);
return 0;
}
@@ -2175,10 +2202,10 @@ clipboard_event_selection_request(XEvent *xevent)
}
else if (lxev->target == g_file_atom1)
{
- LLOGLN(10, ("clipboard_event_selection_request: g_file_atom1"));
+ log_debug("clipboard_event_selection_request: g_file_atom1");
if ((g_clip_c2s.type == lxev->target) && g_clip_c2s.converted)
{
- LLOGLN(10, ("clipboard_event_selection_request: -------------------------------------------"));
+ log_debug("clipboard_event_selection_request: -------------------------------------------");
clipboard_provide_selection_c2s(lxev, lxev->target);
return 0;
}
@@ -2191,10 +2218,10 @@ clipboard_event_selection_request(XEvent *xevent)
}
else if (lxev->target == g_file_atom2)
{
- LLOGLN(10, ("clipboard_event_selection_request: g_file_atom2"));
+ log_debug("clipboard_event_selection_request: g_file_atom2");
if ((g_clip_c2s.type == lxev->target) && g_clip_c2s.converted)
{
- LLOGLN(10, ("clipboard_event_selection_request: -------------------------------------------"));
+ log_debug("clipboard_event_selection_request: -------------------------------------------");
clipboard_provide_selection_c2s(lxev, lxev->target);
return 0;
}
@@ -2207,10 +2234,10 @@ clipboard_event_selection_request(XEvent *xevent)
}
else
{
- LLOGLN(10, ("clipboard_event_selection_request: unknown "
- "target %s", XGetAtomName(g_display, lxev->target)));
- LOGM((LOG_LEVEL_ERROR, "clipboard_event_selection_request: unknown "
- "target %s", XGetAtomName(g_display, lxev->target)));
+ log_debug("clipboard_event_selection_request: unknown "
+ "target %s", XGetAtomName(g_display, lxev->target));
+ log_error("clipboard_event_selection_request: unknown "
+ "target %s", XGetAtomName(g_display, lxev->target));
}
clipboard_refuse_selection(lxev);
@@ -2232,7 +2259,7 @@ clipboard_event_selection_request(XEvent *xevent)
static int APP_CC
clipboard_event_selection_clear(XEvent *xevent)
{
- LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_clear:"));
+ log_debug("clipboard_event_selection_clear:");
return 0;
}
@@ -2262,24 +2289,24 @@ clipboard_event_property_notify(XEvent *xevent)
int data_bytes;
char *cptr;
- LLOGLN(10, ("clipboard_event_property_notify:"));
- LLOGLN(10, ("clipboard_event_property_notify: PropertyNotify .window %d "
+ log_debug("clipboard_event_property_notify:");
+ log_debug("clipboard_event_property_notify: PropertyNotify .window %d "
".state %d .atom %d %s", xevent->xproperty.window,
xevent->xproperty.state, xevent->xproperty.atom,
- XGetAtomName(g_display, xevent->xproperty.atom)));
+ XGetAtomName(g_display, xevent->xproperty.atom));
if (g_clip_c2s.incr_in_progress &&
(xevent->xproperty.window == g_clip_c2s.window) &&
(xevent->xproperty.atom == g_clip_c2s.property) &&
(xevent->xproperty.state == PropertyDelete))
{
- LLOGLN(10, ("clipboard_event_property_notify: INCR PropertyDelete"));
+ log_debug("clipboard_event_property_notify: INCR PropertyDelete");
/* this is used for when copying a large clipboard to the other app,
it will delete the property so we know to send the next one */
if ((g_clip_c2s.data == 0) || (g_clip_c2s.total_bytes < 1))
{
- LLOGLN(0, ("clipboard_event_property_notify: INCR error"));
+ log_debug("clipboard_event_property_notify: INCR error");
return 0;
}
data = (tui8 *)(g_clip_c2s.data + g_clip_c2s.incr_bytes_done);
@@ -2295,13 +2322,13 @@ clipboard_event_property_notify(XEvent *xevent)
data_bytes = g_incr_max_req_size;
}
g_clip_c2s.incr_bytes_done += data_bytes;
- LLOGLN(10, ("clipboard_event_property_notify: data_bytes %d", data_bytes));
+ log_debug("clipboard_event_property_notify: data_bytes %d", data_bytes);
XChangeProperty(xevent->xproperty.display, xevent->xproperty.window,
xevent->xproperty.atom, g_clip_c2s.type, 8,
PropModeReplace, data, data_bytes);
if (data_bytes < 1)
{
- LLOGLN(10, ("clipboard_event_property_notify: INCR done"));
+ log_debug("clipboard_event_property_notify: INCR done");
g_clip_c2s.incr_in_progress = 0;
/* we no longer need property notify */
XSelectInput(xevent->xproperty.display, xevent->xproperty.window,
@@ -2314,7 +2341,7 @@ clipboard_event_property_notify(XEvent *xevent)
(xevent->xproperty.atom == g_clip_s2c.property) &&
(xevent->xproperty.state == PropertyNewValue))
{
- LLOGLN(10, ("clipboard_event_property_notify: INCR PropertyNewValue"));
+ log_debug("clipboard_event_property_notify: INCR PropertyNewValue");
rv = XGetWindowProperty(g_display, g_wnd, g_clip_s2c.property, 0, 0, 0,
AnyPropertyType, &actual_type_return, &actual_format_return,
&nitems_returned, &bytes_left, &data);
@@ -2327,7 +2354,7 @@ clipboard_event_property_notify(XEvent *xevent)
if (bytes_left <= 0)
{
- LOGM((LOG_LEVEL_DEBUG, "clipboard_event_property_notify: INCR done"));
+ log_debug("clipboard_event_property_notify: INCR done");
/* clipboard INCR cycle has completed */
g_clip_s2c.incr_in_progress = 0;
if (g_clip_s2c.type == g_image_bmp_atom)
@@ -2349,8 +2376,8 @@ clipboard_event_property_notify(XEvent *xevent)
}
else
{
- LLOGLN(0, ("clipboard_event_property_notify: error unknown type %d",
- g_clip_s2c.type));
+ log_error("clipboard_event_property_notify: error unknown type %d",
+ g_clip_s2c.type);
clipboard_send_data_response_failed();
}
@@ -2382,7 +2409,7 @@ clipboard_event_property_notify(XEvent *xevent)
return 0;
}
- LLOGLN(10, ("clipboard_event_property_notify: new_data_len %d", new_data_len));
+ log_debug("clipboard_event_property_notify: new_data_len %d", new_data_len);
g_clip_s2c.data = cptr;
g_memcpy(g_clip_s2c.data + g_clip_s2c.total_bytes, data, new_data_len);
g_clip_s2c.total_bytes += new_data_len;
@@ -2430,30 +2457,30 @@ clipboard_xevent(void *xevent)
clipboard_event_property_notify(lxevent);
break;
case UnmapNotify:
- LOG(0, ("chansrv::clipboard_xevent: got UnmapNotify"));
+ log_debug("chansrv::clipboard_xevent: got UnmapNotify");
break;
case ClientMessage:
- LOG(0, ("chansrv::clipboard_xevent: got ClientMessage"));
+ log_debug("chansrv::clipboard_xevent: got ClientMessage");
break;
default:
if (lxevent->type == g_xfixes_event_base +
XFixesSetSelectionOwnerNotify)
{
- LLOGLN(10, ("clipboard_xevent: got XFixesSetSelectionOwnerNotify"));
+ log_debug("clipboard_xevent: got XFixesSetSelectionOwnerNotify");
clipboard_event_selection_owner_notify(lxevent);
break;
}
if (lxevent->type == g_xfixes_event_base +
XFixesSelectionWindowDestroyNotify)
{
- LLOGLN(10, ("clipboard_xevent: got XFixesSelectionWindowDestroyNotify"));
+ log_debug("clipboard_xevent: got XFixesSelectionWindowDestroyNotify");
break;
}
if (lxevent->type == g_xfixes_event_base +
XFixesSelectionClientCloseNotify)
{
- LLOGLN(10, ("clipboard_xevent: got XFixesSelectionClientCloseNotify"));
+ log_debug("clipboard_xevent: got XFixesSelectionClientCloseNotify");
break;
}
diff --git a/sesman/chansrv/clipboard_file.c b/sesman/chansrv/clipboard_file.c
index 42b5d4a3..96f1b0e8 100644
--- a/sesman/chansrv/clipboard_file.c
+++ b/sesman/chansrv/clipboard_file.c
@@ -36,17 +36,45 @@
#include "xcommon.h"
#include "chansrv_fuse.h"
-#define LLOG_LEVEL 1
-#define LLOGLN(_level, _args) \
- do \
- { \
- if (_level < LLOG_LEVEL) \
- { \
- g_write("chansrv:clip [%10.10u]: ", g_time3()); \
- g_writeln _args ; \
- } \
- } \
- while (0)
+/* module based logging */
+#define LOG_ERROR 0
+#define LOG_INFO 1
+#define LOG_DEBUG 2
+#define LOG_LVL LOG_ERROR
+
+#define log_error(_params...) \
+{ \
+ g_write("[%10.10u]: CLIPFILE %s: %d : ERROR: ", \
+ g_time3(), __func__, __LINE__); \
+ g_writeln (_params); \
+}
+
+#define log_always(_params...) \
+{ \
+ g_write("[%10.10u]: CLIPFILE %s: %d : ALWAYS: ", \
+ g_time3(), __func__, __LINE__); \
+ g_writeln (_params); \
+}
+
+#define log_info(_params...) \
+{ \
+ if (LOG_INFO <= LOG_LVL) \
+ { \
+ g_write("[%10.10u]: CLIPFILE %s: %d : ", \
+ g_time3(), __func__, __LINE__); \
+ g_writeln (_params); \
+ } \
+}
+
+#define log_debug(_params...) \
+{ \
+ if (LOG_DEBUG <= LOG_LVL) \
+ { \
+ g_write("[%10.10u]: CLIPFILE %s: %d : ", \
+ g_time3(), __func__, __LINE__); \
+ g_writeln (_params); \
+ } \
+}
extern int g_cliprdr_chan_id; /* in chansrv.c */
@@ -117,7 +145,7 @@ clipboard_check_file(char *filename)
index++;
}
}
- LLOGLN(10, ("[%s] [%s]", filename, lfilename));
+ log_debug("[%s] [%s]", filename, lfilename);
g_strcpy(filename, lfilename);
return 0;
}
@@ -173,15 +201,15 @@ clipboard_get_file(char* file, int bytes)
g_snprintf(full_fn, 255, "%s/%s", pathname, filename);
if (g_directory_exist(full_fn))
{
- LLOGLN(0, ("clipboard_get_file: file [%s] is a directory, "
- "not supported", full_fn));
+ log_error("clipboard_get_file: file [%s] is a directory, "
+ "not supported", full_fn);
flags |= CB_FILE_ATTRIBUTE_DIRECTORY;
return 1;
}
if (!g_file_exist(full_fn))
{
- LLOGLN(0, ("clipboard_get_file: file [%s] does not exist",
- full_fn));
+ log_error("clipboard_get_file: file [%s] does not exist",
+ full_fn);
return 1;
}
else
@@ -193,8 +221,8 @@ clipboard_get_file(char* file, int bytes)
cfi->size = g_file_get_size(full_fn);
cfi->flags = flags;
cfi->time = (g_time1() + CB_EPOCH_DIFF) * 10000000LL;
- LLOGLN(10, ("ok filename [%s] pathname [%s] size [%d]",
- cfi->filename, cfi->pathname, cfi->size));
+ log_debug("ok filename [%s] pathname [%s] size [%d]",
+ cfi->filename, cfi->pathname, cfi->size);
}
return 0;
}
@@ -256,8 +284,8 @@ clipboard_send_data_response_for_file(char *data, int data_size)
char fn[256];
struct cb_file_info *cfi;
- LLOGLN(10, ("clipboard_send_data_response_for_file: data_size %d",
- data_size));
+ log_debug("clipboard_send_data_response_for_file: data_size %d",
+ data_size);
//g_hexdump(data, data_size);
if (g_files_list == 0)
{
@@ -319,18 +347,18 @@ clipboard_send_file_size(int streamId, int lindex)
if (g_files_list == 0)
{
- LLOGLN(10, ("clipboard_send_file_size: error g_files_list is nil"));
+ log_error("clipboard_send_file_size: error g_files_list is nil");
return 1;
}
cfi = (struct cb_file_info *)list_get_item(g_files_list, lindex);
if (cfi == 0)
{
- LLOGLN(10, ("clipboard_send_file_size: error cfi is nil"));
+ log_error("clipboard_send_file_size: error cfi is nil");
return 1;
}
file_size = cfi->size;
- LLOGLN(10, ("clipboard_send_file_size: streamId %d file_size %d",
- streamId, file_size));
+ log_debug("clipboard_send_file_size: streamId %d file_size %d",
+ streamId, file_size);
make_stream(s);
init_stream(s, 8192);
out_uint16_le(s, CB_FILECONTENTS_RESPONSE); /* 9 */
@@ -356,11 +384,11 @@ clipboard_request_file_size(int stream_id, int lindex)
int size;
int rv;
- LLOGLN(10, ("clipboard_request_file_size:"));
+ log_debug("clipboard_request_file_size:");
if (g_file_request_sent_type != 0)
{
- LLOGLN(0, ("clipboard_request_file_size: warning, still waiting "
- "for CB_FILECONTENTS_RESPONSE"));
+ log_error("clipboard_request_file_size: warning, still waiting "
+ "for CB_FILECONTENTS_RESPONSE");
}
make_stream(s);
init_stream(s, 8192);
@@ -398,24 +426,24 @@ clipboard_send_file_data(int streamId, int lindex,
if (g_files_list == 0)
{
- LLOGLN(10, ("clipboard_send_file_data: error g_files_list is nil"));
+ log_error("clipboard_send_file_data: error g_files_list is nil");
return 1;
}
cfi = (struct cb_file_info *)list_get_item(g_files_list, lindex);
if (cfi == 0)
{
- LLOGLN(10, ("clipboard_send_file_data: error cfi is nil"));
+ log_error("clipboard_send_file_data: error cfi is nil");
return 1;
}
- LLOGLN(10, ("clipboard_send_file_data: streamId %d lindex %d "
+ log_debug("clipboard_send_file_data: streamId %d lindex %d "
"nPositionLow %d cbRequested %d", streamId, lindex,
- nPositionLow, cbRequested));
+ nPositionLow, cbRequested);
g_snprintf(full_fn, 255, "%s/%s", cfi->pathname, cfi->filename);
fd = g_file_open_ex(full_fn, 1, 0, 0, 0);
if (fd == -1)
{
- LLOGLN(0, ("clipboard_send_file_data: file open [%s] failed",
- full_fn));
+ log_error("clipboard_send_file_data: file open [%s] failed",
+ full_fn);
return 1;
}
g_file_seek(fd, nPositionLow);
@@ -424,8 +452,8 @@ clipboard_send_file_data(int streamId, int lindex,
size = g_file_read(fd, s->data + 12, cbRequested);
if (size < 1)
{
- LLOGLN(0, ("clipboard_send_file_data: read error, want %d got %d",
- cbRequested, size));
+ log_error("clipboard_send_file_data: read error, want %d got %d",
+ cbRequested, size);
free_stream(s);
g_file_close(fd);
return 1;
@@ -454,13 +482,13 @@ clipboard_request_file_data(int stream_id, int lindex, int offset,
int size;
int rv;
- LLOGLN(10, ("clipboard_request_file_data: stream_id=%d lindex=%d off=%d request_bytes=%d",
- stream_id, lindex, offset, request_bytes));
+ log_debug("clipboard_request_file_data: stream_id=%d lindex=%d off=%d request_bytes=%d",
+ stream_id, lindex, offset, request_bytes);
if (g_file_request_sent_type != 0)
{
- LLOGLN(0, ("clipboard_request_file_data: warning, still waiting "
- "for CB_FILECONTENTS_RESPONSE"));
+ log_error("clipboard_request_file_data: warning, still waiting "
+ "for CB_FILECONTENTS_RESPONSE");
}
make_stream(s);
init_stream(s, 8192);
@@ -498,7 +526,7 @@ clipboard_process_file_request(struct stream *s, int clip_msg_status,
int cbRequested;
//int clipDataId;
- LLOGLN(10, ("clipboard_process_file_request:"));
+ log_debug("clipboard_process_file_request:");
//g_hexdump(s->p, clip_msg_len);
in_uint32_le(s, streamId);
in_uint32_le(s, lindex);
@@ -528,14 +556,14 @@ clipboard_process_file_response(struct stream *s, int clip_msg_status,
int streamId;
int file_size;
- LLOGLN(10, ("clipboard_process_file_response:"));
+ log_debug("clipboard_process_file_response:");
if (g_file_request_sent_type == CB_FILECONTENTS_SIZE)
{
g_file_request_sent_type = 0;
in_uint32_le(s, streamId);
in_uint32_le(s, file_size);
- LLOGLN(10, ("clipboard_process_file_response: streamId %d "
- "file_size %d", streamId, file_size));
+ log_debug("clipboard_process_file_response: streamId %d "
+ "file_size %d", streamId, file_size);
xfuse_file_contents_size(streamId, file_size);
}
else if (g_file_request_sent_type == CB_FILECONTENTS_RANGE)
@@ -546,7 +574,7 @@ clipboard_process_file_response(struct stream *s, int clip_msg_status,
}
else
{
- LLOGLN(0, ("clipboard_process_file_response: error"));
+ log_error("clipboard_process_file_response: error");
g_file_request_sent_type = 0;
}
return 0;
@@ -574,14 +602,14 @@ clipboard_c2s_in_file_info(struct stream *s, struct clip_file_desc *cfd)
ex_bytes -= 2;
in_uint8s(s, ex_bytes);
in_uint8s(s, 8); /* pad */
- LLOGLN(10, ("clipboard_c2s_in_file_info:"));
- LLOGLN(10, (" flags 0x%8.8x", cfd->flags));
- LLOGLN(10, (" fileAttributes 0x%8.8x", cfd->fileAttributes));
- LLOGLN(10, (" lastWriteTime 0x%8.8x%8.8x", cfd->lastWriteTimeHigh,
- cfd->lastWriteTimeLow));
- LLOGLN(10, (" fileSize 0x%8.8x%8.8x", cfd->fileSizeHigh,
- cfd->fileSizeLow));
- LLOGLN(10, (" num_chars %d cFileName [%s]", num_chars, cfd->cFileName));
+ log_debug("clipboard_c2s_in_file_info:");
+ log_debug(" flags 0x%8.8x", cfd->flags);
+ log_debug(" fileAttributes 0x%8.8x", cfd->fileAttributes);
+ log_debug(" lastWriteTime 0x%8.8x%8.8x", cfd->lastWriteTimeHigh,
+ cfd->lastWriteTimeLow);
+ log_debug(" fileSize 0x%8.8x%8.8x", cfd->fileSizeHigh,
+ cfd->fileSizeLow);
+ log_debug(" num_chars %d cFileName [%s]", num_chars, cfd->cFileName);
return 0;
}
@@ -597,17 +625,17 @@ clipboard_c2s_in_files(struct stream *s, char *file_list)
if (!s_check_rem(s, 4))
{
- LLOGLN(0, ("clipboard_c2s_in_files: parse error"));
+ log_error("clipboard_c2s_in_files: parse error");
return 1;
}
in_uint32_le(s, cItems);
if (cItems > 64 * 1024) /* sanity check */
{
- LLOGLN(0, ("clipboard_c2s_in_files: error cItems %d too big", cItems));
+ log_error("clipboard_c2s_in_files: error cItems %d too big", cItems);
return 1;
}
xfuse_clear_clip_dir();
- LLOGLN(10, ("clipboard_c2s_in_files: cItems %d", cItems));
+ log_debug("clipboard_c2s_in_files: cItems %d", cItems);
cfd = (struct clip_file_desc *)
g_malloc(sizeof(struct clip_file_desc), 0);
ptr = file_list;
@@ -618,8 +646,8 @@ clipboard_c2s_in_files(struct stream *s, char *file_list)
if ((g_pos(cfd->cFileName, "\\") >= 0) ||
(cfd->fileAttributes & CB_FILE_ATTRIBUTE_DIRECTORY))
{
- LLOGLN(0, ("clipboard_c2s_in_files: skipping directory not "
- "supported [%s]", cfd->cFileName));
+ log_error("clipboard_c2s_in_files: skipping directory not "
+ "supported [%s]", cfd->cFileName);
continue;
}
xfuse_add_clip_dir_item(cfd->cFileName, 0, cfd->fileSizeLow, lindex);