summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsorg71 <jsorg71>2005-01-07 01:21:09 +0000
committerjsorg71 <jsorg71>2005-01-07 01:21:09 +0000
commite14b8365fab73f97d2c55be746eb98a7044639d8 (patch)
tree58f849cdd8d8bbe7b994ea19f3d9edd77b7eb477
parent9611a5f111a54492ff12f1c864736bec46c8d7cb (diff)
downloadxrdp-proprietary-e14b8365fab73f97d2c55be746eb98a7044639d8.tar.gz
xrdp-proprietary-e14b8365fab73f97d2c55be746eb98a7044639d8.zip
commit bitmap compres work and moved some files around
-rw-r--r--xrdp/Makefile11
-rw-r--r--xrdp/xrdp.h82
-rw-r--r--xrdp/xrdp.ini16
-rw-r--r--xrdp/xrdp_bitmap.c4
-rw-r--r--xrdp/xrdp_bitmap_compress.c879
-rw-r--r--xrdp/xrdp_defines.h8
-rw-r--r--xrdp/xrdp_login_wnd.c78
-rw-r--r--xrdp/xrdp_process.c11
-rw-r--r--xrdp/xrdp_types.h37
-rw-r--r--xrdp/xrdp_wm.c195
10 files changed, 1126 insertions, 195 deletions
diff --git a/xrdp/Makefile b/xrdp/Makefile
index c26d1852..55f8d488 100644
--- a/xrdp/Makefile
+++ b/xrdp/Makefile
@@ -1,12 +1,13 @@
-XRDPOBJ = xrdp.o os_calls.o xrdp_tcp.o xrdp_iso.o xrdp_mcs.o xrdp_sec.o \
+XRDPOBJ = ../common/os_calls.o \
+ xrdp.o xrdp_tcp.o xrdp_iso.o xrdp_mcs.o xrdp_sec.o \
xrdp_rdp.o xrdp_process.o xrdp_listen.o xrdp_orders.o \
xrdp_bitmap.o xrdp_wm.o xrdp_painter.o xrdp_list.o \
xrdp_region.o xrdp_cache.o xrdp_font.o funcs.o \
- xrdp_login_wnd.o xrdp_file.o
+ xrdp_login_wnd.o xrdp_file.o xrdp_bitmap_compress.o
-#CFLAGS = -Wall -O2 -DXRDP_DEBUG
-CFLAGS = -Wall -O2
+#CFLAGS = -Wall -O2 -I../common -DXRDP_DEBUG
+CFLAGS = -Wall -O2 -I../common
LDFLAGS = -L /usr/gnu/lib
LIBS = -lpthread -lcrypto
CC = gcc
@@ -17,4 +18,4 @@ xrdp: $(XRDPOBJ)
$(CC) $(LDFLAGS) -o xrdp $(XRDPOBJ) $(LIBS)
clean:
- rm -f *.o xrdp
+ rm -f $(XRDPOBJ) xrdp
diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h
index c8c199ec..8a01e8db 100644
--- a/xrdp/xrdp.h
+++ b/xrdp/xrdp.h
@@ -20,86 +20,13 @@
*/
-/* check endianess */
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define L_ENDIAN
-#elif __BYTE_ORDER == __BIG_ENDIAN
-#define B_ENDIAN
-#endif
-/* check if we need to align data */
-#if defined(__sparc__) || defined(__alpha__) || defined(__hppa__) || \
- defined(__AIX__) || defined(__PPC__) || defined(__mips__) || \
- defined(__ia64__)
-#define NEED_ALIGN
-#endif
/* include other h files */
+#include "arch.h"
#include "parse.h"
#include "xrdp_types.h"
#include "constants.h"
#include "xrdp_defines.h"
-
-/* os_calls.c */
-int g_init_system(void);
-int g_exit_system(void);
-void g_printf(char *format, ...);
-void g_hexdump(char* p, int len);
-void* g_malloc(int size, int zero);
-void* g_malloc1(int size, int zero);
-void g_free(void* ptr);
-void g_free1(void* ptr);
-void g_memset(void* ptr, int val, int size);
-void g_memcpy(void* d_ptr, const void* s_ptr, int size);
-int g_getchar(void);
-int g_tcp_socket(void);
-int g_tcp_local_socket(void);
-void g_tcp_close(int sck);
-int g_tcp_connect(int sck, char* address, char* port);
-int g_tcp_set_non_blocking(int sck);
-int g_tcp_bind(int sck, char* port);
-int g_tcp_local_bind(int sck, char* port);
-int g_tcp_listen(int sck);
-int g_tcp_accept(int sck);
-int g_tcp_recv(int sck, void* ptr, int len, int flags);
-int g_tcp_send(int sck, void* ptr, int len, int flags);
-int g_tcp_last_error_would_block(int sck);
-int g_tcp_select(int sck1, int sck2);
-int g_is_term(void);
-void g_set_term(int in_val);
-void g_sleep(int msecs);
-int g_thread_create(THREAD_RV (THREAD_CC * start_routine)(void*), void* arg);
-void* g_rc4_info_create(void);
-void g_rc4_info_delete(void* rc4_info);
-void g_rc4_set_key(void* rc4_info, char* key, int len);
-void g_rc4_crypt(void* rc4_info, char* data, int len);
-void* g_sha1_info_create(void);
-void g_sha1_info_delete(void* sha1_info);
-void g_sha1_clear(void* sha1_info);
-void g_sha1_transform(void* sha1_info, char* data, int len);
-void g_sha1_complete(void* sha1_info, char* data);
-void* g_md5_info_create(void);
-void g_md5_info_delete(void* md5_info);
-void g_md5_clear(void* md5_info);
-void g_md5_transform(void* md5_info, char* data, int len);
-void g_md5_complete(void* md5_info, char* data);
-int g_mod_exp(char* out, char* in, char* mod, char* exp);
-void g_random(char* data, int len);
-int g_abs(int i);
-int g_memcmp(void* s1, void* s2, int len);
-int g_file_open(char* file_name);
-int g_file_close(int fd);
-int g_file_read(int fd, char* ptr, int len);
-int g_file_write(int fd, char* ptr, int len);
-int g_file_seek(int fd, int offset);
-int g_file_lock(int fd, int start, int len);
-int g_strlen(char* text);
-char* g_strcpy(char* dest, char* src);
-char* g_strncpy(char* dest, char* src, int len);
-char* g_strcat(char* dest, char* src);
-char* g_strdup(char* in);
-int g_strcmp(char* c1, char* c2);
-int g_load_library(char* in);
-int g_free_library(int lib);
-void* g_get_proc_address(int lib, char* name);
+#include "os_calls.h"
/* xrdp_tcp.c */
struct xrdp_tcp* xrdp_tcp_create(struct xrdp_iso* owner);
@@ -322,3 +249,8 @@ int xrdp_login_wnd_create(struct xrdp_wm* self);
int xrdp_file_read_sections(int fd, struct xrdp_list* names);
int xrdp_file_read_section(int fd, char* section, struct xrdp_list* names,
struct xrdp_list* values);
+
+/* xrdp_bitmap_compress.c */
+int xrdp_bitmap_compress(char* in_data, int width, int height,
+ struct stream* s, int bpp, int byte_limit,
+ int start_line, struct stream* temp);
diff --git a/xrdp/xrdp.ini b/xrdp/xrdp.ini
index e85f9e6d..db1562fb 100644
--- a/xrdp/xrdp.ini
+++ b/xrdp/xrdp.ini
@@ -2,19 +2,19 @@
[globals]
[vnc1]
-name=vnc test
+name=self:2
lib=../vnc/libvnc.so
auth=local
ip=127.0.0.1
-port=5901
-user=n/a
+port=5902
+username=ask
password=master
[vnc2]
-name=vnc test2
+name=self:3
lib=../vnc/libvnc.so
auth=local
-ip=205.5.61.3
-port=5900
-user=n/a
-password=ecs
+ip=127.0.0.1
+port=5903
+username=n/a
+password=master
diff --git a/xrdp/xrdp_bitmap.c b/xrdp/xrdp_bitmap.c
index 21264e6c..18803a6a 100644
--- a/xrdp/xrdp_bitmap.c
+++ b/xrdp/xrdp_bitmap.c
@@ -130,7 +130,9 @@ struct xrdp_bitmap* xrdp_bitmap_get_child_by_id(struct xrdp_bitmap* self,
{
b = (struct xrdp_bitmap*)xrdp_list_get_item(self->child_list, i);
if (b->id == id)
+ {
return b;
+ }
}
return 0;
}
@@ -591,7 +593,7 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
{
if (rect != 0)
{
- self->wm->mod->mod_invalidate((int)self->wm->mod,
+ self->wm->mod->mod_invalidate(self->wm->mod,
rect->left, rect->top,
rect->right - rect->left,
rect->bottom - rect->top);
diff --git a/xrdp/xrdp_bitmap_compress.c b/xrdp/xrdp_bitmap_compress.c
new file mode 100644
index 00000000..00d53025
--- /dev/null
+++ b/xrdp/xrdp_bitmap_compress.c
@@ -0,0 +1,879 @@
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ xrdp: A Remote Desktop Protocol server.
+ Copyright (C) Jay Sorg 2004
+
+ bitmap compressor
+
+*/
+
+#include "xrdp.h"
+
+/*****************************************************************************/
+#define IN_PIXEL8(in_ptr, in_x, in_y, in_w, in_last_pixel, in_pixel); \
+{ \
+ if (in_ptr == 0) \
+ { \
+ in_pixel = 0; \
+ } \
+ else if (in_x < in_w) \
+ { \
+ in_pixel = GETPIXEL8(in_ptr, in_x, in_y, in_w); \
+ } \
+ else \
+ { \
+ in_pixel = in_last_pixel; \
+ } \
+}
+
+/*****************************************************************************/
+#define IN_PIXEL16(in_ptr, in_x, in_y, in_w, in_last_pixel, in_pixel); \
+{ \
+ if (in_ptr == 0) \
+ { \
+ in_pixel = 0; \
+ } \
+ else if (in_x < in_w) \
+ { \
+ in_pixel = GETPIXEL16(in_ptr, in_x, in_y, in_w); \
+ } \
+ else \
+ { \
+ in_pixel = in_last_pixel; \
+ } \
+}
+
+/*****************************************************************************/
+/* color */
+#define OUT_COLOR_COUNT1(in_count, in_s, in_data) \
+{ \
+ if (in_count > 0) \
+ { \
+ if (in_count < 32) \
+ { \
+ temp = (0x3 << 5) | in_count; \
+ out_uint8(in_s, temp); \
+ out_uint8(in_s, in_data); \
+ } \
+ else if (in_count < 256 + 32) \
+ { \
+ out_uint8(in_s, 0x60); \
+ temp = in_count - 32; \
+ out_uint8(in_s, temp); \
+ out_uint8(in_s, in_data); \
+ } \
+ else \
+ { \
+ out_uint8(in_s, 0xf3); \
+ out_uint16_le(in_s, in_count); \
+ out_uint8(in_s, in_data); \
+ } \
+ } \
+ in_count = 0; \
+}
+
+/*****************************************************************************/
+/* color */
+#define OUT_COLOR_COUNT2(in_count, in_s, in_data) \
+{ \
+ if (in_count > 0) \
+ { \
+ if (in_count < 32) \
+ { \
+ temp = (0x3 << 5) | in_count; \
+ out_uint8(in_s, temp); \
+ out_uint16_le(in_s, in_data); \
+ } \
+ else if (in_count < 256 + 32) \
+ { \
+ out_uint8(in_s, 0x60); \
+ temp = in_count - 32; \
+ out_uint8(in_s, temp); \
+ out_uint16_le(in_s, in_data); \
+ } \
+ else \
+ { \
+ out_uint8(in_s, 0xf3); \
+ out_uint16_le(in_s, in_count); \
+ out_uint16_le(in_s, in_data); \
+ } \
+ } \
+ in_count = 0; \
+}
+
+/*****************************************************************************/
+/* copy */
+#define OUT_COPY_COUNT1(in_count, in_s, in_data) \
+{ \
+ if (in_count > 0) \
+ { \
+ if (in_count < 32) \
+ { \
+ temp = (0x4 << 5) | in_count; \
+ out_uint8(in_s, temp); \
+ out_uint8a(in_s, in_data->data, in_count); \
+ } \
+ else if (in_count < 256 + 32) \
+ { \
+ out_uint8(in_s, 0x80); \
+ temp = in_count - 32; \
+ out_uint8(in_s, temp); \
+ out_uint8a(in_s, in_data->data, in_count); \
+ } \
+ else \
+ { \
+ out_uint8(in_s, 0xf4); \
+ out_uint16_le(in_s, in_count); \
+ out_uint8a(in_s, in_data->data, in_count); \
+ } \
+ } \
+ in_count = 0; \
+ init_stream(in_data, 0); \
+}
+
+/*****************************************************************************/
+/* copy */
+#define OUT_COPY_COUNT2(in_count, in_s, in_data) \
+{ \
+ if (in_count > 0) \
+ { \
+ if (in_count < 32) \
+ { \
+ temp = (0x4 << 5) | in_count; \
+ out_uint8(in_s, temp); \
+ temp = in_count * 2; \
+ out_uint8a(in_s, in_data->data, temp); \
+ } \
+ else if (in_count < 256 + 32) \
+ { \
+ out_uint8(in_s, 0x80); \
+ temp = in_count - 32; \
+ out_uint8(in_s, temp); \
+ temp = in_count * 2; \
+ out_uint8a(in_s, in_data->data, temp); \
+ } \
+ else \
+ { \
+ out_uint8(in_s, 0xf4); \
+ out_uint16_le(in_s, in_count); \
+ temp = in_count * 2; \
+ out_uint8a(in_s, in_data->data, temp); \
+ } \
+ } \
+ in_count = 0; \
+ init_stream(in_data, 0); \
+}
+
+/*****************************************************************************/
+/* bicolor */
+#define OUT_BICOLOR_COUNT1(in_count, in_s, in_color1, in_color2) \
+{ \
+ if (in_count > 0) \
+ { \
+ if (in_count / 2 < 16) \
+ { \
+ temp = (0xe << 4) | (in_count / 2); \
+ out_uint8(in_s, temp); \
+ out_uint8(in_s, in_color1); \
+ out_uint8(in_s, in_color2); \
+ } \
+ else if (in_count / 2 < 256 + 16) \
+ { \
+ out_uint8(in_s, 0xe0); \
+ temp = in_count / 2 - 16; \
+ out_uint8(in_s, temp); \
+ out_uint8(in_s, in_color1); \
+ out_uint8(in_s, in_color2); \
+ } \
+ else \
+ { \
+ out_uint8(in_s, 0xf8); \
+ temp = in_count / 2; \
+ out_uint16_le(in_s, temp); \
+ out_uint8(in_s, in_color1); \
+ out_uint8(in_s, in_color2); \
+ } \
+ } \
+ in_count = 0; \
+}
+
+/*****************************************************************************/
+/* bicolor */
+#define OUT_BICOLOR_COUNT2(in_count, in_s, in_color1, in_color2) \
+{ \
+ if (in_count > 0) \
+ { \
+ if (in_count / 2 < 16) \
+ { \
+ temp = (0xe << 4) | (in_count / 2); \
+ out_uint8(in_s, temp); \
+ out_uint16_le(in_s, in_color1); \
+ out_uint16_le(in_s, in_color2); \
+ } \
+ else if (in_count / 2 < 256 + 16) \
+ { \
+ out_uint8(in_s, 0xe0); \
+ temp = in_count / 2 - 16; \
+ out_uint8(in_s, temp); \
+ out_uint16_le(in_s, in_color1); \
+ out_uint16_le(in_s, in_color2); \
+ } \
+ else \
+ { \
+ out_uint8(in_s, 0xf8); \
+ temp = in_count / 2; \
+ out_uint16_le(in_s, temp); \
+ out_uint16_le(in_s, in_color1); \
+ out_uint16_le(in_s, in_color2); \
+ } \
+ } \
+ in_count = 0; \
+}
+
+/*****************************************************************************/
+/* fill */
+#define OUT_FILL_COUNT1(in_count, in_s) \
+{ \
+ if (in_count > 0) \
+ { \
+ if (in_count < 32) \
+ { \
+ out_uint8(in_s, in_count); \
+ } \
+ else if (in_count < 256 + 32) \
+ { \
+ out_uint8(in_s, 0x0); \
+ temp = in_count - 32; \
+ out_uint8(in_s, temp); \
+ } \
+ else \
+ { \
+ out_uint8(in_s, 0xf0); \
+ out_uint16_le(in_s, in_count); \
+ } \
+ } \
+ in_count = 0; \
+}
+
+/*****************************************************************************/
+/* fill */
+#define OUT_FILL_COUNT2(in_count, in_s) \
+{ \
+ if (in_count > 0) \
+ { \
+ if (in_count < 32) \
+ { \
+ out_uint8(in_s, in_count); \
+ } \
+ else if (in_count < 256 + 32) \
+ { \
+ out_uint8(in_s, 0x0); \
+ temp = in_count - 32; \
+ out_uint8(in_s, temp); \
+ } \
+ else \
+ { \
+ out_uint8(in_s, 0xf0); \
+ out_uint16_le(in_s, in_count); \
+ } \
+ } \
+ in_count = 0; \
+}
+
+/*****************************************************************************/
+/* mix */
+#define OUT_MIX_COUNT1(in_count, in_s) \
+{ \
+ if (in_count > 0) \
+ { \
+ if (in_count < 32) \
+ { \
+ temp = (0x1 << 5) | in_count; \
+ out_uint8(in_s, temp); \
+ } \
+ else if (in_count < 256 + 32) \
+ { \
+ out_uint8(in_s, 0x20); \
+ temp = in_count - 32; \
+ out_uint8(in_s, temp); \
+ } \
+ else \
+ { \
+ out_uint8(in_s, 0xf1); \
+ out_uint16_le(in_s, in_count); \
+ } \
+ } \
+ in_count = 0; \
+}
+
+/*****************************************************************************/
+/* mix */
+#define OUT_MIX_COUNT2(in_count, in_s) \
+{ \
+ if (in_count > 0) \
+ { \
+ if (in_count < 32) \
+ { \
+ temp = (0x1 << 5) | in_count; \
+ out_uint8(in_s, temp); \
+ } \
+ else if (in_count < 256 + 32) \
+ { \
+ out_uint8(in_s, 0x20); \
+ temp = in_count - 32; \
+ out_uint8(in_s, temp); \
+ } \
+ else \
+ { \
+ out_uint8(in_s, 0xf1); \
+ out_uint16_le(in_s, in_count); \
+ } \
+ } \
+ in_count = 0; \
+}
+
+/*****************************************************************************/
+/* fom */
+#define OUT_FOM_COUNT1(in_count, in_s, in_mask, in_mask_len) \
+{ \
+ if (in_count > 0) \
+ { \
+ if ((in_count % 8) == 0 && in_count < 249) \
+ { \
+ temp = (0x2 << 5) | (in_count / 8); \
+ out_uint8(in_s, temp); \
+ out_uint8a(in_s, in_mask, in_mask_len); \
+ } \
+ else if (in_count < 256) \
+ { \
+ out_uint8(in_s, 0x40); \
+ temp = in_count - 1; \
+ out_uint8(in_s, temp); \
+ out_uint8a(in_s, in_mask, in_mask_len); \
+ } \
+ else \
+ { \
+ out_uint8(in_s, 0xf2); \
+ out_uint16_le(in_s, in_count); \
+ out_uint8a(in_s, in_mask, in_mask_len); \
+ } \
+ } \
+ in_count = 0; \
+}
+
+/*****************************************************************************/
+/* fom */
+#define OUT_FOM_COUNT2(in_count, in_s, in_mask, in_mask_len) \
+{ \
+ if (in_count > 0) \
+ { \
+ if ((in_count % 8) == 0 && in_count < 249) \
+ { \
+ temp = (0x2 << 5) | (in_count / 8); \
+ out_uint8(in_s, temp); \
+ out_uint8a(in_s, in_mask, in_mask_len); \
+ } \
+ else if (in_count < 256) \
+ { \
+ out_uint8(in_s, 0x40); \
+ temp = in_count - 1; \
+ out_uint8(in_s, temp); \
+ out_uint8a(in_s, in_mask, in_mask_len); \
+ } \
+ else \
+ { \
+ out_uint8(in_s, 0xf2); \
+ out_uint16_le(in_s, in_count); \
+ out_uint8a(in_s, in_mask, in_mask_len); \
+ } \
+ } \
+ in_count = 0; \
+}
+
+/*****************************************************************************/
+#define TEST_FILL \
+((last_line == 0 && pixel == 0) || \
+ (last_line != 0 && pixel == ypixel))
+#define TEST_MIX \
+((last_line == 0 && pixel == mix) || \
+ (last_line != 0 && pixel == (ypixel ^ mix)))
+#define TEST_FOM (TEST_FILL || TEST_MIX)
+#define TEST_COLOR (pixel == last_pixel)
+#define TEST_BICOLOR \
+( \
+ (pixel != last_pixel) && \
+ ( \
+ (!bicolor_spin && pixel == bicolor1 && last_pixel == bicolor2) || \
+ (bicolor_spin && pixel == bicolor2 && last_pixel == bicolor1) \
+ ) \
+)
+#define RESET_COUNTS \
+{ \
+ bicolor_count = 0; \
+ fill_count = 0; \
+ color_count = 0; \
+ mix_count = 0; \
+ fom_count = 0; \
+ fom_mask_len = 0; \
+ bicolor_spin = 0; \
+}
+
+/*****************************************************************************/
+int xrdp_bitmap_compress(char* in_data, int width, int height,
+ struct stream* s, int bpp, int byte_limit,
+ int start_line, struct stream* temp_s)
+{
+ char* line;
+ char* last_line;
+ char fom_mask[8192];
+ int lines_sent;
+ int pixel;
+ int e;
+ int count;
+ int color_count;
+ int last_pixel;
+ int bicolor_count;
+ int bicolor1;
+ int bicolor2;
+ int bicolor_spin;
+ int end;
+ int i;
+ int out_count;
+ int ypixel;
+ int last_ypixel;
+ int fill_count;
+ int mix_count;
+ int mix;
+ int fom_count;
+ int fom_mask_len;
+ int temp; /* used in macros */
+
+ init_stream(temp_s, 0);
+ e = width % 4;
+ if (e != 0)
+ {
+ e = 4 - e;
+ }
+ fom_mask_len = 0;
+ last_line = 0;
+ lines_sent = 0;
+ end = width + e;
+ count = 0;
+ color_count = 0;
+ last_pixel = 0;
+ last_ypixel = 0;
+ bicolor_count = 0;
+ bicolor1 = 0;
+ bicolor2 = 0;
+ bicolor_spin = 0;
+ fill_count = 0;
+ mix_count = 0;
+ fom_count = 0;
+ if (bpp == 8)
+ {
+ mix = 0xff;
+ out_count = end;
+ line = in_data + width * start_line;
+ while (start_line >= 0 && out_count < 32768)
+ {
+ i = (s->p - s->data) + count;
+ if (i - color_count >= byte_limit &&
+ i - bicolor_count >= byte_limit &&
+ i - fill_count >= byte_limit)
+ {
+ break;
+ }
+ out_count += end;
+ for (i = 0; i < end; i++)
+ {
+ /* read next pixel */
+ IN_PIXEL8(line, i, 0, width, last_pixel, pixel);
+ IN_PIXEL8(last_line, i, 0, width, last_ypixel, ypixel);
+ if (!TEST_FILL)
+ {
+ if (fill_count > 3 && fill_count > color_count &&
+ fill_count > bicolor_count)
+ {
+ count -= fill_count;
+ OUT_COPY_COUNT1(count, s, temp_s);
+ OUT_FILL_COUNT1(fill_count, s);
+ RESET_COUNTS;
+ }
+ fill_count = 0;
+ }
+ if (!TEST_COLOR)
+ {
+ if (color_count > 3 && color_count > fill_count &&
+ color_count > bicolor_count)
+ {
+ count -= color_count;
+ OUT_COPY_COUNT1(count, s, temp_s);
+ OUT_COLOR_COUNT1(color_count, s, last_pixel);
+ RESET_COUNTS;
+ }
+ color_count = 0;
+ }
+ if (!TEST_BICOLOR)
+ {
+ if (bicolor_count > 3 && bicolor_count > fill_count &&
+ bicolor_count > color_count)
+ {
+ if ((bicolor_count % 2) == 0)
+ {
+ count -= bicolor_count;
+ OUT_COPY_COUNT1(count, s, temp_s);
+ OUT_BICOLOR_COUNT1(bicolor_count, s, bicolor1, bicolor2);
+ }
+ else
+ {
+ bicolor_count--;
+ count -= bicolor_count;
+ OUT_COPY_COUNT1(count, s, temp_s);
+ OUT_BICOLOR_COUNT1(bicolor_count, s, bicolor2, bicolor1);
+ }
+ RESET_COUNTS;
+ }
+ bicolor_count = 0;
+ bicolor1 = last_pixel;
+ bicolor2 = pixel;
+ bicolor_spin = 0;
+ }
+ if (TEST_FILL && last_line != 0) /* ms client don't like fill on */
+ { /* 1st line */
+ fill_count++;
+ }
+ if (TEST_COLOR)
+ {
+ color_count++;
+ }
+ if (TEST_BICOLOR)
+ {
+ if (bicolor_spin == 0 && pixel == bicolor1)
+ {
+ bicolor_spin = 1;
+ bicolor_count++;
+ }
+ else if (bicolor_spin == 1 && pixel == bicolor2)
+ {
+ bicolor_spin = 0;
+ bicolor_count++;
+ }
+ }
+ out_uint8(temp_s, pixel);
+ count++;
+ last_pixel = pixel;
+ last_ypixel = ypixel;
+ }
+ last_line = line;
+ line = line - width;
+ start_line--;
+ lines_sent++;
+ }
+ if (fill_count > 3)
+ {
+ count -= fill_count;
+ OUT_COPY_COUNT1(count, s, temp_s);
+ OUT_FILL_COUNT1(fill_count, s);
+ }
+ else if (color_count > 3)
+ {
+ count -= color_count;
+ OUT_COPY_COUNT1(count, s, temp_s);
+ OUT_COLOR_COUNT1(color_count, s, last_pixel);
+ }
+ else if (bicolor_count > 3)
+ {
+ if ((bicolor_count % 2) == 0)
+ {
+ count -= bicolor_count;
+ OUT_COPY_COUNT1(count, s, temp_s);
+ OUT_BICOLOR_COUNT1(bicolor_count, s, bicolor1, bicolor2);
+ }
+ else
+ {
+ bicolor_count--;
+ count -= bicolor_count;
+ OUT_COPY_COUNT1(count, s, temp_s);
+ OUT_BICOLOR_COUNT1(bicolor_count, s, bicolor2, bicolor1);
+ }
+ }
+ else
+ {
+ OUT_COPY_COUNT1(count, s, temp_s);
+ }
+ }
+ else if (bpp == 16)
+ {
+ mix = 0xffff;
+ out_count = end * 2;
+ line = in_data + width * start_line * 2;
+ while (start_line >= 0 && out_count < 32768)
+ {
+ i = (s->p - s->data) + count * 2;
+ if (i - (color_count * 2) >= byte_limit &&
+ i - (bicolor_count * 2) >= byte_limit &&
+ i - (fill_count * 2) >= byte_limit &&
+ i - (mix_count * 2) >= byte_limit &&
+ i - (fom_count * 2) >= byte_limit)
+ {
+ break;
+ }
+ out_count += end * 2;
+ for (i = 0; i < end; i++)
+ {
+ /* read next pixel */
+ IN_PIXEL16(line, i, 0, width, last_pixel, pixel);
+ IN_PIXEL16(last_line, i, 0, width, last_ypixel, ypixel);
+ if (!TEST_FILL)
+ {
+ if (fill_count > 3 &&
+ fill_count >= color_count &&
+ fill_count >= bicolor_count &&
+ fill_count >= mix_count &&
+ fill_count >= fom_count)
+ {
+ count -= fill_count;
+ OUT_COPY_COUNT2(count, s, temp_s);
+ OUT_FILL_COUNT2(fill_count, s);
+ RESET_COUNTS;
+ }
+ fill_count = 0;
+ }
+ if (!TEST_MIX)
+ {
+ if (mix_count > 3 &&
+ mix_count >= fill_count &&
+ mix_count >= bicolor_count &&
+ mix_count >= color_count &&
+ mix_count >= fom_count)
+ {
+ count -= mix_count;
+ OUT_COPY_COUNT2(count, s, temp_s);
+ OUT_MIX_COUNT2(mix_count, s);
+ RESET_COUNTS;
+ }
+ mix_count = 0;
+ }
+ if (!TEST_COLOR)
+ {
+ if (color_count > 3 &&
+ color_count >= fill_count &&
+ color_count >= bicolor_count &&
+ color_count >= mix_count &&
+ color_count >= fom_count)
+ {
+ count -= color_count;
+ OUT_COPY_COUNT2(count, s, temp_s);
+ OUT_COLOR_COUNT2(color_count, s, last_pixel);
+ RESET_COUNTS;
+ }
+ color_count = 0;
+ }
+ if (!TEST_BICOLOR)
+ {
+ if (bicolor_count > 3 &&
+ bicolor_count >= fill_count &&
+ bicolor_count >= color_count &&
+ bicolor_count >= mix_count &&
+ bicolor_count >= fom_count)
+ {
+ if ((bicolor_count % 2) == 0)
+ {
+ count -= bicolor_count;
+ OUT_COPY_COUNT2(count, s, temp_s);
+ OUT_BICOLOR_COUNT2(bicolor_count, s, bicolor1, bicolor2);
+ }
+ else
+ {
+ bicolor_count--;
+ count -= bicolor_count;
+ OUT_COPY_COUNT2(count, s, temp_s);
+ OUT_BICOLOR_COUNT2(bicolor_count, s, bicolor2, bicolor1);
+ }
+ RESET_COUNTS;
+ }
+ bicolor_count = 0;
+ bicolor1 = last_pixel;
+ bicolor2 = pixel;
+ bicolor_spin = 0;
+ }
+ if (!TEST_FOM)
+ {
+ if (fom_count > 3 &&
+ fom_count >= fill_count &&
+ fom_count >= color_count &&
+ fom_count >= mix_count &&
+ fom_count >= bicolor_count)
+ {
+ count -= fom_count;
+ OUT_COPY_COUNT2(count, s, temp_s);
+ OUT_FOM_COUNT2(fom_count, s, fom_mask, fom_mask_len);
+ RESET_COUNTS;
+ }
+ fom_count = 0;
+ fom_mask_len = 0;
+ }
+ if (TEST_FILL)
+ {
+ fill_count++;
+ }
+ if (TEST_MIX)
+ {
+ mix_count++;
+ }
+ if (TEST_COLOR)
+ {
+ color_count++;
+ }
+ if (TEST_BICOLOR)
+ {
+ bicolor_spin = !bicolor_spin;
+ bicolor_count++;
+ }
+ if (TEST_FOM)
+ {
+ if ((fom_count % 8) == 0)
+ {
+ fom_mask[fom_mask_len] = 0;
+ fom_mask_len++;
+ }
+ if (pixel == (ypixel ^ mix))
+ {
+ fom_mask[fom_mask_len - 1] |= (1 << (fom_count % 8));
+ }
+ fom_count++;
+ }
+ out_uint16_le(temp_s, pixel);
+ count++;
+ last_pixel = pixel;
+ last_ypixel = ypixel;
+ }
+ /* can't take fix, mix, or fom past first line */
+ if (last_line == 0)
+ {
+ if (fill_count > 3 &&
+ fill_count >= color_count &&
+ fill_count >= bicolor_count &&
+ fill_count >= mix_count &&
+ fill_count >= fom_count)
+ {
+ count -= fill_count;
+ OUT_COPY_COUNT2(count, s, temp_s);
+ OUT_FILL_COUNT2(fill_count, s);
+ RESET_COUNTS;
+ }
+ fill_count = 0;
+ if (mix_count > 3 &&
+ mix_count >= fill_count &&
+ mix_count >= bicolor_count &&
+ mix_count >= color_count &&
+ mix_count >= fom_count)
+ {
+ count -= mix_count;
+ OUT_COPY_COUNT2(count, s, temp_s);
+ OUT_MIX_COUNT2(mix_count, s);
+ RESET_COUNTS;
+ }
+ mix_count = 0;
+ if (fom_count > 3 &&
+ fom_count >= fill_count &&
+ fom_count >= color_count &&
+ fom_count >= mix_count &&
+ fom_count >= bicolor_count)
+ {
+ count -= fom_count;
+ OUT_COPY_COUNT2(count, s, temp_s);
+ OUT_FOM_COUNT2(fom_count, s, fom_mask, fom_mask_len);
+ RESET_COUNTS;
+ }
+ fom_count = 0;
+ fom_mask_len = 0;
+ }
+ last_line = line;
+ line = line - width * 2;
+ start_line--;
+ lines_sent++;
+ }
+ if (fill_count > 3 &&
+ fill_count >= color_count &&
+ fill_count >= bicolor_count &&
+ fill_count >= mix_count &&
+ fill_count >= fom_count)
+ {
+ count -= fill_count;
+ OUT_COPY_COUNT2(count, s, temp_s);
+ OUT_FILL_COUNT2(fill_count, s);
+ }
+ else if (mix_count > 3 &&
+ mix_count >= color_count &&
+ mix_count >= bicolor_count &&
+ mix_count >= fill_count &&
+ mix_count >= fom_count)
+ {
+ count -= mix_count;
+ OUT_COPY_COUNT2(count, s, temp_s);
+ OUT_MIX_COUNT2(mix_count, s);
+ }
+ else if (color_count > 3 &&
+ color_count >= mix_count &&
+ color_count >= bicolor_count &&
+ color_count >= fill_count &&
+ color_count >= fom_count)
+ {
+ count -= color_count;
+ OUT_COPY_COUNT2(count, s, temp_s);
+ OUT_COLOR_COUNT2(color_count, s, last_pixel);
+ }
+ else if (bicolor_count > 3 &&
+ bicolor_count >= mix_count &&
+ bicolor_count >= color_count &&
+ bicolor_count >= fill_count &&
+ bicolor_count >= fom_count)
+ {
+ if ((bicolor_count % 2) == 0)
+ {
+ count -= bicolor_count;
+ OUT_COPY_COUNT2(count, s, temp_s);
+ OUT_BICOLOR_COUNT2(bicolor_count, s, bicolor1, bicolor2);
+ }
+ else
+ {
+ bicolor_count--;
+ count -= bicolor_count;
+ OUT_COPY_COUNT2(count, s, temp_s);
+ OUT_BICOLOR_COUNT2(bicolor_count, s, bicolor2, bicolor1);
+ }
+ count -= bicolor_count;
+ OUT_COPY_COUNT2(count, s, temp_s);
+ OUT_BICOLOR_COUNT2(bicolor_count, s, bicolor1, bicolor2);
+ }
+ else if (fom_count > 3 &&
+ fom_count >= mix_count &&
+ fom_count >= color_count &&
+ fom_count >= fill_count &&
+ fom_count >= bicolor_count)
+ {
+ count -= fom_count;
+ OUT_COPY_COUNT2(count, s, temp_s);
+ OUT_FOM_COUNT2(fom_count, s, fom_mask, fom_mask_len);
+ }
+ else
+ {
+ OUT_COPY_COUNT2(count, s, temp_s);
+ }
+ }
+ return lines_sent;
+}
diff --git a/xrdp/xrdp_defines.h b/xrdp/xrdp_defines.h
index 8c26cff8..9f292c6c 100644
--- a/xrdp/xrdp_defines.h
+++ b/xrdp/xrdp_defines.h
@@ -51,11 +51,3 @@
#define COLOR24(r, g, b) ((r) | ((g) << 8) | ((b) << 16))
/* font macros */
#define FONT_DATASIZE(f) ((((f)->height * (((f)->width + 7) / 8)) + 3) & ~3);
-/* defines for thread creation factor function */
-#ifdef _WIN32
-#define THREAD_RV unsigned long
-#define THREAD_CC __stdcall
-#else
-#define THREAD_RV void*
-#define THREAD_CC
-#endif
diff --git a/xrdp/xrdp_login_wnd.c b/xrdp/xrdp_login_wnd.c
index b6d873ac..c6070870 100644
--- a/xrdp/xrdp_login_wnd.c
+++ b/xrdp/xrdp_login_wnd.c
@@ -72,13 +72,11 @@ logging on.");
}
/*****************************************************************************/
-int server_begin_update(int handle)
+int server_begin_update(struct xrdp_mod* mod)
{
- struct xrdp_mod* mod;
struct xrdp_wm* wm;
struct xrdp_painter* p;
- mod = (struct xrdp_mod*)handle;
wm = (struct xrdp_wm*)mod->wm;
p = xrdp_painter_create(wm);
xrdp_painter_begin_update(p);
@@ -87,12 +85,10 @@ int server_begin_update(int handle)
}
/*****************************************************************************/
-int server_end_update(int handle)
+int server_end_update(struct xrdp_mod* mod)
{
- struct xrdp_mod* mod;
struct xrdp_painter* p;
- mod = (struct xrdp_mod*)handle;
p = (struct xrdp_painter*)mod->painter;
xrdp_painter_end_update(p);
xrdp_painter_delete(p);
@@ -101,14 +97,12 @@ int server_end_update(int handle)
}
/*****************************************************************************/
-int server_fill_rect(int handle, int x, int y, int cx, int cy,
+int server_fill_rect(struct xrdp_mod* mod, int x, int y, int cx, int cy,
int color)
{
- struct xrdp_mod* mod;
struct xrdp_wm* wm;
struct xrdp_painter* p;
- mod = (struct xrdp_mod*)handle;
wm = (struct xrdp_wm*)mod->wm;
p = (struct xrdp_painter*)mod->painter;
p->fg_color = color;
@@ -117,13 +111,11 @@ int server_fill_rect(int handle, int x, int y, int cx, int cy,
}
/*****************************************************************************/
-int server_screen_blt(int handle, int x, int y, int cx, int cy,
+int server_screen_blt(struct xrdp_mod* mod, int x, int y, int cx, int cy,
int srcx, int srcy)
{
- struct xrdp_mod* mod;
struct xrdp_wm* wm;
- mod = (struct xrdp_mod*)handle;
wm = (struct xrdp_wm*)mod->wm;
xrdp_orders_init(wm->orders);
xrdp_orders_screen_blt(wm->orders, x, y, cx, cy, srcx, srcy, 0xcc, 0);
@@ -132,14 +124,12 @@ int server_screen_blt(int handle, int x, int y, int cx, int cy,
}
/*****************************************************************************/
-int server_paint_rect(int handle, int x, int y, int cx, int cy,
+int server_paint_rect(struct xrdp_mod* mod, int x, int y, int cx, int cy,
char* data)
{
- struct xrdp_mod* mod;
struct xrdp_wm* wm;
struct xrdp_bitmap* b;
- mod = (struct xrdp_mod*)handle;
wm = (struct xrdp_wm*)mod->wm;
b = xrdp_bitmap_create_with_data(cx, cy, wm->screen->bpp, data);
xrdp_wm_send_bitmap(wm, b, x, y, cx, cy);
@@ -150,24 +140,21 @@ int server_paint_rect(int handle, int x, int y, int cx, int cy,
}
/*****************************************************************************/
-int server_set_cursor(int handle, int x, int y, char* data, char* mask)
+int server_set_cursor(struct xrdp_mod* mod, int x, int y,
+ char* data, char* mask)
{
- struct xrdp_mod* mod;
struct xrdp_wm* wm;
- mod = (struct xrdp_mod*)handle;
wm = (struct xrdp_wm*)mod->wm;
xrdp_wm_send_cursor(wm, 2, data, mask, x, y);
return 0;
}
/*****************************************************************************/
-int server_palette(int handle, int* palette)
+int server_palette(struct xrdp_mod* mod, int* palette)
{
- struct xrdp_mod* mod;
struct xrdp_wm* wm;
- mod = (struct xrdp_mod*)handle;
wm = (struct xrdp_wm*)mod->wm;
g_memcpy(wm->palette, palette, 256 * sizeof(int));
xrdp_cache_add_palette(wm->cache, palette);
@@ -183,15 +170,13 @@ int xrdp_wm_popup_notify(struct xrdp_bitmap* wnd,
}
/*****************************************************************************/
-int server_error_popup(int handle, char* error, char* caption)
+int server_error_popup(struct xrdp_mod* mod, char* error, char* caption)
{
#ifdef aa0
- struct xrdp_mod* mod;
struct xrdp_wm* wm;
struct xrdp_bitmap* wnd;
struct xrdp_bitmap* but;
- mod = (struct xrdp_mod*)handle;
wm = (struct xrdp_wm*)mod->wm;
wnd = xrdp_bitmap_create(400, 200, wm->screen->bpp, WND_TYPE_WND);
xrdp_list_add_item(wm->screen->child_list, (int)wnd);
@@ -234,9 +219,9 @@ int xrdp_wm_setup_mod(struct xrdp_wm* self,
self->mod_handle = g_load_library(mod_data->lib);
if (self->mod_handle != 0)
{
- (void*)self->mod_init =
+ self->mod_init = (int(*)())
g_get_proc_address(self->mod_handle, "mod_init");
- (void*)self->mod_exit =
+ self->mod_exit = (int(*)(int))
g_get_proc_address(self->mod_handle, "mod_exit");
if (self->mod_init != 0 && self->mod_exit != 0)
{
@@ -285,6 +270,7 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
struct xrdp_bitmap* but;
struct xrdp_bitmap* b;
struct xrdp_bitmap* combo;
+ struct xrdp_bitmap* edit;
struct xrdp_wm* wm;
struct xrdp_rect rect;
struct xrdp_mod_data con_mod;
@@ -339,7 +325,7 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
}
else if (sender->id == 3) /* ok button */
{
- combo = (struct xrdp_bitmap*)xrdp_bitmap_get_child_by_id(wnd, 6);
+ combo = xrdp_bitmap_get_child_by_id(wnd, 6);
if (combo != 0)
{
mod = (struct xrdp_mod_data*)xrdp_list_get_item(combo->data_list,
@@ -347,25 +333,50 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
if (mod != 0)
{
con_mod = *mod;
+ if (g_strcmp(con_mod.username, "ask") == 0)
+ {
+ edit = xrdp_bitmap_get_child_by_id(wnd, 4);
+ if (edit != 0)
+ {
+ g_strcpy(con_mod.username, edit->caption);
+ }
+ }
+ if (g_strcmp(con_mod.password, "ask") == 0)
+ {
+ edit = xrdp_bitmap_get_child_by_id(wnd, 5);
+ if (edit != 0)
+ {
+ g_strcpy(con_mod.password, edit->caption);
+ }
+ }
if (xrdp_wm_setup_mod(wm, mod) == 0)
{
xrdp_wm_delete_all_childs(wm);
if (!wm->pro_layer->term)
{
- if (wm->mod->mod_start((int)wm->mod, wm->screen->width,
+ if (wm->mod->mod_start(wm->mod, wm->screen->width,
wm->screen->height, wm->screen->bpp) != 0)
+ {
wm->pro_layer->term = 1; /* kill session */
+ }
}
if (!wm->pro_layer->term)
{
- if (wm->mod->mod_connect((int)wm->mod, con_mod.ip, con_mod.port,
- con_mod.user, con_mod.password) != 0)
+ wm->mod->mod_set_param(wm->mod, "ip", con_mod.ip);
+ wm->mod->mod_set_param(wm->mod, "port", con_mod.port);
+ wm->mod->mod_set_param(wm->mod, "username", con_mod.username);
+ wm->mod->mod_set_param(wm->mod, "password", con_mod.password);
+ if (wm->mod->mod_connect(wm->mod) != 0)
+ {
wm->pro_layer->term = 1; /* kill session */
+ }
}
if (!wm->pro_layer->term)
{
if (wm->mod->sck != 0)
+ {
wm->pro_layer->app_sck = wm->mod->sck;
+ }
}
}
}
@@ -424,7 +435,8 @@ int xrdp_wm_login_fill_in_combo(struct xrdp_wm* self, struct xrdp_bitmap* b)
}
else
{
- mod_data = g_malloc(sizeof(struct xrdp_mod_data), 1);
+ mod_data = (struct xrdp_mod_data*)
+ g_malloc(sizeof(struct xrdp_mod_data), 1);
g_strcpy(mod_data->name, p);
for (j = 0; j < section_names->count; j++)
{
@@ -446,9 +458,9 @@ int xrdp_wm_login_fill_in_combo(struct xrdp_wm* self, struct xrdp_bitmap* b)
{
g_strcpy(mod_data->port, r);
}
- else if (g_strcmp("user", q) == 0)
+ else if (g_strcmp("username", q) == 0)
{
- g_strcpy(mod_data->user, r);
+ g_strcpy(mod_data->username, r);
}
else if (g_strcmp("password", q) == 0)
{
diff --git a/xrdp/xrdp_process.c b/xrdp/xrdp_process.c
index 0f8323da..21512800 100644
--- a/xrdp/xrdp_process.c
+++ b/xrdp/xrdp_process.c
@@ -66,7 +66,7 @@ int xrdp_process_main_loop(struct xrdp_process* self)
{
init_stream(s, 8192);
cont = 1;
- while (cont)
+ while (cont && !self->term)
{
if (xrdp_rdp_recv(self->rdp_layer, s, &code) != 0)
{
@@ -123,7 +123,7 @@ int xrdp_process_main_loop(struct xrdp_process* self)
{
break;
}
- if (self->wm->mod->mod_signal((int)self->wm->mod) != 0)
+ if (self->wm->mod->mod_signal(self->wm->mod) != 0)
{
break;
}
@@ -138,6 +138,13 @@ int xrdp_process_main_loop(struct xrdp_process* self)
}
}
}
+ if (self->wm->mod != 0)
+ {
+ if (self->wm->mod->mod_end != 0)
+ {
+ self->wm->mod->mod_end(self->wm->mod);
+ }
+ }
xrdp_rdp_disconnect(self->rdp_layer);
xrdp_rdp_delete(self->rdp_layer);
self->rdp_layer = 0;
diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h
index 4527533c..c4e5e442 100644
--- a/xrdp/xrdp_types.h
+++ b/xrdp/xrdp_types.h
@@ -25,25 +25,26 @@ struct xrdp_mod
{
int size; /* size of this struct */
/* client functions */
- int (*mod_start)(int handle, int w, int h, int bpp);
- int (*mod_connect)(int handle, char* ip, char* port,
- char* username, char* password);
- int (*mod_event)(int handle, int msg, int param1, int param2);
- int (*mod_signal)(int handle);
- int (*mod_invalidate)(int handle, int x, int y, int cx, int cy);
- int d1[95];
+ int (*mod_start)(struct xrdp_mod* v, int w, int h, int bpp);
+ int (*mod_connect)(struct xrdp_mod* v);
+ int (*mod_event)(struct xrdp_mod* v, int msg, int param1, int param2);
+ int (*mod_signal)(struct xrdp_mod* v);
+ int (*mod_invalidate)(struct xrdp_mod* v, int x, int y, int cx, int cy);
+ int (*mod_end)(struct xrdp_mod* v);
+ int (*mod_set_param)(struct xrdp_mod* v, char* name, char* value);
+ int d1[93];
/* server functions */
- int (*server_begin_update)(int handle);
- int (*server_end_update)(int handle);
- int (*server_fill_rect)(int handle, int x, int y, int cx, int cy,
+ int (*server_begin_update)(struct xrdp_mod* v);
+ int (*server_end_update)(struct xrdp_mod* v);
+ int (*server_fill_rect)(struct xrdp_mod* v, int x, int y, int cx, int cy,
int color);
- int (*server_screen_blt)(int handle, int x, int y, int cx, int cy,
+ int (*server_screen_blt)(struct xrdp_mod* v, int x, int y, int cx, int cy,
int srcx, int srcy);
- int (*server_paint_rect)(int handle, int x, int y, int cx, int cy,
+ int (*server_paint_rect)(struct xrdp_mod* v, int x, int y, int cx, int cy,
char* data);
- int (*server_set_cursor)(int handle, int x, int y, char* data, char* mask);
- int (*server_palette)(int handle, int* palette);
- int (*server_error_popup)(int handle, char* error, char* caption);
+ int (*server_set_cursor)(struct xrdp_mod* v, int x, int y, char* data, char* mask);
+ int (*server_palette)(struct xrdp_mod* v, int* palette);
+ int (*server_error_popup)(struct xrdp_mod* v, char* error, char* caption);
int d2[92];
/* common */
int handle; /* pointer to self as int */
@@ -362,6 +363,10 @@ struct xrdp_wm
int (*mod_init)();
int (*mod_exit)(int);
struct xrdp_mod* mod;
+ /* */
+ int use_comp;
+ /* */
+ int op1;
};
/* rdp process */
@@ -476,6 +481,6 @@ struct xrdp_mod_data
char lib[256];
char ip[256];
char port[256];
- char user[256];
+ char username[256];
char password[256];
};
diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c
index f2ab6f64..63ba7eae 100644
--- a/xrdp/xrdp_wm.c
+++ b/xrdp/xrdp_wm.c
@@ -37,6 +37,8 @@ struct xrdp_wm* xrdp_wm_create(struct xrdp_process* owner)
self->painter = xrdp_painter_create(self);
self->rdp_layer = owner->rdp_layer;
self->cache = xrdp_cache_create(self, self->orders);
+ self->use_comp = 1;
+ self->op1 = 0;
return self;
}
@@ -44,15 +46,24 @@ struct xrdp_wm* xrdp_wm_create(struct xrdp_process* owner)
void xrdp_wm_delete(struct xrdp_wm* self)
{
if (self == 0)
+ {
return;
+ }
xrdp_cache_delete(self->cache);
xrdp_painter_delete(self->painter);
xrdp_bitmap_delete(self->screen);
/* free any modual stuff */
- if (self->mod != 0 && self->mod_exit != 0)
- self->mod_exit((int)self->mod);
+ if (self->mod != 0)
+ {
+ if (self->mod_exit != 0)
+ {
+ self->mod_exit((int)self->mod);
+ }
+ }
if (self->mod_handle != 0)
+ {
g_free_library(self->mod_handle);
+ }
/* free self */
g_free(self);
}
@@ -96,52 +107,140 @@ int xrdp_wm_send_bitmap(struct xrdp_wm* self, struct xrdp_bitmap* bitmap,
int lines_sending;
int Bpp;
int e;
+ int bufsize;
+ int total_bufsize;
+ int num_updates;
+ char* p_num_updates;
char* p;
char* q;
struct stream* s;
+ struct stream* temp_s;
- lines_sending = 0;
- make_stream(s);
- init_stream(s, 8192);
Bpp = (bitmap->bpp + 7) / 8;
- data_size = bitmap->width * bitmap->height * Bpp;
- line_size = bitmap->width * Bpp;
- total_lines = bitmap->height;
e = bitmap->width % 4;
if (e != 0)
e = 4 - e;
- i = 0;
- p = bitmap->data;
- if (line_size > 0 && total_lines > 0)
+ line_size = bitmap->width * Bpp;
+ make_stream(s);
+ init_stream(s, 8192);
+ if (self->use_comp)
{
- while (i < total_lines)
+ make_stream(temp_s);
+ init_stream(temp_s, 65536);
+ i = 0;
+ if (cy <= bitmap->height)
+ i = cy;
+ while (i > 0)
{
- lines_sending = 4096 / (line_size + e * Bpp);
- if (i + lines_sending > total_lines)
- lines_sending = total_lines - i;
- p = p + line_size * lines_sending;
+ total_bufsize = 0;
+ num_updates = 0;
xrdp_rdp_init_data(self->rdp_layer, s);
out_uint16_le(s, RDP_UPDATE_BITMAP);
- out_uint16_le(s, 1); /* num updates */
- out_uint16_le(s, x);
- out_uint16_le(s, y + i);
- out_uint16_le(s, (x + cx) - 1);
- out_uint16_le(s, (y + i + lines_sending) - 1);
- out_uint16_le(s, bitmap->width + e);
- out_uint16_le(s, lines_sending);
- out_uint16_le(s, bitmap->bpp); /* bpp */
- out_uint16_le(s, 0); /* compress */
- out_uint16_le(s, (line_size + e * Bpp) * lines_sending); /* bufsize */
- q = p;
- for (j = 0; j < lines_sending; j++)
+ p_num_updates = s->p;
+ out_uint8s(s, 2); /* num_updates set later */
+ do
{
- q = q - line_size;
- out_uint8a(s, q, line_size)
- out_uint8s(s, e * Bpp);
- }
- s_mark_end(s);
+ if (self->op1)
+ {
+ s_push_layer(s, channel_hdr, 18);
+ }
+ else
+ {
+ s_push_layer(s, channel_hdr, 26);
+ }
+ p = s->p;
+ lines_sending = xrdp_bitmap_compress(bitmap->data, bitmap->width,
+ bitmap->height,
+ s, bitmap->bpp,
+ 4096 - total_bufsize,
+ i - 1, temp_s);
+ if (lines_sending == 0)
+ break;
+ num_updates++;
+ bufsize = s->p - p;
+ total_bufsize += bufsize;
+ i = i - lines_sending;
+ s_mark_end(s);
+ s_pop_layer(s, channel_hdr);
+ out_uint16_le(s, x); /* left */
+ out_uint16_le(s, y + i); /* top */
+ out_uint16_le(s, (x + cx) - 1); /* right */
+ out_uint16_le(s, (y + i + lines_sending) - 1); /* bottom */
+ out_uint16_le(s, bitmap->width + e); /* width */
+ out_uint16_le(s, lines_sending); /* height */
+ out_uint16_le(s, bitmap->bpp); /* bpp */
+ if (self->op1)
+ {
+ out_uint16_le(s, 0x401); /* compress */
+ out_uint16_le(s, bufsize); /* compressed size */
+ j = (bitmap->width + e) * Bpp;
+ j = j * lines_sending;
+ }
+ else
+ {
+ out_uint16_le(s, 0x1); /* compress */
+ j = bufsize + 8;
+ out_uint16_le(s, j);
+ out_uint8s(s, 2); /* pad */
+ out_uint16_le(s, bufsize); /* compressed size */
+ j = (bitmap->width + e) * Bpp;
+ out_uint16_le(s, j); /* line size */
+ j = j * lines_sending;
+ out_uint16_le(s, j); /* final size */
+ }
+ if (j > 32768)
+ g_printf("error, decompressed size too big, its %d\n\r", j);
+ if (bufsize > 8192)
+ g_printf("error, compressed size too big, its %d\n\r", bufsize);
+ s->p = s->end;
+ } while (total_bufsize < 4096 && i > 0);
+ p_num_updates[0] = num_updates;
+ p_num_updates[1] = num_updates >> 8;
xrdp_rdp_send_data(self->rdp_layer, s, RDP_DATA_PDU_UPDATE);
- i = i + lines_sending;
+ if (total_bufsize > 8192)
+ g_printf("error, total compressed size too big, its %d\n\r",
+ total_bufsize);
+ }
+ free_stream(temp_s);
+ }
+ else
+ {
+ lines_sending = 0;
+ data_size = bitmap->width * bitmap->height * Bpp;
+ total_lines = bitmap->height;
+ i = 0;
+ p = bitmap->data;
+ if (line_size > 0 && total_lines > 0)
+ {
+ while (i < total_lines)
+ {
+ lines_sending = 4096 / (line_size + e * Bpp);
+ if (i + lines_sending > total_lines)
+ lines_sending = total_lines - i;
+ p = p + line_size * lines_sending;
+ xrdp_rdp_init_data(self->rdp_layer, s);
+ out_uint16_le(s, RDP_UPDATE_BITMAP);
+ out_uint16_le(s, 1); /* num updates */
+ out_uint16_le(s, x);
+ out_uint16_le(s, y + i);
+ out_uint16_le(s, (x + cx) - 1);
+ out_uint16_le(s, (y + i + lines_sending) - 1);
+ out_uint16_le(s, bitmap->width + e);
+ out_uint16_le(s, lines_sending);
+ out_uint16_le(s, bitmap->bpp); /* bpp */
+ out_uint16_le(s, 0); /* compress */
+ out_uint16_le(s, (line_size + e * Bpp) * lines_sending); /* bufsize */
+ q = p;
+ for (j = 0; j < lines_sending; j++)
+ {
+ q = q - line_size;
+ out_uint8a(s, q, line_size)
+ out_uint8s(s, e * Bpp);
+ }
+ s_mark_end(s);
+ xrdp_rdp_send_data(self->rdp_layer, s, RDP_DATA_PDU_UPDATE);
+ i = i + lines_sending;
+ }
}
}
free_stream(s);
@@ -664,7 +763,9 @@ int xrdp_wm_mouse_move(struct xrdp_wm* self, int x, int y)
if (self->mod != 0) /* if screen is mod controled */
{
if (self->mod->mod_event != 0)
- self->mod->mod_event((int)self->mod, WM_MOUSEMOVE, x, y);
+ {
+ self->mod->mod_event(self->mod, WM_MOUSEMOVE, x, y);
+ }
}
}
if (self->button_down != 0)
@@ -769,29 +870,29 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down)
if (self->mod->mod_event != 0)
{
if (but == 1 && down)
- self->mod->mod_event((int)self->mod, WM_LBUTTONDOWN, x, y);
+ self->mod->mod_event(self->mod, WM_LBUTTONDOWN, x, y);
else if (but == 1 && !down)
- self->mod->mod_event((int)self->mod, WM_LBUTTONUP, x, y);
+ self->mod->mod_event(self->mod, WM_LBUTTONUP, x, y);
if (but == 2 && down)
- self->mod->mod_event((int)self->mod, WM_RBUTTONDOWN, x, y);
+ self->mod->mod_event(self->mod, WM_RBUTTONDOWN, x, y);
else if (but == 2 && !down)
- self->mod->mod_event((int)self->mod, WM_RBUTTONUP, x, y);
+ self->mod->mod_event(self->mod, WM_RBUTTONUP, x, y);
if (but == 3 && down)
- self->mod->mod_event((int)self->mod, WM_BUTTON3DOWN, x, y);
+ self->mod->mod_event(self->mod, WM_BUTTON3DOWN, x, y);
else if (but == 3 && !down)
- self->mod->mod_event((int)self->mod, WM_BUTTON3UP, x, y);
+ self->mod->mod_event(self->mod, WM_BUTTON3UP, x, y);
if (but == 4)
{
- self->mod->mod_event((int)self->mod, WM_BUTTON4DOWN,
+ self->mod->mod_event(self->mod, WM_BUTTON4DOWN,
self->mouse_x, self->mouse_y);
- self->mod->mod_event((int)self->mod, WM_BUTTON4UP,
+ self->mod->mod_event(self->mod, WM_BUTTON4UP,
self->mouse_x, self->mouse_y);
}
if (but == 5)
{
- self->mod->mod_event((int)self->mod, WM_BUTTON5DOWN,
+ self->mod->mod_event(self->mod, WM_BUTTON5DOWN,
self->mouse_x, self->mouse_y);
- self->mod->mod_event((int)self->mod, WM_BUTTON5UP,
+ self->mod->mod_event(self->mod, WM_BUTTON5UP,
self->mouse_x, self->mouse_y);
}
}
@@ -928,9 +1029,9 @@ int xrdp_wm_key(struct xrdp_wm* self, int device_flags, int scan_code)
self->num_lock,
self->scroll_lock);
if (c != 0)
- self->mod->mod_event((int)self->mod, msg, c, 0xffff);
+ self->mod->mod_event(self->mod, msg, c, 0xffff);
else
- self->mod->mod_event((int)self->mod, msg, scan_code, device_flags);
+ self->mod->mod_event(self->mod, msg, scan_code, device_flags);
}
}
else if (self->focused_window != 0)