diff options
author | Jay Sorg <jay.sorg@gmail.com> | 2012-11-04 13:52:33 -0800 |
---|---|---|
committer | Jay Sorg <jay.sorg@gmail.com> | 2012-11-04 13:52:33 -0800 |
commit | e2ef19098b2ffbf52b7c03c9f015e49069553419 (patch) | |
tree | 6b6c506b0f87c8773fe1962c9a99f7c3dd62b90c /sesman/chansrv/clipboard_file.c | |
parent | 900d66dc6e3541f52a884e0755d903cde7ce90ef (diff) | |
download | xrdp-proprietary-e2ef19098b2ffbf52b7c03c9f015e49069553419.tar.gz xrdp-proprietary-e2ef19098b2ffbf52b7c03c9f015e49069553419.zip |
chansrv: work on clipboard file copy
Diffstat (limited to 'sesman/chansrv/clipboard_file.c')
-rw-r--r-- | sesman/chansrv/clipboard_file.c | 88 |
1 files changed, 82 insertions, 6 deletions
diff --git a/sesman/chansrv/clipboard_file.c b/sesman/chansrv/clipboard_file.c index e169d89f..b60a1bad 100644 --- a/sesman/chansrv/clipboard_file.c +++ b/sesman/chansrv/clipboard_file.c @@ -77,6 +77,7 @@ struct clip_file_desc /* CLIPRDR_FILEDESCRIPTOR */ static struct cb_file_info g_files[64]; static int g_num_files = 0; +static int g_file_request_sent_type = 0; /* number of seconds from 1 Jan. 1601 00:00 to 1 Jan 1970 00:00 UTC */ #define CB_EPOCH_DIFF 11644473600LL @@ -336,7 +337,7 @@ clipboard_send_file_size(int streamId, int lindex) /*****************************************************************************/ /* ask the client to send the file size */ int APP_CC -clipboard_request_file_size(int streamId, int lindex) +clipboard_request_file_size(int stream_id, int lindex) { struct stream *s; int size; @@ -345,12 +346,17 @@ clipboard_request_file_size(int streamId, int lindex) file_size = g_files[lindex].size; LLOGLN(10, ("clipboard_request_file_size:")); + if (g_file_request_sent_type != 0) + { + LLOGLN(0, ("clipboard_request_file_size: warning, still waiting " + "for CB_FILECONTENTS_RESPONSE")); + } make_stream(s); init_stream(s, 8192); out_uint16_le(s, CB_FILECONTENTS_REQUEST); /* 8 */ out_uint16_le(s, 0); out_uint32_le(s, 28); - out_uint32_le(s, streamId); + out_uint32_le(s, stream_id); out_uint32_le(s, lindex); out_uint32_le(s, CB_FILECONTENTS_SIZE); out_uint32_le(s, 0); /* nPositionLow */ @@ -362,6 +368,7 @@ clipboard_request_file_size(int streamId, int lindex) size = (int)(s->end - s->data); rv = send_channel_data(g_cliprdr_chan_id, s->data, size); free_stream(s); + g_file_request_sent_type = CB_FILECONTENTS_SIZE; return rv; } @@ -418,6 +425,46 @@ clipboard_send_file_data(int streamId, int lindex, } /*****************************************************************************/ +/* ask the client to send the file size */ +int APP_CC +clipboard_request_file_data(int stream_id, int lindex, int offset, + int request_bytes) +{ + struct stream *s; + int size; + int rv; + int file_size; + + file_size = g_files[lindex].size; + LLOGLN(10, ("clipboard_request_file_data:")); + if (g_file_request_sent_type != 0) + { + LLOGLN(0, ("clipboard_request_file_data: warning, still waiting " + "for CB_FILECONTENTS_RESPONSE")); + } + make_stream(s); + init_stream(s, 8192); + out_uint16_le(s, CB_FILECONTENTS_REQUEST); /* 8 */ + out_uint16_le(s, 0); + out_uint32_le(s, 28); + out_uint32_le(s, stream_id); + out_uint32_le(s, lindex); + out_uint32_le(s, CB_FILECONTENTS_RANGE); + out_uint32_le(s, offset); /* nPositionLow */ + out_uint32_le(s, 0); /* nPositionHigh */ + out_uint32_le(s, request_bytes); /* cbRequested */ + out_uint32_le(s, 0); /* clipDataId */ + out_uint32_le(s, 0); + s_mark_end(s); + size = (int)(s->end - s->data); + rv = send_channel_data(g_cliprdr_chan_id, s->data, size); + free_stream(s); + g_file_request_sent_type = CB_FILECONTENTS_RANGE; + return rv; +} + + +/*****************************************************************************/ int APP_CC clipboard_process_file_request(struct stream *s, int clip_msg_status, int clip_msg_len) @@ -451,6 +498,35 @@ clipboard_process_file_request(struct stream *s, int clip_msg_status, } /*****************************************************************************/ +/* server requested info about the file and this is the responce + it's either the file size or file data */ +int APP_CC +clipboard_process_file_response(struct stream *s, int clip_msg_status, + int clip_msg_len) +{ + int streamId; + int file_size; + char *data; + + LLOGLN(0, ("clipboard_process_file_response:")); + if (g_file_request_sent_type == CB_FILECONTENTS_SIZE) + { + in_uint32_le(s, streamId); + in_uint32_le(s, file_size); + LLOGLN(0, ("clipboard_process_file_response: streamId %d " + "file_size %d", streamId, file_size)); + fuse_file_contents_size(streamId, file_size); + } + else if (g_file_request_sent_type == CB_FILECONTENTS_RANGE) + { + in_uint32_le(s, streamId); + fuse_file_contents_range(streamId, s->p, clip_msg_len - 4); + } + g_file_request_sent_type = 0; + return 0; +} + +/*****************************************************************************/ /* read in CLIPRDR_FILEDESCRIPTOR */ static int APP_CC clipboard_c2s_in_file_info(struct stream *s, struct clip_file_desc *cfd) @@ -487,17 +563,17 @@ clipboard_c2s_in_file_info(struct stream *s, struct clip_file_desc *cfd) int APP_CC clipboard_c2s_in_files(struct stream *s) { - tui32 cItems; + int cItems; + int lindex; struct clip_file_desc cfd; in_uint32_le(s, cItems); fuse_clear_clip_dir(); LLOGLN(0, ("clipboard_c2s_in_files: cItems %d", cItems)); - while (cItems > 0) + for (lindex = 0; lindex < cItems; lindex++) { clipboard_c2s_in_file_info(s, &cfd); - fuse_add_clip_dir_item(cfd.cFileName, 0, cfd.fileSizeLow); - cItems--; + fuse_add_clip_dir_item(cfd.cFileName, 0, cfd.fileSizeLow, lindex); } return 0; } |