Merge branch 'master' of github.com:FreeRDP/xrdp

ulab-next
Laxmikant Rashinkar 12 years ago
commit 0d3a2c7207

@ -168,7 +168,7 @@ xrdp_ffi2stat(struct xfuse_file_info *ffi, struct stat *stbuf)
} }
else else
{ {
stbuf->st_mode = S_IFREG | 0444; stbuf->st_mode = S_IFREG | 0664;
stbuf->st_nlink = 1; stbuf->st_nlink = 1;
stbuf->st_size = ffi->size; stbuf->st_size = ffi->size;
stbuf->st_uid = g_uid; stbuf->st_uid = g_uid;
@ -187,7 +187,7 @@ xrdp_ll_lookup(fuse_req_t req, fuse_ino_t parent, const char *name)
struct xfuse_file_info *ffi; struct xfuse_file_info *ffi;
struct fuse_entry_param e; struct fuse_entry_param e;
LLOGLN(0, ("xrdp_ll_lookup: name %s", name)); LLOGLN(10, ("xrdp_ll_lookup: name %s", name));
if (parent != 1) if (parent != 1)
{ {
fuse_reply_err(req, ENOENT); fuse_reply_err(req, ENOENT);
@ -197,7 +197,7 @@ xrdp_ll_lookup(fuse_req_t req, fuse_ino_t parent, const char *name)
ffi = fuse_find_file_info_by_name(g_fuse_files, name); ffi = fuse_find_file_info_by_name(g_fuse_files, name);
if (ffi != 0) if (ffi != 0)
{ {
LLOGLN(0, ("xrdp_ll_lookup: name %s ino %d", name, ffi->ino)); LLOGLN(10, ("xrdp_ll_lookup: name %s ino %d", name, ffi->ino));
g_memset(&e, 0, sizeof(e)); g_memset(&e, 0, sizeof(e));
e.ino = ffi->ino; e.ino = ffi->ino;
e.attr_timeout = 1.0; e.attr_timeout = 1.0;
@ -217,7 +217,7 @@ xrdp_ll_getattr(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
struct stat stbuf; struct stat stbuf;
struct xfuse_file_info *ffi; struct xfuse_file_info *ffi;
LLOGLN(0, ("xrdp_ll_getattr: ino %d", ino)); LLOGLN(10, ("xrdp_ll_getattr: ino %d", ino));
g_memset(&stbuf, 0, sizeof(stbuf)); g_memset(&stbuf, 0, sizeof(stbuf));
if (ino == 1) if (ino == 1)
{ {
@ -300,7 +300,7 @@ xrdp_ll_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
struct xfuse_file_info *ffi; struct xfuse_file_info *ffi;
struct dirbuf b; struct dirbuf b;
LLOGLN(0, ("xrdp_ll_readdir: ino %d", ino)); LLOGLN(10, ("xrdp_ll_readdir: ino %d", ino));
if (ino != 1) if (ino != 1)
{ {
fuse_reply_err(req, ENOTDIR); fuse_reply_err(req, ENOTDIR);
@ -326,7 +326,7 @@ xrdp_ll_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
static void DEFAULT_CC static void DEFAULT_CC
xrdp_ll_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi) 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)); LLOGLN(10, ("xrdp_ll_open: ino %d", (int)ino));
if (ino == 1) if (ino == 1)
{ {
fuse_reply_err(req, EISDIR); fuse_reply_err(req, EISDIR);
@ -351,7 +351,7 @@ xrdp_ll_read(fuse_req_t req, fuse_ino_t ino, size_t size,
struct xfuse_file_info *ffi; struct xfuse_file_info *ffi;
struct req_list_item *rli; struct req_list_item *rli;
LLOGLN(0, ("xrdp_ll_read: %d %d %d", (int)ino, (int)off, (int)size)); LLOGLN(10, ("xrdp_ll_read: %d %d %d", (int)ino, (int)off, (int)size));
ffi = fuse_find_file_info_by_ino(g_fuse_files, ino); ffi = fuse_find_file_info_by_ino(g_fuse_files, ino);
if (ffi != 0) if (ffi != 0)
{ {
@ -455,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 *ffi;
struct xfuse_file_info *ffi1; struct xfuse_file_info *ffi1;
LLOGLN(0, ("fuse_add_clip_dir_item: adding %s ino %d", filename, g_ino)); LLOGLN(10, ("fuse_add_clip_dir_item: adding %s ino %d", filename, g_ino));
ffi = g_fuse_files; ffi = g_fuse_files;
if (ffi == 0) if (ffi == 0)
{ {
@ -541,12 +541,21 @@ fuse_init(void)
char *param0 = "xrdp-chansrv"; char *param0 = "xrdp-chansrv";
char *argv[4]; char *argv[4];
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) if (g_ch != 0)
{ {
return 0; return 0;
} }
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_directory_exist(g_fuse_root_path))
{
if (!g_create_dir(g_fuse_root_path))
{
LLOGLN(0, ("fuse_init: g_create_dir failed [%s]",
g_fuse_root_path));
return 1;
}
}
g_time = g_time1(); g_time = g_time1();
g_uid = g_getuid(); g_uid = g_getuid();
g_gid = g_getgid(); g_gid = g_getgid();
@ -603,7 +612,7 @@ fuse_deinit(void)
int APP_CC int APP_CC
fuse_file_contents_size(int stream_id, int file_size) fuse_file_contents_size(int stream_id, int file_size)
{ {
LLOGLN(0, ("fuse_file_contents_size: file_size %d", file_size)); LLOGLN(10, ("fuse_file_contents_size: file_size %d", file_size));
return 0; return 0;
} }
@ -613,7 +622,7 @@ fuse_file_contents_range(int stream_id, char *data, int data_bytes)
{ {
struct req_list_item *rli; struct req_list_item *rli;
LLOGLN(0, ("fuse_file_contents_range: data_bytes %d", data_bytes)); LLOGLN(10, ("fuse_file_contents_range: data_bytes %d", data_bytes));
rli = (struct req_list_item *)list_get_item(g_req_list, 0); rli = (struct req_list_item *)list_get_item(g_req_list, 0);
if (rli != 0) if (rli != 0)
{ {
@ -645,6 +654,8 @@ fuse_file_contents_range(int stream_id, char *data, int data_bytes)
#include "arch.h" #include "arch.h"
char g_fuse_root_path[256] = "";
/*****************************************************************************/ /*****************************************************************************/
int APP_CC int APP_CC
fuse_get_wait_objs(tbus *objs, int *count, int *timeout) fuse_get_wait_objs(tbus *objs, int *count, int *timeout)

@ -169,7 +169,7 @@ x-special/gnome-copied-files
#include "xcommon.h" #include "xcommon.h"
#include "chansrv_fuse.h" #include "chansrv_fuse.h"
#define LLOG_LEVEL 11 #define LLOG_LEVEL 1
#define LLOGLN(_level, _args) \ #define LLOGLN(_level, _args) \
do \ do \
{ \ { \
@ -824,7 +824,7 @@ clipboard_set_selection_owner(void)
{ {
Window owner; Window owner;
LLOGLN(0, ("clipboard_set_selection_owner:")); LLOGLN(10, ("clipboard_set_selection_owner:"));
g_selection_time = clipboard_get_server_time(); g_selection_time = clipboard_get_server_time();
XSetSelectionOwner(g_display, g_clipboard_atom, g_wnd, g_selection_time); XSetSelectionOwner(g_display, g_clipboard_atom, g_wnd, g_selection_time);
owner = XGetSelectionOwner(g_display, g_clipboard_atom); owner = XGetSelectionOwner(g_display, g_clipboard_atom);
@ -846,8 +846,8 @@ clipboard_provide_selection_c2s(XSelectionRequestEvent *req, Atom type)
XEvent xev; XEvent xev;
long val1[2]; long val1[2];
LLOGLN(0, ("clipboard_provide_selection_c2s: bytes %d", LLOGLN(10, ("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,
@ -872,8 +872,8 @@ clipboard_provide_selection_c2s(XSelectionRequestEvent *req, Atom type)
g_clip_c2s.type = type; g_clip_c2s.type = 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;
LLOGLN(0, ("clipboard_provide_selection_c2s: start INCR property %s " LLOGLN(10, ("clipboard_provide_selection_c2s: start INCR property %s "
"type %s", XGetAtomName(g_display, req->property), "type %s", XGetAtomName(g_display, req->property),
XGetAtomName(g_display, type))); XGetAtomName(g_display, type)));
val1[0] = g_clip_c2s.total_bytes; val1[0] = g_clip_c2s.total_bytes;
val1[1] = 0; val1[1] = 0;
@ -905,7 +905,7 @@ clipboard_provide_selection(XSelectionRequestEvent *req, Atom type, int format,
bytes = FORMAT_TO_BYTES(format); bytes = FORMAT_TO_BYTES(format);
bytes *= length; bytes *= length;
LLOGLN(0, ("clipboard_provide_selection: bytes %d", bytes)); LLOGLN(10, ("clipboard_provide_selection: bytes %d", bytes));
if (bytes < g_incr_max_req_size) if (bytes < g_incr_max_req_size)
{ {
XChangeProperty(g_display, req->requestor, req->property, XChangeProperty(g_display, req->requestor, req->property,
@ -990,7 +990,7 @@ clipboard_process_format_announce(struct stream *s, int clip_msg_status,
desc[15] = 0; desc[15] = 0;
clip_msg_len -= 32; clip_msg_len -= 32;
} }
LLOGLN(0, ("clipboard_process_format_announce: formatId 0x%8.8x " LLOGLN(10, ("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));
g_formatIds[g_num_formatIds] = formatId; g_formatIds[g_num_formatIds] = formatId;
@ -1067,8 +1067,8 @@ clipboard_process_data_request(struct stream *s, int clip_msg_status,
LOGM((LOG_LEVEL_DEBUG, "clipboard_process_data_request: " LOGM((LOG_LEVEL_DEBUG, "clipboard_process_data_request: "
"CLIPRDR_DATA_REQUEST")); "CLIPRDR_DATA_REQUEST"));
LLOGLN(0, ("clipboard_process_data_request:")); LLOGLN(10, ("clipboard_process_data_request:"));
LLOGLN(0, (" %d", g_clip_s2c.xrdp_clip_type)); LLOGLN(10, (" %d", g_clip_s2c.xrdp_clip_type));
in_uint32_le(s, requestedFormatId); in_uint32_le(s, requestedFormatId);
switch (requestedFormatId) switch (requestedFormatId)
{ {
@ -1188,7 +1188,7 @@ clipboard_process_data_response(struct stream *s, int clip_msg_status,
int len; int len;
int index; int index;
LLOGLN(0, ("clipboard_process_data_response:")); LLOGLN(10, ("clipboard_process_data_response:"));
lxev = &g_saved_selection_req_event; lxev = &g_saved_selection_req_event;
g_clip_c2s.converted = 1; g_clip_c2s.converted = 1;
if (g_clip_c2s.xrdp_clip_type == XRDP_CB_BITMAP) if (g_clip_c2s.xrdp_clip_type == XRDP_CB_BITMAP)
@ -1329,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 " LOG(10, ("clipboard_data_in: chan_is %d "
"chan_flags %d length %d total_length %d", "chan_flags %d length %d total_length %d",
chan_id, chan_flags, length, total_length)); chan_id, chan_flags, length, total_length));
//LLOGLN(10, ("clipboard_data_in:")); LLOGLN(10, ("clipboard_data_in:"));
if ((chan_flags & 3) == 3) if ((chan_flags & 3) == 3)
{ {
@ -1437,14 +1437,14 @@ clipboard_event_selection_owner_notify(XEvent *xevent)
XFixesSelectionNotifyEvent *lxevent; XFixesSelectionNotifyEvent *lxevent;
lxevent = (XFixesSelectionNotifyEvent *)xevent; lxevent = (XFixesSelectionNotifyEvent *)xevent;
LLOGLN(0, ("clipboard_event_selection_owner_notify: %p", lxevent->owner)); LLOGLN(10, ("clipboard_event_selection_owner_notify: %p", lxevent->owner));
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_owner_notify: " LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_owner_notify: "
"window %d subtype %d owner %d g_wnd %d", "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) if (lxevent->owner == g_wnd)
{ {
LLOGLN(0, ("clipboard_event_selection_owner_notify: matches g_wnd")); LLOGLN(10, ("clipboard_event_selection_owner_notify: matches g_wnd"));
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_owner_notify: skipping, " LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_owner_notify: skipping, "
"onwer == g_wnd")); "onwer == g_wnd"));
g_got_selection = 1; g_got_selection = 1;
@ -1474,8 +1474,8 @@ clipboard_get_window_property(Window wnd, Atom prop, Atom *type, int *fmt,
tui8 *lxdata; tui8 *lxdata;
Atom ltype; Atom ltype;
LLOGLN(0, ("clipboard_get_window_property:")); LLOGLN(10, ("clipboard_get_window_property:"));
LLOGLN(0, (" prop %d name %s", prop, XGetAtomName(g_display, prop))); LLOGLN(10, (" prop %d name %s", prop, XGetAtomName(g_display, prop)));
lxdata = 0; lxdata = 0;
ltype = 0; ltype = 0;
XGetWindowProperty(g_display, wnd, prop, 0, 0, 0, XGetWindowProperty(g_display, wnd, prop, 0, 0, 0,
@ -1614,8 +1614,9 @@ clipboard_event_selection_notify(XEvent *xevent)
if (rv == 0) if (rv == 0)
{ {
LLOGLN(0, ("clipboard_event_selection_notify: wnd %p prop %s", lxevent->requestor, LLOGLN(10, ("clipboard_event_selection_notify: wnd %p prop %s",
XGetAtomName(g_display, lxevent->property))); lxevent->requestor,
XGetAtomName(g_display, 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);
@ -1631,10 +1632,10 @@ clipboard_event_selection_notify(XEvent *xevent)
{ {
/* nothing more to do here, the data is comming in through /* nothing more to do here, the data is comming in through
PropertyNotify */ PropertyNotify */
LLOGLN(0, ("clipboard_event_selection_notify: type is INCR " LLOGLN(10, ("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,
XGetAtomName(g_display, lxevent->property), 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.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;
@ -2078,7 +2079,7 @@ clipboard_event_property_notify(XEvent *xevent)
(xevent->xproperty.atom == g_clip_c2s.property) && (xevent->xproperty.atom == g_clip_c2s.property) &&
(xevent->xproperty.state == PropertyDelete)) (xevent->xproperty.state == PropertyDelete))
{ {
LLOGLN(0, ("clipboard_event_property_notify: INCR PropertyDelete")); LLOGLN(10, ("clipboard_event_property_notify: INCR PropertyDelete"));
/* this is used for when copying a large clipboard to the other app, /* 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 */ it will delete the property so we know to send the next one */
@ -2094,13 +2095,13 @@ clipboard_event_property_notify(XEvent *xevent)
bytes = g_incr_max_req_size; bytes = g_incr_max_req_size;
} }
g_clip_c2s.incr_bytes_done += bytes; g_clip_c2s.incr_bytes_done += bytes;
LLOGLN(0, ("clipboard_event_property_notify: bytes %d", bytes)); LLOGLN(10, ("clipboard_event_property_notify: bytes %d", bytes));
XChangeProperty(xevent->xproperty.display, xevent->xproperty.window, XChangeProperty(xevent->xproperty.display, xevent->xproperty.window,
xevent->xproperty.atom, g_clip_c2s.type, 8, xevent->xproperty.atom, g_clip_c2s.type, 8,
PropModeReplace, data, bytes); PropModeReplace, data, bytes);
if (bytes < 1) if (bytes < 1)
{ {
LLOGLN(0, ("clipboard_event_property_notify: INCR done")); LLOGLN(10, ("clipboard_event_property_notify: INCR done"));
g_clip_c2s.incr_in_progress = 0; g_clip_c2s.incr_in_progress = 0;
/* we no longer need property notify */ /* we no longer need property notify */
XSelectInput(xevent->xproperty.display, xevent->xproperty.window, XSelectInput(xevent->xproperty.display, xevent->xproperty.window,
@ -2112,7 +2113,7 @@ clipboard_event_property_notify(XEvent *xevent)
(xevent->xproperty.atom == g_clip_s2c.property) && (xevent->xproperty.atom == g_clip_s2c.property) &&
(xevent->xproperty.state == PropertyNewValue)) (xevent->xproperty.state == PropertyNewValue))
{ {
LLOGLN(0, ("clipboard_event_property_notify: INCR PropertyNewValue")); LLOGLN(10, ("clipboard_event_property_notify: INCR PropertyNewValue"));
rv = XGetWindowProperty(g_display, g_wnd, g_clip_s2c.property, 0, 0, 0, rv = XGetWindowProperty(g_display, g_wnd, g_clip_s2c.property, 0, 0, 0,
AnyPropertyType, &actual_type_return, &actual_format_return, AnyPropertyType, &actual_type_return, &actual_format_return,
&nitems_returned, &bytes_left, &data); &nitems_returned, &bytes_left, &data);
@ -2238,20 +2239,20 @@ clipboard_xevent(void *xevent)
if (lxevent->type == g_xfixes_event_base + if (lxevent->type == g_xfixes_event_base +
XFixesSetSelectionOwnerNotify) XFixesSetSelectionOwnerNotify)
{ {
LLOGLN(0, ("clipboard_xevent: got XFixesSetSelectionOwnerNotify")); LLOGLN(10, ("clipboard_xevent: got XFixesSetSelectionOwnerNotify"));
clipboard_event_selection_owner_notify(lxevent); clipboard_event_selection_owner_notify(lxevent);
break; break;
} }
if (lxevent->type == g_xfixes_event_base + if (lxevent->type == g_xfixes_event_base +
XFixesSelectionWindowDestroyNotify) XFixesSelectionWindowDestroyNotify)
{ {
LLOGLN(0, ("clipboard_xevent: got XFixesSelectionWindowDestroyNotify")); LLOGLN(10, ("clipboard_xevent: got XFixesSelectionWindowDestroyNotify"));
break; break;
} }
if (lxevent->type == g_xfixes_event_base + if (lxevent->type == g_xfixes_event_base +
XFixesSelectionClientCloseNotify) XFixesSelectionClientCloseNotify)
{ {
LLOGLN(0, ("clipboard_xevent: got XFixesSelectionClientCloseNotify")); LLOGLN(10, ("clipboard_xevent: got XFixesSelectionClientCloseNotify"));
break; break;
} }

@ -28,6 +28,7 @@
#include "arch.h" #include "arch.h"
#include "parse.h" #include "parse.h"
#include "os_calls.h" #include "os_calls.h"
#include "list.h"
#include "chansrv.h" #include "chansrv.h"
#include "clipboard.h" #include "clipboard.h"
#include "clipboard_file.h" #include "clipboard_file.h"
@ -35,7 +36,7 @@
#include "xcommon.h" #include "xcommon.h"
#include "chansrv_fuse.h" #include "chansrv_fuse.h"
#define LLOG_LEVEL 11 #define LLOG_LEVEL 1
#define LLOGLN(_level, _args) \ #define LLOGLN(_level, _args) \
do \ do \
{ \ { \
@ -63,8 +64,9 @@ struct cb_file_info
tui64 time; tui64 time;
}; };
static struct cb_file_info g_files[64]; static struct list *g_files_list = 0;
static int g_num_files = 0;
/* used when server is asking for file info from the client */
static int g_file_request_sent_type = 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 */ /* number of seconds from 1 Jan. 1601 00:00 to 1 Jan 1970 00:00 UTC */
@ -115,7 +117,7 @@ clipboard_check_file(char *filename)
index++; index++;
} }
} }
LLOGLN(0, ("[%s] [%s]", filename, lfilename)); LLOGLN(10, ("[%s] [%s]", filename, lfilename));
g_strcpy(filename, lfilename); g_strcpy(filename, lfilename);
return 0; return 0;
} }
@ -130,17 +132,15 @@ clipboard_get_file(char* file, int bytes)
char full_fn[256]; /* /etc/xrdp/xrdp.ini */ char full_fn[256]; /* /etc/xrdp/xrdp.ini */
char filename[256]; /* xrdp.ini */ char filename[256]; /* xrdp.ini */
char pathname[256]; /* /etc/xrdp */ char pathname[256]; /* /etc/xrdp */
struct cb_file_info *cfi;
/* x-special/gnome-copied-files */ /* x-special/gnome-copied-files */
if ((g_strncmp(file, "copy", 4) == 0) && (bytes == 4)) if ((g_strncmp(file, "copy", 4) == 0) && (bytes == 4))
{ {
g_writeln("jay");
return 0; return 0;
} }
if ((g_strncmp(file, "cut", 3) == 0) && (bytes == 3)) if ((g_strncmp(file, "cut", 3) == 0) && (bytes == 3))
{ {
g_writeln("jay");
return 0; return 0;
} }
sindex = 0; sindex = 0;
@ -186,16 +186,15 @@ clipboard_get_file(char* file, int bytes)
} }
else else
{ {
g_strcpy(g_files[g_num_files].filename, filename); cfi = (struct cb_file_info*)g_malloc(sizeof(struct cb_file_info), 1);
g_strcpy(g_files[g_num_files].pathname, pathname); list_add_item(g_files_list, (tintptr)cfi);
g_files[g_num_files].size = g_file_get_size(full_fn); g_strcpy(cfi->filename, filename);
g_files[g_num_files].flags = flags; g_strcpy(cfi->pathname, pathname);
g_files[g_num_files].time = (g_time1() + CB_EPOCH_DIFF) * 10000000LL; cfi->size = g_file_get_size(full_fn);
g_writeln("ok filename [%s] pathname [%s] size [%d]", cfi->flags = flags;
g_files[g_num_files].filename, cfi->time = (g_time1() + CB_EPOCH_DIFF) * 10000000LL;
g_files[g_num_files].pathname, LLOGLN(10, ("ok filename [%s] pathname [%s] size [%d]",
g_files[g_num_files].size); cfi->filename, cfi->pathname, cfi->size));
g_num_files++;
} }
return 0; return 0;
} }
@ -208,7 +207,6 @@ clipboard_get_files(char *files, int bytes)
int file_index; int file_index;
char file[512]; char file[512];
g_num_files = 0;
file_index = 0; file_index = 0;
for (index = 0; index < bytes; index++) for (index = 0; index < bytes; index++)
{ {
@ -227,10 +225,6 @@ clipboard_get_files(char *files, int bytes)
file[file_index] = files[index]; file[file_index] = files[index];
file_index++; file_index++;
} }
if (g_num_files > 60)
{
break;
}
} }
if (file_index > 0) if (file_index > 0)
{ {
@ -238,7 +232,7 @@ clipboard_get_files(char *files, int bytes)
{ {
} }
} }
if (g_num_files < 1) if (g_files_list->count < 1)
{ {
return 1; return 1;
} }
@ -260,12 +254,19 @@ clipboard_send_data_response_for_file(char *data, int data_size)
int index; int index;
tui32 ui32; tui32 ui32;
char fn[256]; char fn[256];
struct cb_file_info *cfi;
LLOGLN(10, ("clipboard_send_data_response_for_file: data_size %d", LLOGLN(10, ("clipboard_send_data_response_for_file: data_size %d",
data_size)); data_size));
//g_hexdump(data, data_size); //g_hexdump(data, data_size);
if (g_files_list == 0)
{
g_files_list = list_create();
g_files_list->auto_free = 1;
}
list_clear(g_files_list);
clipboard_get_files(data, data_size); clipboard_get_files(data, data_size);
cItems = g_num_files; cItems = g_files_list->count;
bytes_after_header = cItems * 592 + 4; bytes_after_header = cItems * 592 + 4;
make_stream(s); make_stream(s);
init_stream(s, 64 + bytes_after_header); init_stream(s, 64 + bytes_after_header);
@ -275,32 +276,31 @@ clipboard_send_data_response_for_file(char *data, int data_size)
out_uint32_le(s, cItems); out_uint32_le(s, cItems);
for (index = 0; index < cItems; index++) for (index = 0; index < cItems; index++)
{ {
cfi = (struct cb_file_info *)list_get_item(g_files_list, index);
flags = CB_FD_ATTRIBUTES | CB_FD_FILESIZE | CB_FD_WRITESTIME | CB_FD_PROGRESSUI; flags = CB_FD_ATTRIBUTES | CB_FD_FILESIZE | CB_FD_WRITESTIME | CB_FD_PROGRESSUI;
out_uint32_le(s, flags); out_uint32_le(s, flags);
out_uint8s(s, 32); /* reserved1 */ out_uint8s(s, 32); /* reserved1 */
flags = g_files[index].flags; flags = cfi->flags;
out_uint32_le(s, flags); out_uint32_le(s, flags);
out_uint8s(s, 16); /* reserved2 */ out_uint8s(s, 16); /* reserved2 */
/* file time */ /* file time */
/* 100-nanoseconds intervals since 1 January 1601 */ /* 100-nanoseconds intervals since 1 January 1601 */
//out_uint32_le(s, 0x2c305d08); /* 25 October 2009, 21:17 */ //out_uint32_le(s, 0x2c305d08); /* 25 October 2009, 21:17 */
//out_uint32_le(s, 0x01ca55f3); //out_uint32_le(s, 0x01ca55f3);
ui32 = g_files[index].time & 0xffffffff; ui32 = cfi->time & 0xffffffff;
out_uint32_le(s, ui32); out_uint32_le(s, ui32);
ui32 = g_files[index].time >> 32; ui32 = cfi->time >> 32;
out_uint32_le(s, ui32); out_uint32_le(s, ui32);
/* file size */ /* file size */
out_uint32_le(s, 0); out_uint32_le(s, 0);
out_uint32_le(s, g_files[index].size); out_uint32_le(s, cfi->size);
//g_writeln("jay size %d", g_files[index].size); g_snprintf(fn, 255, "%s", cfi->filename);
g_snprintf(fn, 255, "%s", g_files[index].filename);
clipboard_out_unicode(s, fn, 256); clipboard_out_unicode(s, fn, 256);
out_uint8s(s, 8); /* pad */ out_uint8s(s, 8); /* pad */
} }
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);
//g_hexdump(s->data, size);
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;
@ -315,8 +315,20 @@ clipboard_send_file_size(int streamId, int lindex)
int size; int size;
int rv; int rv;
int file_size; int file_size;
struct cb_file_info *cfi;
file_size = g_files[lindex].size; if (g_files_list == 0)
{
LLOGLN(10, ("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"));
return 1;
}
file_size = cfi->size;
LLOGLN(10, ("clipboard_send_file_size: streamId %d file_size %d", LLOGLN(10, ("clipboard_send_file_size: streamId %d file_size %d",
streamId, file_size)); streamId, file_size));
make_stream(s); make_stream(s);
@ -326,7 +338,6 @@ clipboard_send_file_size(int streamId, int lindex)
out_uint32_le(s, 12); out_uint32_le(s, 12);
out_uint32_le(s, streamId); out_uint32_le(s, streamId);
out_uint32_le(s, file_size); out_uint32_le(s, file_size);
g_writeln("file_size %d", file_size);
out_uint32_le(s, 0); out_uint32_le(s, 0);
out_uint32_le(s, 0); out_uint32_le(s, 0);
s_mark_end(s); s_mark_end(s);
@ -344,9 +355,7 @@ clipboard_request_file_size(int stream_id, int lindex)
struct stream *s; struct stream *s;
int size; int size;
int rv; int rv;
int file_size;
file_size = g_files[lindex].size;
LLOGLN(10, ("clipboard_request_file_size:")); LLOGLN(10, ("clipboard_request_file_size:"));
if (g_file_request_sent_type != 0) if (g_file_request_sent_type != 0)
{ {
@ -385,12 +394,23 @@ clipboard_send_file_data(int streamId, int lindex,
int rv; int rv;
int fd; int fd;
char full_fn[256]; char full_fn[256];
struct cb_file_info *cfi;
if (g_files_list == 0)
{
LLOGLN(10, ("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"));
return 1;
}
LLOGLN(10, ("clipboard_send_file_data: streamId %d lindex %d " LLOGLN(10, ("clipboard_send_file_data: streamId %d lindex %d "
"nPositionLow %d cbRequested %d", streamId, lindex, "nPositionLow %d cbRequested %d", streamId, lindex,
nPositionLow, cbRequested)); nPositionLow, cbRequested));
g_snprintf(full_fn, 255, "%s/%s", g_files[lindex].pathname, g_snprintf(full_fn, 255, "%s/%s", cfi->pathname, cfi->filename);
g_files[lindex].filename);
fd = g_file_open_ex(full_fn, 1, 0, 0, 0); fd = g_file_open_ex(full_fn, 1, 0, 0, 0);
if (fd == -1) if (fd == -1)
{ {
@ -401,13 +421,11 @@ clipboard_send_file_data(int streamId, int lindex,
g_file_seek(fd, nPositionLow); g_file_seek(fd, nPositionLow);
make_stream(s); make_stream(s);
init_stream(s, cbRequested + 64); init_stream(s, cbRequested + 64);
//g_memset(s->data + 12, 26, cbRequested);
size = g_file_read(fd, s->data + 12, cbRequested); size = g_file_read(fd, s->data + 12, cbRequested);
//g_writeln("size %d", size);
if (size < 1) if (size < 1)
{ {
LLOGLN(10, ("clipboard_send_file_data: read error, want %d got %d", LLOGLN(0, ("clipboard_send_file_data: read error, want %d got %d",
cbRequested, size)); cbRequested, size));
free_stream(s); free_stream(s);
g_file_close(fd); g_file_close(fd);
return 1; return 1;
@ -435,9 +453,7 @@ clipboard_request_file_data(int stream_id, int lindex, int offset,
struct stream *s; struct stream *s;
int size; int size;
int rv; int rv;
int file_size;
file_size = g_files[lindex].size;
LLOGLN(10, ("clipboard_request_file_data:")); LLOGLN(10, ("clipboard_request_file_data:"));
if (g_file_request_sent_type != 0) if (g_file_request_sent_type != 0)
{ {
@ -467,6 +483,7 @@ clipboard_request_file_data(int stream_id, int lindex, int offset,
/*****************************************************************************/ /*****************************************************************************/
/* client is asking from info about a file */
int APP_CC int APP_CC
clipboard_process_file_request(struct stream *s, int clip_msg_status, clipboard_process_file_request(struct stream *s, int clip_msg_status,
int clip_msg_len) int clip_msg_len)
@ -508,15 +525,14 @@ clipboard_process_file_response(struct stream *s, int clip_msg_status,
{ {
int streamId; int streamId;
int file_size; int file_size;
char *data;
LLOGLN(0, ("clipboard_process_file_response:")); LLOGLN(10, ("clipboard_process_file_response:"));
if (g_file_request_sent_type == CB_FILECONTENTS_SIZE) if (g_file_request_sent_type == CB_FILECONTENTS_SIZE)
{ {
g_file_request_sent_type = 0; g_file_request_sent_type = 0;
in_uint32_le(s, streamId); in_uint32_le(s, streamId);
in_uint32_le(s, file_size); in_uint32_le(s, file_size);
LLOGLN(0, ("clipboard_process_file_response: streamId %d " LLOGLN(10, ("clipboard_process_file_response: streamId %d "
"file_size %d", streamId, file_size)); "file_size %d", streamId, file_size));
fuse_file_contents_size(streamId, file_size); fuse_file_contents_size(streamId, file_size);
} }
@ -579,7 +595,7 @@ clipboard_c2s_in_files(struct stream *s, char *file_list)
in_uint32_le(s, cItems); in_uint32_le(s, cItems);
fuse_clear_clip_dir(); fuse_clear_clip_dir();
LLOGLN(0, ("clipboard_c2s_in_files: cItems %d", cItems)); LLOGLN(10, ("clipboard_c2s_in_files: cItems %d", cItems));
cfd = (struct clip_file_desc *) cfd = (struct clip_file_desc *)
g_malloc(sizeof(struct clip_file_desc), 0); g_malloc(sizeof(struct clip_file_desc), 0);
ptr = file_list; ptr = file_list;
@ -587,6 +603,13 @@ clipboard_c2s_in_files(struct stream *s, char *file_list)
{ {
g_memset(cfd, 0, sizeof(struct clip_file_desc)); g_memset(cfd, 0, sizeof(struct clip_file_desc));
clipboard_c2s_in_file_info(s, cfd); clipboard_c2s_in_file_info(s, cfd);
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));
continue;
}
fuse_add_clip_dir_item(cfd->cFileName, 0, cfd->fileSizeLow, lindex); fuse_add_clip_dir_item(cfd->cFileName, 0, cfd->fileSizeLow, lindex);
g_strcpy(ptr, "file://"); g_strcpy(ptr, "file://");

Loading…
Cancel
Save