Merge pull request #90 from neutrinolabs/master

xorg driver, smart card, etc
ulab-next
jsorg71 11 years ago
commit b8388a65a2

@ -183,6 +183,31 @@ struct stream
} while (0)
#endif
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define in_uint64_le(s, v) do \
{ \
(v) = (tui64) \
( \
(((tui64)(*((unsigned char*)((s)->p + 0)))) << 0) | \
(((tui64)(*((unsigned char*)((s)->p + 1)))) << 8) | \
(((tui64)(*((unsigned char*)((s)->p + 2)))) << 16) | \
(((tui64)(*((unsigned char*)((s)->p + 3)))) << 24) | \
(((tui64)(*((unsigned char*)((s)->p + 4)))) << 32) | \
(((tui64)(*((unsigned char*)((s)->p + 5)))) << 40) | \
(((tui64)(*((unsigned char*)((s)->p + 6)))) << 48) | \
(((tui64)(*((unsigned char*)((s)->p + 7)))) << 56) \
); \
(s)->p += 8; \
} while (0)
#else
#define in_uint64_le(s, v) do \
{ \
(v) = *((tui64*)((s)->p)); \
(s)->p += 8; \
} while (0)
#endif
/******************************************************************************/
#define in_uint32_be(s, v) do \
{ \

@ -92,6 +92,7 @@ struct xrdp_client_info
int use_bulk_comp;
int pointer_flags; /* 0 color, 1 new, 2 no new */
int use_fast_path;
int require_credentials; /* when true, credentials *must* be passed on cmd line */
};
#endif

@ -135,6 +135,10 @@ xrdp_rdp_read_config(struct xrdp_client_info *client_info)
{
client_info->pointer_flags = text2bool(value) == 0 ? 2 : 0;
}
else if (g_strcasecmp(item, "require_credentials") == 0)
{
client_info->require_credentials = text2bool(value);
}
}
list_delete(items);

@ -451,6 +451,8 @@ xrdp_sec_process_logon_info(struct xrdp_sec *self, struct stream *s)
else
{
in_uint8s(s, len_password + 2);
if (self->rdp_layer->client_info.require_credentials)
return 1; /* credentials on cmd line is mandatory */
}
unicode_in(s, len_program, self->rdp_layer->client_info.program, 255);

@ -46,6 +46,7 @@ xrdp_chansrv_SOURCES = \
clipboard_file.c \
devredir.c \
smartcard.c \
smartcard_pcsc.c \
rail.c \
xcommon.c \
drdynvc.c \

@ -57,7 +57,7 @@ struct xrdp_api_data
int APP_CC send_channel_data(int chan_id, char *data, int size);
int APP_CC main_cleanup(void);
int APP_CC find_empty_slot_in_dvc_channels();
struct xrdp_api_data *APP_CC struct_from_dvc_chan_id(tui32 dvc_chan_id);
struct xrdp_api_data * APP_CC struct_from_dvc_chan_id(tui32 dvc_chan_id);
int remove_struct_with_chan_id(tui32 dvc_chan_id);
#define LOG_LEVEL 5

