diff options
author | Jay Sorg <jay.sorg@gmail.com> | 2012-11-05 01:04:04 -0800 |
---|---|---|
committer | Jay Sorg <jay.sorg@gmail.com> | 2012-11-05 01:04:04 -0800 |
commit | 77e74e8e680d432769112492d14d05909eb15ebc (patch) | |
tree | 9e4f041698af2896d1aa5015602598e720f36743 /sesman | |
parent | e2ef19098b2ffbf52b7c03c9f015e49069553419 (diff) | |
download | xrdp-proprietary-77e74e8e680d432769112492d14d05909eb15ebc.tar.gz xrdp-proprietary-77e74e8e680d432769112492d14d05909eb15ebc.zip |
chansrv: clipboard file copy / paste working now
Diffstat (limited to 'sesman')
-rw-r--r-- | sesman/chansrv/chansrv_fuse.c | 83 | ||||
-rw-r--r-- | sesman/chansrv/clipboard.c | 196 | ||||
-rw-r--r-- | sesman/chansrv/clipboard_common.h | 12 | ||||
-rw-r--r-- | sesman/chansrv/clipboard_file.c | 71 | ||||
-rw-r--r-- | sesman/chansrv/clipboard_file.h | 5 |
5 files changed, 301 insertions, 66 deletions
diff --git a/sesman/chansrv/chansrv_fuse.c b/sesman/chansrv/chansrv_fuse.c index 036ae6f8..269601f2 100644 --- a/sesman/chansrv/chansrv_fuse.c +++ b/sesman/chansrv/chansrv_fuse.c @@ -30,6 +30,7 @@ #include <unistd.h> #include "arch.h" #include "parse.h" +#include "list.h" #include "os_calls.h" #include "chansrv.h" #include "chansrv_fuse.h" @@ -47,6 +48,8 @@ } \ while (0) +char g_fuse_root_path[256] = ""; + static struct fuse_chan *g_ch = 0; static struct fuse_session *g_se = 0; static char *g_mountpoint = 0; @@ -58,7 +61,15 @@ static int g_uid = 0; static int g_gid = 0; /* used for file data request sent to client */ -static fuse_req_t g_req = 0; +struct req_list_item +{ + fuse_req_t req; + int stream_id; + int lindex; + int off; + int size; +}; +static struct list *g_req_list = 0; struct dirbuf { @@ -223,6 +234,7 @@ xrdp_ll_getattr(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi) ffi = fuse_find_file_info_by_ino(g_fuse_files, ino); if (ffi == 0) { + LLOGLN(0, ("xrdp_ll_getattr: fuse_find_file_info_by_ino failed ino %d", ino)); fuse_reply_err(req, ENOENT); } else if (xrdp_ffi2stat(ffi, &stbuf) == -1) @@ -315,7 +327,7 @@ static void DEFAULT_CC xrdp_ll_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi) { LLOGLN(0, ("xrdp_ll_open: ino %d", (int)ino)); - if (ino == 1 || ino == 2) + if (ino == 1) { fuse_reply_err(req, EISDIR); } @@ -326,7 +338,6 @@ xrdp_ll_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi) else { fuse_reply_open(req, fi); - clipboard_request_file_size(0, 0); } } @@ -338,20 +349,30 @@ xrdp_ll_read(fuse_req_t req, fuse_ino_t ino, size_t size, char *data; int stream_id; struct xfuse_file_info *ffi; + struct req_list_item *rli; LLOGLN(0, ("xrdp_ll_read: %d %d %d", (int)ino, (int)off, (int)size)); - ffi = fuse_find_file_info_by_ino(g_fuse_files, ino); if (ffi != 0) { - stream_id = 0; - clipboard_request_file_data(stream_id, ffi->lindex, off, size); - g_req = req; /* reply later */ + stream_id = 0; + rli = (struct req_list_item *) + g_malloc(sizeof(struct req_list_item), 1); + rli->req = req; + rli->stream_id = stream_id; + rli->lindex = ffi->lindex; + rli->off = off; + rli->size = size; + list_add_item(g_req_list, (tbus)rli); + if (g_req_list->count == 1) + { + clipboard_request_file_data(rli->stream_id, rli->lindex, + rli->off, rli->size); + } return; } - - LLOGLN(0, ("xrdp_ll_read: fuse_find_file_info_by_ino failed")); + LLOGLN(0, ("xrdp_ll_read: fuse_find_file_info_by_ino failed ino %d", (int)ino)); data = (char *)g_malloc(size, 1); fuse_reply_buf(req, data, size); g_free(data); @@ -434,7 +455,7 @@ fuse_add_clip_dir_item(char *filename, int flags, int size, int lindex) struct xfuse_file_info *ffi; struct xfuse_file_info *ffi1; - LLOGLN(0, ("fuse_add_clip_dir_item: adding %s", filename)); + LLOGLN(0, ("fuse_add_clip_dir_item: adding %s ino %d", filename, g_ino)); ffi = g_fuse_files; if (ffi == 0) { @@ -519,10 +540,9 @@ fuse_init(void) { char *param0 = "xrdp-chansrv"; char *argv[4]; - char root_path[256]; - g_snprintf(root_path, 255, "%s/xrdp_client", g_getenv("HOME")); - LLOGLN(0, ("fuse_init: using root_path [%s]", root_path)); + g_snprintf(g_fuse_root_path, 255, "%s/xrdp_client", g_getenv("HOME")); + LLOGLN(0, ("fuse_init: using root_path [%s]", g_fuse_root_path)); if (g_ch != 0) { return 0; @@ -531,7 +551,7 @@ fuse_init(void) g_uid = g_getuid(); g_gid = g_getgid(); argv[0] = param0; - argv[1] = root_path; + argv[1] = g_fuse_root_path; argv[2] = 0; g_memset(&g_xrdp_ll_oper, 0, sizeof(g_xrdp_ll_oper)); @@ -541,6 +561,9 @@ fuse_init(void) g_xrdp_ll_oper.open = xrdp_ll_open; g_xrdp_ll_oper.read = xrdp_ll_read; + g_req_list = list_create(); + g_req_list->auto_free = 1; + return fuse_init_lib(2, argv); } @@ -568,6 +591,11 @@ fuse_deinit(void) g_free(g_buffer); g_buffer = 0; } + if (g_req_list != 0) + { + list_delete(g_req_list); + g_req_list = 0; + } return 0; } @@ -583,8 +611,33 @@ fuse_file_contents_size(int stream_id, int file_size) int APP_CC fuse_file_contents_range(int stream_id, char *data, int data_bytes) { + struct req_list_item *rli; + LLOGLN(0, ("fuse_file_contents_range: data_bytes %d", data_bytes)); - fuse_reply_buf(g_req, data, data_bytes); + rli = (struct req_list_item *)list_get_item(g_req_list, 0); + if (rli != 0) + { + fuse_reply_buf(rli->req, data, data_bytes); + list_remove_item(g_req_list, 0); + if (g_req_list->count > 0) + { + /* send next request */ + rli = (struct req_list_item *)list_get_item(g_req_list, 0); + if (rli != 0) + { + clipboard_request_file_data(rli->stream_id, rli->lindex, + rli->off, rli->size); + } + else + { + LLOGLN(0, ("fuse_file_contents_range: error")); + } + } + } + else + { + LLOGLN(0, ("fuse_file_contents_range: error")); + } return 0; } diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c index e3018179..d4e8c645 100644 --- a/sesman/chansrv/clipboard.c +++ b/sesman/chansrv/clipboard.c @@ -42,7 +42,21 @@ TIMESTAMP wininfo - show window info xlsatoms - dump atoms -dolphin 1.4 KDE 4.4.5 copy one file +dolphin 1.4 KDE 4.4.5 (debian 6) copy one file +text/uri-list +text/x-moz-url +text/plain +UTF8_STRING +STRING +TEXT +COMPOUND_TEXT +application/x-qiconlist +TARGETS +MULTIPLE +TIMESTAMP +SAVE_TARGETS + +dolphin 1.6.1 KDE 4.6.5 (kubuntu 11.04) copy one file text/uri-list text/x-moz-url text/plain @@ -112,6 +126,34 @@ image/x-ico image/x-win-bitmap image/jpeg +thunar 1.2.1 copy a file +TIMESTAMP +TARGETS +MULTIPLE +x-special/gnome-copied-files +UTF8_STRING + +dolphin 1.6.1 KDE 4.6.5 (kubuntu 11.04) copy two files +text/uri-list +/home/jay/temp/jetstream1.txt +/home/jay/temp/jpeg64x64.jpg +0000 66 69 6c 65 3a 2f 2f 2f 68 6f 6d 65 2f 6a 61 79 file:///home/jay +0010 2f 74 65 6d 70 2f 6a 65 74 73 74 72 65 61 6d 31 /temp/jetstream1 +0020 2e 74 78 74 0d 0a 66 69 6c 65 3a 2f 2f 2f 68 6f .txt..file:///ho +0030 6d 65 2f 6a 61 79 2f 74 65 6d 70 2f 6a 70 65 67 me/jay/temp/jpeg +0040 36 34 78 36 34 2e 6a 70 67 64x64.jpg + +thunar 1.2.1 (kubuntu 11.04) copy two files +x-special/gnome-copied-files +/home/jay/temp/jetstream1.txt +/home/jay/temp/jpeg64x64.jpg +0000 63 6f 70 79 0a 66 69 6c 65 3a 2f 2f 2f 68 6f 6d copy.file:///hom +0010 65 2f 6a 61 79 2f 74 65 6d 70 2f 6a 65 74 73 74 e/jay/temp/jetst +0020 72 65 61 6d 31 2e 74 78 74 0d 0a 66 69 6c 65 3a ream1.txt..file: +0030 2f 2f 2f 68 6f 6d 65 2f 6a 61 79 2f 74 65 6d 70 ///home/jay/temp +0040 2f 6a 70 65 67 36 34 78 36 34 2e 6a 70 67 0d 0a /jpeg64x64.jpg.. + + */ #include <X11/Xlib.h> @@ -202,6 +244,8 @@ static int g_cliprdr_flags = CB_USE_LONG_FORMAT_NAMES | static int g_formatIds[16]; static int g_num_formatIds = 0; +static int g_file_format_id = 0; + /*****************************************************************************/ /* this is one way to get the current time from the x server */ static Time APP_CC @@ -911,8 +955,6 @@ clipboard_process_format_announce(struct stream *s, int clip_msg_status, int formatId; int count; int bytes; - int got_file; - int file_format_id; char desc[256]; char *holdp; @@ -920,10 +962,12 @@ clipboard_process_format_announce(struct stream *s, int clip_msg_status, "CLIPRDR_FORMAT_ANNOUNCE")); LLOGLN(10, ("clipboard_process_format_announce %d", clip_msg_len)); clipboard_send_format_ack(); + + fuse_clear_clip_dir(); + g_clip_c2s.converted = 0; + desc[0] = 0; g_num_formatIds = 0; - got_file = 0; - file_format_id = 0; while (clip_msg_len > 3) { in_uint32_le(s, formatId); @@ -955,25 +999,15 @@ clipboard_process_format_announce(struct stream *s, int clip_msg_status, { LLOGLN(10, ("clipboard_process_format_announce: max formats")); } - //if (formatId == 0x0000c0c8) - //if (formatId == 0x0000c0ed) + + /* format id for file copy copy seems to keep changing */ + /* seen 0x0000c0c8, 0x0000c0ed */ if (g_strcmp(desc, "FileGroupDescriptorW") == 0) { - got_file = 1; - file_format_id = formatId; + g_file_format_id = formatId; } } - if (got_file) - { - LLOGLN(0, ("clipboard_process_format_announce: sending file list request")); - g_clip_c2s.xrdp_clip_type = XRDP_CB_FILE; - //clipboard_send_data_request(0x0000c0c8); - //clipboard_send_data_request(0x0000c0ed); - clipboard_send_data_request(file_format_id); - return 0; - } - if ((g_num_formatIds > 0) && (g_clip_c2s.incr_in_progress == 0) && /* don't interrupt incr */ (g_clip_s2c.incr_in_progress == 0)) @@ -1050,7 +1084,7 @@ clipboard_process_data_request(struct stream *s, int clip_msg_status, LLOGLN(10, ("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_utf8_atom, + XConvertSelection(g_display, g_clipboard_atom, g_clip_s2c.type, g_clip_property_atom, g_wnd, CurrentTime); } break; @@ -1155,8 +1189,8 @@ clipboard_process_data_response(struct stream *s, int clip_msg_status, int index; LLOGLN(0, ("clipboard_process_data_response:")); - LLOGLN(0, (" %d", g_clip_c2s.xrdp_clip_type)); lxev = &g_saved_selection_req_event; + g_clip_c2s.converted = 1; if (g_clip_c2s.xrdp_clip_type == XRDP_CB_BITMAP) { clipboard_process_data_response_for_image(s, clip_msg_status, @@ -1165,9 +1199,25 @@ clipboard_process_data_response(struct stream *s, int clip_msg_status, } if (g_clip_c2s.xrdp_clip_type == XRDP_CB_FILE) { - LLOGLN(0, (" XRDP_CB_FILE")); - //g_hexdump(s->p, s->end - s->p); - clipboard_c2s_in_files(s); + g_free(g_clip_c2s.data); + g_clip_c2s.data = (char *)g_malloc(1024 * 1024, 1); + /* text/uri-list */ + if (g_clip_c2s.type == g_file_atom1) + { + clipboard_c2s_in_files(s, g_clip_c2s.data); + } + /* x-special/gnome-copied-files */ + else if (g_clip_c2s.type == g_file_atom2) + { + g_strcpy(g_clip_c2s.data, "copy\n"); + clipboard_c2s_in_files(s, g_clip_c2s.data + 5); + } + else + { + LLOGLN(0, ("clipboard_process_data_response: error")); + } + g_clip_c2s.total_bytes = g_strlen(g_clip_c2s.data); + clipboard_provide_selection_c2s(lxev, lxev->target); return 0; } LOGM((LOG_LEVEL_DEBUG, "clipboard_process_data_response: " @@ -1279,7 +1329,7 @@ clipboard_data_in(struct stream *s, int chan_id, int chan_flags, int length, LOG(10, ("clipboard_data_in: chan_is %d " "chan_flags %d length %d total_length %d", chan_id, chan_flags, length, total_length)); - LLOGLN(10, ("clipboard_data_in:")); + //LLOGLN(10, ("clipboard_data_in:")); if ((chan_flags & 3) == 3) { @@ -1534,8 +1584,8 @@ clipboard_event_selection_notify(XEvent *xevent) int got_string; int got_utf8; int got_bmp_image; - int got_file; int send_format_announce; + Atom got_file_atom; Atom atom; Atom *atoms; Atom type; @@ -1548,7 +1598,7 @@ clipboard_event_selection_notify(XEvent *xevent) got_string = 0; got_utf8 = 0; got_bmp_image = 0; - got_file = 0; + got_file_atom = 0; send_format_announce = 0; rv = 0; data = 0; @@ -1575,6 +1625,7 @@ clipboard_event_selection_notify(XEvent *xevent) "clipboard_get_window_property failed error %d", rv)); return 0; } + //g_hexdump(data, data_size); XDeleteProperty(g_display, lxevent->requestor, lxevent->property); if (type == g_incr_atom) { @@ -1590,7 +1641,7 @@ clipboard_event_selection_notify(XEvent *xevent) g_clip_s2c.total_bytes = 0; g_free(g_clip_s2c.data); g_clip_s2c.data = 0; - g_hexdump(data, sizeof(long)); + //g_hexdump(data, sizeof(long)); g_free(data); return 0; } @@ -1628,7 +1679,7 @@ clipboard_event_selection_notify(XEvent *xevent) else if ((atom == g_file_atom1) || (atom == g_file_atom2)) { LLOGLN(10, ("clipboard_event_selection_notify: file")); - got_file = 1; + got_file_atom = atom; } else { @@ -1701,6 +1752,40 @@ clipboard_event_selection_notify(XEvent *xevent) data_size - 14); } } + 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)); + if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 0)) + { + g_free(g_clip_s2c.data); + g_clip_s2c.total_bytes = data_size; + g_clip_s2c.data = (char *) g_malloc(g_clip_s2c.total_bytes + 1, 0); + g_memcpy(g_clip_s2c.data, data, g_clip_s2c.total_bytes); + g_clip_s2c.data[g_clip_s2c.total_bytes] = 0; + clipboard_send_data_response_for_file(g_clip_s2c.data, + g_clip_s2c.total_bytes); + } + } + 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)); + if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 0)) + { + g_free(g_clip_s2c.data); + g_clip_s2c.total_bytes = data_size; + g_clip_s2c.data = (char *) g_malloc(g_clip_s2c.total_bytes + 1, 0); + g_memcpy(g_clip_s2c.data, data, g_clip_s2c.total_bytes); + g_clip_s2c.data[g_clip_s2c.total_bytes] = 0; + clipboard_send_data_response_for_file(g_clip_s2c.data, + g_clip_s2c.total_bytes); + } + } else { LOGM((LOG_LEVEL_ERROR, "clipboard_event_selection_notify: " @@ -1714,9 +1799,10 @@ clipboard_event_selection_notify(XEvent *xevent) } } - if (got_file) + if (got_file_atom != 0) { - g_clip_s2c.type = g_utf8_atom; + /* text/uri-list or x-special/gnome-copied-files */ + g_clip_s2c.type = got_file_atom; g_clip_s2c.xrdp_clip_type = XRDP_CB_FILE; g_clip_s2c.converted = 0; g_clip_s2c.clip_time = lxevent->time; @@ -1825,6 +1911,15 @@ clipboard_event_selection_request(XEvent *xevent) 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")); + atom_buf[atom_count] = g_file_atom1; + atom_count++; + LLOGLN(10, (" 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)); return clipboard_provide_selection(lxev, XA_ATOM, 32, @@ -1869,6 +1964,13 @@ clipboard_event_selection_request(XEvent *xevent) } else if (lxev->target == g_image_bmp_atom) { + LLOGLN(10, ("clipboard_event_selection_request: image/bmp")); + if ((g_clip_c2s.type == lxev->target) && g_clip_c2s.converted) + { + LLOGLN(10, ("clipboard_event_selection_request: -------------------------------------------")); + clipboard_provide_selection_c2s(lxev, lxev->target); + return 0; + } g_memcpy(&g_saved_selection_req_event, lxev, sizeof(g_saved_selection_req_event)); g_clip_c2s.type = g_image_bmp_atom; @@ -1876,6 +1978,38 @@ clipboard_event_selection_request(XEvent *xevent) clipboard_send_data_request(CB_FORMAT_DIB); return 0; } + else if (lxev->target == g_file_atom1) + { + LLOGLN(10, ("clipboard_event_selection_request: g_file_atom1")); + if ((g_clip_c2s.type == lxev->target) && g_clip_c2s.converted) + { + LLOGLN(10, ("clipboard_event_selection_request: -------------------------------------------")); + clipboard_provide_selection_c2s(lxev, lxev->target); + return 0; + } + g_memcpy(&g_saved_selection_req_event, lxev, + sizeof(g_saved_selection_req_event)); + g_clip_c2s.type = g_file_atom1; + g_clip_c2s.xrdp_clip_type = XRDP_CB_FILE; + clipboard_send_data_request(g_file_format_id); + return 0; + } + else if (lxev->target == g_file_atom2) + { + LLOGLN(10, ("clipboard_event_selection_request: g_file_atom2")); + if ((g_clip_c2s.type == lxev->target) && g_clip_c2s.converted) + { + LLOGLN(10, ("clipboard_event_selection_request: -------------------------------------------")); + clipboard_provide_selection_c2s(lxev, lxev->target); + return 0; + } + g_memcpy(&g_saved_selection_req_event, lxev, + sizeof(g_saved_selection_req_event)); + g_clip_c2s.type = g_file_atom2; + g_clip_c2s.xrdp_clip_type = XRDP_CB_FILE; + clipboard_send_data_request(g_file_format_id); + return 0; + } else { LLOGLN(10, ("clipboard_event_selection_request: unknown " diff --git a/sesman/chansrv/clipboard_common.h b/sesman/chansrv/clipboard_common.h index 4c72a3b5..0a155394 100644 --- a/sesman/chansrv/clipboard_common.h +++ b/sesman/chansrv/clipboard_common.h @@ -109,9 +109,21 @@ struct clip_c2s /* client to server, pasting from mstsc to linux app */ Atom property; /* XRDP_CLIP_PROPERTY_ATOM, _QT_SELECTION, ... */ Window window; /* Window used in INCR transfer */ int xrdp_clip_type; /* XRDP_CB_TEXT, XRDP_CB_BITMAP, XRDP_CB_FILE, ... */ + int converted; Time clip_time; }; +struct clip_file_desc /* CLIPRDR_FILEDESCRIPTOR */ +{ + tui32 flags; + tui32 fileAttributes; + tui32 lastWriteTimeLow; + tui32 lastWriteTimeHigh; + tui32 fileSizeHigh; + tui32 fileSizeLow; + char cFileName[256]; +}; + int APP_CC clipboard_out_unicode(struct stream *s, char *text, int num_chars); int APP_CC diff --git a/sesman/chansrv/clipboard_file.c b/sesman/chansrv/clipboard_file.c index b60a1bad..3fb64b10 100644 --- a/sesman/chansrv/clipboard_file.c +++ b/sesman/chansrv/clipboard_file.c @@ -52,8 +52,7 @@ extern int g_cliprdr_chan_id; /* in chansrv.c */ extern struct clip_s2c g_clip_s2c; /* in clipboard.c */ extern struct clip_c2s g_clip_c2s; /* in clipboard.c */ -//extern struct file_item *g_file_items; /* in chansrv_fuse.c */ -//extern int g_file_items_count; /* in chansrv_fuse.c */ +extern char g_fuse_root_path[]; /* in chansrv_fuse.c */ struct cb_file_info { @@ -64,17 +63,6 @@ struct cb_file_info tui64 time; }; -struct clip_file_desc /* CLIPRDR_FILEDESCRIPTOR */ -{ - tui32 flags; - tui32 fileAttributes; - tui32 lastWriteTimeLow; - tui32 lastWriteTimeHigh; - tui32 fileSizeHigh; - tui32 fileSizeLow; - char cFileName[256]; -}; - static struct cb_file_info g_files[64]; static int g_num_files = 0; static int g_file_request_sent_type = 0; @@ -143,9 +131,23 @@ clipboard_get_file(char* file, int bytes) char filename[256]; /* xrdp.ini */ char pathname[256]; /* /etc/xrdp */ + + /* x-special/gnome-copied-files */ + if ((g_strncmp(file, "copy", 4) == 0) && (bytes == 4)) + { + g_writeln("jay"); + return 0; + } + if ((g_strncmp(file, "cut", 3) == 0) && (bytes == 3)) + { + g_writeln("jay"); + return 0; + } sindex = 0; flags = CB_FILE_ATTRIBUTE_ARCHIVE; - if (g_strncmp(file, "file:///", 8) == 0) + /* text/uri-list */ + /* x-special/gnome-copied-files */ + if (g_strncmp(file, "file://", 7) == 0) { sindex = 7; } @@ -511,6 +513,7 @@ clipboard_process_file_response(struct stream *s, int clip_msg_status, LLOGLN(0, ("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(0, ("clipboard_process_file_response: streamId %d " @@ -519,10 +522,15 @@ clipboard_process_file_response(struct stream *s, int clip_msg_status, } else if (g_file_request_sent_type == CB_FILECONTENTS_RANGE) { + g_file_request_sent_type = 0; in_uint32_le(s, streamId); fuse_file_contents_range(streamId, s->p, clip_msg_len - 4); } - g_file_request_sent_type = 0; + else + { + LLOGLN(0, ("clipboard_process_file_response: error")); + g_file_request_sent_type = 0; + } return 0; } @@ -561,19 +569,44 @@ clipboard_c2s_in_file_info(struct stream *s, struct clip_file_desc *cfd) /*****************************************************************************/ int APP_CC -clipboard_c2s_in_files(struct stream *s) +clipboard_c2s_in_files(struct stream *s, char *file_list) { int cItems; int lindex; - struct clip_file_desc cfd; + int str_len; + struct clip_file_desc *cfd; + char *ptr; in_uint32_le(s, cItems); fuse_clear_clip_dir(); LLOGLN(0, ("clipboard_c2s_in_files: cItems %d", cItems)); + cfd = (struct clip_file_desc *) + g_malloc(sizeof(struct clip_file_desc), 0); + ptr = file_list; for (lindex = 0; lindex < cItems; lindex++) { - clipboard_c2s_in_file_info(s, &cfd); - fuse_add_clip_dir_item(cfd.cFileName, 0, cfd.fileSizeLow, lindex); + g_memset(cfd, 0, sizeof(struct clip_file_desc)); + clipboard_c2s_in_file_info(s, cfd); + fuse_add_clip_dir_item(cfd->cFileName, 0, cfd->fileSizeLow, lindex); + + g_strcpy(ptr, "file://"); + ptr += 7; + + str_len = g_strlen(g_fuse_root_path); + g_strcpy(ptr, g_fuse_root_path); + ptr += str_len; + + *ptr = '/'; + ptr++; + + str_len = g_strlen(cfd->cFileName); + g_strcpy(ptr, cfd->cFileName); + ptr += str_len; + + *ptr = '\n'; + ptr++; } + *ptr = 0; + g_free(cfd); return 0; } diff --git a/sesman/chansrv/clipboard_file.h b/sesman/chansrv/clipboard_file.h index 46c41d51..61640887 100644 --- a/sesman/chansrv/clipboard_file.h +++ b/sesman/chansrv/clipboard_file.h @@ -28,7 +28,10 @@ int APP_CC clipboard_process_file_request(struct stream *s, int clip_msg_status, int clip_msg_len); int APP_CC -clipboard_c2s_in_files(struct stream *s); +clipboard_process_file_response(struct stream *s, int clip_msg_status, + int clip_msg_len); +int APP_CC +clipboard_c2s_in_files(struct stream *s, char *file_list); int APP_CC clipboard_request_file_size(int stream_id, int lindex); |