diff options
45 files changed, 675 insertions, 4035 deletions
diff --git a/Makefile.am b/Makefile.am index 26dcb8aa..79f2e4f3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,10 +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 = freerdp1 -else -FREERDPDIR = -endif if XRDP_NEUTRINORDP NEUTRINORDPDIR = neutrinordp @@ -24,7 +19,6 @@ SUBDIRS = \ rdp \ xup \ mc \ - $(FREERDPDIR) \ $(NEUTRINORDPDIR) \ libxrdp \ xrdp \ 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..1939ddc9 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -2935,3 +2935,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..2dbbe660 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -152,5 +152,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..3ec37104 100644 --- a/common/parse.h +++ b/common/parse.h @@ -279,6 +279,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..0b672168 100644 --- a/common/trans.c +++ b/common/trans.c @@ -142,6 +142,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) { @@ -226,9 +227,18 @@ trans_force_read_s(struct trans *self, struct stream *in_s, int size) { 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 @@ -285,9 +295,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 diff --git a/common/trans.h b/common/trans.h index 8daa980a..4b8e3b42 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,7 @@ struct trans struct stream* in_s; struct stream* out_s; char* listen_filename; + tis_term is_term; /* used to test for exit */ }; struct trans* APP_CC diff --git a/configure.ac b/configure.ac index a2a80aa2..11188d36 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]) @@ -83,8 +79,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 +122,6 @@ AC_CONFIG_FILES([Makefile libxrdp/Makefile xup/Makefile mc/Makefile - freerdp1/Makefile neutrinordp/Makefile xrdp/Makefile sesman/Makefile @@ -141,8 +134,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-color.h b/freerdp/xrdp-color.h deleted file mode 100644 index 3c58c032..00000000 --- a/freerdp/xrdp-color.h +++ /dev/null @@ -1,28 +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. - */ - -#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/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..279113b8 100644 --- a/libxrdp/Makefile.am +++ b/libxrdp/Makefile.am @@ -11,8 +11,8 @@ 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 diff --git a/libxrdp/xrdp_orders.c b/libxrdp/xrdp_orders.c index 29234173..f753371d 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 @@ -2091,6 +2091,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++) @@ -2120,6 +2139,7 @@ xrdp_orders_send_raw_bitmap2(struct xrdp_orders *self, out_uint8s(self->out_s, Bpp); } } + } return 0; } @@ -2228,7 +2248,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 @@ -2306,7 +2326,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; @@ -2321,7 +2341,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)) { diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c index 93219968..2d90485f 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"); @@ -133,11 +133,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); } } @@ -146,7 +146,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) @@ -227,7 +227,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 @@ -247,7 +247,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); diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index 388d0273..26d4182e 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -77,6 +77,13 @@ int g_exec_pid = 0; tui32 g_dvc_chan_id = 100; /*****************************************************************************/ +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 @@ -844,13 +851,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); } @@ -875,6 +884,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); diff --git a/sesman/chansrv/chansrv.h b/sesman/chansrv/chansrv.h index bca30ca4..12162dd1 100644 --- a/sesman/chansrv/chansrv.h +++ b/sesman/chansrv/chansrv.h @@ -54,6 +54,9 @@ 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 main_cleanup(void); int APP_CC find_empty_slot_in_dvc_channels(); diff --git a/sesman/chansrv/smartcard_pcsc.c b/sesman/chansrv/smartcard_pcsc.c index a3a269d7..909c7df3 100644 --- a/sesman/chansrv/smartcard_pcsc.c +++ b/sesman/chansrv/smartcard_pcsc.c @@ -24,6 +24,7 @@ #define PCSC_STANDIN 1 +#include "chansrv.h" #include "os_calls.h" #include "smartcard.h" #include "log.h" @@ -258,7 +259,8 @@ scard_pcsc_init(void) if (g_lis == 0) { - g_lis = trans_create(2, 8192, 8192); + g_lis = trans_create(TRANS_MODE_UNIX, 8192, 8192); + g_lis->is_term = g_is_term; g_snprintf(g_pcsc_directory, 255, "/tmp/.xrdp/pcsc%d", g_display_num); if (g_directory_exist(g_pcsc_directory)) { 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/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/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 6fd7c38a..c9afd285 100644 --- a/xorg/X11R7.6/rdp/rdp.h +++ b/xorg/X11R7.6/rdp/rdp.h @@ -103,6 +103,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 @@ -252,6 +256,8 @@ struct rdp_draw_item union urdp_draw_item u; }; +#define XRDP_USE_COUNT_THRESHOLD 1 + struct _rdpPixmapRec { int status; @@ -260,6 +266,10 @@ struct _rdpPixmapRec int is_dirty; int is_scratch; 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; }; diff --git a/xorg/X11R7.6/rdp/rdpdraw.c b/xorg/X11R7.6/rdp/rdpdraw.c index 4b900f4e..ecc7dbda 100644 --- a/xorg/X11R7.6/rdp/rdpdraw.c +++ b/xorg/X11R7.6/rdp/rdpdraw.c @@ -804,11 +804,14 @@ xrdp_is_os(PixmapPtr pix, rdpPixmapPtr priv) rdpup_end_update(); rdpup_switch_os_surface(-1); } + priv->use_count++; return 1; } } + priv->use_count++; return 0; } + priv->use_count++; return 1; } @@ -1035,7 +1038,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(®, NullBox, 0); RegionCopy(®, pOldRegion); RegionInit(&clip, NullBox, 0); @@ -1047,18 +1052,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(®); 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(®); - rdpup_send_area(0, box3->x1, box3->y1, + rdpup_send_area(10, box3->x1 + dx, box3->y1 + dy, box3->x2 - box3->x1, box3->y2 - box3->y1); } @@ -1073,6 +1088,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); @@ -1080,6 +1097,8 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion) for (i = 0; i < num_reg_rects; i++) { box2 = REGION_RECTS(®)[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, @@ -1092,6 +1111,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); @@ -1099,6 +1120,8 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion) for (i = num_reg_rects - 1; i >= 0; i--) { box2 = REGION_RECTS(®)[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, @@ -1113,9 +1136,6 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion) RegionUninit(®); RegionUninit(&clip); - g_pScreen->CopyWindow = g_rdpScreen.CopyWindow; - g_pScreen->CopyWindow(pWin, ptOldOrg, pOldRegion); - g_pScreen->CopyWindow = rdpCopyWindow; } /******************************************************************************/ diff --git a/xorg/X11R7.6/rdp/rdpinput.c b/xorg/X11R7.6/rdp/rdpinput.c index 39cd78dd..18e267b6 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 */ @@ -59,6 +65,12 @@ static int g_tab_down = 0; above *_down vars */ static int g_scroll_lock_down = 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) @@ -744,12 +756,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(); } @@ -779,6 +792,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); @@ -809,35 +823,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 < 5; 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 06c8bd73..b8a763a7 100644 --- a/xorg/X11R7.6/rdp/rdpup.c +++ b/xorg/X11R7.6/rdp/rdpup.c @@ -22,12 +22,23 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "rdp.h" #include "xrdp_rail.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_listen_sck = 0; static int g_sck = 0; static int g_sck_closed = 0; @@ -123,12 +134,67 @@ 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) { int index; + 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); @@ -466,6 +532,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 @@ -478,6 +572,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", @@ -507,6 +602,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); @@ -643,6 +760,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); @@ -781,6 +905,27 @@ 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, 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)); + + box.x1 = x; + box.y1 = y; + box.x2 = box.x1 + cx; + box.y2 = box.y1 + cy; + + RegionInit(®, &box, 0); + LLOGLN(10, ("< %d %d %d %d", box.x1, box.y1, box.x2, box.y2)); + RegionSubtract(g_shm_reg, g_shm_reg, ®); + RegionUninit(®); + + } else { rdpLog("unknown message type in rdpup_process_msg %d\n", msg_type); @@ -799,6 +944,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; } /******************************************************************************/ @@ -811,6 +960,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; } /******************************************************************************/ @@ -818,6 +971,7 @@ int rdpup_init(void) { char text[256]; + char *ptext; int i; if (!g_directory_exist("/tmp/.xrdp")) @@ -902,6 +1056,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; } @@ -940,6 +1127,16 @@ rdpup_check(void) g_begin = 0; g_con_number++; 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; + } } @@ -1559,11 +1756,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; @@ -1571,7 +1770,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)); @@ -1628,8 +1830,69 @@ 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 = 32; + 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); + 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(®, &box, 0); + RegionUnion(g_shm_reg, g_shm_reg, ®); + RegionUninit(®); + return; + } + + ly = y; while (ly < y + h) { lx = x; 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 99d5743b..081adf3c 100644 --- a/xrdp/xrdp.h +++ b/xrdp/xrdp.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 cac7f114..52022546 100644 --- a/xrdp/xrdp_cache.c +++ b/xrdp/xrdp_cache.c @@ -136,6 +136,10 @@ 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 == _b1->width && _b1->height == _b2->height + /*****************************************************************************/ /* returns cache id */ int APP_CC @@ -171,7 +175,8 @@ xrdp_cache_add_bitmap(struct xrdp_cache *self, struct xrdp_bitmap *bitmap, { #ifdef USE_CRC - if (xrdp_bitmap_compare_with_crc(self->bitmap_items[i][j].bitmap, bitmap)) + //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 @@ -191,7 +196,8 @@ xrdp_cache_add_bitmap(struct xrdp_cache *self, struct xrdp_bitmap *bitmap, { #ifdef USE_CRC - if (xrdp_bitmap_compare_with_crc(self->bitmap_items[i][j].bitmap, bitmap)) + //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 @@ -211,7 +217,8 @@ xrdp_cache_add_bitmap(struct xrdp_cache *self, struct xrdp_bitmap *bitmap, { #ifdef USE_CRC - if (xrdp_bitmap_compare_with_crc(self->bitmap_items[i][j].bitmap, bitmap)) + //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 0a79810b..10bea994 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -797,11 +797,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; @@ -1486,6 +1488,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); @@ -2206,7 +2209,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); diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index bfcc7548..9dfbb06b 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) { @@ -20,6 +20,9 @@ #include "xup.h" +#include <sys/ipc.h> +#include <sys/shm.h> + /******************************************************************************/ /* returns error */ int DEFAULT_CC @@ -512,7 +515,33 @@ 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 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, 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; @@ -536,6 +565,9 @@ 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; char *bmpdata; char cur_data[32 * (32 * 3)]; char cur_mask[32 * (32 / 8)]; @@ -661,6 +693,44 @@ 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, 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); + break; + default: g_writeln("lib_mod_process_orders: unknown order type %d", type); rv = 0; @@ -139,4 +139,6 @@ struct mod tbus sck_obj; int shift_state; struct xrdp_client_info client_info; + int screen_shmem_id; + char *screen_shmem_pixels; }; |