chansrv: work on clipboard
This commit is contained in:
parent
159e240845
commit
6e25a5e600
@ -32,10 +32,11 @@ xrdp_chansrv_SOURCES = \
|
||||
devredir.c \
|
||||
rail.c \
|
||||
xcommon.c \
|
||||
drdynvc.c
|
||||
drdynvc.c \
|
||||
chansrv_fuse.c
|
||||
|
||||
xrdp_chansrv_LDFLAGS = \
|
||||
$(EXTRA_FLAGS)
|
||||
$(EXTRA_FLAGS) -lfuse
|
||||
|
||||
xrdp_chansrv_LDADD = \
|
||||
-L/usr/X11R6/lib \
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "log.h"
|
||||
#include "rail.h"
|
||||
#include "xcommon.h"
|
||||
#include "chansrv_fuse.h"
|
||||
|
||||
static struct trans *g_lis_trans = 0;
|
||||
static struct trans *g_con_trans = 0;
|
||||
@ -195,10 +196,13 @@ send_channel_data(int chan_id, char *data, int size)
|
||||
{
|
||||
int index;
|
||||
|
||||
//g_writeln("send_channel_data chan_id %d size %d", chan_id, size);
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "chansrv::send_channel_data: size %d", size));
|
||||
|
||||
if (chan_id == -1)
|
||||
{
|
||||
g_writeln("send_channel_data: error, chan_id is -1");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -392,6 +396,8 @@ process_message_channel_setup(struct stream *s)
|
||||
drdynvc_init();
|
||||
}
|
||||
|
||||
fuse_init();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -582,6 +588,8 @@ my_api_trans_data_in(struct trans *trans)
|
||||
int bytes_read;
|
||||
struct xrdp_api_data *ad;
|
||||
|
||||
//g_writeln("my_api_trans_data_in:");
|
||||
|
||||
LOG(10, ("my_api_trans_data_in:"));
|
||||
|
||||
if (trans == 0)
|
||||
@ -597,7 +605,9 @@ my_api_trans_data_in(struct trans *trans)
|
||||
LOGM((LOG_LEVEL_DEBUG, "my_api_trans_data_in:"));
|
||||
|
||||
s = trans_get_in_s(trans);
|
||||
bytes_read = g_tcp_recv(trans->sck, s->data, 8192, 0);
|
||||
bytes_read = g_tcp_recv(trans->sck, s->data, 8192 * 4, 0);
|
||||
|
||||
//g_writeln("bytes_read %d", bytes_read);
|
||||
|
||||
if (bytes_read > 0)
|
||||
{
|
||||
@ -620,7 +630,7 @@ my_api_trans_data_in(struct trans *trans)
|
||||
}
|
||||
else
|
||||
{
|
||||
ad = (struct xrdp_api_data *) trans->callback_data;
|
||||
ad = (struct xrdp_api_data *) (trans->callback_data);
|
||||
if ((ad != NULL) && (ad->dvc_chan_id > 0))
|
||||
{
|
||||
/* WTSVirtualChannelClose() was invoked, or connection dropped */
|
||||
@ -686,6 +696,7 @@ my_api_trans_conn_in(struct trans *trans, struct trans *new_trans)
|
||||
int index;
|
||||
char chan_pri;
|
||||
|
||||
g_writeln("my_api_trans_conn_in:");
|
||||
if ((trans == 0) || (trans != g_api_lis_trans) || (new_trans == 0))
|
||||
{
|
||||
return 1;
|
||||
@ -805,7 +816,7 @@ setup_api_listen(void)
|
||||
char port[256];
|
||||
int error = 0;
|
||||
|
||||
g_api_lis_trans = trans_create(TRANS_MODE_UNIX, 8192, 8192);
|
||||
g_api_lis_trans = trans_create(TRANS_MODE_UNIX, 8192 * 4, 8192 * 4);
|
||||
g_snprintf(port, 255, "/tmp/.xrdp/xrdpapi_%d", g_display_num);
|
||||
g_api_lis_trans->trans_conn_in = my_api_trans_conn_in;
|
||||
error = trans_listen(g_api_lis_trans, port);
|
||||
@ -915,6 +926,7 @@ channel_thread_loop(void *in_val)
|
||||
xcommon_check_wait_objs();
|
||||
sound_check_wait_objs();
|
||||
dev_redir_check_wait_objs();
|
||||
fuse_check_wait_objs();
|
||||
timeout = -1;
|
||||
num_objs = 0;
|
||||
objs[num_objs] = g_term_event;
|
||||
@ -926,6 +938,7 @@ channel_thread_loop(void *in_val)
|
||||
xcommon_get_wait_objs(objs, &num_objs, &timeout);
|
||||
sound_get_wait_objs(objs, &num_objs, &timeout);
|
||||
dev_redir_get_wait_objs(objs, &num_objs, &timeout);
|
||||
fuse_get_wait_objs(objs, &num_objs, &timeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
441
sesman/chansrv/chansrv_fuse.c
Normal file
441
sesman/chansrv/chansrv_fuse.c
Normal file
@ -0,0 +1,441 @@
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define FUSE_USE_VERSION 26
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
#include <fuse/fuse_lowlevel.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "arch.h"
|
||||
#include "parse.h"
|
||||
#include "os_calls.h"
|
||||
#include "chansrv.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)
|
||||
|
||||
static struct fuse_chan *g_ch = 0;
|
||||
static struct fuse_session *g_se = 0;
|
||||
static char *g_mountpoint = 0;
|
||||
static tintptr g_bufsize = 0;
|
||||
static char *g_buffer = 0;
|
||||
static int g_fd = 0;
|
||||
|
||||
struct file_item *g_file_items = 0;
|
||||
int g_file_items_count = 0;
|
||||
|
||||
static time_t g_time = 0;
|
||||
static int g_uid = 0;
|
||||
static int g_gid = 0;
|
||||
|
||||
struct dirbuf
|
||||
{
|
||||
char *p;
|
||||
int size;
|
||||
int alloc_bytes;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
xrdp_stat(fuse_ino_t ino, struct stat *stbuf)
|
||||
{
|
||||
int index;
|
||||
|
||||
LLOGLN(10, ("xrdp_stat: ino %d", (int)ino));
|
||||
stbuf->st_ino = ino;
|
||||
switch (ino)
|
||||
{
|
||||
case 1: /* . */
|
||||
case 2: /* .. */
|
||||
stbuf->st_mode = S_IFDIR | 0755;
|
||||
stbuf->st_nlink = 2;
|
||||
stbuf->st_uid = g_uid;
|
||||
stbuf->st_gid = g_gid;
|
||||
stbuf->st_atime = g_time;
|
||||
stbuf->st_mtime = g_time;
|
||||
stbuf->st_ctime = g_time;
|
||||
break;
|
||||
|
||||
default:
|
||||
index = ino - 3;
|
||||
if (index < 0 || index >= g_file_items_count)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
stbuf->st_mode = S_IFREG | 0444;
|
||||
stbuf->st_nlink = 1;
|
||||
stbuf->st_size = g_file_items[index].data_bytes;
|
||||
stbuf->st_uid = g_uid;
|
||||
stbuf->st_gid = g_gid;
|
||||
stbuf->st_atime = g_time;
|
||||
stbuf->st_mtime = g_time;
|
||||
stbuf->st_ctime = g_time;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
xrdp_ll_lookup(fuse_req_t req, fuse_ino_t parent, const char *name)
|
||||
{
|
||||
struct fuse_entry_param e;
|
||||
int index;
|
||||
|
||||
LLOGLN(10, ("xrdp_ll_lookup: name %s", name));
|
||||
if (parent != 1)
|
||||
{
|
||||
fuse_reply_err(req, ENOENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (index = 0; index < g_file_items_count; index++)
|
||||
{
|
||||
if (g_strcmp(name, g_file_items[index].filename) == 0)
|
||||
{
|
||||
g_memset(&e, 0, sizeof(e));
|
||||
e.ino = g_file_items[index].ino;
|
||||
e.attr_timeout = 1.0;
|
||||
e.entry_timeout = 1.0;
|
||||
xrdp_stat(e.ino, &e.attr);
|
||||
fuse_reply_entry(req, &e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
fuse_reply_err(req, ENOENT);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
xrdp_ll_getattr(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
|
||||
{
|
||||
struct stat stbuf;
|
||||
|
||||
g_memset(&stbuf, 0, sizeof(stbuf));
|
||||
if (xrdp_stat(ino, &stbuf) == -1)
|
||||
{
|
||||
fuse_reply_err(req, ENOENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
fuse_reply_attr(req, &stbuf, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static void APP_CC
|
||||
dirbuf_add(fuse_req_t req, struct dirbuf *b, const char *name, fuse_ino_t ino)
|
||||
{
|
||||
struct stat stbuf;
|
||||
char *newp;
|
||||
int oldsize;
|
||||
|
||||
oldsize = b->size;
|
||||
b->size += fuse_add_direntry(req, 0, 0, name, 0, 0);
|
||||
LLOGLN(10, ("1 %d %d %d", b->alloc_bytes, b->size, oldsize));
|
||||
if (b->size > b->alloc_bytes)
|
||||
{
|
||||
b->alloc_bytes = (b->size + 1023) & (~1023);
|
||||
LLOGLN(10, ("2 %d %d %d", b->alloc_bytes, b->size, oldsize));
|
||||
newp = g_malloc(b->alloc_bytes, 0);
|
||||
g_memcpy(newp, b->p, oldsize);
|
||||
g_free(b->p);
|
||||
b->p = newp;
|
||||
}
|
||||
g_memset(&stbuf, 0, sizeof(stbuf));
|
||||
stbuf.st_ino = ino;
|
||||
fuse_add_direntry(req, b->p + oldsize, b->size - oldsize, name, &stbuf,
|
||||
b->size);
|
||||
}
|
||||
|
||||
#define lmin(x, y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
/*****************************************************************************/
|
||||
static int APP_CC
|
||||
reply_buf_limited(fuse_req_t req, const char *buf, size_t bufsize,
|
||||
off_t off, size_t maxsize)
|
||||
{
|
||||
LLOGLN(10, ("reply_buf_limited: %d", maxsize));
|
||||
if (off < bufsize)
|
||||
{
|
||||
return fuse_reply_buf(req, buf + off,
|
||||
lmin(bufsize - off, maxsize));
|
||||
}
|
||||
else
|
||||
{
|
||||
return fuse_reply_buf(req, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
xrdp_ll_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
|
||||
off_t off, struct fuse_file_info *fi)
|
||||
{
|
||||
struct dirbuf b;
|
||||
int index;
|
||||
|
||||
if (ino != 1)
|
||||
{
|
||||
fuse_reply_err(req, ENOTDIR);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_memset(&b, 0, sizeof(b));
|
||||
dirbuf_add(req, &b, ".", 1);
|
||||
dirbuf_add(req, &b, "..", 2);
|
||||
for (index = 0; index < g_file_items_count; index++)
|
||||
{
|
||||
dirbuf_add(req, &b, g_file_items[index].filename,
|
||||
g_file_items[index].ino);
|
||||
}
|
||||
reply_buf_limited(req, b.p, b.size, off, size);
|
||||
g_free(b.p);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
xrdp_ll_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
|
||||
{
|
||||
LLOGLN(10, ("xrdp_ll_open: ino %d", (int)ino));
|
||||
if (ino == 1 || ino == 2)
|
||||
{
|
||||
fuse_reply_err(req, EISDIR);
|
||||
}
|
||||
else if ((fi->flags & 3) != O_RDONLY)
|
||||
{
|
||||
fuse_reply_err(req, EACCES);
|
||||
}
|
||||
else
|
||||
{
|
||||
fuse_reply_open(req, fi);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static void DEFAULT_CC
|
||||
xrdp_ll_read(fuse_req_t req, fuse_ino_t ino, size_t size,
|
||||
off_t off, struct fuse_file_info *fi)
|
||||
{
|
||||
int index;
|
||||
|
||||
LLOGLN(10, ("xrdp_ll_read: %d %d %d", (int)ino, (int)off, (int)size));
|
||||
index = ino - 3;
|
||||
if (index < 0 || index >= g_file_items_count)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
reply_buf_limited(req, g_file_items[index].data,
|
||||
g_file_items[index].data_bytes,
|
||||
off, size);
|
||||
}
|
||||
}
|
||||
|
||||
static struct fuse_lowlevel_ops xrdp_ll_oper =
|
||||
{
|
||||
.lookup = xrdp_ll_lookup,
|
||||
.getattr = xrdp_ll_getattr,
|
||||
.readdir = xrdp_ll_readdir,
|
||||
.open = xrdp_ll_open,
|
||||
.read = xrdp_ll_read,
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
static int APP_CC
|
||||
fuse_init_lib(int argc, char **argv)
|
||||
{
|
||||
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
|
||||
int error;
|
||||
|
||||
error = fuse_parse_cmdline(&args, &g_mountpoint, 0, 0);
|
||||
if (error == -1)
|
||||
{
|
||||
LLOGLN(0, ("fuse_init_lib: fuse_parse_cmdline failed"));
|
||||
fuse_opt_free_args(&args);
|
||||
return 1;
|
||||
}
|
||||
g_ch = fuse_mount(g_mountpoint, &args);
|
||||
if (g_ch == 0)
|
||||
{
|
||||
LLOGLN(0, ("fuse_init_lib: fuse_mount failed"));
|
||||
fuse_opt_free_args(&args);
|
||||
return 1;
|
||||
}
|
||||
g_se = fuse_lowlevel_new(&args, &xrdp_ll_oper,
|
||||
sizeof(xrdp_ll_oper), 0);
|
||||
if (g_se == 0)
|
||||
{
|
||||
LLOGLN(0, ("fuse_init_lib: fuse_lowlevel_new failed"));
|
||||
fuse_unmount(g_mountpoint, g_ch);
|
||||
g_ch = 0;
|
||||
fuse_opt_free_args(&args);
|
||||
return 1;
|
||||
}
|
||||
fuse_opt_free_args(&args);
|
||||
fuse_session_add_chan(g_se, g_ch);
|
||||
g_bufsize = fuse_chan_bufsize(g_ch);
|
||||
g_buffer = g_malloc(g_bufsize, 0);
|
||||
g_fd = fuse_chan_fd(g_ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
fuse_set_dir_item(int index, char *filename, int flags, char *data,
|
||||
int data_bytes, int ino)
|
||||
{
|
||||
g_strncpy(g_file_items[index].filename, filename, 255);
|
||||
g_file_items[index].flags = flags;
|
||||
g_memcpy(g_file_items[index].data, data, data_bytes);
|
||||
g_file_items[index].data_bytes = data_bytes;
|
||||
g_file_items[index].ino = ino;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
fuse_get_wait_objs(tbus *objs, int *count, int *timeout)
|
||||
{
|
||||
int lcount;
|
||||
|
||||
LLOGLN(10, ("fuse_get_wait_objs:"));
|
||||
if (g_ch == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
lcount = *count;
|
||||
objs[lcount] = g_fd;
|
||||
lcount++;
|
||||
*count = lcount;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
fuse_check_wait_objs(void)
|
||||
{
|
||||
struct fuse_chan *tmpch;
|
||||
int res;
|
||||
|
||||
LLOGLN(10, ("fuse_check_wait_objs:"));
|
||||
if (g_ch == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (g_tcp_select(g_fd, 0) & 1)
|
||||
{
|
||||
LLOGLN(10, ("fuse_check_wait_objs: fd is set"));
|
||||
tmpch = g_ch;
|
||||
res = fuse_chan_recv(&tmpch, g_buffer, g_bufsize);
|
||||
if (res == -EINTR)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (res <= 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
fuse_session_process(g_se, g_buffer, res, tmpch);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
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));
|
||||
if (g_ch != 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
g_time = g_time1();
|
||||
g_uid = g_getuid();
|
||||
g_gid = g_getgid();
|
||||
argv[0] = param0;
|
||||
argv[1] = root_path;
|
||||
argv[2] = 0;
|
||||
|
||||
g_file_items = g_malloc(sizeof(struct file_item) * 3, 1);
|
||||
fuse_set_dir_item(0, "File1", 0, "1\n", 2, 3);
|
||||
fuse_set_dir_item(1, "File2", 0, "2\n", 2, 4);
|
||||
fuse_set_dir_item(2, "File3", 0, "3\n", 2, 5);
|
||||
g_file_items_count = 3;
|
||||
|
||||
return fuse_init_lib(2, argv);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns error */
|
||||
int APP_CC
|
||||
fuse_deinit(void)
|
||||
{
|
||||
LLOGLN(0, ("fuse_deinit:"));
|
||||
if (g_ch != 0)
|
||||
{
|
||||
LLOGLN(0, ("fuse_deinit: calling fuse_unmount"));
|
||||
fuse_session_remove_chan(g_ch);
|
||||
fuse_unmount(g_mountpoint, g_ch);
|
||||
g_ch = 0;
|
||||
}
|
||||
if (g_se != 0)
|
||||
{
|
||||
LLOGLN(0, ("fuse_deinit: calling fuse_session_destroy"));
|
||||
fuse_session_destroy(g_se);
|
||||
g_se = 0;
|
||||
}
|
||||
if (g_buffer != 0)
|
||||
{
|
||||
g_free(g_buffer);
|
||||
g_buffer = 0;
|
||||
}
|
||||
if (g_file_items != 0)
|
||||
{
|
||||
g_free(g_file_items);
|
||||
g_file_items = 0;
|
||||
g_file_items_count = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
26
sesman/chansrv/chansrv_fuse.h
Normal file
26
sesman/chansrv/chansrv_fuse.h
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
#if !defined(CHANSRV_FUSE_H)
|
||||
#define CHANSRV_FUSE_H
|
||||
|
||||
struct file_item
|
||||
{
|
||||
char filename[256];
|
||||
int flags;
|
||||
char data[256];
|
||||
int data_bytes;
|
||||
int ino;
|
||||
};
|
||||
|
||||
int APP_CC
|
||||
fuse_set_dir_item(int index, char *filename, int flags, char *data,
|
||||
int data_bytes, int ino);
|
||||
int APP_CC
|
||||
fuse_get_wait_objs(tbus *objs, int *count, int *timeout);
|
||||
int APP_CC
|
||||
fuse_check_wait_objs(void);
|
||||
int APP_CC
|
||||
fuse_init(void);
|
||||
int APP_CC
|
||||
fuse_deinit(void);
|
||||
|
||||
#endif
|
63
sesman/chansrv/clipboard-notes.txt
Normal file
63
sesman/chansrv/clipboard-notes.txt
Normal file
@ -0,0 +1,63 @@
|
||||
LOG_LEVEL
|
||||
|
||||
dolphin
|
||||
clipboard_event_selection_owner_notify:
|
||||
clipboard_event_selection_notify: 0x1f7 text/uri-list
|
||||
clipboard_event_selection_notify: 0x1f8 text/x-moz-url
|
||||
clipboard_event_selection_notify: 0x1f3 text/plain
|
||||
clipboard_event_selection_notify: 0xee UTF8_STRING
|
||||
clipboard_event_selection_notify: 0x1f STRING
|
||||
clipboard_event_selection_notify: 0x1a1 TEXT
|
||||
clipboard_event_selection_notify: 0x1a0 COMPOUND_TEXT
|
||||
clipboard_event_selection_notify: 0x1fa application/x-qiconlist
|
||||
clipboard_event_selection_notify: 0xec TARGETS
|
||||
clipboard_event_selection_notify: 0xed MULTIPLE
|
||||
clipboard_event_selection_notify: 0xeb TIMESTAMP
|
||||
clipboard_event_selection_notify: 0x183 SAVE_TARGETS
|
||||
|
||||
thunar
|
||||
clipboard_event_selection_owner_notify:
|
||||
clipboard_event_selection_notify: 0xeb TIMESTAMP
|
||||
clipboard_event_selection_notify: 0xec TARGETS
|
||||
clipboard_event_selection_notify: 0xed MULTIPLE
|
||||
clipboard_event_selection_notify: 0x204 x-special/gnome-copied-files
|
||||
clipboard_event_selection_notify: 0xee UTF8_STRING
|
||||
clipboard_data_in:
|
||||
clipboard_data_in: 3
|
||||
|
||||
pcmanfm
|
||||
clipboard_event_selection_owner_notify:
|
||||
clipboard_event_selection_notify: 0xeb TIMESTAMP
|
||||
clipboard_event_selection_notify: 0xec TARGETS
|
||||
clipboard_event_selection_notify: 0xed MULTIPLE
|
||||
clipboard_event_selection_notify: 0x1f7 text/uri-list
|
||||
clipboard_event_selection_notify: 0x204 x-special/gnome-copied-files
|
||||
clipboard_event_selection_notify: 0x1f9 application/x-kde-cutselection
|
||||
clipboard_event_selection_notify: 0xee UTF8_STRING
|
||||
|
||||
CAJA
|
||||
clipboard_event_selection_notify: 0x141 TIMESTAMP
|
||||
clipboard_event_selection_notify: 0x130 TARGETS
|
||||
clipboard_event_selection_notify: 0x142 MULTIPLE
|
||||
clipboard_event_selection_notify: 0x143 x-special/mate-copied-files
|
||||
clipboard_event_selection_notify: 0x144 text/uri-list
|
||||
clipboard_event_selection_notify: 0x0 (null)
|
||||
clipboard_event_selection_notify: 0x25 WM_ICON_NAME
|
||||
clipboard_event_selection_notify: 0x47524154 (null)
|
||||
clipboard_event_selection_notify: 0x50000078 (null)
|
||||
clipboard_event_selection_notify: 0x0 (null)
|
||||
clipboard_event_selection_notify: 0x25 WM_ICON_NAME
|
||||
|
||||
nautilus
|
||||
clipboard_event_selection_notify: 0x141 TIMESTAMP
|
||||
clipboard_event_selection_notify: 0x130 TARGETS
|
||||
clipboard_event_selection_notify: 0x142 MULTIPLE
|
||||
clipboard_event_selection_notify: 0x154 x-special/gnome-copied-files
|
||||
clipboard_event_selection_notify: 0x144 text/uri-list
|
||||
clipboard_event_selection_notify: 0xfb UTF8_STRING
|
||||
clipboard_event_selection_notify: 0x0 (null)
|
||||
clipboard_event_selection_notify: 0x25 WM_ICON_NAME
|
||||
clipboard_event_selection_notify: 0x47524154 (null)
|
||||
clipboard_event_selection_notify: 0x50000078 (null)
|
||||
clipboard_event_selection_notify: 0x0 (null)
|
||||
clipboard_event_selection_notify: 0x25 WM_ICON_NAME
|
@ -55,6 +55,7 @@ xlsatoms - dump atoms
|
||||
#include "clipboard_file.h"
|
||||
#include "clipboard_common.h"
|
||||
#include "xcommon.h"
|
||||
#include "chansrv_fuse.h"
|
||||
|
||||
#define LLOG_LEVEL 11
|
||||
#define LLOGLN(_level, _args) \
|
||||
@ -202,6 +203,7 @@ clipboard_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
fuse_init();
|
||||
xcommon_init();
|
||||
clipboard_deinit();
|
||||
g_incr_max_req_size = XMaxRequestSize(g_display) * 4 - 24;
|
||||
@ -346,6 +348,8 @@ clipboard_deinit(void)
|
||||
g_wnd = 0;
|
||||
}
|
||||
|
||||
fuse_deinit();
|
||||
|
||||
g_free(g_clip_c2s.data);
|
||||
g_clip_c2s.data = 0;
|
||||
g_free(g_clip_s2c.data);
|
||||
@ -442,7 +446,7 @@ clipboard_out_unicode(struct stream *s, char *text, int num_chars)
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns number of bytes read */
|
||||
static int APP_CC
|
||||
int APP_CC
|
||||
clipboard_in_unicode(struct stream *s, char *text, int *num_chars)
|
||||
{
|
||||
int index;
|
||||
@ -838,6 +842,7 @@ clipboard_process_format_announce(struct stream *s, int clip_msg_status,
|
||||
int formatId;
|
||||
int count;
|
||||
int bytes;
|
||||
int got_file;
|
||||
char desc[256];
|
||||
char *holdp;
|
||||
|
||||
@ -847,6 +852,7 @@ clipboard_process_format_announce(struct stream *s, int clip_msg_status,
|
||||
clipboard_send_format_ack();
|
||||
desc[0] = 0;
|
||||
g_num_formatIds = 0;
|
||||
got_file = 0;
|
||||
while (clip_msg_len > 3)
|
||||
{
|
||||
in_uint32_le(s, formatId);
|
||||
@ -869,7 +875,7 @@ 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 "
|
||||
LLOGLN(0, ("clipboard_process_format_announce: formatId 0x%8.8x "
|
||||
"wszFormatName [%s] clip_msg_len %d", formatId, desc,
|
||||
clip_msg_len));
|
||||
g_formatIds[g_num_formatIds] = formatId;
|
||||
@ -878,6 +884,18 @@ clipboard_process_format_announce(struct stream *s, int clip_msg_status,
|
||||
{
|
||||
LLOGLN(10, ("clipboard_process_format_announce: max formats"));
|
||||
}
|
||||
if (formatId == 0x0000c0c8)
|
||||
{
|
||||
got_file = 1;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((g_num_formatIds > 0) &&
|
||||
@ -1069,6 +1087,13 @@ clipboard_process_data_response(struct stream *s, int clip_msg_status,
|
||||
clip_msg_len);
|
||||
return 0;
|
||||
}
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
LOGM((LOG_LEVEL_DEBUG, "clipboard_process_data_response: "
|
||||
"CLIPRDR_DATA_RESPONSE"));
|
||||
len = (int)(s->end - s->p);
|
||||
|
@ -28,8 +28,6 @@ clipboard_init(void);
|
||||
int APP_CC
|
||||
clipboard_deinit(void);
|
||||
int APP_CC
|
||||
clipboard_out_unicode(struct stream *s, char *text, int num_chars);
|
||||
int APP_CC
|
||||
clipboard_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
int total_length);
|
||||
int APP_CC
|
||||
|
@ -80,8 +80,12 @@
|
||||
#define CB_FD_WRITESTIME 0x00000020
|
||||
#define CB_FD_PROGRESSUI 0x00004000
|
||||
|
||||
#define CB_FILE_ATTRIBUTE_ARCHIVE 0x00000020;
|
||||
#define CB_FILE_ATTRIBUTE_NORMAL 0x00000080;
|
||||
#define CB_FILE_ATTRIBUTE_READONLY 0x00000001
|
||||
#define CB_FILE_ATTRIBUTE_HIDDEN 0x00000002
|
||||
#define CB_FILE_ATTRIBUTE_SYSTEM 0x00000004
|
||||
#define CB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
|
||||
#define CB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
|
||||
#define CB_FILE_ATTRIBUTE_NORMAL 0x00000080
|
||||
|
||||
struct clip_s2c /* server to client, pasting from linux app to mstsc */
|
||||
{
|
||||
@ -108,4 +112,9 @@ struct clip_c2s /* client to server, pasting from mstsc to linux app */
|
||||
Time clip_time;
|
||||
};
|
||||
|
||||
int APP_CC
|
||||
clipboard_out_unicode(struct stream *s, char *text, int num_chars);
|
||||
int APP_CC
|
||||
clipboard_in_unicode(struct stream *s, char *text, int *num_chars);
|
||||
|
||||
#endif
|
||||
|
@ -16,6 +16,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* MS-RDPECLIP
|
||||
* http://msdn.microsoft.com/en-us/library/cc241066%28prot.20%29.aspx
|
||||
*
|
||||
* CLIPRDR_FILEDESCRIPTOR
|
||||
* http://msdn.microsoft.com/en-us/library/ff362447%28prot.20%29.aspx */
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
@ -27,6 +33,7 @@
|
||||
#include "clipboard_file.h"
|
||||
#include "clipboard_common.h"
|
||||
#include "xcommon.h"
|
||||
#include "chansrv_fuse.h"
|
||||
|
||||
#define LLOG_LEVEL 11
|
||||
#define LLOGLN(_level, _args) \
|
||||
@ -45,18 +52,52 @@ 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 */
|
||||
|
||||
|
||||
struct cb_file_info
|
||||
{
|
||||
char pathname[256];
|
||||
char filename[256];
|
||||
int flags;
|
||||
int size;
|
||||
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;
|
||||
|
||||
/* number of seconds from 1 Jan. 1601 00:00 to 1 Jan 1970 00:00 UTC */
|
||||
#define CB_EPOCH_DIFF 11644473600LL
|
||||
|
||||
/*****************************************************************************/
|
||||
static tui64 APP_CC
|
||||
timeval2wintime(struct timeval *tv)
|
||||
{
|
||||
tui64 result;
|
||||
|
||||
result = CB_EPOCH_DIFF;
|
||||
result += tv->tv_sec;
|
||||
result *= 10000000LL;
|
||||
result += tv->tv_usec * 10;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* this will replace %20 or any hex with the space or correct char
|
||||
* returns error */
|
||||
static int APP_CC
|
||||
clipboard_check_file(char *filename)
|
||||
{
|
||||
@ -97,11 +138,13 @@ clipboard_get_file(char* file, int bytes)
|
||||
{
|
||||
int sindex;
|
||||
int pindex;
|
||||
int flags;
|
||||
char full_fn[256]; /* /etc/xrdp/xrdp.ini */
|
||||
char filename[256]; /* xrdp.ini */
|
||||
char pathname[256]; /* /etc/xrdp */
|
||||
|
||||
sindex = 0;
|
||||
flags = CB_FILE_ATTRIBUTE_ARCHIVE;
|
||||
if (g_strncmp(file, "file:///", 8) == 0)
|
||||
{
|
||||
sindex = 7;
|
||||
@ -130,6 +173,7 @@ clipboard_get_file(char* file, int bytes)
|
||||
{
|
||||
LLOGLN(0, ("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))
|
||||
@ -143,6 +187,8 @@ clipboard_get_file(char* file, int bytes)
|
||||
g_strcpy(g_files[g_num_files].filename, filename);
|
||||
g_strcpy(g_files[g_num_files].pathname, pathname);
|
||||
g_files[g_num_files].size = g_file_get_size(full_fn);
|
||||
g_files[g_num_files].flags = flags;
|
||||
g_files[g_num_files].time = (g_time1() + CB_EPOCH_DIFF) * 10000000LL;
|
||||
g_writeln("ok filename [%s] pathname [%s] size [%d]",
|
||||
g_files[g_num_files].filename,
|
||||
g_files[g_num_files].pathname,
|
||||
@ -209,6 +255,7 @@ clipboard_send_data_response_for_file(char *data, int data_size)
|
||||
int cItems;
|
||||
int flags;
|
||||
int index;
|
||||
tui32 ui32;
|
||||
char fn[256];
|
||||
|
||||
LLOGLN(10, ("clipboard_send_data_response_for_file: data_size %d",
|
||||
@ -228,14 +275,17 @@ clipboard_send_data_response_for_file(char *data, int data_size)
|
||||
flags = CB_FD_ATTRIBUTES | CB_FD_FILESIZE | CB_FD_WRITESTIME | CB_FD_PROGRESSUI;
|
||||
out_uint32_le(s, flags);
|
||||
out_uint8s(s, 32); /* reserved1 */
|
||||
flags = CB_FILE_ATTRIBUTE_ARCHIVE;
|
||||
//flags = CB_FILE_ATTRIBUTE_NORMAL;
|
||||
flags = g_files[index].flags;
|
||||
out_uint32_le(s, flags);
|
||||
out_uint8s(s, 16); /* reserved2 */
|
||||
/* file time */
|
||||
/* 100-nanoseconds intervals since 1 January 1601 */
|
||||
out_uint32_le(s, 0x2c305d08); /* 25 October 2009, 21:17 */
|
||||
out_uint32_le(s, 0x01ca55f3);
|
||||
//out_uint32_le(s, 0x2c305d08); /* 25 October 2009, 21:17 */
|
||||
//out_uint32_le(s, 0x01ca55f3);
|
||||
ui32 = g_files[index].time & 0xffffffff;
|
||||
out_uint32_le(s, ui32);
|
||||
ui32 = g_files[index].time >> 32;
|
||||
out_uint32_le(s, ui32);
|
||||
/* file size */
|
||||
out_uint32_le(s, 0);
|
||||
out_uint32_le(s, g_files[index].size);
|
||||
@ -365,3 +415,63 @@ clipboard_process_file_request(struct stream *s, int clip_msg_status,
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* read in CLIPRDR_FILEDESCRIPTOR */
|
||||
static int APP_CC
|
||||
clipboard_c2s_in_file_info(struct stream *s, struct clip_file_desc *cfd)
|
||||
{
|
||||
int num_chars;
|
||||
int ex_bytes;
|
||||
|
||||
in_uint32_le(s, cfd->flags);
|
||||
in_uint8s(s, 32); /* reserved1 */
|
||||
in_uint32_le(s, cfd->fileAttributes);
|
||||
in_uint8s(s, 16); /* reserved2 */
|
||||
in_uint32_le(s, cfd->lastWriteTimeLow);
|
||||
in_uint32_le(s, cfd->lastWriteTimeHigh);
|
||||
in_uint32_le(s, cfd->fileSizeHigh);
|
||||
in_uint32_le(s, cfd->fileSizeLow);
|
||||
num_chars = 256;
|
||||
clipboard_in_unicode(s, cfd->cFileName, &num_chars);
|
||||
ex_bytes = 512 - num_chars * 2;
|
||||
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));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
clipboard_c2s_in_files(struct stream *s)
|
||||
{
|
||||
tui32 cItems;
|
||||
struct clip_file_desc cfd;
|
||||
int ino;
|
||||
int index;
|
||||
|
||||
in_uint32_le(s, cItems);
|
||||
g_file_items_count = cItems;
|
||||
g_free(g_file_items);
|
||||
g_file_items = g_malloc(sizeof(struct file_item) * g_file_items_count, 1);
|
||||
LLOGLN(10, ("clipboard_c2s_in_files: cItems %d", cItems));
|
||||
ino = 3;
|
||||
index = 0;
|
||||
while (cItems > 0)
|
||||
{
|
||||
clipboard_c2s_in_file_info(s, &cfd);
|
||||
fuse_set_dir_item(index, cfd.cFileName, 0, "1\n", 2, ino);
|
||||
index++;
|
||||
ino++;
|
||||
cItems--;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -27,5 +27,7 @@ clipboard_send_data_response_for_file(char *data, int data_size);
|
||||
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);
|
||||
|
||||
#endif
|
||||
|
@ -132,7 +132,7 @@ xcommon_get_wait_objs(tbus *objs, int *count, int *timeout)
|
||||
|
||||
if (((!g_clip_up) && (!g_rail_up)) || (objs == 0) || (count == 0))
|
||||
{
|
||||
LOG(10, ("xcommon_get_wait_objs: nothing to do"));
|
||||
//LOG(10, ("xcommon_get_wait_objs: nothing to do"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ xcommon_check_wait_objs(void)
|
||||
|
||||
if ((!g_clip_up) && (!g_rail_up))
|
||||
{
|
||||
LOG(10, ("xcommon_check_wait_objs: nothing to do"));
|
||||
//LOG(10, ("xcommon_check_wait_objs: nothing to do"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user