summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am7
-rw-r--r--common/arch.h2
-rw-r--r--common/log.c24
-rw-r--r--common/os_calls.c26
-rw-r--r--common/os_calls.h2
-rw-r--r--common/parse.h32
-rw-r--r--common/trans.c158
-rw-r--r--common/trans.h5
-rw-r--r--common/xrdp_constants.h2
-rw-r--r--configure.ac17
-rw-r--r--docs/man/sesman.ini.56
-rw-r--r--freerdp/Makefile.am20
-rw-r--r--freerdp/xrdp-color.c314
-rw-r--r--freerdp/xrdp-freerdp.c1049
-rw-r--r--freerdp/xrdp-freerdp.h105
-rw-r--r--freerdp1/Makefile.am28
-rw-r--r--freerdp1/xrdp-color.c313
-rw-r--r--freerdp1/xrdp-color.h29
-rw-r--r--freerdp1/xrdp-freerdp.c1858
-rw-r--r--freerdp1/xrdp-freerdp.h180
-rw-r--r--libxrdp/Makefile.am11
-rw-r--r--libxrdp/libxrdp.h7
-rw-r--r--libxrdp/xrdp_iso.c18
-rw-r--r--libxrdp/xrdp_jpeg_compress.c139
-rw-r--r--libxrdp/xrdp_mcs.c119
-rw-r--r--libxrdp/xrdp_orders.c32
-rw-r--r--libxrdp/xrdp_rdp.c148
-rw-r--r--libxrdp/xrdp_sec.c149
-rw-r--r--sesman/chansrv/Makefile.am6
-rw-r--r--sesman/chansrv/chansrv.c75
-rw-r--r--sesman/chansrv/chansrv.h10
-rw-r--r--sesman/chansrv/chansrv_fuse.c218
-rw-r--r--sesman/chansrv/clipboard.c2
-rw-r--r--sesman/chansrv/devredir.c23
-rw-r--r--sesman/chansrv/fifo.c255
-rw-r--r--sesman/chansrv/fifo.h (renamed from freerdp/xrdp-color.h)25
-rw-r--r--sesman/chansrv/irp.h1
-rw-r--r--sesman/chansrv/mlog.h112
-rw-r--r--sesman/chansrv/pcsc/Makefile12
-rw-r--r--sesman/chansrv/pcsc/xrdp_pcsc.c856
-rw-r--r--sesman/chansrv/rail.c5
-rw-r--r--sesman/chansrv/smartcard.c2219
-rw-r--r--sesman/chansrv/smartcard.h124
-rw-r--r--sesman/chansrv/smartcard_pcsc.c660
-rw-r--r--sesman/chansrv/smartcard_pcsc.h28
-rw-r--r--sesman/chansrv/sound.c3
-rw-r--r--sesman/chansrv/xcommon.c2
-rw-r--r--sesman/config.c10
-rw-r--r--sesman/sesman.ini5
-rw-r--r--sesman/session.c7
-rw-r--r--tcutils/README.txt29
-rw-r--r--tcutils/main.cpp11
-rw-r--r--tcutils/mainwindow.cpp234
-rw-r--r--tcutils/mainwindow.h57
-rw-r--r--tcutils/mainwindow.ui100
-rw-r--r--tcutils/moc_mainwindow.cpp104
-rw-r--r--tcutils/qrc_resources.cpp1191
-rw-r--r--tcutils/resources.qrc5
-rw-r--r--tcutils/resources/images/tools.gifbin0 -> 17765 bytes
-rwxr-xr-xtcutils/tcutilsbin0 -> 63109 bytes
-rw-r--r--tcutils/tcutils.pro30
-rw-r--r--tcutils/tcutils.pro.user365
-rw-r--r--tcutils/ui_mainwindow.h105
-rw-r--r--tcutils/utils.cpp217
-rw-r--r--tcutils/utils.h150
-rw-r--r--tests/memtest/libmem.c10
-rw-r--r--tests/memtest/libmem.h2
-rw-r--r--xorg/X11R7.6/rdp/rdp.h10
-rw-r--r--xorg/X11R7.6/rdp/rdpCopyArea.c14
-rw-r--r--xorg/X11R7.6/rdp/rdpCopyPlane.c4
-rw-r--r--xorg/X11R7.6/rdp/rdpFillPolygon.c4
-rw-r--r--xorg/X11R7.6/rdp/rdpImageGlyphBlt.c4
-rw-r--r--xorg/X11R7.6/rdp/rdpImageText16.c4
-rw-r--r--xorg/X11R7.6/rdp/rdpImageText8.c4
-rw-r--r--xorg/X11R7.6/rdp/rdpPolyArc.c4
-rw-r--r--xorg/X11R7.6/rdp/rdpPolyFillArc.c4
-rw-r--r--xorg/X11R7.6/rdp/rdpPolyFillRect.c34
-rw-r--r--xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c4
-rw-r--r--xorg/X11R7.6/rdp/rdpPolyPoint.c4
-rw-r--r--xorg/X11R7.6/rdp/rdpPolyRectangle.c4
-rw-r--r--xorg/X11R7.6/rdp/rdpPolySegment.c4
-rw-r--r--xorg/X11R7.6/rdp/rdpPolyText16.c4
-rw-r--r--xorg/X11R7.6/rdp/rdpPolyText8.c4
-rw-r--r--xorg/X11R7.6/rdp/rdpPolylines.c4
-rw-r--r--xorg/X11R7.6/rdp/rdpPushPixels.c4
-rw-r--r--xorg/X11R7.6/rdp/rdpPutImage.c6
-rw-r--r--xorg/X11R7.6/rdp/rdpSetSpans.c18
-rw-r--r--xorg/X11R7.6/rdp/rdpdraw.c217
-rw-r--r--xorg/X11R7.6/rdp/rdpinput.c79
-rw-r--r--xorg/X11R7.6/rdp/rdpup.c447
-rw-r--r--xrdp/xrdp.c2
-rw-r--r--xrdp/xrdp.h4
-rw-r--r--xrdp/xrdp.ini4
-rw-r--r--xrdp/xrdp_bitmap.c57
-rw-r--r--xrdp/xrdp_cache.c30
-rw-r--r--xrdp/xrdp_listen.c10
-rw-r--r--xrdp/xrdp_mm.c7
-rw-r--r--xrdp/xrdp_process.c3
-rw-r--r--xrdp/xrdp_types.h3
-rw-r--r--xrdp/xrdp_wm.c2
-rw-r--r--xup/xup.c77
-rw-r--r--xup/xup.h2
102 files changed, 8429 insertions, 4725 deletions
diff --git a/Makefile.am b/Makefile.am
index d6e9e168..e8905c98 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,11 +1,5 @@
EXTRA_DIST = bootstrap COPYING design.txt faq-compile.txt faq-general.txt file-loc.txt install.txt prog_std.txt readme.txt
-if XRDP_FREERDP1
-FREERDPDIR =
-else
-FREERDPDIR =
-endif
-
if XRDP_NEUTRINORDP
NEUTRINORDPDIR = neutrinordp
else
@@ -24,7 +18,6 @@ SUBDIRS = \
rdp \
xup \
mc \
- $(FREERDPDIR) \
$(NEUTRINORDPDIR) \
libxrdp \
xrdp \
diff --git a/common/arch.h b/common/arch.h
index b8780926..6a29b0a9 100644
--- a/common/arch.h
+++ b/common/arch.h
@@ -1,7 +1,7 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
- * Copyright (C) Jay Sorg 2004-2012
+ * Copyright (C) Jay Sorg 2004-2013
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/common/log.c b/common/log.c
index ce0000aa..55353a8f 100644
--- a/common/log.c
+++ b/common/log.c
@@ -363,7 +363,7 @@ internal_config_read_logging(int file, struct log_config *lc,
if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_ENABLE_SYSLOG))
{
- lc->enable_syslog = text2bool((char *)list_get_item(param_v, i));
+ lc->enable_syslog = g_text2bool((char *)list_get_item(param_v, i));
}
if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_SYSLOG_LEVEL))
@@ -413,28 +413,6 @@ internalInitAndAllocStruct(void)
* Here below the public functions
*/
-
-/**
- *
- * @brief Reads sesman configuration
- * @param s translates the strings "1", "true" and "yes" in 1 (true) and other strings in 0
- * @return 0 on false, 1 on 1,true, yes
- *
- */
-int APP_CC
-text2bool(char *s)
-{
- if ( (g_atoi(s) != 0) ||
- (0 == g_strcasecmp(s, "true")) ||
- (0 == g_strcasecmp(s, "on")) ||
- (0 == g_strcasecmp(s, "yes")))
- {
- return 1;
- }
-
- return 0;
-}
-
enum logReturns DEFAULT_CC
log_start_from_param(const struct log_config *iniParams)
{
diff --git a/common/os_calls.c b/common/os_calls.c
index f5f5cd60..c5a15bb0 100644
--- a/common/os_calls.c
+++ b/common/os_calls.c
@@ -2501,6 +2501,17 @@ g_signal_child_stop(void (*func)(int))
}
/*****************************************************************************/
+
+void APP_CC
+g_signal_segfault(void (*func)(int))
+{
+#if defined(_WIN32)
+#else
+ signal(SIGSEGV, func);
+#endif
+}
+
+/*****************************************************************************/
/* does not work in win32 */
void APP_CC
g_signal_hang_up(void (*func)(int))
@@ -2935,3 +2946,18 @@ g_time3(void)
return (tp.tv_sec * 1000) + (tp.tv_usec / 1000);
#endif
}
+
+/*****************************************************************************/
+/* returns boolean */
+int APP_CC
+g_text2bool(const char *s)
+{
+ if ( (g_atoi(s) != 0) ||
+ (0 == g_strcasecmp(s, "true")) ||
+ (0 == g_strcasecmp(s, "on")) ||
+ (0 == g_strcasecmp(s, "yes")))
+ {
+ return 1;
+ }
+ return 0;
+}
diff --git a/common/os_calls.h b/common/os_calls.h
index cba37588..443a1840 100644
--- a/common/os_calls.h
+++ b/common/os_calls.h
@@ -125,6 +125,7 @@ int APP_CC g_get_errno(void);
int APP_CC g_execvp(const char* p1, char* args[]);
int APP_CC g_execlp3(const char* a1, const char* a2, const char* a3);
void APP_CC g_signal_child_stop(void (*func)(int));
+void APP_CC g_signal_segfault(void (*func)(int));
void APP_CC g_signal_hang_up(void (*func)(int));
void APP_CC g_signal_user_interrupt(void (*func)(int));
void APP_CC g_signal_kill(void (*func)(int));
@@ -152,5 +153,6 @@ int APP_CC g_check_user_in_group(const char* username, int gid, int* ok);
int APP_CC g_time1(void);
int APP_CC g_time2(void);
int APP_CC g_time3(void);
+int APP_CC g_text2bool(const char *s);
#endif
diff --git a/common/parse.h b/common/parse.h
index f92e76de..69a57ff8 100644
--- a/common/parse.h
+++ b/common/parse.h
@@ -56,6 +56,9 @@ struct stream
#define s_check_rem(s, n) ((s)->p + (n) <= (s)->end)
/******************************************************************************/
+#define s_check_rem_out(s, n) ((s)->p + (n) <= (s)->data + (s)->size)
+
+/******************************************************************************/
#define s_check_end(s) ((s)->p == (s)->end)
/******************************************************************************/
@@ -279,6 +282,35 @@ struct stream
#endif
/******************************************************************************/
+#if defined(B_ENDIAN) || defined(NEED_ALIGN)
+#define out_uint64_le(s, v) do \
+{ \
+ *((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++; \
+ *((s)->p) = (unsigned char)((v) >> 32); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 40); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 48); \
+ (s)->p++; \
+ *((s)->p) = (unsigned char)((v) >> 56); \
+ (s)->p++; \
+} while (0)
+#else
+#define out_uint64_le(s, v) do \
+{ \
+ *((tui64*)((s)->p)) = (v); \
+ (s)->p += 8; \
+} while (0)
+#endif
+
+/******************************************************************************/
#define out_uint32_be(s, v) do \
{ \
*((s)->p) = (unsigned char)((v) >> 24); \
diff --git a/common/trans.c b/common/trans.c
index e862249e..5d5c6125 100644
--- a/common/trans.c
+++ b/common/trans.c
@@ -92,6 +92,86 @@ trans_get_wait_objs(struct trans *self, tbus *objs, int *count)
/*****************************************************************************/
int APP_CC
+trans_get_wait_objs_rw(struct trans *self,
+ tbus *robjs, int *rcount,
+ tbus *wobjs, int *wcount)
+{
+ if (self == 0)
+ {
+ return 1;
+ }
+
+ if (self->status != TRANS_STATUS_UP)
+ {
+ return 1;
+ }
+
+ robjs[*rcount] = self->sck;
+ (*rcount)++;
+
+ if (self->wait_s != 0)
+ {
+ wobjs[*wcount] = self->sck;
+ (*wcount)++;
+ }
+
+ return 0;
+}
+
+/*****************************************************************************/
+int APP_CC
+send_waiting(struct trans *self, int block)
+{
+ struct stream *temp_s;
+ int bytes;
+ int sent;
+ int timeout;
+ int cont;
+
+ timeout = block ? 100 : 0;
+ cont = 1;
+ while (cont)
+ {
+ if (self->wait_s != 0)
+ {
+ temp_s = self->wait_s;
+ if (g_tcp_can_send(self->sck, timeout))
+ {
+ bytes = (int) (temp_s->end - temp_s->p);
+ sent = g_tcp_send(self->sck, temp_s->p, bytes, 0);
+ if (sent > 0)
+ {
+ temp_s->p += sent;
+ if (temp_s->p >= temp_s->end)
+ {
+ self->wait_s = (struct stream *) (temp_s->next_packet);
+ free_stream(temp_s);
+ }
+ }
+ else if (sent == 0)
+ {
+ return 1;
+ }
+ else
+ {
+ if (!g_tcp_last_error_would_block(self->sck))
+ {
+ return 1;
+ }
+ }
+ }
+ }
+ else
+ {
+ break;
+ }
+ cont = block;
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+int APP_CC
trans_check_wait_objs(struct trans *self)
{
tbus in_sck = (tbus)0;
@@ -142,6 +222,7 @@ trans_check_wait_objs(struct trans *self)
in_trans->sck = in_sck;
in_trans->type1 = TRANS_TYPE_SERVER;
in_trans->status = TRANS_STATUS_UP;
+ in_trans->is_term = self->is_term;
if (self->trans_conn_in(self, in_trans) != 0)
{
@@ -202,6 +283,12 @@ trans_check_wait_objs(struct trans *self)
}
}
}
+ if (send_waiting(self, 0) != 0)
+ {
+ /* error */
+ self->status = TRANS_STATUS_DOWN;
+ return 1;
+ }
}
return rv;
@@ -220,15 +307,28 @@ trans_force_read_s(struct trans *self, struct stream *in_s, int size)
while (size > 0)
{
+ /* make sure stream has room */
+ if ((in_s->end + size) > (in_s->data + in_s->size))
+ {
+ return 1;
+ }
rcvd = g_tcp_recv(self->sck, in_s->end, size, 0);
-
if (rcvd == -1)
{
if (g_tcp_last_error_would_block(self->sck))
{
- if (!g_tcp_can_recv(self->sck, 10))
+ if (!g_tcp_can_recv(self->sck, 100))
{
/* check for term here */
+ if (self->is_term != 0)
+ {
+ if (self->is_term())
+ {
+ /* term */
+ self->status = TRANS_STATUS_DOWN;
+ return 1;
+ }
+ }
}
}
else
@@ -277,6 +377,12 @@ trans_force_write_s(struct trans *self, struct stream *out_s)
size = (int)(out_s->end - out_s->data);
total = 0;
+ if (send_waiting(self, 1) != 0)
+ {
+ self->status = TRANS_STATUS_DOWN;
+ return 1;
+ }
+
while (total < size)
{
sent = g_tcp_send(self->sck, out_s->data + total, size - total, 0);
@@ -285,9 +391,18 @@ trans_force_write_s(struct trans *self, struct stream *out_s)
{
if (g_tcp_last_error_would_block(self->sck))
{
- if (!g_tcp_can_send(self->sck, 10))
+ if (!g_tcp_can_send(self->sck, 100))
{
/* check for term here */
+ if (self->is_term != 0)
+ {
+ if (self->is_term())
+ {
+ /* term */
+ self->status = TRANS_STATUS_DOWN;
+ return 1;
+ }
+ }
}
}
else
@@ -321,6 +436,43 @@ trans_force_write(struct trans *self)
/*****************************************************************************/
int APP_CC
+trans_write_copy(struct trans *self)
+{
+ int size;
+ struct stream *out_s;
+ struct stream *wait_s;
+ struct stream *temp_s;
+
+ if (self->status != TRANS_STATUS_UP)
+ {
+ return 1;
+ }
+
+ out_s = self->out_s;
+ size = (int)(out_s->end - out_s->data);
+ make_stream(wait_s);
+ init_stream(wait_s, size);
+ out_uint8a(wait_s, out_s->data, size);
+ s_mark_end(wait_s);
+ wait_s->p = wait_s->data;
+ if (self->wait_s == 0)
+ {
+ self->wait_s = wait_s;
+ }
+ else
+ {
+ temp_s = self->wait_s;
+ while (temp_s->next_packet != 0)
+ {
+ temp_s = (struct stream *) (temp_s->next_packet);
+ }
+ temp_s->next_packet = wait_s;
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+int APP_CC
trans_connect(struct trans *self, const char *server, const char *port,
int timeout)
{
diff --git a/common/trans.h b/common/trans.h
index 8daa980a..b7b9c20d 100644
--- a/common/trans.h
+++ b/common/trans.h
@@ -38,6 +38,7 @@ struct trans; /* forward declaration */
typedef int (*ttrans_data_in)(struct trans* self);
typedef int (*ttrans_conn_in)(struct trans* self, struct trans* new_self);
+typedef int (*tis_term)(void);
struct trans
{
@@ -52,6 +53,8 @@ struct trans
struct stream* in_s;
struct stream* out_s;
char* listen_filename;
+ tis_term is_term; /* used to test for exit */
+ struct stream* wait_s;
};
struct trans* APP_CC
@@ -71,6 +74,8 @@ trans_force_read(struct trans* self, int size);
int APP_CC
trans_force_write(struct trans* self);
int APP_CC
+trans_write_copy(struct trans* self);
+int APP_CC
trans_connect(struct trans* self, const char* server, const char* port,
int timeout);
int APP_CC
diff --git a/common/xrdp_constants.h b/common/xrdp_constants.h
index 4ccc4a46..6b1685f5 100644
--- a/common/xrdp_constants.h
+++ b/common/xrdp_constants.h
@@ -564,6 +564,8 @@
#define CMDTYPE_FRAME_MARKER 0x0004
#define CMDTYPE_STREAM_SURFACE_BITS 0x0006
+#define XRDP_MAX_BITMAP_CACHE_ID 3
+#define XRDP_MAX_BITMAP_CACHE_IDX 2000
#define XRDP_BITMAP_CACHE_ENTRIES 2048
#endif
diff --git a/configure.ac b/configure.ac
index a2a80aa2..e8823350 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
# Process this file with autoconf to produce a configure script
AC_PREREQ(2.59)
-AC_INIT([xrdp], [0.6.0], [xrdp-devel@lists.sourceforge.net])
+AC_INIT([xrdp], [0.7.0], [xrdp-devel@lists.sourceforge.net])
AC_CONFIG_HEADERS(config_ac.h:config_ac-h.in)
AM_INIT_AUTOMAKE([1.6 foreign])
AC_PROG_CC
@@ -31,10 +31,6 @@ AC_ARG_ENABLE(xrdpdebug, AS_HELP_STRING([--enable-xrdpdebug],
[Build debug (default: no)]),
[xrdpdebug=true], [xrdpdebug=false])
AM_CONDITIONAL(XRDP_DEBUG, [test x$xrdpdebug = xtrue])
-AC_ARG_ENABLE(freerdp1, AS_HELP_STRING([--enable-freerdp1],
- [Build freerdp1 module (default: no)]),
- [freerdp1=true], [freerdp1=false])
-AM_CONDITIONAL(XRDP_FREERDP1, [test x$freerdp1 = xtrue])
AC_ARG_ENABLE(neutrinordp, AS_HELP_STRING([--enable-neutrinordp],
[Build neutrinordp module (default: no)]),
[neutrinordp=true], [neutrinordp=false])
@@ -43,6 +39,10 @@ AC_ARG_ENABLE(jpeg, AS_HELP_STRING([--enable-jpeg],
[Build jpeg module (default: no)]),
[jpeg=true], [jpeg=false])
AM_CONDITIONAL(XRDP_JPEG, [test x$jpeg = xtrue])
+AC_ARG_ENABLE(tjpeg, AS_HELP_STRING([--enable-tjpeg],
+ [Build turbo jpeg module(assumes /opt/libjpeg-turbo) (default: no)]),
+ [tjpeg=true], [tjpeg=false])
+AM_CONDITIONAL(XRDP_TJPEG, [test x$tjpeg = xtrue])
AC_ARG_ENABLE(simplesound, AS_HELP_STRING([--enable-simplesound],
[Build simple pulse audio interface (default: no)]),
[simplesound=true], [simplesound=false])
@@ -83,8 +83,6 @@ then
AC_DEFINE([USE_NOPAM],1,[Disable PAM])
fi
-AS_IF( [test "x$enable_freerdp1" = "xyes"] , [PKG_CHECK_MODULES(FREERDP, freerdp >= 1.0.0)] )
-
AS_IF( [test "x$enable_neutrinordp" = "xyes"] , [PKG_CHECK_MODULES(FREERDP, freerdp >= 1.0.0)] )
# checking for libjpeg
@@ -128,7 +126,6 @@ AC_CONFIG_FILES([Makefile
libxrdp/Makefile
xup/Makefile
mc/Makefile
- freerdp1/Makefile
neutrinordp/Makefile
xrdp/Makefile
sesman/Makefile
@@ -141,8 +138,8 @@ AC_CONFIG_FILES([Makefile
docs/man/Makefile
instfiles/Makefile
instfiles/pam.d/Makefile
- instfiles/init.d/Makefile
- instfiles/default/Makefile
+ instfiles/init.d/Makefile
+ instfiles/default/Makefile
genkeymap/Makefile
xrdpapi/Makefile
xrdpvr/Makefile
diff --git a/docs/man/sesman.ini.5 b/docs/man/sesman.ini.5
index 2bf69297..84beafb4 100644
--- a/docs/man/sesman.ini.5
+++ b/docs/man/sesman.ini.5
@@ -98,9 +98,8 @@ If unset or set to \fI0\fR, unlimited session are allowed.
.TP
\fBKillDisconnected\fR=\fI[0|1]\fR
-If set to \fB1\fR, \fBtrue\fR or \fByes\fR, every session will be killed when the user disconnects.
+If set to \fB1\fR, \fBtrue\fR or \fByes\fR, every session will be killed within 60 seconds when the user disconnects.
.br
-\fI\-this option is currently ignored!\-\fR
.TP
\fBIdleTimeLimit\fR=\fI<number>\fR
@@ -112,11 +111,10 @@ If set to \fI0\fR, automatic disconnection is disabled.
.TP
\fBDisconnectedTimeLimit\fR=\fI<number>\fR
-Sets the the time limit before a disconnected session is killed.
+Sets the time(in seconds) limit before a disconnected session is killed.
.br
If set to \fI0\fR, automatic killing is disabled.
.br
-\fI\-this option is currently ignored!\-\fR
.SH "SECURITY"
The following parameters can be used in the \fB[Sessions]\fR section:
diff --git a/freerdp/Makefile.am b/freerdp/Makefile.am
deleted file mode 100644
index 21f78741..00000000
--- a/freerdp/Makefile.am
+++ /dev/null
@@ -1,20 +0,0 @@
-EXTRA_DIST = xrdp-freerdp.h
-
-AM_CFLAGS = \
- -DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
- -DXRDP_SBIN_PATH=\"${sbindir}\" \
- -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
- -DXRDP_PID_PATH=\"${localstatedir}/run\"
-
-INCLUDES = \
- -I$(top_srcdir)/common \
- $(FREERDP_CFLAGS)
-
-lib_LTLIBRARIES = \
- libxrdpfreerdp.la
-
-libxrdpfreerdp_la_SOURCES = xrdp-freerdp.c xrdp-color.c
-
-libxrdpfreerdp_la_LIBADD = \
- $(top_builddir)/common/libcommon.la \
- $(FREERDP_LIBS)
diff --git a/freerdp/xrdp-color.c b/freerdp/xrdp-color.c
deleted file mode 100644
index 0ecf4dbf..00000000
--- a/freerdp/xrdp-color.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/**
- * xrdp: A Remote Desktop Protocol server.
- *
- * Copyright (C) Jay Sorg 2004-2012
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * freerdp wrapper
- */
-
-#include "xrdp-freerdp.h"
-
-char *APP_CC
-convert_bitmap(int in_bpp, int out_bpp, char *bmpdata,
- int width, int height, int *palette)
-{
- char *out;
- char *src;
- char *dst;
- int i;
- int j;
- int red;
- int green;
- int blue;
- int pixel;
-
- if ((in_bpp == 8) && (out_bpp == 8))
- {
- out = (char *)g_malloc(width * height, 0);
- src = bmpdata;
- dst = out;
-
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- pixel = *((tui8 *)src);
- pixel = palette[pixel];
- SPLITCOLOR32(red, green, blue, pixel);
- pixel = COLOR8(red, green, blue);
- *dst = pixel;
- src++;
- dst++;
- }
- }
-
- return out;
- }
-
- if ((in_bpp == 8) && (out_bpp == 16))
- {
- out = (char *)g_malloc(width * height * 2, 0);
- src = bmpdata;
- dst = out;
-
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- pixel = *((tui8 *)src);
- pixel = palette[pixel];
- SPLITCOLOR32(red, green, blue, pixel);
- pixel = COLOR16(red, green, blue);
- *((tui16 *)dst) = pixel;
- src++;
- dst += 2;
- }
- }
-
- return out;
- }
-
- if ((in_bpp == 8) && (out_bpp == 24))
- {
- out = (char *)g_malloc(width * height * 4, 0);
- src = bmpdata;
- dst = out;
-
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- pixel = *((tui8 *)src);
- pixel = palette[pixel];
- SPLITCOLOR32(red, green, blue, pixel);
- pixel = COLOR24RGB(red, green, blue);
- *((tui32 *)dst) = pixel;
- src++;
- dst += 4;
- }
- }
-
- return out;
- }
-
- if ((in_bpp == 15) && (out_bpp == 16))
- {
- out = (char *)g_malloc(width * height * 2, 0);
- src = bmpdata;
- dst = out;
-
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- pixel = *((tui16 *)src);
- SPLITCOLOR15(red, green, blue, pixel);
- pixel = COLOR16(red, green, blue);
- *((tui16 *)dst) = pixel;
- src += 2;
- dst += 2;
- }
- }
-
- return out;
- }
-
- if ((in_bpp == 15) && (out_bpp == 24))
- {
- out = (char *)g_malloc(width * height * 4, 0);
- src = bmpdata;
- dst = out;
-
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- pixel = *((tui16 *)src);
- SPLITCOLOR15(red, green, blue, pixel);
- pixel = COLOR24RGB(red, green, blue);
- *((tui32 *)dst) = pixel;
- src += 2;
- dst += 4;
- }
- }
-
- return out;
- }
-
- if ((in_bpp == 16) && (out_bpp == 16))
- {
- return bmpdata;
- }
-
- if ((in_bpp == 16) && (out_bpp == 24))
- {
- out = (char *)g_malloc(width * height * 4, 0);
- src = bmpdata;
- dst = out;
-
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- pixel = *((tui16 *)src);
- SPLITCOLOR16(red, green, blue, pixel);
- pixel = COLOR24RGB(red, green, blue);
- *((tui32 *)dst) = pixel;
- src += 2;
- dst += 4;
- }
- }
-
- return out;
- }
-
- if ((in_bpp == 24) && (out_bpp == 24))
- {
- out = (char *)g_malloc(width * height * 4, 0);
- src = bmpdata;
- dst = out;
-
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- blue = *((tui8 *)src);
- src++;
- green = *((tui8 *)src);
- src++;
- red = *((tui8 *)src);
- src++;
- pixel = COLOR24RGB(red, green, blue);
- *((tui32 *)dst) = pixel;
- dst += 4;
- }
- }
-
- return out;
- }
-
- if ((in_bpp == 32) && (out_bpp == 24))
- {
- return bmpdata;
- }
-
- if ((in_bpp == 32) && (out_bpp == 32))
- {
- return bmpdata;
- }
-
- if ((in_bpp == 15) && (out_bpp == 15))
- {
- return bmpdata;
- }
-
- g_writeln("convert_bitmap: error unknown conversion from %d to %d",
- in_bpp, out_bpp);
- return 0;
-}
-
-/*****************************************************************************/
-/* returns color or 0 */
-int APP_CC
-convert_color(int in_bpp, int out_bpp, int in_color, int *palette)
-{
- int pixel;
- int red;
- int green;
- int blue;
-
- if ((in_bpp == 1) && (out_bpp == 24))
- {
- pixel = in_color == 0 ? 0 : 0xffffff;
- return pixel;
- }
-
- if ((in_bpp == 8) && (out_bpp == 8))
- {
- pixel = palette[in_color];
- SPLITCOLOR32(red, green, blue, pixel);
- pixel = COLOR8(red, green, blue);
- return pixel;
- }
-
- if ((in_bpp == 8) && (out_bpp == 16))
- {
- pixel = palette[in_color];
- SPLITCOLOR32(red, green, blue, pixel);
- pixel = COLOR16(red, green, blue);
- return pixel;
- }
-
- if ((in_bpp == 8) && (out_bpp == 24))
- {
- pixel = palette[in_color];
- SPLITCOLOR32(red, green, blue, pixel);
- pixel = COLOR24BGR(red, green, blue);
- return pixel;
- }
-
- if ((in_bpp == 15) && (out_bpp == 16))
- {
- pixel = in_color;
- SPLITCOLOR15(red, green, blue, pixel);
- pixel = COLOR16(red, green, blue);
- return pixel;
- }
-
- if ((in_bpp == 15) && (out_bpp == 24))
- {
- pixel = in_color;
- SPLITCOLOR15(red, green, blue, pixel);
- pixel = COLOR24BGR(red, green, blue);
- return pixel;
- }
-
- if ((in_bpp == 16) && (out_bpp == 16))
- {
- return in_color;
- }
-
- if ((in_bpp == 16) && (out_bpp == 24))
- {
- pixel = in_color;
- SPLITCOLOR16(red, green, blue, pixel);
- pixel = COLOR24BGR(red, green, blue);
- return pixel;
- }
-
- if ((in_bpp == 24) && (out_bpp == 24))
- {
- return in_color;
- }
-
- if ((in_bpp == 32) && (out_bpp == 24))
- {
- return in_color;
- }
-
- if ((in_bpp == 32) && (out_bpp == 32))
- {
- return in_color;
- }
-
- if ((in_bpp == 15) && (out_bpp == 15))
- {
- return in_color;
- }
-
- g_writeln("convert_color: error unknown conversion from %d to %d",
- in_bpp, out_bpp);
- return 0;
-}
diff --git a/freerdp/xrdp-freerdp.c b/freerdp/xrdp-freerdp.c
deleted file mode 100644
index 5ee58800..00000000
--- a/freerdp/xrdp-freerdp.c
+++ /dev/null
@@ -1,1049 +0,0 @@
-/**
- * xrdp: A Remote Desktop Protocol server.
- *
- * Copyright (C) Jay Sorg 2004-2012
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * freerdp wrapper
- */
-
-#include "xrdp-freerdp.h"
-#include "xrdp-color.h"
-
-#define GET_MOD(_inst) ((struct mod*)((_inst)->param1))
-#define SET_MOD(_inst, _mod) ((_inst)->param1) = _mod
-
-struct my_bitmap
-{
- char *data;
- int width;
- int height;
- int bpp;
-};
-
-struct my_cursor
-{
- char *andmask;
- int andbpp;
- char *xormask;
- int xorbpp;
- int width;
- int height;
- int hotx;
- int hoty;
-};
-
-/*****************************************************************************/
-/* return error */
-static int DEFAULT_CC
-lib_mod_start(struct mod *mod, int w, int h, int bpp)
-{
- LIB_DEBUG(mod, "in lib_mod_start");
- g_writeln("lib_mod_start: w %d h %d bpp %d", w, h, bpp);
- mod->width = w;
- mod->height = h;
- mod->bpp = bpp;
-
- if (bpp == 24)
- {
- mod->settings->server_depth = 32;
- }
- else
- {
- mod->settings->server_depth = mod->bpp;
- }
-
- mod->settings->width = mod->width;
- mod->settings->height = mod->height;
- LIB_DEBUG(mod, "out lib_mod_start");
- return 0;
-}
-
-/******************************************************************************/
-/* return error */
-static int DEFAULT_CC
-lib_mod_connect(struct mod *mod)
-{
- int code;
-
- LIB_DEBUG(mod, "in lib_mod_connect");
- code = mod->inst->rdp_connect(mod->inst);
- g_writeln("lib_mod_connect: code %d", code);
- LIB_DEBUG(mod, "out lib_mod_connect");
- return code;
-}
-
-/******************************************************************************/
-/* return error */
-static int DEFAULT_CC
-lib_mod_event(struct mod *mod, int msg, long param1, long param2,
- long param3, long param4)
-{
- LIB_DEBUG(mod, "in lib_mod_event");
- int ext;
-
- //g_writeln("%d %d %d %d %d", msg, param1, param2, param3, param4);
- switch (msg)
- {
- case 15:
- ext = param4 & 0x100 ? 1 : 0;
- mod->inst->rdp_send_input_scancode(mod->inst, 0, ext, param3);
- break;
- case 16:
- ext = param4 & 0x100 ? 1 : 0;
- mod->inst->rdp_send_input_scancode(mod->inst, 1, ext, param3);
- break;
- case 17:
- mod->inst->rdp_sync_input(mod->inst, param4);
- break;
- case 100:
- mod->inst->rdp_send_input_mouse(mod->inst, PTRFLAGS_MOVE,
- param1, param2);
- break;
- case 101:
- mod->inst->rdp_send_input_mouse(mod->inst, PTRFLAGS_BUTTON1,
- param1, param2);
- break;
- case 102:
- mod->inst->rdp_send_input_mouse(mod->inst,
- PTRFLAGS_BUTTON1 | PTRFLAGS_DOWN,
- param1, param2);
- break;
- case 103:
- mod->inst->rdp_send_input_mouse(mod->inst,
- PTRFLAGS_BUTTON2, param1, param2);
- break;
- case 104:
- mod->inst->rdp_send_input_mouse(mod->inst,
- PTRFLAGS_BUTTON2 | PTRFLAGS_DOWN,
- param1, param2);
- break;
- case 105:
- mod->inst->rdp_send_input_mouse(mod->inst,
- PTRFLAGS_BUTTON3, param1, param2);
- break;
- case 106:
- mod->inst->rdp_send_input_mouse(mod->inst,
- PTRFLAGS_BUTTON3 | PTRFLAGS_DOWN,
- param1, param2);
- break;
- case 107:
- mod->inst->rdp_send_input_mouse(mod->inst,
- PTRFLAGS_WHEEL | 0x0078, 0, 0);
- break;
- case 108:
- break;
- case 109:
- mod->inst->rdp_send_input_mouse(mod->inst,
- PTRFLAGS_WHEEL |
- PTRFLAGS_WHEEL_NEGATIVE | 0x0088, 0, 0);
- break;
- case 110:
- break;
- }
-
- LIB_DEBUG(mod, "out lib_mod_event");
- return 0;
-}
-
-/******************************************************************************/
-/* return error */
-static int DEFAULT_CC
-lib_mod_signal(struct mod *mod)
-{
- LIB_DEBUG(mod, "in lib_mod_signal");
- g_writeln("lib_mod_signal:");
- LIB_DEBUG(mod, "out lib_mod_signal");
- return 0;
-}
-
-/******************************************************************************/
-/* return error */
-static int DEFAULT_CC
-lib_mod_end(struct mod *mod)
-{
- g_writeln("lib_mod_end:");
- return 0;
-}
-
-/******************************************************************************/
-/* return error */
-static int DEFAULT_CC
-lib_mod_set_param(struct mod *mod, char *name, char *value)
-{
- g_writeln("lib_mod_set_param: name [%s] value [%s]", name, value);
-
- if (g_strcmp(name, "hostname") == 0)
- {
- g_strncpy(mod->settings->hostname, value, sizeof(mod->settings->hostname));
- }
- else if (g_strcmp(name, "ip") == 0)
- {
- g_strncpy(mod->settings->server, value, sizeof(mod->settings->server));
- }
- else if (g_strcmp(name, "port") == 0)
- {
- mod->settings->tcp_port_rdp = g_atoi(value);
- }
- else if (g_strcmp(name, "keylayout") == 0)
- {
- mod->settings->keyboard_layout = g_atoi(value);
- }
- else if (g_strcmp(name, "name") == 0)
- {
- }
- else if (g_strcmp(name, "lib") == 0)
- {
- }
- else
- {
- g_writeln("lib_mod_set_param: unknown name [%s] value [%s]", name, value);
- }
-
- return 0;
-}
-
-/******************************************************************************/
-static int DEFAULT_CC
-mod_session_change(struct mod *v, int a, int b)
-{
- g_writeln("mod_session_change:");
- return 0;
-}
-
-/******************************************************************************/
-static int DEFAULT_CC
-mod_get_wait_objs(struct mod *v, tbus *read_objs, int *rcount,
- tbus *write_objs, int *wcount, int *timeout)
-{
- void **rfds;
- void **wfds;
-
- rfds = (void **)read_objs;
- wfds = (void **)write_objs;
- return v->inst->rdp_get_fds(v->inst, rfds, rcount, wfds, wcount);
-}
-
-/******************************************************************************/
-static int DEFAULT_CC
-mod_check_wait_objs(struct mod *v)
-{
- return v->inst->rdp_check_fds(v->inst);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_error(rdpInst *inst, const char *text)
-{
- g_writeln("ui_error: %s", text);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_warning(rdpInst *inst, const char *text)
-{
- g_writeln("ui_warning: %s", text);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_unimpl(rdpInst *inst, const char *text)
-{
- g_writeln("ui_unimpl: %s", text);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_begin_update(rdpInst *inst)
-{
- struct mod *mod;
-
- mod = GET_MOD(inst);
- mod->server_begin_update(mod);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_end_update(rdpInst *inst)
-{
- struct mod *mod;
-
- mod = GET_MOD(inst);
- mod->server_end_update(mod);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_desktop_save(rdpInst *inst, int offset, int x, int y,
- int cx, int cy)
-{
- g_writeln("ui_desktop_save:");
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_desktop_restore(rdpInst *inst, int offset, int x, int y,
- int cx, int cy)
-{
- g_writeln("ui_desktop_restore:");
-}
-
-/******************************************************************************/
-static RD_HBITMAP DEFAULT_CC
-ui_create_bitmap(rdpInst *inst, int width, int height, uint8 *data)
-{
- struct my_bitmap *bm;
- struct mod *mod;
- int size;
- int bpp;
- char *bmpdata;
-
- mod = GET_MOD(inst);
- bpp = mod->bpp == 24 ? 32 : mod->bpp;
- bm = (struct my_bitmap *)g_malloc(sizeof(struct my_bitmap), 1);
- bm->width = width;
- bm->height = height;
- bm->bpp = bpp;
- bmpdata = convert_bitmap(mod->settings->server_depth, bpp,
- data, width, height, mod->cmap);
-
- if (bmpdata == (char *)data)
- {
- size = width * height * ((bpp + 7) / 8);
- bm->data = (char *)g_malloc(size, 0);
- g_memcpy(bm->data, bmpdata, size);
- }
- else
- {
- bm->data = bmpdata;
- }
-
- return bm;
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_paint_bitmap(rdpInst *inst, int x, int y, int cx, int cy, int width,
- int height, uint8 *data)
-{
- struct mod *mod;
- char *bmpdata;
-
- mod = GET_MOD(inst);
- bmpdata = convert_bitmap(mod->settings->server_depth, mod->bpp,
- data, width, height, mod->cmap);
-
- if (bmpdata != 0)
- {
- mod->server_paint_rect(mod, x, y, cx, cy, bmpdata, width, height, 0, 0);
- }
-
- if (bmpdata != (char *)data)
- {
- g_free(bmpdata);
- }
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_destroy_bitmap(rdpInst *inst, RD_HBITMAP bmp)
-{
- struct my_bitmap *bm;
-
- bm = (struct my_bitmap *)bmp;
- g_free(bm->data);
- g_free(bm);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_line(rdpInst *inst, uint8 opcode, int startx, int starty, int endx,
- int endy, RD_PEN *pen)
-{
- g_writeln("ui_line:");
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_rect(rdpInst *inst, int x, int y, int cx, int cy, uint32 color)
-{
- struct mod *mod;
-
- mod = GET_MOD(inst);
- color = convert_color(mod->settings->server_depth, mod->bpp,
- color, mod->cmap);
- mod->server_set_fgcolor(mod, color);
- mod->server_fill_rect(mod, x, y, cx, cy);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_polygon(rdpInst *inst, uint8 opcode, uint8 fillmode, RD_POINT *point,
- int npoints, RD_BRUSH *brush, uint32 bgcolor, uint32 fgcolor)
-{
- g_writeln("ui_polygon:");
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_polyline(rdpInst *inst, uint8 opcode, RD_POINT *points, int npoints,
- RD_PEN *pen)
-{
- g_writeln("ui_polyline:");
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_ellipse(rdpInst *inst, uint8 opcode, uint8 fillmode, int x, int y,
- int cx, int cy, RD_BRUSH *brush, uint32 bgcolor, uint32 fgcolor)
-{
- g_writeln("ui_ellipse:");
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_add_char(rdpInst *inst, uint8 font, uint16 character, sint16 offset,
- sint16 baseline, uint16 width, uint16 height, uint8 *data)
-{
- struct mod *mod;
-
- //g_writeln("ui_add_char:");
- mod = GET_MOD(inst);
- mod->server_add_char(mod, font, character, offset, baseline,
- width, height, (char *)data);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_draw_text(rdpInst *inst, uint8 font, uint8 flags,
- uint8 opcode, int mixmode,
- int x, int y, int clipx, int clipy, int clipcx, int clipcy,
- int boxx, int boxy, int boxcx, int boxcy, RD_BRUSH *brush,
- uint32 bgcolor, uint32 fgcolor, uint8 *text, uint8 length)
-{
- struct mod *mod;
-
- //g_writeln("ui_draw_text: flags %d mixmode %d x %d y %d", flags, mixmode, x, y);
- //g_writeln("%d %d %d %d %d %d %d %d", clipx, clipy, clipcx, clipcy, boxx, boxy, boxcx, boxcy);
- mod = GET_MOD(inst);
- fgcolor = convert_color(mod->settings->server_depth, mod->bpp,
- fgcolor, mod->cmap);
- mod->server_set_fgcolor(mod, fgcolor);
- bgcolor = convert_color(mod->settings->server_depth, mod->bpp,
- bgcolor, mod->cmap);
- mod->server_set_bgcolor(mod, bgcolor);
- mod->server_draw_text(mod, font, flags, mixmode,
- clipx, clipy, clipx + clipcx, clipy + clipcy,
- boxx, boxy, boxx + boxcx, boxy + boxcy, x, y,
- (char *)text, length);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_start_draw_glyphs(rdpInst *inst, uint32 bgcolor, uint32 fgcolor)
-{
- g_writeln("ui_start_draw_glyphs:");
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_draw_glyph(rdpInst *inst, int x, int y, int cx, int cy,
- RD_HGLYPH glyph)
-{
- g_writeln("ui_draw_glyph:");
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_end_draw_glyphs(rdpInst *inst, int x, int y, int cx, int cy)
-{
- g_writeln("ui_end_draw_glyphs:");
-}
-
-/******************************************************************************/
-static uint32 DEFAULT_CC
-ui_get_toggle_keys_state(rdpInst *inst)
-{
- g_writeln("ui_get_toggle_keys_state:");
- return 0;
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_bell(rdpInst *inst)
-{
- g_writeln("ui_bell:");
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_destblt(rdpInst *inst, uint8 opcode, int x, int y, int cx, int cy)
-{
- struct mod *mod;
-
- g_writeln("ui_destblt:");
- mod = GET_MOD(inst);
- mod->server_set_opcode(mod, opcode);
- mod->server_fill_rect(mod, x, y, cx, cy);
- mod->server_set_opcode(mod, 0xcc);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_patblt(rdpInst *inst, uint8 opcode, int x, int y, int cx, int cy,
- RD_BRUSH *brush, uint32 bgcolor, uint32 fgcolor)
-{
- struct mod *mod;
- uint8 idata[8];
- int index;
-
- mod = GET_MOD(inst);
- mod->server_set_opcode(mod, opcode);
- fgcolor = convert_color(mod->settings->server_depth, mod->bpp,
- fgcolor, mod->cmap);
- mod->server_set_fgcolor(mod, fgcolor);
- bgcolor = convert_color(mod->settings->server_depth, mod->bpp,
- bgcolor, mod->cmap);
- mod->server_set_bgcolor(mod, bgcolor);
- mod->server_set_mixmode(mod, 1);
-
- if (brush->bd != 0)
- {
- if (brush->bd->color_code == 1) /* 8x8 1 bpp */
- {
- for (index = 0; index < 8; index++)
- {
- idata[index] = ~(brush->bd->data[index]);
- }
-
- mod->server_set_brush(mod, brush->xorigin, brush->yorigin,
- brush->style, idata);
- }
- else
- {
- g_writeln("ui_patblt: error color_code %d", brush->bd->color_code);
- }
- }
- else
- {
- for (index = 0; index < 8; index++)
- {
- idata[index] = ~(brush->pattern[index]);
- }
-
- mod->server_set_brush(mod, brush->xorigin, brush->yorigin,
- brush->style, idata);
- }
-
- mod->server_fill_rect(mod, x, y, cx, cy);
- mod->server_set_opcode(mod, 0xcc);
- mod->server_set_mixmode(mod, 0);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_screenblt(rdpInst *inst, uint8 opcode, int x, int y, int cx, int cy,
- int srcx, int srcy)
-{
- struct mod *mod;
-
- mod = GET_MOD(inst);
- mod->server_set_opcode(mod, opcode);
- mod->server_screen_blt(mod, x, y, cx, cy, srcx, srcy);
- mod->server_set_opcode(mod, 0xcc);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_memblt(rdpInst *inst, uint8 opcode, int x, int y, int cx, int cy,
- RD_HBITMAP src, int srcx, int srcy)
-{
- struct my_bitmap *bitmap;
- struct mod *mod;
- char *bmpdata;
-
- mod = GET_MOD(inst);
- bitmap = (struct my_bitmap *)src;
- mod->server_set_opcode(mod, opcode);
- mod->server_paint_rect(mod, x, y, cx, cy, bitmap->data,
- bitmap->width, bitmap->height, srcx, srcy);
- mod->server_set_opcode(mod, 0xcc);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_triblt(rdpInst *inst, uint8 opcode, int x, int y, int cx, int cy,
- RD_HBITMAP src, int srcx, int srcy, RD_BRUSH *brush,
- uint32 bgcolor, uint32 fgcolor)
-{
- g_writeln("ui_triblt:");
-}
-
-/******************************************************************************/
-static RD_HGLYPH DEFAULT_CC
-ui_create_glyph(rdpInst *inst, int width, int height, uint8 *data)
-{
- g_writeln("ui_create_glyph:");
- return 0;
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_destroy_glyph(rdpInst *inst, RD_HGLYPH glyph)
-{
- g_writeln("ui_destroy_glyph:");
-}
-
-/******************************************************************************/
-static int DEFAULT_CC
-ui_select(rdpInst *inst, int rdp_socket)
-{
- return 1;
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_set_clip(rdpInst *inst, int x, int y, int cx, int cy)
-{
- struct mod *mod;
-
- mod = GET_MOD(inst);
- mod->server_set_clip(mod, x, y, cx, cy);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_reset_clip(rdpInst *inst)
-{
- struct mod *mod;
-
- mod = GET_MOD(inst);
- mod->server_reset_clip(mod);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_resize_window(rdpInst *inst)
-{
- g_writeln("ui_resize_window:");
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_set_cursor(rdpInst *inst, RD_HCURSOR cursor)
-{
- struct mod *mod;
- struct my_cursor *cur;
-
- //g_writeln("ui_set_cursor:");
- mod = GET_MOD(inst);
- cur = (struct my_cursor *)cursor;
-
- if (cur != 0)
- {
- mod->server_set_cursor(mod, cur->hotx, cur->hoty,
- cur->xormask, cur->andmask);
- }
- else
- {
- g_writeln("ui_set_cursor: nil cursor");
- }
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_destroy_cursor(rdpInst *inst, RD_HCURSOR cursor)
-{
- struct my_cursor *cur;
-
- //g_writeln("ui_destroy_cursor:");
- cur = (struct my_cursor *)cursor;
-
- if (cur != 0)
- {
- g_free(cur->andmask);
- g_free(cur->xormask);
- }
-
- g_free(cur);
-}
-
-#define RGB24(_r, _g, _b) \
- (_r << 16) | (_g << 8) | _b;
-
-/******************************************************************************/
-static int
-l_get_pixel(tui8 *data, int x, int y, int width, int height, int bpp)
-{
- int start;
- int shift;
- tui16 *src16;
- tui32 *src32;
- int red, green, blue;
-
- switch (bpp)
- {
- case 1:
- width = (width + 7) / 8;
- start = (y * width) + x / 8;
- shift = x % 8;
- return (data[start] & (0x80 >> shift)) != 0;
- case 8:
- return data[y * width + x];
- case 15:
- case 16:
- src16 = (uint16 *) data;
- return src16[y * width + x];
- case 24:
- data += y * width * 3;
- data += x * 3;
- red = data[0];
- green = data[1];
- blue = data[2];
- return RGB24(red, green, blue);
- case 32:
- src32 = (uint32 *) data;
- return src32[y * width + x];
- default:
- g_writeln("l_get_pixel: unknown bpp %d", bpp);
- break;
- }
-
- return 0;
-}
-
-/******************************************************************************/
-static void
-l_set_pixel(tui8 *data, int x, int y, int width, int height,
- int bpp, int pixel)
-{
- int start;
- int shift;
- int *dst32;
- tui8 *dst8;
-
- if (bpp == 1)
- {
- width = (width + 7) / 8;
- start = (y * width) + x / 8;
- shift = x % 8;
-
- if (pixel)
- {
- data[start] = data[start] | (0x80 >> shift);
- }
- else
- {
- data[start] = data[start] & ~(0x80 >> shift);
- }
- }
- else if (bpp == 24)
- {
- dst8 = data + (y * width + x) * 3;
- *(dst8++) = (pixel >> 16) & 0xff;
- *(dst8++) = (pixel >> 8) & 0xff;
- *(dst8++) = (pixel >> 0) & 0xff;
- }
- else if (bpp == 32)
- {
- dst32 = (int *) data;
- dst32[y * width + x] = pixel;
- }
- else
- {
- g_writeln("l_set_pixel: unknown bpp %d", bpp);
- }
-}
-
-
-/******************************************************************************/
-/* andmask = mask = 32 * 32 / 8
- xormask = data = 32 * 32 * 3 */
-static RD_HCURSOR DEFAULT_CC
-ui_create_cursor(rdpInst *inst, unsigned int x, unsigned int y,
- int width, int height, uint8 *andmask,
- uint8 *xormask, int bpp)
-{
- struct mod *mod;
- struct my_cursor *cur;
- int i;
- int j;
- int jj;
- int apixel;
- int xpixel;
- char *dst;
-
- mod = GET_MOD(inst);
- g_writeln("ui_create_cursor: x %d y %d width %d height %d bpp %d",
- x, y, width, height, bpp);
- cur = (struct my_cursor *)g_malloc(sizeof(struct my_cursor), 1);
- cur->width = width;
- cur->height = height;
- cur->hotx = x;
- cur->hoty = y;
- cur->andmask = g_malloc(32 * 32 * 4, 1);
- cur->xormask = g_malloc(32 * 32 * 4, 1);
-
- for (j = 0; j < height; j++)
- {
- jj = (bpp != 1) ? j : (height - 1) - j;
-
- for (i = 0; i < width; i++)
- {
- apixel = l_get_pixel(andmask, i, jj, width, height, 1);
- xpixel = l_get_pixel(xormask, i, jj, width, height, bpp);
- xpixel = convert_color(bpp, 24, xpixel, mod->cmap);
- l_set_pixel(cur->andmask, i, j, width, height, 1, apixel);
- l_set_pixel(cur->xormask, i, j, width, height, 24, xpixel);
- }
- }
-
- return (RD_HCURSOR)cur;
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_set_null_cursor(rdpInst *inst)
-{
- g_writeln("ui_set_null_cursor:");
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_set_default_cursor(rdpInst *inst)
-{
- g_writeln("ui_set_default_cursor:");
-}
-
-/******************************************************************************/
-static RD_HPALETTE DEFAULT_CC
-ui_create_palette(rdpInst *inst, RD_PALETTE *colors)
-{
- struct mod *mod;
- int index;
- int red;
- int green;
- int blue;
- int pixel;
- int count;
- int *cmap;
-
- mod = GET_MOD(inst);
- g_writeln("ui_create_palette:");
- count = 256;
-
- if (count > colors->count)
- {
- count = colors->count;
- }
-
- cmap = (int *)g_malloc(256 * 4, 1);
-
- for (index = 0; index < count; index++)
- {
- red = colors->entries[index].red;
- green = colors->entries[index].green;
- blue = colors->entries[index].blue;
- pixel = COLOR24RGB(red, green, blue);
- cmap[index] = pixel;
- }
-
- return (RD_HPALETTE)cmap;
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_move_pointer(rdpInst *inst, int x, int y)
-{
- g_writeln("ui_move_pointer:");
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_set_palette(rdpInst *inst, RD_HPALETTE map)
-{
- struct mod *mod;
-
- mod = GET_MOD(inst);
- g_writeln("ui_set_palette:");
- g_memcpy(mod->cmap, map, 256 * 4);
- g_free(map);
-}
-
-/******************************************************************************/
-static RD_HBITMAP DEFAULT_CC
-ui_create_surface(rdpInst *inst, int width, int height, RD_HBITMAP old)
-{
- g_writeln("ui_create_surface:");
- return 0;
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_set_surface(rdpInst *inst, RD_HBITMAP surface)
-{
- g_writeln("ui_set_surface:");
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_destroy_surface(rdpInst *inst, RD_HBITMAP surface)
-{
- g_writeln("ui_destroy_surface:");
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-ui_channel_data(rdpInst *inst, int chan_id, char *data, int data_size,
- int flags, int total_size)
-{
- g_writeln("ui_channel_data:");
-}
-
-/******************************************************************************/
-static RD_BOOL DEFAULT_CC
-ui_authenticate(rdpInst *inst)
-{
- return 1;
-}
-
-/******************************************************************************/
-static int DEFAULT_CC
-ui_decode(rdpInst *inst, uint8 *data, int data_size)
-{
- return 0;
-}
-
-/******************************************************************************/
-static RD_BOOL DEFAULT_CC
-ui_check_certificate(rdpInst *inst, const char *fingerprint,
- const char *subject, const char *issuer, RD_BOOL verified)
-{
- return 1;
-}
-
-/******************************************************************************/
-struct mod *EXPORT_CC
-mod_init(void)
-{
- struct mod *mod;
-
- //g_writeln("1");
- //freerdp_global_init();
- //g_writeln("2");
- mod = (struct mod *)g_malloc(sizeof(struct mod), 1);
- mod->size = sizeof(struct mod);
- mod->version = CURRENT_MOD_VER;
- mod->handle = (tbus)mod;
- mod->mod_connect = lib_mod_connect;
- mod->mod_start = lib_mod_start;
- mod->mod_event = lib_mod_event;
- mod->mod_signal = lib_mod_signal;
- mod->mod_end = lib_mod_end;
- mod->mod_set_param = lib_mod_set_param;
- mod->mod_session_change = mod_session_change;
- mod->mod_get_wait_objs = mod_get_wait_objs;
- mod->mod_check_wait_objs = mod_check_wait_objs;
- mod->settings = (struct rdp_set *)g_malloc(sizeof(struct rdp_set), 1);
-
- mod->settings->width = 1280;
- mod->settings->height = 1024;
- mod->settings->encryption = 1;
- mod->settings->rdp_security = 1;
- mod->settings->tls_security = 1;
- mod->settings->server_depth = 16;
- mod->settings->bitmap_cache = 1;
- mod->settings->bitmap_compression = 1;
- mod->settings->performanceflags =
- PERF_DISABLE_WALLPAPER | PERF_DISABLE_FULLWINDOWDRAG | PERF_DISABLE_MENUANIMATIONS;
- mod->settings->new_cursors = 1;
- mod->settings->rdp_version = 5;
- mod->settings->text_flags = 1;
-
- mod->inst = freerdp_new(mod->settings);
-
- if (mod->inst == 0)
- {
- return 0;
- }
-
- SET_MOD(mod->inst, mod);
- mod->inst->ui_error = ui_error;
- mod->inst->ui_warning = ui_warning;
- mod->inst->ui_unimpl = ui_unimpl;
- mod->inst->ui_begin_update = ui_begin_update;
- mod->inst->ui_end_update = ui_end_update;
- mod->inst->ui_desktop_save = ui_desktop_save;
- mod->inst->ui_desktop_restore = ui_desktop_restore;
- mod->inst->ui_create_bitmap = ui_create_bitmap;
- mod->inst->ui_paint_bitmap = ui_paint_bitmap;
- mod->inst->ui_destroy_bitmap = ui_destroy_bitmap;
- mod->inst->ui_line = ui_line;
- mod->inst->ui_rect = ui_rect;
- mod->inst->ui_polygon = ui_polygon;
- mod->inst->ui_polyline = ui_polyline;
- mod->inst->ui_ellipse = ui_ellipse;
- mod->inst->ui_add_char = ui_add_char;
- mod->inst->ui_draw_text = ui_draw_text;
- mod->inst->ui_start_draw_glyphs = ui_start_draw_glyphs;
- mod->inst->ui_draw_glyph = ui_draw_glyph;
- mod->inst->ui_end_draw_glyphs = ui_end_draw_glyphs;
- mod->inst->ui_get_toggle_keys_state = ui_get_toggle_keys_state;
- mod->inst->ui_bell = ui_bell;
- mod->inst->ui_destblt = ui_destblt;
- mod->inst->ui_patblt = ui_patblt;
- mod->inst->ui_screenblt = ui_screenblt;
- mod->inst->ui_memblt = ui_memblt;
- mod->inst->ui_triblt = ui_triblt;
- mod->inst->ui_create_glyph = ui_create_glyph;
- mod->inst->ui_destroy_glyph = ui_destroy_glyph;
- mod->inst->ui_select = ui_select;
- mod->inst->ui_set_clip = ui_set_clip;
- mod->inst->ui_reset_clip = ui_reset_clip;
- mod->inst->ui_resize_window = ui_resize_window;
- mod->inst->ui_set_cursor = ui_set_cursor;
- mod->inst->ui_destroy_cursor = ui_destroy_cursor;
- mod->inst->ui_create_cursor = ui_create_cursor;
- mod->inst->ui_set_null_cursor = ui_set_null_cursor;
- mod->inst->ui_set_default_cursor = ui_set_default_cursor;
- mod->inst->ui_create_palette = ui_create_palette;
- mod->inst->ui_move_pointer = ui_move_pointer;
- mod->inst->ui_set_palette = ui_set_palette;
- mod->inst->ui_create_surface = ui_create_surface;
- mod->inst->ui_set_surface = ui_set_surface;
- mod->inst->ui_destroy_surface = ui_destroy_surface;
- mod->inst->ui_channel_data = ui_channel_data;
-
- mod->inst->ui_authenticate = ui_authenticate;
- mod->inst->ui_decode = ui_decode;
- mod->inst->ui_check_certificate = ui_check_certificate;
-
- return mod;
-}
-
-/******************************************************************************/
-int EXPORT_CC
-mod_exit(struct mod *mod)
-{
- if (mod == 0)
- {
- return 0;
- }
-
- freerdp_free(mod->inst);
- g_free(mod->settings);
- g_free(mod);
- //freerdp_global_finish();
- return 0;
-}
diff --git a/freerdp/xrdp-freerdp.h b/freerdp/xrdp-freerdp.h
deleted file mode 100644
index b62c8206..00000000
--- a/freerdp/xrdp-freerdp.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * xrdp: A Remote Desktop Protocol server.
- *
- * Copyright (C) Jay Sorg 2004-2012
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * freerdp wrapper
- */
-
-/* include other h files */
-#include "arch.h"
-#include "parse.h"
-#include "os_calls.h"
-#include "defines.h"
-
-/* this is the freerdp main header */
-#include <freerdp/freerdp.h>
-
-#define CURRENT_MOD_VER 2
-
-struct mod
-{
- int size; /* size of this struct */
- int version; /* internal version */
- /* client functions */
- int (*mod_start)(struct mod* v, int w, int h, int bpp);
- int (*mod_connect)(struct mod* v);
- int (*mod_event)(struct mod* v, int msg, long param1, long param2,
- long param3, long param4);
- int (*mod_signal)(struct mod* v);
- int (*mod_end)(struct mod* v);
- int (*mod_set_param)(struct mod* v, char* name, char* value);
- int (*mod_session_change)(struct mod* v, int, int);
- int (*mod_get_wait_objs)(struct mod* v, tbus* read_objs, int* rcount,
- tbus* write_objs, int* wcount, int* timeout);
- int (*mod_check_wait_objs)(struct mod* v);
- long mod_dumby[100 - 9]; /* align, 100 minus the number of mod
- functions above */
- /* server functions */
- int (*server_begin_update)(struct mod* v);
- int (*server_end_update)(struct mod* v);
- int (*server_fill_rect)(struct mod* v, int x, int y, int cx, int cy);
- int (*server_screen_blt)(struct mod* v, int x, int y, int cx, int cy,
- int srcx, int srcy);
- int (*server_paint_rect)(struct mod* v, int x, int y, int cx, int cy,
- char* data, int width, int height, int srcx, int srcy);
- int (*server_set_cursor)(struct mod* v, int x, int y, char* data, char* mask);
- int (*server_palette)(struct mod* v, int* palette);
- int (*server_msg)(struct mod* v, char* msg, int code);
- int (*server_is_term)(struct mod* v);
- int (*server_set_clip)(struct mod* v, int x, int y, int cx, int cy);
- int (*server_reset_clip)(struct mod* v);
- int (*server_set_fgcolor)(struct mod* v, int fgcolor);
- int (*server_set_bgcolor)(struct mod* v, int bgcolor);
- int (*server_set_opcode)(struct mod* v, int opcode);
- int (*server_set_mixmode)(struct mod* v, int mixmode);
- int (*server_set_brush)(struct mod* v, int x_orgin, int y_orgin,
- int style, char* pattern);
- int (*server_set_pen)(struct mod* v, int style,
- int width);
- int (*server_draw_line)(struct mod* v, int x1, int y1, int x2, int y2);
- int (*server_add_char)(struct mod* v, int font, int charactor,
- int offset, int baseline,
- int width, int height, char* data);
- int (*server_draw_text)(struct mod* v, int font,
- int flags, int mixmode, int clip_left, int clip_top,
- int clip_right, int clip_bottom,
- int box_left, int box_top,
- int box_right, int box_bottom,
- int x, int y, char* data, int data_len);
- int (*server_reset)(struct mod* v, int width, int height, int bpp);
- int (*server_query_channel)(struct mod* v, int index,
- char* channel_name,
- int* channel_flags);
- int (*server_get_channel_id)(struct mod* v, char* name);
- int (*server_send_to_channel)(struct mod* v, int channel_id,
- char* data, int data_len,
- int total_data_len, int flags);
- int (*server_bell_trigger)(struct mod* v);
- long server_dumby[100 - 25]; /* align, 100 minus the number of server
- functions above */
- /* common */
- tbus handle; /* pointer to self as long */
- tbus wm;
- tbus painter;
- int sck;
- /* mod data */
- int width;
- int height;
- int bpp;
- struct rdp_set* settings;
- struct rdp_inst* inst;
- int cmap[256];
-};
diff --git a/freerdp1/Makefile.am b/freerdp1/Makefile.am
deleted file mode 100644
index d1d49440..00000000
--- a/freerdp1/Makefile.am
+++ /dev/null
@@ -1,28 +0,0 @@
-EXTRA_DIST = xrdp-freerdp.h
-EXTRA_DEFINES =
-
-if XRDP_DEBUG
-EXTRA_DEFINES += -DXRDP_DEBUG
-else
-EXTRA_DEFINES += -DXRDP_NODEBUG
-endif
-
-AM_CFLAGS = \
- -DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
- -DXRDP_SBIN_PATH=\"${sbindir}\" \
- -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
- -DXRDP_PID_PATH=\"${localstatedir}/run\" \
- $(EXTRA_DEFINES)
-
-INCLUDES = \
- -I$(top_srcdir)/common \
- $(FREERDP_CFLAGS)
-
-lib_LTLIBRARIES = \
- libxrdpfreerdp1.la
-
-libxrdpfreerdp1_la_SOURCES = xrdp-freerdp.c xrdp-color.c
-
-libxrdpfreerdp1_la_LIBADD = \
- $(top_builddir)/common/libcommon.la \
- $(FREERDP_LIBS)
diff --git a/freerdp1/xrdp-color.c b/freerdp1/xrdp-color.c
deleted file mode 100644
index 6b99140a..00000000
--- a/freerdp1/xrdp-color.c
+++ /dev/null
@@ -1,313 +0,0 @@
-/**
- * FreeRDP: A Remote Desktop Protocol Server
- * freerdp wrapper
- *
- * Copyright 2011-2012 Jay Sorg
- *
- * 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.
- */
-
-#include "xrdp-freerdp.h"
-
-char *APP_CC
-convert_bitmap(int in_bpp, int out_bpp, char *bmpdata,
- int width, int height, int *palette)
-{
- char *out;
- char *src;
- char *dst;
- int i;
- int j;
- int red;
- int green;
- int blue;
- int pixel;
-
- if ((in_bpp == 8) && (out_bpp == 8))
- {
- out = (char *)g_malloc(width * height, 0);
- src = bmpdata;
- dst = out;
-
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- pixel = *((tui8 *)src);
- pixel = palette[pixel];
- SPLITCOLOR32(red, green, blue, pixel);
- pixel = COLOR8(red, green, blue);
- *dst = pixel;
- src++;
- dst++;
- }
- }
-
- return out;
- }
-
- if ((in_bpp == 8) && (out_bpp == 16))
- {
- out = (char *)g_malloc(width * height * 2, 0);
- src = bmpdata;
- dst = out;
-
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- pixel = *((tui8 *)src);
- pixel = palette[pixel];
- SPLITCOLOR32(red, green, blue, pixel);
- pixel = COLOR16(red, green, blue);
- *((tui16 *)dst) = pixel;
- src++;
- dst += 2;
- }
- }
-
- return out;
- }
-
- if ((in_bpp == 8) && (out_bpp == 24))
- {
- out = (char *)g_malloc(width * height * 4, 0);
- src = bmpdata;
- dst = out;
-
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- pixel = *((tui8 *)src);
- pixel = palette[pixel];
- SPLITCOLOR32(red, green, blue, pixel);
- pixel = COLOR24RGB(red, green, blue);
- *((tui32 *)dst) = pixel;
- src++;
- dst += 4;
- }
- }
-
- return out;
- }
-
- if ((in_bpp == 15) && (out_bpp == 16))
- {
- out = (char *)g_malloc(width * height * 2, 0);
- src = bmpdata;
- dst = out;
-
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- pixel = *((tui16 *)src);
- SPLITCOLOR15(red, green, blue, pixel);
- pixel = COLOR16(red, green, blue);
- *((tui16 *)dst) = pixel;
- src += 2;
- dst += 2;
- }
- }
-
- return out;
- }
-
- if ((in_bpp == 15) && (out_bpp == 24))
- {
- out = (char *)g_malloc(width * height * 4, 0);
- src = bmpdata;
- dst = out;
-
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- pixel = *((tui16 *)src);
- SPLITCOLOR15(red, green, blue, pixel);
- pixel = COLOR24RGB(red, green, blue);
- *((tui32 *)dst) = pixel;
- src += 2;
- dst += 4;
- }
- }
-
- return out;
- }
-
- if ((in_bpp == 15) && (out_bpp == 15))
- {
- return bmpdata;
- }
-
- if ((in_bpp == 16) && (out_bpp == 16))
- {
- return bmpdata;
- }
-
- if ((in_bpp == 16) && (out_bpp == 24))
- {
- out = (char *)g_malloc(width * height * 4, 0);
- src = bmpdata;
- dst = out;
-
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- pixel = *((tui16 *)src);
- SPLITCOLOR16(red, green, blue, pixel);
- pixel = COLOR24RGB(red, green, blue);
- *((tui32 *)dst) = pixel;
- src += 2;
- dst += 4;
- }
- }
-
- return out;
- }
-
- if ((in_bpp == 24) && (out_bpp == 24))
- {
- out = (char *)g_malloc(width * height * 4, 0);
- src = bmpdata;
- dst = out;
-
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- blue = *((tui8 *)src);
- src++;
- green = *((tui8 *)src);
- src++;
- red = *((tui8 *)src);
- src++;
- pixel = COLOR24RGB(red, green, blue);
- *((tui32 *)dst) = pixel;
- dst += 4;
- }
- }
-
- return out;
- }
-
- if ((in_bpp == 32) && (out_bpp == 24))
- {
- return bmpdata;
- }
-
- if ((in_bpp == 32) && (out_bpp == 32))
- {
- return bmpdata;
- }
-
- g_writeln("convert_bitmap: error unknown conversion from %d to %d",
- in_bpp, out_bpp);
- return 0;
-}
-
-/*****************************************************************************/
-/* returns color or 0 */
-int APP_CC
-convert_color(int in_bpp, int out_bpp, int in_color, int *palette)
-{
- int pixel;
- int red;
- int green;
- int blue;
-
- if ((in_bpp == 1) && (out_bpp == 24))
- {
- pixel = in_color == 0 ? 0 : 0xffffff;
- return pixel;
- }
-
- if ((in_bpp == 8) && (out_bpp == 8))
- {
- pixel = palette[in_color];
- SPLITCOLOR32(red, green, blue, pixel);
- pixel = COLOR8(red, green, blue);
- return pixel;
- }
-
- if ((in_bpp == 8) && (out_bpp == 16))
- {
- pixel = palette[in_color];
- SPLITCOLOR32(red, green, blue, pixel);
- pixel = COLOR16(red, green, blue);
- return pixel;
- }
-
- if ((in_bpp == 8) && (out_bpp == 24))
- {
- pixel = palette[in_color];
- SPLITCOLOR32(red, green, blue, pixel);
- pixel = COLOR24BGR(red, green, blue);
- return pixel;
- }
-
- if ((in_bpp == 15) && (out_bpp == 16))
- {
- pixel = in_color;
- SPLITCOLOR15(red, green, blue, pixel);
- pixel = COLOR16(red, green, blue);
- return pixel;
- }
-
- if ((in_bpp == 15) && (out_bpp == 24))
- {
- pixel = in_color;
- SPLITCOLOR15(red, green, blue, pixel);
- pixel = COLOR24BGR(red, green, blue);
- return pixel;
- }
-
- if ((in_bpp == 15) && (out_bpp == 15))
- {
- return in_color;
- }
-
- if ((in_bpp == 16) && (out_bpp == 16))
- {
- return in_color;
- }
-
- if ((in_bpp == 16) && (out_bpp == 24))
- {
- pixel = in_color;
- SPLITCOLOR16(red, green, blue, pixel);
- pixel = COLOR24BGR(red, green, blue);
- return pixel;
- }
-
- if ((in_bpp == 24) && (out_bpp == 24))
- {
- return in_color;
- }
-
- if ((in_bpp == 32) && (out_bpp == 24))
- {
- return in_color;
- }
-
- if ((in_bpp == 32) && (out_bpp == 32))
- {
- return in_color;
- }
-
- g_writeln("convert_color: error unknown conversion from %d to %d",
- in_bpp, out_bpp);
- return 0;
-}
diff --git a/freerdp1/xrdp-color.h b/freerdp1/xrdp-color.h
deleted file mode 100644
index 6a3f7362..00000000
--- a/freerdp1/xrdp-color.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * FreeRDP: A Remote Desktop Protocol Server
- * freerdp wrapper
- *
- * Copyright 2011-2012 Jay Sorg
- *
- * 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.
- */
-
-#ifndef __XRDP_COLOR_H
-#define __XRDP_COLOR_H
-
-char* APP_CC
-convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
- int width, int height, int* palette);
-int APP_CC
-convert_color(int in_bpp, int out_bpp, int in_color, int* palette);
-
-#endif
diff --git a/freerdp1/xrdp-freerdp.c b/freerdp1/xrdp-freerdp.c
deleted file mode 100644
index ca4fe31f..00000000
--- a/freerdp1/xrdp-freerdp.c
+++ /dev/null
@@ -1,1858 +0,0 @@
-/**
- * FreeRDP: A Remote Desktop Protocol Server
- * freerdp wrapper
- *
- * Copyright 2011-2012 Jay Sorg
- *
- * 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.
- */
-
-#include <freerdp/settings.h>
-#include <X11/Xlib.h>
-#include "xrdp-freerdp.h"
-#include "xrdp-color.h"
-#include "xrdp_rail.h"
-#include "log.h"
-
-#ifdef XRDP_DEBUG
-#define LOG_LEVEL 99
-#else
-#define LOG_LEVEL 0
-#endif
-
-#define LLOG(_level, _args) \
- do { if (_level < LOG_LEVEL) { g_write _args ; } } while (0)
-#define LLOGLN(_level, _args) \
- do { if (_level < LOG_LEVEL) { g_writeln _args ; } } while (0)
-
-struct mod_context
-{
- rdpContext _p;
- struct mod *modi;
-};
-typedef struct mod_context modContext;
-
-void verifyColorMap(struct mod *mod)
-{
- int i ;
- for( i = 0 ;i<255 ; i++)
- {
- if(mod->colormap[i]!=0)
- {
- return ;
- }
- }
- LLOGLN(0, ("The colormap is all NULL\n"));
-}
-/*****************************************************************************/
-/* return error */
-static int DEFAULT_CC
-lxrdp_start(struct mod *mod, int w, int h, int bpp)
-{
- rdpSettings *settings;
-
- LLOGLN(10, ("lxrdp_start: w %d h %d bpp %d", w, h, bpp));
- settings = mod->inst->settings;
- settings->DesktopWidth = w;
- settings->DesktopHeight = h;
- settings->ColorDepth = bpp;
- mod->bpp = bpp;
- // TODO what does this really become
- settings->DisableEncryption = 1; // settings->encryption = 1;
- settings->TlsSecurity = 1;
- settings->NlaSecurity = 0;
- settings->RdpSecurity = 1;
-
- return 0;
-}
-
-/******************************************************************************/
-/* return error */
-static int DEFAULT_CC
-lxrdp_connect(struct mod *mod)
-{
- BOOL ok;
-
- LLOGLN(10, ("lxrdp_connect:"));
-
- ok = freerdp_connect(mod->inst);
- LLOGLN(0, ("lxrdp_connect: freerdp_connect returned %d", ok));
-
- if (!ok)
- {
- LLOGLN(0, ("Failure to connect"));
-#ifdef ERRORSTART
-
- if (connectErrorCode != 0)
- {
- char buf[128];
-
- if (connectErrorCode < ERRORSTART)
- {
- if (strerror_r(connectErrorCode, buf, 128) != 0)
- {
- g_snprintf(buf, 128, "Errorcode from connect : %d", connectErrorCode);
- }
- }
- else
- {
- switch (connectErrorCode)
- {
- case PREECONNECTERROR:
- g_snprintf(buf, 128, "The error code from connect is "
- "PREECONNECTERROR");
- break;
- case UNDEFINEDCONNECTERROR:
- g_snprintf(buf, 128, "The error code from connect is "
- "UNDEFINEDCONNECTERROR");
- break;
- case POSTCONNECTERROR:
- g_snprintf(buf, 128, "The error code from connect is "
- "POSTCONNECTERROR");
- break;
- case DNSERROR:
- g_snprintf(buf, 128, "The DNS system generated an error");
- break;
- case DNSNAMENOTFOUND:
- g_snprintf(buf, 128, "The DNS system could not find the "
- "specified name");
- break;
- case CONNECTERROR:
- g_snprintf(buf, 128, "A general connect error was returned");
- break;
- case MCSCONNECTINITIALERROR:
- g_snprintf(buf, 128, "The error code from connect is "
- "MCSCONNECTINITIALERROR");
- break;
- case TLSCONNECTERROR:
- g_snprintf(buf, 128, "Error in TLS handshake");
- break;
- case AUTHENTICATIONERROR:
- g_snprintf(buf, 128, "Authentication error check your password "
- "and username");
- break;
- default:
- g_snprintf(buf, 128, "Unhandled Errorcode from connect : %d",
- connectErrorCode);
- break;
- }
- }
- log_message(LOG_LEVEL_INFO,buf);
- mod->server_msg(mod, buf, 0);
- }
-
-#endif
- log_message(LOG_LEVEL_INFO,"freerdp_connect Failed to destination :%s:%d",mod->inst->settings->ServerHostname,mod->inst->settings->ServerPort);
- return 1;
- }
- else
- {
- log_message(LOG_LEVEL_INFO,"freerdp_connect returned Success to destination :%s:%d",mod->inst->settings->ServerHostname,mod->inst->settings->ServerPort);
- }
-
- return 0;
-}
-
-/******************************************************************************/
-/* return error */
-static int DEFAULT_CC
-lxrdp_event(struct mod *mod, int msg, long param1, long param2,
- long param3, long param4)
-{
- int x;
- int y;
- int flags;
- int size;
- int total_size;
- int chanid;
- int lchid;
- char *data;
-
- LLOGLN(12, ("lxrdp_event: msg %d", msg));
-
- switch (msg)
- {
- case 15: /* key down */
- mod->inst->input->KeyboardEvent(mod->inst->input, param4, param3);
- break;
- case 16: /* key up */
- mod->inst->input->KeyboardEvent(mod->inst->input, param4, param3);
- break;
- case 17: /*Synchronize*/
- LLOGLN(11, ("Synchronized event handled"));
- mod->inst->input->SynchronizeEvent(mod->inst->input, 0);
- break;
- case 100: /* mouse move */
- LLOGLN(12, ("mouse move %d %d", param1, param2));
- x = param1;
- y = param2;
- flags = PTR_FLAGS_MOVE;
- mod->inst->input->MouseEvent(mod->inst->input, flags, x, y);
- break;
- case 101: /* left button up */
- LLOGLN(12, ("left button up %d %d", param1, param2));
- x = param1;
- y = param2;
- flags = PTR_FLAGS_BUTTON1;
- mod->inst->input->MouseEvent(mod->inst->input, flags, x, y);
- break;
- case 102: /* left button down */
- LLOGLN(12, ("left button down %d %d", param1, param2));
- x = param1;
- y = param2;
- flags = PTR_FLAGS_BUTTON1 | PTR_FLAGS_DOWN;
- mod->inst->input->MouseEvent(mod->inst->input, flags, x, y);
- break;
- case 103: /* right button up */
- LLOGLN(12, ("right button up %d %d", param1, param2));
- x = param1;
- y = param2;
- flags = PTR_FLAGS_BUTTON2;
- mod->inst->input->MouseEvent(mod->inst->input, flags, x, y);
- break;
- case 104: /* right button down */
- LLOGLN(12, ("right button down %d %d", param1, param2));
- x = param1;
- y = param2;
- flags = PTR_FLAGS_BUTTON2 | PTR_FLAGS_DOWN;
- mod->inst->input->MouseEvent(mod->inst->input, flags, x, y);
- break;
- case 105: /* middle button up */
- LLOGLN(12, ("middle button up %d %d", param1, param2));
- x = param1;
- y = param2;
- flags = PTR_FLAGS_BUTTON3;
- mod->inst->input->MouseEvent(mod->inst->input, flags, x, y);
- break;
- case 106: /* middle button down */
- LLOGLN(12, ("middle button down %d %d", param1, param2));
- x = param1;
- y = param2;
- flags = PTR_FLAGS_BUTTON3 | PTR_FLAGS_DOWN;
- mod->inst->input->MouseEvent(mod->inst->input, flags, x, y);
- break;
- case 107: /* wheel up */
- flags = PTR_FLAGS_WHEEL | 0x0078;
- mod->inst->input->MouseEvent(mod->inst->input, flags, 0, 0);
- case 108:
- break;
- case 109: /* wheel down */
- flags = PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x0088;
- mod->inst->input->MouseEvent(mod->inst->input, flags, 0, 0);
- case 110:
- break;
- case 200:
- LLOGLN(12, ("Invalidate request sent from client"));
- RECTANGLE_16 *rectangle = (RECTANGLE_16 *) g_malloc(sizeof(RECTANGLE_16), 0);
- /* The parameters are coded as follows param1 = MAKELONG(y, x), param2 =MAKELONG(h, w)
- * #define MAKELONG(lo, hi) ((((hi) & 0xffff) << 16) | ((lo) & 0xffff))
- */
- rectangle->left = (param1 >> 16) & 0xffff;
- rectangle->top = param1 & 0xffff;
- rectangle->right = (((param2 >> 16) & 0xffff) + rectangle->left) - 1;
- rectangle->bottom = ((param2 & 0xffff) + rectangle->top) - 1;
-
- if (mod->inst->settings->RefreshRect)
- {
- if (mod->inst->update != NULL)
- {
- if (mod->inst->update->RefreshRect != NULL)
- {
- if (mod->inst->context != NULL)
- {
- LLOGLN(0, ("update rectangle left: %d top: %d bottom: %d right: %d",
- rectangle->left, rectangle->top, rectangle->bottom, rectangle->right));
- mod->inst->update->RefreshRect(mod->inst->context, 1, rectangle);
- }
- else
- {
- LLOGLN(0, ("Invalidate request -The context is null"));
- }
- }
- else
- {
- LLOGLN(0, ("Invalidate request - RefreshRect is Null"));
- }
- }
- else
- {
- LLOGLN(0, ("Invalidate request -the update pointer is null"));
- }
- }
- else
- {
- LLOGLN(0, ("Invalidate request - warning - update rectangle is disabled"));
- }
-
- g_free(rectangle);
- break;
- case 0x5555:
- chanid = LOWORD(param1);
- flags = HIWORD(param1);
- size = (int)param2;
- data = (char *)param3;
- total_size = (int)param4;
- LLOGLN(12, ("lxrdp_event: client to server flags %d", flags));
-
- if ((chanid < 0) || (chanid >= mod->inst->settings->ChannelDefArraySize))
- {
- LLOGLN(0, ("lxrdp_event: error chanid %d", chanid));
- break;
- }
-
- lchid = mod->inst->settings->ChannelDefArray[chanid].ChannelId;
-
- switch (flags & 3)
- {
- case 3:
- mod->inst->SendChannelData(mod->inst, lchid, (tui8 *)data, total_size);
- break;
- case 2:
- /* end */
- g_memcpy(mod->chan_buf + mod->chan_buf_valid, data, size);
- mod->chan_buf_valid += size;
- mod->inst->SendChannelData(mod->inst, lchid, (tui8 *)(mod->chan_buf),
- total_size);
- g_free(mod->chan_buf);
- mod->chan_buf = 0;
- mod->chan_buf_bytes = 0;
- mod->chan_buf_valid = 0;
- break;
- case 1:
- /* start */
- g_free(mod->chan_buf);
- mod->chan_buf = (char *)g_malloc(total_size, 0);
- mod->chan_buf_bytes = total_size;
- mod->chan_buf_valid = 0;
- g_memcpy(mod->chan_buf + mod->chan_buf_valid, data, size);
- mod->chan_buf_valid += size;
- break;
- default:
- /* middle */
- g_memcpy(mod->chan_buf + mod->chan_buf_valid, data, size);
- mod->chan_buf_valid += size;
- break;
- }
-
- break;
- default:
- LLOGLN(0, ("Unhandled message type in eventhandler %d", msg));
- break;
- }
-
- return 0;
-}
-
-/******************************************************************************/
-/* return error */
-static int DEFAULT_CC
-lxrdp_signal(struct mod *mod)
-{
- LLOGLN(10, ("lxrdp_signal:"));
- return 0;
-}
-
-/******************************************************************************/
-/* return error */
-static int DEFAULT_CC
-lxrdp_end(struct mod *mod)
-{
- int i;
- int j;
-
- for (j = 0; j < 4; j++)
- {
- for (i = 0; i < 4096; i++)
- {
- g_free(mod->bitmap_cache[j][i].data);
- }
- }
-
- for (i = 0; i < 64; i++)
- {
- if (mod->brush_cache[i].data != mod->brush_cache[i].b8x8)
- {
- g_free(mod->brush_cache[i].data);
- }
- }
-
- LLOGLN(10, ("lxrdp_end:"));
- return 0;
-}
-
-/******************************************************************************/
-/* return error */
-static int DEFAULT_CC
-lxrdp_set_param(struct mod *mod, char *name, char *value)
-{
- rdpSettings *settings;
-
- LLOGLN(10, ("lxrdp_set_param: name [%s] value [%s]", name, value));
- settings = mod->inst->settings;
-
- LLOGLN(10, ("%p %d", settings->ServerHostname, settings->DisableEncryption));
-
- if (g_strcmp(name, "hostname") == 0)
- {
- }
- else if (g_strcmp(name, "ip") == 0)
- {
- settings->ServerHostname = g_strdup(value);
- }
- else if (g_strcmp(name, "port") == 0)
- {
- settings->ServerPort = g_atoi(value);
- }
- else if (g_strcmp(name, "keylayout") == 0)
- {
- }
- else if (g_strcmp(name, "name") == 0)
- {
- }
- else if (g_strcmp(name, "lib") == 0)
- {
- }
- else if (g_strcmp(name, "username") == 0)
- {
- g_strncpy(mod->username, value, 255);
- }
- else if (g_strcmp(name, "password") == 0)
- {
- g_strncpy(mod->password, value, 255);
- }
- else if (g_strcmp(name, "client_info") == 0)
- {
- g_memcpy(&(mod->client_info), value, sizeof(mod->client_info));
- /* This is a Struct and cannot be printed in next else*/
- LLOGLN(10, ("Client_info struct ignored"));
- }
- else
- {
- LLOGLN(0, ("lxrdp_set_param: unknown name [%s] value [%s]", name, value));
- }
-
- return 0;
-}
-
-/******************************************************************************/
-static int DEFAULT_CC
-lxrdp_session_change(struct mod *mod, int a, int b)
-{
- LLOGLN(0, ("lxrdp_session_change: - no code here"));
- return 0;
-}
-
-/******************************************************************************/
-static int DEFAULT_CC
-lxrdp_get_wait_objs(struct mod *mod, tbus *read_objs, int *rcount,
- tbus *write_objs, int *wcount, int *timeout)
-{
- void **rfds;
- void **wfds;
- BOOL ok;
-
- LLOGLN(12, ("lxrdp_get_wait_objs:"));
- rfds = (void **)read_objs;
- wfds = (void **)write_objs;
- ok = freerdp_get_fds(mod->inst, rfds, rcount, wfds, wcount);
-
- if (!ok)
- {
- LLOGLN(0, ("lxrdp_get_wait_objs: freerdp_get_fds failed"));
- return 1;
- }
-
- return 0;
-}
-
-/******************************************************************************/
-static int DEFAULT_CC
-lxrdp_check_wait_objs(struct mod *mod)
-{
- BOOL ok;
-
- LLOGLN(12, ("lxrdp_check_wait_objs:"));
- ok = freerdp_check_fds(mod->inst);
-
- if (!ok)
- {
- LLOGLN(0, ("lxrdp_check_wait_objs: freerdp_check_fds failed"));
- return 1;
- }
-
- return 0;
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_begin_paint(rdpContext *context)
-{
- struct mod *mod;
-
- LLOGLN(10, ("lfreerdp_begin_paint:"));
- mod = ((struct mod_context *)context)->modi;
- mod->server_begin_update(mod);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_end_paint(rdpContext *context)
-{
- struct mod *mod;
-
- LLOGLN(10, ("lfreerdp_end_paint:"));
- mod = ((struct mod_context *)context)->modi;
- mod->server_end_update(mod);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_set_bounds(rdpContext *context, rdpBounds *bounds)
-{
- struct mod *mod;
- int x;
- int y;
- int cx;
- int cy;
-
- LLOGLN(10, ("lfreerdp_set_bounds: %p", bounds));
- mod = ((struct mod_context *)context)->modi;
-
- if (bounds != 0)
- {
- x = bounds->left;
- y = bounds->top;
- cx = (bounds->right - bounds->left) + 1;
- cy = (bounds->bottom - bounds->top) + 1;
- mod->server_set_clip(mod, x, y, cx, cy);
- }
- else
- {
- mod->server_reset_clip(mod);
- }
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_bitmap_update(rdpContext *context, BITMAP_UPDATE *bitmap)
-{
- struct mod *mod;
- int index;
- int cx;
- int cy;
- int server_bpp;
- int server_Bpp;
- int client_bpp;
- int j;
- int line_bytes;
- BITMAP_DATA *bd;
- char *dst_data;
- char *dst_data1;
- char *src;
- char *dst;
-
- mod = ((struct mod_context *)context)->modi;
- LLOGLN(10, ("lfreerdp_bitmap_update: %d %d", bitmap->number, bitmap->count));
-
- server_bpp = mod->inst->settings->ColorDepth;
- server_Bpp = (server_bpp + 7) / 8;
- client_bpp = mod->bpp;
-
- for (index = 0; index < bitmap->number; index++)
- {
- bd = &bitmap->rectangles[index];
- cx = (bd->destRight - bd->destLeft) + 1;
- cy = (bd->destBottom - bd->destTop) + 1;
- line_bytes = server_Bpp * bd->width;
- dst_data = (char *)g_malloc(bd->height * line_bytes + 16, 0);
-
- if (bd->compressed)
- {
- LLOGLN(20,("decompress size : %d",bd->bitmapLength));
- if(!bitmap_decompress(bd->bitmapDataStream, (tui8 *)dst_data, bd->width,
- bd->height, bd->bitmapLength, server_bpp, server_bpp)){
- LLOGLN(0,("Failure to decompress the bitmap"));
- }
- }
- else
- {
- /* bitmap is upside down */
- LLOGLN(10,("bitmap upside down"));
- src = (char *)(bd->bitmapDataStream);
- dst = dst_data + bd->height * line_bytes;
-
- for (j = 0; j < bd->height; j++)
- {
- dst -= line_bytes;
- g_memcpy(dst, src, line_bytes);
- src += line_bytes;
- }
- }
-
- dst_data1 = convert_bitmap(server_bpp, client_bpp, dst_data,
- bd->width, bd->height, mod->colormap);
- mod->server_paint_rect(mod, bd->destLeft, bd->destTop, cx, cy,
- dst_data1, bd->width, bd->height, 0, 0);
-
- if (dst_data1 != dst_data)
- {
- g_free(dst_data1);
- }
-
- g_free(dst_data);
- }
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_dst_blt(rdpContext *context, DSTBLT_ORDER *dstblt)
-{
- struct mod *mod;
-
- mod = ((struct mod_context *)context)->modi;
- LLOGLN(10, ("lfreerdp_dst_blt:"));
- mod->server_set_opcode(mod, dstblt->bRop);
- mod->server_fill_rect(mod, dstblt->nLeftRect, dstblt->nTopRect,
- dstblt->nWidth, dstblt->nHeight);
- mod->server_set_opcode(mod, 0xcc);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_pat_blt(rdpContext *context, PATBLT_ORDER *patblt)
-{
- struct mod *mod;
- int idx;
- int fgcolor;
- int bgcolor;
- int server_bpp;
- int client_bpp;
- struct brush_item *bi;
-
- mod = ((struct mod_context *)context)->modi;
- LLOGLN(10, ("lfreerdp_pat_blt:"));
-
- server_bpp = mod->inst->settings->ColorDepth;
- client_bpp = mod->bpp;
- LLOGLN(0, ("lfreerdp_pat_blt: bpp %d %d", server_bpp, client_bpp));
-
- fgcolor = convert_color(server_bpp, client_bpp,
- patblt->foreColor, mod->colormap);
- bgcolor = convert_color(server_bpp, client_bpp,
- patblt->backColor, mod->colormap);
-
- if(fgcolor==bgcolor)
- {
- LLOGLN(0, ("Warning same color on both bg and fg"));
- }
- mod->server_set_mixmode(mod, 1);
- mod->server_set_opcode(mod, patblt->bRop);
- mod->server_set_fgcolor(mod, fgcolor);
- mod->server_set_bgcolor(mod, bgcolor);
-
- if (patblt->brush.style & 0x80)
- {
- idx = patblt->brush.hatch;
-
- if ((idx < 0) || (idx >= 64))
- {
- LLOGLN(0, ("lfreerdp_pat_blt: error"));
- return;
- }
-
- bi = mod->brush_cache + idx;
- mod->server_set_brush(mod, patblt->brush.x, patblt->brush.y,
- 3, bi->b8x8);
- }
- else
- {
- mod->server_set_brush(mod, patblt->brush.x, patblt->brush.y,
- patblt->brush.style,
- (char *)(patblt->brush.p8x8));
- }
-
- mod->server_fill_rect(mod, patblt->nLeftRect, patblt->nTopRect,
- patblt->nWidth, patblt->nHeight);
- mod->server_set_opcode(mod, 0xcc);
- mod->server_set_mixmode(mod, 0);
-
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_scr_blt(rdpContext *context, SCRBLT_ORDER *scrblt)
-{
- struct mod *mod;
-
- mod = ((struct mod_context *)context)->modi;
- LLOGLN(10, ("lfreerdp_scr_blt:"));
- mod->server_set_opcode(mod, scrblt->bRop);
- mod->server_screen_blt(mod, scrblt->nLeftRect, scrblt->nTopRect,
- scrblt->nWidth, scrblt->nHeight,
- scrblt->nXSrc, scrblt->nYSrc);
- mod->server_set_opcode(mod, 0xcc);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_opaque_rect(rdpContext *context, OPAQUE_RECT_ORDER *opaque_rect)
-{
- struct mod *mod;
- int server_bpp;
- int client_bpp;
- int fgcolor;
-
- mod = ((struct mod_context *)context)->modi;
- LLOGLN(10, ("lfreerdp_opaque_rect:"));
- server_bpp = mod->inst->settings->ColorDepth;
- client_bpp = mod->bpp;
- fgcolor = convert_color(server_bpp, client_bpp,
- opaque_rect->color, mod->colormap);
- mod->server_set_fgcolor(mod, fgcolor);
- mod->server_fill_rect(mod, opaque_rect->nLeftRect, opaque_rect->nTopRect,
- opaque_rect->nWidth, opaque_rect->nHeight);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_mem_blt(rdpContext *context, MEMBLT_ORDER *memblt)
-{
- int id;
- int idx;
- struct mod *mod;
- struct bitmap_item *bi;
-
- mod = ((struct mod_context *)context)->modi;
- LLOGLN(10, ("lfreerdp_mem_blt: cacheId %d cacheIndex %d",
- memblt->cacheId, memblt->cacheIndex));
-
- id = memblt->cacheId;
- idx = memblt->cacheIndex;
-
- if (idx == 32767) /* BITMAPCACHE_WAITING_LIST_INDEX */
- {
- idx = 4096 - 1;
- }
-
- if ((id < 0) || (id >= 4))
- {
- LLOGLN(0, ("lfreerdp_mem_blt: bad id [%d]", id));
- return;
- }
-
- if ((idx < 0) || (idx >= 4096))
- {
- LLOGLN(0, ("lfreerdp_mem_blt: bad idx [%d]", idx));
- return;
- }
-
- bi = &(mod->bitmap_cache[id][idx]);
-
- mod->server_set_opcode(mod, memblt->bRop);
- mod->server_paint_rect(mod, memblt->nLeftRect, memblt->nTopRect,
- memblt->nWidth, memblt->nHeight,
- bi->data, bi->width, bi->height,
- memblt->nXSrc, memblt->nYSrc);
- mod->server_set_opcode(mod, 0xcc);
-
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_glyph_index(rdpContext *context, GLYPH_INDEX_ORDER *glyph_index)
-{
- struct mod *mod;
- int server_bpp;
- int client_bpp;
- int fgcolor;
- int bgcolor;
-
- mod = ((struct mod_context *)context)->modi;
- LLOGLN(10, ("lfreerdp_glyph_index:"));
- server_bpp = mod->inst->settings->ColorDepth;
- client_bpp = mod->bpp;
- fgcolor = convert_color(server_bpp, client_bpp,
- glyph_index->foreColor, mod->colormap);
- bgcolor = convert_color(server_bpp, client_bpp,
- glyph_index->backColor, mod->colormap);
- mod->server_set_bgcolor(mod, fgcolor);
- mod->server_set_fgcolor(mod, bgcolor);
- mod->server_draw_text(mod, glyph_index->cacheId, glyph_index->flAccel,
- glyph_index->fOpRedundant,
- glyph_index->bkLeft, glyph_index->bkTop,
- glyph_index->bkRight, glyph_index->bkBottom,
- glyph_index->opLeft, glyph_index->opTop,
- glyph_index->opRight, glyph_index->opBottom,
- glyph_index->x, glyph_index->y,
- (char *)(glyph_index->data), glyph_index->cbData);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_line_to(rdpContext *context, LINE_TO_ORDER *line_to)
-{
- struct mod *mod;
- int server_bpp;
- int client_bpp;
- int fgcolor;
- int bgcolor;
-
- mod = ((struct mod_context *)context)->modi;
- LLOGLN(10, ("lfreerdp_line_to:"));
- mod->server_set_opcode(mod, line_to->bRop2);
- server_bpp = mod->inst->settings->ColorDepth;
- client_bpp = mod->bpp;
- fgcolor = convert_color(server_bpp, client_bpp,
- line_to->penColor, mod->colormap);
- bgcolor = convert_color(server_bpp, client_bpp,
- line_to->backColor, mod->colormap);
- mod->server_set_fgcolor(mod, fgcolor);
- mod->server_set_bgcolor(mod, bgcolor);
- mod->server_set_pen(mod, line_to->penStyle, line_to->penWidth);
- mod->server_draw_line(mod, line_to->nXStart, line_to->nYStart,
- line_to->nXEnd, line_to->nYEnd);
- mod->server_set_opcode(mod, 0xcc);
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_cache_bitmap(rdpContext *context, CACHE_BITMAP_ORDER *cache_bitmap_order)
-{
- LLOGLN(0, ("lfreerdp_cache_bitmap: - no code here"));
-}
-
-/******************************************************************************/
-/* Turn the bitmap upside down*/
-static void DEFAULT_CC
-lfreerdp_upsidedown(UINT8 *destination, CACHE_BITMAP_V2_ORDER *cache_bitmap_v2_order, int server_Bpp)
-{
- tui8 *src;
- tui8 *dst;
- int line_bytes;
- int j;
-
- if (destination == NULL)
- {
- LLOGLN(0, ("lfreerdp_upsidedown: destination pointer is NULL !!!"));
- return;
- }
-
- line_bytes = server_Bpp * cache_bitmap_v2_order->bitmapWidth;
- src = cache_bitmap_v2_order->bitmapDataStream;
- dst = destination + ((cache_bitmap_v2_order->bitmapHeight) * line_bytes);
-
- for (j = 0; j < cache_bitmap_v2_order->bitmapHeight; j++)
- {
- dst -= line_bytes;
- g_memcpy(dst, src, line_bytes);
- src += line_bytes;
- }
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_cache_bitmapV2(rdpContext *context,
- CACHE_BITMAP_V2_ORDER *cache_bitmap_v2_order)
-{
- char *dst_data;
- char *dst_data1;
- int bytes;
- int width;
- int height;
- int id;
- int idx;
- int flags;
- int server_bpp;
- int server_Bpp;
- int client_bpp;
- struct mod *mod;
-
- LLOGLN(10, ("lfreerdp_cache_bitmapV2: %d %d 0x%8.8x compressed %d",
- cache_bitmap_v2_order->cacheId,
- cache_bitmap_v2_order->cacheIndex,
- cache_bitmap_v2_order->flags,
- cache_bitmap_v2_order->compressed));
-
- mod = ((struct mod_context *)context)->modi;
- id = cache_bitmap_v2_order->cacheId;
- idx = cache_bitmap_v2_order->cacheIndex;
- flags = cache_bitmap_v2_order->flags;
-
- if (flags & 0x10) /* CBR2_DO_NOT_CACHE */
- {
- LLOGLN(0, ("lfreerdp_cache_bitmapV2: CBR2_DO_NOT_CACHE"));
- idx = 4096 - 1;
- }
-
- if ((id < 0) || (id >= 4))
- {
- LLOGLN(0, ("lfreerdp_cache_bitmapV2: bad id [%d]", id));
- return;
- }
-
- if ((idx < 0) || (idx >= 4096))
- {
- LLOGLN(0, ("lfreerdp_cache_bitmapV2: bad idx [%d]", idx));
- return;
- }
-
- server_bpp = mod->inst->settings->ColorDepth;
- server_Bpp = (server_bpp + 7) / 8;
- client_bpp = mod->bpp;
-
- width = cache_bitmap_v2_order->bitmapWidth;
- height = cache_bitmap_v2_order->bitmapHeight;
- bytes = width * height * server_Bpp + 16;
- dst_data = (char *)g_malloc(bytes, 0);
-
- if (cache_bitmap_v2_order->compressed)
- {
- bitmap_decompress(cache_bitmap_v2_order->bitmapDataStream,
- (tui8 *)dst_data, width, height,
- cache_bitmap_v2_order->bitmapLength,
- server_bpp, server_bpp);
- }
- else
- {
- /* Uncompressed bitmaps are upside down */
- lfreerdp_upsidedown((tui8 *)dst_data, cache_bitmap_v2_order, server_Bpp);
- LLOGLN(10, ("lfreerdp_cache_bitmapV2: upside down progressed"));
- }
-
- dst_data1 = convert_bitmap(server_bpp, client_bpp, dst_data,
- width, height, mod->colormap);
- g_free(mod->bitmap_cache[id][idx].data);
- mod->bitmap_cache[id][idx].width = width;
- mod->bitmap_cache[id][idx].height = height;
- mod->bitmap_cache[id][idx].data = dst_data1;
-
- if (dst_data != dst_data1)
- {
- g_free(dst_data);
- }
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_cache_glyph(rdpContext *context, CACHE_GLYPH_ORDER *cache_glyph_order)
-{
- int index;
- GLYPH_DATA *gd;
- struct mod *mod;
-
- mod = ((struct mod_context *)context)->modi;
- LLOGLN(10, ("lfreerdp_cache_glyph: %d", cache_glyph_order->cGlyphs));
-
- for (index = 0; index < cache_glyph_order->cGlyphs; index++)
- {
- gd = cache_glyph_order->glyphData[index];
- LLOGLN(10, (" %d %d %d %d %d", gd->cacheIndex, gd->x, gd->y,
- gd->cx, gd->cy));
- mod->server_add_char(mod, cache_glyph_order->cacheId, gd->cacheIndex,
- gd->x, gd->y, gd->cx, gd->cy, (char *)(gd->aj));
- free(gd->aj);
- gd->aj = 0;
- free(gd);
- cache_glyph_order->glyphData[index] = 0;
- }
-
- free(cache_glyph_order->unicodeCharacters);
- cache_glyph_order->unicodeCharacters = 0;
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_cache_brush(rdpContext *context, CACHE_BRUSH_ORDER *cache_brush_order)
-{
- int idx;
- int bytes;
- int bpp;
- int cx;
- int cy;
- struct mod *mod;
-
- mod = ((struct mod_context *)context)->modi;
- bpp = cache_brush_order->bpp;
- cx = cache_brush_order->cx;
- cy = cache_brush_order->cy;
- idx = cache_brush_order->index;
- bytes = cache_brush_order->length;
- LLOGLN(10, ("lfreerdp_cache_brush: bpp %d cx %d cy %d idx %d bytes %d",
- bpp, cx, cy, idx, bytes));
-
- if ((idx < 0) || (idx >= 64))
- {
- LLOGLN(0, ("lfreerdp_cache_brush: error idx %d", idx));
- return;
- }
-
- if ((bpp != 1) || (cx != 8) || (cy != 8))
- {
- LLOGLN(0, ("lfreerdp_cache_brush: error unsupported brush "
- "bpp %d cx %d cy %d", bpp, cx, cy));
- return;
- }
-
- mod->brush_cache[idx].bpp = bpp;
- mod->brush_cache[idx].width = cx;
- mod->brush_cache[idx].height = cy;
- mod->brush_cache[idx].data = mod->brush_cache[idx].b8x8;
-
- if (bytes > 8)
- {
- bytes = 8;
- }
-
- g_memset(mod->brush_cache[idx].data, 0, 8);
-
- if (bytes > 0)
- {
- if (bytes > 8)
- {
- LLOGLN(0, ("lfreerdp_cache_brush: bytes to big %d", bytes));
- bytes = 8;
- }
-
- g_memcpy(mod->brush_cache[idx].data, cache_brush_order->data, bytes);
- }
-
- LLOGLN(10, ("lfreerdp_cache_brush: out bpp %d cx %d cy %d idx %d bytes %d",
- bpp, cx, cy, idx, bytes));
-
- free(cache_brush_order->data);
- cache_brush_order->data = 0;
-
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_pointer_position(rdpContext *context,
- POINTER_POSITION_UPDATE *pointer_position)
-{
- LLOGLN(0, ("lfreerdp_pointer_position: - no code here"));
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_pointer_system(rdpContext *context,
- POINTER_SYSTEM_UPDATE *pointer_system)
-{
- LLOGLN(0, ("lfreerdp_pointer_system: - no code here type value = %d",pointer_system->type));
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_pointer_color(rdpContext *context,
- POINTER_COLOR_UPDATE *pointer_color)
-{
- LLOGLN(0, ("lfreerdp_pointer_color: - no code here"));
-}
-
-/******************************************************************************/
-static int APP_CC
-lfreerdp_get_pixel(void *bits, int width, int height, int bpp,
- int delta, int x, int y)
-{
- int start;
- int shift;
- int pixel;
- tui8 *src8;
-
- if (bpp == 1)
- {
- src8 = (tui8 *)bits;
- start = (y * delta) + x / 8;
- shift = x % 8;
- pixel = (src8[start] & (0x80 >> shift)) != 0;
- return pixel ? 0xffffff : 0;
- }
- else
- {
- LLOGLN(0, ("lfreerdp_get_pixel: unknown bpp %d", bpp));
- }
-
- return 0;
-}
-
-/******************************************************************************/
-static int APP_CC
-lfreerdp_set_pixel(int pixel, void *bits, int width, int height, int bpp,
- int delta, int x, int y)
-{
- tui8 *dst8;
- int start;
- int shift;
-
- if (bpp == 1)
- {
- dst8 = (tui8 *)bits;
- start = (y * delta) + x / 8;
- shift = x % 8;
-
- if (pixel)
- {
- dst8[start] = dst8[start] | (0x80 >> shift);
- }
- else
- {
- dst8[start] = dst8[start] & ~(0x80 >> shift);
- }
- }
- else if (bpp == 24)
- {
- dst8 = (tui8 *)bits;
- dst8 += y * delta + x * 3;
- dst8[0] = (pixel >> 0) & 0xff;
- dst8[1] = (pixel >> 8) & 0xff;
- dst8[2] = (pixel >> 16) & 0xff;
- }
- else
- {
- LLOGLN(0, ("lfreerdp_set_pixel: unknown bpp %d", bpp));
- }
-
- return 0;
-}
-
-/******************************************************************************/
-static int APP_CC
-lfreerdp_convert_color_image(void *dst, int dst_width, int dst_height,
- int dst_bpp, int dst_delta,
- void *src, int src_width, int src_height,
- int src_bpp, int src_delta)
-{
- int i;
- int j;
- int pixel;
-
- for (j = 0; j < dst_height; j++)
- {
- for (i = 0; i < dst_width; i++)
- {
- pixel = lfreerdp_get_pixel(src, src_width, src_height, src_bpp,
- src_delta, i, j);
- lfreerdp_set_pixel(pixel, dst, dst_width, dst_height, dst_bpp,
- dst_delta, i, j);
- }
- }
-
- return 0;
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_pointer_new(rdpContext *context,
- POINTER_NEW_UPDATE *pointer_new)
-{
- struct mod *mod;
- int index;
- tui8 *dst;
- tui8 *src;
-
- mod = ((struct mod_context *)context)->modi;
- LLOGLN(20, ("lfreerdp_pointer_new:"));
- LLOGLN(20, (" bpp %d", pointer_new->xorBpp));
- LLOGLN(20, (" width %d height %d", pointer_new->colorPtrAttr.width,
- pointer_new->colorPtrAttr.height));
-
- LLOGLN(20, (" lengthXorMask %d lengthAndMask %d",
- pointer_new->colorPtrAttr.lengthXorMask,
- pointer_new->colorPtrAttr.lengthAndMask));
-
- index = pointer_new->colorPtrAttr.cacheIndex;
- if(index>=32)
- {
- LLOGLN(0,("pointer index too big"));
- return ;
- }
- // In this fix we remove the xorBpp check, even if
- // the mouse pointers are not correct we can use them.
- // Configure your destination not to use windows Aero as pointer scheme
- else if ( // pointer_new->xorBpp == 1 &&
- pointer_new->colorPtrAttr.width == 32 &&
- pointer_new->colorPtrAttr.height == 32 &&
- index < 32)
- {
- mod->pointer_cache[index].hotx = pointer_new->colorPtrAttr.xPos;
- mod->pointer_cache[index].hoty = pointer_new->colorPtrAttr.yPos;
-
- dst = (tui8 *)(mod->pointer_cache[index].data);
- dst += 32 * 32 * 3 - 32 * 3;
- src = pointer_new->colorPtrAttr.xorMaskData;
- lfreerdp_convert_color_image(dst, 32, 32, 24, 32 * -3,
- src, 32, 32, 1, 32 / 8);
-
- dst = (tui8 *)(mod->pointer_cache[index].mask);
- dst += ( 32 * 32 / 8) - (32 / 8);
- src = pointer_new->colorPtrAttr.andMaskData;
- lfreerdp_convert_color_image(dst, 32, 32, 1, 32 / -8,
- src, 32, 32, 1, 32 / 8);
-
- //memcpy(mod->pointer_cache[index].mask,
- // pointer_new->colorPtrAttr.andMaskData, 32 * 32 / 8);
-
- mod->server_set_pointer(mod, mod->pointer_cache[index].hotx,
- mod->pointer_cache[index].hoty, mod->pointer_cache[index].data,
- mod->pointer_cache[index].mask);
- }
- else
- {
- LLOGLN(0, ("lfreerdp_pointer_new: error bpp %d width %d height %d index: %d",
- pointer_new->xorBpp, pointer_new->colorPtrAttr.width,
- pointer_new->colorPtrAttr.height,index));
- }
-
- free(pointer_new->colorPtrAttr.xorMaskData);
- pointer_new->colorPtrAttr.xorMaskData = 0;
- free(pointer_new->colorPtrAttr.andMaskData);
- pointer_new->colorPtrAttr.andMaskData = 0;
-
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_pointer_cached(rdpContext *context,
- POINTER_CACHED_UPDATE *pointer_cached)
-{
- struct mod *mod;
- int index;
-
- mod = ((struct mod_context *)context)->modi;
- index = pointer_cached->cacheIndex;
- LLOGLN(10, ("lfreerdp_pointer_cached:%d", index));
- mod->server_set_pointer(mod, mod->pointer_cache[index].hotx,
- mod->pointer_cache[index].hoty, mod->pointer_cache[index].data,
- mod->pointer_cache[index].mask);
-}
-
-static void DEFAULT_CC lfreerdp_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
-{
- LLOGLN(0, ("lfreerdp_polygon_sc called:- not supported!!!!!!!!!!!!!!!!!!!!"));
-}
-
-static void DEFAULT_CC lfreerdp_polygon_sc(rdpContext* context, POLYGON_SC_ORDER* polygon_sc)
-{
- struct mod *mod;
- int i, npoints;
- XPoint points[4];
- int fgcolor;
- int server_bpp, client_bpp;
-
- mod = ((struct mod_context *)context)->modi;
- LLOGLN(10, ("lfreerdp_polygon_sc :%d(points) %d(color) %d(fillmode) %d(bRop) %d(cbData) %d(x) %d(y)", polygon_sc->numPoints,polygon_sc->brushColor,polygon_sc->fillMode,polygon_sc->bRop2,polygon_sc->cbData,polygon_sc->xStart,polygon_sc->yStart));
- if(polygon_sc->numPoints==3)
- {
- server_bpp = mod->inst->settings->ColorDepth;
- client_bpp = mod->bpp;
-
- points[0].x = polygon_sc->xStart;
- points[0].y = polygon_sc->yStart;
-
- for (i = 0; i < polygon_sc->numPoints; i++)
- {
- points[i + 1].x = polygon_sc->points[i].x;
- points[i + 1].y = polygon_sc->points[i].y;
- }
- fgcolor = convert_color(server_bpp, client_bpp,
- polygon_sc->brushColor, mod->colormap);
-
- mod->server_set_opcode(mod, polygon_sc->bRop2);
- mod->server_set_bgcolor(mod, 255);
- mod->server_set_fgcolor(mod, fgcolor);
- mod->server_set_pen(mod, 1, 1); // style, width
- // TODO replace with correct brush; this is a workaround
- // This workaround handles the text cursor in microsoft word.
- mod->server_draw_line(mod,polygon_sc->xStart,polygon_sc->yStart,polygon_sc->xStart,polygon_sc->yStart+points[2].y);
-// mod->server_fill_rect(mod, points[0].x, points[0].y,
-// points[0].x-points[3].x, points[0].y-points[2].y);
-// mod->server_set_brush(mod,); // howto use this on our indata??
- mod->server_set_opcode(mod, 0xcc);
- }
- else
- {
- LLOGLN(0, ("Not handled number of points in lfreerdp_polygon_sc"));
- }
-}
-
-static void DEFAULT_CC lfreerdp_syncronize(rdpContext* context)
-{
- struct mod *mod;
- mod = ((struct mod_context *)context)->modi;
- LLOGLN(0, ("lfreerdp_synchronize received - not handled"));
-}
-
-/******************************************************************************/
-static BOOL DEFAULT_CC
-lfreerdp_pre_connect(freerdp *instance)
-{
- struct mod *mod;
- int index;
- int error;
- int num_chans;
- int ch_flags;
- char ch_name[256];
- char *dst_ch_name;
-
- LLOGLN(0, ("lfreerdp_pre_connect:"));
- mod = ((struct mod_context *)(instance->context))->modi;
- verifyColorMap(mod);
- num_chans = 0;
- index = 0;
- error = mod->server_query_channel(mod, index, ch_name, &ch_flags);
-
- while (error == 0)
- {
- num_chans++;
- LLOGLN(10, ("lfreerdp_pre_connect: got channel [%s], flags [0x%8.8x]",
- ch_name, ch_flags));
- dst_ch_name = instance->settings->ChannelDefArray[index].Name;
- g_memset(dst_ch_name, 0, 8);
- g_snprintf(dst_ch_name, 8, "%s", ch_name);
- instance->settings->ChannelDefArray[index].options = ch_flags;
- index++;
- error = mod->server_query_channel(mod, index, ch_name, &ch_flags);
- }
-
- instance->settings->ChannelCount = num_chans;
-
- // TODO
- // instance->settings->offscreen_bitmap_cache = false;
- instance->settings->OffscreenSupportLevel = 0;
- instance->settings->DrawNineGridEnabled = 0 ;
-
- // TODO
- //instance->settings->glyph_cache = true;
- instance->settings->GlyphSupportLevel = GLYPH_SUPPORT_FULL;
- instance->settings->OrderSupport[NEG_GLYPH_INDEX_INDEX] = TRUE;
- instance->settings->OrderSupport[NEG_FAST_GLYPH_INDEX] = FALSE;
- instance->settings->OrderSupport[NEG_FAST_INDEX_INDEX] = FALSE;
- instance->settings->OrderSupport[NEG_SCRBLT_INDEX] = TRUE;
- instance->settings->OrderSupport[NEG_SAVEBITMAP_INDEX] = FALSE;
-
- instance->settings->BitmapCacheEnabled = TRUE;
- instance->settings->OrderSupport[NEG_MEMBLT_INDEX] = TRUE;
- instance->settings->OrderSupport[NEG_MEMBLT_V2_INDEX] = TRUE;
- instance->settings->OrderSupport[NEG_MEM3BLT_INDEX] = FALSE;
- instance->settings->OrderSupport[NEG_MEM3BLT_V2_INDEX] = FALSE;
- instance->settings->BitmapCacheV2NumCells = 3; // 5;
- instance->settings->BitmapCacheV2CellInfo[0].numEntries = 0x78; // 600;
- instance->settings->BitmapCacheV2CellInfo[0].persistent = FALSE;
- instance->settings->BitmapCacheV2CellInfo[1].numEntries = 0x78; // 600;
- instance->settings->BitmapCacheV2CellInfo[1].persistent = FALSE;
- instance->settings->BitmapCacheV2CellInfo[2].numEntries = 0x150; // 2048;
- instance->settings->BitmapCacheV2CellInfo[2].persistent = FALSE;
- instance->settings->BitmapCacheV2CellInfo[3].numEntries = 0; // 4096;
- instance->settings->BitmapCacheV2CellInfo[3].persistent = FALSE;
- instance->settings->BitmapCacheV2CellInfo[4].numEntries = 0; // 2048;
- instance->settings->BitmapCacheV2CellInfo[4].persistent = FALSE;
-
- // instance->settings->BitmapCacheV3Enabled = FALSE;
- instance->settings->OrderSupport[NEG_MULTIDSTBLT_INDEX] = FALSE;
- instance->settings->OrderSupport[NEG_MULTIPATBLT_INDEX] = FALSE;
- instance->settings->OrderSupport[NEG_MULTISCRBLT_INDEX] = FALSE;
- instance->settings->OrderSupport[NEG_MULTIOPAQUERECT_INDEX] = FALSE;
- instance->settings->OrderSupport[NEG_POLYLINE_INDEX] = FALSE;
-
- instance->settings->Username = g_strdup(mod->username);
- instance->settings->Password = g_strdup(mod->password);
-
- if (mod->client_info.rail_support_level > 0)
- {
- LLOGLN(0, ("Railsupport !!!!!!!!!!!!!!!!!!"));
- instance->settings->RemoteApplicationMode = TRUE;
- instance->settings->RemoteAppLanguageBarSupported = TRUE;
- instance->settings->Workarea = TRUE;
- instance->settings->PerformanceFlags = PERF_DISABLE_WALLPAPER | PERF_DISABLE_FULLWINDOWDRAG;
- }
- else
- {
- LLOGLN(10, ("Special PerformanceFlags changed"));
- instance->settings->PerformanceFlags = PERF_DISABLE_WALLPAPER | PERF_DISABLE_FULLWINDOWDRAG | PERF_DISABLE_MENUANIMATIONS | PERF_DISABLE_THEMING ; // | PERF_DISABLE_CURSOR_SHADOW | PERF_DISABLE_CURSORSETTINGS ;
- }
- instance->settings->CompressionEnabled = FALSE ;
- instance->settings->IgnoreCertificate = TRUE ;
-
- // here
- //instance->settings->RdpVersion = 4;
-
- instance->update->BeginPaint = lfreerdp_begin_paint;
- instance->update->EndPaint = lfreerdp_end_paint;
- instance->update->SetBounds = lfreerdp_set_bounds;
- instance->update->BitmapUpdate = lfreerdp_bitmap_update;
- instance->update->Synchronize = lfreerdp_syncronize ;
- instance->update->primary->DstBlt = lfreerdp_dst_blt;
- instance->update->primary->PatBlt = lfreerdp_pat_blt;
- instance->update->primary->ScrBlt = lfreerdp_scr_blt;
- instance->update->primary->OpaqueRect = lfreerdp_opaque_rect;
- instance->update->primary->MemBlt = lfreerdp_mem_blt;
- instance->update->primary->GlyphIndex = lfreerdp_glyph_index;
- instance->update->primary->LineTo = lfreerdp_line_to;
- instance->update->primary->PolygonSC = lfreerdp_polygon_sc ;
- instance->update->primary->PolygonCB = lfreerdp_polygon_cb;
- instance->update->secondary->CacheBitmap = lfreerdp_cache_bitmap;
- instance->update->secondary->CacheBitmapV2 = lfreerdp_cache_bitmapV2;
- instance->update->secondary->CacheGlyph = lfreerdp_cache_glyph;
- instance->update->secondary->CacheBrush = lfreerdp_cache_brush;
-
- instance->update->pointer->PointerPosition = lfreerdp_pointer_position;
- instance->update->pointer->PointerSystem = lfreerdp_pointer_system;
- instance->update->pointer->PointerColor = lfreerdp_pointer_color;
- instance->update->pointer->PointerNew = lfreerdp_pointer_new;
- instance->update->pointer->PointerCached = lfreerdp_pointer_cached;
-
- if ((mod->username[0] != 0) && (mod->password[0] != 0))
- {
- /* since we have username and password, we can try nla */
- instance->settings->NlaSecurity = 1;
- }
- else
- {
- instance->settings->NlaSecurity = 0;
- }
-
- return TRUE;
-}
-
-/*****************************************************************************/
-void DEFAULT_CC
-lrail_WindowCreate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
- WINDOW_STATE_ORDER *window_state)
-{
- int index;
- struct mod *mod;
- struct rail_window_state_order wso;
-
- LLOGLN(0, ("llrail_WindowCreate:"));
- mod = ((struct mod_context *)context)->modi;
- memset(&wso, 0, sizeof(wso));
- /* copy the window state order */
- wso.owner_window_id = window_state->ownerWindowId;
- wso.style = window_state->style;
- wso.extended_style = window_state->extendedStyle;
- wso.show_state = window_state->showState;
-
- if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_TITLE)
- {
- freerdp_UnicodeToAsciiAlloc(window_state->titleInfo.string, &wso.title_info, window_state->titleInfo.length / 2);
- }
-
- LLOGLN(0, ("lrail_WindowCreate: %s", wso.title_info));
- wso.client_offset_x = window_state->clientOffsetX;
- wso.client_offset_y = window_state->clientOffsetY;
- wso.client_area_width = window_state->clientAreaWidth;
- wso.client_area_height = window_state->clientAreaHeight;
- wso.rp_content = window_state->RPContent;
- wso.root_parent_handle = window_state->rootParentHandle;
- wso.window_offset_x = window_state->windowOffsetX;
- wso.window_offset_y = window_state->windowOffsetY;
- wso.window_client_delta_x = window_state->windowClientDeltaX;
- wso.window_client_delta_y = window_state->windowClientDeltaY;
- wso.window_width = window_state->windowWidth;
- wso.window_height = window_state->windowHeight;
- wso.num_window_rects = window_state->numWindowRects;
-
- if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS)
- {
- wso.window_rects = (struct rail_window_rect *)
- g_malloc(sizeof(struct rail_window_rect) * wso.num_window_rects, 0);
-
- for (index = 0; index < wso.num_window_rects; index++)
- {
- wso.window_rects[index].left = window_state->windowRects[index].left;
- wso.window_rects[index].top = window_state->windowRects[index].top;
- wso.window_rects[index].right = window_state->windowRects[index].right;
- wso.window_rects[index].bottom = window_state->windowRects[index].bottom;
- }
- }
-
- wso.visible_offset_x = window_state->visibleOffsetX;
- wso.visible_offset_y = window_state->visibleOffsetY;
- wso.num_visibility_rects = window_state->numVisibilityRects;
-
- if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY)
- {
- wso.visibility_rects = (struct rail_window_rect *)
- g_malloc(sizeof(struct rail_window_rect) * wso.num_visibility_rects, 0);
-
- for (index = 0; index < wso.num_visibility_rects; index++)
- {
- wso.visibility_rects[index].left = window_state->visibilityRects[index].left;
- wso.visibility_rects[index].top = window_state->visibilityRects[index].top;
- wso.visibility_rects[index].right = window_state->visibilityRects[index].right;
- wso.visibility_rects[index].bottom = window_state->visibilityRects[index].bottom;
- }
- }
-
- mod->server_window_new_update(mod, orderInfo->windowId, &wso,
- orderInfo->fieldFlags);
-
- free(wso.title_info);
- g_free(wso.window_rects);
- g_free(wso.visibility_rects);
-}
-
-/*****************************************************************************/
-void DEFAULT_CC
-lrail_WindowUpdate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
- WINDOW_STATE_ORDER *window_state)
-{
- LLOGLN(0, ("lrail_WindowUpdate:"));
- lrail_WindowCreate(context, orderInfo, window_state);
-}
-
-/*****************************************************************************/
-void DEFAULT_CC
-lrail_WindowDelete(rdpContext *context, WINDOW_ORDER_INFO *orderInfo)
-{
- struct mod *mod;
-
- LLOGLN(0, ("lrail_WindowDelete:"));
- mod = ((struct mod_context *)context)->modi;
- mod->server_window_delete(mod, orderInfo->windowId);
-}
-
-/*****************************************************************************/
-void DEFAULT_CC
-lrail_WindowIcon(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
- WINDOW_ICON_ORDER *window_icon)
-{
- struct mod *mod;
- struct rail_icon_info rii;
-
- LLOGLN(0, ("lrail_WindowIcon:"));
- mod = ((struct mod_context *)context)->modi;
- memset(&rii, 0, sizeof(rii));
- rii.bpp = window_icon->iconInfo->bpp;
- rii.width = window_icon->iconInfo->width;
- rii.height = window_icon->iconInfo->height;
- rii.cmap_bytes = window_icon->iconInfo->cbColorTable;
- rii.mask_bytes = window_icon->iconInfo->cbBitsMask;
- rii.data_bytes = window_icon->iconInfo->cbBitsColor;
- rii.mask = (char *)(window_icon->iconInfo->bitsMask);
- rii.cmap = (char *)(window_icon->iconInfo->colorTable);
- rii.data = (char *)(window_icon->iconInfo->bitsColor);
- mod->server_window_icon(mod, orderInfo->windowId,
- window_icon->iconInfo->cacheEntry,
- window_icon->iconInfo->cacheId, &rii,
- orderInfo->fieldFlags);
-}
-
-/*****************************************************************************/
-void DEFAULT_CC
-lrail_WindowCachedIcon(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
- WINDOW_CACHED_ICON_ORDER *window_cached_icon)
-{
- struct mod *mod;
-
- LLOGLN(0, ("lrail_WindowCachedIcon:"));
- mod = ((struct mod_context *)context)->modi;
- mod->server_window_cached_icon(mod, orderInfo->windowId,
- window_cached_icon->cachedIcon.cacheEntry,
- window_cached_icon->cachedIcon.cacheId,
- orderInfo->fieldFlags);
-}
-
-/*****************************************************************************/
-void DEFAULT_CC
-lrail_NotifyIconCreate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
- NOTIFY_ICON_STATE_ORDER *notify_icon_state)
-{
- struct mod *mod;
- struct rail_notify_state_order rnso;
-
- LLOGLN(0, ("lrail_NotifyIconCreate:"));
-
- mod = ((struct mod_context *)context)->modi;
-
- memset(&rnso, 0, sizeof(rnso));
- rnso.version = notify_icon_state->version;
-
- if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_TIP)
- {
- freerdp_UnicodeToAsciiAlloc(notify_icon_state->toolTip.string,
- &rnso.tool_tip, notify_icon_state->toolTip.length / 2);
- }
-
- if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_INFO_TIP)
- {
- rnso.infotip.timeout = notify_icon_state->infoTip.timeout;
- rnso.infotip.flags = notify_icon_state->infoTip.flags;
- freerdp_UnicodeToAsciiAlloc(notify_icon_state->infoTip.text.string,
- &rnso.infotip.text, notify_icon_state->infoTip.text.length / 2);
- freerdp_UnicodeToAsciiAlloc(notify_icon_state->infoTip.title.string,
- &rnso.infotip.title, notify_icon_state->infoTip.title.length / 2);
- }
-
- rnso.state = notify_icon_state->state;
- rnso.icon_cache_entry = notify_icon_state->icon.cacheEntry;
- rnso.icon_cache_id = notify_icon_state->icon.cacheId;
-
- rnso.icon_info.bpp = notify_icon_state->icon.bpp;
- rnso.icon_info.width = notify_icon_state->icon.width;
- rnso.icon_info.height = notify_icon_state->icon.height;
- rnso.icon_info.cmap_bytes = notify_icon_state->icon.cbColorTable;
- rnso.icon_info.mask_bytes = notify_icon_state->icon.cbBitsMask;
- rnso.icon_info.data_bytes = notify_icon_state->icon.cbBitsColor;
- rnso.icon_info.mask = (char *)(notify_icon_state->icon.bitsMask);
- rnso.icon_info.cmap = (char *)(notify_icon_state->icon.colorTable);
- rnso.icon_info.data = (char *)(notify_icon_state->icon.bitsColor);
-
- mod->server_notify_new_update(mod, orderInfo->windowId,
- orderInfo->notifyIconId,
- &rnso, orderInfo->fieldFlags);
-
- free(rnso.tool_tip);
- free(rnso.infotip.text);
- free(rnso.infotip.title);
-}
-
-/*****************************************************************************/
-void DEFAULT_CC
-lrail_NotifyIconUpdate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
- NOTIFY_ICON_STATE_ORDER *notify_icon_state)
-{
- LLOGLN(0, ("lrail_NotifyIconUpdate:"));
- lrail_NotifyIconCreate(context, orderInfo, notify_icon_state);
-}
-
-/*****************************************************************************/
-void DEFAULT_CC
-lrail_NotifyIconDelete(rdpContext *context, WINDOW_ORDER_INFO *orderInfo)
-{
- struct mod *mod;
-
- LLOGLN(0, ("lrail_NotifyIconDelete:"));
- mod = ((struct mod_context *)context)->modi;
- mod->server_notify_delete(mod, orderInfo->windowId,
- orderInfo->notifyIconId);
-}
-
-/*****************************************************************************/
-void DEFAULT_CC
-lrail_MonitoredDesktop(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
- MONITORED_DESKTOP_ORDER *monitored_desktop)
-{
- int index;
- struct mod *mod;
- struct rail_monitored_desktop_order rmdo;
-
- LLOGLN(0, ("lrail_MonitoredDesktop:"));
- mod = ((struct mod_context *)context)->modi;
- memset(&rmdo, 0, sizeof(rmdo));
- rmdo.active_window_id = monitored_desktop->activeWindowId;
- rmdo.num_window_ids = monitored_desktop->numWindowIds;
-
- if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER)
- {
- if (rmdo.num_window_ids > 0)
- {
- rmdo.window_ids = (int *)g_malloc(sizeof(int) * rmdo.num_window_ids, 0);
-
- for (index = 0; index < rmdo.num_window_ids; index++)
- {
- rmdo.window_ids[index] = monitored_desktop->windowIds[index];
- }
- }
- }
-
- mod->server_monitored_desktop(mod, &rmdo, orderInfo->fieldFlags);
- g_free(rmdo.window_ids);
-}
-
-/*****************************************************************************/
-void DEFAULT_CC
-lrail_NonMonitoredDesktop(rdpContext *context, WINDOW_ORDER_INFO *orderInfo)
-{
- struct mod *mod;
- struct rail_monitored_desktop_order rmdo;
-
- LLOGLN(0, ("lrail_NonMonitoredDesktop:"));
- mod = ((struct mod_context *)context)->modi;
- memset(&rmdo, 0, sizeof(rmdo));
- mod->server_monitored_desktop(mod, &rmdo, orderInfo->fieldFlags);
-}
-
-/******************************************************************************/
-static BOOL DEFAULT_CC
-lfreerdp_post_connect(freerdp *instance)
-{
- struct mod *mod;
-
- LLOGLN(0, ("lfreerdp_post_connect:"));
- mod = ((struct mod_context *)(instance->context))->modi;
- g_memset(mod->password, 0, sizeof(mod->password));
-
- mod->inst->update->window->WindowCreate = lrail_WindowCreate;
- mod->inst->update->window->WindowUpdate = lrail_WindowUpdate;
- mod->inst->update->window->WindowDelete = lrail_WindowDelete;
- mod->inst->update->window->WindowIcon = lrail_WindowIcon;
- mod->inst->update->window->WindowCachedIcon = lrail_WindowCachedIcon;
- mod->inst->update->window->NotifyIconCreate = lrail_NotifyIconCreate;
- mod->inst->update->window->NotifyIconUpdate = lrail_NotifyIconUpdate;
- mod->inst->update->window->NotifyIconDelete = lrail_NotifyIconDelete;
- mod->inst->update->window->MonitoredDesktop = lrail_MonitoredDesktop;
- mod->inst->update->window->NonMonitoredDesktop = lrail_NonMonitoredDesktop;
-
- return TRUE;
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_context_new(freerdp *instance, rdpContext *context)
-{
- LLOGLN(0, ("lfreerdp_context_new: %p", context));
-}
-
-/******************************************************************************/
-static void DEFAULT_CC
-lfreerdp_context_free(freerdp *instance, rdpContext *context)
-{
- LLOGLN(0, ("lfreerdp_context_free: - no code here"));
-}
-
-/******************************************************************************/
-static int DEFAULT_CC
-lfreerdp_receive_channel_data(freerdp *instance, int channelId, UINT8 *data,
- int size, int flags, int total_size)
-{
- struct mod *mod;
- int lchid;
- int index;
- int error;
-
- mod = ((struct mod_context *)(instance->context))->modi;
- lchid = -1;
-
- for (index = 0; index < instance->settings->ChannelDefArraySize; index++)
- {
- if (instance->settings->ChannelDefArray[index].ChannelId == channelId)
- {
- lchid = index;
- break;
- }
- }
-
- if (lchid >= 0)
- {
- LLOGLN(10, ("lfreerdp_receive_channel_data: server to client"));
- error = mod->server_send_to_channel(mod, lchid, (char *)data, size,
- total_size, flags);
-
- if (error != 0)
- {
- LLOGLN(0, ("lfreerdp_receive_channel_data: error %d", error));
- }
- }
- else
- {
- LLOGLN(0, ("lfreerdp_receive_channel_data: bad lchid"));
- }
-
- return 0;
-}
-
-/******************************************************************************/
-static BOOL DEFAULT_CC
-lfreerdp_authenticate(freerdp *instance, char **username,
- char **password, char **domain)
-{
- LLOGLN(0, ("lfreerdp_authenticate: - no code here"));
- return TRUE;
-}
-
-/******************************************************************************/
-static BOOL DEFAULT_CC
-lfreerdp_verify_certificate(freerdp *instance, char *subject, char *issuer,
- char *fingerprint)
-{
- LLOGLN(0, ("lfreerdp_verify_certificate: - no code here"));
- return TRUE;
-}
-
-/******************************************************************************/
-struct mod *EXPORT_CC
-mod_init(void)
-{
- struct mod *mod;
- modContext *lcon;
-
- LLOGLN(0, ("mod_init:"));
- mod = (struct mod *)g_malloc(sizeof(struct mod), 1);
- freerdp_get_version(&(mod->vmaj), &(mod->vmin), &(mod->vrev));
- LLOGLN(0, (" FreeRDP version major %d minor %d revision %d",
- mod->vmaj, mod->vmin, mod->vrev));
- mod->size = sizeof(struct mod);
- mod->version = CURRENT_MOD_VER;
- mod->handle = (tbus)mod;
- mod->mod_connect = lxrdp_connect;
- mod->mod_start = lxrdp_start;
- mod->mod_event = lxrdp_event;
- mod->mod_signal = lxrdp_signal;
- mod->mod_end = lxrdp_end;
- mod->mod_set_param = lxrdp_set_param;
- mod->mod_session_change = lxrdp_session_change;
- mod->mod_get_wait_objs = lxrdp_get_wait_objs;
- mod->mod_check_wait_objs = lxrdp_check_wait_objs;
-
- mod->inst = freerdp_new();
- mod->inst->PreConnect = lfreerdp_pre_connect;
- mod->inst->PostConnect = lfreerdp_post_connect;
- mod->inst->context_size = sizeof(modContext);
- mod->inst->ContextNew = lfreerdp_context_new;
- mod->inst->ContextFree = lfreerdp_context_free;
- mod->inst->ReceiveChannelData = lfreerdp_receive_channel_data;
- mod->inst->Authenticate = lfreerdp_authenticate;
- mod->inst->VerifyCertificate = lfreerdp_verify_certificate;
-
- freerdp_context_new(mod->inst);
-
- lcon = (modContext *)(mod->inst->context);
- lcon->modi = mod;
- LLOGLN(10, ("mod_init: mod %p", mod));
-
- return mod;
-}
-
-/******************************************************************************/
-int EXPORT_CC
-mod_exit(struct mod *mod)
-{
- LLOGLN(0, ("mod_exit:"));
-
- if (mod == 0)
- {
- return 0;
- }
-
- if (mod->inst == NULL)
- {
- LLOGLN(0, ("mod_exit - null pointer for inst:"));
- g_free(mod);
- return 0 ;
- }
-
- freerdp_disconnect(mod->inst);
-
- if ((mod->vmaj == 1) && (mod->vmin == 0) && (mod->vrev == 1))
- {
- /* this version has a bug with double free in freerdp_free */
- }
- else
- {
- freerdp_context_free(mod->inst);
- }
-
- freerdp_free(mod->inst);
- g_free(mod);
- return 0;
-}
diff --git a/freerdp1/xrdp-freerdp.h b/freerdp1/xrdp-freerdp.h
deleted file mode 100644
index c2956b4d..00000000
--- a/freerdp1/xrdp-freerdp.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/**
- * FreeRDP: A Remote Desktop Protocol Server
- * freerdp wrapper
- *
- * Copyright 2011-2012 Jay Sorg
- *
- * 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.
- */
-
-/* include other h files */
-#include "arch.h"
-#include "parse.h"
-#include "os_calls.h"
-#include "defines.h"
-#include "xrdp_rail.h"
-#include "xrdp_client_info.h"
-
-/* this is the freerdp main header */
-#include <freerdp/freerdp.h>
-#include <freerdp/rail.h>
-#include <freerdp/rail/rail.h>
-#include <freerdp/codec/bitmap.h>
-//#include <freerdp/utils/memory.h>
-//#include "/home/jay/git/jsorg71/staging/include/freerdp/freerdp.h"
-
-struct bitmap_item
-{
- int width;
- int height;
- char* data;
-};
-
-struct brush_item
-{
- int bpp;
- int width;
- int height;
- char* data;
- char b8x8[8];
-};
-
-struct pointer_item
-{
- int hotx;
- int hoty;
- char data[32 * 32 * 3];
- char mask[32 * 32 / 8];
-};
-
-#define CURRENT_MOD_VER 2
-
-struct mod
-{
- int size; /* size of this struct */
- int version; /* internal version */
- /* client functions */
- int (*mod_start)(struct mod* v, int w, int h, int bpp);
- int (*mod_connect)(struct mod* v);
- int (*mod_event)(struct mod* v, int msg, long param1, long param2,
- long param3, long param4);
- int (*mod_signal)(struct mod* v);
- int (*mod_end)(struct mod* v);
- int (*mod_set_param)(struct mod* v, char* name, char* value);
- int (*mod_session_change)(struct mod* v, int, int);
- int (*mod_get_wait_objs)(struct mod* v, tbus* read_objs, int* rcount,
- tbus* write_objs, int* wcount, int* timeout);
- int (*mod_check_wait_objs)(struct mod* v);
- long mod_dumby[100 - 9]; /* align, 100 minus the number of mod
- functions above */
- /* server functions */
- int (*server_begin_update)(struct mod* v);
- int (*server_end_update)(struct mod* v);
- int (*server_fill_rect)(struct mod* v, int x, int y, int cx, int cy);
- int (*server_screen_blt)(struct mod* v, int x, int y, int cx, int cy,
- int srcx, int srcy);
- int (*server_paint_rect)(struct mod* v, int x, int y, int cx, int cy,
- char* data, int width, int height, int srcx, int srcy);
- int (*server_set_pointer)(struct mod* v, int x, int y, char* data, char* mask);
- int (*server_palette)(struct mod* v, int* palette);
- int (*server_msg)(struct mod* v, char* msg, int code);
- int (*server_is_term)(struct mod* v);
- int (*server_set_clip)(struct mod* v, int x, int y, int cx, int cy);
- int (*server_reset_clip)(struct mod* v);
- int (*server_set_fgcolor)(struct mod* v, int fgcolor);
- int (*server_set_bgcolor)(struct mod* v, int bgcolor);
- int (*server_set_opcode)(struct mod* v, int opcode);
- int (*server_set_mixmode)(struct mod* v, int mixmode);
- int (*server_set_brush)(struct mod* v, int x_orgin, int y_orgin,
- int style, char* pattern);
- int (*server_set_pen)(struct mod* v, int style,
- int width);
- int (*server_draw_line)(struct mod* v, int x1, int y1, int x2, int y2);
- int (*server_add_char)(struct mod* v, int font, int charactor,
- int offset, int baseline,
- int width, int height, char* data);
- int (*server_draw_text)(struct mod* v, int font,
- int flags, int mixmode, int clip_left, int clip_top,
- int clip_right, int clip_bottom,
- int box_left, int box_top,
- int box_right, int box_bottom,
- int x, int y, char* data, int data_len);
- int (*server_reset)(struct mod* v, int width, int height, int bpp);
- int (*server_query_channel)(struct mod* v, int index,
- char* channel_name,
- int* channel_flags);
- int (*server_get_channel_id)(struct mod* v, char* name);
- int (*server_send_to_channel)(struct mod* v, int channel_id,
- char* data, int data_len,
- int total_data_len, int flags);
- int (*server_bell_trigger)(struct mod* v);
- /* off screen bitmaps */
- int (*server_create_os_surface)(struct mod* v, int rdpindex,
- int width, int height);
- int (*server_switch_os_surface)(struct mod* v, int rdpindex);
- int (*server_delete_os_surface)(struct mod* v, int rdpindex);
- int (*server_paint_rect_os)(struct mod* mod, int x, int y,
- int cx, int cy,
- int rdpindex, int srcx, int srcy);
- int (*server_set_hints)(struct mod* mod, int hints, int mask);
- /* rail */
- int (*server_window_new_update)(struct mod* mod, int window_id,
- struct rail_window_state_order* window_state,
- int flags);
- int (*server_window_delete)(struct mod* mod, int window_id);
- int (*server_window_icon)(struct mod* mod,
- int window_id, int cache_entry, int cache_id,
- struct rail_icon_info* icon_info,
- int flags);
- int (*server_window_cached_icon)(struct mod* mod,
- int window_id, int cache_entry,
- int cache_id, int flags);
- int (*server_notify_new_update)(struct mod* mod,
- int window_id, int notify_id,
- struct rail_notify_state_order* notify_state,
- int flags);
- int (*server_notify_delete)(struct mod* mod, int window_id,
- int notify_id);
- int (*server_monitored_desktop)(struct mod* mod,
- struct rail_monitored_desktop_order* mdo,
- int flags);
-
- long server_dumby[100 - 37]; /* align, 100 minus the number of server
- functions above */
- /* common */
- tbus handle; /* pointer to self as long */
- tbus wm;
- tbus painter;
- int sck;
- /* mod data */
- int width;
- int height;
- int bpp;
- int colormap[256];
- char* chan_buf;
- int chan_buf_valid;
- int chan_buf_bytes;
- int vmaj;
- int vmin;
- int vrev;
- char username[256];
- char password[256];
-
- struct xrdp_client_info client_info;
-
- struct rdp_freerdp* inst;
- struct bitmap_item bitmap_cache[4][4096];
- struct brush_item brush_cache[64];
- struct pointer_item pointer_cache[32];
-
-};
diff --git a/libxrdp/Makefile.am b/libxrdp/Makefile.am
index 4aba9e7e..6564da36 100644
--- a/libxrdp/Makefile.am
+++ b/libxrdp/Makefile.am
@@ -11,15 +11,22 @@ else
EXTRA_DEFINES += -DXRDP_NODEBUG
endif
-if XRDP_FREERDP1
-EXTRA_DEFINES += -DXRDP_FREERDP1
+if XRDP_NEUTRINORDP
+EXTRA_DEFINES += -DXRDP_NEUTRINORDP
EXTRA_LIBS += $(FREERDP_LIBS)
endif
+if XRDP_TJPEG
+EXTRA_DEFINES += -DXRDP_JPEG -DXRDP_TJPEG
+EXTRA_INCLUDES += -I/opt/libjpeg-turbo/include
+EXTRA_FLAGS += -L/opt/libjpeg-turbo/lib -Wl,-rpath -Wl,/opt/libjpeg-turbo/lib
+EXTRA_LIBS += -lturbojpeg
+else
if XRDP_JPEG
EXTRA_DEFINES += -DXRDP_JPEG
EXTRA_LIBS += -ljpeg
endif
+endif
if GOT_PREFIX
EXTRA_INCLUDES += -I$(prefix)/include
diff --git a/libxrdp/libxrdp.h b/libxrdp/libxrdp.h
index 33bcdc09..1adeb21c 100644
--- a/libxrdp/libxrdp.h
+++ b/libxrdp/libxrdp.h
@@ -233,6 +233,7 @@ struct xrdp_orders
int order_count;
int order_level; /* inc for every call to xrdp_orders_init */
struct xrdp_orders_state orders_state;
+ void* jpeg_han;
int rfx_min_pixel;
};
@@ -463,10 +464,14 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
int start_line, struct stream* temp_s,
int e);
int APP_CC
-xrdp_jpeg_compress(char* in_data, int width, int height,
+xrdp_jpeg_compress(void *handle, char* in_data, int width, int height,
struct stream* s, int bpp, int byte_limit,
int start_line, struct stream* temp_s,
int e, int quality);
+void *APP_CC
+xrdp_jpeg_init(void);
+int APP_CC
+xrdp_jpeg_deinit(void *handle);
/* xrdp_channel.c */
struct xrdp_channel* APP_CC
diff --git a/libxrdp/xrdp_iso.c b/libxrdp/xrdp_iso.c
index d851c1bb..feba6814 100644
--- a/libxrdp/xrdp_iso.c
+++ b/libxrdp/xrdp_iso.c
@@ -72,20 +72,38 @@ xrdp_iso_recv_msg(struct xrdp_iso *self, struct stream *s, int *code)
in_uint8s(s, 1);
in_uint16_be(s, len);
+ if (len < 4)
+ {
+ return 1;
+ }
+
if (xrdp_tcp_recv(self->tcp_layer, s, len - 4) != 0)
{
return 1;
}
+ if (!s_check_rem(s, 2))
+ {
+ return 1;
+ }
+
in_uint8s(s, 1);
in_uint8(s, *code);
if (*code == ISO_PDU_DT)
{
+ if (!s_check_rem(s, 1))
+ {
+ return 1;
+ }
in_uint8s(s, 1);
}
else
{
+ if (!s_check_rem(s, 5))
+ {
+ return 1;
+ }
in_uint8s(s, 5);
}
diff --git a/libxrdp/xrdp_jpeg_compress.c b/libxrdp/xrdp_jpeg_compress.c
index 82a816a0..a41bd1cf 100644
--- a/libxrdp/xrdp_jpeg_compress.c
+++ b/libxrdp/xrdp_jpeg_compress.c
@@ -20,7 +20,112 @@
#include "libxrdp.h"
-#if defined(XRDP_JPEG)
+#if defined(XRDP_TJPEG)
+
+/* turbo jpeg */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <turbojpeg.h>
+
+/*****************************************************************************/
+int APP_CC
+xrdp_jpeg_compress(void *handle, char *in_data, int width, int height,
+ struct stream *s, int bpp, int byte_limit,
+ int start_line, struct stream *temp_s,
+ int e, int quality)
+{
+ int error;
+ int i;
+ int j;
+ unsigned int pixel;
+ unsigned int *src32;
+ unsigned int *dst32;
+ unsigned long cdata_bytes;
+ unsigned char *src_buf;
+ unsigned char *dst_buf;
+ char *temp_buf;
+ tjhandle tj_han;
+
+ if (bpp != 24)
+ {
+ g_writeln("xrdp_jpeg_compress: bpp wrong %d", bpp);
+ return height;
+ }
+ if (handle == 0)
+ {
+ g_writeln("xrdp_jpeg_compress: handle is nil");
+ return height;
+ }
+ tj_han = (tjhandle) handle;
+ cdata_bytes = byte_limit;
+ src_buf = (unsigned char *) in_data;
+ dst_buf = (unsigned char *) (s->p);
+ temp_buf = 0;
+ if (e == 0)
+ {
+ src_buf = (unsigned char*)in_data;
+ }
+ else
+ {
+ temp_buf = (char *) g_malloc((width + e) * height * 4, 0);
+ dst32 = (unsigned int *) temp_buf;
+ src32 = (unsigned int *) in_data;
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ pixel = *src32;
+ src32++;
+ *dst32 = pixel;
+ dst32++;
+ }
+ for (i = 0; i < e; i++)
+ {
+ *dst32 = pixel;
+ dst32++;
+ }
+ }
+ src_buf = (unsigned char *) temp_buf;
+ }
+ dst_buf = (unsigned char*)(s->p);
+ error = tjCompress(tj_han, src_buf, width + e, (width + e) * 4, height,
+ TJPF_XBGR, dst_buf, &cdata_bytes,
+ TJSAMP_420, quality, 0);
+ s->p += cdata_bytes;
+ g_free(temp_buf);
+ return height;
+}
+
+/*****************************************************************************/
+void *APP_CC
+xrdp_jpeg_init(void)
+{
+ tjhandle tj_han;
+
+ tj_han = tjInitCompress();
+ return tj_han;
+}
+
+/*****************************************************************************/
+int APP_CC
+xrdp_jpeg_deinit(void *handle)
+{
+ tjhandle tj_han;
+
+ if (handle == 0)
+ {
+ return 0;
+ }
+ tj_han = (tjhandle) handle;
+ tjDestroy(tj_han);
+ return 0;
+}
+
+#elif defined(XRDP_JPEG)
+
+/* libjpeg */
#include <stdio.h>
#include <stdlib.h>
@@ -205,7 +310,7 @@ jpeg_compress(char *in_data, int width, int height,
/*****************************************************************************/
int APP_CC
-xrdp_jpeg_compress(char *in_data, int width, int height,
+xrdp_jpeg_compress(void *handle, char *in_data, int width, int height,
struct stream *s, int bpp, int byte_limit,
int start_line, struct stream *temp_s,
int e, int quality)
@@ -215,11 +320,25 @@ xrdp_jpeg_compress(char *in_data, int width, int height,
return height;
}
+/*****************************************************************************/
+void *APP_CC
+xrdp_jpeg_init(void)
+{
+ return 0;
+}
+
+/*****************************************************************************/
+int APP_CC
+xrdp_jpeg_deinit(void *handle)
+{
+ return 0;
+}
+
#else
/*****************************************************************************/
int APP_CC
-xrdp_jpeg_compress(char *in_data, int width, int height,
+xrdp_jpeg_compress(void *handle, char *in_data, int width, int height,
struct stream *s, int bpp, int byte_limit,
int start_line, struct stream *temp_s,
int e, int quality)
@@ -227,4 +346,18 @@ xrdp_jpeg_compress(char *in_data, int width, int height,
return height;
}
+/*****************************************************************************/
+void *APP_CC
+xrdp_jpeg_init(void)
+{
+ return 0;
+}
+
+/*****************************************************************************/
+int APP_CC
+xrdp_jpeg_deinit(void *handle)
+{
+ return 0;
+}
+
#endif
diff --git a/libxrdp/xrdp_mcs.c b/libxrdp/xrdp_mcs.c
index 4bf3d025..d110c987 100644
--- a/libxrdp/xrdp_mcs.c
+++ b/libxrdp/xrdp_mcs.c
@@ -132,6 +132,11 @@ xrdp_mcs_recv(struct xrdp_mcs *self, struct stream *s, int *chan)
return 1;
}
+ if (!s_check_rem(s, 1))
+ {
+ return 1;
+ }
+
in_uint8(s, opcode);
appid = opcode >> 2;
@@ -145,6 +150,11 @@ xrdp_mcs_recv(struct xrdp_mcs *self, struct stream *s, int *chan)
/* this is channels getting added from the client */
if (appid == MCS_CJRQ)
{
+ if (!s_check_rem(s, 4))
+ {
+ return 1;
+ }
+
in_uint16_be(s, userid);
in_uint16_be(s, chanid);
log_message(LOG_LEVEL_DEBUG,"MCS_CJRQ - channel join request received");
@@ -176,6 +186,11 @@ xrdp_mcs_recv(struct xrdp_mcs *self, struct stream *s, int *chan)
return 1;
}
+ if (!s_check_rem(s, 6))
+ {
+ return 1;
+ }
+
in_uint8s(s, 2);
in_uint16_be(s, *chan);
in_uint8s(s, 1);
@@ -183,6 +198,10 @@ xrdp_mcs_recv(struct xrdp_mcs *self, struct stream *s, int *chan)
if (len & 0x80)
{
+ if (!s_check_rem(s, 1))
+ {
+ return 1;
+ }
in_uint8s(s, 1);
}
@@ -202,10 +221,18 @@ xrdp_mcs_ber_parse_header(struct xrdp_mcs *self, struct stream *s,
if (tag_val > 0xff)
{
+ if (!s_check_rem(s, 2))
+ {
+ return 1;
+ }
in_uint16_be(s, tag);
}
else
{
+ if (!s_check_rem(s, 1))
+ {
+ return 1;
+ }
in_uint8(s, tag);
}
@@ -214,6 +241,11 @@ xrdp_mcs_ber_parse_header(struct xrdp_mcs *self, struct stream *s,
return 1;
}
+ if (!s_check_rem(s, 1))
+ {
+ return 1;
+ }
+
in_uint8(s, l);
if (l & 0x80)
@@ -223,6 +255,10 @@ xrdp_mcs_ber_parse_header(struct xrdp_mcs *self, struct stream *s,
while (l > 0)
{
+ if (!s_check_rem(s, 1))
+ {
+ return 1;
+ }
in_uint8(s, i);
*len = (*len << 8) | i;
l--;
@@ -255,6 +291,11 @@ xrdp_mcs_parse_domain_params(struct xrdp_mcs *self, struct stream *s)
return 1;
}
+ if ((len < 0) || !s_check_rem(s, len))
+ {
+ return 1;
+ }
+
in_uint8s(s, len);
if (s_check(s))
@@ -276,7 +317,7 @@ xrdp_mcs_recv_connect_initial(struct xrdp_mcs *self)
struct stream *s;
make_stream(s);
- init_stream(s, 8192);
+ init_stream(s, 16 * 1024);
if (xrdp_iso_recv(self->iso_layer, s) != 0)
{
@@ -296,6 +337,12 @@ xrdp_mcs_recv_connect_initial(struct xrdp_mcs *self)
return 1;
}
+ if ((len < 0) || !s_check_rem(s, len))
+ {
+ free_stream(s);
+ return 1;
+ }
+
in_uint8s(s, len);
if (xrdp_mcs_ber_parse_header(self, s, BER_TAG_OCTET_STRING, &len) != 0)
@@ -304,6 +351,12 @@ xrdp_mcs_recv_connect_initial(struct xrdp_mcs *self)
return 1;
}
+ if ((len < 0) || !s_check_rem(s, len))
+ {
+ free_stream(s);
+ return 1;
+ }
+
in_uint8s(s, len);
if (xrdp_mcs_ber_parse_header(self, s, BER_TAG_BOOLEAN, &len) != 0)
@@ -312,6 +365,12 @@ xrdp_mcs_recv_connect_initial(struct xrdp_mcs *self)
return 1;
}
+ if ((len < 0) || !s_check_rem(s, len))
+ {
+ free_stream(s);
+ return 1;
+ }
+
in_uint8s(s, len);
if (xrdp_mcs_parse_domain_params(self, s) != 0)
@@ -338,6 +397,19 @@ xrdp_mcs_recv_connect_initial(struct xrdp_mcs *self)
return 1;
}
+ /* mcs data can not be zero length */
+ if ((len <= 0) || (len > 16 * 1024))
+ {
+ free_stream(s);
+ return 1;
+ }
+
+ if (!s_check_rem(s, len))
+ {
+ free_stream(s);
+ return 1;
+ }
+
/* make a copy of client mcs data */
init_stream(self->client_mcs_data, len);
out_uint8a(self->client_mcs_data, s->p, len);
@@ -372,6 +444,12 @@ xrdp_mcs_recv_edrq(struct xrdp_mcs *self)
free_stream(s);
return 1;
}
+
+ if (!s_check_rem(s, 1))
+ {
+ free_stream(s);
+ return 1;
+ }
in_uint8(s, opcode);
@@ -381,11 +459,22 @@ xrdp_mcs_recv_edrq(struct xrdp_mcs *self)
return 1;
}
+ if (!s_check_rem(s, 4))
+ {
+ free_stream(s);
+ return 1;
+ }
+
in_uint8s(s, 2);
in_uint8s(s, 2);
if (opcode & 2)
{
+ if (!s_check_rem(s, 2))
+ {
+ free_stream(s);
+ return 1;
+ }
in_uint16_be(s, self->userid);
}
@@ -416,6 +505,12 @@ xrdp_mcs_recv_aurq(struct xrdp_mcs *self)
return 1;
}
+ if (!s_check_rem(s, 1))
+ {
+ free_stream(s);
+ return 1;
+ }
+
in_uint8(s, opcode);
if ((opcode >> 2) != MCS_AURQ)
@@ -426,6 +521,11 @@ xrdp_mcs_recv_aurq(struct xrdp_mcs *self)
if (opcode & 2)
{
+ if (!s_check_rem(s, 2))
+ {
+ free_stream(s);
+ return 1;
+ }
in_uint16_be(s, self->userid);
}
@@ -491,6 +591,12 @@ xrdp_mcs_recv_cjrq(struct xrdp_mcs *self)
return 1;
}
+ if (!s_check_rem(s, 1))
+ {
+ free_stream(s);
+ return 1;
+ }
+
in_uint8(s, opcode);
if ((opcode >> 2) != MCS_CJRQ)
@@ -499,10 +605,21 @@ xrdp_mcs_recv_cjrq(struct xrdp_mcs *self)
return 1;
}
+ if (!s_check_rem(s, 4))
+ {
+ free_stream(s);
+ return 1;
+ }
+
in_uint8s(s, 4);
if (opcode & 2)
{
+ if (!s_check_rem(s, 2))
+ {
+ free_stream(s);
+ return 1;
+ }
in_uint8s(s, 2);
}
diff --git a/libxrdp/xrdp_orders.c b/libxrdp/xrdp_orders.c
index 8ef26492..289f2c9c 100644
--- a/libxrdp/xrdp_orders.c
+++ b/libxrdp/xrdp_orders.c
@@ -20,7 +20,7 @@
#include "libxrdp.h"
-#if defined(XRDP_FREERDP1)
+#if defined(XRDP_NEUTRINORDP)
#include <freerdp/codec/rfx.h>
#endif
@@ -47,6 +47,7 @@ xrdp_orders_create(struct xrdp_session *session, struct xrdp_rdp *rdp_layer)
init_stream(self->out_s, 16384);
self->orders_state.clip_right = 1; /* silly rdp right clip */
self->orders_state.clip_bottom = 1; /* silly rdp bottom clip */
+ self->jpeg_han = xrdp_jpeg_init();
self->rfx_min_pixel = rdp_layer->client_info.rfx_min_pixel;
if (self->rfx_min_pixel == 0)
{
@@ -64,6 +65,7 @@ xrdp_orders_delete(struct xrdp_orders *self)
return;
}
+ xrdp_jpeg_deinit(self->jpeg_han);
free_stream(self->out_s);
g_free(self->orders_state.text_data);
g_free(self);
@@ -2432,6 +2434,25 @@ xrdp_orders_send_raw_bitmap2(struct xrdp_orders *self,
i = cache_idx & 0xff;
out_uint8(self->out_s, i);
+ if (1 && Bpp == 3)
+ {
+ for (i = height - 1; i >= 0; i--)
+ {
+ for (j = 0; j < width; j++)
+ {
+ pixel = GETPIXEL32(data, j, i, width);
+ out_uint8(self->out_s, pixel);
+ out_uint8(self->out_s, pixel >> 8);
+ out_uint8(self->out_s, pixel >> 16);
+ }
+ for (j = 0; j < e; j++)
+ {
+ out_uint8s(self->out_s, Bpp);
+ }
+ }
+ }
+ else
+ {
for (i = height - 1; i >= 0; i--)
{
for (j = 0; j < width; j++)
@@ -2461,6 +2482,7 @@ xrdp_orders_send_raw_bitmap2(struct xrdp_orders *self,
out_uint8s(self->out_s, Bpp);
}
}
+ }
return 0;
}
@@ -2569,7 +2591,7 @@ xrdp_orders_send_as_jpeg(struct xrdp_orders *self,
return 1;
}
-#if defined(XRDP_FREERDP1)
+#if defined(XRDP_NEUTRINORDP)
/*****************************************************************************/
/* secondary drawing order (bitmap v3) using remotefx compression */
static int APP_CC
@@ -2649,7 +2671,7 @@ xrdp_orders_send_bitmap3(struct xrdp_orders *self,
struct stream *xr_s; /* xrdp stream */
struct stream *temp_s; /* xrdp stream */
struct xrdp_client_info *ci;
-#if defined(XRDP_FREERDP1)
+#if defined(XRDP_NEUTRINORDP)
STREAM *fr_s; /* FreeRDP stream */
RFX_CONTEXT *context;
RFX_RECT rect;
@@ -2664,7 +2686,7 @@ xrdp_orders_send_bitmap3(struct xrdp_orders *self,
if (ci->v3_codec_id == ci->rfx_codec_id)
{
-#if defined(XRDP_FREERDP1)
+#if defined(XRDP_NEUTRINORDP)
if (!xrdp_orders_send_as_rfx(self, width, height, bpp, hints))
{
@@ -2717,7 +2739,7 @@ xrdp_orders_send_bitmap3(struct xrdp_orders *self,
make_stream(temp_s);
init_stream(temp_s, 16384);
quality = ci->jpeg_prop[0];
- xrdp_jpeg_compress(data, width, height, xr_s, bpp, 16384,
+ xrdp_jpeg_compress(self->jpeg_han, data, width, height, xr_s, bpp, 16384,
height - 1, temp_s, e, quality);
s_mark_end(xr_s);
bufsize = (int)(xr_s->end - xr_s->data);
diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c
index 02a6b6fb..1a7e717f 100644
--- a/libxrdp/xrdp_rdp.c
+++ b/libxrdp/xrdp_rdp.c
@@ -21,7 +21,7 @@
#include "libxrdp.h"
#include "log.h"
-#if defined(XRDP_FREERDP1)
+#if defined(XRDP_NEUTRINORDP)
#include <freerdp/codec/rfx.h>
#endif
@@ -88,15 +88,15 @@ xrdp_rdp_read_config(struct xrdp_client_info *client_info)
if (g_strcasecmp(item, "bitmap_cache") == 0)
{
- client_info->use_bitmap_cache = text2bool(value);
+ client_info->use_bitmap_cache = g_text2bool(value);
}
else if (g_strcasecmp(item, "bitmap_compression") == 0)
{
- client_info->use_bitmap_comp = text2bool(value);
+ client_info->use_bitmap_comp = g_text2bool(value);
}
else if (g_strcasecmp(item, "bulk_compression") == 0)
{
- client_info->use_bulk_comp = text2bool(value);
+ client_info->use_bulk_comp = g_text2bool(value);
}
else if (g_strcasecmp(item, "crypt_level") == 0)
{
@@ -121,7 +121,7 @@ xrdp_rdp_read_config(struct xrdp_client_info *client_info)
}
else if (g_strcasecmp(item, "allow_channels") == 0)
{
- client_info->channel_code = text2bool(value);
+ client_info->channel_code = g_text2bool(value);
if (client_info->channel_code == 0)
{
log_message(LOG_LEVEL_DEBUG,"Info - All channels are disabled");
@@ -137,11 +137,11 @@ xrdp_rdp_read_config(struct xrdp_client_info *client_info)
}
else if (g_strcasecmp(item, "new_cursors") == 0)
{
- client_info->pointer_flags = text2bool(value) == 0 ? 2 : 0;
+ client_info->pointer_flags = g_text2bool(value) == 0 ? 2 : 0;
}
else if (g_strcasecmp(item, "require_credentials") == 0)
{
- client_info->require_credentials = text2bool(value);
+ client_info->require_credentials = g_text2bool(value);
}
}
@@ -150,7 +150,7 @@ xrdp_rdp_read_config(struct xrdp_client_info *client_info)
return 0;
}
-#if defined(XRDP_FREERDP1)
+#if defined(XRDP_NEUTRINORDP)
/*****************************************************************************/
static void
cpuid(tui32 info, tui32 *eax, tui32 *ebx, tui32 *ecx, tui32 *edx)
@@ -231,7 +231,7 @@ xrdp_rdp_create(struct xrdp_session *session, struct trans *trans)
bytes = sizeof(self->client_info.client_ip) - 1;
g_write_ip_address(trans->sck, self->client_info.client_ip, bytes);
self->mppc_enc = mppc_enc_new(PROTO_RDP_50);
-#if defined(XRDP_FREERDP1)
+#if defined(XRDP_NEUTRINORDP)
self->rfx_enc = rfx_context_new();
rfx_context_set_cpu_opt(self->rfx_enc, xrdp_rdp_detect_cpu());
#endif
@@ -251,7 +251,7 @@ xrdp_rdp_delete(struct xrdp_rdp *self)
xrdp_sec_delete(self->sec_layer);
mppc_enc_free(self->mppc_enc);
-#if defined(XRDP_FREERDP1)
+#if defined(XRDP_NEUTRINORDP)
rfx_context_free((RFX_CONTEXT *)(self->rfx_enc));
#endif
g_free(self);
@@ -518,6 +518,11 @@ xrdp_rdp_parse_client_mcs_data(struct xrdp_rdp *self)
p = &(self->sec_layer->client_mcs_data);
p->p = p->data;
+ if (!s_check_rem(p, 31 + 2 + 2 + 120 + 2))
+ {
+ g_writeln("xrdp_rdp_parse_client_mcs_data: error");
+ return 1;
+ }
in_uint8s(p, 31);
in_uint16_le(p, self->client_info.width);
in_uint16_le(p, self->client_info.height);
@@ -528,6 +533,10 @@ xrdp_rdp_parse_client_mcs_data(struct xrdp_rdp *self)
switch (i)
{
case 0xca01:
+ if (!s_check_rem(p, 6 + 1))
+ {
+ return 1;
+ }
in_uint8s(p, 6);
in_uint8(p, i);
@@ -840,6 +849,11 @@ xrdp_process_capset_general(struct xrdp_rdp *self, struct stream *s,
{
int i;
+ if (len < 10 + 2)
+ {
+ g_writeln("xrdp_process_capset_general: error");
+ return 1;
+ }
in_uint8s(s, 10);
in_uint16_le(s, i);
/* use_compact_packets is pretty much 'use rdp5' */
@@ -861,6 +875,11 @@ xrdp_process_capset_order(struct xrdp_rdp *self, struct stream *s,
int cap_flags;
DEBUG(("order capabilities"));
+ if (len < 20 + 2 + 2 + 2 + 2 + 2 + 2 + 32 + 2 + 2 + 4 + 4 + 4 + 4)
+ {
+ g_writeln("xrdp_process_capset_order: error");
+ return 1;
+ }
in_uint8s(s, 20); /* Terminal desc, pad */
in_uint8s(s, 2); /* Cache X granularity */
in_uint8s(s, 2); /* Cache Y granularity */
@@ -918,13 +937,32 @@ static int APP_CC
xrdp_process_capset_bmpcache(struct xrdp_rdp *self, struct stream *s,
int len)
{
+ int i;
+
+ if (len < 24 + 2 + 2 + 2 + 2 + 2 + 2)
+ {
+ g_writeln("xrdp_process_capset_bmpcache: error");
+ return 1;
+ }
self->client_info.bitmap_cache_version |= 1;
in_uint8s(s, 24);
- in_uint16_le(s, self->client_info.cache1_entries);
+ /* cache 1 */
+ in_uint16_le(s, i);
+ i = MIN(i, XRDP_MAX_BITMAP_CACHE_IDX);
+ i = MAX(i, 0);
+ self->client_info.cache1_entries = i;
in_uint16_le(s, self->client_info.cache1_size);
- in_uint16_le(s, self->client_info.cache2_entries);
+ /* cache 2 */
+ in_uint16_le(s, i);
+ i = MIN(i, XRDP_MAX_BITMAP_CACHE_IDX);
+ i = MAX(i, 0);
+ self->client_info.cache2_entries = i;
in_uint16_le(s, self->client_info.cache2_size);
- in_uint16_le(s, self->client_info.cache3_entries);
+ /* caceh 3 */
+ in_uint16_le(s, i);
+ i = MIN(i, XRDP_MAX_BITMAP_CACHE_IDX);
+ i = MAX(i, 0);
+ self->client_info.cache3_entries = i;
in_uint16_le(s, self->client_info.cache3_size);
DEBUG(("cache1 entries %d size %d", self->client_info.cache1_entries,
self->client_info.cache1_size));
@@ -944,22 +982,30 @@ xrdp_process_capset_bmpcache2(struct xrdp_rdp *self, struct stream *s,
int Bpp = 0;
int i = 0;
+ if (len < 2 + 2 + 4 + 4 + 4)
+ {
+ g_writeln("xrdp_process_capset_bmpcache2: error");
+ return 1;
+ }
self->client_info.bitmap_cache_version |= 2;
Bpp = (self->client_info.bpp + 7) / 8;
in_uint16_le(s, i); /* cache flags */
self->client_info.bitmap_cache_persist_enable = i;
in_uint8s(s, 2); /* number of caches in set, 3 */
in_uint32_le(s, i);
- i = MIN(i, XRDP_BITMAP_CACHE_ENTRIES);
+ i = MIN(i, XRDP_MAX_BITMAP_CACHE_IDX);
+ i = MAX(i, 0);
self->client_info.cache1_entries = i;
self->client_info.cache1_size = 256 * Bpp;
in_uint32_le(s, i);
- i = MIN(i, XRDP_BITMAP_CACHE_ENTRIES);
+ i = MIN(i, XRDP_MAX_BITMAP_CACHE_IDX);
+ i = MAX(i, 0);
self->client_info.cache2_entries = i;
self->client_info.cache2_size = 1024 * Bpp;
in_uint32_le(s, i);
i = i & 0x7fffffff;
- i = MIN(i, XRDP_BITMAP_CACHE_ENTRIES);
+ i = MIN(i, XRDP_MAX_BITMAP_CACHE_IDX);
+ i = MAX(i, 0);
self->client_info.cache3_entries = i;
self->client_info.cache3_size = 4096 * Bpp;
DEBUG(("cache1 entries %d size %d", self->client_info.cache1_entries,
@@ -978,6 +1024,11 @@ xrdp_process_capset_cache_v3_codec_id(struct xrdp_rdp *self, struct stream *s,
{
int codec_id;
+ if (len < 1)
+ {
+ g_writeln("xrdp_process_capset_cache_v3_codec_id: error");
+ return 1;
+ }
in_uint8(s, codec_id);
g_writeln("xrdp_process_capset_cache_v3_codec_id: cache_v3_codec_id %d",
codec_id);
@@ -995,6 +1046,11 @@ xrdp_process_capset_pointercache(struct xrdp_rdp *self, struct stream *s,
int colorPointerFlag;
int no_new_cursor;
+ if (len < 2 + 2 + 2)
+ {
+ g_writeln("xrdp_process_capset_pointercache: error");
+ return 1;
+ }
no_new_cursor = self->client_info.pointer_flags & 2;
in_uint16_le(s, colorPointerFlag);
self->client_info.pointer_flags = colorPointerFlag;
@@ -1031,6 +1087,11 @@ xrdp_process_capset_brushcache(struct xrdp_rdp *self, struct stream *s,
{
int code;
+ if (len < 4)
+ {
+ g_writeln("xrdp_process_capset_brushcache: error");
+ return 1;
+ }
in_uint32_le(s, code);
self->client_info.brush_cache_code = code;
return 0;
@@ -1043,12 +1104,11 @@ xrdp_process_offscreen_bmpcache(struct xrdp_rdp *self, struct stream *s,
{
int i32;
- if (len - 4 < 8)
+ if (len < 4 + 2 + 2)
{
- g_writeln("xrdp_process_offscreen_bmpcache: bad len");
+ g_writeln("xrdp_process_offscreen_bmpcache: error");
return 1;
}
-
in_uint32_le(s, i32);
self->client_info.offscreen_support_level = i32;
in_uint16_le(s, i32);
@@ -1069,12 +1129,11 @@ xrdp_process_capset_rail(struct xrdp_rdp *self, struct stream *s, int len)
{
int i32;
- if (len - 4 < 4)
+ if (len < 4)
{
- g_writeln("xrdp_process_capset_rail: bad len");
+ g_writeln("xrdp_process_capset_rail: error");
return 1;
}
-
in_uint32_le(s, i32);
self->client_info.rail_support_level = i32;
g_writeln("xrdp_process_capset_rail: rail_support_level %d",
@@ -1088,12 +1147,11 @@ xrdp_process_capset_window(struct xrdp_rdp *self, struct stream *s, int len)
{
int i32;
- if (len - 4 < 7)
+ if (len < 4 + 1 + 2)
{
- g_writeln("xrdp_process_capset_window: bad len");
+ g_writeln("xrdp_process_capset_window: error");
return 1;
}
-
in_uint32_le(s, i32);
self->client_info.wnd_support_level = i32;
in_uint8(s, i32);
@@ -1120,14 +1178,32 @@ xrdp_process_capset_codecs(struct xrdp_rdp *self, struct stream *s, int len)
char *codec_guid;
char *next_guid;
+ if (len < 1)
+ {
+ g_writeln("xrdp_process_capset_codecs: error");
+ return 1;
+ }
in_uint8(s, codec_count);
+ len--;
for (index = 0; index < codec_count; index++)
{
codec_guid = s->p;
+ if (len < 16 + 1 + 2)
+ {
+ g_writeln("xrdp_process_capset_codecs: error");
+ return 1;
+ }
in_uint8s(s, 16);
in_uint8(s, codec_id);
in_uint16_le(s, codec_properties_length);
+ len -= 16 + 1 + 2;
+ if (len < codec_properties_length)
+ {
+ g_writeln("xrdp_process_capset_codecs: error");
+ return 1;
+ }
+ len -= codec_properties_length;
next_guid = s->p + codec_properties_length;
if (g_memcmp(codec_guid, XR_CODEC_GUID_NSCODEC, 16) == 0)
@@ -1193,9 +1269,19 @@ xrdp_rdp_process_confirm_active(struct xrdp_rdp *self, struct stream *s)
for (index = 0; index < num_caps; index++)
{
p = s->p;
+ if (!s_check_rem(s, 4))
+ {
+ g_writeln("xrdp_rdp_process_confirm_active: error 1");
+ return 1;
+ }
in_uint16_le(s, type);
in_uint16_le(s, len);
-
+ if ((len < 4) || !s_check_rem(s, len - 4))
+ {
+ g_writeln("xrdp_rdp_process_confirm_active: error len %d", len, s->end - s->p);
+ return 1;
+ }
+ len -= 4;
switch (type)
{
case RDP_CAPSET_GENERAL: /* 1 */
@@ -1281,7 +1367,7 @@ xrdp_rdp_process_confirm_active(struct xrdp_rdp *self, struct stream *s)
break;
}
- s->p = p + len;
+ s->p = p + len + 4;
}
DEBUG(("out xrdp_rdp_process_confirm_active"));
@@ -1308,12 +1394,20 @@ xrdp_rdp_process_data_input(struct xrdp_rdp *self, struct stream *s)
int param2;
int time;
+ if (!s_check_rem(s, 4))
+ {
+ return 1;
+ }
in_uint16_le(s, num_events);
in_uint8s(s, 2); /* pad */
DEBUG(("in xrdp_rdp_process_data_input %d events", num_events));
for (index = 0; index < num_events; index++)
{
+ if (!s_check_rem(s, 12))
+ {
+ return 1;
+ }
in_uint32_le(s, time);
in_uint16_le(s, msg_type);
in_uint16_le(s, device_flags);
diff --git a/libxrdp/xrdp_sec.c b/libxrdp/xrdp_sec.c
index 726fcde4..fbdc99a4 100644
--- a/libxrdp/xrdp_sec.c
+++ b/libxrdp/xrdp_sec.c
@@ -331,12 +331,20 @@ unicode_in(struct stream *s, int uni_len, char *dst, int dst_len)
break;
}
+ if (!s_check_rem(s, 2))
+ {
+ return 1;
+ }
in_uint8(s, dst[dst_index]);
in_uint8s(s, 1);
dst_index++;
src_index += 2;
}
+ if (!s_check_rem(s, 2))
+ {
+ return 1;
+ }
in_uint8s(s, 2);
return 0;
}
@@ -359,6 +367,10 @@ xrdp_sec_process_logon_info(struct xrdp_sec *self, struct stream *s)
/* initialize (zero out) local variables */
g_memset(tmpdata, 0, sizeof(char) * 256);
+ if (!s_check_rem(s, 8))
+ {
+ return 1;
+ }
in_uint8s(s, 4);
in_uint32_le(s, flags);
DEBUG(("in xrdp_sec_process_logon_info flags $%x", flags));
@@ -398,6 +410,10 @@ xrdp_sec_process_logon_info(struct xrdp_sec *self, struct stream *s)
}
}
+ if (!s_check_rem(s, 2))
+ {
+ return 1;
+ }
in_uint16_le(s, len_domain);
if (len_domain > 511)
@@ -406,6 +422,10 @@ xrdp_sec_process_logon_info(struct xrdp_sec *self, struct stream *s)
return 1;
}
+ if (!s_check_rem(s, 2))
+ {
+ return 1;
+ }
in_uint16_le(s, len_user);
if (len_user > 511)
@@ -414,6 +434,10 @@ xrdp_sec_process_logon_info(struct xrdp_sec *self, struct stream *s)
return 1;
}
+ if (!s_check_rem(s, 2))
+ {
+ return 1;
+ }
in_uint16_le(s, len_password);
if (len_password > 511)
@@ -422,6 +446,10 @@ xrdp_sec_process_logon_info(struct xrdp_sec *self, struct stream *s)
return 1;
}
+ if (!s_check_rem(s, 2))
+ {
+ return 1;
+ }
in_uint16_le(s, len_program);
if (len_program > 511)
@@ -430,6 +458,10 @@ xrdp_sec_process_logon_info(struct xrdp_sec *self, struct stream *s)
return 1;
}
+ if (!s_check_rem(s, 2))
+ {
+ return 1;
+ }
in_uint16_le(s, len_directory);
if (len_directory > 511)
@@ -438,35 +470,75 @@ xrdp_sec_process_logon_info(struct xrdp_sec *self, struct stream *s)
return 1;
}
- unicode_in(s, len_domain, self->rdp_layer->client_info.domain, 255);
+ if (unicode_in(s, len_domain, self->rdp_layer->client_info.domain, 255) != 0)
+ {
+ return 1;
+ }
DEBUG(("domain %s", self->rdp_layer->client_info.domain));
- unicode_in(s, len_user, self->rdp_layer->client_info.username, 255);
+ if (unicode_in(s, len_user, self->rdp_layer->client_info.username, 255) != 0)
+ {
+ return 1;
+ }
DEBUG(("username %s", self->rdp_layer->client_info.username));
if (flags & RDP_LOGON_AUTO)
{
- unicode_in(s, len_password, self->rdp_layer->client_info.password, 255);
+ if (unicode_in(s, len_password, self->rdp_layer->client_info.password, 255) != 0)
+ {
+ return 1;
+ }
DEBUG(("flag RDP_LOGON_AUTO found"));
}
else
{
+ if (!s_check_rem(s, len_password + 2))
+ {
+ return 1;
+ }
in_uint8s(s, len_password + 2);
if (self->rdp_layer->client_info.require_credentials)
+ {
+ g_writeln("xrdp_sec_process_logon_info: credentials on cmd line is mandatory");
return 1; /* credentials on cmd line is mandatory */
+ }
}
- unicode_in(s, len_program, self->rdp_layer->client_info.program, 255);
+ if (unicode_in(s, len_program, self->rdp_layer->client_info.program, 255) != 0)
+ {
+ return 1;
+ }
DEBUG(("program %s", self->rdp_layer->client_info.program));
- unicode_in(s, len_directory, self->rdp_layer->client_info.directory, 255);
+ if (unicode_in(s, len_directory, self->rdp_layer->client_info.directory, 255) != 0)
+ {
+ return 1;
+ }
DEBUG(("directory %s", self->rdp_layer->client_info.directory));
if (flags & RDP_LOGON_BLOB)
{
+ if (!s_check_rem(s, 4))
+ {
+ return 1;
+ }
in_uint8s(s, 2); /* unknown */
in_uint16_le(s, len_ip);
- unicode_in(s, len_ip - 2, tmpdata, 255);
+ if (unicode_in(s, len_ip - 2, tmpdata, 255) != 0)
+ {
+ return 1;
+ }
+ if (!s_check_rem(s, 2))
+ {
+ return 1;
+ }
in_uint16_le(s, len_dll);
- unicode_in(s, len_dll - 2, tmpdata, 255);
+ if (unicode_in(s, len_dll - 2, tmpdata, 255) != 0)
+ {
+ return 1;
+ }
+ if (!s_check_rem(s, 4 + 62 + 22 + 62 + 26 + 4))
+ {
+ return 1;
+ }
in_uint32_le(s, tzone); /* len of timetone */
in_uint8s(s, 62); /* skip */
in_uint8s(s, 22); /* skip misc. */
@@ -676,17 +748,29 @@ xrdp_sec_recv(struct xrdp_sec *self, struct stream *s, int *chan)
return 1;
}
+ if (!s_check_rem(s, 4))
+ {
+ return 1;
+ }
in_uint32_le(s, flags);
DEBUG((" in xrdp_sec_recv flags $%x", flags));
if (flags & SEC_ENCRYPT) /* 0x08 */
{
+ if (!s_check_rem(s, 8))
+ {
+ return 1;
+ }
in_uint8s(s, 8); /* signature */
xrdp_sec_decrypt(self, s->p, (int)(s->end - s->p));
}
if (flags & SEC_CLIENT_RANDOM) /* 0x01 */
{
+ if (!s_check_rem(s, 4 + 64))
+ {
+ return 1;
+ }
in_uint32_le(s, len);
in_uint8a(s, self->client_crypt_random, 64);
xrdp_sec_rsa_op(self->client_random, self->client_crypt_random,
@@ -836,16 +920,30 @@ xrdp_sec_process_mcs_data_channels(struct xrdp_sec *self, struct stream *s)
return 0;
}
+ if (!s_check_rem(s, 4))
+ {
+ return 1;
+ }
+
in_uint32_le(s, num_channels);
+ if (num_channels > 31)
+ {
+ return 1;
+ }
+
for (index = 0; index < num_channels; index++)
{
channel_item = (struct mcs_channel_item *)
g_malloc(sizeof(struct mcs_channel_item), 1);
+ if (!s_check_rem(s, 12))
+ {
+ return 1;
+ }
in_uint8a(s, channel_item->name, 8);
in_uint32_le(s, channel_item->flags);
channel_item->chanid = MCS_GLOBAL_CHANNEL + (index + 1);
- list_add_item(self->mcs_layer->channel_list, (long)channel_item);
+ list_add_item(self->mcs_layer->channel_list, (tintptr)channel_item);
DEBUG(("got channel flags %8.8x name %s", channel_item->flags,
channel_item->name));
}
@@ -864,10 +962,14 @@ xrdp_sec_process_mcs_data(struct xrdp_sec *self)
int tag = 0;
int size = 0;
- s = &self->client_mcs_data;
+ s = &(self->client_mcs_data);
/* set p to beginning */
s->p = s->data;
/* skip header */
+ if (!s_check_rem(s, 23))
+ {
+ return 1;
+ }
in_uint8s(s, 23);
while (s_check_rem(s, 4))
@@ -890,7 +992,10 @@ xrdp_sec_process_mcs_data(struct xrdp_sec *self)
case SEC_TAG_CLI_CRYPT:
break;
case SEC_TAG_CLI_CHANNELS:
- xrdp_sec_process_mcs_data_channels(self, s);
+ if (xrdp_sec_process_mcs_data_channels(self, s) != 0)
+ {
+ return 1;
+ }
break;
case SEC_TAG_CLI_4:
break;
@@ -999,7 +1104,7 @@ xrdp_sec_out_mcs_data(struct xrdp_sec *self)
/*****************************************************************************/
/* process the mcs client data we received from the mcs layer */
-static void APP_CC
+static int APP_CC
xrdp_sec_in_mcs_data(struct xrdp_sec *self)
{
struct stream *s = (struct stream *)NULL;
@@ -1011,6 +1116,10 @@ xrdp_sec_in_mcs_data(struct xrdp_sec *self)
s = &(self->client_mcs_data);
/* get hostname, its unicode */
s->p = s->data;
+ if (!s_check_rem(s, 47))
+ {
+ return 1;
+ }
in_uint8s(s, 47);
g_memset(client_info->hostname, 0, 32);
c = 1;
@@ -1018,6 +1127,10 @@ xrdp_sec_in_mcs_data(struct xrdp_sec *self)
while (index < 16 && c != 0)
{
+ if (!s_check_rem(s, 2))
+ {
+ return 1;
+ }
in_uint8(s, c);
in_uint8s(s, 1);
client_info->hostname[index] = c;
@@ -1026,13 +1139,22 @@ xrdp_sec_in_mcs_data(struct xrdp_sec *self)
/* get build */
s->p = s->data;
+ if (!s_check_rem(s, 43 + 4))
+ {
+ return 1;
+ }
in_uint8s(s, 43);
in_uint32_le(s, client_info->build);
/* get keylayout */
s->p = s->data;
+ if (!s_check_rem(s, 39 + 4))
+ {
+ return 1;
+ }
in_uint8s(s, 39);
in_uint32_le(s, client_info->keylayout);
s->p = s->data;
+ return 0;
}
/*****************************************************************************/
@@ -1105,7 +1227,10 @@ xrdp_sec_incoming(struct xrdp_sec *self)
(int)(self->server_mcs_data.end - self->server_mcs_data.data));
#endif
DEBUG((" out xrdp_sec_incoming"));
- xrdp_sec_in_mcs_data(self);
+ if (xrdp_sec_in_mcs_data(self) != 0)
+ {
+ return 1;
+ }
return 0;
}
diff --git a/sesman/chansrv/Makefile.am b/sesman/chansrv/Makefile.am
index 96c7effc..2d73f05c 100644
--- a/sesman/chansrv/Makefile.am
+++ b/sesman/chansrv/Makefile.am
@@ -8,7 +8,8 @@ EXTRA_DIST = \
drdynvc.h \
rail.h \
sound.h \
- xcommon.h
+ xcommon.h \
+ mlog.h
EXTRA_DEFINES =
EXTRA_INCLUDES =
@@ -51,7 +52,8 @@ xrdp_chansrv_SOURCES = \
xcommon.c \
drdynvc.c \
chansrv_fuse.c \
- irp.c
+ irp.c \
+ fifo.c
xrdp_chansrv_LDFLAGS = \
$(EXTRA_FLAGS)
diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c
index ddc4a4ed..01c6a43d 100644
--- a/sesman/chansrv/chansrv.c
+++ b/sesman/chansrv/chansrv.c
@@ -81,19 +81,19 @@ tui32 g_dvc_chan_id = 100;
struct timeout_obj
{
tui32 mstime;
- void* data;
- void (*callback)(void* data);
- struct timeout_obj* next;
+ void *data;
+ void (*callback)(void *data);
+ struct timeout_obj *next;
};
-static struct timeout_obj* g_timeout_head = 0;
-static struct timeout_obj* g_timeout_tail = 0;
+static struct timeout_obj *g_timeout_head = 0;
+static struct timeout_obj *g_timeout_tail = 0;
/*****************************************************************************/
int APP_CC
-add_timeout(int msoffset, void (*callback)(void* data), void* data)
+add_timeout(int msoffset, void (*callback)(void *data), void *data)
{
- struct timeout_obj* tobj;
+ struct timeout_obj *tobj;
tui32 now;
LOG(10, ("add_timeout:"));
@@ -117,12 +117,12 @@ add_timeout(int msoffset, void (*callback)(void* data), void* data)
/*****************************************************************************/
static int APP_CC
-get_timeout(int* timeout)
+get_timeout(int *timeout)
{
- struct timeout_obj* tobj;
+ struct timeout_obj *tobj;
tui32 now;
int ltimeout;
-
+
LOG(10, ("get_timeout:"));
ltimeout = *timeout;
if (ltimeout < 1)
@@ -165,12 +165,12 @@ get_timeout(int* timeout)
static int APP_CC
check_timeout(void)
{
- struct timeout_obj* tobj;
- struct timeout_obj* last_tobj;
- struct timeout_obj* temp_tobj;
+ struct timeout_obj *tobj;
+ struct timeout_obj *last_tobj;
+ struct timeout_obj *temp_tobj;
int count;
tui32 now;
-
+
LOG(10, ("check_timeout:"));
count = 0;
tobj = g_timeout_head;
@@ -216,6 +216,13 @@ check_timeout(void)
}
/*****************************************************************************/
+int DEFAULT_CC
+g_is_term(void)
+{
+ return g_is_wait_obj_set(g_term_event);
+}
+
+/*****************************************************************************/
/* add data to chan_item, on its way to the client */
/* returns error */
static int APP_CC
@@ -288,11 +295,11 @@ send_data_from_chan_item(struct chan_item *chan_item)
out_uint32_le(s, cod->s->size);
out_uint8a(s, cod->s->p, size);
s_mark_end(s);
- LOGM((LOG_LEVEL_DEBUG, "chansrv::send_channel_data: -- "
+ LOGM((LOG_LEVEL_DEBUG, "chansrv::send_data_from_chan_item: -- "
"size %d chan_flags 0x%8.8x", size, chan_flags));
g_sent = 1;
- error = trans_force_write(g_con_trans);
+ error = trans_write_copy(g_con_trans);
if (error != 0)
{
return 1;
@@ -412,7 +419,7 @@ send_init_response_message(void)
out_uint32_le(s, 2); /* msg id */
out_uint32_le(s, 8); /* size */
s_mark_end(s);
- return trans_force_write(g_con_trans);
+ return trans_write_copy(g_con_trans);
}
/*****************************************************************************/
@@ -435,7 +442,7 @@ send_channel_setup_response_message(void)
out_uint32_le(s, 4); /* msg id */
out_uint32_le(s, 8); /* size */
s_mark_end(s);
- return trans_force_write(g_con_trans);
+ return trans_write_copy(g_con_trans);
}
/*****************************************************************************/
@@ -458,7 +465,7 @@ send_channel_data_response_message(void)
out_uint32_le(s, 6); /* msg id */
out_uint32_le(s, 8); /* size */
s_mark_end(s);
- return trans_force_write(g_con_trans);
+ return trans_write_copy(g_con_trans);
}
/*****************************************************************************/
@@ -657,7 +664,7 @@ process_message_channel_data(struct stream *s)
if (chan_flags & 2) /* last */
{
s_mark_end(ls);
- trans_force_write(g_api_con_trans);
+ trans_write_copy(g_api_con_trans);
}
}
}
@@ -1008,13 +1015,15 @@ setup_listen(void)
if (g_use_unix_socket)
{
- g_lis_trans = trans_create(2, 8192, 8192);
+ g_lis_trans = trans_create(TRANS_MODE_UNIX, 8192, 8192);
+ g_lis_trans->is_term = g_is_term;
g_snprintf(port, 255, "/tmp/.xrdp/xrdp_chansrv_socket_%d",
7200 + g_display_num);
}
else
{
- g_lis_trans = trans_create(1, 8192, 8192);
+ g_lis_trans = trans_create(TRANS_MODE_TCP, 8192, 8192);
+ g_lis_trans->is_term = g_is_term;
g_snprintf(port, 255, "%d", 7200 + g_display_num);
}
@@ -1039,6 +1048,7 @@ setup_api_listen(void)
int error = 0;
g_api_lis_trans = trans_create(TRANS_MODE_UNIX, 8192 * 4, 8192 * 4);
+ g_api_lis_trans->is_term = g_is_term;
g_snprintf(port, 255, "/tmp/.xrdp/xrdpapi_%d", g_display_num);
g_api_lis_trans->trans_conn_in = my_api_trans_conn_in;
error = trans_listen(g_api_lis_trans, port);
@@ -1058,7 +1068,9 @@ THREAD_RV THREAD_CC
channel_thread_loop(void *in_val)
{
tbus objs[32];
+ tbus wobjs[32];
int num_objs;
+ int num_wobjs;
int timeout;
int error;
THREAD_RV rv;
@@ -1072,12 +1084,13 @@ channel_thread_loop(void *in_val)
{
timeout = -1;
num_objs = 0;
+ num_wobjs = 0;
objs[num_objs] = g_term_event;
num_objs++;
trans_get_wait_objs(g_lis_trans, objs, &num_objs);
trans_get_wait_objs(g_api_lis_trans, objs, &num_objs);
- while (g_obj_wait(objs, num_objs, 0, 0, timeout) == 0)
+ while (g_obj_wait(objs, num_objs, wobjs, num_wobjs, timeout) == 0)
{
check_timeout();
if (g_is_wait_obj_set(g_term_event))
@@ -1152,10 +1165,12 @@ channel_thread_loop(void *in_val)
xfuse_check_wait_objs();
timeout = -1;
num_objs = 0;
+ num_wobjs = 0;
objs[num_objs] = g_term_event;
num_objs++;
trans_get_wait_objs(g_lis_trans, objs, &num_objs);
- trans_get_wait_objs(g_con_trans, objs, &num_objs);
+ trans_get_wait_objs_rw(g_con_trans, objs, &num_objs,
+ wobjs, &num_wobjs);
trans_get_wait_objs(g_api_lis_trans, objs, &num_objs);
trans_get_wait_objs(g_api_con_trans, objs, &num_objs);
xcommon_get_wait_objs(objs, &num_objs, &timeout);
@@ -1200,7 +1215,7 @@ child_signal_handler(int sig)
{
int i1;
- LOG(10, ("child_signal_handler:"));
+ LOG(0, ("child_signal_handler:"));
do
{
@@ -1217,6 +1232,14 @@ child_signal_handler(int sig)
while (i1 >= 0);
}
+void DEFAULT_CC
+segfault_signal_handler(int sig)
+{
+ LOG(0, ("segfault_signal_handler: entered......."));
+ xfuse_deinit();
+ exit(0);
+}
+
/*****************************************************************************/
static int APP_CC
get_display_num_from_display(char *display_text)
@@ -1471,6 +1494,8 @@ main(int argc, char **argv)
g_signal_user_interrupt(term_signal_handler); /* SIGINT */
g_signal_pipe(nil_signal_handler); /* SIGPIPE */
g_signal_child_stop(child_signal_handler); /* SIGCHLD */
+ g_signal_segfault(segfault_signal_handler);
+
display_text = g_getenv("DISPLAY");
LOGM((LOG_LEVEL_INFO, "main: DISPLAY env var set to %s", display_text));
get_display_num_from_display(display_text);
diff --git a/sesman/chansrv/chansrv.h b/sesman/chansrv/chansrv.h
index 4eb5752a..a3e8ed51 100644
--- a/sesman/chansrv/chansrv.h
+++ b/sesman/chansrv/chansrv.h
@@ -1,8 +1,8 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
- * Copyright (C) Jay Sorg 2009-2012
- * Copyright (C) Laxmikant Rashinkar 2009-2012
+ * Copyright (C) Jay Sorg 2009-2013
+ * Copyright (C) Laxmikant Rashinkar 2009-2013
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,11 +54,13 @@ struct xrdp_api_data
int is_connected;
};
+int DEFAULT_CC
+g_is_term(void);
+
int APP_CC send_channel_data(int chan_id, char *data, int size);
int APP_CC send_rail_drawing_orders(char* data, int size);
int APP_CC main_cleanup(void);
-int APP_CC
-add_timeout(int msoffset, void (*callback)(void* data), void* data);
+int APP_CC add_timeout(int msoffset, void (*callback)(void* data), void* data);
int APP_CC find_empty_slot_in_dvc_channels();
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);
diff --git a/sesman/chansrv/chansrv_fuse.c b/sesman/chansrv/chansrv_fuse.c
index 572679eb..2eb78ea0 100644
--- a/sesman/chansrv/chansrv_fuse.c
+++ b/sesman/chansrv/chansrv_fuse.c
@@ -102,6 +102,7 @@ void xfuse_devredir_cb_file_close(void *vp) {}
#include "os_calls.h"
#include "chansrv_fuse.h"
#include "list.h"
+#include "fifo.h"
#define min(x, y) ((x) < (y) ? (x) : (y))
@@ -223,6 +224,16 @@ struct dir_info
int index;
};
+/* queue FUSE opendir commands so we run only one at a time */
+struct opendir_req
+{
+ fuse_req_t req;
+ fuse_ino_t ino;
+ struct fuse_file_info *fi;
+};
+
+FIFO g_fifo_opendir;
+
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 */
@@ -338,19 +349,22 @@ static void xfuse_cb_create(fuse_req_t req, fuse_ino_t parent,
static void xfuse_cb_fsync(fuse_req_t req, fuse_ino_t ino, int datasync,
struct fuse_file_info *fi);
-/* clipboard calls */
-int clipboard_request_file_data(int stream_id, int lindex, int offset,
- int request_bytes);
-
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 int xfuse_proc_opendir_req(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);
+/* clipboard calls */
+int clipboard_request_file_data(int stream_id, int lindex, int offset,
+ int request_bytes);
+
/* misc calls */
static void xfuse_mark_as_stale(int pinode);
static void xfuse_delete_stale_entries(int pinode);
@@ -403,6 +417,9 @@ int xfuse_init()
if (xfuse_init_xrdp_fs())
return -1;
+ /* setup FIFOs */
+ fifo_init(&g_fifo_opendir, 30);
+
/* setup FUSE callbacks */
g_memset(&g_xfuse_ops, 0, sizeof(g_xfuse_ops));
g_xfuse_ops.lookup = xfuse_cb_lookup;
@@ -424,6 +441,8 @@ int xfuse_init()
fuse_opt_add_arg(&args, "xrdp-chansrv");
fuse_opt_add_arg(&args, g_fuse_root_path);
+ //fuse_opt_add_arg(&args, "-s"); /* single threaded mode */
+ //fuse_opt_add_arg(&args, "-d"); /* debug mode */
if (xfuse_init_lib(&args))
{
@@ -444,6 +463,7 @@ int xfuse_init()
int xfuse_deinit()
{
xfuse_deinit_xrdp_fs();
+ fifo_deinit(&g_fifo_opendir);
if (g_ch != 0)
{
@@ -901,12 +921,11 @@ static int xfuse_deinit_xrdp_fs()
static int xfuse_is_inode_valid(int ino)
{
- /* our lowest ino is FIRST_INODE */
- if (ino < FIRST_INODE)
+ /* is ino present in our table? */
+ if ((ino < FIRST_INODE) || (ino >= g_xrdp_fs.next_node))
return 0;
- /* is ino present in our table? */
- if (ino >= g_xrdp_fs.next_node)
+ if (g_xrdp_fs.inode_table[ino] == NULL)
return 0;
return 1;
@@ -989,6 +1008,11 @@ static void xfuse_dump_fs()
log_debug("found %d entries", g_xrdp_fs.num_entries - FIRST_INODE);
+#if 0
+ log_debug("not dumping xrdp fs");
+ return;
+#endif
+
for (i = FIRST_INODE; i < g_xrdp_fs.num_entries; i++)
{
if ((xinode = g_xrdp_fs.inode_table[i]) == NULL)
@@ -1229,6 +1253,9 @@ static int xfuse_delete_file_with_xinode(XRDP_INODE *xinode)
if ((xinode == NULL) || (xinode->mode & S_IFDIR))
return -1;
+ log_always("deleting: inode=%d name=%s", xinode->inode, xinode->name);
+ log_debug("deleting: inode=%d name=%s", xinode->inode, xinode->name);
+
g_xrdp_fs.inode_table[xinode->parent_inode]->nentries--;
g_xrdp_fs.inode_table[xinode->inode] = NULL;
free(xinode);
@@ -1281,6 +1308,12 @@ static int xfuse_recursive_delete_dir_with_xinode(XRDP_INODE *xinode)
if ((xinode == NULL) || (xinode->mode & S_IFREG))
return -1;
+ log_always("recursively deleting dir with inode=%d name=%s",
+ xinode->inode, xinode->name);
+
+ log_debug("recursively deleting dir with inode=%d name=%s",
+ xinode->inode, xinode->name);
+
for (i = FIRST_INODE; i < g_xrdp_fs.num_entries; i++)
{
if ((xip = g_xrdp_fs.inode_table[i]) == NULL)
@@ -1342,60 +1375,6 @@ 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)
-{
- XRDP_INODE *xinode;
- XRDP_INODE *xinode1;
- struct dirbuf b;
- int first_time = 1;
- int i;
-
- memset(&b, 0, sizeof(struct dirbuf));
-
- 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 != ino)
- continue;
-
- if (first_time)
- {
- first_time = 0;
- if (ino == 1)
- {
- xfuse_dirbuf_add(req, &b, ".", 1);
- xfuse_dirbuf_add(req, &b, "..", 1);
- }
- else
- {
- xinode1 = g_xrdp_fs.inode_table[ino];
- xfuse_dirbuf_add(req, &b, ".", ino);
- xfuse_dirbuf_add(req, &b, "..", xinode1->parent_inode);
- }
- }
-
- xfuse_dirbuf_add(req, &b, xinode->name, xinode->inode);
- }
-
- if (!first_time)
- {
- if (off < b.size)
- fuse_reply_buf(req, b.p + off, min(b.size - off, size));
- else
- fuse_reply_buf(req, NULL, 0);
- }
-
- if (b.p)
- free(b.p);
-}
-#endif
-
/******************************************************************************
** **
** callbacks for devredir **
@@ -1464,8 +1443,9 @@ void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode)
void xfuse_devredir_cb_enum_dir_done(void *vp, tui32 IoStatus)
{
- XFUSE_INFO *fip;
- struct dir_info *di;
+ XFUSE_INFO *fip;
+ struct dir_info *di;
+ struct opendir_req *odreq;
log_debug("vp=%p IoStatus=0x%x", vp, IoStatus);
@@ -1473,7 +1453,7 @@ void xfuse_devredir_cb_enum_dir_done(void *vp, tui32 IoStatus)
if (fip == NULL)
{
log_debug("fip is NULL");
- return;
+ goto done;
}
if (IoStatus != 0)
@@ -1506,6 +1486,22 @@ done:
if (fip)
free(fip);
+
+ /* remove current request */
+ g_free(fifo_remove(&g_fifo_opendir));
+
+ while (1)
+ {
+ /* process next request */
+ odreq = fifo_peek(&g_fifo_opendir);
+ if (!odreq)
+ return;
+
+ if (xfuse_proc_opendir_req(odreq->req, odreq->ino, odreq->fi))
+ g_free(fifo_remove(&g_fifo_opendir)); /* req failed */
+ else
+ break; /* req has been queued */
+ }
}
void xfuse_devredir_cb_open_file(void *vp, tui32 IoStatus, tui32 DeviceId,
@@ -1903,15 +1899,19 @@ static void xfuse_cb_getattr(fuse_req_t req, fuse_ino_t ino,
}
xino = g_xrdp_fs.inode_table[ino];
+ if (!xino)
+ {
+ log_debug("****** invalid ino=%d", (int) ino);
+ fuse_reply_err(req, EBADF);
+ return;
+ }
memset(&stbuf, 0, sizeof(stbuf));
stbuf.st_ino = ino;
stbuf.st_mode = xino->mode;
stbuf.st_nlink = xino->nlink;
stbuf.st_size = xino->size;
-
fuse_reply_attr(req, &stbuf, 1.0);
- log_debug("exiting");
}
/**
@@ -1977,8 +1977,7 @@ static void xfuse_cb_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
int i;
int first_time;
- log_debug("req=%p inode=%d name=%s size=%d offset=%d", req, ino,
- g_xrdp_fs.inode_table[ino]->name, size, off);
+ log_debug("req=%p inode=%d size=%d offset=%d", req, ino, size, off);
/* do we have a valid inode? */
if (!xfuse_is_inode_valid(ino))
@@ -2014,6 +2013,12 @@ static void xfuse_cb_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
{
first_time = 0;
ti = g_xrdp_fs.inode_table[ino];
+ if (!ti)
+ {
+ log_debug("****** g_xrdp_fs.inode_table[%d] is NULL", ino);
+ fuse_reply_buf(req, NULL, 0);
+ return;
+ }
xfuse_dirbuf_add1(req, &b, ".", ino);
xfuse_dirbuf_add1(req, &b, "..", ti->parent_inode);
}
@@ -2451,6 +2456,12 @@ static void xfuse_cb_open(fuse_req_t req, fuse_ino_t ino,
/* if ino points to a dir, fail the open request */
xinode = g_xrdp_fs.inode_table[ino];
+ if (!xinode)
+ {
+ log_debug("****** g_xrdp_fs.inode_table[%d] is NULL", ino);
+ fuse_reply_err(req, EBADF);
+ return;
+ }
if (xinode->mode & S_IFDIR)
{
log_debug("reading a dir not allowed!");
@@ -2491,8 +2502,6 @@ static void xfuse_cb_open(fuse_req_t req, fuse_ino_t ino,
fip->name[1023] = 0;
fip->reply_type = RT_FUSE_REPLY_OPEN;
- /* LK_TODO need to handle open permissions */
-
/* we want path minus 'root node of the share' */
if ((cptr = strchr(full_path, '/')) == NULL)
{
@@ -2532,6 +2541,12 @@ static void xfuse_cb_release(fuse_req_t req, fuse_ino_t ino, struct
}
XRDP_INODE *xinode = g_xrdp_fs.inode_table[ino];
+ if (!xinode)
+ {
+ log_debug("****** g_xrdp_fs.inode_table[%d] is NULL", ino);
+ fuse_reply_err(req, 0);
+ return;
+ }
if (xinode->is_loc_resource)
{
/* specified file is a local resource */
@@ -2748,7 +2763,12 @@ static void xfuse_cb_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr,
return;
}
- xinode = g_xrdp_fs.inode_table[ino];
+ if ((xinode = g_xrdp_fs.inode_table[ino]) == NULL)
+ {
+ log_debug("g_xrdp_fs.inode_table[%d] is NULL", ino);
+ fuse_reply_err(req, EBADF);
+ return;
+ }
if (to_set & FUSE_SET_ATTR_MODE)
{
@@ -2813,9 +2833,40 @@ 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 */
}
+/**
+ * Get dir listing
+ *****************************************************************************/
static void xfuse_cb_opendir(fuse_req_t req, fuse_ino_t ino,
struct fuse_file_info *fi)
{
+ struct opendir_req *odreq;
+
+ /* save request */
+ odreq = malloc(sizeof(struct opendir_req));
+ odreq->req = req;
+ odreq->ino = ino;
+ odreq->fi = fi;
+
+ if (fifo_is_empty(&g_fifo_opendir))
+ {
+ fifo_insert(&g_fifo_opendir, odreq);
+ xfuse_proc_opendir_req(req, ino, fi);
+ }
+ else
+ {
+ /* place req in FIFO; xfuse_devredir_cb_enum_dir_done() will handle it */
+ fifo_insert(&g_fifo_opendir, odreq);
+ }
+}
+
+/**
+ * Process the next opendir req
+ *
+ * @return 0 of the request was sent for remote lookup, -1 otherwise
+ *****************************************************************************/
+static int xfuse_proc_opendir_req(fuse_req_t req, fuse_ino_t ino,
+ struct fuse_file_info *fi)
+{
struct dir_info *di;
XRDP_INODE *xinode;
XFUSE_INFO *fip;
@@ -2823,19 +2874,26 @@ static void xfuse_cb_opendir(fuse_req_t req, fuse_ino_t ino,
char full_path[4096];
char *cptr;
- log_debug("inode=%d name=%s", ino, g_xrdp_fs.inode_table[ino]->name);
+ log_debug("inode=%d", ino);
if (!xfuse_is_inode_valid(ino))
{
log_error("inode %d is not valid", ino);
fuse_reply_err(req, EBADF);
- return;
+ g_free(fifo_remove(&g_fifo_opendir));
+ return -1;
}
if (ino == 1)
goto done; /* special case; enumerate top level dir */
- xinode = g_xrdp_fs.inode_table[ino];
+ if ((xinode = g_xrdp_fs.inode_table[ino]) == NULL)
+ {
+ log_debug("g_xrdp_fs.inode_table[%d] is NULL", ino);
+ fuse_reply_err(req, EBADF);
+ g_free(fifo_remove(&g_fifo_opendir));
+ return -1;
+ }
if (xinode->is_loc_resource)
goto done;
@@ -2846,7 +2904,8 @@ static void xfuse_cb_opendir(fuse_req_t req, fuse_ino_t ino,
if (xinode->is_synced)
{
xfuse_enum_dir(req, ino, size, off, fi);
- return;
+ g_free(fifo_remove(&g_fifo_opendir));
+ return -1;
}
else
{
@@ -2867,7 +2926,8 @@ do_remote_lookup:
{
log_error("system out of memory");
fuse_reply_err(req, ENOMEM);
- return;
+ g_free(fifo_remove(&g_fifo_opendir));
+ return -1;
}
fip->req = req;
@@ -2900,7 +2960,7 @@ do_remote_lookup:
}
}
- return;
+ return 0;
done:
@@ -2908,6 +2968,8 @@ done:
di->index = FIRST_INODE;
fi->fh = (long) di;
fuse_reply_open(req, fi);
+ g_free(fifo_remove(&g_fifo_opendir));
+ return -1;
}
/**
diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c
index 4003f6d9..25775f3b 100644
--- a/sesman/chansrv/clipboard.c
+++ b/sesman/chansrv/clipboard.c
@@ -294,7 +294,7 @@ get_atom_text(Atom atom)
}
if (!failed)
{
- name = get_atom_text(atom);
+ name = XGetAtomName(g_display, atom);
if (name == 0)
{
failed = 1;
diff --git a/sesman/chansrv/devredir.c b/sesman/chansrv/devredir.c
index 418c29e7..cdcc9e94 100644
--- a/sesman/chansrv/devredir.c
+++ b/sesman/chansrv/devredir.c
@@ -68,7 +68,7 @@
#define log_info(_params...) \
{ \
- if (LOG_INFO <= LOG_LEVEL) \
+ if (LOG_INFO <= LOG_LEVEL) \
{ \
g_write("[%10.10u]: DEV_REDIR %s: %d : ", \
g_time3(), __func__, __LINE__); \
@@ -78,7 +78,7 @@
#define log_debug(_params...) \
{ \
- if (LOG_DEBUG <= LOG_LEVEL) \
+ if (LOG_DEBUG <= LOG_LEVEL) \
{ \
g_write("[%10.10u]: DEV_REDIR %s: %d : ", \
g_time3(), __func__, __LINE__); \
@@ -587,53 +587,50 @@ void dev_redir_proc_client_core_cap_resp(struct stream *s)
tui16 cap_type;
tui16 cap_len;
tui32 cap_version;
+ char* holdp;
xstream_rd_u16_le(s, num_caps);
xstream_seek(s, 2); /* padding */
for (i = 0; i < num_caps; i++)
{
+ holdp = s->p;
xstream_rd_u16_le(s, cap_type);
xstream_rd_u16_le(s, cap_len);
xstream_rd_u32_le(s, cap_version);
- /* remove header length and version */
- cap_len -= 8;
-
switch (cap_type)
{
case CAP_GENERAL_TYPE:
log_debug("got CAP_GENERAL_TYPE");
- xstream_seek(s, cap_len);
break;
case CAP_PRINTER_TYPE:
log_debug("got CAP_PRINTER_TYPE");
g_is_printer_redir_supported = 1;
- xstream_seek(s, cap_len);
break;
case CAP_PORT_TYPE:
log_debug("got CAP_PORT_TYPE");
g_is_port_redir_supported = 1;
- xstream_seek(s, cap_len);
break;
case CAP_DRIVE_TYPE:
log_debug("got CAP_DRIVE_TYPE");
g_is_drive_redir_supported = 1;
if (cap_version == 2)
+ {
g_drive_redir_version = 2;
- xstream_seek(s, cap_len);
+ }
break;
case CAP_SMARTCARD_TYPE:
log_debug("got CAP_SMARTCARD_TYPE");
g_is_smartcard_redir_supported = 1;
scard_init();
- xstream_seek(s, cap_len);
break;
}
+ s->p = holdp + cap_len;
}
}
@@ -1101,7 +1098,11 @@ dev_redir_file_open(void *fusep, tui32 device_id, char *path,
#if 1
/* without the 0x00000010 rdesktop opens files in */
/* O_RDONLY instead of O_RDWR mode */
- DesiredAccess = DA_FILE_READ_DATA | DA_FILE_WRITE_DATA | DA_SYNCHRONIZE | 0x00000010;
+ if (mode & O_RDWR)
+ DesiredAccess = DA_FILE_READ_DATA | DA_FILE_WRITE_DATA | DA_SYNCHRONIZE | 0x00000010;
+ else
+ DesiredAccess = DA_FILE_READ_DATA | DA_SYNCHRONIZE;
+
CreateOptions = CO_FILE_SYNCHRONOUS_IO_NONALERT;
CreateDisposition = CD_FILE_OPEN; // WAS 1
#else
diff --git a/sesman/chansrv/fifo.c b/sesman/chansrv/fifo.c
new file mode 100644
index 00000000..630df3cd
--- /dev/null
+++ b/sesman/chansrv/fifo.c
@@ -0,0 +1,255 @@
+/**
+ * xrdp: A Remote Desktop Protocol server.
+ *
+ * Copyright (C) Laxmikant Rashinkar 2013 LK.Rashinkar@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.
+ */
+
+ /* FIFO implementation to store a pointer to a user struct */
+
+/* module based logging */
+#define MODULE_NAME "FIFO "
+#define LOCAL_DEBUG
+
+#include "fifo.h"
+#include "mlog.h"
+
+/**
+ * Initialize a FIFO that grows as required
+ *
+ * @param fp pointer to a FIFO
+ * @param num_entries initial size
+ *
+ * @return 0 on success, -1 on failure
+ *****************************************************************************/
+int
+fifo_init(FIFO* fp, int num_entries)
+{
+ log_debug_high("entered");
+
+ /* validate params */
+ if (!fp)
+ {
+ log_debug_high("invalid parameters");
+ return -1;
+ }
+
+ if (num_entries < 1)
+ num_entries = 10;
+
+ fp->rd_ptr = 0;
+ fp->wr_ptr = 0;
+ fp->user_data = (long *) g_malloc(sizeof(long) * num_entries);
+
+ if (fp->user_data)
+ {
+ fp->entries = num_entries;
+ log_debug_low("FIFO created; rd_ptr=%d wr_ptr=%d entries=%d",
+ fp->rd_ptr, fp->wr_ptr, fp->entries);
+ return 0;
+ }
+ else
+ {
+ log_error("FIFO create error; system out of memory");
+ fp->entries = 0;
+ return -1;
+ }
+}
+
+/**
+ * Deinit FIFO and release resources
+ *
+ * @param fp FIFO to deinit
+ *
+ * @return 0 on success, -1 on error
+ *****************************************************************************/
+int
+fifo_deinit(FIFO* fp)
+{
+ log_debug_high("entered");
+
+ if (!fp)
+ {
+ log_debug_high("FIFO is null");
+ return -1;
+ }
+
+ if (fp->user_data)
+ {
+ g_free(fp->user_data);
+ fp->user_data = 0;
+ }
+
+ fp->rd_ptr = 0;
+ fp->wr_ptr = 0;
+ fp->entries = 0;
+}
+
+/**
+ * Check if FIFO is empty
+ *
+ * @param fp FIFO
+ *
+ * @return 1 if FIFO is empty, 0 otherwise
+ *****************************************************************************/
+int
+fifo_is_empty(FIFO* fp)
+{
+ log_debug_high("entered");
+
+ if (!fp)
+ {
+ log_debug_high("FIFO is null");
+ return 0;
+ }
+
+ return (fp->rd_ptr == fp->wr_ptr) ? 1 : 0;
+}
+
+/**
+ * Insert an item at the end
+ *
+ * @param fp FIFO
+ * @param data data to insert into FIFO
+ *
+ * @param 0 on success, -1 on error
+ *****************************************************************************/
+
+int
+fifo_insert(FIFO* fp, void* data)
+{
+ long* lp;
+ int next_val; /* next value for wr_ptr */
+ int i;
+
+ log_debug_high("entered");
+
+ if (!fp)
+ {
+ log_debug_high("FIFO is null");
+ return -1;
+ }
+
+ next_val = fp->wr_ptr + 1;
+ if (next_val >= fp->entries)
+ next_val = 0;
+
+ if (next_val == fp->rd_ptr)
+ {
+ /* FIFO is full, expand it by 10 entries */
+ lp = (long *) g_malloc(sizeof(long) * (fp->entries + 10));
+ if (!lp)
+ {
+ log_debug_low("FIFO full; cannot expand, no memory");
+ return -1;
+ }
+
+ log_debug_low("FIFO full, expanding by 10 entries");
+
+ /* copy old data new location */
+ for (i = 0; i < (fp->entries - 1); i++)
+ {
+ lp[i] = fp->user_data[fp->rd_ptr++];
+ if (fp->rd_ptr >= fp->entries)
+ fp->rd_ptr = 0;
+ }
+
+ /* update pointers */
+ fp->rd_ptr = 0;
+ fp->wr_ptr = fp->entries - 1;
+ next_val = fp->entries;
+ fp->entries += 10;
+
+ /* free old data */
+ g_free(fp->user_data);
+ fp->user_data = lp;
+ }
+
+ log_debug_low("inserting data at index %d", fp->wr_ptr);
+
+ fp->user_data[fp->wr_ptr] = (long) data;
+ fp->wr_ptr = next_val;
+
+ return 0;
+}
+
+/**
+ * Remove an item from the head
+ *
+ * @param fp FIFO
+ *
+ * @param data on success, NULL on error
+ *****************************************************************************/
+void*
+fifo_remove(FIFO* fp)
+{
+ long data;
+
+ log_debug_high("entered");
+
+ if (!fp)
+ {
+ log_debug_high("FIFO is null");
+ return 0;
+ }
+
+ if (fp->rd_ptr == fp->wr_ptr)
+ {
+ log_debug_high("FIFO is empty");
+ return 0;
+ }
+
+ log_debug_low("removing data at index %d", fp->rd_ptr);
+
+ data = fp->user_data[fp->rd_ptr++];
+
+ if (fp->rd_ptr >= fp->entries)
+ {
+ log_debug_high("FIFO rd_ptr wrapped around");
+ fp->rd_ptr = 0;
+ }
+
+ return (void *) data;
+}
+
+/**
+ * Return item from head, but do not remove it
+ *
+ * @param fp FIFO
+ *
+ * @param data on success, NULL on error
+ *****************************************************************************/
+void*
+fifo_peek(FIFO* fp)
+{
+ long data;
+
+ log_debug_high("entered\n");
+
+ if (!fp)
+ {
+ log_debug_high("FIFO is null\n");
+ return 0;
+ }
+
+ if (fp->rd_ptr == fp->wr_ptr)
+ {
+ log_debug_high("FIFO is empty\n");
+ return 0;
+ }
+
+ log_debug_low("peeking data at index %d\n", fp->rd_ptr);
+
+ return (void *) fp->user_data[fp->rd_ptr];
+}
diff --git a/freerdp/xrdp-color.h b/sesman/chansrv/fifo.h
index 3c58c032..0a23592c 100644
--- a/freerdp/xrdp-color.h
+++ b/sesman/chansrv/fifo.h
@@ -1,7 +1,7 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
- * Copyright (C) Jay Sorg 2004-2012
+ * Copyright (C) Laxmikant Rashinkar 2013 LK.Rashinkar@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,13 +16,20 @@
* limitations under the License.
*/
-#ifndef __XRDP_COLOR_H
-#define __XRDP_COLOR_H
+ /* FIFO implementation to store a pointer to a user struct */
-char* APP_CC
-convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
- int width, int height, int* palette);
-int APP_CC
-convert_color(int in_bpp, int out_bpp, int in_color, int* palette);
+typedef struct fifo
+{
+ long* user_data;
+ int rd_ptr;
+ int wr_ptr;
+ int entries;
+} FIFO;
+
+int fifo_init(FIFO* fp, int num_entries);
+int fifo_deinit(FIFO* fp);
+int fifo_is_empty(FIFO* fp);
+int fifo_insert(FIFO* fp, void* data);
+void* fifo_remove(FIFO* fp);
+void* fifo_peek(FIFO* fp);
-#endif
diff --git a/sesman/chansrv/irp.h b/sesman/chansrv/irp.h
index e1a65d83..a13ea8e5 100644
--- a/sesman/chansrv/irp.h
+++ b/sesman/chansrv/irp.h
@@ -52,6 +52,7 @@ struct irp
void (*callback)(struct stream *s, IRP *irp, tui32 DeviceId,
tui32 CompletionId, tui32 IoStatus);
+ void *user_data;
};
IRP * APP_CC devredir_irp_new(void);
diff --git a/sesman/chansrv/mlog.h b/sesman/chansrv/mlog.h
new file mode 100644
index 00000000..866c9692
--- /dev/null
+++ b/sesman/chansrv/mlog.h
@@ -0,0 +1,112 @@
+/**
+ * xrdp: A Remote Desktop Protocol server.
+ *
+ * Copyright (C) Laxmikant Rashinkar 2013 LK.Rashinkar@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.
+ */
+
+ /* module based logging */
+
+#ifndef _MLOG_H
+#define _MLOG_H
+
+/*
+ * Note1: to enable debug messages, in your .c file, #define LOCAL_DEBUG
+ * BEFORE including this file
+ *
+ * Note2: in your .c file, #define MODULE_NAME, 8 chars long, to print each
+ * log entry with your module name
+ */
+
+#define LOG_ERROR 0
+#define LOG_INFO 1
+#define LOG_DEBUG_LOW 2
+#define LOG_DEBUG_HIGH 3
+#define LOG_LEVEL LOG_ERROR
+
+/*
+ * print always
+ */
+
+#define log_error(_params...) \
+do \
+{ \
+ g_write("[%10.10u]: %s %s: %d: ERROR: ", g_time3(), \
+ MODULE_NAME, __func__, __LINE__); \
+ g_writeln (_params); \
+} \
+while(0)
+
+#define log_always(_params...) \
+do \
+{ \
+ g_write("[%10.10u]: %s %s: %d: ALWAYS: ", g_time3(), \
+ MODULE_NAME, __func__, __LINE__); \
+ g_writeln (_params); \
+} \
+while(0)
+
+/*
+ * print conditionally
+ */
+
+#ifdef LOCAL_DEBUG
+#define log_info(_params...) \
+do \
+{ \
+ if (LOG_INFO <= LOG_LEVEL) \
+ { \
+ g_write("[%10.10u]: %s %s: %d: INFO: ", g_time3(), \
+ MODULE_NAME, __func__, __LINE__); \
+ g_writeln (_params); \
+ } \
+} \
+while(0)
+#else
+#define log_info(_params...)
+#endif
+
+#ifdef LOCAL_DEBUG
+#define log_debug_low(_params...) \
+do \
+{ \
+ if (LOG_DEBUG_LOW <= LOG_LEVEL) \
+ { \
+ g_write("[%10.10u]: %s %s: %d: DEBUG: ", g_time3(), \
+ MODULE_NAME, __func__, __LINE__); \
+ g_writeln (_params); \
+ } \
+} \
+while(0)
+#else
+#define log_debug_low(_params...)
+#endif
+
+#ifdef LOCAL_DEBUG
+#define log_debug_high(_params...) \
+do \
+{ \
+ if (LOG_DEBUG_HIGH <= LOG_LEVEL) \
+ { \
+ g_write("[%10.10u]: %s %s: %d: DEBUG: ", g_time3(), \
+ MODULE_NAME, __func__, __LINE__); \
+ g_writeln (_params); \
+ } \
+} \
+while(0)
+#else
+#define log_debug_high(_params...)
+#endif
+
+#endif /* #ifndef _MLOG_H */
diff --git a/sesman/chansrv/pcsc/Makefile b/sesman/chansrv/pcsc/Makefile
new file mode 100644
index 00000000..483151f2
--- /dev/null
+++ b/sesman/chansrv/pcsc/Makefile
@@ -0,0 +1,12 @@
+
+OBJS = xrdp_pcsc.o
+
+CFLAGS = -Wall -O2 -fPIC
+
+all: libpcsclite.so
+
+libpcsclite.so: $(OBJS)
+ $(CC) $(LDFLAGS) -shared -o libpcsclite.so $(OBJS)
+
+clean:
+ rm -f $(OBJS) libpcsclite.so
diff --git a/sesman/chansrv/pcsc/xrdp_pcsc.c b/sesman/chansrv/pcsc/xrdp_pcsc.c
new file mode 100644
index 00000000..b93dba12
--- /dev/null
+++ b/sesman/chansrv/pcsc/xrdp_pcsc.c
@@ -0,0 +1,856 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <pthread.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/stat.h>
+
+#define PCSC_API
+
+typedef unsigned char BYTE;
+typedef BYTE *LPBYTE;
+typedef unsigned int LONG;
+typedef unsigned int DWORD;
+typedef DWORD *LPDWORD;
+typedef const void *LPCVOID;
+typedef const char *LPCSTR;
+typedef char *LPSTR;
+typedef void *LPVOID;
+typedef const BYTE *LPCBYTE;
+
+typedef LONG SCARDCONTEXT;
+typedef SCARDCONTEXT *LPSCARDCONTEXT;
+
+typedef LONG SCARDHANDLE;
+typedef SCARDHANDLE *LPSCARDHANDLE;
+
+#define MAX_ATR_SIZE 33
+
+typedef struct _SCARD_READERSTATE
+{
+ const char *szReader;
+ void *pvUserData;
+ DWORD dwCurrentState;
+ DWORD dwEventState;
+ DWORD cbAtr;
+ unsigned char rgbAtr[MAX_ATR_SIZE];
+} SCARD_READERSTATE, *LPSCARD_READERSTATE;
+
+typedef struct _SCARD_IO_REQUEST
+{
+ unsigned long dwProtocol;
+ unsigned long cbPciLength;
+} SCARD_IO_REQUEST, *PSCARD_IO_REQUEST, *LPSCARD_IO_REQUEST;
+
+#define LLOG_LEVEL 5
+#define LLOGLN(_level, _args) \
+ do { if (_level < LLOG_LEVEL) { printf _args ; printf("\n"); } } while (0)
+
+#define SCARD_ESTABLISH_CONTEXT 0x01
+#define SCARD_RELEASE_CONTEXT 0x02
+#define SCARD_LIST_READERS 0x03
+#define SCARD_CONNECT 0x04
+#define SCARD_RECONNECT 0x05
+#define SCARD_DISCONNECT 0x06
+#define SCARD_BEGIN_TRANSACTION 0x07
+#define SCARD_END_TRANSACTION 0x08
+#define SCARD_TRANSMIT 0x09
+#define SCARD_CONTROL 0x0A
+#define SCARD_STATUS 0x0B
+#define SCARD_GET_STATUS_CHANGE 0x0C
+#define SCARD_CANCEL 0x0D
+#define SCARD_CANCEL_TRANSACTION 0x0E
+#define SCARD_GET_ATTRIB 0x0F
+#define SCARD_SET_ATTRIB 0x10
+
+#define SCARD_S_SUCCESS 0x00000000
+#define SCARD_F_INTERNAL_ERROR ((LONG)0x80100001)
+
+#define SET_UINT32(_data, _offset, _val) do { \
+ (((BYTE*)(_data)) + (_offset))[0] = ((_val) >> 0) & 0xff; \
+ (((BYTE*)(_data)) + (_offset))[1] = ((_val) >> 8) & 0xff; \
+ (((BYTE*)(_data)) + (_offset))[2] = ((_val) >> 16) & 0xff; \
+ (((BYTE*)(_data)) + (_offset))[3] = ((_val) >> 24) & 0xff; } while (0)
+
+#define GET_UINT32(_data, _offset) \
+ ((((BYTE*)(_data)) + (_offset))[0] << 0) | \
+ ((((BYTE*)(_data)) + (_offset))[1] << 8) | \
+ ((((BYTE*)(_data)) + (_offset))[2] << 16) | \
+ ((((BYTE*)(_data)) + (_offset))[3] << 24)
+
+#define LMIN(_val1, _val2) (_val1) < (_val2) ? (_val1) : (_val2)
+#define LMAX(_val1, _val2) (_val1) > (_val2) ? (_val1) : (_val2)
+
+static int g_sck = -1; /* unix domain socket */
+
+static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* for pcsc_stringify_error */
+static char g_error_str[512];
+
+/*****************************************************************************/
+static int
+get_display_num_from_display(const char *display_text)
+{
+ int rv;
+ int index;
+ int mode;
+ int host_index;
+ int disp_index;
+ int scre_index;
+ char host[256];
+ char disp[256];
+ char scre[256];
+
+ memset(host, 0, 256);
+ memset(disp, 0, 256);
+ memset(scre, 0, 256);
+
+ index = 0;
+ host_index = 0;
+ disp_index = 0;
+ scre_index = 0;
+ mode = 0;
+
+ while (display_text[index] != 0)
+ {
+ if (display_text[index] == ':')
+ {
+ mode = 1;
+ }
+ else if (display_text[index] == '.')
+ {
+ mode = 2;
+ }
+ else if (mode == 0)
+ {
+ host[host_index] = display_text[index];
+ host_index++;
+ }
+ else if (mode == 1)
+ {
+ disp[disp_index] = display_text[index];
+ disp_index++;
+ }
+ else if (mode == 2)
+ {
+ scre[scre_index] = display_text[index];
+ scre_index++;
+ }
+ index++;
+ }
+ host[host_index] = 0;
+ disp[disp_index] = 0;
+ scre[scre_index] = 0;
+ LLOGLN(0, ("get_display_num_from_display: host [%s] disp [%s] scre [%s]",
+ host, disp, scre));
+ rv = atoi(disp);
+ return rv;
+}
+
+/*****************************************************************************/
+static int
+connect_to_chansrv(void)
+{
+ int bytes;
+ int dis;
+ int error;
+ char *xrdp_session;
+ char *xrdp_display;
+ char *home_str;
+ struct sockaddr_un saddr;
+ struct sockaddr *psaddr;
+
+ if (g_sck != -1)
+ {
+ /* already connected */
+ return 0;
+ }
+ xrdp_session = getenv("XRDP_SESSION");
+ if (xrdp_session == NULL)
+ {
+ /* XRDP_SESSION must be set */
+ LLOGLN(0, ("connect_to_chansrv: error, not xrdp session"));
+ return 1;
+ }
+ xrdp_display = getenv("DISPLAY");
+ if (xrdp_display == NULL)
+ {
+ /* DISPLAY must be set */
+ LLOGLN(0, ("connect_to_chansrv: error, display not set"));
+ return 1;
+ }
+ home_str = getenv("HOME");
+ if (home_str == NULL)
+ {
+ /* HOME must be set */
+ LLOGLN(0, ("connect_to_chansrv: error, home not set"));
+ return 1;
+ }
+ dis = get_display_num_from_display(xrdp_display);
+ if (dis < 10)
+ {
+ /* DISPLAY must be > 9 */
+ LLOGLN(0, ("connect_to_chansrv: error, display not > 9 %d", dis));
+ return 1;
+ }
+ g_sck = socket(PF_LOCAL, SOCK_STREAM, 0);
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("connect_to_chansrv: error, socket failed"));
+ return 1;
+ }
+ memset(&saddr, 0, sizeof(struct sockaddr_un));
+ saddr.sun_family = AF_UNIX;
+ bytes = sizeof(saddr.sun_path);
+ snprintf(saddr.sun_path, bytes, "%s/.pcsc%d/pcscd.comm", home_str, dis);
+ saddr.sun_path[bytes - 1] = 0;
+ LLOGLN(0, ("connect_to_chansrv: connecting to %s", saddr.sun_path));
+ psaddr = (struct sockaddr *) &saddr;
+ bytes = sizeof(struct sockaddr_un);
+ error = connect(g_sck, psaddr, bytes);
+ if (error == 0)
+ {
+ }
+ else
+ {
+ perror("connect_to_chansrv");
+ close(g_sck);
+ g_sck = -1;
+ LLOGLN(0, ("connect_to_chansrv: error, open %s", saddr.sun_path));
+ return 1;
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+static int
+send_message(int code, char *data, int bytes)
+{
+ char header[8];
+
+ SET_UINT32(header, 0, bytes);
+ SET_UINT32(header, 4, code);
+ if (send(g_sck, header, 8, 0) != 8)
+ {
+ return 1;
+ }
+ if (send(g_sck, data, bytes, 0) != bytes)
+ {
+ return 1;
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+static int
+get_message(int *code, char *data, int *bytes)
+{
+ char header[8];
+ int max_bytes;
+
+ if (recv(g_sck, header, 8, 0) != 8)
+ {
+ return 1;
+ }
+ max_bytes = *bytes;
+ *bytes = GET_UINT32(header, 0);
+ *code = GET_UINT32(header, 4);
+ if (*bytes > max_bytes)
+ {
+ return 1;
+ }
+ if (recv(g_sck, data, *bytes, 0) != *bytes)
+ {
+ return 1;
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardEstablishContext(DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2,
+ LPSCARDCONTEXT phContext)
+{
+ char msg[256];
+ DWORD context;
+ int code;
+ int bytes;
+ int status;
+
+ LLOGLN(0, ("SCardEstablishContext:"));
+ if (g_sck == -1)
+ {
+ if (connect_to_chansrv() != 0)
+ {
+ LLOGLN(0, ("SCardEstablishContext: error, can not connect "
+ "to chansrv"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ }
+ pthread_mutex_lock(&g_mutex);
+ SET_UINT32(msg, 0, dwScope);
+ if (send_message(SCARD_ESTABLISH_CONTEXT, msg, 4) != 0)
+ {
+ LLOGLN(0, ("SCardEstablishContext: error, send_message"));
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ bytes = 256;
+ if (get_message(&code, msg, &bytes) != 0)
+ {
+ LLOGLN(0, ("SCardEstablishContext: error, get_message"));
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ if ((code != SCARD_ESTABLISH_CONTEXT) || (bytes != 8))
+ {
+ LLOGLN(0, ("SCardEstablishContext: error, bad code"));
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_unlock(&g_mutex);
+ context = GET_UINT32(msg, 0);
+ status = GET_UINT32(msg, 4);
+ LLOGLN(10, ("SCardEstablishContext: got context 0x%8.8x", context));
+ *phContext = context;
+ return status;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardReleaseContext(SCARDCONTEXT hContext)
+{
+ char msg[256];
+ int code;
+ int bytes;
+ int status;
+
+ LLOGLN(0, ("SCardReleaseContext:"));
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("SCardReleaseContext: error, not connected"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_lock(&g_mutex);
+ SET_UINT32(msg, 0, hContext);
+ if (send_message(SCARD_RELEASE_CONTEXT, msg, 4) != 0)
+ {
+ LLOGLN(0, ("SCardReleaseContext: error, send_message"));
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ bytes = 256;
+ if (get_message(&code, msg, &bytes) != 0)
+ {
+ LLOGLN(0, ("SCardReleaseContext: error, get_message"));
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ if ((code != SCARD_RELEASE_CONTEXT) || (bytes != 4))
+ {
+ LLOGLN(0, ("SCardReleaseContext: error, bad code"));
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_unlock(&g_mutex);
+ status = GET_UINT32(msg, 0);
+ LLOGLN(10, ("SCardReleaseContext: got status 0x%8.8x", status));
+ return status;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardIsValidContext(SCARDCONTEXT hContext)
+{
+ LLOGLN(0, ("SCardIsValidContext:"));
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("SCardIsValidContext: error, not connected"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_lock(&g_mutex);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_S_SUCCESS;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardConnect(SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode,
+ DWORD dwPreferredProtocols, LPSCARDHANDLE phCard,
+ LPDWORD pdwActiveProtocol)
+{
+ char msg[256];
+ int code;
+ int bytes;
+ int status;
+ int offset;
+
+ LLOGLN(0, ("SCardConnect:"));
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("SCardConnect: error, not connected"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_lock(&g_mutex);
+ offset = 0;
+ SET_UINT32(msg, offset, hContext);
+ offset += 4;
+ bytes = strlen(szReader);
+ if (bytes > 99)
+ {
+ LLOGLN(0, ("SCardConnect: error, name too long"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ memcpy(msg + offset, szReader, bytes);
+ memset(msg + bytes, 0, 100 - bytes);
+ offset += 100;
+ SET_UINT32(msg, offset, dwShareMode);
+ offset += 4;
+ SET_UINT32(msg, offset, dwPreferredProtocols);
+ offset += 4;
+ if (send_message(SCARD_CONNECT, msg, offset) != 0)
+ {
+ LLOGLN(0, ("SCardConnect: error, send_message"));
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ bytes = 256;
+ if (get_message(&code, msg, &bytes) != 0)
+ {
+ LLOGLN(0, ("SCardConnect: error, get_message"));
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ if (code != SCARD_CONNECT)
+ {
+ LLOGLN(0, ("SCardConnect: error, bad code"));
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_unlock(&g_mutex);
+ *phCard = GET_UINT32(msg, 0);
+ *pdwActiveProtocol = GET_UINT32(msg, 4);
+ status = GET_UINT32(msg, 8);
+ LLOGLN(10, ("SCardReleaseContext: got status 0x%8.8x", status));
+ return status;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardReconnect(SCARDHANDLE hCard, DWORD dwShareMode,
+ DWORD dwPreferredProtocols, DWORD dwInitialization,
+ LPDWORD pdwActiveProtocol)
+{
+ LLOGLN(0, ("SCardReconnect:"));
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("SCardReconnect: error, not connected"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_lock(&g_mutex);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_S_SUCCESS;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardDisconnect(SCARDHANDLE hCard, DWORD dwDisposition)
+{
+ LLOGLN(0, ("SCardDisconnect:"));
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("SCardDisconnect: error, not connected"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_lock(&g_mutex);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_S_SUCCESS;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardBeginTransaction(SCARDHANDLE hCard)
+{
+ char msg[256];
+ int code;
+ int bytes;
+ int status;
+
+ LLOGLN(0, ("SCardBeginTransaction:"));
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("SCardBeginTransaction: error, not connected"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_lock(&g_mutex);
+ SET_UINT32(msg, 0, hCard);
+ if (send_message(SCARD_BEGIN_TRANSACTION, msg, 4) != 0)
+ {
+ LLOGLN(0, ("SCardBeginTransaction: error, send_message"));
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ bytes = 256;
+ if (get_message(&code, msg, &bytes) != 0)
+ {
+ LLOGLN(0, ("SCardBeginTransaction: error, get_message"));
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ if ((code != SCARD_BEGIN_TRANSACTION) || (bytes != 4))
+ {
+ LLOGLN(0, ("SCardBeginTransaction: error, bad code"));
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_unlock(&g_mutex);
+ status = GET_UINT32(msg, 0);
+ LLOGLN(10, ("SCardBeginTransaction: got status 0x%8.8x", status));
+ return status;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition)
+{
+ LLOGLN(0, ("SCardEndTransaction:"));
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("SCardEndTransaction: error, not connected"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_lock(&g_mutex);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_S_SUCCESS;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardStatus(SCARDHANDLE hCard, LPSTR mszReaderName, LPDWORD pcchReaderLen,
+ LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr,
+ LPDWORD pcbAtrLen)
+{
+ LLOGLN(0, ("SCardStatus:"));
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("SCardStatus: error, not connected"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_lock(&g_mutex);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_S_SUCCESS;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout,
+ LPSCARD_READERSTATE rgReaderStates, DWORD cReaders)
+{
+ char *msg;
+ int bytes;
+ int code;
+ int index;
+ int offset;
+ int str_len;
+ int status;
+
+ LLOGLN(0, ("SCardGetStatusChange:"));
+ LLOGLN(10, (" dwTimeout %d cReaders %d", dwTimeout, cReaders));
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("SCardGetStatusChange: error, not connected"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ msg = (char *) malloc(8192);
+ SET_UINT32(msg, 0, hContext);
+ SET_UINT32(msg, 4, dwTimeout);
+ SET_UINT32(msg, 8, cReaders);
+ offset = 12;
+ for (index = 0; index < cReaders; index++)
+ {
+ str_len = strlen(rgReaderStates[index].szReader);
+ str_len = LMIN(str_len, 99);
+ memset(msg + offset, 0, 100);
+ memcpy(msg + offset, rgReaderStates[index].szReader, str_len);
+ offset += 100;
+ LLOGLN(10, (" in dwCurrentState %d", rgReaderStates[index].dwCurrentState));
+ SET_UINT32(msg, offset, rgReaderStates[index].dwCurrentState);
+ offset += 4;
+ LLOGLN(10, (" in dwEventState %d", rgReaderStates[index].dwEventState));
+ SET_UINT32(msg, offset, rgReaderStates[index].dwEventState);
+ offset += 4;
+ LLOGLN(10, (" in cbAtr %d", rgReaderStates[index].cbAtr));
+ SET_UINT32(msg, offset, rgReaderStates[index].cbAtr);
+ offset += 4;
+ memset(msg + offset, 0, 36);
+ memcpy(msg + offset, rgReaderStates[index].rgbAtr, 33);
+ offset += 36;
+ }
+ pthread_mutex_lock(&g_mutex);
+ if (send_message(SCARD_GET_STATUS_CHANGE, msg, offset) != 0)
+ {
+ LLOGLN(0, ("SCardGetStatusChange: error, send_message"));
+ free(msg);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ bytes = 8192;
+ if (get_message(&code, msg, &bytes) != 0)
+ {
+ LLOGLN(0, ("SCardGetStatusChange: error, get_message"));
+ free(msg);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ if (code != SCARD_GET_STATUS_CHANGE)
+ {
+ LLOGLN(0, ("SCardGetStatusChange: error, bad code"));
+ free(msg);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_unlock(&g_mutex);
+ cReaders = GET_UINT32(msg, 0);
+ offset = 4;
+ LLOGLN(10, ("SCardGetStatusChange: got back cReaders %d", cReaders));
+ for (index = 0; index < cReaders; index++)
+ {
+ rgReaderStates[index].dwCurrentState = GET_UINT32(msg, offset);
+ offset += 4;
+ LLOGLN(10, (" out dwCurrentState %d", rgReaderStates[index].dwCurrentState));
+ rgReaderStates[index].dwEventState = GET_UINT32(msg, offset);
+ offset += 4;
+ LLOGLN(10, (" out dwEventState %d", rgReaderStates[index].dwEventState));
+ rgReaderStates[index].cbAtr = GET_UINT32(msg, offset);
+ offset += 4;
+ LLOGLN(10, (" out cbAtr %d", rgReaderStates[index].cbAtr));
+ memcpy(rgReaderStates[index].rgbAtr, msg + offset, 33);
+ offset += 36;
+ }
+ status = GET_UINT32(msg, offset);
+ offset += 4;
+ free(msg);
+ return status;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer,
+ DWORD cbSendLength, LPVOID pbRecvBuffer, DWORD cbRecvLength,
+ LPDWORD lpBytesReturned)
+{
+ LLOGLN(0, ("SCardControl:"));
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("SCardControl: error, not connected"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_lock(&g_mutex);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_S_SUCCESS;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardTransmit(SCARDHANDLE hCard, const SCARD_IO_REQUEST *pioSendPci,
+ LPCBYTE pbSendBuffer, DWORD cbSendLength,
+ SCARD_IO_REQUEST *pioRecvPci, LPBYTE pbRecvBuffer,
+ LPDWORD pcbRecvLength)
+{
+ LLOGLN(0, ("SCardTransmit:"));
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("SCardTransmit: error, not connected"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_lock(&g_mutex);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_S_SUCCESS;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardListReaderGroups(SCARDCONTEXT hContext, LPSTR mszGroups,
+ LPDWORD pcchGroups)
+{
+ LLOGLN(0, ("SCardListReaderGroups:"));
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("SCardListReaderGroups: error, not connected"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_lock(&g_mutex);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_S_SUCCESS;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardListReaders(SCARDCONTEXT hContext, LPCSTR mszGroups, LPSTR mszReaders,
+ LPDWORD pcchReaders)
+{
+ char* msg;
+ char* reader_names;
+ int reader_names_index;
+ int code;
+ int bytes;
+ int num_readers;
+ int status;
+ int offset;
+ int index;
+ char reader[100];
+
+ LLOGLN(0, ("SCardListReaders:"));
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("SCardListReaders: error, not connected"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ msg = (char *) malloc(8192);
+ pthread_mutex_lock(&g_mutex);
+ SET_UINT32(msg, 0, hContext);
+ if (send_message(SCARD_LIST_READERS, msg, 4) != 0)
+ {
+ LLOGLN(0, ("SCardListReaders: error, send_message"));
+ free(msg);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ bytes = 8192;
+ if (get_message(&code, msg, &bytes) != 0)
+ {
+ LLOGLN(0, ("SCardListReaders: error, get_message"));
+ free(msg);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ if (code != SCARD_LIST_READERS)
+ {
+ LLOGLN(0, ("SCardListReaders: error, bad code"));
+ free(msg);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_unlock(&g_mutex);
+ offset = 0;
+ num_readers = GET_UINT32(msg, offset);
+ offset += 4;
+ LLOGLN(10, ("hi - mszReaders %p pcchReaders %p num_readers %d", mszReaders, pcchReaders, num_readers));
+ reader_names = (char *) malloc(8192);
+ reader_names_index = 0;
+ for (index = 0; index < num_readers; index++)
+ {
+ memcpy(reader, msg + offset, 100);
+ bytes = strlen(reader);
+ memcpy(reader_names + reader_names_index, reader, bytes);
+ reader_names_index += bytes;
+ reader_names[reader_names_index] = 0;
+ reader_names_index++;
+ offset += 100;
+ LLOGLN(10, ("SCardListReaders: readername %s", reader));
+ }
+ reader_names[reader_names_index] = 0;
+ reader_names_index++;
+ status = GET_UINT32(msg, offset);
+ offset += 4;
+ if (pcchReaders != 0)
+ {
+ *pcchReaders = reader_names_index;
+ }
+ if (mszReaders != 0)
+ {
+ memcpy(mszReaders, reader_names, reader_names_index);
+ }
+ free(msg);
+ free(reader_names);
+ return status;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardFreeMemory(SCARDCONTEXT hContext, LPCVOID pvMem)
+{
+ LLOGLN(0, ("SCardFreeMemory:"));
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("SCardFreeMemory: error, not connected"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_lock(&g_mutex);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_S_SUCCESS;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardCancel(SCARDCONTEXT hContext)
+{
+ LLOGLN(0, ("SCardCancel:"));
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("SCardCancel: error, not connected"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_lock(&g_mutex);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_S_SUCCESS;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr,
+ LPDWORD pcbAttrLen)
+{
+ LLOGLN(0, ("SCardGetAttrib:"));
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("SCardGetAttrib: error, not connected"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_lock(&g_mutex);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_S_SUCCESS;
+}
+
+/*****************************************************************************/
+PCSC_API LONG
+SCardSetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr,
+ DWORD cbAttrLen)
+{
+ LLOGLN(0, ("SCardSetAttrib:"));
+ if (g_sck == -1)
+ {
+ LLOGLN(0, ("SCardSetAttrib: error, not connected"));
+ return SCARD_F_INTERNAL_ERROR;
+ }
+ pthread_mutex_lock(&g_mutex);
+ pthread_mutex_unlock(&g_mutex);
+ return SCARD_S_SUCCESS;
+}
+
+/*****************************************************************************/
+char *
+pcsc_stringify_error(const long code)
+{
+ switch (code)
+ {
+ case SCARD_S_SUCCESS:
+ snprintf(g_error_str, 511, "Command successful.");
+ break;
+ case SCARD_F_INTERNAL_ERROR:
+ snprintf(g_error_str, 511, "Internal error.");
+ break;
+ default:
+ snprintf(g_error_str, 511, "error 0x%8.8x", (int)code);
+ break;
+ }
+ g_error_str[511] = 0;
+ return g_error_str;
+}
diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c
index 3b8b2a0c..fb1075c6 100644
--- a/sesman/chansrv/rail.c
+++ b/sesman/chansrv/rail.c
@@ -1235,13 +1235,16 @@ rail_win_send_text(Window win)
s_mark_end(s);
send_rail_drawing_orders(s->data, (int)(s->end - s->data));
free_stream(s);
- XFree(data);
/* update rail window data */
rwd->valid |= RWD_TITLE;
crc = get_string_crc(data);
rwd->title_crc = crc;
rail_set_window_data(win, rwd);
}
+ if (data != 0)
+ {
+ XFree(data);
+ }
XFree(rwd);
return 0;
}
diff --git a/sesman/chansrv/smartcard.c b/sesman/chansrv/smartcard.c
index c370479e..9d55807d 100644
--- a/sesman/chansrv/smartcard.c
+++ b/sesman/chansrv/smartcard.c
@@ -21,6 +21,7 @@
* smartcard redirection support
*/
+#include <string.h>
#include "os_calls.h"
#include "smartcard.h"
#include "log.h"
@@ -31,6 +32,8 @@
/*
* TODO
*
+ * o ensure that all wide calls are handled correctly
+ *
* o need to query client for build number and determine whether we should use
* SCREDIR_VERSION_XP or SCREDIR_VERSION_LONGHORN
*
@@ -60,13 +63,15 @@
#endif
#define log_error(_params...) \
+do \
{ \
g_write("[%10.10u]: SMART_CARD %s: %d : ERROR: ", \
g_time3(), __func__, __LINE__); \
g_writeln (_params); \
-}
+} while (0)
#define log_info(_params...) \
+do \
{ \
if (LOG_INFO <= LOG_LEVEL) \
{ \
@@ -74,9 +79,10 @@
g_time3(), __func__, __LINE__); \
g_writeln (_params); \
} \
-}
+} while (0)
#define log_debug(_params...) \
+do \
{ \
if (LOG_DEBUG <= LOG_LEVEL) \
{ \
@@ -84,7 +90,7 @@
g_time3(), __func__, __LINE__); \
g_writeln (_params); \
} \
-}
+} while (0)
/* [MS-RDPESC] 3.1.4 */
#define SCARD_IOCTL_ESTABLISH_CONTEXT 0x00090014 /* EstablishContext */
@@ -98,16 +104,19 @@
#define SCARD_IOCTL_INTRODUCE_READER 0x00090060 /* IntroduceReader */
#define SCARD_IOCTL_FORGET_READER 0x00090068 /* IntroduceReader */
#define SCARD_IOCTL_ADD_READER_TO_GROUP 0x00090070 /* AddReaderToGroup */
-#define SCARD_IOCTL_REMOVE_READER_FROM_GROUP 0x00090078 /* RemoveReaderFromGroup */
-#define SCARD_IOCTL_GET_STATUS_CHANGE 0x000900A0 /* GetStatusChangeA */
+#define SCARD_IOCTL_REMOVE_READER_FROM_GROUP 0x00090078 /* RemoveReaderFromGroup*/
+#define SCARD_IOCTL_GET_STATUS_CHANGE_A 0x000900A0 /* GetStatusChangeA */
+#define SCARD_IOCTL_GET_STATUS_CHANGE_W 0x000900A4 /* GetStatusChangeW */
#define SCARD_IOCTL_CANCEL 0x000900A8 /* Cancel */
-#define SCARD_IOCTL_CONNECT 0x000900AC /* ConnectA */
+#define SCARD_IOCTL_CONNECT_A 0x000900AC /* ConnectA */
+#define SCARD_IOCTL_CONNECT_W 0x000900B0 /* ConnectW */
#define SCARD_IOCTL_RECONNECT 0x000900B4 /* Reconnect */
#define SCARD_IOCTL_DISCONNECT 0x000900B8 /* Disconnect */
#define SCARD_IOCTL_BEGIN_TRANSACTION 0x000900BC /* BeginTransaction */
#define SCARD_IOCTL_END_TRANSACTION 0x000900C0 /* EndTransaction */
#define SCARD_IOCTL_STATE 0x000900C4 /* State */
-#define SCARD_IOCTL_STATUS 0x000900C8 /* StatusA */
+#define SCARD_IOCTL_STATUS_A 0x000900C8 /* StatusA */
+#define SCARD_IOCTL_STATUS_W 0x000900CC /* StatusW */
#define SCARD_IOCTL_TRANSMIT 0x000900D0 /* Transmit */
#define SCARD_IOCTL_CONTROL 0x000900D4 /* Control */
#define SCARD_IOCTL_GETATTRIB 0x000900D8 /* GetAttrib */
@@ -120,288 +129,653 @@
#define SCARD_SCOPE_TERMINAL 0x00000001
#define SCARD_SCOPE_SYSTEM 0x00000002
+/* disposition - action to take on card */
+#define SCARD_LEAVE_CARD 0x00000000
+#define SCARD_RESET_CARD 0x00000001
+#define SCARD_UNPOWER_CARD 0x00000002
+#define SCARD_EJECT_CARD 0x00000003
+
#define MAX_SMARTCARDS 16
/* stores info about a smart card */
typedef struct smartcard
{
tui32 DeviceId;
- char Context[16]; /* opaque context; save as passed to us */
- int Context_len; /* Context len in bytes */
} SMARTCARD;
-SMARTCARD *smartcards[MAX_SMARTCARDS];
-int g_smartcards_inited = 0;
+/* globals */
+SMARTCARD* smartcards[MAX_SMARTCARDS];
+int g_smartcards_inited = 0;
+static tui32 g_device_id = 0;
+static int g_scard_index = 0;
+/* externs */
extern tui32 g_completion_id;
-extern int g_rdpdr_chan_id; /* in chansrv.c */
+extern int g_rdpdr_chan_id; /* in chansrv.c */
+
+
+/******************************************************************************
+** static functions local to this file **
+******************************************************************************/
+static struct stream * APP_CC scard_make_new_ioctl(IRP *irp, tui32 ioctl);
+static int APP_CC scard_add_new_device(tui32 device_id);
+static int APP_CC scard_get_free_slot(void);
+static void APP_CC scard_release_resources(void);
+static void APP_CC scard_send_EstablishContext(IRP* irp, int scope);
+static void APP_CC scard_send_ReleaseContext(IRP* irp, tui32 context);
+static void APP_CC scard_send_IsContextValid(IRP* irp, tui32 context);
+static void APP_CC scard_send_ListReaders(IRP* irp, tui32 context, int wide);
+
+static void APP_CC scard_send_GetStatusChange(IRP* irp, tui32 context, int wide,
+ tui32 timeout, tui32 num_readers,
+ READER_STATE* rsa);
+
+static void APP_CC scard_send_Connect(IRP* irp, tui32 context, int wide,
+ READER_STATE* rs);
+
+static void APP_CC scard_send_Reconnect(IRP* irp, tui32 context,
+ tui32 sc_handle, READER_STATE* rs);
+
+static void APP_CC scard_send_BeginTransaction(IRP* irp, tui32 sc_handle);
+static void APP_CC scard_send_EndTransaction(IRP* irp, tui32 sc_handle);
+static void APP_CC scard_send_Status(IRP* irp, int wide, tui32 sc_handle);
+
+static void APP_CC scard_send_Disconnect(IRP* irp, tui32 context,
+ tui32 sc_handle);
+
+static int APP_CC scard_send_Transmit(IRP* irp, tui32 sc_handle,
+ READER_STATE* rs);
+
+static int APP_CC scard_send_Control(IRP* irp, tui32 context, tui32 sc_handle,
+ READER_STATE* rs);
+
+static int APP_CC scard_send_Cancel(IRP* irp, tui32 context);
+
+static int APP_CC scard_send_GetAttrib(IRP* irp, tui32 sc_handle,
+ READER_STATE* rs);
+
+/******************************************************************************
+** local callbacks into this module **
+******************************************************************************/
+
+static void APP_CC scard_handle_EstablishContext_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus);
+
+static void APP_CC scard_handle_ReleaseContext_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus);
+
+
+static void APP_CC scard_handle_IsContextValid_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus);
+
+static void APP_CC scard_handle_ListReaders_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus);
+
+static void APP_CC scard_handle_GetStatusChange_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus);
+
+static void APP_CC scard_handle_Connect_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus);
+
+static void APP_CC scard_handle_Reconnect_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus);
+
+static void APP_CC scard_handle_BeginTransaction_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus);
+
+static void APP_CC scard_handle_EndTransaction_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId,
+ tui32 CompletionId,
+ tui32 IoStatus);
-/* forward declarations specific to this file */
-static void scard_send_EstablishContext(IRP *irp);
-static void scard_send_ListReaders(IRP *irp, int wide);
-static struct stream *scard_make_new_ioctl(IRP *irp, tui32 ioctl);
-static int scard_add_new_device(tui32 device_id);
-static int scard_get_free_slot(void);
-static void scard_release_resources(void);
+static void APP_CC scard_handle_Status_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus);
+
+static void APP_CC scard_handle_Disconnect_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus);
+
+
+static void APP_CC scard_handle_Transmit_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId,
+ tui32 CompletionId,
+ tui32 IoStatus);
+
+static void APP_CC scard_handle_Control_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId,
+ tui32 CompletionId,
+ tui32 IoStatus);
+
+static void APP_CC scard_handle_Cancel_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId,
+ tui32 CompletionId,
+ tui32 IoStatus);
+
+static void APP_CC scard_handle_GetAttrib_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId,
+ tui32 CompletionId,
+ tui32 IoStatus);
/******************************************************************************
-** non static functions **
+** **
+** externally accessible functions, defined in smartcard.h **
+** **
******************************************************************************/
+/**
+ *****************************************************************************/
void APP_CC
scard_device_announce(tui32 device_id)
{
- IRP *irp;
-
log_debug("entered: device_id=%d", device_id);
- if (!g_smartcards_inited)
+ if (g_smartcards_inited)
+ return;
+
+ g_memset(&smartcards, 0, sizeof(smartcards));
+ g_smartcards_inited = 1;
+ g_device_id = device_id;
+ g_scard_index = scard_add_new_device(device_id);
+
+ if (g_scard_index < 0)
+ log_debug("scard_add_new_device failed with DeviceId=%d", g_device_id);
+ else
+ log_debug("added smartcard with DeviceId=%d to list", g_device_id);
+}
+
+/**
+ *
+ *****************************************************************************/
+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();
+}
+
+/**
+ *
+ *****************************************************************************/
+int APP_CC
+scard_send_establish_context(struct trans *con, int scope)
+{
+ IRP *irp;
+
+ /* setup up IRP */
+ if ((irp = devredir_irp_new()) == NULL)
{
- g_memset(&smartcards, 0, sizeof(smartcards));
- g_smartcards_inited = 1;
+ log_error("system out of memory");
+ return 1;
}
+ irp->scard_index = g_scard_index;
+ irp->CompletionId = g_completion_id++;
+ irp->DeviceId = g_device_id;
+ irp->callback = scard_handle_EstablishContext_Return;
+ irp->user_data = con;
+
+ /* send IRP to client */
+ scard_send_EstablishContext(irp, scope);
+
+ return 0;
+}
+
+/**
+ * Release a previously established Smart Card context
+ *****************************************************************************/
+int APP_CC
+scard_send_release_context(struct trans *con, tui32 context)
+{
+ IRP *irp;
+
+ /* setup up IRP */
if ((irp = devredir_irp_new()) == NULL)
{
log_error("system out of memory");
- return;
+ return 1;
}
- irp->scard_index = scard_add_new_device(device_id);
- if (irp->scard_index < 0)
+ irp->scard_index = g_scard_index;
+ irp->CompletionId = g_completion_id++;
+ irp->DeviceId = g_device_id;
+ irp->callback = scard_handle_ReleaseContext_Return;
+ irp->user_data = con;
+
+ /* send IRP to client */
+ scard_send_ReleaseContext(irp, context);
+
+ return 0;
+}
+
+/**
+ * Checks if a previously established context is still valid
+ *****************************************************************************/
+int APP_CC
+scard_send_is_valid_context(struct trans *con, tui32 context)
+{
+ IRP *irp;
+
+ /* setup up IRP */
+ if ((irp = devredir_irp_new()) == NULL)
{
- log_debug("NOT adding smartcard with DeviceId=%d to list", device_id);
- devredir_irp_delete(irp);
- return;
+ log_error("system out of memory");
+ return 1;
}
- log_debug("added smartcard with DeviceId=%d to list", device_id);
-
+ irp->scard_index = g_scard_index;
irp->CompletionId = g_completion_id++;
- irp->DeviceId = device_id;
- irp->callback = scard_handle_EstablishContext_Return;
+ irp->DeviceId = g_device_id;
+ irp->callback = scard_handle_IsContextValid_Return;
+ irp->user_data = con;
- scard_send_EstablishContext(irp);
- log_debug("leaving");
-}
+ /* send IRP to client */
+ scard_send_IsContextValid(irp, context);
-/******************************************************************************
-** callbacks into this module **
-******************************************************************************/
+ return 0;
+}
-void APP_CC
-scard_handle_EstablishContext_Return(struct stream *s, IRP *irp,
- tui32 DeviceId, tui32 CompletionId,
- tui32 IoStatus)
+/**
+ *
+ *****************************************************************************/
+int APP_CC
+scard_send_list_readers(struct trans *con, tui32 context, int wide)
{
- tui32 len;
- int tmp;
- SMARTCARD *sc;
-
- log_debug("entered");
+ IRP *irp;
- /* sanity check */
- if ((DeviceId != irp->DeviceId) || (CompletionId != irp->CompletionId))
+ /* setup up IRP */
+ if ((irp = devredir_irp_new()) == NULL)
{
- log_error("DeviceId/CompletionId do not match those in IRP");
- return;
+ log_error("system out of memory");
+ return 1;
}
+ irp->scard_index = g_scard_index;
+ irp->CompletionId = g_completion_id++;
+ irp->DeviceId = g_device_id;
+ irp->callback = scard_handle_ListReaders_Return;
+ irp->user_data = con;
- if (IoStatus != 0)
+ /* send IRP to client */
+ scard_send_ListReaders(irp, context, wide);
+
+ return 0;
+}
+
+/**
+ * Send get change in status command
+ *
+ * @param con connection to client
+ * @param wide TRUE if unicode string
+ * @param timeout timeout in milliseconds, -1 for infinity
+ * @param num_readers number of entries in rsa
+ * @param rsa array of READER_STATEs
+ *****************************************************************************/
+int APP_CC
+scard_send_get_status_change(struct trans *con, tui32 context, int wide,
+ tui32 timeout, tui32 num_readers,
+ READER_STATE* rsa)
+{
+ IRP *irp;
+
+ /* setup up IRP */
+ if ((irp = devredir_irp_new()) == NULL)
{
- log_error("failed to establish context - device not usable");
- /* LK_TODO delete irp and smartcard entry */
- return;
+ log_error("system out of memory");
+ return 1;
}
- sc = smartcards[irp->scard_index];
+ irp->scard_index = g_scard_index;
+ irp->CompletionId = g_completion_id++;
+ irp->DeviceId = g_device_id;
+ irp->callback = scard_handle_GetStatusChange_Return;
+ irp->user_data = con;
- /* get OutputBufferLen */
- xstream_rd_u32_le(s, len);
+ /* send IRP to client */
+ scard_send_GetStatusChange(irp, context, wide, timeout, num_readers, rsa);
- /* LK_TODO */
- g_hexdump(s->p, len);
+ return 0;
+}
- xstream_rd_u32_le(s, tmp); /* should be len 8, LE, V1 */
- xstream_rd_u32_le(s, tmp); /* marshalling flag */
- xstream_rd_u32_le(s, tmp); /* ?? */
- xstream_rd_u32_le(s, tmp); /* ?? */
- xstream_rd_u32_le(s, tmp); /* ?? */
- xstream_rd_u32_le(s, tmp); /* ?? */
- xstream_rd_u32_le(s, tmp); /* ?? */
- xstream_rd_u32_le(s, len); /* len of context in bytes */
- sc->Context_len = len;
- xstream_copyout(sc->Context, s, len);
+/**
+ * Open a connection to the smart card located in the reader
+ *
+ * @param con connection to client
+ * @param wide TRUE if unicode string
+ *****************************************************************************/
+int APP_CC
+scard_send_connect(struct trans *con, tui32 context, int wide,
+ READER_STATE* rs)
+{
+ IRP *irp;
- if (LOG_LEVEL == LOG_DEBUG)
+ /* setup up IRP */
+ if ((irp = devredir_irp_new()) == NULL)
{
- log_debug("dumping context (%d bytes)", sc->Context_len);
- g_hexdump(sc->Context, sc->Context_len);
+ log_error("system out of memory");
+ return 1;
}
- irp->callback = scard_handle_ListReaders_Return;
- scard_send_ListReaders(irp, 1);
+ irp->scard_index = g_scard_index;
+ irp->CompletionId = g_completion_id++;
+ irp->DeviceId = g_device_id;
+ irp->callback = scard_handle_Connect_Return;
+ irp->user_data = con;
- /* LK_TODO need to delete IRP */
- log_debug("leaving");
+ /* send IRP to client */
+ scard_send_Connect(irp, context, wide, rs);
+
+ return 0;
}
-void APP_CC
-scard_handle_ListReaders_Return(struct stream *s, IRP *irp,
- tui32 DeviceId, tui32 CompletionId,
- tui32 IoStatus)
+/**
+ * The reconnect method re-establishes a smart card reader handle. On success,
+ * the handle is valid once again.
+ *
+ * @param con connection to client
+ * @param sc_handle handle to device
+ * @param rs reader state where following fields are set
+ * rs.shared_mode_flag
+ * rs.preferred_protocol
+ * rs.init_type
+ *****************************************************************************/
+int APP_CC
+scard_send_reconnect(struct trans *con, tui32 context, tui32 sc_handle,
+ READER_STATE* rs)
{
- tui32 len;
-
- log_debug("entered");
+ IRP *irp;
- /* sanity check */
- if ((DeviceId != irp->DeviceId) || (CompletionId != irp->CompletionId))
+ /* setup up IRP */
+ if ((irp = devredir_irp_new()) == NULL)
{
- log_error("DeviceId/CompletionId do not match those in IRP");
- return;
+ log_error("system out of memory");
+ return 1;
}
- if (IoStatus != 0)
+ irp->scard_index = g_scard_index;
+ irp->CompletionId = g_completion_id++;
+ irp->DeviceId = g_device_id;
+ irp->callback = scard_handle_Reconnect_Return;
+ irp->user_data = con;
+
+ /* send IRP to client */
+ scard_send_Reconnect(irp, context, sc_handle, rs);
+
+ return 0;
+}
+
+/**
+ * Lock smart card reader for exclusive access for specified smart
+ * card reader handle.
+ *
+ * @param con connection to client
+ *****************************************************************************/
+int APP_CC
+scard_send_begin_transaction(struct trans *con, tui32 sc_handle)
+{
+ IRP *irp;
+
+ /* setup up IRP */
+ if ((irp = devredir_irp_new()) == NULL)
{
- log_error("failed to list readers - device not usable");
- /* LK_TODO delete irp and smartcard entry */
- return;
+ log_error("system out of memory");
+ return 1;
}
- /* get OutputBufferLen */
- xstream_rd_u32_le(s, len);
+ irp->scard_index = g_scard_index;
+ irp->CompletionId = g_completion_id++;
+ irp->DeviceId = g_device_id;
+ irp->callback = scard_handle_BeginTransaction_Return;
+ irp->user_data = con;
- /* LK_TODO */
- log_debug("dumping %d bytes", len);
- g_hexdump(s->p, len);
+ /* send IRP to client */
+ scard_send_BeginTransaction(irp, sc_handle);
- log_debug("leaving");
+ return 0;
}
-/******************************************************************************
-** static functions local to this file **
-******************************************************************************/
-
/**
+ * Release a smart card reader after being locked by a previously
+ * successful call to Begin Transaction
*
+ * @param con connection to client
+ * @param sc_handle handle to smartcard
*****************************************************************************/
+int APP_CC
+scard_send_end_transaction(struct trans *con, tui32 sc_handle)
+{
+ IRP *irp;
-static void APP_CC
-scard_send_EstablishContext(IRP *irp)
+ /* setup up IRP */
+ if ((irp = devredir_irp_new()) == NULL)
+ {
+ log_error("system out of memory");
+ return 1;
+ }
+
+ irp->scard_index = g_scard_index;
+ irp->CompletionId = g_completion_id++;
+ irp->DeviceId = g_device_id;
+ irp->callback = scard_handle_EndTransaction_Return;
+ irp->user_data = con;
+
+ /* send IRP to client */
+ scard_send_EndTransaction(irp, sc_handle);
+
+ return 0;
+}
+
+/**
+ * Get the status of a connection for a valid smart card reader handle
+ *
+ * @param con connection to client
+ * @param wide TRUE if unicode string
+ *****************************************************************************/
+int APP_CC
+scard_send_status(struct trans *con, int wide, tui32 sc_handle)
{
- struct stream *s;
- int bytes;
+ IRP *irp;
- if ((s = scard_make_new_ioctl(irp, SCARD_IOCTL_ESTABLISH_CONTEXT)) == NULL)
- return;
+ /* setup up IRP */
+ if ((irp = devredir_irp_new()) == NULL)
+ {
+ log_error("system out of memory");
+ return 1;
+ }
- xstream_wr_u32_le(s, 0x08); /* len */
- xstream_wr_u32_le(s, 0); /* unused */
- xstream_wr_u32_le(s, SCARD_SCOPE_SYSTEM); /* Ioctl specific data */
- xstream_wr_u32_le(s, 0); /* don't know what this is, */
- /* but Win7 is sending it */
- /* get stream len */
- bytes = xstream_len(s);
+ irp->scard_index = g_scard_index;
+ irp->CompletionId = g_completion_id++;
+ irp->DeviceId = g_device_id;
+ irp->callback = scard_handle_Status_Return;
+ irp->user_data = con;
- /* InputBufferLength is number of bytes AFTER 20 byte padding */
- *(s->data + 28) = bytes - 56;
+ /* send IRP to client */
+ scard_send_Status(irp, wide, sc_handle);
- /* send to client */
- send_channel_data(g_rdpdr_chan_id, s->data, bytes);
- xstream_free(s);
+ return 0;
}
/**
+ * Release a smart card reader handle that was acquired in ConnectA/ConnectW
*
+ * @param con connection to client
+ * @param sc_handle handle to smartcard
*****************************************************************************/
+int APP_CC
+scard_send_disconnect(struct trans *con, tui32 context, tui32 sc_handle)
+{
+ IRP *irp;
-static void APP_CC
-scard_send_ListReaders(IRP *irp, int wide)
+ /* setup up IRP */
+ if ((irp = devredir_irp_new()) == NULL)
+ {
+ log_error("system out of memory");
+ return 1;
+ }
+
+ irp->scard_index = g_scard_index;
+ irp->CompletionId = g_completion_id++;
+ irp->DeviceId = g_device_id;
+ irp->callback = scard_handle_Disconnect_Return;
+ irp->user_data = con;
+
+ /* send IRP to client */
+ scard_send_Disconnect(irp, context, sc_handle);
+
+ return 0;
+}
+
+/**
+ * The Transmit_Call structure is used to send data to the smart card
+ * associated with a valid context.
+ *****************************************************************************/
+int APP_CC
+scard_send_transmit(struct trans *con, tui32 sc_handle, READER_STATE* rs)
{
- /* see [MS-RDPESC] 2.2.2.4 */
+ IRP *irp;
- SMARTCARD *sc;
- struct stream *s;
- int bytes;
- tui32 ioctl;
+ /* setup up IRP */
+ if ((irp = devredir_irp_new()) == NULL)
+ {
+ log_error("system out of memory");
+ return 1;
+ }
- if ((sc = smartcards[irp->scard_index]) == NULL)
+ irp->scard_index = g_scard_index;
+ irp->CompletionId = g_completion_id++;
+ irp->DeviceId = g_device_id;
+ irp->callback = scard_handle_Transmit_Return;
+ irp->user_data = con;
+
+ /* send IRP to client */
+ scard_send_Transmit(irp, sc_handle, rs);
+
+ return 0;
+}
+
+/**
+ * Communicate directly with the smart card reader
+ *****************************************************************************/
+int APP_CC
+scard_send_control(struct trans *con, tui32 context, tui32 sc_handle,
+ READER_STATE* rs)
+{
+ IRP *irp;
+
+ /* setup up IRP */
+ if ((irp = devredir_irp_new()) == NULL)
{
- log_error("smartcards[%d] is NULL", irp->scard_index);
- return;
+ log_error("system out of memory");
+ return 1;
}
- ioctl = (wide > 0) ? SCARD_IOCTL_LIST_READERS_W :
- SCARD_IOCTL_LIST_READERS_A;
+ irp->scard_index = g_scard_index;
+ irp->CompletionId = g_completion_id++;
+ irp->DeviceId = g_device_id;
+ irp->callback = scard_handle_Control_Return;
+ irp->user_data = con;
- if ((s = scard_make_new_ioctl(irp, ioctl)) == NULL)
- return;
+ /* send IRP to client */
+ scard_send_Control(irp, context, sc_handle, rs);
- xstream_wr_u32_le(s, 72); /* number of bytes to follow */
- xstream_seek(s, 0x1c); /* freerdp does not use this */
+ return 0;
+}
- /* insert context */
- xstream_wr_u32_le(s, sc->Context_len);
- xstream_copyin(s, sc->Context, sc->Context_len);
+/**
+ * Cancel any outstanding calls
+ *****************************************************************************/
+int APP_CC
+scard_send_cancel(struct trans *con, tui32 context)
+{
+ IRP *irp;
- xstream_wr_u32_le(s, 36); /* length of mszGroups */
- xstream_wr_u16_le(s, 0x0053);
- xstream_wr_u16_le(s, 0x0043);
- xstream_wr_u16_le(s, 0x0061);
- xstream_wr_u16_le(s, 0x0072);
- xstream_wr_u16_le(s, 0x0064);
- xstream_wr_u16_le(s, 0x0024);
- xstream_wr_u16_le(s, 0x0041);
- xstream_wr_u16_le(s, 0x006c);
- xstream_wr_u16_le(s, 0x006c);
- xstream_wr_u16_le(s, 0x0052);
- xstream_wr_u16_le(s, 0x0065);
- xstream_wr_u16_le(s, 0x0061);
- xstream_wr_u16_le(s, 0x0064);
- xstream_wr_u16_le(s, 0x0065);
- xstream_wr_u16_le(s, 0x0072);
- xstream_wr_u16_le(s, 0x0073);
+ /* setup up IRP */
+ if ((irp = devredir_irp_new()) == NULL)
+ {
+ log_error("system out of memory");
+ return 1;
+ }
- xstream_wr_u32_le(s, 0x00);
+ irp->scard_index = g_scard_index;
+ irp->CompletionId = g_completion_id++;
+ irp->DeviceId = g_device_id;
+ irp->callback = scard_handle_Cancel_Return;
+ irp->user_data = con;
- /* get stream len */
- bytes = xstream_len(s);
+ /* send IRP to client */
+ scard_send_Cancel(irp, context);
- /* InputBufferLength is number of bytes AFTER 20 byte padding */
- *(s->data + 28) = bytes - 56;
+ return 0;
+}
- /* send to client */
- send_channel_data(g_rdpdr_chan_id, s->data, bytes);
- xstream_free(s);
+/**
+ * Get reader attributes
+ *****************************************************************************/
+int APP_CC
+scard_send_get_attrib(struct trans *con, tui32 sc_handle, READER_STATE* rs)
+{
+ IRP *irp;
- /*
- scard_device_control: dumping 120 bytes of data
- 0000 00 08 00 00 58 00 00 00 2c 00 09 00 00 00 00 00 ....X...,.......
- 0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
- 0020 01 10 08 00 cc cc cc cc 48 00 00 00 00 00 00 00 ........H.......
- 0030 04 00 00 00 00 00 02 00 24 00 00 00 04 00 02 00 ........$.......
- 0040 00 00 00 00 ff ff ff ff 04 00 00 00 84 db 03 01 ................
- 0050 24 00 00 00 53 00 43 00 61 00 72 00 64 00 24 00 $...S.C.a.r.d.$.
- 0060 41 00 6c 00 6c 00 52 00 65 00 61 00 64 00 65 00 A.l.l.R.e.a.d.e.
- 0070 72 00 73 00 00 00 00 00 r.s.....
- scard_device_control: output_len=2048 input_len=88 ioctl_code=0x9002c
- */
+ /* setup up IRP */
+ if ((irp = devredir_irp_new()) == NULL)
+ {
+ log_error("system out of memory");
+ return 1;
+ }
- /*
- scard_device_control: dumping 120 bytes of data
- 0000 00 08 00 00 80 00 00 00 14 00 09 00 00 00 00 00 ................
- 0010 2e 2e 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ................
- 0020 01 10 08 00 cc cc cc cc 48 00 00 00 00 00 00 00 ........H.......
- 0030 02 00 00 00 00 00 00 00 72 64 00 00 00 00 00 00 ........rd......
- 0040 81 27 00 00 00 00 00 00 04 00 00 00 84 b3 03 01 .'..............
- 0050 24 00 00 00 53 00 43 00 61 00 72 00 64 00 24 00 $...S.C.a.r.d.$.
- 0060 41 00 6c 00 6c 00 52 00 65 00 61 00 64 00 65 00 A.l.l.R.e.a.d.e.
- 0070 72 00 73 00 00 00 00 00 r.s.....
- scard_device_control: output_len=2048 input_len=128 ioctl_code=0x90014
- */
+ irp->scard_index = g_scard_index;
+ irp->CompletionId = g_completion_id++;
+ irp->DeviceId = g_device_id;
+ irp->callback = scard_handle_GetAttrib_Return;
+ irp->user_data = con;
+
+ /* send IRP to client */
+ scard_send_GetAttrib(irp, sc_handle, rs);
+
+ return 0;
}
+/******************************************************************************
+** **
+** static functions local to this file **
+** **
+******************************************************************************/
+
/**
* Crate a new stream and insert specified IOCTL
*
@@ -410,7 +784,6 @@ scard_send_ListReaders(IRP *irp, int wide)
*
* @return stream with IOCTL inserted in it, NULL on error
*****************************************************************************/
-
static struct stream * APP_CC
scard_make_new_ioctl(IRP *irp, tui32 ioctl)
{
@@ -435,7 +808,7 @@ scard_make_new_ioctl(IRP *irp, tui32 ioctl)
struct stream *s;
- xstream_new(s, 1024 * 3);
+ xstream_new(s, 1024 * 4);
if (s == NULL)
{
log_error("system out of memory");
@@ -468,7 +841,6 @@ scard_make_new_ioctl(IRP *irp, tui32 ioctl)
*
* @return index into smartcards[] on success, -1 on failure
*****************************************************************************/
-
static int APP_CC
scard_add_new_device(tui32 device_id)
{
@@ -476,7 +848,10 @@ scard_add_new_device(tui32 device_id)
SMARTCARD *sc;
if ((index = scard_get_free_slot()) < 0)
+ {
+ log_error("scard_get_free_slot failed");
return -1;
+ }
if ((sc = g_malloc(sizeof(SMARTCARD), 1)) == NULL)
{
@@ -496,7 +871,6 @@ scard_add_new_device(tui32 device_id)
* @return index of first unused entry in smartcards or -1 if smartcards
* is full
*****************************************************************************/
-
static int APP_CC
scard_get_free_slot(void)
{
@@ -518,7 +892,6 @@ scard_get_free_slot(void)
/**
* Release resources prior to shutting down
*****************************************************************************/
-
static void APP_CC
scard_release_resources(void)
{
@@ -537,37 +910,1463 @@ scard_release_resources(void)
/**
*
*****************************************************************************/
-int APP_CC
-scard_get_wait_objs(tbus *objs, int *count, int *timeout)
+static void APP_CC
+scard_send_EstablishContext(IRP *irp, int scope)
{
- return scard_pcsc_get_wait_objs(objs, count, timeout);
+ struct stream *s;
+ int bytes;
+
+ if ((s = scard_make_new_ioctl(irp, SCARD_IOCTL_ESTABLISH_CONTEXT)) == NULL)
+ {
+ log_error("scard_make_new_ioctl failed");
+ return;
+ }
+
+ xstream_wr_u32_le(s, 0x08); /* len */
+ xstream_wr_u32_le(s, 0); /* unused */
+ xstream_wr_u32_le(s, scope); /* Ioctl specific data */
+ xstream_wr_u32_le(s, 0); /* don't know what this is, */
+ /* but Win7 is sending it */
+ /* get stream len */
+ bytes = xstream_len(s);
+
+ /* InputBufferLength is number of bytes AFTER 20 byte padding */
+ *(s->data + 28) = bytes - 56;
+
+ /* send to client */
+ send_channel_data(g_rdpdr_chan_id, s->data, bytes);
+ xstream_free(s);
+}
+
+/**
+ * Release a previously established Smart Card context
+ *****************************************************************************/
+static void APP_CC
+scard_send_ReleaseContext(IRP* irp, tui32 context)
+{
+ /* see [MS-RDPESC] 3.1.4.2 */
+
+ SMARTCARD* sc;
+ struct stream* s;
+ int bytes;
+
+ if ((sc = smartcards[irp->scard_index]) == NULL)
+ {
+ log_error("smartcards[%d] is NULL", irp->scard_index);
+ return;
+ }
+
+ if ((s = scard_make_new_ioctl(irp, SCARD_IOCTL_RELEASE_CONTEXT)) == NULL)
+ return;
+
+ /*
+ * command format
+ *
+ * ......
+ * 20 bytes padding
+ * u32 4 bytes len 8, LE, v1
+ * u32 4 bytes filler
+ * 4 bytes len - don't know what this is, zero for now
+ * 12 bytes unused
+ * u32 4 bytes context len
+ * 4 bytes context
+ */
+
+ xstream_wr_u32_le(s, 0);
+ xstream_seek(s, 12);
+
+ /* insert context */
+ xstream_wr_u32_le(s, 4);
+ xstream_wr_u32_le(s, context);
+
+ /* get stream len */
+ bytes = xstream_len(s);
+
+ /* InputBufferLength is number of bytes AFTER 20 byte padding */
+ *(s->data + 28) = bytes - 56;
+
+ /* send to client */
+ send_channel_data(g_rdpdr_chan_id, s->data, bytes);
+ xstream_free(s);
+}
+
+/**
+ * Checks if a previously established context is still valid
+ *****************************************************************************/
+static void APP_CC
+scard_send_IsContextValid(IRP* irp, tui32 context)
+{
+ /* see [MS-RDPESC] 3.1.4.3 */
+
+ SMARTCARD* sc;
+ struct stream* s;
+ int bytes;
+
+ if ((sc = smartcards[irp->scard_index]) == NULL)
+ {
+ log_error("smartcards[%d] is NULL", irp->scard_index);
+ return;
+ }
+
+ if ((s = scard_make_new_ioctl(irp, SCARD_IOCTL_IS_VALID_CONTEXT)) == NULL)
+ return;
+
+ /*
+ * command format
+ *
+ * ......
+ * 20 bytes padding
+ * u32 4 bytes len 8, LE, v1
+ * u32 4 bytes filler
+ * 16 bytes unused (s->p currently pointed here at unused[0])
+ * u32 4 bytes context len
+ * u32 4 bytes context
+ */
+
+ xstream_wr_u32_le(s, 16);
+
+ /* insert context */
+ xstream_wr_u32_le(s, 4);
+ xstream_wr_u32_le(s, context);
+
+ /* get stream len */
+ bytes = xstream_len(s);
+
+ /* InputBufferLength is number of bytes AFTER 20 byte padding */
+ *(s->data + 28) = bytes - 56;
+
+ /* send to client */
+ send_channel_data(g_rdpdr_chan_id, s->data, bytes);
+ xstream_free(s);
}
/**
*
*****************************************************************************/
-int APP_CC
-scard_check_wait_objs(void)
+static void APP_CC
+scard_send_ListReaders(IRP *irp, tui32 context, int wide)
{
- return scard_pcsc_check_wait_objs();
+ /* see [MS-RDPESC] 2.2.2.4 */
+
+ SMARTCARD *sc;
+ struct stream *s;
+ int bytes;
+ tui32 ioctl;
+
+ if ((sc = smartcards[irp->scard_index]) == NULL)
+ {
+ log_error("smartcards[%d] is NULL", irp->scard_index);
+ return;
+ }
+
+ ioctl = (wide) ? SCARD_IOCTL_LIST_READERS_W :
+ SCARD_IOCTL_LIST_READERS_A;
+
+ if ((s = scard_make_new_ioctl(irp, ioctl)) == NULL)
+ return;
+
+ xstream_wr_u32_le(s, 72); /* number of bytes to follow */
+ xstream_seek(s, 28); /* freerdp does not use this */
+
+ /* insert context */
+ xstream_wr_u32_le(s, 4);
+ xstream_wr_u32_le(s, context);
+
+ xstream_wr_u32_le(s, 36); /* length of mszGroups */
+ xstream_wr_u16_le(s, 0x0053);
+ xstream_wr_u16_le(s, 0x0043);
+ xstream_wr_u16_le(s, 0x0061);
+ xstream_wr_u16_le(s, 0x0072);
+ xstream_wr_u16_le(s, 0x0064);
+ xstream_wr_u16_le(s, 0x0024);
+ xstream_wr_u16_le(s, 0x0041);
+ xstream_wr_u16_le(s, 0x006c);
+ xstream_wr_u16_le(s, 0x006c);
+ xstream_wr_u16_le(s, 0x0052);
+ xstream_wr_u16_le(s, 0x0065);
+ xstream_wr_u16_le(s, 0x0061);
+ xstream_wr_u16_le(s, 0x0064);
+ xstream_wr_u16_le(s, 0x0065);
+ xstream_wr_u16_le(s, 0x0072);
+ xstream_wr_u16_le(s, 0x0073);
+
+ xstream_wr_u32_le(s, 0x00);
+
+ /* get stream len */
+ bytes = xstream_len(s);
+
+ /* InputBufferLength is number of bytes AFTER 20 byte padding */
+ *(s->data + 28) = bytes - 56;
+
+ /* send to client */
+ send_channel_data(g_rdpdr_chan_id, s->data, bytes);
+ xstream_free(s);
+
+ /*
+ scard_device_control: dumping 120 bytes of data
+ 0000 00 08 00 00 58 00 00 00 2c 00 09 00 00 00 00 00 ....X...,.......
+ 0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 0020 01 10 08 00 cc cc cc cc 48 00 00 00 00 00 00 00 ........H.......
+ 0030 04 00 00 00 00 00 02 00 24 00 00 00 04 00 02 00 ........$.......
+ 0040 00 00 00 00 ff ff ff ff 04 00 00 00 84 db 03 01 ................
+ 0050 24 00 00 00 53 00 43 00 61 00 72 00 64 00 24 00 $...S.C.a.r.d.$.
+ 0060 41 00 6c 00 6c 00 52 00 65 00 61 00 64 00 65 00 A.l.l.R.e.a.d.e.
+ 0070 72 00 73 00 00 00 00 00 r.s.....
+ scard_device_control: output_len=2048 input_len=88 ioctl_code=0x9002c
+ */
+
+ /*
+ scard_device_control: dumping 120 bytes of data
+ 0000 00 08 00 00 80 00 00 00 14 00 09 00 00 00 00 00 ................
+ 0010 2e 2e 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ................
+ 0020 01 10 08 00 cc cc cc cc 48 00 00 00 00 00 00 00 ........H.......
+ 0030 02 00 00 00 00 00 00 00 72 64 00 00 00 00 00 00 ........rd......
+ 0040 81 27 00 00 00 00 00 00 04 00 00 00 84 b3 03 01 .'..............
+ 0050 24 00 00 00 53 00 43 00 61 00 72 00 64 00 24 00 $...S.C.a.r.d.$.
+ 0060 41 00 6c 00 6c 00 52 00 65 00 61 00 64 00 65 00 A.l.l.R.e.a.d.e.
+ 0070 72 00 73 00 00 00 00 00 r.s.....
+ scard_device_control: output_len=2048 input_len=128 ioctl_code=0x90014
+ */
+}
+
+/*****************************************************************************/
+static int
+align_s(struct stream *s, int bytes)
+{
+ int i32;
+
+ i32 = (int) (s->p - s->data);
+ while ((i32 % bytes) != 0)
+ {
+ out_uint8s(s, 1);
+ i32 = (int) (s->p - s->data);
+ }
+ return 0;
}
/**
+ * Get change in status
*
+ * @param irp I/O resource pkt
+ * @param wide TRUE if unicode string
+ * @param timeout timeout in milliseconds, -1 for infinity
+ * @param num_readers number of entries in rsa
+ * @param rsa array of READER_STATEs
*****************************************************************************/
-int APP_CC
-scard_init(void)
+static void APP_CC
+scard_send_GetStatusChange(IRP* irp, tui32 context, int wide, tui32 timeout,
+ tui32 num_readers, READER_STATE* rsa)
{
- log_debug("init")
- return scard_pcsc_init();
+ /* see [MS-RDPESC] 2.2.2.11 for ASCII */
+ /* see [MS-RDPESC] 2.2.2.12 for Wide char */
+
+ SMARTCARD* sc;
+ READER_STATE* rs;
+ struct stream* s;
+ tui32 ioctl;
+ int bytes;
+ int i;
+ int len;
+ int num_chars;
+ int index;
+ twchar w_reader_name[100];
+
+ if ((sc = smartcards[irp->scard_index]) == NULL)
+ {
+ log_error("smartcards[%d] is NULL", irp->scard_index);
+ return;
+ }
+
+ ioctl = (wide) ? SCARD_IOCTL_GET_STATUS_CHANGE_W :
+ SCARD_IOCTL_GET_STATUS_CHANGE_A;
+
+ if ((s = scard_make_new_ioctl(irp, ioctl)) == NULL)
+ return;
+
+ xstream_seek(s, 16); /* unused */
+ xstream_wr_u32_le(s, timeout);
+ xstream_wr_u32_le(s, num_readers);
+ xstream_wr_u32_le(s, 0); /* unused */
+
+ /* insert context */
+ xstream_wr_u32_le(s, 4);
+ xstream_wr_u32_le(s, context);
+
+ xstream_wr_u32_le(s, 0); /* unused */
+
+ /* insert card reader state */
+ for (i = 0; i < num_readers; i++)
+ {
+ rs = &rsa[i];
+ xstream_wr_u32_le(s, 0); /* unused */
+ xstream_wr_u32_le(s, rs->current_state);
+ xstream_wr_u32_le(s, rs->event_state);
+ xstream_wr_u32_le(s, rs->atr_len);
+ xstream_copyin(s, rs->atr, 33);
+ out_uint8s(s, 3);
+ }
+
+ if (wide)
+ {
+ /* insert card reader names */
+ for (i = 0; i < num_readers; i++)
+ {
+ rs = &rsa[i];
+ num_chars = g_mbstowcs(w_reader_name, rs->reader_name, 99);
+ xstream_wr_u32_le(s, 0); /* unused */
+ xstream_wr_u32_le(s, 0); /* unused */
+ xstream_wr_u32_le(s, num_chars);
+ for (index = 0; index < num_chars; index++)
+ {
+ xstream_wr_u16_le(s, w_reader_name[index]);
+ }
+ align_s(s, 4);
+ }
+ }
+ else
+ {
+ /* insert card reader names */
+ for (i = 0; i < num_readers; i++)
+ {
+ rs = &rsa[i];
+ num_chars = g_mbstowcs(w_reader_name, rs->reader_name, 99);
+ xstream_wr_u32_le(s, 0); /* unused */
+ xstream_wr_u32_le(s, 0); /* unused */
+ xstream_wr_u32_le(s, num_chars);
+ for (index = 0; index < num_chars; index++)
+ {
+ xstream_wr_u8(s, w_reader_name[index]);
+ }
+ align_s(s, 4);
+ }
+ }
+
+ /* get stream len */
+ bytes = xstream_len(s);
+
+ /* InputBufferLength is number of bytes AFTER 20 byte padding */
+ *(s->data + 28) = bytes - 56;
+
+ /* send to client */
+ send_channel_data(g_rdpdr_chan_id, s->data, bytes);
+ xstream_free(s);
}
/**
+ * Send connect command
*
+ * @param irp I/O resource pkt
+ * @param wide TRUE if unicode string
+ * @param rs reader state
*****************************************************************************/
-int APP_CC
-scard_deinit(void)
+static void APP_CC
+scard_send_Connect(IRP* irp, tui32 context, int wide, READER_STATE* rs)
{
- log_debug("deinit")
- return scard_pcsc_deinit();
+ /* see [MS-RDPESC] 2.2.2.13 for ASCII */
+ /* see [MS-RDPESC] 2.2.2.14 for Wide char */
+
+ SMARTCARD* sc;
+ struct stream* s;
+ tui32 ioctl;
+ int bytes;
+ int len;
+ int num_chars;
+ int index;
+ twchar w_reader_name[100];
+
+ if ((sc = smartcards[irp->scard_index]) == NULL)
+ {
+ log_error("smartcards[%d] is NULL", irp->scard_index);
+ return;
+ }
+
+ ioctl = (wide) ? SCARD_IOCTL_CONNECT_W :
+ SCARD_IOCTL_CONNECT_A;
+
+ if ((s = scard_make_new_ioctl(irp, ioctl)) == NULL)
+ return;
+
+ /*
+ * command format
+ *
+ * ......
+ * 20 bytes padding
+ * u32 4 bytes len 8, LE, v1
+ * u32 4 bytes filler
+ * 20 bytes unused (s->p currently pointed here at unused[0])
+ * u32 4 bytes dwShareMode
+ * u32 4 bytes dwPreferredProtocols
+ * xx bytes reader name
+ * u32 4 bytes context length (len)
+ * len bytes context
+ */
+
+ xstream_seek(s, 20);
+ xstream_wr_u32_le(s, rs->dwShareMode);
+ xstream_wr_u32_le(s, rs->dwPreferredProtocols);
+
+ /* insert reader name */
+ num_chars = g_mbstowcs(w_reader_name, rs->reader_name, 99);
+ xstream_wr_u32_le(s, 0);
+ xstream_wr_u32_le(s, 0);
+ xstream_wr_u32_le(s, num_chars);
+ if (wide)
+ {
+ for (index = 0; index < num_chars; index++)
+ {
+ xstream_wr_u16_le(s, w_reader_name[index]);
+ }
+ }
+ else
+ {
+ for (index = 0; index < num_chars; index++)
+ {
+ xstream_wr_u8(s, w_reader_name[index]);
+ }
+ }
+ align_s(s, 4);
+
+ /* insert context */
+ xstream_wr_u32_le(s, 4);
+ xstream_wr_u32_le(s, context);
+
+ /* get stream len */
+ bytes = xstream_len(s);
+
+ /* InputBufferLength is number of bytes AFTER 20 byte padding */
+ *(s->data + 28) = bytes - 56;
+
+ /* send to client */
+ send_channel_data(g_rdpdr_chan_id, s->data, bytes);
+ xstream_free(s);
+}
+
+/**
+ * The reconnect method re-establishes a smart card reader handle. On success,
+ * the handle is valid once again.
+ *
+ * @param con connection to client
+ * @param sc_handle handle to device
+ * @param rs reader state where following fields are set
+ * rs.shared_mode_flag
+ * rs.preferred_protocol
+ * rs.init_type
+ *****************************************************************************/
+static void APP_CC
+scard_send_Reconnect(IRP* irp, tui32 context, tui32 sc_handle, READER_STATE* rs)
+{
+ /* see [MS-RDPESC] 2.2.2.15 */
+ /* see [MS-RDPESC] 3.1.4.36 */
+
+ SMARTCARD* sc;
+ struct stream* s;
+ int bytes;
+
+ if ((sc = smartcards[irp->scard_index]) == NULL)
+ {
+ log_error("smartcards[%d] is NULL", irp->scard_index);
+ return;
+ }
+
+ if ((s = scard_make_new_ioctl(irp, SCARD_IOCTL_RECONNECT)) == NULL)
+ return;
+
+ /*
+ * command format
+ *
+ * ......
+ * 20 bytes padding
+ * u32 4 bytes len 8, LE, v1
+ * u32 4 bytes filler
+ * 24 bytes unused (s->p currently pointed here at unused[0])
+ * u32 4 bytes dwShareMode
+ * u32 4 bytes dwPreferredProtocols
+ * u32 4 bytes dwInitialization
+ * u32 4 bytes context length
+ * u32 4 bytes context
+ * u32 4 bytes handle length
+ * u32 4 bytes handle
+ */
+
+ xstream_seek(s, 24);
+ xstream_wr_u32_le(s, rs->dwShareMode);
+ xstream_wr_u32_le(s, rs->dwPreferredProtocols);
+ xstream_wr_u32_le(s, rs->init_type);
+ xstream_wr_u32_le(s, 4);
+ xstream_wr_u32_le(s, context);
+ xstream_wr_u32_le(s, 4);
+ xstream_wr_u32_le(s, sc_handle);
+
+ /* get stream len */
+ bytes = xstream_len(s);
+
+ /* InputBufferLength is number of bytes AFTER 20 byte padding */
+ *(s->data + 28) = bytes - 56;
+
+ /* send to client */
+ send_channel_data(g_rdpdr_chan_id, s->data, bytes);
+ xstream_free(s);
+}
+
+/**
+ * Lock smart card reader for exclusive access for specified smart
+ * card reader handle.
+ *
+ * @param con connection to client
+ *****************************************************************************/
+static void APP_CC
+scard_send_BeginTransaction(IRP *irp, tui32 sc_handle)
+{
+ /* see [MS-RDPESC] 4.9 */
+
+ SMARTCARD *sc;
+ struct stream *s;
+ int bytes;
+
+ if ((sc = smartcards[irp->scard_index]) == NULL)
+ {
+ log_error("smartcards[%d] is NULL", irp->scard_index);
+ return;
+ }
+
+ if ((s = scard_make_new_ioctl(irp, SCARD_IOCTL_BEGIN_TRANSACTION)) == NULL)
+ return;
+
+ /*
+ * command format
+ *
+ * ......
+ * 20 bytes padding
+ * u32 4 bytes len 8, LE, v1
+ * u32 4 bytes filler
+ * 36 bytes unused (s->p currently pointed here at unused[0])
+ * u32 4 bytes len of sc_handle
+ * 4 bytes sc_handle
+ */
+
+ xstream_seek(s, 36);
+
+ /* insert handle */
+ xstream_wr_u32_le(s, 4);
+ xstream_wr_u32_le(s, sc_handle);
+
+ /* get stream len */
+ bytes = xstream_len(s);
+
+ /* InputBufferLength is number of bytes AFTER 20 byte padding */
+ *(s->data + 28) = bytes - 56;
+
+ /* send to client */
+ send_channel_data(g_rdpdr_chan_id, s->data, bytes);
+ xstream_free(s);
+}
+
+/**
+ * Release a smart card reader after being locked by a previously
+ * successful call to Begin Transaction
+ *
+ * @param con connection to client
+ * @param sc_handle handle to smartcard
+ *****************************************************************************/
+static void APP_CC
+scard_send_EndTransaction(IRP *irp, tui32 sc_handle)
+{
+ /* see [MS-RDPESC] 3.1.4.32 */
+
+ SMARTCARD* sc;
+ struct stream* s;
+ int bytes;
+
+ if ((sc = smartcards[irp->scard_index]) == NULL)
+ {
+ log_error("smartcards[%d] is NULL", irp->scard_index);
+ return;
+ }
+
+ if ((s = scard_make_new_ioctl(irp, SCARD_IOCTL_END_TRANSACTION)) == NULL)
+ return;
+
+ /*
+ * command format
+ *
+ * ......
+ * 20 bytes padding
+ * u32 4 bytes len 8, LE, v1
+ * u32 4 bytes filler
+ * 24 bytes unused (s->p currently pointed here at unused[0])
+ * u32 4 bytes disposition
+ * 8 unused
+ * u32 4 bytes length of sc_handle
+ * 4 bytes sc_handle
+ */
+
+ xstream_seek(s, 24);
+ xstream_wr_u32_le(s, SCARD_LEAVE_CARD);
+ xstream_seek(s, 8);
+
+ /* insert handle */
+ xstream_wr_u32_le(s, 4);
+ xstream_wr_u32_le(s, sc_handle);
+
+ /* get stream len */
+ bytes = xstream_len(s);
+
+ /* InputBufferLength is number of bytes AFTER 20 byte padding */
+ *(s->data + 28) = bytes - 56;
+
+ /* send to client */
+ send_channel_data(g_rdpdr_chan_id, s->data, bytes);
+ xstream_free(s);
+}
+
+/**
+ * Get the status of a connection for a valid smart card reader handle
+ *
+ * @param con connection to client
+ * @param wide TRUE if unicode string
+ *****************************************************************************/
+static void APP_CC
+scard_send_Status(IRP *irp, int wide, tui32 sc_handle)
+{
+ /* see [MS-RDPESC] 2.2.2.18 */
+
+ SMARTCARD *sc;
+ struct stream *s;
+ int bytes;
+ tui32 ioctl;
+
+ if ((sc = smartcards[irp->scard_index]) == NULL)
+ {
+ log_error("smartcards[%d] is NULL", irp->scard_index);
+ return;
+ }
+
+ ioctl = (wide) ? SCARD_IOCTL_CONNECT_W :
+ SCARD_IOCTL_CONNECT_A;
+
+ if ((s = scard_make_new_ioctl(irp, ioctl)) == NULL)
+ return;
+
+ /*
+ * command format
+ *
+ * ......
+ * 20 bytes padding
+ * u32 4 bytes len 8, LE, v1
+ * u32 4 bytes filler
+ * 28 bytes unused (s->p currently pointed here at unused[0])
+ * u32 4 bytes reader len
+ * u32 4 bytes ATR len
+ * 8 bytes unused
+ * u32 4 bytes len of sc_handle
+ * 4 bytes sc_handle
+ * 4 bytes unused
+ */
+
+ xstream_seek(s, 28);
+ xstream_wr_u32_le(s, -1); /* readerLen, see [MS-RDPESC] 4.11 */
+ xstream_wr_u32_le(s, 36); /* atrLen, see [MS-RDPESC] 4.11 */
+ xstream_seek(s, 8);
+
+ /* insert sc_handle */
+ xstream_wr_u32_le(s, 4);
+ xstream_wr_u32_le(s, sc_handle);
+
+ xstream_wr_u32_le(s, 0);
+
+ /* get stream len */
+ bytes = xstream_len(s);
+
+ /* InputBufferLength is number of bytes AFTER 20 byte padding */
+ *(s->data + 28) = bytes - 56;
+
+ /* send to client */
+ send_channel_data(g_rdpdr_chan_id, s->data, bytes);
+ xstream_free(s);
+}
+
+/**
+ * Release a smart card reader handle that was acquired in ConnectA/ConnectW
+ *
+ * @param con connection to client
+ * @param sc_handle handle to smartcard
+ *****************************************************************************/
+static void APP_CC
+scard_send_Disconnect(IRP *irp, tui32 context, tui32 sc_handle)
+{
+ /* see [MS-RDPESC] 3.1.4.30 */
+
+ SMARTCARD* sc;
+ struct stream* s;
+ int bytes;
+
+ if ((sc = smartcards[irp->scard_index]) == NULL)
+ {
+ log_error("smartcards[%d] is NULL", irp->scard_index);
+ return;
+ }
+
+ if ((s = scard_make_new_ioctl(irp, SCARD_IOCTL_DISCONNECT)) == NULL)
+ return;
+
+ /*
+ * command format
+ *
+ * ......
+ * 20 bytes padding
+ * u32 4 bytes len 8, LE, v1
+ * u32 4 bytes filler
+ * 24 bytes unused (s->p currently pointed here at unused[0])
+ * u32 4 bytes disposition
+ * u32 4 bytes context len
+ * 4 bytes context
+ * u32 4 bytes length of sc_handle
+ * 4 bytes sc_handle
+ */
+
+ xstream_seek(s, 24);
+ xstream_wr_u32_le(s, SCARD_RESET_CARD);
+
+ /* insert context */
+ xstream_wr_u32_le(s, 4);
+ xstream_wr_u32_le(s, context);
+
+ /* insert handle */
+ xstream_wr_u32_le(s, 4);
+ xstream_wr_u32_le(s, sc_handle);
+
+ /* get stream len */
+ bytes = xstream_len(s);
+
+ /* InputBufferLength is number of bytes AFTER 20 byte padding */
+ *(s->data + 28) = bytes - 56;
+
+ /* send to client */
+ send_channel_data(g_rdpdr_chan_id, s->data, bytes);
+ xstream_free(s);
+}
+
+/**
+ * The Transmit_Call structure is used to send data to the smart card
+ * associated with a valid context.
+ *****************************************************************************/
+static int APP_CC
+scard_send_Transmit(IRP* irp, tui32 sc_handle, READER_STATE* rs)
+{
+ /* see [MS-RDPESC] 2.2.2.19 */
+
+ SMARTCARD* sc;
+ struct stream* s;
+ int bytes;
+
+ if ((sc = smartcards[irp->scard_index]) == NULL)
+ {
+ log_error("smartcards[%d] is NULL", irp->scard_index);
+ return;
+ }
+
+ if ((s = scard_make_new_ioctl(irp, SCARD_IOCTL_TRANSMIT)) == NULL)
+ return;
+
+ /*
+ * command format
+ *
+ * ......
+ * 20 bytes padding
+ * u32 4 bytes len 8, LE, v1
+ * u32 4 bytes filler
+ * 12 bytes unused (s->p currently pointed here at unused[0])
+ * u32 4 bytes map0
+ * 4 bytes unused
+ * u32 4 bytes map1
+ * u32 4 bytes dwProtocol
+ * u32 4 bytes cbPciLength
+ * u32 4 bytes map2
+ * u32 4 byts cbSendLength
+ * u32 4 bytes map3
+ * u32 4 bytes map4
+ * u32 4 bytes map5
+ * u32 4 bytes map6
+ * u32 4 bytes cbRecvLength
+ * u32 4 bytes len of sc_handle
+ * u32 4 bytes sc_handle
+ */
+
+ xstream_seek(s, 12);
+ xstream_wr_u32_le(s, rs->map0);
+ xstream_seek(s, 4);
+ xstream_wr_u32_le(s, rs->map1);
+ xstream_wr_u32_le(s, rs->dwProtocol);
+ xstream_wr_u32_le(s, rs->cbPciLength);
+ xstream_wr_u32_le(s, rs->map2);
+ xstream_wr_u32_le(s, rs->cbSendLength);
+ xstream_wr_u32_le(s, rs->map3);
+ xstream_wr_u32_le(s, rs->map4);
+ xstream_wr_u32_le(s, rs->map5);
+ xstream_wr_u32_le(s, rs->map6);
+ xstream_wr_u32_le(s, rs->cbRecvLength);
+ xstream_wr_u32_le(s, 4);
+ xstream_wr_u32_le(s, sc_handle);
+
+ /* get stream len */
+ bytes = xstream_len(s);
+
+ /* InputBufferLength is number of bytes AFTER 20 byte padding */
+ *(s->data + 28) = bytes - 56;
+
+ /* send to client */
+ send_channel_data(g_rdpdr_chan_id, s->data, bytes);
+ xstream_free(s);
+}
+
+/**
+ * Communicate directly with the smart card reader
+ *****************************************************************************/
+static int APP_CC
+scard_send_Control(IRP* irp, tui32 context, tui32 sc_handle, READER_STATE* rs)
+{
+ /* see [MS-RDPESC] 2.2.2.19 */
+
+ SMARTCARD* sc;
+ struct stream* s;
+ int bytes;
+
+ if ((sc = smartcards[irp->scard_index]) == NULL)
+ {
+ log_error("smartcards[%d] is NULL", irp->scard_index);
+ return;
+ }
+
+ if ((s = scard_make_new_ioctl(irp, SCARD_IOCTL_CONTROL)) == NULL)
+ return;
+
+ /*
+ * command format
+ *
+ * ......
+ * 20 bytes padding
+ * u32 4 bytes len 8, LE, v1
+ * u32 4 bytes filler
+ * 12 bytes unused (s->p currently pointed here at unused[0])
+ * u32 4 bytes map0
+ * 4 bytes unused
+ * u32 4 bytes map1
+ * u32 4 bytes dwControlCode
+ * u32 4 bytes cbRecvLength
+ * u32 4 bytes map2
+ * 4 bytes unused
+ * u32 4 bytes cbOutBufferSize
+ * u32 4 bytes context len
+ * u32 4 bytes context
+ * u32 4 bytes handle len
+ * u32 4 bytes handle
+ */
+
+ xstream_seek(s, 12);
+ xstream_wr_u32_le(s, rs->map0);
+ xstream_wr_u32_le(s, 0);
+ xstream_wr_u32_le(s, rs->map1);
+ xstream_wr_u32_le(s, rs->dwControlCode);
+ xstream_wr_u32_le(s, rs->cbRecvLength);
+ xstream_wr_u32_le(s, rs->map2);
+ xstream_wr_u32_le(s, 0);
+ xstream_wr_u32_le(s, rs->cbOutBufferSize);
+ xstream_wr_u32_le(s, 4);
+ xstream_wr_u32_le(s, context);
+ xstream_wr_u32_le(s, 4);
+ xstream_wr_u32_le(s, sc_handle);
+
+ /* get stream len */
+ bytes = xstream_len(s);
+
+ /* InputBufferLength is number of bytes AFTER 20 byte padding */
+ *(s->data + 28) = bytes - 56;
+
+ /* send to client */
+ send_channel_data(g_rdpdr_chan_id, s->data, bytes);
+ xstream_free(s);
+}
+
+/**
+ * Cancel any outstanding calls
+ *****************************************************************************/
+static int APP_CC scard_send_Cancel(IRP* irp, tui32 context)
+{
+ /* see [MS-RDPESC] 3.1.4.27 */
+
+ SMARTCARD* sc;
+ struct stream* s;
+ int bytes;
+
+ if ((sc = smartcards[irp->scard_index]) == NULL)
+ {
+ log_error("smartcards[%d] is NULL", irp->scard_index);
+ return;
+ }
+
+ if ((s = scard_make_new_ioctl(irp, SCARD_IOCTL_CANCEL)) == NULL)
+ return;
+
+ /*
+ * command format
+ *
+ * ......
+ * 20 bytes padding
+ * u32 4 bytes len 8, LE, v1
+ * u32 4 bytes filler
+ * 16 bytes unused (s->p currently pointed here at unused[0])
+ * u32 4 bytes context len
+ * u32 4 bytes context
+ */
+
+ xstream_seek(s, 16);
+ xstream_wr_u32_le(s, 4);
+ xstream_wr_u32_le(s, context);
+
+ /* get stream len */
+ bytes = xstream_len(s);
+
+ /* InputBufferLength is number of bytes AFTER 20 byte padding */
+ *(s->data + 28) = bytes - 56;
+
+ /* send to client */
+ send_channel_data(g_rdpdr_chan_id, s->data, bytes);
+ xstream_free(s);
+}
+
+/**
+ * Get reader attributes
+ *****************************************************************************/
+static int APP_CC
+scard_send_GetAttrib(IRP* irp, tui32 sc_handle, READER_STATE* rs)
+{
+ /* see [MS-RDPESC] 2.2.2.21 */
+
+ SMARTCARD* sc;
+ struct stream* s;
+ int bytes;
+
+ if ((sc = smartcards[irp->scard_index]) == NULL)
+ {
+ log_error("smartcards[%d] is NULL", irp->scard_index);
+ return;
+ }
+
+ if ((s = scard_make_new_ioctl(irp, SCARD_IOCTL_GETATTRIB)) == NULL)
+ return;
+
+ /*
+ * command format
+ *
+ * ......
+ * 20 bytes padding
+ * u32 4 bytes len 8, LE, v1
+ * u32 4 bytes filler
+ * 24 bytes unused (s->p currently pointed here at unused[0])
+ * u32 4 bytes dwAttribId
+ * 4 bytes unused
+ * u32 4 bytes dwAttrLen
+ * 8 bytes unused
+ * u32 4 bytes handle len
+ * u32 4 bytes handle
+ */
+
+ xstream_seek(s, 24);
+ xstream_wr_u32_le(s, rs->dwAttribId);
+ xstream_wr_u32_le(s, 0);
+ xstream_wr_u32_le(s, rs->dwAttrLen);
+ xstream_seek(s, 8);
+ xstream_wr_u32_le(s, 4);
+ xstream_wr_u32_le(s, sc_handle);
+
+ /* get stream len */
+ bytes = xstream_len(s);
+
+ /* InputBufferLength is number of bytes AFTER 20 byte padding */
+ *(s->data + 28) = bytes - 56;
+
+ /* send to client */
+ send_channel_data(g_rdpdr_chan_id, s->data, bytes);
+ xstream_free(s);
+}
+
+/******************************************************************************
+** **
+** local callbacks into this module **
+** **
+******************************************************************************/
+
+/**
+ *
+ *****************************************************************************/
+static void APP_CC
+scard_handle_EstablishContext_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus)
+{
+ tui32 len;
+ struct trans *con;
+
+ log_debug("entered");
+ /* sanity check */
+ if ((DeviceId != irp->DeviceId) || (CompletionId != irp->CompletionId))
+ {
+ log_error("DeviceId/CompletionId do not match those in IRP");
+ return;
+ }
+ if (IoStatus != 0)
+ {
+ log_error("failed to establish context - device not usable");
+ /* LK_TODO delete irp and smartcard entry */
+ return;
+ }
+ /* get OutputBufferLen */
+ xstream_rd_u32_le(s, len);
+ con = (struct trans *) (irp->user_data);
+ scard_function_establish_context_return(con, s, len);
+ devredir_irp_delete(irp);
+ log_debug("leaving");
+}
+
+/**
+ *
+ *****************************************************************************/
+static void
+scard_handle_ReleaseContext_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus)
+{
+ tui32 len;
+ struct trans *con;
+
+ log_debug("entered");
+ /* sanity check */
+ if ((DeviceId != irp->DeviceId) || (CompletionId != irp->CompletionId))
+ {
+ log_error("DeviceId/CompletionId do not match those in IRP");
+ return;
+ }
+ if (IoStatus != 0)
+ {
+ log_error("ReleaseContext failed");
+ /* LK_TODO delete irp and smartcard entry */
+ return;
+ }
+ /* get OutputBufferLen */
+ xstream_rd_u32_le(s, len);
+ con = (struct trans *) (irp->user_data);
+ scard_function_release_context_return(con, s, len);
+ devredir_irp_delete(irp);
+ log_debug("leaving");
+}
+
+static void APP_CC scard_handle_IsContextValid_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus)
+{
+ tui32 len;
+
+ log_debug("entered");
+
+ /* sanity check */
+ if ((DeviceId != irp->DeviceId) || (CompletionId != irp->CompletionId))
+ {
+ log_error("DeviceId/CompletionId do not match those in IRP");
+ return;
+ }
+
+ if (IoStatus != 0)
+ {
+ log_error("Error checking context validity");
+ /* LK_TODO delete irp and smartcard entry */
+ return;
+ }
+
+ /* get OutputBufferLen */
+ xstream_rd_u32_le(s, len);
+
+ log_debug("leaving");
+}
+
+/**
+ *
+ *****************************************************************************/
+static void APP_CC
+scard_handle_ListReaders_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus)
+{
+ tui32 len;
+ struct trans *con;
+
+ log_debug("entered");
+ /* sanity check */
+ if ((DeviceId != irp->DeviceId) || (CompletionId != irp->CompletionId))
+ {
+ log_error("DeviceId/CompletionId do not match those in IRP");
+ return;
+ }
+ if (IoStatus != 0)
+ {
+ log_error("failed to list readers");
+ /* LK_TODO delete irp and smartcard entry */
+ return;
+ }
+ /* get OutputBufferLen */
+ xstream_rd_u32_le(s, len);
+ con = (struct trans *) (irp->user_data);
+ scard_function_list_readers_return(con, s, len);
+ devredir_irp_delete(irp);
+ log_debug("leaving");
+}
+
+/**
+ *
+ *****************************************************************************/
+static void
+scard_handle_GetStatusChange_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus)
+{
+ tui32 len;
+ struct trans *con;
+
+ log_debug("entered");
+ /* sanity check */
+ if ((DeviceId != irp->DeviceId) || (CompletionId != irp->CompletionId))
+ {
+ log_error("DeviceId/CompletionId do not match those in IRP");
+ return;
+ }
+ if (IoStatus != 0)
+ {
+ log_error("failed to get status change");
+ /* LK_TODO delete irp and smartcard entry */
+ return;
+ }
+ /* get OutputBufferLen */
+ xstream_rd_u32_le(s, len);
+ con = (struct trans *) (irp->user_data);
+ scard_function_get_status_change_return(con, s, len);
+ devredir_irp_delete(irp);
+ log_debug("leaving");
+}
+
+/**
+ *
+ *****************************************************************************/
+static void
+scard_handle_Connect_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus)
+{
+ tui32 len;
+ struct trans *con;
+
+ log_debug("entered");
+
+ /* sanity check */
+ if ((DeviceId != irp->DeviceId) || (CompletionId != irp->CompletionId))
+ {
+ log_error("DeviceId/CompletionId do not match those in IRP");
+ return;
+ }
+
+ if (IoStatus != 0)
+ {
+ log_error("failed to connect");
+ /* LK_TODO delete irp and smartcard entry */
+ return;
+ }
+
+ /* get OutputBufferLen */
+ xstream_rd_u32_le(s, len);
+ con = (struct trans *) (irp->user_data);
+ scard_function_connect_return(con, s, len);
+ devredir_irp_delete(irp);
+ log_debug("leaving");
+}
+
+/**
+ *
+ *****************************************************************************/
+static void APP_CC
+scard_handle_Reconnect_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus)
+{
+ tui32 len;
+
+ log_debug("entered");
+
+ /* sanity check */
+ if ((DeviceId != irp->DeviceId) || (CompletionId != irp->CompletionId))
+ {
+ log_error("DeviceId/CompletionId do not match those in IRP");
+ return;
+ }
+
+ if (IoStatus != 0)
+ {
+ log_error("failed to reconnect");
+ /* LK_TODO delete irp and smartcard entry */
+ return;
+ }
+
+ /* get OutputBufferLen */
+ xstream_rd_u32_le(s, len);
+
+ log_debug("leaving");
+}
+
+/**
+ *
+ *****************************************************************************/
+static void
+scard_handle_BeginTransaction_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus)
+{
+ tui32 len;
+
+ log_debug("entered");
+
+ /* sanity check */
+ if ((DeviceId != irp->DeviceId) || (CompletionId != irp->CompletionId))
+ {
+ log_error("DeviceId/CompletionId do not match those in IRP");
+ return;
+ }
+
+ if (IoStatus != 0)
+ {
+ log_error("BeginTransaction failed");
+ /* LK_TODO delete irp and smartcard entry */
+ return;
+ }
+
+ /* get OutputBufferLen */
+ xstream_rd_u32_le(s, len);
+
+ log_debug("leaving");
+}
+
+/**
+ *
+ *****************************************************************************/
+static void
+scard_handle_EndTransaction_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus)
+{
+ tui32 len;
+
+ log_debug("entered");
+
+ /* sanity check */
+ if ((DeviceId != irp->DeviceId) || (CompletionId != irp->CompletionId))
+ {
+ log_error("DeviceId/CompletionId do not match those in IRP");
+ return;
+ }
+
+ if (IoStatus != 0)
+ {
+ log_error("EndTransaction failed");
+ /* LK_TODO delete irp and smartcard entry */
+ return;
+ }
+
+ /* get OutputBufferLen */
+ xstream_rd_u32_le(s, len);
+
+ log_debug("leaving");
+}
+
+/**
+ *
+ *****************************************************************************/
+static void
+scard_handle_Status_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus)
+{
+ tui32 len;
+
+ log_debug("entered");
+
+ /* sanity check */
+ if ((DeviceId != irp->DeviceId) || (CompletionId != irp->CompletionId))
+ {
+ log_error("DeviceId/CompletionId do not match those in IRP");
+ return;
+ }
+
+ if (IoStatus != 0)
+ {
+ log_error("StatusCall failed");
+ /* LK_TODO delete irp and smartcard entry */
+ return;
+ }
+
+ /* get OutputBufferLen */
+ xstream_rd_u32_le(s, len);
+
+ log_debug("leaving");
+}
+
+/**
+ *
+ *****************************************************************************/
+static void
+scard_handle_Disconnect_Return(struct stream *s, IRP *irp,
+ tui32 DeviceId, tui32 CompletionId,
+ tui32 IoStatus)
+{
+ tui32 len;
+
+ log_debug("entered");
+
+ /* sanity check */
+ if ((DeviceId != irp->DeviceId) || (CompletionId != irp->CompletionId))
+ {
+ log_error("DeviceId/CompletionId do not match those in IRP");
+ return;
+ }
+
+ if (IoStatus != 0)
+ {
+ log_error("Disconnect failed");
+ /* LK_TODO delete irp and smartcard entry */
+ return;
+ }
+
+ /* get OutputBufferLen */
+ xstream_rd_u32_le(s, len);
+
+ log_debug("leaving");
+}
+
+/**
+ *
+ *****************************************************************************/
+static void APP_CC
+scard_handle_Transmit_Return(struct stream *s, IRP *irp, tui32 DeviceId,
+ tui32 CompletionId, tui32 IoStatus)
+{
+ tui32 len;
+
+ log_debug("entered");
+
+ /* sanity check */
+ if ((DeviceId != irp->DeviceId) || (CompletionId != irp->CompletionId))
+ {
+ log_error("DeviceId/CompletionId do not match those in IRP");
+ return;
+ }
+
+ if (IoStatus != 0)
+ {
+ log_error("Transmit failed");
+ /* LK_TODO delete irp and smartcard entry */
+ return;
+ }
+
+ /* get OutputBufferLen */
+ xstream_rd_u32_le(s, len);
+
+ log_debug("leaving");
+}
+
+/**
+ *
+ *****************************************************************************/
+static void APP_CC
+scard_handle_Control_Return(struct stream *s, IRP *irp, tui32 DeviceId,
+ tui32 CompletionId,tui32 IoStatus)
+{
+ tui32 len;
+
+ log_debug("entered");
+
+ /* sanity check */
+ if ((DeviceId != irp->DeviceId) || (CompletionId != irp->CompletionId))
+ {
+ log_error("DeviceId/CompletionId do not match those in IRP");
+ return;
+ }
+
+ if (IoStatus != 0)
+ {
+ log_error("Control failed");
+ /* LK_TODO delete irp and smartcard entry */
+ return;
+ }
+
+ /* get OutputBufferLen */
+ xstream_rd_u32_le(s, len);
+
+ log_debug("leaving");
+}
+
+/**
+ *
+ *****************************************************************************/
+static void APP_CC
+scard_handle_Cancel_Return(struct stream *s, IRP *irp, tui32 DeviceId,
+ tui32 CompletionId, tui32 IoStatus)
+{
+ tui32 len;
+
+ log_debug("entered");
+
+ /* sanity check */
+ if ((DeviceId != irp->DeviceId) || (CompletionId != irp->CompletionId))
+ {
+ log_error("DeviceId/CompletionId do not match those in IRP");
+ return;
+ }
+
+ if (IoStatus != 0)
+ {
+ log_error("Cancel_call failed");
+ /* LK_TODO delete irp and smartcard entry */
+ return;
+ }
+
+ /* get OutputBufferLen */
+ xstream_rd_u32_le(s, len);
+
+ log_debug("leaving");
+}
+
+/**
+ *
+ *****************************************************************************/
+static void APP_CC
+scard_handle_GetAttrib_Return(struct stream *s, IRP *irp, tui32 DeviceId,
+ tui32 CompletionId, tui32 IoStatus)
+{
+ tui32 len;
+
+ log_debug("entered");
+
+ /* sanity check */
+ if ((DeviceId != irp->DeviceId) || (CompletionId != irp->CompletionId))
+ {
+ log_error("DeviceId/CompletionId do not match those in IRP");
+ return;
+ }
+
+ if (IoStatus != 0)
+ {
+ log_error("GetAttrib_call failed");
+ /* LK_TODO delete irp and smartcard entry */
+ return;
+ }
+
+ /* get OutputBufferLen */
+ xstream_rd_u32_le(s, len);
+
+ log_debug("leaving");
}
diff --git a/sesman/chansrv/smartcard.h b/sesman/chansrv/smartcard.h
index a85b9f5f..600aef04 100644
--- a/sesman/chansrv/smartcard.h
+++ b/sesman/chansrv/smartcard.h
@@ -26,26 +26,118 @@
#include "parse.h"
#include "irp.h"
+#include "trans.h"
+
+#define SCARD_SHARE_EXCLUSIVE 0x00000001
+#define SCARD_SHARE_SHARED 0x00000002
+#define SCARD_SHARE_DIRECT 0x00000003
+
+/* see [MS-RDPESC] 2.2.5 protocol identifier - Table A */
+#define SCARD_PROTOCOL_UNDEFINED 0x00000000
+#define SCARD_PROTOCOL_T0 0x00000001
+#define SCARD_PROTOCOL_T1 0x00000002
+#define SCARD_PROTOCOL_Tx 0x00000003
+#define SCARD_PROTOCOL_RAW 0x00010000
+
+/* see [MS-RDPESC] 2.2.5 protocol identifier - Table B */
+#define SCARD_PROTOCOL_DEFAULT 0x80000000
+#define SCARD_PROTOCOL_OPTIMAL 0x00000000
+
+/* initialization type */
+#define SCARD_LEAVE_CARD 0x00000000 /* do not do anything */
+#define SCARD_RESET_CARD 0x00000001 /* reset smart card */
+#define SCARD_UNPOWER_CARD 0x00000002 /* turn off and reset card */
+
+typedef struct reader_state
+{
+ char reader_name[128];
+ tui32 current_state;
+ tui32 event_state;
+ tui32 atr_len; /* number of bytes in atr[] */
+ tui8 atr[36];
+
+ /*
+ * share mode flag, can be one of:
+ * SCARD_SHARE_EXCLUSIVE app not willing to share smartcard with other apps
+ * SCARD_SHARE_SHARED app willing to share smartcard with other apps
+ * SCARD_SHARE_DIRECT app demands direct control of smart card, hence
+ * it is not available to other readers
+ */
+ tui32 dwShareMode;
+
+ /*
+ * This field MUST have a value from Table A which is logically
+ * OR'ed with a value from Table B.
+ */
+ tui32 dwPreferredProtocols;
+
+ /*
+ * initialization type, must be one of the initialization type
+ * defined above
+ */
+ tui32 init_type;
+
+ /* required by scard_send_transmit(), scard_send_control() */
+ tui32 map0;
+ tui32 map1;
+ tui32 map2;
+ tui32 map3;
+ tui32 map4;
+ tui32 map5;
+ tui32 map6;
+
+ tui32 dwProtocol;
+ tui32 cbPciLength;
+ tui32 cbSendLength;
+ tui32 cbRecvLength;
+ tui32 dwControlCode;
+ tui32 cbOutBufferSize;
+ tui32 dwAttribId;
+ tui32 dwAttrLen;
+
+} READER_STATE;
-/* forward declarations */
void scard_device_announce(tui32 device_id);
+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);
+int APP_CC scard_send_establish_context(struct trans *con, int scope);
+int APP_CC scard_send_release_context(struct trans *con, tui32 context);
+int APP_CC scard_send_is_valid_context(struct trans *con, tui32 context);
+int APP_CC scard_send_list_readers(struct trans *con, tui32 context, int wide);
+
+int APP_CC scard_send_get_status_change(struct trans *con, tui32 context,
+ int wide, tui32 timeout,
+ tui32 num_readers, READER_STATE* rsa);
+
+int APP_CC scard_send_connect(struct trans *con, tui32 context, int wide,
+ READER_STATE* rs);
+
+int APP_CC scard_send_reconnect(struct trans *con, tui32 context,
+ tui32 sc_handle, READER_STATE* rs);
-/* callbacks into this module */
-void scard_handle_EstablishContext_Return(struct stream *s, IRP *irp,
- tui32 DeviceId, tui32 CompletionId,
- tui32 IoStatus);
+int APP_CC scard_send_begin_transaction(struct trans *con, tui32 sc_handle);
+int APP_CC scard_send_end_transaction(struct trans *con, tui32 sc_handle);
+int APP_CC scard_send_status(struct trans *con, int wide, tui32 sc_handle);
+int APP_CC scard_send_disconnect(struct trans *con, tui32 context, tui32 sc_handle);
-void scard_handle_ListReaders_Return(struct stream *s, IRP *irp,
- tui32 DeviceId, tui32 CompletionId,
- tui32 IoStatus);
+int APP_CC scard_send_transmit(struct trans *con, tui32 sc_handle,
+ READER_STATE* rs);
-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);
+int APP_CC scard_send_control(struct trans *con, tui32 context, tui32 sc_handle,
+ READER_STATE* rs);
+int APP_CC scard_send_cancel(struct trans *con, tui32 context);
+
+int APP_CC scard_send_get_attrib(struct trans *con, tui32 sc_handle,
+ READER_STATE* rs);
+
+/*
+ * Notes:
+ * SCardTransmit - partially done
+ * SCardControl - partially done
+ * SCardListReaderGroups - not supported
+ * SCardSetAttrib - not supported
+ */
#endif /* end #ifndef _SMARTCARD_C */
diff --git a/sesman/chansrv/smartcard_pcsc.c b/sesman/chansrv/smartcard_pcsc.c
index a3a269d7..62b3b722 100644
--- a/sesman/chansrv/smartcard_pcsc.c
+++ b/sesman/chansrv/smartcard_pcsc.c
@@ -20,8 +20,12 @@
/*
* smartcard redirection support, PCSC daemon standin
* this will act like pcsc daemon
+ * pcsc lib and daemon write struct on unix domain socket for communication
*/
+#define JAY_TODO_CONTEXT 0
+#define JAY_TODO_WIDE 1
+
#define PCSC_STANDIN 1
#include "os_calls.h"
@@ -30,77 +34,32 @@
#include "irp.h"
#include "devredir.h"
#include "trans.h"
+#include "chansrv.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
+#define LLOG_LEVEL 11
+#define LLOGLN(_level, _args) \
+ do \
+ { \
+ if (_level < LLOG_LEVEL) \
+ { \
+ g_write("chansrv:smartcard_pcsc [%10.10u]: ", g_time3()); \
+ g_writeln _args ; \
+ } \
+ } \
+ while (0)
+
+#define XRDP_PCSC_STATE_NONE 0
+#define XRDP_PCSC_STATE_GOT_EC (1 << 0) /* establish context */
+#define XRDP_PCSC_STATE_GOT_LR (1 << 1) /* list readers */
+#define XRDP_PCSC_STATE_GOT_RC (1 << 2) /* release context */
+#define XRDP_PCSC_STATE_GOT_GSC (1 << 3) /* get status change */
+#define XRDP_PCSC_STATE_GOT_C (1 << 4) /* connect */
+#define XRDP_PCSC_STATE_GOT_BT (1 << 5) /* begin transaction */
+
+/* TODO: put this in con */
+static int g_xrdp_pcsc_state = XRDP_PCSC_STATE_NONE;
extern int g_display_num; /* in chansrv.c */
@@ -115,15 +74,14 @@ 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] = "";
+static char g_pcsclite_ipc_dir[256] = "";
+static int g_pub_file_fd = 0;
/*****************************************************************************/
int APP_CC
scard_pcsc_get_wait_objs(tbus *objs, int *count, int *timeout)
{
- log_debug("scard_pcsc_get_wait_objs");
-
+ LLOGLN(0, ("scard_pcsc_get_wait_objs"));
if (g_lis != 0)
{
trans_get_wait_objs(g_lis, objs, count);
@@ -139,8 +97,7 @@ scard_pcsc_get_wait_objs(tbus *objs, int *count, int *timeout)
int APP_CC
scard_pcsc_check_wait_objs(void)
{
- log_debug("scard_pcsc_check_wait_objs");
-
+ LLOGLN(0, ("scard_pcsc_check_wait_objs"));
if (g_lis != 0)
{
trans_check_wait_objs(g_lis);
@@ -155,34 +112,488 @@ scard_pcsc_check_wait_objs(void)
/*****************************************************************************/
/* returns error */
int APP_CC
-scard_process_version(psharedSegmentMsg msg)
+scard_process_establish_context(struct trans *con, struct stream *in_s)
{
+ int dwScope;
+
+ LLOGLN(0, ("scard_process_establish_context:"));
+ if (g_xrdp_pcsc_state & XRDP_PCSC_STATE_GOT_EC)
+ {
+ LLOGLN(0, ("scard_process_establish_context: opps"));
+ return 1;
+ }
+ g_xrdp_pcsc_state |= XRDP_PCSC_STATE_GOT_EC;
+ in_uint32_le(in_s, dwScope);
+ LLOGLN(0, ("scard_process_establish_context: dwScope 0x%8.8x", dwScope));
+ scard_send_establish_context(con, dwScope);
return 0;
}
/*****************************************************************************/
/* returns error */
int APP_CC
-scard_process_msg(struct stream *s)
+scard_function_establish_context_return(struct trans *con,
+ struct stream *in_s,
+ int len)
{
- sharedSegmentMsg msg;
- int rv;
+ int bytes;
+ tui32 context;
+ tui32 context_len;
+ struct stream *out_s;
+
+ LLOGLN(0, ("scard_function_establish_context_return:"));
+ if ((g_xrdp_pcsc_state & XRDP_PCSC_STATE_GOT_EC) == 0)
+ {
+ LLOGLN(0, ("scard_function_establish_context_return: opps"));
+ return 1;
+ }
+ g_xrdp_pcsc_state &= ~XRDP_PCSC_STATE_GOT_EC;
+ in_uint8s(in_s, 28);
+ in_uint32_le(in_s, context_len);
+ if (context_len != 4)
+ {
+ LLOGLN(0, ("scard_function_establish_context_return: opps"));
+ return 1;
+ }
+ in_uint32_le(in_s, context);
+ LLOGLN(0, ("scard_function_establish_context_return: context 0x%8.8x", context));
+ out_s = trans_get_out_s(con, 8192);
+ s_push_layer(out_s, iso_hdr, 8);
+ out_uint32_le(out_s, context);
+ out_uint32_le(out_s, 0); /* SCARD_S_SUCCESS status */
+ s_mark_end(out_s);
+ bytes = (int) (out_s->end - out_s->data);
+ s_pop_layer(out_s, iso_hdr);
+ out_uint32_le(out_s, bytes - 8);
+ out_uint32_le(out_s, 0x01); /* SCARD_ESTABLISH_CONTEXT 0x01 */
+ return trans_force_write(con);
+}
+
+/*****************************************************************************/
+/* returns error */
+int APP_CC
+scard_process_release_context(struct trans *con, struct stream *in_s)
+{
+ int hContext;
+
+ LLOGLN(0, ("scard_process_release_context:"));
+ if (g_xrdp_pcsc_state & XRDP_PCSC_STATE_GOT_RC)
+ {
+ LLOGLN(0, ("scard_process_establish_context: opps"));
+ return 1;
+ }
+ g_xrdp_pcsc_state |= XRDP_PCSC_STATE_GOT_RC;
+ in_uint32_le(in_s, hContext);
+ LLOGLN(0, ("scard_process_release_context: hContext 0x%8.8x", hContext));
+ scard_send_release_context(con, hContext);
+ return 0;
+}
+
+/*****************************************************************************/
+/* returns error */
+int APP_CC
+scard_function_release_context_return(struct trans *con,
+ struct stream *in_s,
+ int len)
+{
+ int bytes;
+ struct stream *out_s;
+ tui32 context;
+
+ LLOGLN(0, ("scard_function_release_context_return:"));
+ if ((g_xrdp_pcsc_state & XRDP_PCSC_STATE_GOT_RC) == 0)
+ {
+ LLOGLN(0, ("scard_function_release_context_return: opps"));
+ return 1;
+ }
+ g_xrdp_pcsc_state &= ~XRDP_PCSC_STATE_GOT_RC;
+ out_s = trans_get_out_s(con, 8192);
+ s_push_layer(out_s, iso_hdr, 8);
+ out_uint32_le(out_s, 0); /* SCARD_S_SUCCESS status */
+ s_mark_end(out_s);
+ bytes = (int) (out_s->end - out_s->data);
+ s_pop_layer(out_s, iso_hdr);
+ out_uint32_le(out_s, bytes - 8);
+ out_uint32_le(out_s, 0x02); /* SCARD_RELEASE_CONTEXT 0x02 */
+ return trans_force_write(con);
+}
+
+/*****************************************************************************/
+/* returns error */
+int APP_CC
+scard_process_list_readers(struct trans *con, struct stream *in_s)
+{
+ int hContext;
+
+ LLOGLN(0, ("scard_process_list_readers:"));
+ if (g_xrdp_pcsc_state & XRDP_PCSC_STATE_GOT_LR)
+ {
+ LLOGLN(0, ("scard_process_list_readers: opps"));
+ return 1;
+ }
+ g_xrdp_pcsc_state |= XRDP_PCSC_STATE_GOT_LR;
+ in_uint32_le(in_s, hContext);
+ LLOGLN(0, ("scard_process_list_readers: dwScope 0x%8.8x", hContext));
+ scard_send_list_readers(con, hContext, 1);
+ return 0;
+}
+
+/*****************************************************************************/
+int APP_CC
+scard_function_list_readers_return(struct trans *con,
+ struct stream *in_s,
+ int len)
+{
+ struct stream *out_s;
+ int chr;
+ int readers;
+ int rn_index;
+ int index;
+ int bytes;
+ twchar reader_name[100];
+ char lreader_name[16][100];
+
+ LLOGLN(10, ("scard_function_list_readers_return:"));
+ g_hexdump(in_s->p, len);
+ if ((g_xrdp_pcsc_state & XRDP_PCSC_STATE_GOT_LR) == 0)
+ {
+ LLOGLN(10, ("scard_function_list_readers_return: opps"));
+ return 1;
+ }
+ g_xrdp_pcsc_state &= ~XRDP_PCSC_STATE_GOT_LR;
+
+ g_memset(reader_name, 0, sizeof(reader_name));
+ g_memset(lreader_name, 0, sizeof(lreader_name));
+ in_uint8s(in_s, 28);
+ len -= 28;
+ in_uint32_le(in_s, len);
+ g_writeln("len %d", len);
+ rn_index = 0;
+ readers = 0;
+ while (len > 0)
+ {
+ in_uint16_le(in_s, chr);
+ len -= 2;
+ if (chr == 0)
+ {
+ if (reader_name[0] != 0)
+ {
+ g_wcstombs(lreader_name[readers], reader_name, 99);
+ g_writeln("1 %s", lreader_name[readers]);
+ g_memset(reader_name, 0, sizeof(reader_name));
+ readers++;
+ }
+ reader_name[0] = 0;
+ rn_index = 0;
+ }
+ else
+ {
+ reader_name[rn_index] = chr;
+ rn_index++;
+ }
+ }
+ if (rn_index > 0)
+ {
+ if (reader_name[0] != 0)
+ {
+ g_wcstombs(lreader_name[readers], reader_name, 99);
+ g_writeln("2 %s", lreader_name[readers]);
+ g_memset(reader_name, 0, sizeof(reader_name));
+ readers++;
+ }
+ }
+
+ out_s = trans_get_out_s(con, 8192);
+ s_push_layer(out_s, iso_hdr, 8);
+ out_uint32_le(out_s, readers);
+ for (index = 0; index < readers; index++)
+ {
+ g_writeln("3 - %s", lreader_name[index]);
+ out_uint8a(out_s, lreader_name[index], 100);
+ }
+ out_uint32_le(out_s, 0); /* SCARD_S_SUCCESS status */
+ s_mark_end(out_s);
+ bytes = (int) (out_s->end - out_s->data);
+ s_pop_layer(out_s, iso_hdr);
+ out_uint32_le(out_s, bytes - 8);
+ out_uint32_le(out_s, 0x03); /* SCARD_LIST_READERS 0x03 */
+ return trans_force_write(con);
+}
+
+/*****************************************************************************/
+/* returns error */
+int APP_CC
+scard_process_connect(struct trans *con, struct stream *in_s)
+{
+ int hContext;
+ char szReader[100];
+ READER_STATE rs;
+
+ LLOGLN(0, ("scard_process_connect:"));
+ if (g_xrdp_pcsc_state & XRDP_PCSC_STATE_GOT_C)
+ {
+ LLOGLN(0, ("scard_process_connect: opps"));
+ return 1;
+ }
+ g_memset(&rs, 0, sizeof(rs));
+ g_xrdp_pcsc_state |= XRDP_PCSC_STATE_GOT_C;
+ in_uint32_le(in_s, hContext);
+ in_uint8a(in_s, szReader, 100);
+ in_uint32_le(in_s, rs.dwShareMode);
+ in_uint32_le(in_s, rs.dwPreferredProtocols);
+ LLOGLN(0, ("scard_process_connect: dwShareMode 0x%8.8x "
+ "dwPreferredProtocols 0x%8.8x", rs.dwShareMode,
+ rs.dwPreferredProtocols));
+ scard_send_connect(con, hContext, 1, &rs);
+ return 0;
+}
+
+/*****************************************************************************/
+int APP_CC
+scard_function_connect_return(struct trans *con,
+ struct stream *in_s,
+ int len)
+{
+ int dwActiveProtocol;
+ int hCard;
+ int bytes;
+ struct stream *out_s;
- 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);
+ g_hexdump(in_s->p, len);
+ if ((g_xrdp_pcsc_state & XRDP_PCSC_STATE_GOT_C) == 0)
+ {
+ LLOGLN(0, ("scard_function_connect_return: opps"));
+ return 1;
+ }
+ g_xrdp_pcsc_state &= ~XRDP_PCSC_STATE_GOT_C;
+ in_uint8s(in_s, 36);
+ in_uint32_le(in_s, dwActiveProtocol);
+ in_uint8s(in_s, 36);
+ in_uint32_le(in_s, hCard);
+ out_s = trans_get_out_s(con, 8192);
+ s_push_layer(out_s, iso_hdr, 8);
+ out_uint32_le(out_s, hCard);
+ out_uint32_le(out_s, dwActiveProtocol);
+ out_uint32_le(out_s, 0); /* SCARD_S_SUCCESS status */
+ s_mark_end(out_s);
+ bytes = (int) (out_s->end - out_s->data);
+ s_pop_layer(out_s, iso_hdr);
+ out_uint32_le(out_s, bytes - 8);
+ out_uint32_le(out_s, 0x04); /* SCARD_CONNECT 0x04 */
+ return trans_force_write(con);
+}
- log_debug("scard_process_msg: mtype 0x%2.2x command 0x%2.2x",
- msg.mtype, msg.command);
+/*****************************************************************************/
+/* returns error */
+int APP_CC
+scard_process_begin_transaction(struct trans *con, struct stream *in_s)
+{
+ int hCard;
+
+ LLOGLN(0, ("scard_process_begin_transaction:"));
+ if (g_xrdp_pcsc_state & XRDP_PCSC_STATE_GOT_BT)
+ {
+ LLOGLN(0, ("scard_process_begin_transaction: opps"));
+ return 1;
+ }
+ g_xrdp_pcsc_state |= XRDP_PCSC_STATE_GOT_BT;
+ in_uint32_le(in_s, hCard);
+ LLOGLN(0, ("scard_process_begin_transaction: hCard 0x%8.8x", hCard));
+ scard_send_begin_transaction(con, hCard);
+ return 0;
+}
+/*****************************************************************************/
+/* returns error */
+int APP_CC
+scard_process_get_status_change(struct trans *con, struct stream *in_s)
+{
+ int index;
+ int hContext;
+ int dwTimeout;
+ int cReaders;
+ READER_STATE *rsa;
+
+ LLOGLN(0, ("scard_process_get_status_change:"));
+ if (g_xrdp_pcsc_state & XRDP_PCSC_STATE_GOT_GSC)
+ {
+ LLOGLN(0, ("scard_process_get_status_change: opps"));
+ return 1;
+ }
+ in_uint32_le(in_s, hContext);
+ in_uint32_le(in_s, dwTimeout);
+ in_uint32_le(in_s, cReaders);
+ if ((cReaders < 0) || (cReaders > 16))
+ {
+ LLOGLN(0, ("scard_process_get_status_change: bad cReaders %d", cReaders));
+ return 1;
+ }
+ rsa = (READER_STATE *) g_malloc(sizeof(READER_STATE) * cReaders, 1);
+
+ for (index = 0; index < cReaders; index++)
+ {
+ in_uint8a(in_s, rsa[index].reader_name, 100);
+ LLOGLN(10, ("scard_process_get_status_change: reader_name %s",
+ rsa[index].reader_name));
+ in_uint32_le(in_s, rsa[index].current_state);
+ LLOGLN(10, ("scard_process_get_status_change: current_state %d",
+ rsa[index].current_state));
+ in_uint32_le(in_s, rsa[index].event_state);
+ LLOGLN(10, ("scard_process_get_status_change: event_state %d",
+ rsa[index].event_state));
+ in_uint32_le(in_s, rsa[index].atr_len);
+ LLOGLN(10, ("scard_process_get_status_change: atr_len %d",
+ rsa[index].atr_len));
+ in_uint8a(in_s, rsa[index].atr, 36);
+ }
+
+ LLOGLN(0, ("scard_process_get_status_change: hContext 0x%8.8x dwTimeout "
+ "%d cReaders %d", hContext, dwTimeout, cReaders));
+
+ g_xrdp_pcsc_state |= XRDP_PCSC_STATE_GOT_GSC;
+
+ scard_send_get_status_change(con, hContext, 1, dwTimeout, cReaders, rsa);
+
+ g_free(rsa);
+
+ return 0;
+}
+
+/*****************************************************************************/
+int APP_CC
+scard_function_get_status_change_return(struct trans *con,
+ struct stream *in_s,
+ int len)
+{
+ int bytes;
+ int index;
+ int cReaders;
+ tui32 current_state;
+ tui32 event_state;
+ tui32 atr_len; /* number of bytes in atr[] */
+ tui8 atr[36];
+ struct stream *out_s;
+
+ LLOGLN(0, ("scard_function_get_status_change_return:"));
+ g_hexdump(in_s->p, len);
+ if ((g_xrdp_pcsc_state & XRDP_PCSC_STATE_GOT_GSC) == 0)
+ {
+ LLOGLN(0, ("scard_function_establish_context_return: opps"));
+ return 1;
+ }
+ g_xrdp_pcsc_state &= ~XRDP_PCSC_STATE_GOT_GSC;
+ in_uint8s(in_s, 28);
+ in_uint32_le(in_s, cReaders);
+ if (cReaders > 0)
+ {
+ out_s = trans_get_out_s(con, 8192);
+ s_push_layer(out_s, iso_hdr, 8);
+ out_uint32_le(out_s, cReaders);
+ for (index = 0; index < cReaders; index++)
+ {
+ in_uint32_le(in_s, current_state);
+ out_uint32_le(out_s, current_state);
+ in_uint32_le(in_s, event_state);
+ out_uint32_le(out_s, event_state);
+ in_uint32_le(in_s, atr_len);
+ out_uint32_le(out_s, atr_len);
+ in_uint8a(in_s, atr, 36);
+ out_uint8a(out_s, atr, 36);
+ }
+ out_uint32_le(out_s, 0); /* SCARD_S_SUCCESS status */
+ s_mark_end(out_s);
+ bytes = (int) (out_s->end - out_s->data);
+ s_pop_layer(out_s, iso_hdr);
+ out_uint32_le(out_s, bytes - 8);
+ out_uint32_le(out_s, 0x0C); /* SCARD_ESTABLISH_CONTEXT 0x0C */
+ return trans_force_write(con);
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+/* returns error */
+int APP_CC
+scard_process_msg(struct trans *con, struct stream *in_s, int command)
+{
+ int rv;
+
+ LLOGLN(0, ("scard_process_msg: command 0x%4.4x", command));
rv = 0;
- switch (msg.mtype)
+ switch (command)
{
- case 0xF8: /* CMD_VERSION */
- rv = scard_process_version(&msg);
+ case 0x01: /* SCARD_ESTABLISH_CONTEXT */
+ LLOGLN(0, ("scard_process_msg: SCARD_ESTABLISH_CONTEXT"));
+ rv = scard_process_establish_context(con, in_s);
+ break;
+ case 0x02: /* SCARD_RELEASE_CONTEXT */
+ LLOGLN(0, ("scard_process_msg: SCARD_RELEASE_CONTEXT"));
+ rv = scard_process_release_context(con, in_s);
+ break;
+
+ case 0x03: /* SCARD_LIST_READERS */
+ LLOGLN(0, ("scard_process_msg: SCARD_LIST_READERS"));
+ rv = scard_process_list_readers(con, in_s);
+ break;
+
+ case 0x04: /* SCARD_CONNECT */
+ LLOGLN(0, ("scard_process_msg: SCARD_CONNECT"));
+ rv = scard_process_connect(con, in_s);
+ break;
+
+ case 0x05: /* SCARD_RECONNECT */
+ LLOGLN(0, ("scard_process_msg: SCARD_RECONNECT"));
+ break;
+
+ case 0x06: /* SCARD_DISCONNECT */
+ LLOGLN(0, ("scard_process_msg: SCARD_DISCONNECT"));
+ break;
+
+ case 0x07: /* SCARD_BEGIN_TRANSACTION */
+ LLOGLN(0, ("scard_process_msg: SCARD_BEGIN_TRANSACTION"));
+ rv = scard_process_begin_transaction(con, in_s);
+ break;
+
+ case 0x08: /* SCARD_END_TRANSACTION */
+ LLOGLN(0, ("scard_process_msg: SCARD_END_TRANSACTION"));
+ break;
+
+ case 0x09: /* SCARD_TRANSMIT */
+ LLOGLN(0, ("scard_process_msg: SCARD_TRANSMIT"));
+ break;
+
+ case 0x0A: /* SCARD_CONTROL */
+ LLOGLN(0, ("scard_process_msg: SCARD_CONTROL"));
+ break;
+
+ case 0x0B: /* SCARD_STATUS */
+ LLOGLN(0, ("scard_process_msg: SCARD_STATUS"));
+ break;
+
+ case 0x0C: /* SCARD_GET_STATUS_CHANGE */
+ LLOGLN(0, ("scard_process_msg: SCARD_GET_STATUS_CHANGE"));
+ rv = scard_process_get_status_change(con, in_s);
+ break;
+
+ case 0x0D: /* SCARD_CANCEL */
+ LLOGLN(0, ("scard_process_msg: SCARD_CANCEL"));
+ break;
+
+ case 0x0E: /* SCARD_CANCEL_TRANSACTION */
+ LLOGLN(0, ("scard_process_msg: SCARD_CANCEL_TRANSACTION"));
+ break;
+
+ case 0x0F: /* SCARD_GET_ATTRIB */
+ LLOGLN(0, ("scard_process_msg: SCARD_GET_ATTRIB"));
+ break;
+
+ case 0x10: /* SCARD_SET_ATTRIB */
+ LLOGLN(0, ("scard_process_msg: SCARD_SET_ATTRIB"));
+ break;
+
+ default:
+ LLOGLN(0, ("scard_process_msg: unknown mtype 0x%4.4x", command));
+ rv = 1;
break;
}
return rv;
@@ -196,22 +607,27 @@ my_pcsc_trans_data_in(struct trans *trans)
struct stream *s;
int id;
int size;
+ int command;
int error;
- log_debug("my_pcsc_trans_data_in:");
-
+ LLOGLN(0, ("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);
+ in_uint32_le(s, size);
+ in_uint32_le(s, command);
+ LLOGLN(0, ("my_pcsc_trans_data_in: size %d command %d", size, command));
+ error = trans_force_read(trans, size);
+ if (error == 0)
+ {
+ error = scard_process_msg(g_con, s, command);
+ }
return error;
}
@@ -220,7 +636,7 @@ my_pcsc_trans_data_in(struct trans *trans)
int DEFAULT_CC
my_pcsc_trans_conn_in(struct trans *trans, struct trans *new_trans)
{
- log_debug("my_pcsc_trans_conn_in:");
+ LLOGLN(0, ("my_pcsc_trans_conn_in:"));
if (trans == 0)
{
@@ -239,11 +655,13 @@ my_pcsc_trans_conn_in(struct trans *trans, struct trans *new_trans)
g_con = new_trans;
g_con->trans_data_in = my_pcsc_trans_data_in;
+#if 1
+ g_con->header_size = 8;
+#else
g_con->header_size = RXSHAREDSEGMENT_BYTES;
-
- log_debug("my_pcsc_trans_conn_in: sizeof sharedSegmentMsg is %d",
- sizeof(sharedSegmentMsg));
-
+ LLOGLN(0, ("my_pcsc_trans_conn_in: sizeof sharedSegmentMsg is %d",
+ sizeof(sharedSegmentMsg)));
+#endif
return 0;
}
@@ -252,33 +670,40 @@ int APP_CC
scard_pcsc_init(void)
{
char port[256];
+ char *home;
+ int disp;
int error;
+ int index;
- log_debug("scard_pcsc_init:");
-
+ LLOGLN(0, ("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))
+
+ //g_snprintf(g_pcsclite_ipc_dir, 255, "/tmp/.xrdp/pcsc%d", g_display_num);
+ home = g_getenv("HOME");
+ disp = g_display_num;
+ g_snprintf(g_pcsclite_ipc_dir, 255, "%s/.pcsc%d", home, disp);
+
+ if (g_directory_exist(g_pcsclite_ipc_dir))
{
- if (g_remove_dir(g_pcsc_directory) != 0)
+ if (g_remove_dir(g_pcsclite_ipc_dir) != 0)
{
- log_error("scard_pcsc_init: g_remove_dir failed");
+ LLOGLN(0, ("scard_pcsc_init: g_remove_dir failed"));
}
}
- if (g_create_dir(g_pcsc_directory) != 0)
+ if (!g_create_dir(g_pcsclite_ipc_dir))
{
- log_error("scard_pcsc_init: g_create_dir failed");
+ LLOGLN(0, ("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_chmod_hex(g_pcsclite_ipc_dir, 0x1777);
+ g_snprintf(port, 255, "%s/pcscd.comm", g_pcsclite_ipc_dir);
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);
+ LLOGLN(0, ("scard_pcsc_init: trans_listen failed for port %s",
+ port));
return 1;
}
}
@@ -289,17 +714,20 @@ scard_pcsc_init(void)
int APP_CC
scard_pcsc_deinit(void)
{
- log_debug("scard_pcsc_deinit:");
-
+ LLOGLN(0, ("scard_pcsc_deinit:"));
if (g_lis != 0)
{
trans_delete(g_lis);
g_lis = 0;
- if (g_remove_dir(g_pcsc_directory) != 0)
+
+ g_file_close(g_pub_file_fd);
+ g_pub_file_fd = 0;
+
+ if (g_remove_dir(g_pcsclite_ipc_dir) != 0)
{
- log_error("scard_pcsc_deinit: g_remove_dir failed");
+ LLOGLN(0, ("scard_pcsc_deinit: g_remove_dir failed"));
}
- g_pcsc_directory[0] = 0;
+ g_pcsclite_ipc_dir[0] = 0;
}
return 0;
}
diff --git a/sesman/chansrv/smartcard_pcsc.h b/sesman/chansrv/smartcard_pcsc.h
index a97a70d3..94effea9 100644
--- a/sesman/chansrv/smartcard_pcsc.h
+++ b/sesman/chansrv/smartcard_pcsc.h
@@ -24,13 +24,25 @@
#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);
+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);
+int APP_CC scard_function_establish_context_return(struct trans *con,
+ struct stream *in_s,
+ int len);
+int APP_CC scard_function_release_context_return(struct trans *con,
+ struct stream *in_s,
+ int len);
+int APP_CC scard_function_list_readers_return(struct trans *con,
+ struct stream *in_s,
+ int len);
+
+int APP_CC scard_function_get_status_change_return(struct trans *con,
+ struct stream *in_s,
+ int len);
+int APP_CC scard_function_connect_return(struct trans *con,
+ struct stream *in_s,
+ int len);
#endif /* end #ifndef _SMARTCARD_PCSC_H */
diff --git a/sesman/chansrv/sound.c b/sesman/chansrv/sound.c
index 9ee3c8c3..2e85f1f2 100644
--- a/sesman/chansrv/sound.c
+++ b/sesman/chansrv/sound.c
@@ -551,7 +551,8 @@ sound_init(void)
LOG(0, ("sound_init:"));
sound_send_server_formats();
- g_audio_l_trans = trans_create(2, 128 * 1024, 8192);
+ g_audio_l_trans = trans_create(TRANS_MODE_UNIX, 128 * 1024, 8192);
+ g_audio_l_trans->is_term = g_is_term;
g_snprintf(port, 255, CHANSRV_PORT_STR, g_display_num);
g_audio_l_trans->trans_conn_in = sound_trans_audio_conn_in;
error = trans_listen(g_audio_l_trans, port);
diff --git a/sesman/chansrv/xcommon.c b/sesman/chansrv/xcommon.c
index 9884040f..919bc41b 100644
--- a/sesman/chansrv/xcommon.c
+++ b/sesman/chansrv/xcommon.c
@@ -25,8 +25,10 @@
#include "clipboard.h"
#include "rail.h"
+/*
#undef LOG_LEVEL
#define LOG_LEVEL 11
+*/
extern int g_clip_up; /* in clipboard.c */
diff --git a/sesman/config.c b/sesman/config.c
index c7c3de24..877a949c 100644
--- a/sesman/config.c
+++ b/sesman/config.c
@@ -130,7 +130,7 @@ config_read_globals(int file, struct config_sesman *cf, struct list *param_n,
}
else if (0 == g_strcasecmp(buf, SESMAN_CFG_ENABLE_USERWM))
{
- cf->enable_user_wm = text2bool((char *)list_get_item(param_v, i));
+ cf->enable_user_wm = g_text2bool((char *)list_get_item(param_v, i));
}
else if (0 == g_strcasecmp(buf, SESMAN_CFG_PORT))
{
@@ -212,7 +212,7 @@ config_read_logging(int file, struct log_config* lc, struct list* param_n,
}
if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_ENABLE_SYSLOG))
{
- lc->enable_syslog = text2bool((char*)list_get_item(param_v, i));
+ lc->enable_syslog = g_text2bool((char*)list_get_item(param_v, i));
}
if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_SYSLOG_LEVEL))
{
@@ -261,7 +261,7 @@ config_read_security(int file, struct config_security *sc,
if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_ALLOW_ROOT))
{
- sc->allow_root = text2bool((char *)list_get_item(param_v, i));
+ sc->allow_root = g_text2bool((char *)list_get_item(param_v, i));
}
if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_LOGIN_RETRY))
@@ -288,7 +288,7 @@ config_read_security(int file, struct config_security *sc,
}
if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_ALWAYSGROUPCHECK))
{
- sc->ts_always_group_check = text2bool((char *)list_get_item(param_v, i));
+ sc->ts_always_group_check = g_text2bool((char *)list_get_item(param_v, i));
}
}
@@ -355,7 +355,7 @@ config_read_sessions(int file, struct config_sessions *se, struct list *param_n,
if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_KILL_DISC))
{
- se->kill_disconnected = text2bool((char *)list_get_item(param_v, i));
+ se->kill_disconnected = g_text2bool((char *)list_get_item(param_v, i));
}
if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_IDLE_LIMIT))
diff --git a/sesman/sesman.ini b/sesman/sesman.ini
index 571e063b..02fef5ba 100644
--- a/sesman/sesman.ini
+++ b/sesman/sesman.ini
@@ -17,8 +17,13 @@ AlwaysGroupCheck = false
[Sessions]
X11DisplayOffset=10
MaxSessions=10
+# if 1, true, or yes, kill session after 60 seconds
KillDisconnected=0
+# if not zero, the seconds without mouse or keyboard input before disconnect
+# not complete yet
IdleTimeLimit=0
+# if not zero, the seconds before a disconnected session is killed
+# min 60 seconds
DisconnectedTimeLimit=0
[Logging]
diff --git a/sesman/session.c b/sesman/session.c
index 888604da..c21ecb6a 100644
--- a/sesman/session.c
+++ b/sesman/session.c
@@ -559,6 +559,13 @@ session_start_fork(int width, int height, int bpp, char *username,
env_set_user(username, passwd_file, display);
env_check_password_file(passwd_file, password);
+ g_snprintf(text, 255, "%d", g_cfg->sess.max_idle_time);
+ g_setenv("XRDP_SESMAN_MAX_IDLE_TIME", text, 1);
+ g_snprintf(text, 255, "%d", g_cfg->sess.max_disc_time);
+ g_setenv("XRDP_SESMAN_MAX_DISC_TIME", text, 1);
+ g_snprintf(text, 255, "%d", g_cfg->sess.kill_disconnected);
+ g_setenv("XRDP_SESMAN_KILL_DISCONNECTED", text, 1);
+
if (type == SESMAN_SESSION_TYPE_XVNC)
{
xserver_params = list_create();
diff --git a/tcutils/README.txt b/tcutils/README.txt
new file mode 100644
index 00000000..de75f1b2
--- /dev/null
+++ b/tcutils/README.txt
@@ -0,0 +1,29 @@
+A QT based utility program for thinclients using xrdp and NeutrinoRDP
+
+This program sends commands to NeutrinoRDP to do something
+useful on the client end (such as unmounting a USB drive,
+or powering down the client)
+
+Required packages to build tcutils:
+-----------------------------------
+libqt4-gui
+qt4-dev-tools
+
+to build tcutils:
+-----------------
+qmake
+make
+
+To run tcutils:
+---------------
+include xrdpapi/.libs in your LD_LIBRARY_PATH
+
+Example:
+--------
+export LD_LIBRARY_PATH=../xrdpapi/.libs
+run tcutils inside the xfreerdp session
+
+this is how we run xfreerdp:
+----------------------------
+./xfreerdp --sec rdp --plugin tcutils 192.168.2.149
+
diff --git a/tcutils/main.cpp b/tcutils/main.cpp
new file mode 100644
index 00000000..d951345f
--- /dev/null
+++ b/tcutils/main.cpp
@@ -0,0 +1,11 @@
+#include <QtGui/QApplication>
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+
+ return a.exec();
+}
diff --git a/tcutils/mainwindow.cpp b/tcutils/mainwindow.cpp
new file mode 100644
index 00000000..8cc0a988
--- /dev/null
+++ b/tcutils/mainwindow.cpp
@@ -0,0 +1,234 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::MainWindow)
+{
+ ui->setupUi(this);
+
+ wtsChannel = NULL;
+ okToQuit = false;
+ savedGeometry = this->geometry();
+
+ /* setup tab to unmount drives */
+ ui->tabWidget->setTabText(0, "Unmount drives");
+ connect(ui->btnRefresh, SIGNAL(clicked()), this, SLOT(onBtnRefreshClicked()));
+ connect(ui->btnUnmount, SIGNAL(clicked()), this, SLOT(onBtnUnmountClicked()));
+
+ ui->tabWidget->setTabText(1, "");
+ if (initWtsChannel())
+ {
+ okToQuit = true;
+ QTimer::singleShot(10, qApp, SLOT(quit()));
+ return;
+ }
+ setupSystemTray();
+
+ /* set up status bar to display messages */
+ statusBar = new QStatusBar;
+ this->setStatusBar(statusBar);
+ setStatusMsg("Connected to client");
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+void MainWindow::setupSystemTray()
+{
+ trayMenu = new QMenu(this);
+ trayMenu->addAction("Launch Thinclient Utils", this, SLOT(onActionLaunch()));
+ trayMenu->addSeparator();
+ trayMenu->addAction("Quit", this, SLOT(onActionQuit()));
+
+ trayIcon = new QSystemTrayIcon;
+ trayIcon->setContextMenu(trayMenu);
+ trayIcon->setIcon(QIcon(":/images/resources/images/tools.gif"));
+
+ trayIcon->show();
+
+ trayIcon->showMessage("TCutils", "Click on the tcutils icon to launch tcutils",
+ QSystemTrayIcon::Information, 3000);
+
+ connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
+ this, SLOT(onSystemTrayClicked(QSystemTrayIcon::ActivationReason)));
+}
+
+/**
+ *
+ *****************************************************************************/
+
+int MainWindow::initWtsChannel()
+{
+ /* init the channel just once */
+ if (wtsChannel)
+ return 0;
+
+ /* open a WTS channel and connect to remote client */
+ wtsChannel = WTSVirtualChannelOpenEx(WTS_CURRENT_SESSION, "tcutils", 0);
+ if (wtsChannel == NULL)
+ {
+ QMessageBox::information(this, "Open virtual channel", "Error "
+ "connecting to remote client. This program "
+ "can only be used when connected via "
+ "NeutrinoRDP.\n\nClick ok to close this "
+ "application");
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+ *
+ *****************************************************************************/
+
+int MainWindow::deinitWtsChannel()
+{
+ if (!wtsChannel)
+ return -1;
+
+ WTSVirtualChannelClose(wtsChannel);
+ return 0;
+}
+
+/**
+ * Display a msg on the status bar
+ *
+ * @param msg message to display in status bar
+ *****************************************************************************/
+
+void MainWindow::setStatusMsg(QString msg)
+{
+ statusBar->showMessage(msg, 30000);
+}
+
+/**
+ *
+ *****************************************************************************/
+
+void MainWindow::closeEvent(QCloseEvent *event)
+{
+ if (!okToQuit)
+ {
+ savedGeometry = this->geometry();
+ this->hide();
+ event->ignore();
+ return;
+ }
+
+ if (wtsChannel)
+ deinitWtsChannel();
+
+ event->accept();
+}
+
+/******************************************************************************
+** **
+** slots go here **
+** **
+******************************************************************************/
+#if 1
+void MainWindow::onBtnRefreshClicked()
+{
+ int i;
+
+ /* clear drive list */
+ if (itemList.count())
+ {
+ for (i = 0; i < itemList.count(); i++)
+ ui->listWidget->removeItemWidget(itemList.at(i));
+
+ itemList.clear();
+ }
+ ui->listWidget->clear();
+
+ if (Utils::getMountList(wtsChannel, &itemList))
+ {
+ QMessageBox::information(this, "Get device list", "\nError getting "
+ "device list from client");
+ return;
+ }
+
+ if (itemList.count() == 0)
+ {
+ QMessageBox::information(this, "Get device list",
+ "\nNo devices found!");
+ return;
+ }
+
+ /* add mount point to list widget */
+ for (i = 0; i < itemList.count(); i++)
+ ui->listWidget->insertItem(i, itemList.at(i));
+}
+#else
+void MainWindow::onBtnRefreshClicked()
+{
+ QListWidgetItem *item;
+ int i;
+ int j;
+
+ /* clear drive list */
+ if (itemList.count())
+ {
+ for (i = 0; i < itemList.count(); i++)
+ ui->listWidget->removeItemWidget(itemList.at(i));
+
+ itemList.clear();
+ }
+ ui->listWidget->clear();
+
+ QDir dir(QDir::homePath() + "/xrdp_client");
+ QStringList sl = dir.entryList();
+
+ for (i = 0, j = 0; i < sl.count(); i++)
+ {
+ /* skip files starting with . */
+ if (sl.at(i).startsWith("."))
+ continue;
+
+ /* add mount point to list widget */
+ item = new QListWidgetItem;
+ item->setText(sl.at(i));
+ ui->listWidget->insertItem(j++, item);
+ itemList.append(item);
+ }
+}
+#endif
+
+void MainWindow::onBtnUnmountClicked()
+{
+ QListWidgetItem *item = ui->listWidget->currentItem();
+
+ if (!item)
+ {
+ QMessageBox::information(this, "Unmount device", "\nNo device selected. "
+ "You must select a device to unmount");
+ return;
+ }
+
+ if (Utils::unmountDevice(wtsChannel, item->text(), statusBar) == 0)
+ {
+ delete ui->listWidget->takeItem(itemList.indexOf(item));
+ itemList.removeOne(item);
+ }
+}
+
+void MainWindow::onActionQuit()
+{
+ okToQuit = true;
+ this->close();
+}
+
+void MainWindow::onActionLaunch()
+{
+ this->show();
+ this->setGeometry(savedGeometry);
+}
+
+void MainWindow::onSystemTrayClicked(QSystemTrayIcon::ActivationReason)
+{
+ trayMenu->popup(QCursor::pos());
+}
diff --git a/tcutils/mainwindow.h b/tcutils/mainwindow.h
new file mode 100644
index 00000000..1639522f
--- /dev/null
+++ b/tcutils/mainwindow.h
@@ -0,0 +1,57 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <xrdpapi.h>
+#include <QSystemTrayIcon>
+#include <QMenu>
+#include <QCloseEvent>
+#include <QFileDialog>
+#include <QDir>
+#include <QListWidgetItem>
+#include <QList>
+#include <QMessageBox>
+#include <QTimer>
+#include <QStatusBar>
+//#include <QDebug>
+
+#include "utils.h"
+
+namespace Ui {
+class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+private:
+ Ui::MainWindow *ui;
+ void *wtsChannel;
+ QSystemTrayIcon *trayIcon;
+ QMenu *trayMenu;
+ bool okToQuit;
+ QRect savedGeometry;
+ QStatusBar *statusBar;
+
+ QList<QListWidgetItem *> itemList;
+
+ void setupSystemTray();
+ int initWtsChannel();
+ int deinitWtsChannel();
+ void setStatusMsg(QString msg);
+ void closeEvent(QCloseEvent * event);
+
+private slots:
+ void onBtnRefreshClicked();
+ void onBtnUnmountClicked();
+ void onActionQuit();
+ void onActionLaunch();
+ void onSystemTrayClicked(QSystemTrayIcon::ActivationReason);
+};
+
+#endif // MAINWINDOW_H
diff --git a/tcutils/mainwindow.ui b/tcutils/mainwindow.ui
new file mode 100644
index 00000000..802d01a3
--- /dev/null
+++ b/tcutils/mainwindow.ui
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>541</width>
+ <height>355</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>TC Utils</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>511</width>
+ <height>291</height>
+ </rect>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tabUnmount">
+ <attribute name="title">
+ <string>Tab 1</string>
+ </attribute>
+ <widget class="QListWidget" name="listWidget">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>321</width>
+ <height>221</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="btnUnmount">
+ <property name="geometry">
+ <rect>
+ <x>350</x>
+ <y>60</y>
+ <width>141</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Unmount device</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="btnRefresh">
+ <property name="geometry">
+ <rect>
+ <x>350</x>
+ <y>10</y>
+ <width>141</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Get device list</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string>Tab 2</string>
+ </attribute>
+ </widget>
+ </widget>
+ </widget>
+ <widget class="QMenuBar" name="menuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>541</width>
+ <height>25</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QToolBar" name="mainToolBar">
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ </widget>
+ <widget class="QStatusBar" name="statusBar"/>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tcutils/moc_mainwindow.cpp b/tcutils/moc_mainwindow.cpp
new file mode 100644
index 00000000..85806598
--- /dev/null
+++ b/tcutils/moc_mainwindow.cpp
@@ -0,0 +1,104 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'mainwindow.h'
+**
+** Created: Sun Aug 25 15:11:44 2013
+** by: The Qt Meta Object Compiler version 63 (Qt 4.8.1)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "mainwindow.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'mainwindow.h' doesn't include <QObject>."
+#elif Q_MOC_OUTPUT_REVISION != 63
+#error "This file was generated using the moc from 4.8.1. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+static const uint qt_meta_data_MainWindow[] = {
+
+ // content:
+ 6, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 5, 14, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+ 0, 0, // constructors
+ 0, // flags
+ 0, // signalCount
+
+ // slots: signature, parameters, type, tag, flags
+ 12, 11, 11, 11, 0x08,
+ 34, 11, 11, 11, 0x08,
+ 56, 11, 11, 11, 0x08,
+ 71, 11, 11, 11, 0x08,
+ 88, 11, 11, 11, 0x08,
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_MainWindow[] = {
+ "MainWindow\0\0onBtnRefreshClicked()\0"
+ "onBtnUnmountClicked()\0onActionQuit()\0"
+ "onActionLaunch()\0"
+ "onSystemTrayClicked(QSystemTrayIcon::ActivationReason)\0"
+};
+
+void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+{
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ Q_ASSERT(staticMetaObject.cast(_o));
+ MainWindow *_t = static_cast<MainWindow *>(_o);
+ switch (_id) {
+ case 0: _t->onBtnRefreshClicked(); break;
+ case 1: _t->onBtnUnmountClicked(); break;
+ case 2: _t->onActionQuit(); break;
+ case 3: _t->onActionLaunch(); break;
+ case 4: _t->onSystemTrayClicked((*reinterpret_cast< QSystemTrayIcon::ActivationReason(*)>(_a[1]))); break;
+ default: ;
+ }
+ }
+}
+
+const QMetaObjectExtraData MainWindow::staticMetaObjectExtraData = {
+ 0, qt_static_metacall
+};
+
+const QMetaObject MainWindow::staticMetaObject = {
+ { &QMainWindow::staticMetaObject, qt_meta_stringdata_MainWindow,
+ qt_meta_data_MainWindow, &staticMetaObjectExtraData }
+};
+
+#ifdef Q_NO_DATA_RELOCATION
+const QMetaObject &MainWindow::getStaticMetaObject() { return staticMetaObject; }
+#endif //Q_NO_DATA_RELOCATION
+
+const QMetaObject *MainWindow::metaObject() const
+{
+ return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
+}
+
+void *MainWindow::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_MainWindow))
+ return static_cast<void*>(const_cast< MainWindow*>(this));
+ return QMainWindow::qt_metacast(_clname);
+}
+
+int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QMainWindow::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ if (_id < 5)
+ qt_static_metacall(this, _c, _id, _a);
+ _id -= 5;
+ }
+ return _id;
+}
+QT_END_MOC_NAMESPACE
diff --git a/tcutils/qrc_resources.cpp b/tcutils/qrc_resources.cpp
new file mode 100644
index 00000000..3f2366cb
--- /dev/null
+++ b/tcutils/qrc_resources.cpp
@@ -0,0 +1,1191 @@
+/****************************************************************************
+** Resource object code
+**
+** Created: Sun Aug 25 15:11:45 2013
+** by: The Resource Compiler for Qt version 4.8.1
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include <QtCore/qglobal.h>
+
+static const unsigned char qt_resource_data[] = {
+ // /home/lk/projects/jtech/nlabs_xrdp_tcutils/tcutils/resources/images/tools.gif
+ 0x0,0x0,0x45,0x65,
+ 0x47,
+ 0x49,0x46,0x38,0x39,0x61,0xab,0x0,0xb7,0x0,0xe7,0xff,0x0,0x22,0x26,0x9a,0x18,
+ 0x2a,0x95,0x24,0x29,0x8f,0x1d,0x2e,0x92,0x1d,0x32,0x71,0x23,0x33,0x64,0x15,0x37,
+ 0x6c,0x16,0x34,0x96,0x22,0x31,0x96,0x1f,0x37,0x65,0x25,0x3b,0x5a,0x28,0x35,0x93,
+ 0x1d,0x38,0x9a,0x2c,0x38,0x70,0x1f,0x39,0x95,0x24,0x3a,0x87,0x14,0x3d,0x9f,0x15,
+ 0x3e,0x99,0x2a,0x40,0x65,0x24,0x3f,0x81,0x1f,0x41,0x7d,0x21,0x42,0x6e,0x25,0x3d,
+ 0x99,0x29,0x40,0x70,0x2c,0x3e,0x7b,0x1b,0x41,0x9c,0x24,0x42,0x78,0xd,0x46,0x99,
+ 0x10,0x46,0xa0,0x29,0x40,0x97,0x1f,0x43,0x9e,0x1f,0x44,0x99,0x2b,0x40,0x9e,0x1e,
+ 0x45,0x93,0x24,0x44,0x8c,0x21,0x43,0xa6,0x1e,0x49,0x84,0x23,0x45,0xa1,0x16,0x49,
+ 0xa3,0x29,0x43,0xab,0x2a,0x48,0x77,0x22,0x49,0x8a,0x19,0x4b,0x99,0x26,0x47,0x9d,
+ 0x30,0x45,0x95,0x2b,0x49,0x7f,0x1a,0x4b,0x9f,0x1c,0x4a,0xac,0x3d,0x47,0x6f,0x28,
+ 0x48,0xa4,0x31,0x48,0x8a,0x28,0x49,0x9f,0x2e,0x4a,0x87,0x1c,0x4e,0x95,0x1d,0x4c,
+ 0xa7,0x29,0x4a,0x98,0x27,0x4e,0x79,0x1e,0x4d,0xa1,0x2a,0x4a,0xa0,0x1d,0x50,0x90,
+ 0x11,0x51,0xab,0x25,0x4f,0x84,0x37,0x4a,0x82,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22,
+ 0x4,0x2b,0x88,0x3f,0xfb,0x63,0x42,0xd3,0x69,0x96,0x1f,0x7c,0x5,0x50,0x12,0x89,
+ 0x2d,0x9a,0x37,0xe7,0xb2,0xfe,0xa4,0xe5,0x68,0xe,0x3e,0xb8,0x28,0x41,0xc8,0x2,
+ 0x4a,0x90,0xe,0x33,0xd0,0x18,0x14,0x88,0x24,0x75,0x58,0xb3,0xf5,0x21,0x12,0xdb,
+ 0x43,0x43,0x6c,0x68,0x11,0x1,0x31,0x5,0x88,0xc9,0x82,0x65,0xba,0x18,0x28,0x18,
+ 0x82,0x14,0x5c,0xc1,0x16,0xb4,0x43,0x18,0xa4,0x3e,0xb7,0x2b,0x35,0x5b,0xaa,0xc1,
+ 0xee,0xfb,0xbe,0x2a,0x9,0x82,0x5e,0x93,0x3,0x3a,0x78,0x1b,0x14,0x78,0x4,0x72,
+ 0x28,0x8c,0xc2,0x38,0x85,0xb,0x10,0x3,0x42,0x0,0xd,0x22,0x88,0x3f,0x3a,0x68,
+ 0xc2,0x49,0x84,0x83,0x31,0xdb,0x2,0x32,0x68,0x1,0x55,0xf8,0x6,0x96,0x10,0x40,
+ 0x95,0x18,0x12,0x9e,0xa0,0xa1,0x23,0x49,0x92,0x2c,0x60,0x2,0x37,0x68,0x2,0x17,
+ 0x48,0x8f,0x46,0x68,0x3,0x34,0x28,0x6,0x79,0x20,0x7,0xd4,0x9a,0x2f,0x5a,0x43,
+ 0x43,0xdc,0x29,0xaa,0xb7,0x52,0x87,0x67,0xc8,0x4,0x14,0x58,0x82,0xa4,0xb0,0x82,
+ 0x2f,0x8,0x83,0x3d,0x68,0x82,0x15,0xa0,0xc3,0xe4,0xb3,0x43,0x17,0xc4,0x43,0x3d,
+ 0x9c,0xc1,0x3e,0xbc,0x41,0xf0,0x93,0x20,0x39,0x58,0x84,0x40,0x5c,0x84,0x23,0x20,
+ 0x2,0x3d,0x98,0x83,0x36,0xc8,0x84,0x5b,0x48,0x6,0x64,0x88,0x84,0x16,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0x6f,0x12,0x74,0x84,0x55,0xd,0x85,0x95,0x52,0x59,0x6b,0x8d,0x36,0xa2,
+ 0x5b,0x29,0xcd,0x95,0xc4,0x5d,0xe7,0xeb,0xd5,0x3e,0xa5,0xee,0x14,0x36,0xb7,0x50,
+ 0x45,0xf5,0x33,0x0,0x41,0x5f,0x28,0xc1,0x3,0xd7,0x2c,0x70,0xd5,0xd9,0x45,0x19,
+ 0x95,0xd6,0x5d,0x6a,0x15,0x65,0x12,0x4e,0x16,0xb1,0x75,0x4b,0x5b,0xa2,0xb8,0x9d,
+ 0xd1,0xdb,0x6f,0x79,0x2b,0xb6,0x58,0x2f,0x5f,0x78,0x61,0x4,0x73,0x33,0xf0,0xe9,
+ 0x83,0x75,0x11,0x8e,0x35,0x44,0x77,0xa5,0x4d,0x38,0x51,0x79,0xe7,0xad,0xd7,0xde,
+ 0xa4,0x94,0xb2,0x80,0x36,0x7,0x3c,0xdd,0xf7,0xa9,0x7e,0xfd,0x15,0x75,0xa1,0x0,
+ 0x2,0x2,0x0,0x3b,
+
+};
+
+static const unsigned char qt_resource_name[] = {
+ // images
+ 0x0,0x6,
+ 0x7,0x3,0x7d,0xc3,
+ 0x0,0x69,
+ 0x0,0x6d,0x0,0x61,0x0,0x67,0x0,0x65,0x0,0x73,
+ // resources
+ 0x0,0x9,
+ 0xa,0x6c,0x78,0x43,
+ 0x0,0x72,
+ 0x0,0x65,0x0,0x73,0x0,0x6f,0x0,0x75,0x0,0x72,0x0,0x63,0x0,0x65,0x0,0x73,
+ // tools.gif
+ 0x0,0x9,
+ 0x6,0x36,0xbb,0x36,
+ 0x0,0x74,
+ 0x0,0x6f,0x0,0x6f,0x0,0x6c,0x0,0x73,0x0,0x2e,0x0,0x67,0x0,0x69,0x0,0x66,
+
+};
+
+static const unsigned char qt_resource_struct[] = {
+ // :
+ 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1,
+ // :/images
+ 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x2,
+ // :/images/resources
+ 0x0,0x0,0x0,0x12,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x3,
+ // :/images/resources/images
+ 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x4,
+ // :/images/resources/images/tools.gif
+ 0x0,0x0,0x0,0x2a,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,
+
+};
+
+QT_BEGIN_NAMESPACE
+
+extern Q_CORE_EXPORT bool qRegisterResourceData
+ (int, const unsigned char *, const unsigned char *, const unsigned char *);
+
+extern Q_CORE_EXPORT bool qUnregisterResourceData
+ (int, const unsigned char *, const unsigned char *, const unsigned char *);
+
+QT_END_NAMESPACE
+
+
+int QT_MANGLE_NAMESPACE(qInitResources_resources)()
+{
+ QT_PREPEND_NAMESPACE(qRegisterResourceData)
+ (0x01, qt_resource_struct, qt_resource_name, qt_resource_data);
+ return 1;
+}
+
+Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qInitResources_resources))
+
+int QT_MANGLE_NAMESPACE(qCleanupResources_resources)()
+{
+ QT_PREPEND_NAMESPACE(qUnregisterResourceData)
+ (0x01, qt_resource_struct, qt_resource_name, qt_resource_data);
+ return 1;
+}
+
+Q_DESTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qCleanupResources_resources))
+
diff --git a/tcutils/resources.qrc b/tcutils/resources.qrc
new file mode 100644
index 00000000..76a1f852
--- /dev/null
+++ b/tcutils/resources.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/images">
+ <file>resources/images/tools.gif</file>
+ </qresource>
+</RCC>
diff --git a/tcutils/resources/images/tools.gif b/tcutils/resources/images/tools.gif
new file mode 100644
index 00000000..c6596cc4
--- /dev/null
+++ b/tcutils/resources/images/tools.gif
Binary files differ
diff --git a/tcutils/tcutils b/tcutils/tcutils
new file mode 100755
index 00000000..73aa979a
--- /dev/null
+++ b/tcutils/tcutils
Binary files differ
diff --git a/tcutils/tcutils.pro b/tcutils/tcutils.pro
new file mode 100644
index 00000000..a24029e8
--- /dev/null
+++ b/tcutils/tcutils.pro
@@ -0,0 +1,30 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2013-08-18T13:54:44
+#
+#-------------------------------------------------
+
+QT += core gui
+
+TARGET = tcutils
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+ mainwindow.cpp \
+ utils.cpp
+
+HEADERS += mainwindow.h \
+ utils.h
+
+FORMS += mainwindow.ui
+
+# added by LK Rashinkar
+INCLUDEPATH += ../xrdpapi
+
+LIBS += -Wl,-rpath
+LIBS += -Wl,/usr/local/lib/xrdp
+LIBS += -L../xrdpapi/.libs -lxrdpapi
+
+RESOURCES += \
+ resources.qrc
diff --git a/tcutils/tcutils.pro.user b/tcutils/tcutils.pro.user
new file mode 100644
index 00000000..50311334
--- /dev/null
+++ b/tcutils/tcutils.pro.user
@@ -0,0 +1,365 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE QtCreatorProject>
+<!-- Written by Qt Creator 2.4.1, 2013-08-25T13:35:29. -->
+<qtcreator>
+ <data>
+ <variable>ProjectExplorer.Project.ActiveTarget</variable>
+ <value type="int">0</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.EditorSettings</variable>
+ <valuemap type="QVariantMap">
+ <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
+ <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
+ <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
+ <value type="QString" key="language">Cpp</value>
+ <valuemap type="QVariantMap" key="value">
+ <value type="QString" key="CurrentPreferences">CppGlobal</value>
+ </valuemap>
+ </valuemap>
+ <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
+ <value type="QString" key="language">QmlJS</value>
+ <valuemap type="QVariantMap" key="value">
+ <value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
+ </valuemap>
+ </valuemap>
+ <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
+ <value type="QByteArray" key="EditorConfiguration.Codec">System</value>
+ <value type="bool" key="EditorConfiguration.ConstrainTooltips">true</value>
+ <value type="int" key="EditorConfiguration.IndentSize">4</value>
+ <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
+ <value type="int" key="EditorConfiguration.PaddingMode">1</value>
+ <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
+ <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">2</value>
+ <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
+ <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
+ <value type="int" key="EditorConfiguration.TabSize">8</value>
+ <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
+ <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
+ <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
+ <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
+ <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
+ <value type="bool" key="EditorConfiguration.inEntireDocument">true</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.PluginSettings</variable>
+ <valuemap type="QVariantMap"/>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Target.0</variable>
+ <valuemap type="QVariantMap">
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Target.DesktopTarget</value>
+ <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
+ <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
+ <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
+ <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./usr/bin/gdb</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
+ <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+ <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+ <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.1 in PATH (System) Release</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
+ <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/lk/projects/jtech/nlabs_xrdp_tcutils/tcutils-build-desktop-Qt_4_8_1_in_PATH__System__Release</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">1</value>
+ <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
+ <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./usr/bin/gdb</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
+ <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+ <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+ <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.1 in PATH (System) Debug</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
+ <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/lk/projects/jtech/nlabs_xrdp_tcutils/tcutils-build-desktop-Qt_4_8_1_in_PATH__System__Debug</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">1</value>
+ <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
+ <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./usr/bin/gdb</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
+ <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+ <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+ <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.1 (System) Release</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
+ <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/lk/projects/jtech/nlabs_xrdp_tcutils/tcutils-build-desktop-Qt_4_8_1__System__Release</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">2</value>
+ <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.3">
+ <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./usr/bin/gdb</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
+ <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+ <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+ <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.1 (System) Debug</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
+ <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/lk/projects/jtech/nlabs_xrdp_tcutils/tcutils-build-desktop-Qt_4_8_1__System__Debug</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">2</value>
+ <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">4</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
+ <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
+ <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
+ <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
+ <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
+ <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
+ <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
+ <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
+ <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
+ <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
+ <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
+ <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
+ <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
+ <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
+ <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
+ <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
+ <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
+ <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
+ <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
+ <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
+ <value type="int">0</value>
+ <value type="int">1</value>
+ <value type="int">2</value>
+ <value type="int">3</value>
+ <value type="int">4</value>
+ <value type="int">5</value>
+ <value type="int">6</value>
+ <value type="int">7</value>
+ <value type="int">8</value>
+ <value type="int">9</value>
+ <value type="int">10</value>
+ <value type="int">11</value>
+ <value type="int">12</value>
+ <value type="int">13</value>
+ <value type="int">14</value>
+ </valuelist>
+ <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
+ <value type="int">0</value>
+ <value type="int">1</value>
+ <value type="int">2</value>
+ <value type="int">3</value>
+ <value type="int">4</value>
+ <value type="int">5</value>
+ <value type="int">6</value>
+ <value type="int">7</value>
+ <value type="int">8</value>
+ <value type="int">9</value>
+ <value type="int">10</value>
+ <value type="int">11</value>
+ <value type="int">12</value>
+ <value type="int">13</value>
+ <value type="int">14</value>
+ </valuelist>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">tcutils</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration</value>
+ <value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value>
+ <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
+ <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">tcutils.pro</value>
+ <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
+ <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
+ <valuelist type="QVariantList" key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges"/>
+ <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
+ <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
+ <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
+ <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
+ <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.TargetCount</variable>
+ <value type="int">1</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
+ <value type="QString">{9a0d9632-2baf-44e0-864a-a12692180779}</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
+ <value type="int">10</value>
+ </data>
+</qtcreator>
diff --git a/tcutils/ui_mainwindow.h b/tcutils/ui_mainwindow.h
new file mode 100644
index 00000000..4c47aefa
--- /dev/null
+++ b/tcutils/ui_mainwindow.h
@@ -0,0 +1,105 @@
+/********************************************************************************
+** Form generated from reading UI file 'mainwindow.ui'
+**
+** Created: Sun Aug 25 15:11:42 2013
+** by: Qt User Interface Compiler version 4.8.1
+**
+** WARNING! All changes made in this file will be lost when recompiling UI file!
+********************************************************************************/
+
+#ifndef UI_MAINWINDOW_H
+#define UI_MAINWINDOW_H
+
+#include <QtCore/QVariant>
+#include <QtGui/QAction>
+#include <QtGui/QApplication>
+#include <QtGui/QButtonGroup>
+#include <QtGui/QHeaderView>
+#include <QtGui/QListWidget>
+#include <QtGui/QMainWindow>
+#include <QtGui/QMenuBar>
+#include <QtGui/QPushButton>
+#include <QtGui/QStatusBar>
+#include <QtGui/QTabWidget>
+#include <QtGui/QToolBar>
+#include <QtGui/QWidget>
+
+QT_BEGIN_NAMESPACE
+
+class Ui_MainWindow
+{
+public:
+ QWidget *centralWidget;
+ QTabWidget *tabWidget;
+ QWidget *tabUnmount;
+ QListWidget *listWidget;
+ QPushButton *btnUnmount;
+ QPushButton *btnRefresh;
+ QWidget *tab_2;
+ QMenuBar *menuBar;
+ QToolBar *mainToolBar;
+ QStatusBar *statusBar;
+
+ void setupUi(QMainWindow *MainWindow)
+ {
+ if (MainWindow->objectName().isEmpty())
+ MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
+ MainWindow->resize(541, 355);
+ centralWidget = new QWidget(MainWindow);
+ centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
+ tabWidget = new QTabWidget(centralWidget);
+ tabWidget->setObjectName(QString::fromUtf8("tabWidget"));
+ tabWidget->setGeometry(QRect(0, 0, 511, 291));
+ tabUnmount = new QWidget();
+ tabUnmount->setObjectName(QString::fromUtf8("tabUnmount"));
+ listWidget = new QListWidget(tabUnmount);
+ listWidget->setObjectName(QString::fromUtf8("listWidget"));
+ listWidget->setGeometry(QRect(10, 10, 321, 221));
+ btnUnmount = new QPushButton(tabUnmount);
+ btnUnmount->setObjectName(QString::fromUtf8("btnUnmount"));
+ btnUnmount->setGeometry(QRect(350, 60, 141, 27));
+ btnRefresh = new QPushButton(tabUnmount);
+ btnRefresh->setObjectName(QString::fromUtf8("btnRefresh"));
+ btnRefresh->setGeometry(QRect(350, 10, 141, 27));
+ tabWidget->addTab(tabUnmount, QString());
+ tab_2 = new QWidget();
+ tab_2->setObjectName(QString::fromUtf8("tab_2"));
+ tabWidget->addTab(tab_2, QString());
+ MainWindow->setCentralWidget(centralWidget);
+ menuBar = new QMenuBar(MainWindow);
+ menuBar->setObjectName(QString::fromUtf8("menuBar"));
+ menuBar->setGeometry(QRect(0, 0, 541, 25));
+ MainWindow->setMenuBar(menuBar);
+ mainToolBar = new QToolBar(MainWindow);
+ mainToolBar->setObjectName(QString::fromUtf8("mainToolBar"));
+ MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar);
+ statusBar = new QStatusBar(MainWindow);
+ statusBar->setObjectName(QString::fromUtf8("statusBar"));
+ MainWindow->setStatusBar(statusBar);
+
+ retranslateUi(MainWindow);
+
+ tabWidget->setCurrentIndex(0);
+
+
+ QMetaObject::connectSlotsByName(MainWindow);
+ } // setupUi
+
+ void retranslateUi(QMainWindow *MainWindow)
+ {
+ MainWindow->setWindowTitle(QApplication::translate("MainWindow", "TC Utils", 0, QApplication::UnicodeUTF8));
+ btnUnmount->setText(QApplication::translate("MainWindow", "Unmount device", 0, QApplication::UnicodeUTF8));
+ btnRefresh->setText(QApplication::translate("MainWindow", "Get device list", 0, QApplication::UnicodeUTF8));
+ tabWidget->setTabText(tabWidget->indexOf(tabUnmount), QApplication::translate("MainWindow", "Tab 1", 0, QApplication::UnicodeUTF8));
+ tabWidget->setTabText(tabWidget->indexOf(tab_2), QApplication::translate("MainWindow", "Tab 2", 0, QApplication::UnicodeUTF8));
+ } // retranslateUi
+
+};
+
+namespace Ui {
+ class MainWindow: public Ui_MainWindow {};
+} // namespace Ui
+
+QT_END_NAMESPACE
+
+#endif // UI_MAINWINDOW_H
diff --git a/tcutils/utils.cpp b/tcutils/utils.cpp
new file mode 100644
index 00000000..1b8548c7
--- /dev/null
+++ b/tcutils/utils.cpp
@@ -0,0 +1,217 @@
+#include "utils.h"
+
+Utils::Utils()
+{
+}
+
+int Utils::getMountList(void *wtsChannel, QList<QListWidgetItem *> *itemList)
+{
+ QListWidgetItem *item;
+
+ STREAM s;
+ quint32 bytesToSend;
+ quint32 bytesWritten;
+ quint32 bytesRead;
+ quint32 cmdLen;
+ quint32 cmd;
+ int rv;
+ int i;
+ int nentries;
+ char buf[2048];
+
+ if (!wtsChannel)
+ return -1;
+
+ qstream_new(s, 1024 * 8);
+
+ /*
+ * command format:
+ * 4 bytes cmd_len length of this command
+ * 1 byte cmd TCU_CMD_GET_MOUNT_LIST
+ */
+
+ /* setup command */
+ qstream_wr_u32(&s, 1);
+ qstream_wr_u8(&s, TCU_CMD_GET_MOUNT_LIST);
+ bytesToSend = 5;
+
+ /* send command */
+ rv = WTSVirtualChannelWrite(wtsChannel, s.data, bytesToSend, &bytesWritten);
+ if (rv)
+ {
+ QMessageBox::information(NULL, "Get device list", "\nError sending "
+ "command to client");
+ return -1;
+ }
+
+ qstream_set_pos(&s, 0); /* reuse stream */
+
+ /* get response */
+
+ /*
+ * response format
+ * 4 bytes cmd_len length of this command
+ * 4 bytes cmd TCU_CMD_GET_MOUNT_LIST
+ * 1 byte nentries number of entries in this pkt
+ * n bytes entry_list nentries null terminated strings
+ */
+
+ rv = WTSVirtualChannelRead(wtsChannel, 1000 * 5, s.data, 1024 * 8, &bytesRead);
+ if (rv == 0 || bytesRead == 0)
+ goto error;
+
+ /* did we get the entire cmd? */
+ qstream_rd_u32(&s, cmdLen);
+ if (cmdLen != bytesRead - 4)
+ goto error;
+
+ /* did we get the right response? */
+ qstream_rd_u32(&s, cmd);
+ if (cmd != TCU_CMD_GET_MOUNT_LIST)
+ goto error;
+
+ qstream_rd_u8(&s, nentries);
+ if (nentries == 0)
+ goto done;
+
+ for (i = 0; i < nentries; i++)
+ {
+ strcpy(buf, s.pos);
+ qstream_inc_pos(&s, strlen(buf) + 1);
+ item = new QListWidgetItem;
+ item->setText(QString(buf));
+ itemList->append(item);
+ }
+
+done:
+ qstream_free(&s);
+ return 0;
+
+error:
+ qstream_free(&s);
+ return -1;
+}
+
+int Utils::unmountDevice(void *wtsChannel, QString device, QStatusBar *statusBar)
+{
+ STREAM s;
+ quint32 bytesRead;
+ quint32 cmdLen;
+ quint32 cmd;
+ quint32 bytesWritten;
+ int bytesToSend;
+ int rv;
+ int seconds = 0;
+ char status;
+ char* buf;
+
+ if (!wtsChannel)
+ return -1;
+
+ qstream_new(s, 1024);
+ buf = device.toAscii().data();
+
+ /*
+ * command format:
+ * 4 bytes cmd_len length of this command
+ * 4 bytes cmd TCU_CMD_UNMOUNT_DEVICE
+ * n bytes device null terminated device name
+ */
+
+ /* setup command */
+ bytesToSend = 4 + 4 + device.count() + 1;
+ qstream_wr_u32(&s, bytesToSend - 4);
+ qstream_wr_u32(&s, TCU_CMD_UNMOUNT_DEVICE);
+ strcpy(s.pos, buf);
+
+ /* send command */
+ rv = WTSVirtualChannelWrite(wtsChannel, s.data, bytesToSend, &bytesWritten);
+ if (rv)
+ {
+ QMessageBox::information(NULL, "Unmount device", "\nError sending "
+ "command to client");
+ return -1;
+ }
+
+ qstream_set_pos(&s, 0); /* reuse stream */
+
+ /* get response */
+
+ /*
+ * command format
+ * 4 bytes cmd_len number of bytes in this pkt
+ * 4 bytes cmd TCU_CMD_UNMOUNT_DEVICE
+ * 1 byte status operation status code
+ */
+
+ while (1)
+ {
+ rv = WTSVirtualChannelRead(wtsChannel, 1000 * 1, s.data, 1024, &bytesRead);
+ if (rv == 0)
+ goto error;
+
+ if (bytesRead)
+ break;
+
+ statusBar->showMessage("Waiting for client to unmount device: " +
+ QString::number(++seconds) + " seconds", 30000);
+ }
+
+ statusBar->showMessage("");
+
+ /* did we get the entire pkt? */
+ qstream_rd_u32(&s, cmdLen);
+ if (cmdLen != bytesRead - 4)
+ goto error;
+
+ /* did we get the right response? */
+ qstream_rd_u32(&s, cmd);
+ if (cmd != TCU_CMD_UNMOUNT_DEVICE)
+ goto error;
+
+ /* get status */
+ qstream_rd_u8(&s, status);
+ switch(status)
+ {
+ case UMOUNT_SUCCESS:
+ goto done;
+ break;
+
+ case UMOUNT_BUSY:
+ QMessageBox::information(NULL, "Unmount error", "\nCannot unmount device "
+ "because it is in use");
+ break;
+
+ case UMOUNT_NOT_MOUNTED:
+ QMessageBox::information(NULL, "Unmount error", "\nCannot unmount device "
+ "because it is not mounted");
+ break;
+
+ case UMOUNT_OP_NOT_PERMITTED:
+ QMessageBox::information(NULL, "Unmount error", "\nOperation not "
+ "permitted. The device may be in use");
+ break;
+
+ case UMOUNT_PERMISSION_DENIED:
+ QMessageBox::information(NULL, "Unmount error", "\nYou don't have "
+ "permission to unmount this device");
+ break;
+
+ case UMOUNT_UNKNOWN:
+ QMessageBox::information(NULL, "Unmount error", "Cannot unmount "
+ "device, an unknown error has occurred. The "
+ "drive may be in use or you do not have "
+ "permission to unmount it");
+ break;
+ }
+
+ goto error;
+
+done:
+ qstream_free(&s);
+ return 0;
+
+error:
+ qstream_free(&s);
+ return -1;
+}
diff --git a/tcutils/utils.h b/tcutils/utils.h
new file mode 100644
index 00000000..f0512dc0
--- /dev/null
+++ b/tcutils/utils.h
@@ -0,0 +1,150 @@
+#ifndef UTILS_H
+#define UTILS_H
+
+#include <QDebug>
+#include <QListWidgetItem>
+#include <QMessageBox>
+#include <QStatusBar>
+#include <xrdpapi.h>
+
+/*
+ * stream definition and macros to access them;
+ * all definitions default to little endian
+ */
+
+typedef struct stream
+{
+ char* data; /* holds stream data */
+ char* pos; /* current read/write position */
+ int size; /* number of bytes in data */
+} STREAM;
+
+#define qstream_new(_s, _size) \
+do \
+{ \
+ (_s).data = (char *) malloc(_size); \
+ (_s).pos = (_s).data; \
+ (_s).size = (_size); \
+} \
+while (0)
+
+#define qstream_new_zero(_s, _size) \
+do \
+{ \
+ (_s).data = (char *) calloc((_size), 1); \
+ (_s).pos = (_s).data; \
+ (_s).size = (_size); \
+} \
+while (0)
+
+#define qstream_free(_s) \
+do \
+{ \
+ if ((_s)->data) \
+ free((_s)->data); \
+} \
+while (0)
+
+#define qstream_set_pos(_s, _p) \
+do \
+{ \
+ (_s)->pos = (_s)->data + (_p); \
+} \
+while (0)
+
+#define qstream_inc_pos(_s, _v) \
+do \
+{ \
+ (_s)->pos += (_v); \
+} \
+while (0)
+
+#define qstream_rd_u8(_s, _v) \
+do \
+{ \
+ (_v) = *((unsigned char *) ((_s)->pos)); \
+ (_s)->pos++; \
+} \
+while (0)
+
+#define qstream_rd_u16(_s, _v) \
+do \
+{ \
+ (_v) = (unsigned short) \
+ ( \
+ (*((unsigned char *) ((_s)->pos + 0)) << 0) | \
+ (*((unsigned char *) ((_s)->pos + 1)) << 8) \
+ ); \
+ (_s)->pos += 2; \
+} while (0)
+
+#define qstream_rd_u32(_s, _v) \
+do \
+{ \
+ (_v) = (unsigned int) \
+ ( \
+ (*((unsigned char *) ((_s)->pos + 0)) << 0) | \
+ (*((unsigned char *) ((_s)->pos + 1)) << 8) | \
+ (*((unsigned char *) ((_s)->pos + 2)) << 16) | \
+ (*((unsigned char *) ((_s)->pos + 3)) << 24) \
+ ); \
+ (_s)->pos += 4; \
+} while (0)
+
+#define qstream_wr_u8(_s, _v) \
+do \
+{ \
+ *((_s)->pos) = (unsigned char) (_v); \
+ (_s)->pos++; \
+} while (0)
+
+#define qstream_wr_u16(_s, _v) \
+do \
+{ \
+ *((_s)->pos) = (unsigned char) ((_v) >> 0); \
+ (_s)->pos++; \
+ *((_s)->pos) = (unsigned char) ((_v) >> 8); \
+ (_s)->pos++; \
+} while (0)
+
+#define qstream_wr_u32(_s, _v) \
+do \
+{ \
+ *((_s)->pos) = (unsigned char) ((_v) >> 0); \
+ (_s)->pos++; \
+ *((_s)->pos) = (unsigned char) ((_v) >> 8); \
+ (_s)->pos++; \
+ *((_s)->pos) = (unsigned char) ((_v) >> 16); \
+ (_s)->pos++; \
+ *((_s)->pos) = (unsigned char) ((_v) >> 24); \
+ (_s)->pos++; \
+} while (0)
+
+/* list of commands we support; this list should match the one in */
+/* NeutrinoRDP channels/tcutils/tcutils_main.h */
+enum TCU_COMMANDS
+{
+ TCU_CMD_GET_MOUNT_LIST = 1,
+ TCU_CMD_UNMOUNT_DEVICE
+};
+
+/* umount error codes */
+enum TCU_UMOUNT_ERROR
+{
+ UMOUNT_SUCCESS = 0,
+ UMOUNT_BUSY,
+ UMOUNT_NOT_MOUNTED,
+ UMOUNT_OP_NOT_PERMITTED,
+ UMOUNT_PERMISSION_DENIED,
+ UMOUNT_UNKNOWN
+};
+
+class Utils
+{
+public:
+ Utils();
+ static int getMountList(void *wtsChannel, QList<QListWidgetItem *> *itemList);
+ static int unmountDevice(void *wtsChannel, QString device, QStatusBar *statusBar);
+};
+
+#endif // UTILS_H
diff --git a/tests/memtest/libmem.c b/tests/memtest/libmem.c
index 2fa0dea7..f05ea481 100644
--- a/tests/memtest/libmem.c
+++ b/tests/memtest/libmem.c
@@ -402,3 +402,13 @@ libmem_clear_flags(void* obj, int flags)
self->flags &= ~flags;
return 0;
}
+
+/*****************************************************************************/
+int
+libmem_get_alloced_bytes(void* obj)
+{
+ struct mem_info* self;
+
+ self = (struct mem_info*)obj;
+ return self->total_bytes;
+}
diff --git a/tests/memtest/libmem.h b/tests/memtest/libmem.h
index 4bc4b1ec..cd000443 100644
--- a/tests/memtest/libmem.h
+++ b/tests/memtest/libmem.h
@@ -14,5 +14,7 @@ int
libmem_set_flags(void* obj, int flags);
int
libmem_clear_flags(void* obj, int flags);
+int
+libmem_get_alloced_bytes(void* obj);
#endif
diff --git a/xorg/X11R7.6/rdp/rdp.h b/xorg/X11R7.6/rdp/rdp.h
index 72440af9..63c7436a 100644
--- a/xorg/X11R7.6/rdp/rdp.h
+++ b/xorg/X11R7.6/rdp/rdp.h
@@ -120,6 +120,10 @@ struct image_data
int Bpp;
int lineBytes;
char* pixels;
+ char* shmem_pixels;
+ int shmem_id;
+ int shmem_offset;
+ int shmem_lineBytes;
};
/* Per-screen (framebuffer) structure. There is only one of these, since we
@@ -297,6 +301,10 @@ struct _rdpPixmapRec
then we force remote the pixmap */
int use_count;
int kind_width;
+ /* number of times used in a remote operation
+ if this gets above XRDP_USE_COUNT_THRESHOLD
+ then we force remote the pixmap */
+ int use_count;
struct rdp_draw_item* draw_item_head;
struct rdp_draw_item* draw_item_tail;
};
@@ -507,6 +515,8 @@ int
rdpup_add_os_bitmap(PixmapPtr pixmap, rdpPixmapPtr priv);
int
rdpup_remove_os_bitmap(int rdpindex);
+int
+rdpup_update_os_use(int rdpindex);
void
rdpup_get_screen_image_rect(struct image_data* id);
void
diff --git a/xorg/X11R7.6/rdp/rdpCopyArea.c b/xorg/X11R7.6/rdp/rdpCopyArea.c
index beac8b24..4718a89c 100644
--- a/xorg/X11R7.6/rdp/rdpCopyArea.c
+++ b/xorg/X11R7.6/rdp/rdpCopyArea.c
@@ -429,6 +429,8 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
pSrcPixmap = (PixmapPtr)pSrc;
pSrcPriv = GETPIXPRIV(pSrcPixmap);
+ LLOGLN(10, ("rdpCopyArea: 3 %d %d", pSrcPixmap->usage_hint, pSrcPriv->is_scratch));
+
if (xrdp_is_os(pSrcPixmap, pSrcPriv))
{
if (pDst->type == DRAWABLE_WINDOW)
@@ -468,7 +470,7 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
}
else
{
- LLOGLN(10, ("rdpCopyArea: 2"));
+ LLOGLN(10, ("rdpCopyArea: 2 %d %d", pSrcPixmap->usage_hint, pSrcPriv->is_scratch));
}
}
@@ -494,10 +496,10 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpCopyArea: gettig dirty"));
+ LLOGLN(10, ("rdpCopyArea: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
- dirty_type = RDI_IMGLL;
+ dirty_type = RDI_IMGLY;
}
else
{
@@ -524,10 +526,10 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
if (g_do_dirty_ons)
{
- LLOGLN(10, ("rdpCopyArea: gettig dirty"));
+ LLOGLN(10, ("rdpCopyArea: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
- dirty_type = RDI_IMGLL;
+ dirty_type = RDI_IMGLY;
}
else
{
@@ -543,6 +545,8 @@ rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
return rv;
}
+ LLOGLN(10, ("rdpCopyArea: post_process"));
+
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, pDst, pGC);
diff --git a/xorg/X11R7.6/rdp/rdpCopyPlane.c b/xorg/X11R7.6/rdp/rdpCopyPlane.c
index bc581789..063766ee 100644
--- a/xorg/X11R7.6/rdp/rdpCopyPlane.c
+++ b/xorg/X11R7.6/rdp/rdpCopyPlane.c
@@ -111,7 +111,7 @@ rdpCopyPlane(DrawablePtr pSrc, DrawablePtr pDst,
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpCopyPlane: gettig dirty"));
+ LLOGLN(10, ("rdpCopyPlane: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
@@ -137,7 +137,7 @@ rdpCopyPlane(DrawablePtr pSrc, DrawablePtr pDst,
if (g_do_dirty_ons)
{
- LLOGLN(0, ("rdpCopyPlane: gettig dirty"));
+ LLOGLN(10, ("rdpCopyPlane: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
diff --git a/xorg/X11R7.6/rdp/rdpFillPolygon.c b/xorg/X11R7.6/rdp/rdpFillPolygon.c
index fceab93e..960f619e 100644
--- a/xorg/X11R7.6/rdp/rdpFillPolygon.c
+++ b/xorg/X11R7.6/rdp/rdpFillPolygon.c
@@ -150,7 +150,7 @@ rdpFillPolygon(DrawablePtr pDrawable, GCPtr pGC,
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpFillPolygon: gettig dirty"));
+ LLOGLN(10, ("rdpFillPolygon: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
@@ -176,7 +176,7 @@ rdpFillPolygon(DrawablePtr pDrawable, GCPtr pGC,
if (g_do_dirty_ons)
{
- LLOGLN(0, ("rdpFillPolygon: gettig dirty"));
+ LLOGLN(10, ("rdpFillPolygon: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
diff --git a/xorg/X11R7.6/rdp/rdpImageGlyphBlt.c b/xorg/X11R7.6/rdp/rdpImageGlyphBlt.c
index 2b69432d..d425a30b 100644
--- a/xorg/X11R7.6/rdp/rdpImageGlyphBlt.c
+++ b/xorg/X11R7.6/rdp/rdpImageGlyphBlt.c
@@ -108,7 +108,7 @@ rdpImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpImageGlyphBlt: gettig dirty"));
+ LLOGLN(10, ("rdpImageGlyphBlt: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
@@ -134,7 +134,7 @@ rdpImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
if (g_do_dirty_ons)
{
- LLOGLN(0, ("rdpImageGlyphBlt: gettig dirty"));
+ LLOGLN(10, ("rdpImageGlyphBlt: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
diff --git a/xorg/X11R7.6/rdp/rdpImageText16.c b/xorg/X11R7.6/rdp/rdpImageText16.c
index 5a77224b..604d85e3 100644
--- a/xorg/X11R7.6/rdp/rdpImageText16.c
+++ b/xorg/X11R7.6/rdp/rdpImageText16.c
@@ -106,7 +106,7 @@ rdpImageText16(DrawablePtr pDrawable, GCPtr pGC,
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpImageText16: gettig dirty"));
+ LLOGLN(10, ("rdpImageText16: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLY;
@@ -132,7 +132,7 @@ rdpImageText16(DrawablePtr pDrawable, GCPtr pGC,
if (g_do_dirty_ons)
{
- LLOGLN(10, ("rdpImageText16: gettig dirty"));
+ LLOGLN(10, ("rdpImageText16: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
diff --git a/xorg/X11R7.6/rdp/rdpImageText8.c b/xorg/X11R7.6/rdp/rdpImageText8.c
index c191bd75..08dead18 100644
--- a/xorg/X11R7.6/rdp/rdpImageText8.c
+++ b/xorg/X11R7.6/rdp/rdpImageText8.c
@@ -106,7 +106,7 @@ rdpImageText8(DrawablePtr pDrawable, GCPtr pGC,
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpImageText8: gettig dirty"));
+ LLOGLN(10, ("rdpImageText8: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
@@ -132,7 +132,7 @@ rdpImageText8(DrawablePtr pDrawable, GCPtr pGC,
if (g_do_dirty_ons)
{
- LLOGLN(0, ("rdpImageText8: gettig dirty"));
+ LLOGLN(10, ("rdpImageText8: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
diff --git a/xorg/X11R7.6/rdp/rdpPolyArc.c b/xorg/X11R7.6/rdp/rdpPolyArc.c
index 2d1f153e..84a85587 100644
--- a/xorg/X11R7.6/rdp/rdpPolyArc.c
+++ b/xorg/X11R7.6/rdp/rdpPolyArc.c
@@ -125,7 +125,7 @@ rdpPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs)
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpPolyArc: gettig dirty"));
+ LLOGLN(10, ("rdpPolyArc: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
@@ -151,7 +151,7 @@ rdpPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs)
if (g_do_dirty_ons)
{
- LLOGLN(0, ("rdpPolyArc: gettig dirty"));
+ LLOGLN(10, ("rdpPolyArc: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
diff --git a/xorg/X11R7.6/rdp/rdpPolyFillArc.c b/xorg/X11R7.6/rdp/rdpPolyFillArc.c
index bcbb2643..e3822215 100644
--- a/xorg/X11R7.6/rdp/rdpPolyFillArc.c
+++ b/xorg/X11R7.6/rdp/rdpPolyFillArc.c
@@ -125,7 +125,7 @@ rdpPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs)
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpPolyFillArc: gettig dirty"));
+ LLOGLN(10, ("rdpPolyFillArc: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLY;
@@ -151,7 +151,7 @@ rdpPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs)
if (g_do_dirty_ons)
{
- LLOGLN(0, ("rdpPolyFillArc: gettig dirty"));
+ LLOGLN(10, ("rdpPolyFillArc: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
diff --git a/xorg/X11R7.6/rdp/rdpPolyFillRect.c b/xorg/X11R7.6/rdp/rdpPolyFillRect.c
index f9926fc8..7db4be69 100644
--- a/xorg/X11R7.6/rdp/rdpPolyFillRect.c
+++ b/xorg/X11R7.6/rdp/rdpPolyFillRect.c
@@ -105,10 +105,11 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
if (g_do_dirty_ons)
{
- LLOGLN(10, ("rdpPolyFillRect: gettig dirty"));
+ LLOGLN(10, ("rdpPolyFillRect: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
- dirty_type = RDI_IMGLL;
+ dirty_type = (FillTiled == pGC->fillStyle) ?
+ RDI_IMGLY : RDI_IMGLL;
}
else
{
@@ -122,10 +123,11 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpPolyFillRect: gettig dirty"));
+ LLOGLN(10, ("rdpPolyFillRect: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
- dirty_type = RDI_FILL;
+ dirty_type = (FillTiled == pGC->fillStyle) ?
+ RDI_IMGLY : RDI_IMGLL;
}
else
{
@@ -148,10 +150,11 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
if (g_do_dirty_ons)
{
- LLOGLN(10, ("rdpPolyFillRect: gettig dirty"));
+ LLOGLN(10, ("rdpPolyFillRect: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
- dirty_type = RDI_IMGLL;
+ dirty_type = (FillTiled == pGC->fillStyle) ?
+ RDI_IMGLY : RDI_IMGLL;
}
else
{
@@ -192,7 +195,8 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
}
else
{
- draw_item_add_img_region(pDirtyPriv, fill_reg, GXcopy, RDI_IMGLL, TAG_POLYFILLRECT);
+ draw_item_add_img_region(pDirtyPriv, fill_reg, GXcopy,
+ dirty_type, TAG_POLYFILLRECT);
}
}
else if (got_id)
@@ -214,7 +218,8 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
for (j = REGION_NUM_RECTS(fill_reg) - 1; j >= 0; j--)
{
box = REGION_RECTS(fill_reg)[j];
- rdpup_fill_rect(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
+ rdpup_fill_rect(box.x1, box.y1,
+ box.x2 - box.x1, box.y2 - box.y1);
}
rdpup_set_opcode(GXcopy);
@@ -251,12 +256,15 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
pGC->alu == GXxor*/)) /* todo, why dosen't xor work? */
{
LLOGLN(10, ("rdpPolyFillRect: 3"));
- draw_item_add_fill_region(pDirtyPriv, &clip_reg, pGC->fgPixel,
+ draw_item_add_fill_region(pDirtyPriv, &clip_reg,
+ pGC->fgPixel,
pGC->alu);
}
else
{
- draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, RDI_IMGLL, TAG_POLYFILLRECT);
+ LLOGLN(10, ("rdpPolyFillRect: 4"));
+ draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy,
+ dirty_type, TAG_POLYFILLRECT);
}
}
else if (got_id)
@@ -280,7 +288,8 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&clip_reg)[j];
- rdpup_fill_rect(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
+ rdpup_fill_rect(box.x1, box.y1,
+ box.x2 - box.x1, box.y2 - box.y1);
}
rdpup_set_opcode(GXcopy);
@@ -290,7 +299,8 @@ rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill,
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&clip_reg)[j];
- rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
+ rdpup_send_area(&id, box.x1, box.y1,
+ box.x2 - box.x1, box.y2 - box.y1);
}
}
diff --git a/xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c b/xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c
index 97c8562e..8ce1db08 100644
--- a/xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c
+++ b/xorg/X11R7.6/rdp/rdpPolyGlyphBlt.c
@@ -108,7 +108,7 @@ rdpPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpPolyGlyphBlt: gettig dirty"));
+ LLOGLN(10, ("rdpPolyGlyphBlt: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLY;
@@ -134,7 +134,7 @@ rdpPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
if (g_do_dirty_ons)
{
- LLOGLN(0, ("rdpPolyGlyphBlt: gettig dirty"));
+ LLOGLN(10, ("rdpPolyGlyphBlt: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
diff --git a/xorg/X11R7.6/rdp/rdpPolyPoint.c b/xorg/X11R7.6/rdp/rdpPolyPoint.c
index 28db831a..e2eadafd 100644
--- a/xorg/X11R7.6/rdp/rdpPolyPoint.c
+++ b/xorg/X11R7.6/rdp/rdpPolyPoint.c
@@ -156,7 +156,7 @@ rdpPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode,
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpPolyPoint: gettig dirty"));
+ LLOGLN(10, ("rdpPolyPoint: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
@@ -182,7 +182,7 @@ rdpPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode,
if (g_do_dirty_ons)
{
- LLOGLN(0, ("rdpPolyPoint: gettig dirty"));
+ LLOGLN(10, ("rdpPolyPoint: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
diff --git a/xorg/X11R7.6/rdp/rdpPolyRectangle.c b/xorg/X11R7.6/rdp/rdpPolyRectangle.c
index 3f89000a..c1a5c971 100644
--- a/xorg/X11R7.6/rdp/rdpPolyRectangle.c
+++ b/xorg/X11R7.6/rdp/rdpPolyRectangle.c
@@ -118,7 +118,7 @@ rdpPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects,
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpPolyRectangle: gettig dirty"));
+ LLOGLN(10, ("rdpPolyRectangle: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
@@ -144,7 +144,7 @@ rdpPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects,
if (g_do_dirty_ons)
{
- LLOGLN(10, ("rdpPolyRectangle: gettig dirty"));
+ LLOGLN(10, ("rdpPolyRectangle: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
diff --git a/xorg/X11R7.6/rdp/rdpPolySegment.c b/xorg/X11R7.6/rdp/rdpPolySegment.c
index 623ec748..f4bcfe31 100644
--- a/xorg/X11R7.6/rdp/rdpPolySegment.c
+++ b/xorg/X11R7.6/rdp/rdpPolySegment.c
@@ -115,7 +115,7 @@ rdpPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSegs)
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpPolySegment: gettig dirty"));
+ LLOGLN(10, ("rdpPolySegment: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
@@ -141,7 +141,7 @@ rdpPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSegs)
if (g_do_dirty_ons)
{
- LLOGLN(10, ("rdpPolySegment: gettig dirty"));
+ LLOGLN(10, ("rdpPolySegment: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
diff --git a/xorg/X11R7.6/rdp/rdpPolyText16.c b/xorg/X11R7.6/rdp/rdpPolyText16.c
index cf8b04c4..a28030f0 100644
--- a/xorg/X11R7.6/rdp/rdpPolyText16.c
+++ b/xorg/X11R7.6/rdp/rdpPolyText16.c
@@ -109,7 +109,7 @@ rdpPolyText16(DrawablePtr pDrawable, GCPtr pGC,
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpPolyText16: gettig dirty"));
+ LLOGLN(10, ("rdpPolyText16: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLY;
@@ -135,7 +135,7 @@ rdpPolyText16(DrawablePtr pDrawable, GCPtr pGC,
if (g_do_dirty_ons)
{
- LLOGLN(0, ("rdpPolyText16: gettig dirty"));
+ LLOGLN(10, ("rdpPolyText16: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
diff --git a/xorg/X11R7.6/rdp/rdpPolyText8.c b/xorg/X11R7.6/rdp/rdpPolyText8.c
index e92f8bc8..3157a538 100644
--- a/xorg/X11R7.6/rdp/rdpPolyText8.c
+++ b/xorg/X11R7.6/rdp/rdpPolyText8.c
@@ -109,7 +109,7 @@ rdpPolyText8(DrawablePtr pDrawable, GCPtr pGC,
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpPolyText8: gettig dirty"));
+ LLOGLN(10, ("rdpPolyText8: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLY;
@@ -135,7 +135,7 @@ rdpPolyText8(DrawablePtr pDrawable, GCPtr pGC,
if (g_do_dirty_ons)
{
- LLOGLN(0, ("rdpPolyText8: gettig dirty"));
+ LLOGLN(10, ("rdpPolyText8: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
diff --git a/xorg/X11R7.6/rdp/rdpPolylines.c b/xorg/X11R7.6/rdp/rdpPolylines.c
index 759d1ff9..ba6381b8 100644
--- a/xorg/X11R7.6/rdp/rdpPolylines.c
+++ b/xorg/X11R7.6/rdp/rdpPolylines.c
@@ -166,7 +166,7 @@ rdpPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode,
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpPolylines: gettig dirty"));
+ LLOGLN(10, ("rdpPolylines: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
@@ -192,7 +192,7 @@ rdpPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode,
if (g_do_dirty_ons)
{
- LLOGLN(10, ("rdpPolylines: gettig dirty"));
+ LLOGLN(10, ("rdpPolylines: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
diff --git a/xorg/X11R7.6/rdp/rdpPushPixels.c b/xorg/X11R7.6/rdp/rdpPushPixels.c
index a07ec5eb..e7d330d1 100644
--- a/xorg/X11R7.6/rdp/rdpPushPixels.c
+++ b/xorg/X11R7.6/rdp/rdpPushPixels.c
@@ -102,7 +102,7 @@ rdpPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst,
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpPushPixels: gettig dirty"));
+ LLOGLN(10, ("rdpPushPixels: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLY;
@@ -128,7 +128,7 @@ rdpPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst,
if (g_do_dirty_ons)
{
- LLOGLN(0, ("rdpPushPixels: gettig dirty"));
+ LLOGLN(10, ("rdpPushPixels: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
diff --git a/xorg/X11R7.6/rdp/rdpPutImage.c b/xorg/X11R7.6/rdp/rdpPutImage.c
index 33fedb8a..d244d895 100644
--- a/xorg/X11R7.6/rdp/rdpPutImage.c
+++ b/xorg/X11R7.6/rdp/rdpPutImage.c
@@ -106,7 +106,7 @@ rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y,
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpPutImage: gettig dirty"));
+ LLOGLN(10, ("rdpPutImage: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLY;
@@ -132,10 +132,10 @@ rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y,
if (g_do_dirty_ons)
{
- LLOGLN(10, ("rdpPutImage: gettig dirty"));
+ LLOGLN(10, ("rdpPutImage: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
- dirty_type = RDI_IMGLL;
+ dirty_type = RDI_IMGLY;
}
else
{
diff --git a/xorg/X11R7.6/rdp/rdpSetSpans.c b/xorg/X11R7.6/rdp/rdpSetSpans.c
index 2b650e94..62dd8c5c 100644
--- a/xorg/X11R7.6/rdp/rdpSetSpans.c
+++ b/xorg/X11R7.6/rdp/rdpSetSpans.c
@@ -38,6 +38,8 @@ extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
+extern int g_do_dirty_ons; /* in rdpmain.c */
+extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
@@ -95,7 +97,7 @@ rdpSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *psrc,
if (g_do_dirty_os)
{
- LLOGLN(10, ("rdpSetSpans: gettig dirty"));
+ LLOGLN(10, ("rdpSetSpans: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLY;
@@ -118,8 +120,18 @@ rdpSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *psrc,
if (pDstWnd->viewable)
{
post_process = 1;
- rdpup_get_screen_image_rect(&id);
- got_id = 1;
+ if (g_do_dirty_ons)
+ {
+ LLOGLN(10, ("rdpSetSpans: getting dirty"));
+ g_screenPriv.is_dirty = 1;
+ pDirtyPriv = &g_screenPriv;
+ dirty_type = RDI_IMGLL;
+ }
+ else
+ {
+ rdpup_get_screen_image_rect(&id);
+ got_id = 1;
+ }
}
}
}
diff --git a/xorg/X11R7.6/rdp/rdpdraw.c b/xorg/X11R7.6/rdp/rdpdraw.c
index 9868cc62..0f31862e 100644
--- a/xorg/X11R7.6/rdp/rdpdraw.c
+++ b/xorg/X11R7.6/rdp/rdpdraw.c
@@ -489,6 +489,36 @@ draw_item_remove_all(rdpPixmapRec *priv)
}
/******************************************************************************/
+static int
+remove_empties(rdpPixmapRec* priv)
+{
+ struct rdp_draw_item* di;
+ struct rdp_draw_item* di_prev;
+ int rv;
+
+ rv = 0;
+ /* remove draw items with empty regions */
+ di = priv->draw_item_head;
+ di_prev = 0;
+ while (di != 0)
+ {
+ if (!RegionNotEmpty(di->reg))
+ {
+ LLOGLN(10, ("remove_empties: removing empty item type %d", di->type));
+ draw_item_remove(priv, di);
+ di = di_prev == 0 ? priv->draw_item_head : di_prev->next;
+ rv++;
+ }
+ else
+ {
+ di_prev = di;
+ di = di->next;
+ }
+ }
+ return rv;
+}
+
+/******************************************************************************/
int
region_get_pixel_count(RegionPtr reg)
{
@@ -634,29 +664,31 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv)
{
struct rdp_draw_item *di;
struct rdp_draw_item *di_prev;
- RegionRec treg;
BoxRec box;
+ RegionRec treg;
#if 1
- box.x1 = 0;
- box.x2 = pix->drawable.width;
- box.y1 = 0;
- box.y2 = pix->drawable.height;
- RegionInit(&treg, &box, 0);
- di = priv->draw_item_head;
- di_prev = 0;
- while (di != 0)
+ if (pix != 0)
{
- RegionIntersect(di->reg, di->reg, &treg);
- di_prev = di;
- di = di->next;
+ box.x1 = 0;
+ box.x2 = pix->drawable.width;
+ box.y1 = 0;
+ box.y2 = pix->drawable.height;
+ RegionInit(&treg, &box, 0);
+ di = priv->draw_item_head;
+ di_prev = 0;
+ while (di != 0)
+ {
+ RegionIntersect(di->reg, di->reg, &treg);
+ di_prev = di;
+ di = di->next;
+ }
+ RegionUninit(&treg);
+ remove_empties(priv);
}
- RegionUninit(&treg);
- remove_empties(priv);
#endif
-
-#if 1
+#if 1
/* look for repeating draw types */
if (priv->draw_item_head != 0)
{
@@ -767,78 +799,6 @@ draw_item_pack(PixmapPtr pix, rdpPixmapRec *priv)
}
remove_empties(priv);
#endif
-
-#if 0
- if (priv->draw_item_tail != 0)
- {
- if (priv->draw_item_tail->prev != 0)
- {
- di = priv->draw_item_tail;
- while (di->prev != 0)
- {
- di_prev = di->prev;
- while (di_prev != 0)
- {
- if ((di_prev->flags & 1) == 0)
- {
- if ((di_prev->type == RDI_IMGLY) || (di_prev->type == RDI_IMGLL))
- {
- if ((di->type == RDI_TEXT) &&
- region_interect_at_all(di->reg, di_prev->reg))
- {
- RegionSubtract(di->reg, di->reg, di_prev->reg);
- di_prev->type = RDI_IMGLL;
- }
- }
- else
- {
- if ((di->type == RDI_TEXT) &&
- region_interect_at_all(di->reg, di_prev->reg))
- {
- break;
- }
- }
- }
- di_prev = di_prev->prev;
- }
- di = di->prev;
- }
- }
- }
- remove_empties(priv);
-#endif
-
-#if 0
- /* subtract regions */
- if (priv->draw_item_tail != 0)
- {
- if (priv->draw_item_tail->prev != 0)
- {
- di = priv->draw_item_tail;
- while (di->prev != 0)
- {
- /* skip subtract flag
- * draw items like line can't be used to clear(subtract) previous
- * draw items since they are not opaque
- * eg they can not be the 'S' in 'D = M - S'
- * the region for line draw items is the clip region */
- if ((di->flags & 1) == 0)
- {
- di_prev = di->prev;
- while (di_prev != 0)
- {
- /* D = M - S */
- RegionSubtract(di_prev->reg, di_prev->reg, di->reg);
- di_prev = di_prev->prev;
- }
- }
-
- di = di->prev;
- }
- }
- }
- remove_empties(priv);
-#endif
return 0;
}
@@ -990,11 +950,9 @@ rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
pScreen->CreatePixmap = rdpCreatePixmap;
priv = GETPIXPRIV(rv);
priv->rdpindex = -1;
- priv->con_number = g_con_number;
priv->kind_width = width;
pScreen->ModifyPixmapHeader(rv, org_width, 0, 0, 0, 0, 0);
- pScreen->CreatePixmap = rdpCreatePixmap;
- if (org_width == 0 && height == 0)
+ if ((org_width == 0) && (height == 0))
{
LLOGLN(10, ("rdpCreatePixmap: setting is_scratch"));
priv->is_scratch = 1;
@@ -1020,9 +978,11 @@ rdpDestroyPixmap(PixmapPtr pPixmap)
{
if (XRDP_IS_OS(priv))
{
- rdpup_remove_os_bitmap(priv->rdpindex);
- rdpup_delete_os_surface(priv->rdpindex);
- draw_item_remove_all(priv);
+ if (priv->rdpindex >= 0)
+ {
+ rdpup_remove_os_bitmap(priv->rdpindex);
+ rdpup_delete_os_surface(priv->rdpindex);
+ }
}
}
@@ -1042,20 +1002,20 @@ xrdp_is_os(PixmapPtr pix, rdpPixmapPtr priv)
int width;
int height;
struct image_data id;
-
- if (g_wrapPixmap == 0)
+
+ if (XRDP_IS_OS(priv))
{
- return 0;
+ /* update time stamp */
+ rdpup_update_os_use(priv->rdpindex);
}
- if (priv->status == 0)
+ else
{
width = pix->drawable.width;
height = pix->drawable.height;
if ((pix->usage_hint == 0) &&
(pix->drawable.depth >= g_rdpScreen.depth) &&
- (width > 0) && (height > 0) &&
- (priv->use_count > XRDP_USE_COUNT_THRESHOLD) &&
- (priv->is_scratch == 0))
+ (width > 0) && (height > 0) && (priv->kind_width > 0) &&
+ (priv->is_scratch == 0) && (priv->use_count >= 0))
{
width = (width + 3) & ~3;
priv->rdpindex = rdpup_add_os_bitmap(pix, priv);
@@ -1069,11 +1029,19 @@ xrdp_is_os(PixmapPtr pix, rdpPixmapPtr priv)
box.y2 = height;
if (g_do_dirty_os)
{
- draw_item_remove_all(priv);
- RegionInit(&reg1, &box, 0);
- draw_item_add_img_region(priv, &reg1, GXcopy, RDI_IMGLY, 16);
- RegionUninit(&reg1);
- priv->is_dirty = 1;
+ LLOGLN(10, ("xrdp_is_os: priv->con_number %d g_con_number %d",
+ priv->con_number, g_con_number));
+ LLOGLN(10, ("xrdp_is_os: priv->use_count %d", priv->use_count));
+ if (priv->con_number != g_con_number)
+ {
+ LLOGLN(10, ("xrdp_is_os: queuing invalidating all"));
+ draw_item_remove_all(priv);
+ RegionInit(&reg1, &box, 0);
+ draw_item_add_img_region(priv, &reg1, GXcopy, RDI_IMGLY, 16);
+ RegionUninit(&reg1);
+ priv->is_dirty = 1;
+ priv->con_number = g_con_number;
+ }
}
else
{
@@ -1096,10 +1064,6 @@ xrdp_is_os(PixmapPtr pix, rdpPixmapPtr priv)
priv->use_count++;
return 0;
}
- else
- {
- LLOGLN(10, ("xrdp_is_os: ok"));
- }
priv->use_count++;
return 1;
}
@@ -1344,7 +1308,9 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
BoxRec box2;
BoxPtr box3;
- LLOGLN(10, ("in rdpCopyWindow"));
+ LLOGLN(10, ("rdpCopyWindow:"));
+ LLOGLN(10, ("rdpCopyWindow: new x %d new y %d old x %d old y %d",
+ pWin->drawable.x, pWin->drawable.y, ptOldOrg.x, ptOldOrg.y));
RegionInit(&reg, NullBox, 0);
RegionCopy(&reg, pOldRegion);
RegionInit(&clip, NullBox, 0);
@@ -1356,18 +1322,28 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
{
rdpup_check_dirty_screen(&g_screenPriv);
}
- rdpup_begin_update();
+
+ g_pScreen->CopyWindow = g_rdpScreen.CopyWindow;
+ g_pScreen->CopyWindow(pWin, ptOldOrg, pOldRegion);
+ g_pScreen->CopyWindow = rdpCopyWindow;
+
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));
+ if ((num_clip_rects == 0) || (num_reg_rects == 0))
+ {
+ return;
+ }
+ rdpup_begin_update();
+
/* 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,
+ rdpup_send_area(0, box3->x1 + dx, box3->y1 + dy,
box3->x2 - box3->x1,
box3->y2 - box3->y1);
}
@@ -1382,6 +1358,8 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
for (j = 0; j < num_clip_rects; j++)
{
box1 = REGION_RECTS(&clip)[j];
+ LLOGLN(10, ("clip x %d y %d w %d h %d", 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);
@@ -1389,6 +1367,8 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
for (i = 0; i < num_reg_rects; i++)
{
box2 = REGION_RECTS(&reg)[i];
+ LLOGLN(10, ("reg x %d y %d w %d h %d", box2.x1, box2.y1,
+ box2.x2 - box2.x1, box2.y2 - box2.y1));
rdpup_screen_blt(box2.x1 + dx, box2.y1 + dy,
box2.x2 - box2.x1,
box2.y2 - box2.y1,
@@ -1401,6 +1381,8 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
for (j = num_clip_rects - 1; j >= 0; j--)
{
box1 = REGION_RECTS(&clip)[j];
+ LLOGLN(10, ("clip x %d y %d w %d h %d", 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);
@@ -1408,6 +1390,8 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
for (i = num_reg_rects - 1; i >= 0; i--)
{
box2 = REGION_RECTS(&reg)[i];
+ LLOGLN(10, ("reg x %d y %d w %d h %d", box2.x1, box2.y1,
+ box2.x2 - box2.x1, box2.y2 - box2.y1));
rdpup_screen_blt(box2.x1 + dx, box2.y1 + dy,
box2.x2 - box2.x1,
box2.y2 - box2.y1,
@@ -1422,9 +1406,6 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
RegionUninit(&reg);
RegionUninit(&clip);
- g_pScreen->CopyWindow = g_rdpScreen.CopyWindow;
- g_pScreen->CopyWindow(pWin, ptOldOrg, pOldRegion);
- g_pScreen->CopyWindow = rdpCopyWindow;
}
/******************************************************************************/
@@ -1462,7 +1443,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, 16);
+ draw_item_add_img_region(&g_screenPriv, &reg, GXcopy, RDI_IMGLY, 16);
}
else
{
@@ -1500,7 +1481,7 @@ rdpRestoreAreas(WindowPtr pWin, RegionPtr prgnExposed)
if (g_do_dirty_ons)
{
- draw_item_add_img_region(&g_screenPriv, &reg, GXcopy, RDI_IMGLL, 16);
+ draw_item_add_img_region(&g_screenPriv, &reg, GXcopy, RDI_IMGLY, 16);
}
else
{
diff --git a/xorg/X11R7.6/rdp/rdpinput.c b/xorg/X11R7.6/rdp/rdpinput.c
index d1e4949a..c8739ba0 100644
--- a/xorg/X11R7.6/rdp/rdpinput.c
+++ b/xorg/X11R7.6/rdp/rdpinput.c
@@ -44,6 +44,12 @@ keyboard and mouse stuff
#define DEBUG_OUT_INPUT(arg) ErrorF arg
#endif
+#define LOG_LEVEL 1
+#define LLOG(_level, _args) \
+ do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
+#define LLOGLN(_level, _args) \
+ do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
+
extern ScreenPtr g_pScreen; /* in rdpmain.c */
extern DeviceIntPtr g_pointer; /* in rdpmain.c */
extern DeviceIntPtr g_keyboard; /* in rdpmain.c */
@@ -60,6 +66,12 @@ static int g_tab_down = 0;
static int g_scroll_lock_down = 0;
static OsTimerPtr g_kbtimer = 0;
+static OsTimerPtr g_timer = 0;
+static int g_x = 0;
+static int g_y = 0;
+static int g_timer_schedualed = 0;
+static int g_delay_motion = 1; /* turn on or off */
+
#define MIN_KEY_CODE 8
#define MAX_KEY_CODE 255
#define NO_OF_KEYS ((MAX_KEY_CODE - MIN_KEY_CODE) + 1)
@@ -796,12 +808,13 @@ rdpEnqueueMotion(int x, int y)
EventListPtr rdp_events;
xEvent *pev;
+ LLOGLN(10, ("rdpEnqueueMotion: x %d y %d", x, y));
# if 0
if (x < 128)
{
rdpup_begin_update();
- rdpup_send_area(0, 0, 1024, 768);
+ rdpup_send_area(0, 0, 0, 1024, 768);
rdpup_end_update();
}
@@ -831,6 +844,7 @@ rdpEnqueueButton(int type, int buttons)
EventListPtr rdp_events;
xEvent *pev;
+ LLOGLN(10, ("rdpEnqueueButton:"));
i = GetEventList(&rdp_events);
n = GetPointerEvents(rdp_events, g_pointer, type, buttons, 0, 0, 0, 0);
@@ -861,35 +875,66 @@ rdpEnqueueKey(int type, int scancode)
}
/******************************************************************************/
+static CARD32
+rdpDeferredInputCallback(OsTimerPtr timer, CARD32 now, pointer arg)
+{
+ LLOGLN(10, ("rdpDeferredInputCallback:"));
+ g_timer_schedualed = 0;
+ rdpEnqueueMotion(g_x, g_y);
+ return 0;
+}
+
+/******************************************************************************/
void
PtrAddEvent(int buttonMask, int x, int y)
{
int i;
int type;
int buttons;
+ int send_now;
- rdpEnqueueMotion(x, y);
-
- for (i = 0; i < 7; i++)
+ LLOGLN(10, ("PtrAddEvent: x %d y %d", x, y));
+ send_now = (buttonMask ^ g_old_button_mask) || (g_delay_motion == 0);
+ LLOGLN(10, ("PtrAddEvent: send_now %d g_timer_schedualed %d",
+ send_now, g_timer_schedualed));
+ if (send_now)
{
- if ((buttonMask ^ g_old_button_mask) & (1 << i))
+ if (g_timer_schedualed)
{
- if (buttonMask & (1 << i))
- {
- type = ButtonPress;
- buttons = i + 1;
- rdpEnqueueButton(type, buttons);
- }
- else
+ g_timer_schedualed = 0;
+ TimerCancel(g_timer);
+ }
+ rdpEnqueueMotion(x, y);
+ for (i = 0; i < 5; i++)
+ {
+ if ((buttonMask ^ g_old_button_mask) & (1 << i))
{
- type = ButtonRelease;
- buttons = i + 1;
- rdpEnqueueButton(type, buttons);
+ if (buttonMask & (1 << i))
+ {
+ type = ButtonPress;
+ buttons = i + 1;
+ rdpEnqueueButton(type, buttons);
+ }
+ else
+ {
+ type = ButtonRelease;
+ buttons = i + 1;
+ rdpEnqueueButton(type, buttons);
+ }
}
}
+ g_old_button_mask = buttonMask;
+ }
+ else
+ {
+ g_x = x;
+ g_y = y;
+ if (!g_timer_schedualed)
+ {
+ g_timer_schedualed = 1;
+ g_timer = TimerSet(g_timer, 0, 60, rdpDeferredInputCallback, 0);
+ }
}
-
- g_old_button_mask = buttonMask;
}
/******************************************************************************/
diff --git a/xorg/X11R7.6/rdp/rdpup.c b/xorg/X11R7.6/rdp/rdpup.c
index b4095772..28919799 100644
--- a/xorg/X11R7.6/rdp/rdpup.c
+++ b/xorg/X11R7.6/rdp/rdpup.c
@@ -23,12 +23,26 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "xrdp_rail.h"
#include "rdpglyph.h"
+#include <signal.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <sys/types.h>
+
#define LOG_LEVEL 1
#define LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
+static int g_use_shmem = 1; /* turns on or off */
+static int g_shmemid = 0;
+static char *g_shmemptr = 0;
+static int g_shmem_lineBytes = 0;
+static RegionPtr g_shm_reg = 0;
+
+static int g_rect_id_ack = 0;
+static int g_rect_id = 0;
+
static int g_listen_sck = 0;
static int g_sck = 0;
static int g_sck_closed = 0;
@@ -74,9 +88,12 @@ struct rdpup_os_bitmap
int stamp;
};
+#define USE_MAX_OS_BYTES 1
+#define MAX_OS_BYTES (16 * 1024 * 1024)
static struct rdpup_os_bitmap *g_os_bitmaps = 0;
static int g_max_os_bitmaps = 0;
static int g_os_bitmap_stamp = 0;
+static int g_os_bitmap_alloc_size = 0;
static int g_pixmap_byte_total = 0;
static int g_pixmap_num_used = 0;
@@ -126,6 +143,49 @@ static int g_rdp_opcodes[16] =
0xff /* GXset 0xf 1 */
};
+static int g_do_kill_disconnected = 0; /* turn on or off */
+static OsTimerPtr g_dis_timer = 0;
+static int g_disconnect_scheduled = 0;
+static CARD32 g_disconnect_timeout_s = 60; /* 60 seconds */
+static CARD32 g_disconnect_time_ms = 0; /* time of disconnect in milliseconds */
+
+/******************************************************************************/
+static CARD32
+rdpDeferredDisconnectCallback(OsTimerPtr timer, CARD32 now, pointer arg)
+{
+ CARD32 lnow_ms;
+
+ LLOGLN(10, ("rdpDeferredDisconnectCallback"));
+ if (g_connected)
+ {
+ /* this should not happen */
+ LLOGLN(0, ("rdpDeferredDisconnectCallback: connected"));
+ if (g_dis_timer != 0)
+ {
+ LLOGLN(0, ("rdpDeferredDisconnectCallback: canceling g_dis_timer"));
+ TimerCancel(g_dis_timer);
+ TimerFree(g_dis_timer);
+ g_dis_timer = 0;
+ }
+ g_disconnect_scheduled = 0;
+ return 0;
+ }
+ else
+ {
+ LLOGLN(10, ("rdpDeferredDisconnectCallback: not connected"));
+ }
+ lnow_ms = GetTimeInMillis();
+ if (lnow_ms - g_disconnect_time_ms > g_disconnect_timeout_s * 1000)
+ {
+ LLOGLN(0, ("rdpDeferredDisconnectCallback: exit X11rdp"));
+ kill(getpid(), SIGTERM);
+ return 0;
+ }
+ g_dis_timer = TimerSet(g_dis_timer, 0, 1000 * 10,
+ rdpDeferredDisconnectCallback, 0);
+ return 0;
+}
+
/*****************************************************************************/
static int
rdpup_disconnect(void)
@@ -133,6 +193,18 @@ rdpup_disconnect(void)
int index;
LLOGLN(0, ("rdpup_disconnect:"));
+ if (g_do_kill_disconnected)
+ {
+ if (!g_disconnect_scheduled)
+ {
+ LLOGLN(0, ("rdpup_disconnect: starting g_dis_timer"));
+ g_dis_timer = TimerSet(g_dis_timer, 0, 1000 * 10,
+ rdpDeferredDisconnectCallback, 0);
+ g_disconnect_scheduled = 1;
+ }
+ g_disconnect_time_ms = GetTimeInMillis();
+ }
+
RemoveEnabledDevice(g_sck);
g_connected = 0;
g_tcp_close(g_sck);
@@ -155,6 +227,7 @@ rdpup_disconnect(void)
}
}
}
+ g_os_bitmap_alloc_size = 0;
g_max_os_bitmaps = 0;
g_free(g_os_bitmaps);
@@ -166,6 +239,7 @@ rdpup_disconnect(void)
}
/*****************************************************************************/
+/* returns -1 on error */
int
rdpup_add_os_bitmap(PixmapPtr pixmap, rdpPixmapPtr priv)
{
@@ -173,17 +247,32 @@ rdpup_add_os_bitmap(PixmapPtr pixmap, rdpPixmapPtr priv)
int rv;
int oldest;
int oldest_index;
+ int this_bytes;
+ LLOGLN(10, ("rdpup_add_os_bitmap:"));
if (!g_connected)
{
+ LLOGLN(10, ("rdpup_add_os_bitmap: test error 1"));
return -1;
}
if (g_os_bitmaps == 0)
{
+ LLOGLN(10, ("rdpup_add_os_bitmap: test error 2"));
return -1;
}
+ this_bytes = pixmap->devKind * pixmap->drawable.height;
+ if (this_bytes > MAX_OS_BYTES)
+ {
+ LLOGLN(10, ("rdpup_add_os_bitmap: error, too big this_bytes %d "
+ "width %d height %d", this_bytes,
+ pixmap->drawable.height, pixmap->drawable.height));
+ return -1;
+ }
+
+ oldest = 0x7fffffff;
+ oldest_index = -1;
rv = -1;
index = 0;
@@ -200,42 +289,83 @@ rdpup_add_os_bitmap(PixmapPtr pixmap, rdpPixmapPtr priv)
rv = index;
break;
}
-
+ else
+ {
+ if (g_os_bitmaps[index].stamp < oldest)
+ {
+ oldest = g_os_bitmaps[index].stamp;
+ oldest_index = index;
+ }
+ }
index++;
}
if (rv == -1)
{
+ if (oldest_index == -1)
+ {
+ LLOGLN(0, ("rdpup_add_os_bitmap: error"));
+ }
+ else
+ {
+ LLOGLN(10, ("rdpup_add_os_bitmap: too many pixmaps removing "
+ "oldest_index %d", oldest_index));
+ rdpup_remove_os_bitmap(oldest_index);
+ rdpup_delete_os_surface(oldest_index);
+ g_os_bitmaps[oldest_index].used = 1;
+ g_os_bitmaps[oldest_index].pixmap = pixmap;
+ g_os_bitmaps[oldest_index].priv = priv;
+ g_os_bitmaps[oldest_index].stamp = g_os_bitmap_stamp;
+ g_os_bitmap_stamp++;
+ g_pixmap_num_used++;
+ rv = oldest_index;
+ }
+ }
+
+ if (rv < 0)
+ {
+ LLOGLN(10, ("rdpup_add_os_bitmap: test error 3"));
+ return rv;
+ }
+
+ g_os_bitmap_alloc_size += this_bytes;
+ LLOGLN(10, ("rdpup_add_os_bitmap: this_bytes %d g_os_bitmap_alloc_size %d",
+ this_bytes, g_os_bitmap_alloc_size));
+#if USE_MAX_OS_BYTES
+ while (g_os_bitmap_alloc_size > MAX_OS_BYTES)
+ {
+ LLOGLN(10, ("rdpup_add_os_bitmap: must delete g_pixmap_num_used %d",
+ g_pixmap_num_used));
/* find oldest */
oldest = 0x7fffffff;
- oldest_index = 0;
+ oldest_index = -1;
index = 0;
-
while (index < g_max_os_bitmaps)
{
- if (g_os_bitmaps[index].stamp < oldest)
+ if (g_os_bitmaps[index].used && (g_os_bitmaps[index].stamp < oldest))
{
oldest = g_os_bitmaps[index].stamp;
oldest_index = index;
}
-
index++;
}
-
- LLOGLN(10, ("rdpup_add_os_bitmap: evicting old, oldest_index %d", oldest_index));
- /* evict old */
- g_os_bitmaps[oldest_index].priv->status = 0;
- g_os_bitmaps[oldest_index].priv->con_number = 0;
- /* set new */
- g_os_bitmaps[oldest_index].pixmap = pixmap;
- g_os_bitmaps[oldest_index].priv = priv;
- g_os_bitmaps[oldest_index].stamp = g_os_bitmap_stamp;
- g_os_bitmap_stamp++;
- rv = oldest_index;
+ if (oldest_index == -1)
+ {
+ LLOGLN(0, ("rdpup_add_os_bitmap: error 1"));
+ break;
+ }
+ if (oldest_index == rv)
+ {
+ LLOGLN(0, ("rdpup_add_os_bitmap: error 2"));
+ break;
+ }
+ rdpup_remove_os_bitmap(oldest_index);
+ rdpup_delete_os_surface(oldest_index);
}
-
+#endif
LLOGLN(10, ("rdpup_add_os_bitmap: new bitmap index %d", rv));
- LLOGLN(10, (" g_pixmap_num_used %d", g_pixmap_num_used));
+ LLOGLN(10, ("rdpup_add_os_bitmap: g_pixmap_num_used %d "
+ "g_os_bitmap_stamp 0x%8.8x", g_pixmap_num_used, g_os_bitmap_stamp));
return rv;
}
@@ -243,31 +373,84 @@ rdpup_add_os_bitmap(PixmapPtr pixmap, rdpPixmapPtr priv)
int
rdpup_remove_os_bitmap(int rdpindex)
{
+ PixmapPtr pixmap;
+ rdpPixmapPtr priv;
+ int this_bytes;
+
LLOGLN(10, ("rdpup_remove_os_bitmap: index %d stamp %d",
- rdpindex, g_os_bitmaps[rdpindex].stamp));
+ rdpindex, g_os_bitmaps[rdpindex].stamp));
if (g_os_bitmaps == 0)
{
+ LLOGLN(10, ("rdpup_remove_os_bitmap: test error 1"));
return 1;
}
if ((rdpindex < 0) && (rdpindex >= g_max_os_bitmaps))
{
+ LLOGLN(10, ("rdpup_remove_os_bitmap: test error 2"));
return 1;
}
if (g_os_bitmaps[rdpindex].used)
{
+ pixmap = g_os_bitmaps[rdpindex].pixmap;
+ priv = g_os_bitmaps[rdpindex].priv;
+ draw_item_remove_all(priv);
+ this_bytes = pixmap->devKind * pixmap->drawable.height;
+ g_os_bitmap_alloc_size -= this_bytes;
+ LLOGLN(10, ("rdpup_remove_os_bitmap: this_bytes %d "
+ "g_os_bitmap_alloc_size %d", this_bytes,
+ g_os_bitmap_alloc_size));
g_os_bitmaps[rdpindex].used = 0;
g_os_bitmaps[rdpindex].pixmap = 0;
g_os_bitmaps[rdpindex].priv = 0;
g_pixmap_num_used--;
+ priv->status = 0;
+ priv->con_number = 0;
+ priv->use_count = 0;
+ }
+ else
+ {
+ LLOGLN(0, ("rdpup_remove_os_bitmap: error"));
+ }
+
+ LLOGLN(10, ("rdpup_remove_os_bitmap: g_pixmap_num_used %d",
+ g_pixmap_num_used));
+ return 0;
+}
+
+/*****************************************************************************/
+int
+rdpup_update_os_use(int rdpindex)
+{
+ LLOGLN(10, ("rdpup_update_use: index %d stamp %d",
+ rdpindex, g_os_bitmaps[rdpindex].stamp));
+
+ if (g_os_bitmaps == 0)
+ {
+ return 1;
+ }
+
+ if ((rdpindex < 0) && (rdpindex >= g_max_os_bitmaps))
+ {
+ return 1;
+ }
+
+ if (g_os_bitmaps[rdpindex].used)
+ {
+ g_os_bitmaps[rdpindex].stamp = g_os_bitmap_stamp;
+ g_os_bitmap_stamp++;
+ }
+ else
+ {
+ LLOGLN(0, ("rdpup_update_use: error rdpindex %d", rdpindex));
}
- LLOGLN(10, (" g_pixmap_num_used %d", g_pixmap_num_used));
return 0;
}
+
/*****************************************************************************/
/* returns error */
static int
@@ -382,7 +565,14 @@ rdpDeferredUpdateCallback(OsTimerPtr timer, CARD32 now, pointer arg)
if (g_do_dirty_ons)
{
- rdpup_check_dirty_screen(&g_screenPriv);
+ if (g_rect_id == g_rect_id_ack)
+ {
+ rdpup_check_dirty_screen(&g_screenPriv);
+ }
+ else
+ {
+ LLOGLN(0, ("rdpDeferredUpdateCallback: skipping"));
+ }
}
else
{
@@ -483,6 +673,34 @@ rdpup_recv_msg(struct stream *s)
return rv;
}
+/*****************************************************************************/
+/* wait 'millis' milliseconds for the socket to be able to receive */
+/* returns boolean */
+static int
+sck_can_recv(int sck, int millis)
+{
+ fd_set rfds;
+ struct timeval time;
+ int rv;
+
+ time.tv_sec = millis / 1000;
+ time.tv_usec = (millis * 1000) % 1000000;
+ FD_ZERO(&rfds);
+
+ if (sck > 0)
+ {
+ FD_SET(((unsigned int)sck), &rfds);
+ rv = select(sck + 1, &rfds, 0, 0, &time);
+
+ if (rv > 0)
+ {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
/******************************************************************************/
/*
this from miScreenInit
@@ -495,6 +713,7 @@ process_screen_size_msg(int width, int height, int bpp)
RRScreenSizePtr pSize;
int mmwidth;
int mmheight;
+ int bytes;
Bool ok;
LLOGLN(0, ("process_screen_size_msg: set width %d height %d bpp %d",
@@ -524,6 +743,28 @@ process_screen_size_msg(int width, int height, int bpp)
g_rdpScreen.rdp_Bpp_mask = 0xffffff;
}
+ if (g_use_shmem)
+ {
+ if (g_shmemptr != 0)
+ {
+ shmdt(g_shmemptr);
+ }
+ bytes = g_rdpScreen.rdp_width * g_rdpScreen.rdp_height *
+ g_rdpScreen.rdp_Bpp;
+ g_shmemid = shmget(IPC_PRIVATE, bytes, IPC_CREAT | 0777);
+ g_shmemptr = shmat(g_shmemid, 0, 0);
+ shmctl(g_shmemid, IPC_RMID, NULL);
+ LLOGLN(0, ("process_screen_size_msg: g_shmemid %d g_shmemptr %p",
+ g_shmemid, g_shmemptr));
+ g_shmem_lineBytes = g_rdpScreen.rdp_Bpp * g_rdpScreen.rdp_width;
+
+ if (g_shm_reg != 0)
+ {
+ RegionDestroy(g_shm_reg);
+ }
+ g_shm_reg = RegionCreate(NullBox, 0);
+ }
+
mmwidth = PixelToMM(width);
mmheight = PixelToMM(height);
@@ -668,6 +909,13 @@ rdpup_process_msg(struct stream *s)
int param4;
int bytes;
int i1;
+ int flags;
+ int x;
+ int y;
+ int cx;
+ int cy;
+ RegionRec reg;
+ BoxRec box;
in_uint16_le(s, msg_type);
@@ -855,6 +1103,31 @@ rdpup_process_msg(struct stream *s)
LLOGLN(0, (" client can not do new(color) cursor"));
}
}
+ else if (msg_type == 105)
+ {
+ LLOGLN(10, ("rdpup_process_msg: got msg 105"));
+ in_uint32_le(s, flags);
+ in_uint32_le(s, g_rect_id_ack);
+ in_uint32_le(s, x);
+ in_uint32_le(s, y);
+ in_uint32_le(s, cx);
+ in_uint32_le(s, cy);
+ LLOGLN(10, (" %d %d %d %d", x, y, cx ,cy));
+ LLOGLN(10, (" rect_id %d rect_id_ack %d", g_rect_id, g_rect_id_ack));
+
+ box.x1 = x;
+ box.y1 = y;
+ box.x2 = box.x1 + cx;
+ box.y2 = box.y1 + cy;
+
+ RegionInit(&reg, &box, 0);
+ LLOGLN(10, ("< %d %d %d %d", box.x1, box.y1, box.x2, box.y2));
+ RegionSubtract(g_shm_reg, g_shm_reg, &reg);
+ RegionUninit(&reg);
+
+ }
+
+
else
{
rdpLog("unknown message type in rdpup_process_msg %d\n", msg_type);
@@ -873,6 +1146,10 @@ rdpup_get_screen_image_rect(struct image_data *id)
id->Bpp = g_rdpScreen.rdp_Bpp;
id->lineBytes = g_rdpScreen.paddedWidthInBytes;
id->pixels = g_rdpScreen.pfbMemory;
+ id->shmem_pixels = g_shmemptr;
+ id->shmem_id = g_shmemid;
+ id->shmem_offset = 0;
+ id->shmem_lineBytes = g_shmem_lineBytes;
}
/******************************************************************************/
@@ -885,6 +1162,10 @@ rdpup_get_pixmap_image_rect(PixmapPtr pPixmap, struct image_data *id)
id->Bpp = g_rdpScreen.rdp_Bpp;
id->lineBytes = pPixmap->devKind;
id->pixels = (char *)(pPixmap->devPrivate.ptr);
+ id->shmem_pixels = 0;
+ id->shmem_id = 0;
+ id->shmem_offset = 0;
+ id->shmem_lineBytes = 0;
}
/******************************************************************************/
@@ -892,6 +1173,7 @@ int
rdpup_init(void)
{
char text[256];
+ char *ptext;
int i;
if (!g_directory_exist("/tmp/.xrdp"))
@@ -976,6 +1258,39 @@ rdpup_init(void)
}
}
+ ptext = getenv("XRDP_SESMAN_MAX_IDLE_TIME");
+ if (ptext != 0)
+ {
+ }
+ ptext = getenv("XRDP_SESMAN_MAX_DISC_TIME");
+ if (ptext != 0)
+ {
+ i = atoi(ptext);
+ if (i > 0)
+ {
+ g_do_kill_disconnected = 1;
+ g_disconnect_timeout_s = atoi(ptext);
+ }
+ }
+ ptext = getenv("XRDP_SESMAN_KILL_DISCONNECTED");
+ if (ptext != 0)
+ {
+ i = atoi(ptext);
+ if (i != 0)
+ {
+ g_do_kill_disconnected = 1;
+ g_disconnect_timeout_s = 0;
+ }
+ }
+
+ if (g_do_kill_disconnected && (g_disconnect_timeout_s < 60))
+ {
+ g_disconnect_timeout_s = 60;
+ }
+
+ rdpLog("kill disconencted [%d] timeout [%d] sec\n", g_do_kill_disconnected,
+ g_disconnect_timeout_s);
+
return 1;
}
@@ -1015,6 +1330,16 @@ rdpup_check(void)
g_con_number++;
rdpGlyphInit();
AddEnabledDevice(g_sck);
+
+ if (g_dis_timer != 0)
+ {
+ LLOGLN(0, ("rdpup_check: canceling g_dis_timer"));
+ TimerCancel(g_dis_timer);
+ TimerFree(g_dis_timer);
+ g_dis_timer = 0;
+ }
+ g_disconnect_scheduled = 0;
+
}
}
@@ -1680,11 +2005,13 @@ get_single_color(struct image_data *id, int x, int y, int w, int h)
}
/******************************************************************************/
-/* split the bitmap up into 64 x 64 pixel areas */
+/* split the bitmap up into 64 x 64 pixel areas
+ or send using shared memory */
void
rdpup_send_area(struct image_data *id, int x, int y, int w, int h)
{
char *s;
+ char *d;
int i;
int single_color;
int lx;
@@ -1692,7 +2019,10 @@ rdpup_send_area(struct image_data *id, int x, int y, int w, int h)
int lh;
int lw;
int size;
+ int safety;
struct image_data lid;
+ BoxRec box;
+ RegionRec reg;
LLOGLN(10, ("rdpup_send_area: id %p x %d y %d w %d h %d", id, x, y, w, h));
@@ -1749,8 +2079,71 @@ rdpup_send_area(struct image_data *id, int x, int y, int w, int h)
if (g_connected && g_begin)
{
LLOGLN(10, (" rdpup_send_area"));
- ly = y;
+ if (id->shmem_pixels != 0)
+ {
+ LLOGLN(10, ("rdpup_send_area: using shmem"));
+ box.x1 = x;
+ box.y1 = y;
+ box.x2 = box.x1 + w;
+ box.y2 = box.y1 + h;
+ safety = 0;
+ while (RegionContainsRect(g_shm_reg, &box))
+ {
+ rdpup_end_update();
+ rdpup_begin_update();
+ safety++;
+ if (safety > 100)
+ {
+ break;
+ }
+ if (sck_can_recv(g_sck, 100))
+ {
+ if (rdpup_recv_msg(g_in_s) == 0)
+ {
+ rdpup_process_msg(g_in_s);
+ }
+ }
+ }
+ s = id->pixels;
+ s += y * id->lineBytes;
+ s += x * g_Bpp;
+ d = id->shmem_pixels + id->shmem_offset;
+ d += y * id->shmem_lineBytes;
+ d += x * g_rdpScreen.rdp_Bpp;
+ ly = y;
+ while (ly < y + h)
+ {
+ convert_pixels(s, d, w);
+ s += id->lineBytes;
+ d += id->shmem_lineBytes;
+ ly += 1;
+ }
+ size = 36;
+ rdpup_pre_check(size);
+ out_uint16_le(g_out_s, 60);
+ out_uint16_le(g_out_s, size);
+ g_count++;
+ out_uint16_le(g_out_s, x);
+ out_uint16_le(g_out_s, y);
+ out_uint16_le(g_out_s, w);
+ out_uint16_le(g_out_s, h);
+ out_uint32_le(g_out_s, 0);
+ g_rect_id++;
+ out_uint32_le(g_out_s, g_rect_id);
+ out_uint32_le(g_out_s, id->shmem_id);
+ out_uint32_le(g_out_s, id->shmem_offset);
+ out_uint16_le(g_out_s, id->width);
+ out_uint16_le(g_out_s, id->height);
+ out_uint16_le(g_out_s, x);
+ out_uint16_le(g_out_s, y);
+ RegionInit(&reg, &box, 0);
+ RegionUnion(g_shm_reg, g_shm_reg, &reg);
+ RegionUninit(&reg);
+ return;
+ }
+
+ ly = y;
while ((ly < y + h) && g_connected)
{
lx = x;
@@ -2106,10 +2499,6 @@ rdpup_check_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec *pDirtyPriv)
return 0;
}
- /* update use time / count */
- g_os_bitmaps[pDirtyPriv->rdpindex].stamp = g_os_bitmap_stamp;
- g_os_bitmap_stamp++;
-
LLOGLN(10, ("rdpup_check_dirty: got dirty"));
rdpup_switch_os_surface(pDirtyPriv->rdpindex);
rdpup_get_pixmap_image_rect(pDirtyPixmap, &id);
@@ -2302,8 +2691,8 @@ rdpup_check_dirty_screen(rdpPixmapRec *pDirtyPriv)
for (index = 0; index < count; index++)
{
box = REGION_RECTS(di->reg)[index];
- LLOGLN(10, (" RDI_IMGLL %d %d %d %d", box.x1, box.y1,
- box.x2, box.y2));
+ LLOGLN(10, (" RDI_IMGLL x %d y %d w %d h %d", box.x1, box.y1,
+ box.x2 - box.x1, box.y2 - box.y1));
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1,
box.y2 - box.y1);
}
diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c
index 0c340e55..887ada68 100644
--- a/xrdp/xrdp.c
+++ b/xrdp/xrdp.c
@@ -138,7 +138,7 @@ xrdp_child_fork(void)
}
/*****************************************************************************/
-int APP_CC
+int DEFAULT_CC
g_is_term(void)
{
return g_is_wait_obj_set(g_term_event);
diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h
index 4215c27b..172d417a 100644
--- a/xrdp/xrdp.h
+++ b/xrdp/xrdp.h
@@ -27,8 +27,8 @@
#include "trans.h"
#include "list.h"
#include "libxrdpinc.h"
-#include "xrdp_types.h"
#include "xrdp_constants.h"
+#include "xrdp_types.h"
#include "defines.h"
#include "os_calls.h"
#include "ssl_calls.h"
@@ -41,7 +41,7 @@
long APP_CC
g_xrdp_sync(long (*sync_func)(long param1, long param2), long sync_param1,
long sync_param2);
-int APP_CC
+int DEFAULT_CC
g_is_term(void);
void APP_CC
g_set_term(int in_val);
diff --git a/xrdp/xrdp.ini b/xrdp/xrdp.ini
index 8d97c0d3..c191619b 100644
--- a/xrdp/xrdp.ini
+++ b/xrdp/xrdp.ini
@@ -112,8 +112,8 @@ ip=ask
port=ask3389
[xrdp7]
-name=freerdp-any
-lib=libxrdpfreerdp1.so
+name=neutrinordp-any
+lib=libxrdpneutrinordp.so
ip=ask
port=ask3389
username=ask
diff --git a/xrdp/xrdp_bitmap.c b/xrdp/xrdp_bitmap.c
index 19620c40..b3faea41 100644
--- a/xrdp/xrdp_bitmap.c
+++ b/xrdp/xrdp_bitmap.c
@@ -821,6 +821,8 @@ xrdp_bitmap_copy_box_with_crc(struct xrdp_bitmap *self,
unsigned char *d8 = (unsigned char *)NULL;
unsigned short *s16 = (unsigned short *)NULL;
unsigned short *d16 = (unsigned short *)NULL;
+ unsigned int *s32;
+ unsigned int *d32;
if (self == 0)
{
@@ -864,16 +866,65 @@ xrdp_bitmap_copy_box_with_crc(struct xrdp_bitmap *self,
if (self->bpp == 24)
{
+ s32 = ((unsigned int *)(self->data)) + (self->width * y + x);
+ d32 = ((unsigned int *)(dest->data)) + (dest->width * desty + destx);
+ incs = self->width - cx;
+ incd = dest->width - cx;
+
for (i = 0; i < cy; i++)
{
- for (j = 0; j < cx; j++)
+ j = 0;
+ while (j < cx - 4)
{
- pixel = GETPIXEL32(self->data, j + x, i + y, self->width);
+ pixel = *s32;
CRC_PASS(pixel, crc);
CRC_PASS(pixel >> 8, crc);
CRC_PASS(pixel >> 16, crc);
- SETPIXEL32(dest->data, j + destx, i + desty, dest->width, pixel);
+ *d32 = pixel;
+ s32++;
+ d32++;
+
+ pixel = *s32;
+ CRC_PASS(pixel, crc);
+ CRC_PASS(pixel >> 8, crc);
+ CRC_PASS(pixel >> 16, crc);
+ *d32 = pixel;
+ s32++;
+ d32++;
+
+ pixel = *s32;
+ CRC_PASS(pixel, crc);
+ CRC_PASS(pixel >> 8, crc);
+ CRC_PASS(pixel >> 16, crc);
+ *d32 = pixel;
+ s32++;
+ d32++;
+
+ pixel = *s32;
+ CRC_PASS(pixel, crc);
+ CRC_PASS(pixel >> 8, crc);
+ CRC_PASS(pixel >> 16, crc);
+ *d32 = pixel;
+ s32++;
+ d32++;
+
+ j += 4;
}
+ while (j < cx)
+ {
+ pixel = *s32;
+ CRC_PASS(pixel, crc);
+ CRC_PASS(pixel >> 8, crc);
+ CRC_PASS(pixel >> 16, crc);
+ *d32 = pixel;
+ s32++;
+ d32++;
+
+ j += 1;
+ }
+
+ s32 += incs;
+ d32 += incd;
}
}
else if (self->bpp == 15 || self->bpp == 16)
diff --git a/xrdp/xrdp_cache.c b/xrdp/xrdp_cache.c
index 16ce1283..a93f73c4 100644
--- a/xrdp/xrdp_cache.c
+++ b/xrdp/xrdp_cache.c
@@ -45,12 +45,22 @@ xrdp_cache_create(struct xrdp_wm *owner,
self->wm = owner;
self->session = session;
self->use_bitmap_comp = client_info->use_bitmap_comp;
- self->cache1_entries = client_info->cache1_entries;
+
+ self->cache1_entries = MIN(XRDP_MAX_BITMAP_CACHE_IDX,
+ client_info->cache1_entries);
+ self->cache1_entries = MAX(self->cache1_entries, 0);
self->cache1_size = client_info->cache1_size;
- self->cache2_entries = client_info->cache2_entries;
+
+ self->cache2_entries = MIN(XRDP_MAX_BITMAP_CACHE_IDX,
+ client_info->cache2_entries);
+ self->cache2_entries = MAX(self->cache2_entries, 0);
self->cache2_size = client_info->cache2_size;
- self->cache3_entries = client_info->cache3_entries;
+
+ self->cache3_entries = MIN(XRDP_MAX_BITMAP_CACHE_IDX,
+ client_info->cache3_entries);
+ self->cache3_entries = MAX(self->cache3_entries, 0);
self->cache3_size = client_info->cache3_size;
+
self->bitmap_cache_persist_enable = client_info->bitmap_cache_persist_enable;
self->bitmap_cache_version = client_info->bitmap_cache_version;
self->pointer_cache_entries = client_info->pointer_cache_entries;
@@ -150,6 +160,11 @@ xrdp_cache_reset(struct xrdp_cache *self,
return 0;
}
+#define COMPARE_WITH_CRC(_b1, _b2) \
+ ((_b1 != 0) && (_b2 != 0) && (_b1->crc == _b2->crc) && \
+ (_b1->bpp == _b2->bpp) && \
+ (_b1->width == _b2->width) && (_b1->height == _b2->height))
+
/*****************************************************************************/
/* returns cache id */
int APP_CC
@@ -184,8 +199,7 @@ xrdp_cache_add_bitmap(struct xrdp_cache *self, struct xrdp_bitmap *bitmap,
for (j = 0; j < self->cache1_entries; j++)
{
#ifdef USE_CRC
-
- if (xrdp_bitmap_compare_with_crc(self->bitmap_items[i][j].bitmap, bitmap))
+ if (COMPARE_WITH_CRC(self->bitmap_items[i][j].bitmap, bitmap))
#else
if (xrdp_bitmap_compare(self->bitmap_items[i][j].bitmap, bitmap))
#endif
@@ -204,8 +218,7 @@ xrdp_cache_add_bitmap(struct xrdp_cache *self, struct xrdp_bitmap *bitmap,
for (j = 0; j < self->cache2_entries; j++)
{
#ifdef USE_CRC
-
- if (xrdp_bitmap_compare_with_crc(self->bitmap_items[i][j].bitmap, bitmap))
+ if (COMPARE_WITH_CRC(self->bitmap_items[i][j].bitmap, bitmap))
#else
if (xrdp_bitmap_compare(self->bitmap_items[i][j].bitmap, bitmap))
#endif
@@ -224,8 +237,7 @@ xrdp_cache_add_bitmap(struct xrdp_cache *self, struct xrdp_bitmap *bitmap,
for (j = 0; j < self->cache3_entries; j++)
{
#ifdef USE_CRC
-
- if (xrdp_bitmap_compare_with_crc(self->bitmap_items[i][j].bitmap, bitmap))
+ if (COMPARE_WITH_CRC(self->bitmap_items[i][j].bitmap, bitmap))
#else
if (xrdp_bitmap_compare(self->bitmap_items[i][j].bitmap, bitmap))
#endif
diff --git a/xrdp/xrdp_listen.c b/xrdp/xrdp_listen.c
index 965aa50d..2e1617a6 100644
--- a/xrdp/xrdp_listen.c
+++ b/xrdp/xrdp_listen.c
@@ -66,6 +66,10 @@ xrdp_listen_create(void)
{
log_message(LOG_LEVEL_ERROR,"xrdp_listen_create: trans_create failed");
}
+ else
+ {
+ self->listen_trans->is_term = g_is_term;
+ }
return self;
}
@@ -199,19 +203,19 @@ xrdp_listen_get_port_address(char *port, int port_bytes,
if (g_strcasecmp(val, "fork") == 0)
{
val = (char *)list_get_item(values, index);
- startup_param->fork = text2bool(val);
+ startup_param->fork = g_text2bool(val);
}
if (g_strcasecmp(val, "tcp_nodelay") == 0)
{
val = (char *)list_get_item(values, index);
- *tcp_nodelay = text2bool(val);
+ *tcp_nodelay = g_text2bool(val);
}
if (g_strcasecmp(val, "tcp_keepalive") == 0)
{
val = (char *)list_get_item(values, index);
- *tcp_keepalive = text2bool(val);
+ *tcp_keepalive = g_text2bool(val);
}
}
}
diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c
index b1499984..560ebedb 100644
--- a/xrdp/xrdp_mm.c
+++ b/xrdp/xrdp_mm.c
@@ -1063,11 +1063,13 @@ xrdp_mm_connect_chansrv(struct xrdp_mm *self, char *ip, char *port)
{
/* unix socket */
self->chan_trans = trans_create(TRANS_MODE_UNIX, 8192, 8192);
+ self->chan_trans->is_term = g_is_term;
}
else
{
/* tcp */
self->chan_trans = trans_create(TRANS_MODE_TCP, 8192, 8192);
+ self->chan_trans->is_term = g_is_term;
}
self->chan_trans->trans_data_in = xrdp_mm_chan_data_in;
@@ -1752,6 +1754,7 @@ xrdp_mm_connect(struct xrdp_mm *self)
ok = 0;
trans_delete(self->sesman_trans);
self->sesman_trans = trans_create(TRANS_MODE_TCP, 8192, 8192);
+ self->sesman_trans->is_term = g_is_term;
xrdp_mm_get_sesman_port(port, sizeof(port));
g_snprintf(text, 255, "connecting to sesman ip %s port %s", ip, port);
xrdp_wm_log_msg(self->wm, text);
@@ -2546,7 +2549,7 @@ is_channel_enabled(char *inName, struct list *names, struct list *values)
if ( index >= 0 )
{
val = (char *)list_get_item(values, index);
- reply = text2bool(val);
+ reply = g_text2bool(val);
if (reply == 0)
{
log_message(LOG_LEVEL_INFO,"This channel is disabled: %s", inName);
@@ -2799,7 +2802,7 @@ server_switch_os_surface(struct xrdp_mod *mod, int rdpindex)
bi = xrdp_cache_get_os_bitmap(wm->cache, rdpindex);
- if (bi != 0)
+ if ((bi != 0) && (bi->bitmap != 0))
{
//g_writeln("server_switch_os_surface: setting target_surface to rdpid %d", id);
wm->target_surface = bi->bitmap;
diff --git a/xrdp/xrdp_process.c b/xrdp/xrdp_process.c
index 228bf630..4c52eaac 100644
--- a/xrdp/xrdp_process.c
+++ b/xrdp/xrdp_process.c
@@ -203,6 +203,9 @@ xrdp_process_main_loop(struct xrdp_process *self)
else
{
g_writeln("xrdp_process_main_loop: libxrdp_process_incomming failed");
+ /* this will try to send a disconnect,
+ maybe should check that connection got far enough */
+ libxrdp_disconnect(self->session);
}
/* Run end in module */
xrdp_process_mod_end(self);
diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h
index 14ae2237..cd71c342 100644
--- a/xrdp/xrdp_types.h
+++ b/xrdp/xrdp_types.h
@@ -216,7 +216,8 @@ struct xrdp_cache
struct xrdp_palette_item palette_items[6];
/* bitmap */
int bitmap_stamp;
- struct xrdp_bitmap_item bitmap_items[3][XRDP_BITMAP_CACHE_ENTRIES];
+ struct xrdp_bitmap_item bitmap_items[XRDP_MAX_BITMAP_CACHE_ID]
+ [XRDP_MAX_BITMAP_CACHE_IDX];
int use_bitmap_comp;
int cache1_entries;
int cache1_size;
diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c
index caa74347..bba25c34 100644
--- a/xrdp/xrdp_wm.c
+++ b/xrdp/xrdp_wm.c
@@ -455,7 +455,7 @@ xrdp_wm_load_static_colors_plus(struct xrdp_wm *self, char *autorun_name)
else if (g_strcasecmp(val, "hidelogwindow") == 0)
{
val = (char *)list_get_item(values, index);
- self->hide_log_window = text2bool(val);
+ self->hide_log_window = g_text2bool(val);
}
else if (g_strcasecmp(val, "pamerrortxt") == 0)
{
diff --git a/xup/xup.c b/xup/xup.c
index a4fe39d0..7c68cbcf 100644
--- a/xup/xup.c
+++ b/xup/xup.c
@@ -20,6 +20,9 @@
#include "xup.h"
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
#define LOG_LEVEL 1
#define LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { g_write _args ; } } while (0)
@@ -537,7 +540,35 @@ process_server_set_pointer_ex(struct mod *mod, struct stream *s)
/******************************************************************************/
/* return error */
-static int
+static int APP_CC
+send_paint_rect_ack(struct mod *mod, int flags, int x, int y, int cx, int cy,
+ int frame_id)
+{
+ int len;
+ struct stream *s;
+
+ make_stream(s);
+ init_stream(s, 8192);
+ s_push_layer(s, iso_hdr, 4);
+ out_uint16_le(s, 105);
+ out_uint32_le(s, flags);
+ out_uint32_le(s, frame_id);
+ out_uint32_le(s, x);
+ out_uint32_le(s, y);
+ out_uint32_le(s, cx);
+ out_uint32_le(s, cy);
+ s_mark_end(s);
+ len = (int)(s->end - s->data);
+ s_pop_layer(s, iso_hdr);
+ out_uint32_le(s, len);
+ lib_send(mod, s->data, len);
+ free_stream(s);
+ return 0;
+}
+
+/******************************************************************************/
+/* return error */
+static int APP_CC
lib_mod_process_orders(struct mod *mod, int type, struct stream *s)
{
int rv;
@@ -566,9 +597,12 @@ lib_mod_process_orders(struct mod *mod, int type, struct stream *s)
int fgcolor;
int bgcolor;
int opcode;
+ int flags;
+ int shmem_id;
+ int shmem_offset;
+ int frame_id;
int charactor;
int font;
- int flags;
int mixmode;
int clip_left;
int clip_top;
@@ -810,6 +844,45 @@ lib_mod_process_orders(struct mod *mod, int type, struct stream *s)
case 51: /* server_set_pointer_ex */
rv = process_server_set_pointer_ex(mod, s);
break;
+ case 60: /* server_paint_rect_shmem */
+ in_sint16_le(s, x);
+ in_sint16_le(s, y);
+ in_uint16_le(s, cx);
+ in_uint16_le(s, cy);
+ in_uint32_le(s, flags);
+ in_uint32_le(s, frame_id);
+ in_uint32_le(s, shmem_id);
+ in_uint32_le(s, shmem_offset);
+ in_uint16_le(s, width);
+ in_uint16_le(s, height);
+ in_sint16_le(s, srcx);
+ in_sint16_le(s, srcy);
+ bmpdata = 0;
+ if (flags == 0) /* screen */
+ {
+ if (mod->screen_shmem_id == 0)
+ {
+ mod->screen_shmem_id = shmem_id;
+ mod->screen_shmem_pixels = shmat(mod->screen_shmem_id, 0, 0);
+ }
+ if (mod->screen_shmem_pixels != 0)
+ {
+ bmpdata = mod->screen_shmem_pixels + shmem_offset;
+ }
+ }
+ if (bmpdata != 0)
+ {
+ rv = mod->server_paint_rect(mod, x, y, cx, cy,
+ bmpdata, width, height,
+ srcx, srcy);
+ }
+ else
+ {
+ rv = 1;
+ }
+ send_paint_rect_ack(mod, flags, x, y, cx, cy, frame_id);
+ break;
+
default:
g_writeln("lib_mod_process_orders: unknown order type %d", type);
rv = 0;
diff --git a/xup/xup.h b/xup/xup.h
index ca232c4d..9ae4f920 100644
--- a/xup/xup.h
+++ b/xup/xup.h
@@ -153,4 +153,6 @@ struct mod
tbus sck_obj;
int shift_state;
struct xrdp_client_info client_info;
+ int screen_shmem_id;
+ char *screen_shmem_pixels;
};