@ -125,6 +125,13 @@ void xfuse_devredir_cb_file_close(void *vp) {}
g_writeln (_params); \
}
#define log_always(_params...) \
{ \
g_write("[%10.10u]: FUSE %s: %d : ALWAYS: ", \
g_time3(), __func__, __LINE__); \
g_writeln (_params); \
}
#define log_info(_params...) \
{ \
if (LOG_INFO <= LOG_LEVEL) \
@ -210,6 +217,12 @@ struct req_list_item
int size;
};
struct dir_info
{
/* last index accessed in g_xrdp_fs.inode_table[] */
int index;
};
static struct list *g_req_list = 0;
static struct xrdp_fs g_xrdp_fs; /* an inst of xrdp file system */
static char *g_mount_point = 0; /* our FUSE mount point */
@ -249,6 +262,7 @@ static int xfuse_does_file_exist(int parent, char *name);
static int xfuse_delete_file(int parent, char *name);
static int xfuse_delete_file_with_xinode(XRDP_INODE *xinode);
static int xfuse_delete_dir_with_xinode(XRDP_INODE *xinode);
static int xfuse_recursive_delete_dir_with_xinode(XRDP_INODE *xinode);
static void xfuse_update_xrdpfs_size();
static void xfuse_enum_dir(fuse_req_t req, fuse_ino_t ino, size_t size,
off_t off, struct fuse_file_info *fi);
@ -331,6 +345,16 @@ int clipboard_request_file_data(int stream_id, int lindex, int offset,
static void xfuse_cb_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr,
int to_set, struct fuse_file_info *fi);
static void xfuse_cb_opendir(fuse_req_t req, fuse_ino_t ino,
struct fuse_file_info *fi);
static void xfuse_cb_releasedir(fuse_req_t req, fuse_ino_t ino,
struct fuse_file_info *fi);
/* misc calls */
static void xfuse_mark_as_stale(int pinode);
static void xfuse_delete_stale_entries(int pinode);
/*****************************************************************************
** **
** public functions - can be called from any code path **
@ -381,20 +405,22 @@ int xfuse_init()
/* setup FUSE callbacks */
g_memset(&g_xfuse_ops, 0, sizeof(g_xfuse_ops));
g_xfuse_ops.lookup = xfuse_cb_lookup;
g_xfuse_ops.readdir = xfuse_cb_readdir;
g_xfuse_ops.mkdir = xfuse_cb_mkdir;
g_xfuse_ops.rmdir = xfuse_cb_rmdir;
g_xfuse_ops.unlink = xfuse_cb_unlink;
g_xfuse_ops.rename = xfuse_cb_rename;
g_xfuse_ops.open = xfuse_cb_open;
g_xfuse_ops.release = xfuse_cb_release;
g_xfuse_ops.read = xfuse_cb_read;
g_xfuse_ops.write = xfuse_cb_write;
g_xfuse_ops.create = xfuse_cb_create;
g_xfuse_ops.lookup = xfuse_cb_lookup;
g_xfuse_ops.readdir = xfuse_cb_readdir;
g_xfuse_ops.mkdir = xfuse_cb_mkdir;
g_xfuse_ops.rmdir = xfuse_cb_rmdir;
g_xfuse_ops.unlink = xfuse_cb_unlink;
g_xfuse_ops.rename = xfuse_cb_rename;
g_xfuse_ops.open = xfuse_cb_open;
g_xfuse_ops.release = xfuse_cb_release;
g_xfuse_ops.read = xfuse_cb_read;
g_xfuse_ops.write = xfuse_cb_write;
g_xfuse_ops.create = xfuse_cb_create;
//g_xfuse_ops.fsync = xfuse_cb_fsync; /* LK_TODO delete this */
g_xfuse_ops.getattr = xfuse_cb_getattr;
g_xfuse_ops.setattr = xfuse_cb_setattr;
g_xfuse_ops.getattr = xfuse_cb_getattr;
g_xfuse_ops.setattr = xfuse_cb_setattr;
g_xfuse_ops.opendir = xfuse_cb_opendir;
g_xfuse_ops.releasedir = xfuse_cb_releasedir;
fuse_opt_add_arg(&args, "xrdp-chansrv");
fuse_opt_add_arg(&args, g_fuse_root_path);
@ -1160,9 +1186,6 @@ static struct xrdp_inode * xfuse_create_file_in_xrdp_fs(tui32 device_id,
log_debug("incremented nentries; parent=%d nentries=%d",
pinode, xinodep->nentries);
/* LK_TODO */
xfuse_dump_fs();
return xinode;
}
@ -1245,6 +1268,52 @@ static int xfuse_delete_dir_with_xinode(XRDP_INODE *xinode)
return 0;
}
/**
* Recursively delete dir with specified inode
*****************************************************************************/
static int xfuse_recursive_delete_dir_with_xinode(XRDP_INODE *xinode)
{
XRDP_INODE *xip;
int i;
/* make sure it is not a file */
if ((xinode == NULL) || (xinode->mode & S_IFREG))
return -1;
for (i = FIRST_INODE; i < g_xrdp_fs.num_entries; i++)
{
if ((xip = g_xrdp_fs.inode_table[i]) == NULL)
continue;
/* look for child inodes */
if (xip->parent_inode == xinode->inode)
{
/* got one */
if (xip->mode & S_IFREG)
{
/* regular file */
g_xrdp_fs.inode_table[xip->parent_inode]->nentries--;
g_xrdp_fs.inode_table[xip->inode] = NULL;
free(xip);
}
else
{
/* got another dir */
xfuse_recursive_delete_dir_with_xinode(xip);
}
}
}
/* our parent will have one less dir */
g_xrdp_fs.inode_table[xinode->parent_inode]->nentries--;
g_xrdp_fs.inode_table[xinode->inode] = NULL;
free(xinode);
return 0;
}
static void xfuse_update_xrdpfs_size()
{
void *vp;
@ -1273,6 +1342,8 @@ static void xfuse_update_xrdpfs_size()
g_xrdp_fs.inode_table = vp;
}
/* LK_TODO do we still need this function */
#if 0
static void xfuse_enum_dir(fuse_req_t req, fuse_ino_t ino, size_t size,
off_t off, struct fuse_file_info *fi)
{
@ -1323,6 +1394,7 @@ static void xfuse_enum_dir(fuse_req_t req, fuse_ino_t ino, size_t size,
if (b.p)
free(b.p);
}
#endif
/******************************************************************************
** **
@ -1336,8 +1408,8 @@ static void xfuse_enum_dir(fuse_req_t req, fuse_ino_t ino, size_t size,
void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode)
{
XFUSE_INFO *fip = (XFUSE_INFO *) vp;
XRDP_INODE *xip = NULL;
XFUSE_INFO *fip = (XFUSE_INFO *) vp;
XRDP_INODE *xip = NULL;
if ((fip == NULL) || (xinode == NULL))
{
@ -1345,14 +1417,14 @@ void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode)
return;
}
log_debug("fip->req=%p", fip->req);
if (!xfuse_is_inode_valid(fip->inode))
{
log_error("inode %d is not valid", fip->inode);
return;
}
log_debug("parent_inode=%d name=%s", fip->inode, xinode->name);
/* if filename is . or .. don't add it */
if ((strcmp(xinode->name, ".") == 0) || (strcmp(xinode->name, "..") == 0))
{
@ -1360,12 +1432,14 @@ void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode)
return;
}
xfuse_dump_fs();
if ((xip = xfuse_get_inode_from_pinode_name(fip->inode, xinode->name)) != NULL)
{
log_debug("inode=%d name=%s already exists in xrdp_fs; not adding it",
fip->inode, xinode->name);
free(xinode);
xinode = xip;
xip->stale = 0;
return;
}
@ -1379,8 +1453,10 @@ void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode)
/* insert it in xrdp fs and update lookup count */
g_xrdp_fs.inode_table[xinode->inode] = xinode;
g_xrdp_fs.inode_table[fip->inode]->nentries++; /* this was missing */
g_xrdp_fs.inode_table[fip->inode]->nentries++;
xfuse_update_xrdpfs_size();
xfuse_dump_fs();
}
/**
@ -1388,27 +1464,18 @@ void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode)
void xfuse_devredir_cb_enum_dir_done(void *vp, tui32 IoStatus)
{
log_debug(">>>>>> vp=%p IoStatus=0x%x", vp, IoStatus);
XFUSE_INFO *fip;
struct dir_info *di;
if (vp == NULL)
return;
XRDP_INODE *xinode;
XRDP_INODE *ti;
struct dirbuf1 b;
int i;
int first_time = 1;
XFUSE_INFO *fip = (XFUSE_INFO *) vp;
log_debug("vp=%p IoStatus=0x%x", vp, IoStatus);
fip = (XFUSE_INFO *) vp;
if (fip == NULL)
{
log_debug("fip is NULL");
goto done;
return;
}
log_debug("fip->req=%p", fip->req);
if (IoStatus != 0)
{
/* command failed */
@ -1425,168 +1492,22 @@ void xfuse_devredir_cb_enum_dir_done(void *vp, tui32 IoStatus)
fuse_reply_err(fip->req, EBADF);
goto done;
}
#if 0
memset(&b, 0, sizeof(struct dirbuf));
#else
b.bytes_in_buf = 0;
#endif
for (i = FIRST_INODE; i < g_xrdp_fs.num_entries; i++)
{
if ((xinode = g_xrdp_fs.inode_table[i]) == NULL)
continue;
/* match parent inode */
if (xinode->parent_inode != fip->inode)
continue;
xfuse_delete_stale_entries(fip->inode);
xinode->is_synced = 1;
/* this will be used by xfuse_cb_readdir() */
di = calloc(1, sizeof(struct dir_info));
di->index = FIRST_INODE;
fip->fi->fh = (long) di;
if (first_time)
{
first_time = 0;
ti = g_xrdp_fs.inode_table[fip->inode];
#if 0
xfuse_dirbuf_add(fip->req, &b, ".", fip->inode);
xfuse_dirbuf_add(fip->req, &b, "..", ti->parent_inode);
#else
xfuse_dirbuf_add1(fip->req, &b, ".", fip->inode);
xfuse_dirbuf_add1(fip->req, &b, "..", ti->parent_inode);
#endif
}
#if 0
xfuse_dirbuf_add(fip->req, &b, xinode->name, xinode->inode);
#else
xfuse_dirbuf_add1(fip->req, &b, xinode->name, xinode->inode);
#endif
}
if ((first_time == 0) && (fip->invoke_fuse))
{
if (fip->off < b.bytes_in_buf)
{
#if 0
fuse_reply_buf(fip->req, b.p + fip->off,
min(b.size - fip->off, fip->size));
#else
log_debug("calling fuse_reply_buf() with data...");
fuse_reply_buf(fip->req, b.buf, b.bytes_in_buf);
log_debug("calling fuse_reply_buf() with data...done");
#endif
}
else
{
log_debug("calling fuse_reply_buf() with NULL...");
fuse_reply_buf(fip->req, NULL, 0);
log_debug("calling fuse_reply_buf() with NULL...done");
}
}
else
{
log_debug("calling fuse_reply_err()...");
fuse_reply_err(fip->req, ENOENT);
log_debug("calling fuse_reply_err()...done");
}
fuse_reply_open(fip->req, fip->fi);
done:
#if 0
if (b.p)
free(b.p);
#endif
if (!fip)
printf("###### %s : %s : %d: fip is NULL\n", __FILE__, __func__, __LINE__);
if (fip)
free(fip);
}
void xfuse_devredir_cb_enum_dir_done_TODO(void *vp, tui32 IoStatus)
{
struct xrdp_inode *xinode;
struct fuse_entry_param e;
int i;
XFUSE_INFO *fip = (XFUSE_INFO *) vp;
printf("--------- xfuse_devredir_cb_enum_dir_done() entered\n");
xfuse_dump_fs();
if (fip == NULL)
{
log_debug("fip is NULL");
goto done;
}
if (IoStatus != 0)
{
/* command failed */
if (fip->invoke_fuse)
fuse_reply_err(fip->req, ENOENT);
goto done;
}
/* do we have a valid inode? */
if (!xfuse_is_inode_valid(fip->inode))
{
log_error("inode %d is not valid", fip->inode);
if (fip->invoke_fuse)
fuse_reply_err(fip->req, EBADF);
goto done;
}
log_debug("looking for parent_inode=%d name=%s", fip->inode, fip->name);
for (i = FIRST_INODE; i < g_xrdp_fs.num_entries; i++)
{
if ((xinode = g_xrdp_fs.inode_table[i]) == NULL)
continue;
/* match parent inode */
if (xinode->parent_inode != fip->inode)
continue;
/* match name */
if (strcmp(xinode->name, fip->name) != 0)
continue;
memset(&e, 0, sizeof(e));
e.ino = xinode->inode;
e.attr_timeout = XFUSE_ATTR_TIMEOUT;
e.entry_timeout = XFUSE_ENTRY_TIMEOUT;
e.attr.st_ino = xinode->inode;
e.attr.st_mode = xinode->mode;
e.attr.st_nlink = xinode->nlink;
e.attr.st_uid = xinode->uid;
e.attr.st_gid = xinode->gid;
e.attr.st_size = xinode->size;
e.attr.st_atime = xinode->atime;
e.attr.st_mtime = xinode->mtime;
e.attr.st_ctime = xinode->ctime;
e.generation = 1;
xinode->is_synced = 1;
if (fip->invoke_fuse)
fuse_reply_entry(fip->req, &e);
break;
}
if (i == g_xrdp_fs.num_entries)
{
/* requested entry not found */
log_debug("did NOT find entry");
if (fip->invoke_fuse)
fuse_reply_err(fip->req, ENOENT);
}
done:
free(fip);
}
void xfuse_devredir_cb_open_file(void *vp, tui32 IoStatus, tui32 DeviceId,
tui32 FileId)
{
@ -1652,7 +1573,7 @@ void xfuse_devredir_cb_open_file(void *vp, tui32 IoStatus, tui32 DeviceId,
{
if (fip->reply_type == RT_FUSE_REPLY_OPEN)
{
log_debug("LK_TODO sending fuse_reply_open(); "
log_debug("sending fuse_reply_open(); "
"DeviceId=%d FileId=%d req=%p fi=%p",
fh->DeviceId, fh->FileId, fip->req, fip->fi);
@ -1984,7 +1905,7 @@ static void xfuse_cb_getattr(fuse_req_t req, fuse_ino_t ino,
xino = g_xrdp_fs.inode_table[ino];
memset(&stbuf, 0, sizeof(stbuf));
stbuf.st_ino = ino;
stbuf.st_ino = ino;
stbuf.st_mode = xino->mode;
stbuf.st_nlink = xino->nlink;
stbuf.st_size = xino->size;
@ -2049,14 +1970,17 @@ static int xfuse_dirbuf_add1(fuse_req_t req, struct dirbuf1 *b,
static void xfuse_cb_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
off_t off, struct fuse_file_info *fi)
{
XRDP_INODE *xinode;
XFUSE_INFO *fip;
tui32 device_id;
char full_path[4096];
char *cptr;
XRDP_INODE *xinode;
XRDP_INODE *ti;
struct dir_info *di;
struct dirbuf1 b;
int i;
int first_time;
log_debug("req=%p inode=%d size=%d offset=%d", req, ino, size, off);
log_debug("req=%p inode=%d name=%s size=%d offset=%d", req, ino,
g_xrdp_fs.inode_table[ino]->name, size, off);
/* do we have a valid inode? */
if (!xfuse_is_inode_valid(ino))
{
log_error("inode %d is not valid", ino);
@ -2064,80 +1988,44 @@ static void xfuse_cb_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
return;
}
if (ino == 1)
di = (struct dir_info *) fi->fh;
if (di == NULL)
{
/* special case; enumerate top level dir */
log_debug("enumerating top level dir");
xfuse_enum_dir(req, ino, size, off, fi);
/* something seriously wrong somewhere! */
fuse_reply_buf(req, 0, 0);
return;
}
xinode = g_xrdp_fs.inode_table[ino];
if (xinode->is_loc_resource)
{
/* enumerate local resources */
xfuse_enum_dir(req, ino, size, off, fi);
return;
}
/* enumerate resources on a remote device */
#ifdef USE_SYNC_FLAG
if (xinode->is_synced)
{
xfuse_enum_dir(req, ino, size, off, fi);
return;
}
else
{
goto do_remote_lookup;
}
#endif
do_remote_lookup:
log_debug("did not find entry; redirecting call to dev_redir");
device_id = xfuse_get_device_id_for_inode((tui32) ino, full_path);
log_debug("dev_id=%d ino=%d full_path=%s", device_id, ino, full_path);
b.bytes_in_buf = 0;
first_time = (di->index == FIRST_INODE) ? 1 : 0;
if ((fip = calloc(1, sizeof(XFUSE_INFO))) == NULL)
for (i = di->index; i < g_xrdp_fs.num_entries; i++, di->index++)
{
log_error("system out of memory");
fuse_reply_err(req, ENOMEM);
return;
}
fip->req = req;
fip->inode = ino;
fip->size = size;
fip->off = off;
fip->fi = fi;
fip->dirbuf1.first_time = 1;
fip->dirbuf1.bytes_in_buf = 0;
if ((xinode = g_xrdp_fs.inode_table[i]) == NULL)
continue;
fip->invoke_fuse = 1;
fip->device_id = device_id;
/* match parent inode */
if (xinode->parent_inode != ino)
continue;
log_debug("fip->req=%p", fip->req);
xinode->is_synced = 1;
/* we want path minus 'root node of the share' */
if ((cptr = strchr(full_path, '/')) == NULL)
{
/* enumerate root dir */
if (dev_redir_get_dir_listing((void *) fip, device_id, "\\"))
if (first_time)
{
log_error("failed to send dev_redir_get_dir_listing() cmd");
fuse_reply_buf(req, NULL, 0);
first_time = 0;
ti = g_xrdp_fs.inode_table[ino];
xfuse_dirbuf_add1(req, &b, ".", ino);
xfuse_dirbuf_add1(req, &b, "..", ti->parent_inode);
}
if (xfuse_dirbuf_add1(req, &b, xinode->name, xinode->inode))
break; /* buffer is full */
}
if (b.bytes_in_buf)
fuse_reply_buf(req, b.buf, b.bytes_in_buf);
else
{
if (dev_redir_get_dir_listing((void *) fip, device_id, cptr))
{
log_error("failed to send dev_redir_get_dir_listing() cmd");
fuse_reply_buf(req, NULL, 0);
}
}
fuse_reply_buf(req, NULL, 0);
}
/**
@ -2681,7 +2569,7 @@ static void xfuse_cb_release(fuse_req_t req, fuse_ino_t ino, struct
FileId = handle->FileId;
free(handle);
fip->fi->fh = NULL;
fip->fi->fh = 0;
xinode->close_in_progress = 1;
if (devredir_file_close((void *) fip, fip->device_id, handle->FileId))
@ -2925,4 +2813,185 @@ static void xfuse_cb_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr,
fuse_reply_attr(req, &st, 1.0); /* LK_TODO just faking for now */
}
static void xfuse_cb_opendir(fuse_req_t req, fuse_ino_t ino,
struct fuse_file_info *fi)
{
struct dir_info *di;
XRDP_INODE *xinode;
XFUSE_INFO *fip;
tui32 device_id;
char full_path[4096];
char *cptr;
log_debug("inode=%d name=%s", ino, g_xrdp_fs.inode_table[ino]->name);
if (!xfuse_is_inode_valid(ino))
{
log_error("inode %d is not valid", ino);
fuse_reply_err(req, EBADF);
return;
}
if (ino == 1)
goto done; /* special case; enumerate top level dir */
xinode = g_xrdp_fs.inode_table[ino];
if (xinode->is_loc_resource)
goto done;
/* enumerate resources on a remote device */
#ifdef USE_SYNC_FLAG
if (xinode->is_synced)
{
xfuse_enum_dir(req, ino, size, off, fi);
return;
}
else
{
goto do_remote_lookup;
}
#endif
do_remote_lookup:
xfuse_mark_as_stale((int) ino);
log_debug("did not find entry; redirecting call to dev_redir");
device_id = xfuse_get_device_id_for_inode((tui32) ino, full_path);
log_debug("dev_id=%d ino=%d full_path=%s", device_id, ino, full_path);
if ((fip = calloc(1, sizeof(XFUSE_INFO))) == NULL)
{
log_error("system out of memory");
fuse_reply_err(req, ENOMEM);
return;
}
fip->req = req;
fip->inode = ino;
fip->size = 0;
fip->off = 0;
fip->fi = fi;
fip->dirbuf1.first_time = 1;
fip->dirbuf1.bytes_in_buf = 0;
fip->invoke_fuse = 1;
fip->device_id = device_id;
/* we want path minus 'root node of the share' */
if ((cptr = strchr(full_path, '/')) == NULL)
{
/* enumerate root dir */
if (dev_redir_get_dir_listing((void *) fip, device_id, "\\"))
{
log_error("failed to send dev_redir_get_dir_listing() cmd");
fuse_reply_buf(req, NULL, 0);
}
}
else
{
if (dev_redir_get_dir_listing((void *) fip, device_id, cptr))
{
log_error("failed to send dev_redir_get_dir_listing() cmd");
fuse_reply_buf(req, NULL, 0);
}
}
return;
done:
di = calloc(1, sizeof(struct dir_info));
di->index = FIRST_INODE;
fi->fh = (long) di;
fuse_reply_open(req, fi);
}
/**
*****************************************************************************/
static void xfuse_cb_releasedir(fuse_req_t req, fuse_ino_t ino,
struct fuse_file_info *fi)
{
struct dir_info *di;
di = (struct dir_info *) (tintptr) fi->fh;
if (di)
free(di);
fuse_reply_err(req, 0);
}
/******************************************************************************
* miscellaneous functions
*****************************************************************************/
/**
* Mark all files with matching parent inode as stale
*
* @param pinode the parent inode
*****************************************************************************/
static void
xfuse_mark_as_stale(int pinode)
{
int i;
XRDP_INODE *xinode;
if ((pinode < FIRST_INODE) || (pinode >= g_xrdp_fs.num_entries))
return;
for (i = FIRST_INODE; i < g_xrdp_fs.num_entries; i++)
{
if ((xinode = g_xrdp_fs.inode_table[i]) == NULL)
continue;
/* match parent inode */
if (xinode->parent_inode != pinode)
continue;
/* got a match */
xinode->stale = 1;
}
}
/**
* Delete all files with matching parent inode that are marked as stale
*
* @param pinode the parent inode
*****************************************************************************/
static void
xfuse_delete_stale_entries(int pinode)
{
int i;
XRDP_INODE *xinode;
if ((pinode < FIRST_INODE) || (pinode >= g_xrdp_fs.num_entries))
return;
for (i = FIRST_INODE; i < g_xrdp_fs.num_entries; i++)
{
if ((xinode = g_xrdp_fs.inode_table[i]) == NULL)
continue;
/* match parent inode */
if (xinode->parent_inode != pinode)
continue;
/* got a match, but is it stale? */
if (!xinode->stale)
continue;
/* ok to delete */
if (xinode->mode & S_IFREG)
xfuse_delete_file_with_xinode(xinode);
else
xfuse_recursive_delete_dir_with_xinode(xinode);
}
}
#endif /* end else #ifndef XRDP_FUSE */

@ -41,6 +41,7 @@ struct xrdp_inode
int lindex; /* used in clipboard operations */
int is_loc_resource; /* this is not a redirected resource */
int close_in_progress; /* close cmd sent to client */
int stale; /* mark file as stale, ok to remove */
};
typedef struct xrdp_inode XRDP_INODE; // LK_TODO use this instead of using struct xrdp_inode

File diff suppressed because it is too large Load Diff

@ -1,8 +1,8 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Jay Sorg 2009-2012
* Copyright (C) Laxmikant Rashinkar 2012
* Copyright (C) Jay Sorg 2009-2013
* Copyright (C) Laxmikant Rashinkar 2012-2013
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,14 +23,9 @@
#include "arch.h"
#include "parse.h"
int APP_CC
clipboard_init(void);
int APP_CC
clipboard_deinit(void);
int APP_CC
clipboard_data_in(struct stream* s, int chan_id, int chan_flags, int length,
int total_length);
int APP_CC
clipboard_xevent(void* xevent);
int APP_CC clipboard_init(void);
int APP_CC clipboard_deinit(void);
int APP_CC clipboard_data_in(struct stream *s, int chan_id, int chan_flags, int length, int total_length);
int APP_CC clipboard_xevent(void *xevent);
#endif

@ -1,7 +1,7 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Jay Sorg 2012
* Copyright (C) Jay Sorg 2012-2013
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -127,9 +127,7 @@ struct clip_file_desc /* CLIPRDR_FILEDESCRIPTOR */
char cFileName[256];
};
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);
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

@ -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);

@ -120,13 +120,15 @@ dev_redir_init(void)
/* get a random number that will act as a unique clientID */
if ((fd = open("/dev/urandom", O_RDONLY)))
{
read(fd, u.buf, 4);
if (read(fd, u.buf, 4) != 4)
{
}
close(fd);
}
else
{
/* /dev/urandom did not work - use address of struct s */
tui64 u64 = (tui64) &s;
tui64 u64 = (tui64) (tintptr) &s;
u.clientID = (tui32) u64;
}
@ -152,6 +154,7 @@ dev_redir_init(void)
int APP_CC
dev_redir_deinit(void)
{
scard_deinit();
return 0;
}
@ -282,6 +285,10 @@ done:
int APP_CC
dev_redir_get_wait_objs(tbus *objs, int *count, int *timeout)
{
if (g_is_smartcard_redir_supported)
{
return scard_get_wait_objs(objs, count, timeout);
}
return 0;
}
@ -289,6 +296,10 @@ dev_redir_get_wait_objs(tbus *objs, int *count, int *timeout)
int APP_CC
dev_redir_check_wait_objs(void)
{
if (g_is_smartcard_redir_supported)
{
return scard_check_wait_objs();
}
return 0;
}
@ -515,7 +526,9 @@ void dev_redir_send_drive_dir_request(IRP *irp, tui32 device_id,
if (InitialQuery)
{
if (Path == NULL)
{
return;
}
/* Path in unicode needs this much space */
path_len = ((g_mbstowcs(NULL, Path, 0) * sizeof(twchar)) / 2) + 2;
@ -617,6 +630,7 @@ void dev_redir_proc_client_core_cap_resp(struct stream *s)
case CAP_SMARTCARD_TYPE:
log_debug("got CAP_SMARTCARD_TYPE");
g_is_smartcard_redir_supported = 1;
scard_init();
xstream_seek(s, cap_len);
break;
}
@ -704,7 +718,8 @@ void devredir_proc_client_devlist_announce_req(struct stream *s)
}
}
void dev_redir_proc_device_iocompletion(struct stream *s)
void APP_CC
dev_redir_proc_device_iocompletion(struct stream *s)
{
FUSE_DATA *fuse_data = NULL;
IRP *irp = NULL;
@ -859,11 +874,12 @@ done:
log_debug("exiting");
}
void dev_redir_proc_query_dir_response(IRP *irp,
struct stream *s_in,
tui32 DeviceId,
tui32 CompletionId,
tui32 IoStatus)
void APP_CC
dev_redir_proc_query_dir_response(IRP *irp,
struct stream *s_in,
tui32 DeviceId,
tui32 CompletionId,
tui32 IoStatus)
{
FUSE_DATA *fuse_data = NULL;
XRDP_INODE *xinode = NULL;
@ -984,11 +1000,12 @@ void dev_redir_proc_query_dir_response(IRP *irp,
* @return 0 on success, -1 on failure
*****************************************************************************/
int dev_redir_get_dir_listing(void *fusep, tui32 device_id, char *path)
int APP_CC
dev_redir_get_dir_listing(void *fusep, tui32 device_id, char *path)
{
tui32 DesiredAccess;
tui32 CreateOptions;
tui32 CreateDisposition;
tui32 CreateDisposition;
int rval;
IRP *irp;
@ -1028,8 +1045,9 @@ int dev_redir_get_dir_listing(void *fusep, tui32 device_id, char *path)
return rval;
}
int dev_redir_file_open(void *fusep, tui32 device_id, char *path,
int mode, int type, char *gen_buf)
int APP_CC
dev_redir_file_open(void *fusep, tui32 device_id, char *path,
int mode, int type, char *gen_buf)
{
tui32 DesiredAccess;
tui32 CreateOptions;
@ -1140,7 +1158,8 @@ int devredir_file_close(void *fusep, tui32 device_id, tui32 FileId)
* Remove (delete) a directory or file
*****************************************************************************/
int devredir_rmdir_or_file(void *fusep, tui32 device_id, char *path, int mode)
int APP_CC
devredir_rmdir_or_file(void *fusep, tui32 device_id, char *path, int mode)
{
tui32 DesiredAccess;
tui32 CreateOptions;
@ -1181,8 +1200,9 @@ int devredir_rmdir_or_file(void *fusep, tui32 device_id, char *path, int mode)
* @return 0 on success, -1 on failure
*****************************************************************************/
int devredir_file_read(void *fusep, tui32 DeviceId, tui32 FileId,
tui32 Length, tui64 Offset)
int APP_CC
devredir_file_read(void *fusep, tui32 DeviceId, tui32 FileId,
tui32 Length, tui64 Offset)
{
struct stream *s;
IRP *irp;
@ -1229,8 +1249,9 @@ int devredir_file_read(void *fusep, tui32 DeviceId, tui32 FileId,
return 0;
}
int dev_redir_file_write(void *fusep, tui32 DeviceId, tui32 FileId,
const char *buf, tui32 Length, tui64 Offset)
int APP_CC
dev_redir_file_write(void *fusep, tui32 DeviceId, tui32 FileId,
const char *buf, tui32 Length, tui64 Offset)
{
struct stream *s;
IRP *irp;
@ -1293,7 +1314,8 @@ int dev_redir_file_write(void *fusep, tui32 DeviceId, tui32 FileId,
* @return FUSE_DATA on success, or NULL on failure
*****************************************************************************/
void *devredir_fuse_data_peek(IRP *irp)
void * APP_CC
devredir_fuse_data_peek(IRP *irp)
{
log_debug("returning %p", irp->fd_head);
return irp->fd_head;
@ -1305,7 +1327,8 @@ void *devredir_fuse_data_peek(IRP *irp)
* @return FUSE_DATA on success, NULL on failure
*****************************************************************************/
void *devredir_fuse_data_dequeue(IRP *irp)
void * APP_CC
devredir_fuse_data_dequeue(IRP *irp)
{
FUSE_DATA *head;
@ -1340,7 +1363,8 @@ void *devredir_fuse_data_dequeue(IRP *irp)
* @return 0 on success, -1 on failure
*****************************************************************************/
int devredir_fuse_data_enqueue(IRP *irp, void *vp)
int APP_CC
devredir_fuse_data_enqueue(IRP *irp, void *vp)
{
FUSE_DATA *fd;
FUSE_DATA *tail;
@ -1377,12 +1401,13 @@ int devredir_fuse_data_enqueue(IRP *irp, void *vp)
** miscellaneous stuff **
******************************************************************************/
void devredir_insert_DeviceIoRequest(struct stream *s,
tui32 DeviceId,
tui32 FileId,
tui32 CompletionId,
tui32 MajorFunction,
tui32 MinorFunction)
void APP_CC
devredir_insert_DeviceIoRequest(struct stream *s,
tui32 DeviceId,
tui32 FileId,
tui32 CompletionId,
tui32 MajorFunction,
tui32 MinorFunction)
{
/* setup DR_DEVICE_IOREQUEST header */
xstream_wr_u16_le(s, RDPDR_CTYP_CORE);
@ -1398,7 +1423,8 @@ void devredir_insert_DeviceIoRequest(struct stream *s,
* Convert / to windows compatible \
*****************************************************************************/
void devredir_cvt_slash(char *path)
void APP_CC
devredir_cvt_slash(char *path)
{
char *cptr = path;
@ -1410,7 +1436,8 @@ void devredir_cvt_slash(char *path)
}
}
void devredir_cvt_to_unicode(char *unicode, char *path)
void APP_CC
devredir_cvt_to_unicode(char *unicode, char *path)
{
char *dest;
char *src;
@ -1435,7 +1462,8 @@ void devredir_cvt_to_unicode(char *unicode, char *path)
*dest++ = 0;
}
void devredir_cvt_from_unicode_len(char *path, char *unicode, int len)
void APP_CC
devredir_cvt_from_unicode_len(char *path, char *unicode, int len)
{
char *dest;
char *dest_saved;
@ -1472,7 +1500,8 @@ void devredir_cvt_from_unicode_len(char *path, char *unicode, int len)
g_free(dest_saved);
}
int dev_redir_string_ends_with(char *string, char c)
int APP_CC
dev_redir_string_ends_with(char *string, char c)
{
int len;
@ -1480,14 +1509,16 @@ int dev_redir_string_ends_with(char *string, char c)
return (string[len - 1] == c) ? 1 : 0;
}
void devredir_insert_RDPDR_header(struct stream *s, tui16 Component,
tui16 PacketId)
void APP_CC
devredir_insert_RDPDR_header(struct stream *s, tui16 Component,
tui16 PacketId)
{
xstream_wr_u16_le(s, Component);
xstream_wr_u16_le(s, PacketId);
}
void devredir_proc_cid_rmdir_or_file(IRP *irp, tui32 IoStatus)
void APP_CC
devredir_proc_cid_rmdir_or_file(IRP *irp, tui32 IoStatus)
{
struct stream *s;
int bytes;
@ -1523,7 +1554,8 @@ void devredir_proc_cid_rmdir_or_file(IRP *irp, tui32 IoStatus)
return;
}
void devredir_proc_cid_rmdir_or_file_resp(IRP *irp, tui32 IoStatus)
void APP_CC
devredir_proc_cid_rmdir_or_file_resp(IRP *irp, tui32 IoStatus)
{
FUSE_DATA *fuse_data;
@ -1549,7 +1581,8 @@ void devredir_proc_cid_rmdir_or_file_resp(IRP *irp, tui32 IoStatus)
IRP_MJ_CLOSE, 0, 32);
}
void devredir_proc_cid_rename_file(IRP *irp, tui32 IoStatus)
void APP_CC
devredir_proc_cid_rename_file(IRP *irp, tui32 IoStatus)
{
struct stream *s;
int bytes;
@ -1601,7 +1634,8 @@ void devredir_proc_cid_rename_file(IRP *irp, tui32 IoStatus)
return;
}
void devredir_proc_cid_rename_file_resp(IRP *irp, tui32 IoStatus)
void APP_CC
devredir_proc_cid_rename_file_resp(IRP *irp, tui32 IoStatus)
{
FUSE_DATA *fuse_data;

@ -22,12 +22,9 @@ int g_drdynvc_chan_id;
int g_drdynvc_inited = 0;
static int APP_CC drdynvc_send_capability_request(uint16_t version);
static int APP_CC drdynvc_process_capability_response(struct stream* s,
unsigned char cmd);
static int APP_CC drdynvc_process_open_channel_response(struct stream *s,
unsigned char cmd);
static int APP_CC drdynvc_process_close_channel_response(struct stream *s,
unsigned char cmd);
static int APP_CC drdynvc_process_capability_response(struct stream* s, unsigned char cmd);
static int APP_CC drdynvc_process_open_channel_response(struct stream *s, unsigned char cmd);
static int APP_CC drdynvc_process_close_channel_response(struct stream *s, unsigned char cmd);
static int APP_CC drdynvc_process_data_first(struct stream* s, unsigned char cmd);
static int APP_CC drdynvc_process_data(struct stream* s, unsigned char cmd);
static int APP_CC drdynvc_insert_uint_124(struct stream *s, uint32_t val);

@ -54,12 +54,12 @@ struct irp
tui32 CompletionId, tui32 IoStatus);
};
IRP * devredir_irp_new();
IRP * devredir_irp_clone(IRP *irp);
int devredir_irp_delete(IRP *irp);
IRP * devredir_irp_find(tui32 completion_id);
IRP * devredir_irp_find_by_fileid(tui32 FileId);
IRP * devredir_irp_get_last();
void devredir_irp_dump();
IRP * APP_CC devredir_irp_new(void);
IRP * APP_CC devredir_irp_clone(IRP *irp);
int APP_CC devredir_irp_delete(IRP *irp);
IRP * APP_CC devredir_irp_find(tui32 completion_id);
IRP * APP_CC devredir_irp_find_by_fileid(tui32 FileId);
IRP * APP_CC devredir_irp_get_last(void);
void APP_CC devredir_irp_dump(void);
#endif /* end ifndef __IRP_H */

@ -26,6 +26,7 @@
#include "log.h"
#include "irp.h"
#include "devredir.h"
#include "smartcard_pcsc.h"
/*
* TODO
@ -147,7 +148,8 @@ static void scard_release_resources(void);
** non static functions **
******************************************************************************/
void scard_device_announce(tui32 device_id)
void APP_CC
scard_device_announce(tui32 device_id)
{
IRP *irp;
@ -187,9 +189,10 @@ void scard_device_announce(tui32 device_id)
** callbacks into this module **
******************************************************************************/
void scard_handle_EstablishContext_Return(struct stream *s, IRP *irp,
tui32 DeviceId, tui32 CompletionId,
tui32 IoStatus)
void APP_CC
scard_handle_EstablishContext_Return(struct stream *s, IRP *irp,
tui32 DeviceId, tui32 CompletionId,
tui32 IoStatus)
{
tui32 len;
int tmp;
@ -243,9 +246,10 @@ void scard_handle_EstablishContext_Return(struct stream *s, IRP *irp,
log_debug("leaving");
}
void scard_handle_ListReaders_Return(struct stream *s, IRP *irp,
tui32 DeviceId, tui32 CompletionId,
tui32 IoStatus)
void APP_CC
scard_handle_ListReaders_Return(struct stream *s, IRP *irp,
tui32 DeviceId, tui32 CompletionId,
tui32 IoStatus)
{
tui32 len;
@ -283,7 +287,8 @@ void scard_handle_ListReaders_Return(struct stream *s, IRP *irp,
*
*****************************************************************************/
static void scard_send_EstablishContext(IRP *irp)
static void APP_CC
scard_send_EstablishContext(IRP *irp)
{
struct stream *s;
int bytes;
@ -311,7 +316,8 @@ static void scard_send_EstablishContext(IRP *irp)
*
*****************************************************************************/
static void scard_send_ListReaders(IRP *irp, int wide)
static void APP_CC
scard_send_ListReaders(IRP *irp, int wide)
{
/* see [MS-RDPESC] 2.2.2.4 */
@ -405,7 +411,8 @@ static void scard_send_ListReaders(IRP *irp, int wide)
* @return stream with IOCTL inserted in it, NULL on error
*****************************************************************************/
static struct stream *scard_make_new_ioctl(IRP *irp, tui32 ioctl)
static struct stream * APP_CC
scard_make_new_ioctl(IRP *irp, tui32 ioctl)
{
/*
* format of device control request
@ -462,7 +469,8 @@ static struct stream *scard_make_new_ioctl(IRP *irp, tui32 ioctl)
* @return index into smartcards[] on success, -1 on failure
*****************************************************************************/
static int scard_add_new_device(tui32 device_id)
static int APP_CC
scard_add_new_device(tui32 device_id)
{
int index;
SMARTCARD *sc;
@ -485,10 +493,12 @@ static int scard_add_new_device(tui32 device_id)
/**
* Find first unused entry in smartcards
*
* @return index of first unused entry in smartcards or -1 if smartcards is full
* @return index of first unused entry in smartcards or -1 if smartcards
* is full
*****************************************************************************/
static int scard_get_free_slot(void)
static int APP_CC
scard_get_free_slot(void)
{
int i;
@ -509,7 +519,8 @@ static int scard_get_free_slot(void)
* Release resources prior to shutting down
*****************************************************************************/
static void scard_release_resources(void)
static void APP_CC
scard_release_resources(void)
{
int i;
@ -526,3 +537,37 @@ static void scard_release_resources(void)
/**
*
*****************************************************************************/
int APP_CC
scard_get_wait_objs(tbus *objs, int *count, int *timeout)
{
return scard_pcsc_get_wait_objs(objs, count, timeout);
}
/**
*
*****************************************************************************/
int APP_CC
scard_check_wait_objs(void)
{
return scard_pcsc_check_wait_objs();
}
/**
*
*****************************************************************************/
int APP_CC
scard_init(void)
{
log_debug("init")
return scard_pcsc_init();
}
/**
*
*****************************************************************************/
int APP_CC
scard_deinit(void)
{
log_debug("deinit")
return scard_pcsc_deinit();
}

@ -39,4 +39,13 @@ void scard_handle_ListReaders_Return(struct stream *s, IRP *irp,
tui32 DeviceId, tui32 CompletionId,
tui32 IoStatus);
int APP_CC
scard_get_wait_objs(tbus *objs, int *count, int *timeout);
int APP_CC
scard_check_wait_objs(void);
int APP_CC
scard_init(void);
int APP_CC
scard_deinit(void);
#endif /* end #ifndef _SMARTCARD_C */

@ -0,0 +1,330 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Jay Sorg 2013 jay.sorg@gmail.com
*
* 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.
*
*/
/*
* smartcard redirection support, PCSC daemon standin
* this will act like pcsc daemon
*/
#define PCSC_STANDIN 1
#include "os_calls.h"
#include "smartcard.h"
#include "log.h"
#include "irp.h"
#include "devredir.h"
#include "trans.h"
#if PCSC_STANDIN
/* 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]: PCSC %s: %d : ERROR: ", \
g_time3(), __func__, __LINE__); \
g_writeln (_params); \
}
#define log_always(_params...) \
{ \
g_write("[%10.10u]: PCSC %s: %d : ALWAYS: ", \
g_time3(), __func__, __LINE__); \
g_writeln (_params); \
}
#define log_info(_params...) \
{ \
if (LOG_INFO <= LOG_LEVEL) \
{ \
g_write("[%10.10u]: PCSC %s: %d : ", \
g_time3(), __func__, __LINE__); \
g_writeln (_params); \
} \
}
#define log_debug(_params...) \
{ \
if (LOG_DEBUG <= LOG_LEVEL) \
{ \
g_write("[%10.10u]: PCSC %s: %d : ", \
g_time3(), __func__, __LINE__); \
g_writeln (_params); \
} \
}
#define PCSCLITE_MSG_KEY_LEN 16
#define PCSCLITE_MAX_MESSAGE_SIZE 2048
struct version_struct
{
tsi32 major; /**< IPC major \ref PROTOCOL_VERSION_MAJOR */
tsi32 minor; /**< IPC minor \ref PROTOCOL_VERSION_MINOR */
tui32 rv;
};
typedef struct version_struct version_struct;
struct rxSharedSegment
{
tui32 mtype; /** one of the \c pcsc_adm_commands */
tui32 user_id;
tui32 group_id;
tui32 command; /** one of the \c pcsc_msg_commands */
tui64 date;
tui8 key[PCSCLITE_MSG_KEY_LEN]; /* 16 bytes */
union _u
{
tui8 data[PCSCLITE_MAX_MESSAGE_SIZE];
struct version_struct veStr;
} u;
};
typedef struct rxSharedSegment sharedSegmentMsg, *psharedSegmentMsg;
#define RXSHAREDSEGMENT_BYTES 2088
extern int g_display_num; /* in chansrv.c */
/*****************************************************************************/
struct pcsc_client
{
struct trans *con;
};
static struct pcsc_client *g_head = 0;
static struct pcsc_client *g_tail = 0;
static struct trans *g_lis = 0;
static struct trans *g_con = 0; /* todo, remove this */
static char g_pcsc_directory[256] = "";
/*****************************************************************************/
int APP_CC
scard_pcsc_get_wait_objs(tbus *objs, int *count, int *timeout)
{
log_debug("scard_pcsc_get_wait_objs");
if (g_lis != 0)
{
trans_get_wait_objs(g_lis, objs, count);
}
if (g_con != 0)
{
trans_get_wait_objs(g_con, objs, count);
}
return 0;
}
/*****************************************************************************/
int APP_CC
scard_pcsc_check_wait_objs(void)
{
log_debug("scard_pcsc_check_wait_objs");
if (g_lis != 0)
{
trans_check_wait_objs(g_lis);
}
if (g_con != 0)
{
trans_check_wait_objs(g_con);
}
return 0;
}
/*****************************************************************************/
/* returns error */
int APP_CC
scard_process_version(psharedSegmentMsg msg)
{
return 0;
}
/*****************************************************************************/
/* returns error */
int APP_CC
scard_process_msg(struct stream *s)
{
sharedSegmentMsg msg;
int rv;
g_memset(&msg, 0, sizeof(msg));
in_uint32_le(s, msg.mtype);
in_uint32_le(s, msg.user_id);
in_uint32_le(s, msg.group_id);
in_uint32_le(s, msg.command);
in_uint64_le(s, msg.date);
log_debug("scard_process_msg: mtype 0x%2.2x command 0x%2.2x",
msg.mtype, msg.command);
rv = 0;
switch (msg.mtype)
{
case 0xF8: /* CMD_VERSION */
rv = scard_process_version(&msg);
break;
}
return rv;
}
/*****************************************************************************/
/* returns error */
int DEFAULT_CC
my_pcsc_trans_data_in(struct trans *trans)
{
struct stream *s;
int id;
int size;
int error;
log_debug("my_pcsc_trans_data_in:");
if (trans == 0)
{
return 0;
}
if (trans != g_con)
{
return 1;
}
s = trans_get_in_s(trans);
g_hexdump(s->p, 64);
error = scard_process_msg(s);
return error;
}
/*****************************************************************************/
/* got a new connection from libpcsclite */
int DEFAULT_CC
my_pcsc_trans_conn_in(struct trans *trans, struct trans *new_trans)
{
log_debug("my_pcsc_trans_conn_in:");
if (trans == 0)
{
return 1;
}
if (trans != g_lis)
{
return 1;
}
if (new_trans == 0)
{
return 1;
}
g_con = new_trans;
g_con->trans_data_in = my_pcsc_trans_data_in;
g_con->header_size = RXSHAREDSEGMENT_BYTES;
log_debug("my_pcsc_trans_conn_in: sizeof sharedSegmentMsg is %d",
sizeof(sharedSegmentMsg));
return 0;
}
/*****************************************************************************/
int APP_CC
scard_pcsc_init(void)
{
char port[256];
int error;
log_debug("scard_pcsc_init:");
if (g_lis == 0)
{
g_lis = trans_create(2, 8192, 8192);
g_snprintf(g_pcsc_directory, 255, "/tmp/.xrdp/pcsc%d", g_display_num);
if (g_directory_exist(g_pcsc_directory))
{
if (g_remove_dir(g_pcsc_directory) != 0)
{
log_error("scard_pcsc_init: g_remove_dir failed");
}
}
if (g_create_dir(g_pcsc_directory) != 0)
{
log_error("scard_pcsc_init: g_create_dir failed");
}
g_chmod_hex(g_pcsc_directory, 0x1777);
g_snprintf(port, 255, "%s/pcscd.comm", g_pcsc_directory);
g_lis->trans_conn_in = my_pcsc_trans_conn_in;
error = trans_listen(g_lis, port);
if (error != 0)
{
log_error("scard_pcsc_init: trans_listen failed for port %s",
port);
return 1;
}
}
return 0;
}
/*****************************************************************************/
int APP_CC
scard_pcsc_deinit(void)
{
log_debug("scard_pcsc_deinit:");
if (g_lis != 0)
{
trans_delete(g_lis);
g_lis = 0;
if (g_remove_dir(g_pcsc_directory) != 0)
{
log_error("scard_pcsc_deinit: g_remove_dir failed");
}
g_pcsc_directory[0] = 0;
}
return 0;
}
#else
int APP_CC
scard_pcsc_get_wait_objs(tbus *objs, int *count, int *timeout)
{
return 0;
}
int APP_CC
scard_pcsc_check_wait_objs(void)
{
return 0;
}
int APP_CC
scard_pcsc_init(void)
{
return 0;
}
int APP_CC
scard_pcsc_deinit(void)
{
return 0;
}
#endif

@ -0,0 +1,36 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Jay Sorg 2013 jay.sorg@gmail.com
*
* 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.
*
*/
/*
* smartcard redirection support, PCSC daemon standin
*/
#ifndef _SMARTCARD_PCSC_H
#define _SMARTCARD_PCSC_H
int APP_CC
scard_pcsc_get_wait_objs(tbus *objs, int *count, int *timeout);
int APP_CC
scard_pcsc_check_wait_objs(void);
int APP_CC
scard_pcsc_init(void);
int APP_CC
scard_pcsc_deinit(void);
#endif /* end #ifndef _SMARTCARD_PCSC_H */

@ -105,6 +105,7 @@ env_set_user(char *username, char *passwd_file, int display)
g_sprintf(text, ":%d.0", display);
g_setenv("DISPLAY", text, 1);
g_setenv("LANG", "en_US.UTF-8", 1);
g_setenv("XRDP_SESSION", "1", 1);
if (passwd_file != 0)
{

@ -33,113 +33,14 @@ download_file()
return 0
fi
echo "downloading file $file"
echo "downloading file $download_url/$file"
cd downloads
if [ "$file" = "libpthread-stubs-0.3.tar.bz2" ]; then
wget -cq http://xcb.freedesktop.org/dist/$file
status=$?
cd ..
return $status
elif [ "$file" = "libxcb-1.7.tar.bz2" ]; then
wget -cq http://xcb.freedesktop.org/dist/$file
status=$?
cd ..
return $status
elif [ "$file" = "xcb-proto-1.6.tar.bz2" ]; then
wget -cq http://xcb.freedesktop.org/dist/$file
status=$?
cd ..
return $status
# note pixman updated
elif [ "$file" = "pixman-0.30.0.tar.bz2" ]; then
wget -cq http://xorg.freedesktop.org/archive/individual/lib/$file
status=$?
cd ..
return $status
elif [ "$file" = "libdrm-2.4.26.tar.bz2" ]; then
wget -cq http://dri.freedesktop.org/libdrm/$file
status=$?
cd ..
return $status
elif [ "$file" = "MesaLib-7.10.3.tar.bz2" ]; then
wget -cq ftp://ftp.freedesktop.org/pub/mesa/7.10.3/$file
status=$?
cd ..
return $status
elif [ "$file" = "expat-2.0.1.tar.gz" ]; then
wget -cq http://server1.xrdp.org/xrdp/expat-2.0.1.tar.gz
status=$?
cd ..
return $status
elif [ "$file" = "freetype-2.4.6.tar.bz2" ]; then
wget -cq http://download.savannah.gnu.org/releases/freetype/freetype-2.4.6.tar.bz2
status=$?
cd ..
return $status
elif [ "$file" = "xkeyboard-config-2.0.tar.bz2" ]; then
wget -cq http://www.x.org/releases/individual/data/xkeyboard-config/xkeyboard-config-2.0.tar.bz2
status=$?
cd ..
return $status
elif [ "$file" = "makedepend-1.0.3.tar.bz2" ]; then
wget -cq http://xorg.freedesktop.org/releases/individual/util/makedepend-1.0.3.tar.bz2
status=$?
cd ..
return $status
elif [ "$file" = "libxml2-sources-2.7.8.tar.gz" ]; then
wget -cq ftp://ftp.xmlsoft.org/libxml2/libxml2-sources-2.7.8.tar.gz
status=$?
cd ..
return $status
elif [ "$file" = "Python-2.5.tar.bz2" ]; then
wget -cq http://www.python.org/ftp/python/2.5/Python-2.5.tar.bz2
status=$?
cd ..
return $status
elif [ "$file" = "Python-2.7.tar.bz2" ]; then
wget -cq http://www.python.org/ftp/python/2.7/Python-2.7.tar.bz2
status=$?
cd ..
return $status
elif [ "$file" = "expat-2.0.1.tar.gz" ]; then
wget -cq http://server1.xrdp.org/xrdp/expat-2.0.1.tar.gz
status=$?
cd ..
return $status
elif [ "$file" = "cairo-1.8.8.tar.gz" ]; then
wget -cq http://server1.xrdp.org/xrdp/cairo-1.8.8.tar.gz
status=$?
cd ..
return $status
elif [ "$file" = "libpng-1.2.46.tar.gz" ]; then
wget -cq http://server1.xrdp.org/xrdp/libpng-1.2.46.tar.gz
status=$?
cd ..
return $status
elif [ "$file" = "intltool-0.41.1.tar.gz" ]; then
wget -cq http://launchpad.net/intltool/trunk/0.41.1/+download/intltool-0.41.1.tar.gz
status=$?
cd ..
return $status
elif [ "$file" = "libxslt-1.1.26.tar.gz" ]; then
wget -cq ftp://xmlsoft.org/libxslt/libxslt-1.1.26.tar.gz
status=$?
cd ..
return $status
elif [ "$file" = "fontconfig-2.8.0.tar.gz" ]; then
wget -cq http://server1.xrdp.org/xrdp/fontconfig-2.8.0.tar.gz
status=$?
cd ..
return $status
else
wget -cq $download_url/$file
status=$?
cd ..
return $status
fi
wget -cq $download_url/$file
status=$?
cd ..
return $status
}
remove_modules()
@ -285,7 +186,9 @@ make_it()
data_file=x11_file_list.txt
# this is the default download location for most modules
download_url=http://www.x.org/releases/X11R7.6/src/everything
# changed now to server1.xrdp.org
# was www.x.org/releases/X11R7.6/src/everything
download_url=http://server1.xrdp.org/xrdp/X11R7.6
num_modules=`cat $data_file | wc -l`
count=0

@ -258,7 +258,7 @@ struct _rdpPixmapRec
int rdpindex;
int con_number;
int is_dirty;
int pad0;
int is_scratch;
int kind_width;
struct rdp_draw_item* draw_item_head;
struct rdp_draw_item* draw_item_tail;
@ -341,7 +341,7 @@ int
draw_item_pack(PixmapPtr pix, rdpPixmapRec* priv);
int
draw_item_add_img_region(rdpPixmapRec* priv, RegionPtr reg, int opcode,
int type);
int type, int code);
int
draw_item_add_fill_region(rdpPixmapRec* priv, RegionPtr reg, int color,
int opcode);

@ -375,7 +375,7 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
WindowPtr pDstWnd;
WindowPtr pSrcWnd;
LLOGLN(10, ("rdpCopyArea:"));
LLOGLN(10, ("rdpCopyArea: x %d y %d w %d h %d", dstx, dsty, w, h));
if (pSrc->type == DRAWABLE_WINDOW)
{
@ -416,6 +416,10 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
srcx, srcy, w, h, dstx, dsty);
}
}
else
{
LLOGLN(10, ("rdpCopyArea: 1"));
}
}
}
}
@ -456,8 +460,16 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
dstx, dsty);
}
}
else
{
LLOGLN(10, ("rdpCopyArea: 4"));
}
}
}
else
{
LLOGLN(10, ("rdpCopyArea: 2"));
}
}
/* do original call */
@ -493,6 +505,10 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
got_id = 1;
}
}
else
{
LLOGLN(10, ("rdpCopyArea: 3"));
}
}
else
{
@ -506,7 +522,7 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
if (g_do_dirty_ons)
{
LLOGLN(0, ("rdpCopyArea: gettig dirty"));
LLOGLN(10, ("rdpCopyArea: gettig dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
@ -537,7 +553,7 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, 1);
RegionUninit(&reg1);
}
else if (got_id)
@ -561,7 +577,7 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
box.y2 = box.y1 + h;
RegionInit(&box_reg, &box, 0);
RegionIntersect(&clip_reg, &clip_reg, &box_reg);
draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, 1);
RegionUninit(&box_reg);
}
else if (got_id)

@ -168,7 +168,7 @@ rdpCopyPlane(DrawablePtr pSrc, DrawablePtr pDst,
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, 5);
RegionUninit(&reg1);
}
else if (got_id)
@ -194,7 +194,7 @@ rdpCopyPlane(DrawablePtr pSrc, DrawablePtr pDst,
RegionInit(&reg2, NullBox, 0);
RegionCopy(&reg2, &clip_reg);
RegionIntersect(&reg1, &reg1, &reg2);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, 5);
RegionUninit(&reg1);
RegionUninit(&reg2);
}

@ -203,7 +203,7 @@ rdpFillPolygon(DrawablePtr pDrawable, GCPtr pGC,
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, 7);
RegionUninit(&reg1);
}
else if (got_id)
@ -223,7 +223,7 @@ rdpFillPolygon(DrawablePtr pDrawable, GCPtr pGC,
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, 7);
}
else if (got_id)
{

@ -169,7 +169,7 @@ rdpImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, 13);
RegionUninit(&reg1);
}
else if (got_id)
@ -189,7 +189,7 @@ rdpImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type, 13);
}
else if (got_id)
{

@ -132,7 +132,7 @@ rdpImageText16(DrawablePtr pDrawable, GCPtr pGC,
if (g_do_dirty_ons)
{
LLOGLN(0, ("rdpImageText16: gettig dirty"));
LLOGLN(10, ("rdpImageText16: gettig dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
@ -167,7 +167,7 @@ rdpImageText16(DrawablePtr pDrawable, GCPtr pGC,
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, 12);
RegionUninit(&reg1);
}
else if (got_id)
@ -187,7 +187,7 @@ rdpImageText16(DrawablePtr pDrawable, GCPtr pGC,
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type, 12);
}
else if (got_id)
{

@ -167,7 +167,7 @@ rdpImageText8(DrawablePtr pDrawable, GCPtr pGC,
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, 9);
RegionUninit(&reg1);
}
else if (got_id)
@ -187,7 +187,7 @@ rdpImageText8(DrawablePtr pDrawable, GCPtr pGC,
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type, 9);
}
else if (got_id)
{

@ -185,7 +185,7 @@ rdpPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs)
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, 6);
}
else if (got_id)
{
@ -217,7 +217,7 @@ rdpPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs)
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, 6);
}
else if (got_id)
{

@ -185,7 +185,7 @@ rdpPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs)
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, 8);
}
else if (got_id)
{
@ -217,7 +217,7 @@ rdpPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs)
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, 8);
}
else if (got_id)
{

@ -98,8 +98,25 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
{
pDstPixmap = (PixmapPtr)pDrawable;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (pDstPixmap->devPrivate.ptr == g_rdpScreen.pfbMemory)
{
/* treat like root window */
post_process = 1;
if (xrdp_is_os(pDstPixmap, pDstPriv))
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpPolyFillRect: gettig dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
else if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
@ -131,7 +148,7 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
if (g_do_dirty_ons)
{
LLOGLN(0, ("rdpPolyFillRect: gettig dirty"));
LLOGLN(10, ("rdpPolyFillRect: gettig dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
@ -148,12 +165,14 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
if (!post_process)
{
RegionDestroy(fill_reg);
LLOGLN(10, ("rdpPolyFillRect: out, post_process not set"));
return;
}
RegionTranslate(fill_reg, pDrawable->x, pDrawable->y);
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, pDrawable, pGC);
LLOGLN(10, ("rdpPolyFillRect: cd %d", cd));
if (cd == 1) /* no clip */
{
@ -166,14 +185,14 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
pGC->alu == GXnoop ||
pGC->alu == GXand ||
pGC->alu == GXcopy /*||
pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */
pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */
{
draw_item_add_fill_region(pDirtyPriv, fill_reg, pGC->fgPixel,
pGC->alu);
}
else
{
draw_item_add_img_region(pDirtyPriv, fill_reg, GXcopy, RDI_IMGLL);
draw_item_add_img_region(pDirtyPriv, fill_reg, GXcopy, RDI_IMGLL, 2);
}
}
else if (got_id)
@ -187,7 +206,7 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
pGC->alu == GXnoop ||
pGC->alu == GXand ||
pGC->alu == GXcopy /*||
pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */
pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */
{
rdpup_set_fgcolor(pGC->fgPixel);
rdpup_set_opcode(pGC->alu);
@ -229,20 +248,24 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
pGC->alu == GXnoop ||
pGC->alu == GXand ||
pGC->alu == GXcopy /*||
pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */
pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */
{
LLOGLN(10, ("rdpPolyFillRect: 3"));
draw_item_add_fill_region(pDirtyPriv, &clip_reg, pGC->fgPixel,
pGC->alu);
}
else
{
draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, RDI_IMGLL);
LLOGLN(10, ("rdpPolyFillRect: 4"));
draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, RDI_IMGLL, 2);
}
}
else if (got_id)
{
rdpup_begin_update();
LLOGLN(10, ("2 %x", pGC->fgPixel));
if (pGC->fillStyle == 0 && /* solid fill */
(pGC->alu == GXclear ||
pGC->alu == GXset ||
@ -250,7 +273,7 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
pGC->alu == GXnoop ||
pGC->alu == GXand ||
pGC->alu == GXcopy /*||
pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */
pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */
{
rdpup_set_fgcolor(pGC->fgPixel);
rdpup_set_opcode(pGC->alu);

@ -169,7 +169,7 @@ rdpPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, 14);
RegionUninit(&reg1);
}
else if (got_id)
@ -189,7 +189,7 @@ rdpPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type, 14);
}
else if (got_id)
{

@ -144,7 +144,7 @@ rdpPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects,
if (g_do_dirty_ons)
{
LLOGLN(0, ("rdpPolyRectangle: gettig dirty"));
LLOGLN(10, ("rdpPolyRectangle: gettig dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
@ -221,7 +221,7 @@ rdpPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects,
}
else
{
draw_item_add_img_region(pDirtyPriv, fill_reg, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, fill_reg, GXcopy, dirty_type, 4);
}
RegionDestroy(fill_reg);
@ -275,7 +275,7 @@ rdpPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects,
}
else
{
draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, 4);
}
}
else if (got_id)

@ -141,7 +141,7 @@ rdpPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSegs)
if (g_do_dirty_ons)
{
LLOGLN(0, ("rdpPolySegment: gettig dirty"));
LLOGLN(10, ("rdpPolySegment: gettig dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;

@ -170,7 +170,7 @@ rdpPolyText16(DrawablePtr pDrawable, GCPtr pGC,
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, 11);
RegionUninit(&reg1);
}
else if (got_id)
@ -190,7 +190,7 @@ rdpPolyText16(DrawablePtr pDrawable, GCPtr pGC,
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type, 11);
}
else if (got_id)
{

@ -170,7 +170,7 @@ rdpPolyText8(DrawablePtr pDrawable, GCPtr pGC,
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, 10);
RegionUninit(&reg1);
}
else if (got_id)
@ -190,7 +190,7 @@ rdpPolyText8(DrawablePtr pDrawable, GCPtr pGC,
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type, 10);
}
else if (got_id)
{

@ -192,7 +192,7 @@ rdpPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode,
if (g_do_dirty_ons)
{
LLOGLN(0, ("rdpPolylines: gettig dirty"));
LLOGLN(10, ("rdpPolylines: gettig dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;

@ -160,7 +160,7 @@ rdpPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst,
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, 15);
RegionUninit(&reg1);
}
else if (got_id)
@ -185,7 +185,7 @@ rdpPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst,
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, 15);
RegionUninit(&reg1);
}
else if (got_id)

@ -83,6 +83,8 @@ rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y,
LLOGLN(10, ("rdpPutImage:"));
LLOGLN(10, ("rdpPutImage: drawable id 0x%x", (int)(pDst->id)));
LLOGLN(10, ("rdpPutImage: x %d y %d w %d h %d is_window %d", x, y, w, h,
pDst->type == DRAWABLE_WINDOW));
/* do original call */
rdpPutImageOrg(pDst, pGC, depth, x, y, w, h, leftPad, format, pBits);
@ -130,7 +132,7 @@ rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y,
if (g_do_dirty_ons)
{
LLOGLN(0, ("rdpPutImage: gettig dirty"));
LLOGLN(10, ("rdpPutImage: gettig dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
@ -161,7 +163,7 @@ rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y,
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, 3);
RegionUninit(&reg1);
}
else if (got_id)
@ -183,7 +185,7 @@ rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y,
RegionInit(&reg2, NullBox, 0);
RegionCopy(&reg2, &clip_reg);
RegionIntersect(&reg1, &reg1, &reg2);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, 3);
RegionUninit(&reg1);
RegionUninit(&reg2);
}

@ -583,13 +583,35 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv)
return 0;
}
static char g_strings[][32] =
{
"Composite", /* 0 */
"CopyArea", /* 1 */
"PolyFillRect", /* 2 */
"PutImage", /* 3 */
"PolyRectangle", /* 4 */
"CopyPlane", /* 5 */
"PolyArc", /* 6 */
"FillPolygon", /* 7 */
"PolyFillArc", /* 8 */
"ImageText8", /* 9 */
"PolyText8", /* 10 */
"PolyText16", /* 11 */
"ImageText16", /* 12 */
"ImageGlyphBlt", /* 13 */
"PolyGlyphBlt", /* 14 */
"PushPixels", /* 15 */
"Other"
};
/******************************************************************************/
int
draw_item_add_img_region(rdpPixmapRec *priv, RegionPtr reg, int opcode,
int type)
int type, int code)
{
struct rdp_draw_item *di;
LLOGLN(10, ("draw_item_add_img_region: %s", g_strings[code]));
di = (struct rdp_draw_item *)g_malloc(sizeof(struct rdp_draw_item), 1);
di->type = type;
di->reg = RegionCreate(NullBox, 0);
@ -606,6 +628,7 @@ draw_item_add_fill_region(rdpPixmapRec *priv, RegionPtr reg, int color,
{
struct rdp_draw_item *di;
LLOGLN(10, ("draw_item_add_fill_region:"));
di = (struct rdp_draw_item *)g_malloc(sizeof(struct rdp_draw_item), 1);
di->type = RDI_FILL;
di->u.fill.fg_color = color;
@ -691,6 +714,10 @@ rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
priv->kind_width = width;
pScreen->ModifyPixmapHeader(rv, org_width, 0, 0, 0, 0, 0);
pScreen->CreatePixmap = rdpCreatePixmap;
if (org_width == 0 && height == 0)
{
priv->is_scratch = 1;
}
return rv;
}
@ -741,7 +768,8 @@ xrdp_is_os(PixmapPtr pix, rdpPixmapPtr priv)
height = pix->drawable.height;
if ((pix->usage_hint == 0) &&
(pix->drawable.depth >= g_rdpScreen.depth) &&
(width > 1) && (height > 1) && (priv->kind_width > 0))
(width > 0) && (height > 0) && (priv->kind_width > 0) &&
(priv->is_scratch == 0))
{
LLOGLN(10, ("%d %d", priv->kind_width, pix->drawable.width));
priv->rdpindex = rdpup_add_os_bitmap(pix, priv);
@ -760,7 +788,7 @@ xrdp_is_os(PixmapPtr pix, rdpPixmapPtr priv)
{
draw_item_remove_all(priv);
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(priv, &reg1, GXcopy, RDI_IMGLL);
draw_item_add_img_region(priv, &reg1, GXcopy, RDI_IMGLL, 16);
RegionUninit(&reg1);
priv->is_dirty = 1;
priv->con_number = g_con_number;
@ -995,6 +1023,7 @@ void
rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
{
RegionRec reg;
RegionRec reg1;
RegionRec clip;
int dx;
int dy;
@ -1004,12 +1033,11 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
int num_reg_rects;
BoxRec box1;
BoxRec box2;
BoxPtr box3;
LLOGLN(10, ("in rdpCopyWindow"));
RegionInit(&reg, NullBox, 0);
RegionCopy(&reg, pOldRegion);
g_pScreen->CopyWindow = g_rdpScreen.CopyWindow;
g_pScreen->CopyWindow(pWin, ptOldOrg, pOldRegion);
RegionInit(&clip, NullBox, 0);
RegionCopy(&clip, &pWin->borderClip);
dx = pWin->drawable.x - ptOldOrg.x;
@ -1017,30 +1045,45 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
if (g_do_dirty_ons)
{
LLOGLN(0, ("rdpCopyWindow: gettig dirty TODO"));
//draw_item_add_srcblt_region
rdpup_check_dirty_screen(&g_screenPriv);
}
rdpup_begin_update();
num_clip_rects = REGION_NUM_RECTS(&clip);
num_reg_rects = REGION_NUM_RECTS(&reg);
LLOGLN(10, ("rdpCopyWindow: num_clip_rects %d num_reg_rects %d",
num_clip_rects, num_reg_rects));
/* when there is a huge list of screen copies, just send as bitmap
firefox dragging test does this */
if ((num_clip_rects > 16) && (num_reg_rects > 16))
{
box3 = RegionExtents(&reg);
rdpup_send_area(0, box3->x1, box3->y1,
box3->x2 - box3->x1,
box3->y2 - box3->y1);
}
else
{
rdpup_begin_update();
num_clip_rects = REGION_NUM_RECTS(&clip);
num_reg_rects = REGION_NUM_RECTS(&reg);
/* should maybe sort the rects instead of checking dy < 0 */
/* If we can depend on the rects going from top to bottom, left
to right we are ok */
to right we are ok */
if (dy < 0 || (dy == 0 && dx < 0))
{
for (j = 0; j < num_clip_rects; j++)
{
box1 = REGION_RECTS(&clip)[j];
rdpup_set_clip(box1.x1, box1.y1, box1.x2 - box1.x1, box1.y2 - box1.y1);
rdpup_set_clip(box1.x1, box1.y1,
box1.x2 - box1.x1,
box1.y2 - box1.y1);
for (i = 0; i < num_reg_rects; i++)
{
box2 = REGION_RECTS(&reg)[i];
rdpup_screen_blt(box2.x1 + dx, box2.y1 + dy, box2.x2 - box2.x1,
box2.y2 - box2.y1, box2.x1, box2.y1);
rdpup_screen_blt(box2.x1 + dx, box2.y1 + dy,
box2.x2 - box2.x1,
box2.y2 - box2.y1,
box2.x1, box2.y1);
}
}
}
@ -1049,23 +1092,29 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
for (j = num_clip_rects - 1; j >= 0; j--)
{
box1 = REGION_RECTS(&clip)[j];
rdpup_set_clip(box1.x1, box1.y1, box1.x2 - box1.x1, box1.y2 - box1.y1);
rdpup_set_clip(box1.x1, box1.y1,
box1.x2 - box1.x1,
box1.y2 - box1.y1);
for (i = num_reg_rects - 1; i >= 0; i--)
{
box2 = REGION_RECTS(&reg)[i];
rdpup_screen_blt(box2.x1 + dx, box2.y1 + dy, box2.x2 - box2.x1,
box2.y2 - box2.y1, box2.x1, box2.y1);
rdpup_screen_blt(box2.x1 + dx, box2.y1 + dy,
box2.x2 - box2.x1,
box2.y2 - box2.y1,
box2.x1, box2.y1);
}
}
}
rdpup_reset_clip();
rdpup_end_update();
}
rdpup_reset_clip();
rdpup_end_update();
RegionUninit(&reg);
RegionUninit(&clip);
g_pScreen->CopyWindow = g_rdpScreen.CopyWindow;
g_pScreen->CopyWindow(pWin, ptOldOrg, pOldRegion);
g_pScreen->CopyWindow = rdpCopyWindow;
}
@ -1104,7 +1153,7 @@ rdpClearToBackground(WindowPtr pWin, int x, int y, int w, int h,
if (g_do_dirty_ons)
{
draw_item_add_img_region(&g_screenPriv, &reg, GXcopy, RDI_IMGLL);
draw_item_add_img_region(&g_screenPriv, &reg, GXcopy, RDI_IMGLL, 16);
}
else
{
@ -1142,7 +1191,7 @@ rdpRestoreAreas(WindowPtr pWin, RegionPtr prgnExposed)
if (g_do_dirty_ons)
{
draw_item_add_img_region(&g_screenPriv, &reg, GXcopy, RDI_IMGLL);
draw_item_add_img_region(&g_screenPriv, &reg, GXcopy, RDI_IMGLL, 16);
}
else
{
@ -1304,7 +1353,7 @@ rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
if (g_do_dirty_ons)
{
LLOGLN(0, ("rdpComposite: gettig dirty"));
LLOGLN(10, ("rdpComposite: gettig dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
@ -1337,7 +1386,7 @@ rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, 0);
}
else if (got_id)
{
@ -1370,7 +1419,7 @@ rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, 0);
RegionUninit(&reg1);
}
else if (got_id)

@ -46,10 +46,12 @@ DeviceIntPtr g_keyboard = 0;
int g_can_do_pix_to_pix = 0;
int g_do_dirty_os = 1; /* delay remoting off screen bitmaps */
int g_do_dirty_ons = 0; /* delay remoting screen */
int g_do_dirty_ons = 1; /* delay remoting screen */
Bool g_wrapWindow = 1;
Bool g_wrapPixmap = 1;
int g_codec_mode = 0; /* 0 = standard rdp, 1 = rfx */
rdpPixmapRec g_screenPriv;
/* if true, running in RemoteApp / RAIL mode */
@ -237,7 +239,7 @@ rdpScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
memset(&g_screenPriv, 0, sizeof(g_screenPriv));
/*dpix = 75;
dpiy = 75;*/
dpiy = 75; */
dpix = PixelDPI;
dpiy = PixelDPI;

@ -970,7 +970,7 @@ rdpup_check(void)
int
rdpup_begin_update(void)
{
LLOGLN(10, ("rdpup_begin_update"));
LLOGLN(10, ("rdpup_begin_update:"));
if (g_connected)
{
@ -978,7 +978,6 @@ rdpup_begin_update(void)
{
return 0;
}
init_stream(g_out_s, 0);
s_push_layer(g_out_s, iso_hdr, 8);
out_uint16_le(g_out_s, 1); /* begin update */
@ -1001,6 +1000,7 @@ rdpup_end_update(void)
{
if (g_do_dirty_ons)
{
/* in this mode, end update is only called in check dirty */
rdpup_send_pending();
}
else
@ -1059,7 +1059,8 @@ rdpup_screen_blt(short x, short y, int cx, int cy, short srcx, short srcy)
{
if (g_connected)
{
LLOGLN(10, (" rdpup_screen_blt"));
LLOGLN(10, (" rdpup_screen_blt x %d y %d cx %d cy %d srcx %d srcy %d",
x, y, cx, cy, srcx, srcy));
rdpup_pre_check(16);
out_uint16_le(g_out_s, 4); /* screen blt */
out_uint16_le(g_out_s, 16); /* size */
@ -1868,7 +1869,7 @@ rdpup_check_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec *pDirtyPriv)
g_os_bitmaps[pDirtyPriv->rdpindex].stamp = g_os_bitmap_stamp;
g_os_bitmap_stamp++;
LLOGLN(10, ("-----------------got dirty"));
LLOGLN(10, ("rdpup_check_dirty: got dirty"));
rdpup_switch_os_surface(pDirtyPriv->rdpindex);
rdpup_get_pixmap_image_rect(pDirtyPixmap, &id);
rdpup_begin_update();
@ -1994,7 +1995,7 @@ rdpup_check_dirty_screen(rdpPixmapRec *pDirtyPriv)
return 0;
}
LLOGLN(10, ("-----------------got dirty"));
LLOGLN(10, ("rdpup_check_dirty_screen: got dirty"));
rdpup_get_screen_image_rect(&id);
rdpup_begin_update();
draw_item_pack(0, pDirtyPriv);

@ -14,3 +14,9 @@ allclean:
cd xrdpdev; $(MAKE) clean
cd xrdpkeyb; $(MAKE) clean
cd xrdpmouse; $(MAKE) clean
xinstall:
cp module/libxorgxrdp.so $(HOME)/xorg-modules/
cp xrdpdev/xrdpdev_drv.so $(HOME)/xorg-modules/drivers/
cp xrdpmouse/xrdpmouse_drv.so $(HOME)/xorg-modules/input/
cp xrdpkeyb/xrdpkeyb_drv.so $(HOME)/xorg-modules/input/

@ -5,7 +5,7 @@ rdpPolyRectangle.o rdpPolyArc.o rdpFillPolygon.o rdpPolyFillRect.o \
rdpPolyFillArc.o rdpPolyText8.o rdpPolyText16.o rdpImageText8.o \
rdpImageText16.o rdpImageGlyphBlt.o rdpPolyGlyphBlt.o rdpPushPixels.o \
rdpCursor.o rdpMain.o rdpRandR.o rdpMisc.o rdpReg.o \
rdpComposite.o rdpGlyphs.o
rdpComposite.o rdpGlyphs.o rdpPixmap.o rdpInput.o rdpClientCon.o
CFLAGS = -g -O2 -Wall -fPIC -I/usr/include/xorg -I/usr/include/pixman-1

@ -33,6 +33,38 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define PixelDPI 100
#define PixelToMM(_size) (((_size) * 254 + (PixelDPI) * 5) / ((PixelDPI) * 10))
#define RDPMIN(_val1, _val2) ((_val1) < (_val2) ? (_val1) : (_val2))
#define RDPMAX(_val1, _val2) ((_val1) < (_val2) ? (_val2) : (_val1))
#define RDPCLAMP(_val, _lo, _hi) \
(_val) < (_lo) ? (_lo) : (_val) > (_hi) ? (_hi) : (_val)
/* defined in rdpClientCon.h */
typedef struct _rdpClientCon rdpClientCon;
struct _rdpPointer
{
int cursor_x;
int cursor_y;
int old_button_mask;
int button_mask;
DeviceIntPtr device;
};
typedef struct _rdpPointer rdpPointer;
struct _rdpKeyboard
{
int pause_spe;
int ctrl_down;
int alt_down;
int shift_down;
int tab_down;
/* this is toggled every time num lock key is released, not like the
above *_down vars */
int scroll_lock_down;
DeviceIntPtr device;
};
typedef struct _rdpKeyboard rdpKeyboard;
/* move this to common header */
struct _rdpRec
{
@ -57,7 +89,12 @@ struct _rdpRec
CompositeProcPtr Composite;
GlyphsProcPtr Glyphs;
/* keyboard and mouse */
miPointerScreenFuncPtr pCursorFuncs;
/* mouse */
rdpPointer pointer;
/* keyboard */
rdpKeyboard keyboard;
/* RandR */
RRSetConfigProcPtr rrSetConfig;
@ -73,6 +110,10 @@ struct _rdpRec
RRGetPanningProcPtr rrGetPanning;
RRSetPanningProcPtr rrSetPanning;
int listen_sck;
char uds_data[256];
rdpClientCon *clientConHead;
rdpClientCon *clientConTail;
};
typedef struct _rdpRec rdpRec;
typedef struct _rdpRec * rdpPtr;

@ -0,0 +1,245 @@
/*
Copyright 2005-2013 Jay Sorg
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Client connection to xrdp
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
#include "rdpClientCon.h"
#include "rdpMisc.h"
#define LOG_LEVEL 1
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
#define LTOUI32(_in) ((unsigned int)(_in))
/******************************************************************************/
static int
rdpClientConGotConnection(ScreenPtr pScreen, rdpPtr dev)
{
rdpClientCon *clientCon;
LLOGLN(0, ("rdpClientConGotConnection:"));
clientCon = (rdpClientCon *) g_malloc(sizeof(rdpClientCon), 1);
make_stream(clientCon->in_s);
init_stream(clientCon->in_s, 8192);
make_stream(clientCon->out_s);
init_stream(clientCon->out_s, 8192 * 4 + 100);
if (dev->clientConTail == NULL)
{
dev->clientConHead = clientCon;
dev->clientConTail = clientCon;
}
else
{
dev->clientConTail->next = clientCon;
dev->clientConTail = clientCon;
}
return 0;
}
/******************************************************************************/
static int
rdpClientConGotData(ScreenPtr pScreen, rdpPtr dev, rdpClientCon *clientCon)
{
LLOGLN(0, ("rdpClientConGotData:"));
return 0;
}
/******************************************************************************/
static int
rdpClientConGotControlConnection(ScreenPtr pScreen, rdpPtr dev,
rdpClientCon *clientCon)
{
LLOGLN(0, ("rdpClientConGotControlConnection:"));
return 0;
}
/******************************************************************************/
static int
rdpClientConGotControlData(ScreenPtr pScreen, rdpPtr dev,
rdpClientCon *clientCon)
{
LLOGLN(0, ("rdpClientConGotControlData:"));
return 0;
}
/******************************************************************************/
int
rdpClientConCheck(ScreenPtr pScreen)
{
rdpPtr dev;
rdpClientCon *clientCon;
fd_set rfds;
struct timeval time;
int max;
int sel;
int count;
LLOGLN(10, ("rdpClientConCheck:"));
dev = rdpGetDevFromScreen(pScreen);
time.tv_sec = 0;
time.tv_usec = 0;
FD_ZERO(&rfds);
count = 0;
max = 0;
if (dev->listen_sck > 0)
{
count++;
FD_SET(LTOUI32(dev->listen_sck), &rfds);
max = RDPMAX(dev->listen_sck, max);
}
clientCon = dev->clientConHead;
while (clientCon != NULL)
{
if (clientCon->sck > 0)
{
count++;
FD_SET(LTOUI32(clientCon->sck), &rfds);
max = RDPMAX(clientCon->sck, max);
}
if (clientCon->sckControl > 0)
{
count++;
FD_SET(LTOUI32(clientCon->sckControl), &rfds);
max = RDPMAX(clientCon->sckControl, max);
}
if (clientCon->sckControlListener > 0)
{
count++;
FD_SET(LTOUI32(clientCon->sckControlListener), &rfds);
max = RDPMAX(clientCon->sckControlListener, max);
}
clientCon = clientCon->next;
}
if (count < 1)
{
sel = 0;
}
else
{
sel = select(max + 1, &rfds, 0, 0, &time);
}
if (sel < 1)
{
LLOGLN(10, ("rdpClientConCheck: no select"));
return 0;
}
if (dev->listen_sck > 0)
{
if (FD_ISSET(LTOUI32(dev->listen_sck), &rfds))
{
rdpClientConGotConnection(pScreen, dev);
}
}
clientCon = dev->clientConHead;
while (clientCon != NULL)
{
if (clientCon->sck > 0)
{
if (FD_ISSET(LTOUI32(clientCon->sck), &rfds))
{
rdpClientConGotData(pScreen, dev, clientCon);
}
}
if (clientCon->sckControlListener > 0)
{
if (FD_ISSET(LTOUI32(clientCon->sckControlListener), &rfds))
{
rdpClientConGotControlConnection(pScreen, dev, clientCon);
}
}
if (clientCon->sckControl > 0)
{
if (FD_ISSET(LTOUI32(clientCon->sckControl), &rfds))
{
rdpClientConGotControlData(pScreen, dev, clientCon);
}
}
clientCon = clientCon->next;
}
return 0;
}
/******************************************************************************/
int
rdpClientConInit(rdpPtr dev)
{
int i;
if (!g_directory_exist("/tmp/.xrdp"))
{
if (!g_create_dir("/tmp/.xrdp"))
{
if (!g_directory_exist("/tmp/.xrdp"))
{
LLOGLN(0, ("rdpup_init: g_create_dir failed"));
return 0;
}
}
g_chmod_hex("/tmp/.xrdp", 0x1777);
}
i = atoi(display);
if (i < 1)
{
LLOGLN(0, ("rdpClientConInit: can not run at display < 1"));
return 0;
}
g_sprintf(dev->uds_data, "/tmp/.xrdp/xrdp_display_%s", display);
if (dev->listen_sck == 0)
{
unlink(dev->uds_data);
dev->listen_sck = g_tcp_local_socket_stream();
if (g_tcp_local_bind(dev->listen_sck, dev->uds_data) != 0)
{
LLOGLN(0, ("rdpClientConInit: g_tcp_local_bind failed"));
return 1;
}
g_tcp_listen(dev->listen_sck);
AddEnabledDevice(dev->listen_sck);
}
return 0;
}
/******************************************************************************/
int
rdpClientConDeinit(rdpPtr dev)
{
LLOGLN(0, ("rdpClientConDeinit:"));
if (dev->listen_sck != 0)
{
close(dev->listen_sck);
unlink(dev->uds_data);
}
return 0;
}

@ -0,0 +1,44 @@
/*
Copyright 2005-2013 Jay Sorg
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Client connection to xrdp
*/
#ifndef _RDPCLIENTCON_H
#define _RDPCLIENTCON_H
struct _rdpClientCon
{
int sck;
int sckControlListener;
int sckControl;
struct stream *out_s;
struct stream *in_s;
struct _rdpClientCon *next;
};
int
rdpClientConCheck(ScreenPtr pScreen);
int
rdpClientConInit(rdpPtr dev);
int
rdpClientConDeinit(rdpPtr dev);
#endif

@ -36,6 +36,7 @@ composite(alpha blending) calls
#include "rdp.h"
#include "rdpComposite.h"
#include "rdpDraw.h"
/******************************************************************************/
#define LOG_LEVEL 1
@ -46,8 +47,8 @@ composite(alpha blending) calls
static void
rdpCompositeOrg(PictureScreenPtr ps, rdpPtr dev,
CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst,
INT16 yDst, CARD16 width, CARD16 height)
INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask,
INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
{
ps->Composite = dev->Composite;
ps->Composite(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
@ -63,14 +64,12 @@ rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
{
ScreenPtr pScreen;
rdpPtr dev;
ScrnInfoPtr pScrn;
PictureScreenPtr ps;
LLOGLN(10, ("rdpComposite:"));
pScreen = pSrc->pDrawable->pScreen;
pScrn = xf86Screens[pScreen->myNum];
dev = XRDPPTR(pScrn);
dev = rdpGetDevFromScreen(pScreen);
ps = GetPictureScreen(pScreen);
rdpCompositeOrg(ps, dev, op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
xDst, yDst, width, height);
rdpCompositeOrg(ps, dev, op, pSrc, pMask, pDst, xSrc, ySrc,
xMask, yMask, xDst, yDst, width, height);
}

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -31,8 +42,7 @@ static RegionPtr
rdpCopyAreaOrg(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
int srcx, int srcy, int w, int h, int dstx, int dsty)
{
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_VARS;
RegionPtr rv;
GC_OP_PROLOGUE(pGC);

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -32,9 +43,8 @@ rdpCopyPlaneOrg(DrawablePtr pSrc, DrawablePtr pDst,
GCPtr pGC, int srcx, int srcy, int w, int h,
int dstx, int dsty, unsigned long bitPlane)
{
GC_OP_VARS;
RegionPtr rv;
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_PROLOGUE(pGC);
rv = pGC->ops->CopyPlane(pSrc, pDst, pGC, srcx, srcy,

@ -38,6 +38,7 @@ cursor
#include <mi.h>
#include "rdp.h"
#include "rdpMain.h"
/******************************************************************************/
#define LOG_LEVEL 1
@ -49,7 +50,7 @@ Bool
rdpSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs)
{
LLOGLN(0, ("rdpSpriteRealizeCursor:"));
return 1;
return TRUE;
}
/******************************************************************************/
@ -57,7 +58,7 @@ Bool
rdpSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs)
{
LLOGLN(0, ("rdpSpriteUnrealizeCursor:"));
return 1;
return TRUE;
}
/******************************************************************************/
@ -80,7 +81,7 @@ Bool
rdpSpriteDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScr)
{
LLOGLN(0, ("rdpSpriteDeviceCursorInitialize:"));
return 1;
return TRUE;
}
/******************************************************************************/
@ -88,4 +89,5 @@ void
rdpSpriteDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScr)
{
LLOGLN(0, ("rdpSpriteDeviceCursorCleanup:"));
xorgxrdpDownDown(pScr);
}

@ -38,82 +38,21 @@ misc draw calls
#include <mi.h>
#include "rdp.h"
#include "rdpDraw.h"
/******************************************************************************/
#define LOG_LEVEL 1
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
/*****************************************************************************/
PixmapPtr
rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
unsigned usage_hint)
{
ScrnInfoPtr pScrn;
rdpPtr dev;
PixmapPtr rv;
LLOGLN(10, ("rdpCreatePixmap: width %d height %d depth %d",
width, height, depth));
pScrn = xf86Screens[pScreen->myNum];
dev = XRDPPTR(pScrn);
pScreen->CreatePixmap = dev->CreatePixmap;
rv = pScreen->CreatePixmap(pScreen, width, height, depth, usage_hint);
pScreen->CreatePixmap = rdpCreatePixmap;
return rv;
}
/******************************************************************************/
Bool
rdpDestroyPixmap(PixmapPtr pPixmap)
{
Bool rv;
ScreenPtr pScreen;
rdpPtr dev;
ScrnInfoPtr pScrn;
LLOGLN(10, ("rdpDestroyPixmap: refcnt %d", pPixmap->refcnt));
pScreen = pPixmap->drawable.pScreen;
pScrn = xf86Screens[pScreen->myNum];
dev = XRDPPTR(pScrn);
pScreen->DestroyPixmap = dev->DestroyPixmap;
rv = pScreen->DestroyPixmap(pPixmap);
pScreen->DestroyPixmap = rdpDestroyPixmap;
return rv;
}
/******************************************************************************/
Bool
rdpModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth,
int bitsPerPixel, int devKind, pointer pPixData)
{
Bool rv;
ScreenPtr pScreen;
rdpPtr dev;
ScrnInfoPtr pScrn;
LLOGLN(10, ("rdpModifyPixmapHeader:"));
pScreen = pPixmap->drawable.pScreen;
pScrn = xf86Screens[pScreen->myNum];
dev = XRDPPTR(pScrn);
pScreen->ModifyPixmapHeader = dev->ModifyPixmapHeader;
rv = pScreen->ModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel,
devKind, pPixData);
pScreen->ModifyPixmapHeader = rdpModifyPixmapHeader;
return rv;
}
/*****************************************************************************/
void
rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
{
ScrnInfoPtr pScrn;
ScreenPtr pScreen;
rdpPtr dev;
pScreen = pWin->drawable.pScreen;
pScrn = xf86Screens[pScreen->myNum];
dev = XRDPPTR(pScrn);
dev = rdpGetDevFromScreen(pScreen);
dev->pScreen->CopyWindow = dev->CopyWindow;
dev->pScreen->CopyWindow(pWin, ptOldOrg, pOldRegion);
dev->pScreen->CopyWindow = rdpCopyWindow;
@ -123,13 +62,11 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
Bool
rdpCloseScreen(int index, ScreenPtr pScreen)
{
ScrnInfoPtr pScrn;
rdpPtr dev;
Bool rv;
LLOGLN(0, ("rdpCloseScreen:"));
pScrn = xf86Screens[pScreen->myNum];
dev = XRDPPTR(pScrn);
dev = rdpGetDevFromScreen(pScreen);
dev->pScreen->CloseScreen = dev->CloseScreen;
rv = dev->pScreen->CloseScreen(index, pScreen);
dev->pScreen->CloseScreen = rdpCloseScreen;
@ -146,3 +83,22 @@ rdpGetRootWindowPtr(ScreenPtr pScreen)
return pScreen->root;
#endif
}
/******************************************************************************/
rdpPtr
rdpGetDevFromScreen(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn;
rdpPtr dev;
if (pScreen == NULL)
{
pScrn = xf86Screens[0];
}
else
{
pScrn = xf86Screens[pScreen->myNum];
}
dev = XRDPPTR(pScrn);
return dev;
}

@ -27,15 +27,13 @@ misc draw calls
#include <xorg-server.h>
#include <xf86.h>
/******************************************************************************/
#define GC_OP_VARS rdpPtr dev; rdpGCPtr priv; GCFuncs *oldFuncs
/******************************************************************************/
#define GC_OP_PROLOGUE(_pGC) \
do { \
rdpPtr dev; \
ScreenPtr pScreen; \
ScrnInfoPtr pScrn; \
pScreen = (_pGC)->pScreen; \
pScrn = xf86Screens[pScreen->myNum]; \
dev = XRDPPTR(pScrn); \
dev = rdpGetDevFromScreen((_pGC)->pScreen); \
priv = (rdpGCPtr)rdpGetGCPrivate(_pGC, dev->privateKeyRecGC); \
oldFuncs = (_pGC)->funcs; \
(_pGC)->funcs = priv->funcs; \
@ -52,19 +50,13 @@ do { \
extern GCOps g_rdpGCOps; /* in rdpGC.c */
PixmapPtr
rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
unsigned usage_hint);
Bool
rdpDestroyPixmap(PixmapPtr pPixmap);
Bool
rdpModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth,
int bitsPerPixel, int devKind, pointer pPixData);
void
rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion);
Bool
rdpCloseScreen(int index, ScreenPtr pScreen);
WindowPtr
rdpGetRootWindowPtr(ScreenPtr pScreen);
rdpPtr
rdpGetDevFromScreen(ScreenPtr pScreen);
#endif

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -32,8 +43,7 @@ rdpFillPolygonOrg(DrawablePtr pDrawable, GCPtr pGC,
int shape, int mode, int count,
DDXPointPtr pPts)
{
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_VARS;
GC_OP_PROLOGUE(pGC);
pGC->ops->FillPolygon(pDrawable, pGC, shape, mode, count, pPts);

@ -19,11 +19,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
#define LDEBUG 0
#define LOG_LEVEL 1
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
@ -33,8 +42,7 @@ static void
rdpFillSpansOrg(DrawablePtr pDrawable, GCPtr pGC, int nInit,
DDXPointPtr pptInit, int *pwidthInit, int fSorted)
{
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_VARS;
GC_OP_PROLOGUE(pGC);
pGC->ops->FillSpans(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);

@ -58,21 +58,20 @@ GC related calls
#include "rdpImageGlyphBlt.h"
#include "rdpPolyGlyphBlt.h"
#include "rdpPushPixels.h"
#include "rdpDraw.h"
/******************************************************************************/
#define LOG_LEVEL 1
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
/******************************************************************************/
#define GC_FUNC_VARS rdpPtr dev; rdpGCPtr priv;
/******************************************************************************/
#define GC_FUNC_PROLOGUE(_pGC) \
do { \
rdpPtr dev; \
ScreenPtr pScreen; \
ScrnInfoPtr pScrn; \
pScreen = _pGC->pScreen; \
pScrn = xf86Screens[pScreen->myNum]; \
dev = XRDPPTR(pScrn); \
dev = rdpGetDevFromScreen((_pGC)->pScreen); \
priv = (rdpGCPtr)rdpGetGCPrivate(_pGC, dev->privateKeyRecGC); \
(_pGC)->funcs = priv->funcs; \
if (priv->ops != 0) \
@ -127,7 +126,7 @@ GCOps g_rdpGCOps =
static void
rdpValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr d)
{
rdpGCRec *priv;
GC_FUNC_VARS;
LLOGLN(10, ("rdpValidateGC:"));
GC_FUNC_PROLOGUE(pGC);
@ -140,7 +139,7 @@ rdpValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr d)
static void
rdpChangeGC(GCPtr pGC, unsigned long mask)
{
rdpGCRec *priv;
GC_FUNC_VARS;
LLOGLN(10, ("rdpChangeGC:"));
GC_FUNC_PROLOGUE(pGC);
@ -152,7 +151,7 @@ rdpChangeGC(GCPtr pGC, unsigned long mask)
static void
rdpCopyGC(GCPtr src, unsigned long mask, GCPtr dst)
{
rdpGCRec *priv;
GC_FUNC_VARS;
LLOGLN(10, ("rdpCopyGC:"));
GC_FUNC_PROLOGUE(dst);
@ -164,7 +163,7 @@ rdpCopyGC(GCPtr src, unsigned long mask, GCPtr dst)
static void
rdpDestroyGC(GCPtr pGC)
{
rdpGCRec *priv;
GC_FUNC_VARS;
LLOGLN(10, ("rdpDestroyGC:"));
GC_FUNC_PROLOGUE(pGC);
@ -176,7 +175,7 @@ rdpDestroyGC(GCPtr pGC)
static void
rdpChangeClip(GCPtr pGC, int type, pointer pValue, int nrects)
{
rdpGCRec *priv;
GC_FUNC_VARS;
LLOGLN(10, ("rdpChangeClip:"));
GC_FUNC_PROLOGUE(pGC);
@ -188,7 +187,7 @@ rdpChangeClip(GCPtr pGC, int type, pointer pValue, int nrects)
static void
rdpDestroyClip(GCPtr pGC)
{
rdpGCRec *priv;
GC_FUNC_VARS;
LLOGLN(10, ("rdpDestroyClip:"));
GC_FUNC_PROLOGUE(pGC);
@ -200,7 +199,7 @@ rdpDestroyClip(GCPtr pGC)
static void
rdpCopyClip(GCPtr dst, GCPtr src)
{
rdpGCRec *priv;
GC_FUNC_VARS;
LLOGLN(10, ("rdpCopyClip:"));
GC_FUNC_PROLOGUE(dst);
@ -215,13 +214,11 @@ rdpCreateGC(GCPtr pGC)
Bool rv;
rdpPtr dev;
ScreenPtr pScreen;
ScrnInfoPtr pScrn;
rdpGCPtr priv;
LLOGLN(10, ("rdpCreateGC:"));
pScreen = pGC->pScreen;
pScrn = xf86Screens[pScreen->myNum];
dev = XRDPPTR(pScrn);
dev = rdpGetDevFromScreen(pScreen);
priv = (rdpGCPtr)rdpGetGCPrivate(pGC, dev->privateKeyRecGC);
pScreen->CreateGC = dev->CreateGC;
rv = pScreen->CreateGC(pGC);

@ -37,6 +37,7 @@ gylph(font) calls
#include "rdp.h"
#include "rdpGlyphs.h"
#include "rdpDraw.h"
/******************************************************************************/
#define LOG_LEVEL 1
@ -66,13 +67,11 @@ rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
{
ScreenPtr pScreen;
rdpPtr dev;
ScrnInfoPtr pScrn;
PictureScreenPtr ps;
LLOGLN(10, ("rdpGlyphs:"));
pScreen = pSrc->pDrawable->pScreen;
pScrn = xf86Screens[pScreen->myNum];
dev = XRDPPTR(pScrn);
dev = rdpGetDevFromScreen(pScreen);
ps = GetPictureScreen(pScreen);
rdpGlyphsOrg(ps, dev, op, pSrc, pDst, maskFormat, xSrc, ySrc,
nlists, lists, glyphs);

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -32,8 +43,7 @@ rdpImageGlyphBltOrg(DrawablePtr pDrawable, GCPtr pGC,
int x, int y, unsigned int nglyph,
CharInfoPtr *ppci, pointer pglyphBase)
{
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_VARS;
GC_OP_PROLOGUE(pGC);
pGC->ops->ImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -31,8 +42,7 @@ void
rdpImageText16Org(DrawablePtr pDrawable, GCPtr pGC,
int x, int y, int count, unsigned short *chars)
{
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_VARS;
GC_OP_PROLOGUE(pGC);
pGC->ops->ImageText16(pDrawable, pGC, x, y, count, chars);

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -31,8 +42,7 @@ void
rdpImageText8Org(DrawablePtr pDrawable, GCPtr pGC,
int x, int y, int count, char *chars)
{
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_VARS;
GC_OP_PROLOGUE(pGC);
pGC->ops->ImageText8(pDrawable, pGC, x, y, count, chars);

@ -0,0 +1,121 @@
/*
Copyright 2013 Jay Sorg
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
#include "rdpInput.h"
#include "rdpMisc.h"
#define LOG_LEVEL 1
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
#define MAX_INPUT_PROC 4
struct input_proc_list
{
int type;
rdpInputEventProcPtr proc;
};
static struct input_proc_list g_input_proc[MAX_INPUT_PROC];
/******************************************************************************/
int
rdpRegisterInputCallback(int type, rdpInputEventProcPtr proc)
{
if (type == 0)
{
g_input_proc[0].proc = proc;
}
else if (type == 1)
{
g_input_proc[1].proc = proc;
}
else
{
return 1;
}
return 0;
}
/******************************************************************************/
int
rdpUnregisterInputCallback(rdpInputEventProcPtr proc)
{
int index;
for (index = 0; index < MAX_INPUT_PROC; index++)
{
if (g_input_proc[index].proc == proc)
{
g_input_proc[index].proc = 0;
return 0;
}
}
return 1;
}
/******************************************************************************/
int
rdpInputKeyboardEvent(rdpPtr dev, int msg,
long param1, long param2,
long param3, long param4)
{
if (g_input_proc[0].proc != 0)
{
return g_input_proc[0].proc(dev, msg, param1, param2, param3, param4);
}
return 0;
}
/******************************************************************************/
int
rdpInputMouseEvent(rdpPtr dev, int msg,
long param1, long param2,
long param3, long param4)
{
if (g_input_proc[1].proc != 0)
{
return g_input_proc[1].proc(dev, msg, param1, param2, param3, param4);
}
return 0;
}
/******************************************************************************/
/* called when module loads */
int
rdpInputInit(void)
{
g_memset(g_input_proc, 0, sizeof(g_input_proc));
return 0;
}

@ -0,0 +1,46 @@
/*
Copyright 2013 Jay Sorg
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
input
*/
#ifndef _RDPINPUT_H
#define _RDPINPUT_H
typedef int (*rdpInputEventProcPtr)(rdpPtr dev, int msg,
long param1, long param2,
long param3, long param4);
int
rdpRegisterInputCallback(int type, rdpInputEventProcPtr proc);
int
rdpUnregisterInputCallback(rdpInputEventProcPtr proc);
int
rdpInputKeyboardEvent(rdpPtr dev, int msg,
long param1, long param2,
long param3, long param4);
int
rdpInputMouseEvent(rdpPtr dev, int msg,
long param1, long param2,
long param3, long param4);
int
rdpInputInit(void);
#endif

@ -38,6 +38,9 @@ rdp module main
#include <mi.h>
#include "rdp.h"
#include "rdpInput.h"
#include "rdpDraw.h"
#include "rdpClientCon.h"
/******************************************************************************/
#define LOG_LEVEL 1
@ -52,20 +55,43 @@ rdp module main
#define PACKAGE_VERSION_MINOR 0
#define PACKAGE_VERSION_PATCHLEVEL 0
static int g_initialised = 0;
static Bool g_initialised = FALSE;
/*****************************************************************************/
static pointer
xorgxrdpSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor)
xorgxrdpSetup(pointer Module, pointer Options,
int *ErrorMajor, int *ErrorMinor)
{
LLOGLN(0, ("xorgxrdpSetup:"));
if (!g_initialised)
{
g_initialised = 1;
g_initialised = TRUE;
}
rdpInputInit();
rdpPrivateInit();
return (pointer) 1;
}
/*****************************************************************************/
static void
xorgxrdpTearDown(pointer Module)
{
LLOGLN(0, ("xorgxrdpTearDown:"));
}
/*****************************************************************************/
void
xorgxrdpDownDown(ScreenPtr pScreen)
{
LLOGLN(0, ("xorgxrdpDownDown:"));
if (g_initialised)
{
g_initialised = FALSE;
LLOGLN(0, ("xorgxrdpDownDown: 1"));
rdpClientConDeinit(rdpGetDevFromScreen(pScreen));
}
}
static MODULESETUPPROTO(xorgxrdpSetup);
static XF86ModuleVersionInfo RDPVersRec =
{
@ -83,4 +109,9 @@ static XF86ModuleVersionInfo RDPVersRec =
{ 0, 0, 0, 0 }
};
XF86ModuleData xorgxrdpModuleData = { &RDPVersRec, xorgxrdpSetup, NULL };
_X_EXPORT XF86ModuleData xorgxrdpModuleData =
{
&RDPVersRec,
xorgxrdpSetup,
xorgxrdpTearDown
};

@ -0,0 +1,30 @@
/*
Copyright 2013 Jay Sorg
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
rdp module main
*/
#ifndef __RDPMAIN_H
#define __RDPMAIN_H
void
xorgxrdpDownDown(ScreenPtr pScreen);
#endif

@ -24,6 +24,8 @@ the rest
#ifndef __RDPMISC_H
#define __RDPMISC_H
#include <X11/Xos.h>
int
rdpBitsPerPixel(int depth);
int
@ -75,4 +77,177 @@ g_chmod_hex(const char *filename, int flags);
void
g_hexdump(unsigned char *p, unsigned int len);
#if defined(X_BYTE_ORDER)
# if X_BYTE_ORDER == X_LITTLE_ENDIAN
# define L_ENDIAN
# else
# define B_ENDIAN
# endif
#else
# error Unknown endianness in rdp.h
#endif
/* check if we need to align data */
/* check if we need to align data */
#if defined(__sparc__) || defined(__alpha__) || defined(__hppa__) || \
defined(__AIX__) || defined(__PPC__) || defined(__mips__) || \
defined(__ia64__) || defined(__ppc__) || defined(__arm__)
#define NEED_ALIGN
#endif
/* parser state */
struct stream
{
char* p;
char* end;
char* data;
int size;
/* offsets of various headers */
char* iso_hdr;
char* mcs_hdr;
char* sec_hdr;
char* rdp_hdr;
char* channel_hdr;
char* next_packet;
};
/******************************************************************************/
#define s_push_layer(s, h, n) \
{ \
(s)->h = (s)->p; \
(s)->p += (n); \
}
/******************************************************************************/
#define s_pop_layer(s, h) \
{ \
(s)->p = (s)->h; \
}
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define out_uint16_le(s, v) \
{ \
*((s)->p) = (unsigned char)((v) >> 0); \
(s)->p++; \
*((s)->p) = (unsigned char)((v) >> 8); \
(s)->p++; \
}
#else
#define out_uint16_le(s, v) \
{ \
*((unsigned short*)((s)->p)) = (unsigned short)(v); \
(s)->p += 2; \
}
#endif
/******************************************************************************/
#define init_stream(s, v) \
{ \
if ((v) > (s)->size) \
{ \
g_free((s)->data); \
(s)->data = (char*)g_malloc((v), 0); \
(s)->size = (v); \
} \
(s)->p = (s)->data; \
(s)->end = (s)->data; \
(s)->next_packet = 0; \
}
/******************************************************************************/
#define out_uint8p(s, v, n) \
{ \
g_memcpy((s)->p, (v), (n)); \
(s)->p += (n); \
}
/******************************************************************************/
#define out_uint8a(s, v, n) \
{ \
out_uint8p((s), (v), (n)); \
}
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define out_uint32_le(s, v) \
{ \
*((s)->p) = (unsigned char)((v) >> 0); \
(s)->p++; \
*((s)->p) = (unsigned char)((v) >> 8); \
(s)->p++; \
*((s)->p) = (unsigned char)((v) >> 16); \
(s)->p++; \
*((s)->p) = (unsigned char)((v) >> 24); \
(s)->p++; \
}
#else
#define out_uint32_le(s, v) \
{ \
*((unsigned int*)((s)->p)) = (v); \
(s)->p += 4; \
}
#endif
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define in_uint32_le(s, v) \
{ \
(v) = (unsigned int) \
( \
(*((unsigned char*)((s)->p + 0)) << 0) | \
(*((unsigned char*)((s)->p + 1)) << 8) | \
(*((unsigned char*)((s)->p + 2)) << 16) | \
(*((unsigned char*)((s)->p + 3)) << 24) \
); \
(s)->p += 4; \
}
#else
#define in_uint32_le(s, v) \
{ \
(v) = *((unsigned int*)((s)->p)); \
(s)->p += 4; \
}
#endif
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define in_uint16_le(s, v) \
{ \
(v) = (unsigned short) \
( \
(*((unsigned char*)((s)->p + 0)) << 0) | \
(*((unsigned char*)((s)->p + 1)) << 8) \
); \
(s)->p += 2; \
}
#else
#define in_uint16_le(s, v) \
{ \
(v) = *((unsigned short*)((s)->p)); \
(s)->p += 2; \
}
#endif
/******************************************************************************/
#define s_mark_end(s) \
{ \
(s)->end = (s)->p; \
}
/******************************************************************************/
#define make_stream(s) \
{ \
(s) = (struct stream*)g_malloc(sizeof(struct stream), 1); \
}
/******************************************************************************/
#define free_stream(s) do \
{ \
if ((s) != 0) \
{ \
g_free((s)->data); \
} \
g_free((s)); \
} while (0)
#endif

@ -0,0 +1,94 @@
/*
Copyright 2005-2013 Jay Sorg
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
pixmap calls
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
/******************************************************************************/
#define LOG_LEVEL 1
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
/*****************************************************************************/
PixmapPtr
rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
unsigned usage_hint)
{
rdpPtr dev;
PixmapPtr rv;
LLOGLN(10, ("rdpCreatePixmap: width %d height %d depth %d",
width, height, depth));
dev = rdpGetDevFromScreen(pScreen);
pScreen->CreatePixmap = dev->CreatePixmap;
rv = pScreen->CreatePixmap(pScreen, width, height, depth, usage_hint);
pScreen->CreatePixmap = rdpCreatePixmap;
return rv;
}
/******************************************************************************/
Bool
rdpDestroyPixmap(PixmapPtr pPixmap)
{
Bool rv;
ScreenPtr pScreen;
rdpPtr dev;
LLOGLN(10, ("rdpDestroyPixmap: refcnt %d", pPixmap->refcnt));
pScreen = pPixmap->drawable.pScreen;
dev = rdpGetDevFromScreen(pScreen);
pScreen->DestroyPixmap = dev->DestroyPixmap;
rv = pScreen->DestroyPixmap(pPixmap);
pScreen->DestroyPixmap = rdpDestroyPixmap;
return rv;
}
/******************************************************************************/
Bool
rdpModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth,
int bitsPerPixel, int devKind, pointer pPixData)
{
Bool rv;
ScreenPtr pScreen;
rdpPtr dev;
LLOGLN(10, ("rdpModifyPixmapHeader:"));
pScreen = pPixmap->drawable.pScreen;
dev = rdpGetDevFromScreen(pScreen);
pScreen->ModifyPixmapHeader = dev->ModifyPixmapHeader;
rv = pScreen->ModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel,
devKind, pPixData);
pScreen->ModifyPixmapHeader = rdpModifyPixmapHeader;
return rv;
}

@ -0,0 +1,36 @@
/*
Copyright 2005-2013 Jay Sorg
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
pixmap calls
*/
#ifndef __RDPPIXMAP_H
#define __RDPPIXAMP_H
PixmapPtr
rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
unsigned usage_hint);
Bool
rdpDestroyPixmap(PixmapPtr pPixmap);
Bool
rdpModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth,
int bitsPerPixel, int devKind, pointer pPixData);
#endif

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -30,8 +41,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
void
rdpPolyArcOrg(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs)
{
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_VARS;
GC_OP_PROLOGUE(pGC);
pGC->ops->PolyArc(pDrawable, pGC, narcs, parcs);

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -30,8 +41,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
void
rdpPolyFillArcOrg(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs)
{
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_VARS;
GC_OP_PROLOGUE(pGC);
pGC->ops->PolyFillArc(pDrawable, pGC, narcs, parcs);

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -31,8 +42,7 @@ static void
rdpPolyFillRectOrg(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
xRectangle *prectInit)
{
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_VARS;
GC_OP_PROLOGUE(pGC);
pGC->ops->PolyFillRect(pDrawable, pGC, nrectFill, prectInit);

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -32,8 +43,7 @@ rdpPolyGlyphBltOrg(DrawablePtr pDrawable, GCPtr pGC,
int x, int y, unsigned int nglyph,
CharInfoPtr *ppci, pointer pglyphBase)
{
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_VARS;
GC_OP_PROLOGUE(pGC);
pGC->ops->PolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -31,8 +42,7 @@ void
rdpPolyPointOrg(DrawablePtr pDrawable, GCPtr pGC, int mode,
int npt, DDXPointPtr in_pts)
{
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_VARS;
GC_OP_PROLOGUE(pGC);
pGC->ops->PolyPoint(pDrawable, pGC, mode, npt, in_pts);

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -31,8 +42,7 @@ static void
rdpPolyRectangleOrg(DrawablePtr pDrawable, GCPtr pGC, int nrects,
xRectangle *rects)
{
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_VARS;
GC_OP_PROLOGUE(pGC);
pGC->ops->PolyRectangle(pDrawable, pGC, nrects, rects);

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -30,8 +41,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
void
rdpPolySegmentOrg(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSegs)
{
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_VARS;
GC_OP_PROLOGUE(pGC);
pGC->ops->PolySegment(pDrawable, pGC, nseg, pSegs);

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -31,9 +42,8 @@ int
rdpPolyText16Org(DrawablePtr pDrawable, GCPtr pGC,
int x, int y, int count, unsigned short *chars)
{
GC_OP_VARS;
int rv;
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_PROLOGUE(pGC);
rv = pGC->ops->PolyText16(pDrawable, pGC, x, y, count, chars);

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -31,9 +42,8 @@ int
rdpPolyText8Org(DrawablePtr pDrawable, GCPtr pGC,
int x, int y, int count, char *chars)
{
GC_OP_VARS;
int rv;
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_PROLOGUE(pGC);
rv = pGC->ops->PolyText8(pDrawable, pGC, x, y, count, chars);

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -31,8 +42,7 @@ static void
rdpPolylinesOrg(DrawablePtr pDrawable, GCPtr pGC, int mode,
int npt, DDXPointPtr pptInit)
{
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_VARS;
GC_OP_PROLOGUE(pGC);
pGC->ops->Polylines(pDrawable, pGC, mode, npt, pptInit);

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -31,8 +42,7 @@ void
rdpPushPixelsOrg(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst,
int w, int h, int x, int y)
{
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_VARS;
GC_OP_PROLOGUE(pGC);
pGC->ops->PushPixels(pGC, pBitMap, pDst, w, h, x, y);

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -31,8 +42,7 @@ static void
rdpPutImageOrg(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y,
int w, int h, int leftPad, int format, char *pBits)
{
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_VARS;
GC_OP_PROLOGUE(pGC);
pGC->ops->PutImage(pDst, pGC, depth, x, y, w, h, leftPad,

@ -69,29 +69,8 @@ Bool
rdpRRSetConfig(ScreenPtr pScreen, Rotation rotateKind, int rate,
RRScreenSizePtr pSize)
{
ScrnInfoPtr pScrn;
rdpPtr dev;
rrScrPrivPtr pRRScrPriv;
Bool rv;
LLOGLN(0, ("rdpRRSetConfig:"));
rv = TRUE;
pScrn = xf86Screens[pScreen->myNum];
dev = XRDPPTR(pScrn);
#if 0
pRRScrPriv = rrGetScrPriv(pScreen);
if (pRRScrPriv != 0)
{
if (dev->rrSetConfig != 0)
{
LLOGLN(0, ("rdpRRSetConfig: here"));
pRRScrPriv->rrSetConfig = dev->rrSetConfig;
rv = pRRScrPriv->rrSetConfig(pScreen, rotateKind, rate, pSize);
pRRScrPriv->rrSetConfig = rdpRRSetConfig;
}
}
#endif
return rv;
return TRUE;
}
/******************************************************************************/
@ -100,34 +79,15 @@ rdpRRGetInfo(ScreenPtr pScreen, Rotation *pRotations)
{
int width;
int height;
ScrnInfoPtr pScrn;
rdpPtr dev;
rrScrPrivPtr pRRScrPriv;
Bool rv;
LLOGLN(0, ("rdpRRGetInfo:"));
rv = TRUE;
pScrn = xf86Screens[pScreen->myNum];
dev = XRDPPTR(pScrn);
#if 0
pRRScrPriv = rrGetScrPriv(pScreen);
if (pRRScrPriv != 0)
{
if (dev->rrGetInfo != 0)
{
LLOGLN(0, ("rdpRRGetInfo: here"));
pRRScrPriv->rrGetInfo = dev->rrGetInfo;
rv = pRRScrPriv->rrGetInfo(pScreen, pRotations);
pRRScrPriv->rrGetInfo = rdpRRGetInfo;
}
}
#else
dev = rdpGetDevFromScreen(pScreen);
*pRotations = RR_Rotate_0;
width = dev->width;
height = dev->height;
rdpRRRegisterSize(pScreen, width, height);
#endif
return rv;
return TRUE;
}
/******************************************************************************/
@ -138,13 +98,11 @@ rdpRRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height,
WindowPtr root;
PixmapPtr screenPixmap;
BoxRec box;
ScrnInfoPtr pScrn;
rdpPtr dev;
LLOGLN(0, ("rdpRRScreenSetSize: width %d height %d mmWidth %d mmHeight %d",
width, height, (int)mmWidth, (int)mmHeight));
pScrn = xf86Screens[pScreen->myNum];
dev = XRDPPTR(pScrn);
dev = rdpGetDevFromScreen(pScreen);
root = rdpGetRootWindowPtr(pScreen);
if ((width < 1) || (height < 1))
{
@ -266,12 +224,10 @@ Bool
rdpRRGetPanning(ScreenPtr pScreen, RRCrtcPtr crtc, BoxPtr totalArea,
BoxPtr trackingArea, INT16 *border)
{
ScrnInfoPtr pScrn;
rdpPtr dev;
LLOGLN(0, ("rdpRRGetPanning: %p", crtc));
pScrn = xf86Screens[pScreen->myNum];
dev = XRDPPTR(pScrn);
dev = rdpGetDevFromScreen(pScreen);
if (totalArea != 0)
{

@ -20,6 +20,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
to deal with regions changing in xorg versions
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

@ -19,6 +19,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* this should be before all X11 .h files */
#include <xorg-server.h>
/* all driver need this */
#include <xf86.h>
#include <xf86_OSproc.h>
#include "rdp.h"
#include "rdpDraw.h"
@ -33,8 +44,7 @@ void
rdpSetSpansOrg(DrawablePtr pDrawable, GCPtr pGC, char *psrc,
DDXPointPtr ppt, int *pwidth, int nspans, int fSorted)
{
rdpGCPtr priv;
GCFuncs *oldFuncs;
GC_OP_VARS;
GC_OP_PROLOGUE(pGC);
pGC->ops->SetSpans(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);

@ -44,3 +44,6 @@ sudo mknod -m 666 /dev/vc/7 c 7 7
----input
xrdpkeyb_drv.so
xrdpmouse_drv.so
dpkg -S /usr/lib/xorg/modules/extensions/libglx.so
xserver-xorg-core

@ -47,6 +47,8 @@ This is the main driver file
#include "rdpMisc.h"
#include "rdpComposite.h"
#include "rdpGlyphs.h"
#include "rdpPixmap.h"
#include "rdpClientCon.h"
#define XRDP_DRIVER_NAME "XRDPDEV"
#define XRDP_NAME "XRDPDEV"
@ -152,8 +154,6 @@ rdpPreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
}
rdpPrivateInit();
rdpAllocRec(pScrn);
dev = XRDPPTR(pScrn);
@ -305,7 +305,7 @@ rdpResizeSession(rdpPtr dev, int width, int height)
{
LLOGLN(0, (" calling RRScreenSizeSet"));
ok = RRScreenSizeSet(dev->pScreen, width, height, mmwidth, mmheight);
LLOGLN(0, (" RRScreenSizeSet ok=[%d]", ok));
LLOGLN(0, (" RRScreenSizeSet ok %d", ok));
}
return ok;
}
@ -317,15 +317,13 @@ rdpDeferredRandR(OsTimerPtr timer, CARD32 now, pointer arg)
{
ScreenPtr pScreen;
rrScrPrivPtr pRRScrPriv;
ScrnInfoPtr pScrn;
rdpPtr dev;
char *envvar;
int width;
int height;
pScreen = (ScreenPtr) arg;
pScrn = xf86Screens[pScreen->myNum];
dev = XRDPPTR(pScrn);
dev = rdpGetDevFromScreen(pScreen);
LLOGLN(10, ("rdpDeferredRandR:"));
pRRScrPriv = rrGetScrPriv(pScreen);
if (pRRScrPriv == 0)
@ -396,6 +394,19 @@ rdpDeferredRandR(OsTimerPtr timer, CARD32 now, pointer arg)
return 0;
}
/******************************************************************************/
static void
rdpBlockHandler1(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
{
}
/******************************************************************************/
static void
rdpWakeupHandler1(pointer blockData, int result, pointer pReadmask)
{
rdpClientConCheck((ScreenPtr)blockData);
}
/*****************************************************************************/
static Bool
rdpScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
@ -413,7 +424,7 @@ rdpScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
miClearVisualTypes();
miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth),
pScrn->rgbBits, TrueColor);
pScrn->rgbBits, TrueColor);
miSetPixmapDepths();
LLOGLN(0, ("rdpScreenInit: virtualX %d virtualY %d rgbBits %d depth %d",
pScrn->virtualX, pScrn->virtualY, pScrn->rgbBits, pScrn->depth));
@ -521,8 +532,15 @@ rdpScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
ps->Glyphs = rdpGlyphs;
}
RegisterBlockAndWakeupHandlers(rdpBlockHandler1, rdpWakeupHandler1, pScreen);
g_timer = TimerSet(g_timer, 0, 10, rdpDeferredRandR, pScreen);
if (rdpClientConInit(dev) != 0)
{
LLOGLN(0, ("rdpScreenInit: rdpClientConInit failed"));
}
LLOGLN(0, ("rdpScreenInit: out"));
return TRUE;
}
@ -696,10 +714,17 @@ xrdpdevSetup(pointer module, pointer opts, int *errmaj, int *errmin)
}
}
/*****************************************************************************/
static void
xrdpdevTearDown(pointer Module)
{
LLOGLN(0, ("xrdpdevTearDown:"));
}
/* <drivername>ModuleData */
_X_EXPORT XF86ModuleData xrdpdevModuleData =
{
&g_VersRec,
xrdpdevSetup,
0
xrdpdevTearDown
};

@ -39,12 +39,13 @@ xrdp keyboard module
#include <micmap.h>
#include <mi.h>
#include <xkbsrv.h>
#include "X11/keysym.h"
#include "rdp.h"
/* if 1, a keystroke is done every minute, down, then up */
#define XRDPKB_TEST 0
#include "rdpInput.h"
#include "rdpDraw.h"
/******************************************************************************/
#define LOG_LEVEL 1
@ -83,9 +84,6 @@ xrdp keyboard module
#define N_PREDEFINED_KEYS \
(sizeof(g_kbdMap) / (sizeof(KeySym) * GLYPHS_PER_KEY))
static DeviceIntPtr g_keyboard = 0;
static OsTimerPtr g_timer = 0;
static KeySym g_kbdMap[] =
{
NoSymbol, NoSymbol, /* 8 */
@ -129,7 +127,7 @@ static KeySym g_kbdMap[] =
XK_L, NoSymbol,
XK_semicolon, XK_colon,
XK_apostrophe, XK_quotedbl,
XK_grave, XK_asciitilde,
XK_grave, XK_asciitilde,
XK_Shift_L, NoSymbol, /* 50 */
XK_backslash, XK_bar,
XK_Z, NoSymbol,
@ -206,34 +204,307 @@ static KeySym g_kbdMap[] =
/******************************************************************************/
static void
rdpEnqueueKey(int type, int scancode)
rdpEnqueueKey(DeviceIntPtr device, int type, int scancode)
{
if (type == KeyPress)
{
/* need this cause rdp and X11 repeats are different */
xf86PostKeyboardEvent(g_keyboard, scancode, FALSE);
xf86PostKeyboardEvent(g_keyboard, scancode, TRUE);
xf86PostKeyboardEvent(device, scancode, TRUE);
}
else
{
xf86PostKeyboardEvent(g_keyboard, scancode, FALSE);
xf86PostKeyboardEvent(device, scancode, FALSE);
}
}
#if XRDPKB_TEST
/******************************************************************************/
static CARD32
rdpDeferredUpdateCallback(OsTimerPtr timer, CARD32 now, pointer arg)
static void
sendDownUpKeyEvent(DeviceIntPtr device, int type, int x_scancode)
{
LLOGLN(0, ("rdpDeferredUpdateCallback:"));
/* need this cause rdp and X11 repeats are different */
/* if type is keydown, send keyup + keydown */
if (type == KeyPress)
{
rdpEnqueueKey(device, KeyRelease, x_scancode);
rdpEnqueueKey(device, KeyPress, x_scancode);
}
else
{
rdpEnqueueKey(device, KeyRelease, x_scancode);
}
}
rdpEnqueueKey(KeyPress, 115);
rdpEnqueueKey(KeyRelease, 115);
/******************************************************************************/
static void
check_keysa(rdpKeyboard *keyboard)
{
if (keyboard->ctrl_down != 0)
{
rdpEnqueueKey(keyboard->device, KeyRelease, keyboard->ctrl_down);
keyboard->ctrl_down = 0;
}
if (keyboard->alt_down != 0)
{
rdpEnqueueKey(keyboard->device, KeyRelease, keyboard->alt_down);
keyboard->alt_down = 0;
}
if (keyboard->shift_down != 0)
{
rdpEnqueueKey(keyboard->device, KeyRelease, keyboard->shift_down);
keyboard->shift_down = 0;
}
}
/**
* @param down - true for KeyDown events, false otherwise
* @param param1 - ASCII code of pressed key
* @param param2 -
* @param param3 - scancode of pressed key
* @param param4 -
******************************************************************************/
static void
KbdAddEvent(rdpKeyboard *keyboard, int down, int param1, int param2,
int param3, int param4)
{
int rdp_scancode;
int x_scancode;
int is_ext;
int is_spe;
int type;
type = down ? KeyPress : KeyRelease;
rdp_scancode = param3;
is_ext = param4 & 256; /* 0x100 */
is_spe = param4 & 512; /* 0x200 */
x_scancode = 0;
switch (rdp_scancode)
{
case 58: /* caps lock */
case 42: /* left shift */
case 54: /* right shift */
case 70: /* scroll lock */
x_scancode = rdp_scancode + MIN_KEY_CODE;
if (x_scancode > 0)
{
rdpEnqueueKey(keyboard->device, type, x_scancode);
}
break;
case 56: /* left - right alt button */
if (is_ext)
{
x_scancode = 113; /* right alt button */
}
else
{
x_scancode = 64; /* left alt button */
}
rdpEnqueueKey(keyboard->device, type, x_scancode);
break;
case 15: /* tab */
if (!down && !keyboard->tab_down)
{
/* leave x_scancode 0 here, we don't want the tab key up */
check_keysa(keyboard);
}
else
{
sendDownUpKeyEvent(keyboard->device, type, 23);
}
keyboard->tab_down = down;
break;
case 29: /* left or right ctrl */
/* this is to handle special case with pause key sending control first */
if (is_spe)
{
if (down)
{
keyboard->pause_spe = 1;
/* leave x_scancode 0 here, we don't want the control key down */
}
}
else
{
x_scancode = is_ext ? 109 : 37;
keyboard->ctrl_down = down ? x_scancode : 0;
rdpEnqueueKey(keyboard->device, type, x_scancode);
}
break;
case 69: /* Pause or Num Lock */
if (keyboard->pause_spe)
{
x_scancode = 110;
if (!down)
{
keyboard->pause_spe = 0;
}
}
else
{
x_scancode = keyboard->ctrl_down ? 110 : 77;
}
sendDownUpKeyEvent(keyboard->device, type, x_scancode);
break;
case 28: /* Enter or Return */
x_scancode = is_ext ? 108 : 36;
sendDownUpKeyEvent(keyboard->device, type, x_scancode);
break;
case 53: /* / */
x_scancode = is_ext ? 112 : 61;
sendDownUpKeyEvent(keyboard->device, type, x_scancode);
break;
case 55: /* * on KP or Print Screen */
x_scancode = is_ext ? 111 : 63;
sendDownUpKeyEvent(keyboard->device, type, x_scancode);
break;
case 71: /* 7 or Home */
x_scancode = is_ext ? 97 : 79;
sendDownUpKeyEvent(keyboard->device, type, x_scancode);
break;
g_timer = TimerSet(g_timer, 0, 1000, rdpDeferredUpdateCallback, 0);
case 72: /* 8 or Up */
x_scancode = is_ext ? 98 : 80;
sendDownUpKeyEvent(keyboard->device, type, x_scancode);
break;
case 73: /* 9 or PgUp */
x_scancode = is_ext ? 99 : 81;
sendDownUpKeyEvent(keyboard->device, type, x_scancode);
break;
case 75: /* 4 or Left */
x_scancode = is_ext ? 100 : 83;
sendDownUpKeyEvent(keyboard->device, type, x_scancode);
break;
case 77: /* 6 or Right */
x_scancode = is_ext ? 102 : 85;
sendDownUpKeyEvent(keyboard->device, type, x_scancode);
break;
case 79: /* 1 or End */
x_scancode = is_ext ? 103 : 87;
sendDownUpKeyEvent(keyboard->device, type, x_scancode);
break;
case 80: /* 2 or Down */
x_scancode = is_ext ? 104 : 88;
sendDownUpKeyEvent(keyboard->device, type, x_scancode);
break;
case 81: /* 3 or PgDn */
x_scancode = is_ext ? 105 : 89;
sendDownUpKeyEvent(keyboard->device, type, x_scancode);
break;
case 82: /* 0 or Insert */
x_scancode = is_ext ? 106 : 90;
sendDownUpKeyEvent(keyboard->device, type, x_scancode);
break;
case 83: /* . or Delete */
x_scancode = is_ext ? 107 : 91;
sendDownUpKeyEvent(keyboard->device, type, x_scancode);
break;
case 91: /* left win key */
rdpEnqueueKey(keyboard->device, type, 115);
break;
case 92: /* right win key */
rdpEnqueueKey(keyboard->device, type, 116);
break;
case 93: /* menu key */
rdpEnqueueKey(keyboard->device, type, 117);
break;
default:
x_scancode = rdp_scancode + MIN_KEY_CODE;
if (x_scancode > 0)
{
sendDownUpKeyEvent(keyboard->device, type, x_scancode);
}
break;
}
}
/******************************************************************************/
/* notes -
scroll lock doesn't seem to be a modifier in X
*/
static void
KbdSync(rdpKeyboard *keyboard, int param1)
{
int xkb_state;
xkb_state = XkbStateFieldFromRec(&(keyboard->device->key->xkbInfo->state));
if ((!(xkb_state & 0x02)) != (!(param1 & 4))) /* caps lock */
{
LLOGLN(0, ("KbdSync: toggling caps lock"));
KbdAddEvent(keyboard, 1, 58, 0, 58, 0);
KbdAddEvent(keyboard, 0, 58, 49152, 58, 49152);
}
if ((!(xkb_state & 0x10)) != (!(param1 & 2))) /* num lock */
{
LLOGLN(0, ("KbdSync: toggling num lock"));
KbdAddEvent(keyboard, 1, 69, 0, 69, 0);
KbdAddEvent(keyboard, 0, 69, 49152, 69, 49152);
}
if ((!(keyboard->scroll_lock_down)) != (!(param1 & 1))) /* scroll lock */
{
LLOGLN(0, ("KbdSync: toggling scroll lock"));
KbdAddEvent(keyboard, 1, 70, 0, 70, 0);
KbdAddEvent(keyboard, 0, 70, 49152, 70, 49152);
}
}
/******************************************************************************/
static int
rdpInputKeyboard(rdpPtr dev, int msg, long param1, long param2,
long param3, long param4)
{
rdpKeyboard *keyboard;
keyboard = &(dev->keyboard);
LLOGLN(0, ("rdpInputKeyboard:"));
switch (msg)
{
case 15: /* key down */
case 16: /* key up */
KbdAddEvent(keyboard, msg == 15, param1, param2, param3, param4);
break;
case 17: /* from RDP_INPUT_SYNCHRONIZE */
KbdSync(keyboard, param1);
break;
}
return 0;
}
#endif
/******************************************************************************/
void
@ -322,6 +593,7 @@ rdpkeybControl(DeviceIntPtr device, int what)
CARD8 modMap[MAP_LENGTH];
DevicePtr pDev;
XkbRMLVOSet set;
rdpPtr dev;
LLOGLN(0, ("rdpkeybControl: what %d", what));
pDev = (DevicePtr)device;
@ -338,10 +610,9 @@ rdpkeybControl(DeviceIntPtr device, int what)
set.options = "";
InitKeyboardDeviceStruct(device, &set, rdpkeybBell,
rdpkeybChangeKeyboardControl);
g_keyboard = device;
#if XRDPKB_TEST
g_timer = TimerSet(g_timer, 0, 1000, rdpDeferredUpdateCallback, 0);
#endif
dev = rdpGetDevFromScreen(NULL);
dev->keyboard.device = device;
rdpRegisterInputCallback(0, rdpInputKeyboard);
break;
case DEVICE_ON:
pDev->on = 1;
@ -425,13 +696,6 @@ static InputDriverRec rdpkeyb =
0 /* ref count */
};
/******************************************************************************/
static void
rdpkeybUnplug(pointer p)
{
LLOGLN(0, ("rdpkeybUnplug:"));
}
/******************************************************************************/
static pointer
rdpkeybPlug(pointer module, pointer options, int *errmaj, int *errmin)
@ -441,6 +705,13 @@ rdpkeybPlug(pointer module, pointer options, int *errmaj, int *errmin)
return module;
}
/******************************************************************************/
static void
rdpkeybUnplug(pointer p)
{
LLOGLN(0, ("rdpkeybUnplug:"));
}
/******************************************************************************/
static XF86ModuleVersionInfo rdpkeybVersionRec =
{
@ -459,7 +730,7 @@ static XF86ModuleVersionInfo rdpkeybVersionRec =
};
/******************************************************************************/
XF86ModuleData xrdpkeybModuleData =
_X_EXPORT XF86ModuleData xrdpkeybModuleData =
{
&rdpkeybVersionRec,
rdpkeybPlug,

@ -42,6 +42,8 @@ xrdp mouse module
#include <xserver-properties.h>
#include "rdp.h"
#include "rdpInput.h"
#include "rdpDraw.h"
/******************************************************************************/
#define LOG_LEVEL 1
@ -84,6 +86,127 @@ rdpmouseCtrl(DeviceIntPtr pDevice, PtrCtrl *pCtrl)
LLOGLN(0, ("rdpmouseCtrl:"));
}
/******************************************************************************/
static int
l_bound_by(int val, int low, int high)
{
val = RDPCLAMP(val, low, high);
return val;
}
/******************************************************************************/
static void
rdpEnqueueMotion(DeviceIntPtr device, int x, int y)
{
int valuators[2];
valuators[0] = x;
valuators[1] = y;
xf86PostMotionEvent(device, TRUE, 0, 2, valuators);
}
/******************************************************************************/
static void
rdpEnqueueButton(DeviceIntPtr device, int type, int buttons)
{
xf86PostButtonEvent(device, FALSE, buttons, type, 0, 0);
}
/******************************************************************************/
static void
PtrAddEvent(rdpPointer *pointer)
{
int i;
int type;
int buttons;
rdpEnqueueMotion(pointer->device, pointer->cursor_x, pointer->cursor_y);
for (i = 0; i < 5; i++)
{
if ((pointer->button_mask ^ pointer->old_button_mask) & (1 << i))
{
if (pointer->button_mask & (1 << i))
{
type = ButtonPress;
buttons = i + 1;
rdpEnqueueButton(pointer->device, type, buttons);
}
else
{
type = ButtonRelease;
buttons = i + 1;
rdpEnqueueButton(pointer->device, type, buttons);
}
}
}
pointer->old_button_mask = pointer->button_mask;
}
/******************************************************************************/
static int
rdpInputMouse(rdpPtr dev, int msg,
long param1, long param2,
long param3, long param4)
{
rdpPointer *pointer;
LLOGLN(0, ("rdpInputMouse:"));
pointer = &(dev->pointer);
switch (msg)
{
case 100:
/* without the minus 2, strange things happen when dragging
past the width or height */
pointer->cursor_x = l_bound_by(param1, 0, dev->width - 2);
pointer->cursor_y = l_bound_by(param2, 0, dev->height - 2);
PtrAddEvent(pointer);
break;
case 101:
pointer->button_mask = pointer->button_mask & (~1);
PtrAddEvent(pointer);
break;
case 102:
pointer->button_mask = pointer->button_mask | 1;
PtrAddEvent(pointer);
break;
case 103:
pointer->button_mask = pointer->button_mask & (~4);
PtrAddEvent(pointer);
break;
case 104:
pointer->button_mask = pointer->button_mask | 4;
PtrAddEvent(pointer);
break;
case 105:
pointer->button_mask = pointer->button_mask & (~2);
PtrAddEvent(pointer);
break;
case 106:
pointer->button_mask = pointer->button_mask | 2;
PtrAddEvent(pointer);
break;
case 107:
pointer->button_mask = pointer->button_mask & (~8);
PtrAddEvent(pointer);
break;
case 108:
pointer->button_mask = pointer->button_mask | 8;
PtrAddEvent(pointer);
break;
case 109:
pointer->button_mask = pointer->button_mask & (~16);
PtrAddEvent(pointer);
break;
case 110:
pointer->button_mask = pointer->button_mask | 16;
PtrAddEvent(pointer);
break;
}
return 0;
}
/******************************************************************************/
static int
rdpmouseControl(DeviceIntPtr device, int what)
@ -92,6 +215,7 @@ rdpmouseControl(DeviceIntPtr device, int what)
DevicePtr pDev;
Atom btn_labels[6];
Atom axes_labels[2];
rdpPtr dev;
LLOGLN(0, ("rdpmouseControl: what %d", what));
pDev = (DevicePtr)device;
@ -118,7 +242,9 @@ rdpmouseControl(DeviceIntPtr device, int what)
InitPointerDeviceStruct(pDev, map, 5, btn_labels, rdpmouseCtrl,
GetMotionHistorySize(), 2, axes_labels);
dev = rdpGetDevFromScreen(NULL);
dev->pointer.device = device;
rdpRegisterInputCallback(1, rdpInputMouse);
break;
case DEVICE_ON:
pDev->on = 1;
@ -204,13 +330,6 @@ static InputDriverRec rdpmouse =
0 /* ref count */
};
/******************************************************************************/
static void
rdpmouseUnplug(pointer p)
{
LLOGLN(0, ("rdpmouseUnplug:"));
}
/******************************************************************************/
static pointer
rdpmousePlug(pointer module, pointer options, int *errmaj, int *errmin)
@ -220,6 +339,13 @@ rdpmousePlug(pointer module, pointer options, int *errmaj, int *errmin)
return module;
}
/******************************************************************************/
static void
rdpmouseUnplug(pointer p)
{
LLOGLN(0, ("rdpmouseUnplug:"));
}
/******************************************************************************/
static XF86ModuleVersionInfo rdpmouseVersionRec =
{
@ -238,7 +364,7 @@ static XF86ModuleVersionInfo rdpmouseVersionRec =
};
/******************************************************************************/
XF86ModuleData xrdpmouseModuleData =
_X_EXPORT XF86ModuleData xrdpmouseModuleData =
{
&rdpmouseVersionRec,
rdpmousePlug,

@ -24,6 +24,10 @@ tcp_keepalive=yes
#background=626c72
#autorun=xrdp1
#hidelogwindow=yes
# when true, userid/password *must* be passed on cmd line
# require_credentials=yes
#bulk_compression=yes
# You can set the PAM error text in a gateway setup (MAX 256 chars)
#pamerrortxt=change your password according to policy at http://url

Loading…
Cancel
Save