diff --git a/uiports/makefile_nanox b/uiports/makefile_nanox
deleted file mode 100644
index 222dcd5..0000000
--- a/uiports/makefile_nanox
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# nanoxrdesktop makefile
-#
-# These two following lines must point to the currently installed version of
-# nano-X. You can override them on the make command line to point at your
-# installation without changing this file.
-#
-NXINCLUDES=/usr/local/nanox/src/include
-NXLIBS=/usr/local/nanox/src/lib/libnano-X.a
-
-CC = gcc
-CFLAGS = -Os -Wall -I$(NXINCLUDES)
-RESTOBJ = ../tcp.o ../iso.o ../mcs.o ../secure.o ../rdp.o ../rdp5.o ../orders.o ../cache.o ../mppc.o ../licence.o ../bitmap.o ../channels.o ../pstcache.o
-LDFLAGS = -lcrypto
-
-all: nanoxrd
-
-nanoxrd: $(RESTOBJ) nanoxwin.o
- $(CC) -o nanoxrdesktop nanoxwin.o $(NXLIBS) $(RESTOBJ) $(LDFLAGS)
- strip nanoxrdesktop
-
-clean:
- rm -f nanoxrdesktop
- rm -f *.o
- rm -f ../*.o
diff --git a/uiports/makefile_qt b/uiports/makefile_qt
deleted file mode 100644
index 71b6ff3..0000000
--- a/uiports/makefile_qt
+++ /dev/null
@@ -1,86 +0,0 @@
-#
-# qtrdesktop makefile
-# qt should be installed in /usr/local/qt or /usr/lib/qt3
-# set QTBDIR to this location
-
-QTBDIR = /usr/lib/qt3
-
-CC = g++
-CPPFLAGS = -O2 -Wall -I$(QTBDIR)/include -I..
-# the next line is for sound
-#CPPFLAGS += -DWITH_RDPSND
-RESTOBJ = tcp.o iso.o mcs.o secure.o rdp.o rdp5.o
-RESTOBJ += orders.o cache.o mppc.o licence.o bitmap.o
-RESTOBJ += channels.o pstcache.o ssl.o
-# the next line is for sound
-#RESTOBJ += rdpsnd.o rdpsnd_oss.o rdpsnd_dsp.o
-LD2FLAGS = -L$(QTBDIR)/lib -L/usr/X11R6/lib
-LDFLAGS = -lcrypto -lqt-mt -lXext -lX11 -lm
-MOCFILE = $(QTBDIR)/bin/moc
-
-all: qtrd
-
-qtrd: $(RESTOBJ) qtwin.o
- $(MOCFILE) qtwin.h > moc_qtwin.cpp
- $(CC) $(CPPFLAGS) -c moc_qtwin.cpp
- $(CC) -o qtrdesktop $(LD2FLAGS) qtwin.o moc_qtwin.o $(RESTOBJ) $(LDFLAGS)
- strip qtrdesktop
-
-clean:
- rm -f qtrdesktop
- rm -f *.o
- rm -f ../*.o
- rm -f moc_qtwin.cpp
-
-# common files
-
-tcp.o: ../tcp.c
- $(CC) $(CPPFLAGS) -c ../tcp.c
-
-iso.o: ../iso.c
- $(CC) $(CPPFLAGS) -c ../iso.c
-
-mcs.o: ../mcs.c
- $(CC) $(CPPFLAGS) -c ../mcs.c
-
-secure.o: ../secure.c
- $(CC) $(CPPFLAGS) -c ../secure.c
-
-rdp.o: ../rdp.c
- $(CC) $(CPPFLAGS) -c ../rdp.c
-
-rdp5.o: ../rdp5.c
- $(CC) $(CPPFLAGS) -c ../rdp5.c
-
-orders.o: ../orders.c
- $(CC) $(CPPFLAGS) -c ../orders.c
-
-cache.o: ../cache.c
- $(CC) $(CPPFLAGS) -c ../cache.c
-
-mppc.o: ../mppc.c
- $(CC) $(CPPFLAGS) -c ../mppc.c
-
-licence.o: ../licence.c
- $(CC) $(CPPFLAGS) -c ../licence.c
-
-bitmap.o: ../bitmap.c
- $(CC) $(CPPFLAGS) -c ../bitmap.c
-
-channels.o: ../channels.c
- $(CC) $(CPPFLAGS) -c ../channels.c
-
-pstcache.o: ../pstcache.c
- $(CC) $(CPPFLAGS) -c ../pstcache.c
-
-ssl.o: ../ssl.c
- $(CC) $(CPPFLAGS) -c ../ssl.c
-
-rdpsnd.o: ../rdpsnd.c
- $(CC) $(CPPFLAGS) -c ../rdpsnd.c
-
-rdpsnd_oss.o: ../rdpsnd_oss.c
- $(CC) $(CPPFLAGS) -c ../rdpsnd_oss.c
-
-rdpsnd_dsp.o: ../rdpsnd_dsp.c
- $(CC) $(CPPFLAGS) -c ../rdpsnd_dsp.c
diff --git a/uiports/makefile_qte b/uiports/makefile_qte
deleted file mode 100644
index be672cd..0000000
--- a/uiports/makefile_qte
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# qterdesktop makefile
-# qt should be installed in /usr/local/qt
-#
-CC = g++
-CPPFLAGS = -DQWS -fno-exceptions -fno-rtti -Wall -Os -Wall -I/usr/local/qt/include -DWITH_RDPSND -DNO_DEBUG
-RESTOBJ = ../tcp.o ../iso.o ../mcs.o ../secure.o ../rdp.o ../rdp5.o ../orders.o ../cache.o ../mppc.o ../licence.o ../bitmap.o ../channels.o ../pstcache.o ../rdpsnd.o ../rdpsnd_oss.o
-LD2FLAGS = -L/usr/local/qt/lib
-LDFLAGS = -lcrypto -lqte
-MOCFILE = /usr/local/qt/bin/moc
-
-all: qtrd
-
-qtrd: $(RESTOBJ) qtewin.o
- $(MOCFILE) qtewin.h > moc_qtewin.cpp
- $(CC) $(CPPFLAGS) -c moc_qtewin.cpp
- $(CC) -o qterdesktop $(LD2FLAGS) qtewin.o moc_qtewin.o $(RESTOBJ) $(LDFLAGS)
- strip qterdesktop
-
-clean:
- rm -f qterdesktop
- rm -f *.o
- rm -f ../*.o
- rm -f moc_qtewin.cpp
diff --git a/uiports/makefile_svga b/uiports/makefile_svga
deleted file mode 100644
index a24231e..0000000
--- a/uiports/makefile_svga
+++ /dev/null
@@ -1,36 +0,0 @@
-CC = gcc
-CFLAGS = -Os -DWITH_OPENSSL -DL_ENDIAN -Wall
-RESTOBJ = ../tcp.o ../iso.o ../mcs.o ../secure.o ../rdp.o ../rdp5.o ../orders.o ../cache.o ../mppc.o ../licence.o ../bitmap.o ../channels.o ../pstcache.o ../ssl.o
-LDFLAGS = -lvga -lcrypto
-
-#LDFLAGS = -lm /usr/local/lib/libvga.a /usr/lib/libcrypto.a
-#LDFLAGS = -lvga /usr/lib/libcrypto.a
-
-all: svgard
-svgard: svgawin.o $(RESTOBJ)
- $(CC) -o svgardesktop svgawin.o $(RESTOBJ) $(LDFLAGS)
- strip svgardesktop
-
-#rest: $(RESTOBJ)
-#rest: tcp.o iso.o mcs.o secure.o rdp.o rdp5.o orders.o cache.o mppc.o licence.o bitmap.o channels.o pstcache.o
-rest: ../tcp.c ../iso.c ../mcs.c ../secure.c ../rdp.c ../rdp5.c ../orders.c ../cache.c ../mppc.c ../licence.c ../bitmap.c ../channels.c ../pstcache.c
- $(CC) $(CFLAGS) -c ../tcp.c -o ../tcp.o
- $(CC) $(CFLAGS) -c ../iso.c -o ../iso.o
- $(CC) $(CFLAGS) -c ../mcs.c -o ../mcs.o
- $(CC) $(CFLAGS) -c ../secure.c -o ../secue.o
- $(CC) $(CFLAGS) -c ../rdp.c -o ../rdp.o
- $(CC) $(CFLAGS) -c ../rdp5.c -o ../rdp5.o
- $(CC) $(CFLAGS) -c ../orders.c -o ../orders.o
- $(CC) $(CFLAGS) -c ../cache.c -o ../cache.o
- $(CC) $(CFLAGS) -c ../mppc.c -o ../mppc.o
- $(CC) $(CFLAGS) -c ../licence.c -o ../licence.o
- $(CC) $(CFLAGS) -c ../bitmap.c -o ../bitmap.o
- $(CC) $(CFLAGS) -c ../channels.c -o ../channels.o
- $(CC) $(CFLAGS) -c ../pstcache.c -o ../pstcache.o
-
-svgawin.o: svgawin.c
- $(CC) $(CFLAGS) -c $*.c
-clean:
- rm -f svgardesktop
- rm -f *.o
- rm -f ../*.o
diff --git a/uiports/makefile_xxx b/uiports/makefile_xxx
deleted file mode 100644
index 2dbc765..0000000
--- a/uiports/makefile_xxx
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# xxxrdesktop makefile
-#
-CC = gcc
-CFLAGS = -O2 -Wall
-RESTOBJ = ../tcp.o ../iso.o ../mcs.o ../secure.o ../rdp.o ../rdp5.o ../orders.o ../cache.o ../mppc.o ../licence.o ../bitmap.o ../channels.o ../pstcache.o ../ssl.o
-LDFLAGS = -lcrypto
-
-all: xxxrd
-
-xxxrd: $(RESTOBJ) xxxwin.o
- $(CC) -o xxxrdesktop xxxwin.o $(RESTOBJ) $(LDFLAGS)
- strip xxxrdesktop
-
-clean:
- rm -f xxxrdesktop
- rm -f *.o
- rm -f ../*.o
diff --git a/uiports/nanoxreadme.txt b/uiports/nanoxreadme.txt
deleted file mode 100644
index a56d3cf..0000000
--- a/uiports/nanoxreadme.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-This is the nanox ui port
-tested with versions 0.90
-
-makefile_nanox can be edited to change file locations
-run make -f makefile_nanox in this directory to compile it
-
-nanoxreadme.txt - notes, this file
-makefile_nanox - makefile
-nanoxwin.cpp - ui lib
diff --git a/uiports/nanoxwin.c b/uiports/nanoxwin.c
deleted file mode 100755
index 34a9843..0000000
--- a/uiports/nanoxwin.c
+++ /dev/null
@@ -1,1545 +0,0 @@
-/* -*- c-basic-offset: 8 -*-
- rdesktop: A Remote Desktop Protocol client.
- User interface services - NanoX(microwindows)
- Copyright (C) Jay Sorg 2004-2005
-
- 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 3 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, see .
-*/
-/*
- problems with nanox lib
- opcodes don't work, can only rely on copy
- stipple origins don't work
- clip seems to affect source too, it should only affect dest
- in copyarea functions
-*/
-
-#include "../rdesktop.h"
-
-#include /* va_list va_start va_end */
-#include /* gethostname */
-#include /* getpwuid */
-
-#include
-
-extern int g_tcp_port_rdp;
-int g_use_rdp5 = 1;
-char g_hostname[16];
-char g_username[64];
-int g_width = 800;
-int g_height = 600;
-int g_server_bpp = 16;
-int g_encryption = 1;
-int g_desktop_save = 0; /* todo */
-int g_polygon_ellipse_orders = 0;
-int g_bitmap_cache = 1;
-int g_bitmap_cache_persist_enable = 0;
-int g_bitmap_cache_precache = 1;
-uint32 g_rdp5_performanceflags =
- RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG | RDP5_NO_MENUANIMATIONS;
-int g_console_session = 0;
-int g_keylayout = 0x409; /* Defaults to US keyboard layout */
-int g_keyboard_type = 0x4; /* Defaults to US keyboard layout */
-int g_keyboard_subtype = 0x0; /* Defaults to US keyboard layout */
-int g_keyboard_functionkeys = 0xc; /* Defaults to US keyboard layout */
-
-static int g_sck = 0;
-static char g_servername[256] = "";
-static char g_password[64] = "";
-static char g_domain[64] = "";
-static char g_shell[64] = "";
-static char g_directory[64] = "";
-static GR_WINDOW_ID g_wnd = 0;
-static GR_GC_ID g_gc = 0;
-static GR_GC_ID g_gc_clean = 0;
-static int g_deactivated = 0;
-static int g_ext_disc_reason = 0;
-static GR_SCREEN_INFO g_screen_info;
-static int g_bpp = 0;
-static int g_Bpp = 0;
-static GR_RECT g_clip; /* set in main */
-static GR_CURSOR_ID g_null_cursor; /* set in main */
-static int g_flags = RDP_LOGON_NORMAL;
-
-struct key
-{
- int ch1;
- int ch2;
- int ch3;
- int chs; /* shift char */
-};
-
-static struct key g_keys[256];
-
-/* Session Directory redirection */
-BOOL g_redirect = False;
-char g_redirect_server[64];
-char g_redirect_domain[16];
-char g_redirect_password[64];
-char g_redirect_username[64];
-char g_redirect_cookie[128];
-uint32 g_redirect_flags = 0;
-
-#define COLOR16TO32(color) \
-( \
- ((((color >> 8) & 0xf8) | ((color >> 13) & 0x7)) << 0) | \
- ((((color >> 3) & 0xfc) | ((color >> 9) & 0x3)) << 8) | \
- ((((color << 3) & 0xf8) | ((color >> 2) & 0x7)) << 16) \
-)
-
-static uint32 g_ops[16] =
-{
- GR_MODE_CLEAR, /* 0 */
- GR_MODE_NOR, /* ~(src | dst) */
- GR_MODE_ANDINVERTED, /* (~src) & dst */
- GR_MODE_COPYINVERTED, /* ~src */
- GR_MODE_ANDREVERSE, /* src & (~dst) */
- GR_MODE_INVERT, /* ~(dst) */
- GR_MODE_XOR, /* src ^ dst */
- GR_MODE_NAND, /* ~(src & dst) */
- GR_MODE_AND, /* src & dst */
- GR_MODE_EQUIV, /* ~(src) ^ dst or is it ~(src ^ dst) */
- GR_MODE_NOOP, /* dst */
- GR_MODE_ORINVERTED, /* (~src) | dst */
- GR_MODE_COPY, /* src */
- GR_MODE_ORREVERSE, /* src | (~dst) */
- GR_MODE_OR, /* src | dst */
- GR_MODE_SETTO1 /* ~0 */
-};
-
-/*****************************************************************************/
-/* do a raster op */
-static int rop(int rop, int src, int dst)
-{
- switch (rop)
- {
- case 0x0: return 0;
- case 0x1: return ~(src | dst);
- case 0x2: return (~src) & dst;
- case 0x3: return ~src;
- case 0x4: return src & (~dst);
- case 0x5: return ~(dst);
- case 0x6: return src ^ dst;
- case 0x7: return ~(src & dst);
- case 0x8: return src & dst;
- case 0x9: return ~(src) ^ dst;
- case 0xa: return dst;
- case 0xb: return (~src) | dst;
- case 0xc: return src;
- case 0xd: return src | (~dst);
- case 0xe: return src | dst;
- case 0xf: return ~0;
- }
- return dst;
-}
-
-/*****************************************************************************/
-static int get_pixel32(uint8 * data, int x, int y,
- int width, int height)
-{
- if (x >= 0 && y >= 0 && x < width && y < height)
- {
- return *(((int*)data) + (y * width + x));
- }
- else
- {
- return 0;
- }
-}
-
-/*****************************************************************************/
-static void set_pixel32(uint8 * data, int x, int y,
- int width, int height, int pixel)
-{
- if (x >= 0 && y >= 0 && x < width && y < height)
- {
- *(((int*)data) + (y * width + x)) = pixel;
- }
-}
-
-/*****************************************************************************/
-static int warp_coords(int * x, int * y, int * cx, int * cy,
- int * srcx, int * srcy)
-{
- int dx;
- int dy;
-
- if (g_clip.x > *x)
- {
- dx = g_clip.x - *x;
- }
- else
- {
- dx = 0;
- }
- if (g_clip.y > *y)
- {
- dy = g_clip.y - *y;
- }
- else
- {
- dy = 0;
- }
- if (*x + *cx > g_clip.x + g_clip.width)
- {
- *cx = (*cx - ((*x + *cx) - (g_clip.x + g_clip.width)));
- }
- if (*y + *cy > g_clip.y + g_clip.height)
- {
- *cy = (*cy - ((*y + *cy) - (g_clip.y + g_clip.height)));
- }
- *cx = *cx - dx;
- *cy = *cy - dy;
- if (*cx <= 0)
- {
- return 0;
- }
- if (*cy <= 0)
- {
- return 0;
- }
- *x = *x + dx;
- *y = *y + dy;
- if (srcx != 0)
- {
- *srcx = *srcx + dx;
- }
- if (srcy != 0)
- {
- *srcy = *srcy + dy;
- }
- return 1;
-}
-
-/******************************************************************************/
-/* check if a certain pixel is set in a bitmap */
-static int is_pixel_on(uint8 * data, int x, int y, int width, int bpp)
-{
- int start;
- int shift;
-
- if (bpp == 1)
- {
- width = (width + 7) / 8;
- start = (y * width) + x / 8;
- shift = x % 8;
- return (data[start] & (0x80 >> shift)) != 0;
- }
- else
- return 0;
-}
-
-/*****************************************************************************/
-int ui_select(int in)
-{
- if (g_sck == 0)
- {
- g_sck = in;
- }
- return 1;
-}
-
-/*****************************************************************************/
-void ui_set_clip(int x, int y, int cx, int cy)
-{
- GR_REGION_ID region;
-
- g_clip.x = x;
- g_clip.y = y;
- g_clip.width = cx;
- g_clip.height = cy;
- region = GrNewRegion();
- GrUnionRectWithRegion(region, &g_clip);
- GrSetGCRegion(g_gc, region); /* can't destroy region here, i guess gc */
- /* takes ownership, if you destroy it */
- /* clip is reset, hum */
-}
-
-/*****************************************************************************/
-void ui_reset_clip(void)
-{
- GrSetGCRegion(g_gc, 0);
- g_clip.x = 0;
- g_clip.y = 0;
- g_clip.width = g_width;
- g_clip.height = g_height;
-}
-
-/*****************************************************************************/
-void ui_bell(void)
-{
- GrBell();
-}
-
-/*****************************************************************************/
-/* have to convert the RDP glyph to nanox glyph */
-void * ui_create_glyph(int width, int height, uint8 * data)
-{
- char * p, * q, * r;
- int datasize, i, j;
-
- datasize = GR_BITMAP_SIZE(width, height) * sizeof(GR_BITMAP);
- p = xmalloc(datasize);
- q = p;
- r = data;
- memset(p, 0, datasize);
- for (i = 0; i < height; i++)
- {
- j = 0;
- while (j + 8 < width)
- {
- *q = *(r + 1);
- q++;
- r++;
- *q = *(r - 1);
- q++;
- r++;
- j += 16;
- }
- if ((width % 16) <= 8 && (width % 16) > 0)
- {
- q++;
- *q = *r;
- q++;
- r++;
- j += 8;
- }
- }
- return p;
-}
-
-/*****************************************************************************/
-void ui_destroy_glyph(void * glyph)
-{
- xfree(glyph);
-}
-
-/*****************************************************************************/
-void * ui_create_colourmap(COLOURMAP * colors)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void ui_set_colourmap(void * map)
-{
-}
-
-/*****************************************************************************/
-void * ui_create_bitmap(int width, int height, uint8 * data)
-{
- GR_WINDOW_ID pixmap;
- uint8 * p;
- uint32 i, j, pixel;
-
- p = data;
- pixmap = GrNewPixmap(width, height, 0);
- if (g_server_bpp == 16 && g_bpp == 32)
- {
- p = xmalloc(width * height * g_Bpp);
- for (i = 0; i < height; i++)
- {
- for (j = 0; j < width; j++)
- {
- pixel = *(((uint16 *) data) + (i * width + j));
- pixel = COLOR16TO32(pixel);
- *(((uint32 *) p) + (i * width + j)) = pixel;
- }
- }
- }
- GrArea(pixmap, g_gc_clean, 0, 0, width, height, p, MWPF_RGB);
- if (p != data)
- {
- xfree(p);
- }
- return (void *) pixmap;
-}
-
-/*****************************************************************************/
-void ui_destroy_bitmap(void * bmp)
-{
- GrDestroyWindow((GR_WINDOW_ID)bmp);
-}
-
-/*****************************************************************************/
-#define DO_GLYPH(ttext,idx) \
-{ \
- glyph = cache_get_font (font, ttext[idx]); \
- if (!(flags & TEXT2_IMPLICIT_X)) \
- { \
- xyoffset = ttext[++idx]; \
- if ((xyoffset & 0x80)) \
- { \
- if (flags & TEXT2_VERTICAL) \
- { \
- y += ttext[idx+1] | (ttext[idx+2] << 8); \
- } \
- else \
- { \
- x += ttext[idx+1] | (ttext[idx+2] << 8); \
- } \
- idx += 2; \
- } \
- else \
- { \
- if (flags & TEXT2_VERTICAL) \
- { \
- y += xyoffset; \
- } \
- else \
- { \
- x += xyoffset; \
- } \
- } \
- } \
- if (glyph != NULL) \
- { \
- x1 = x + glyph->offset; \
- y1 = y + glyph->baseline; \
- GrBitmap(g_wnd, g_gc, x1, y1, glyph->width, glyph->height, glyph->pixmap); \
- if (flags & TEXT2_IMPLICIT_X) \
- { \
- x += glyph->width; \
- } \
- } \
-}
-
-/*****************************************************************************/
-void ui_draw_text(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, BRUSH * brush,
- int bgcolor, int fgcolor, uint8 * text, uint8 length)
-{
- FONTGLYPH * glyph;
- int i, j, xyoffset, x1, y1;
- DATABLOB * entry;
-
- GrSetGCMode(g_gc, GR_MODE_COPY);
- GrSetGCUseBackground(g_gc, 0); /* this can be set when gc is created */
- if (g_server_bpp == 16 && g_bpp == 32)
- {
- fgcolor = COLOR16TO32(fgcolor);
- bgcolor = COLOR16TO32(bgcolor);
- }
- GrSetGCForeground(g_gc, bgcolor);
- if (boxx + boxcx > g_width)
- {
- boxcx = g_width - boxx;
- }
- if (boxcx > 1)
- {
- GrFillRect(g_wnd, g_gc, boxx, boxy, boxcx, boxcy);
- }
- else if (mixmode == MIX_OPAQUE)
- {
- GrFillRect(g_wnd, g_gc, clipx, clipy, clipcx, clipcy);
- }
- GrSetGCForeground(g_gc, fgcolor);
- /* Paint text, character by character */
- for (i = 0; i < length;)
- {
- switch (text[i])
- {
- case 0xff:
- if (i + 2 < length)
- {
- cache_put_text(text[i + 1], text, text[i + 2]);
- }
- else
- {
- error("this shouldn't be happening\n");
- exit(1);
- }
- /* this will move pointer from start to first character after */
- /* FF command */
- length -= i + 3;
- text = &(text[i + 3]);
- i = 0;
- break;
- case 0xfe:
- entry = cache_get_text(text[i + 1]);
- if (entry != NULL)
- {
- if ((((uint8 *) (entry->data))[1] == 0) &&
- (!(flags & TEXT2_IMPLICIT_X)))
- {
- if (flags & TEXT2_VERTICAL)
- {
- y += text[i + 2];
- }
- else
- {
- x += text[i + 2];
- }
- }
- for (j = 0; j < entry->size; j++)
- {
- DO_GLYPH(((uint8 *) (entry->data)), j);
- }
- }
- if (i + 2 < length)
- {
- i += 3;
- }
- else
- {
- i += 2;
- }
- length -= i;
- /* this will move pointer from start to first character after */
- /* FE command */
- text = &(text[i]);
- i = 0;
- break;
- default:
- DO_GLYPH(text, i);
- i++;
- break;
- }
- }
-}
-
-/*****************************************************************************/
-void ui_line(uint8 opcode, int startx, int starty, int endx, int endy,
- PEN * pen)
-{
- uint32 op;
- uint32 color;
-
- color = pen->colour;
- if (opcode == 5) /* GR_MODE_INVERT, not supported so convert it */
- { /* i think x ^ -1 = ~x */
- color = 0xffffffff;
- opcode = 6; /* GR_MODE_XOR */
- }
- if (opcode == 12 || opcode == 6) /* nanox only supports these 2 opcode */
- {
- op = g_ops[opcode];
- GrSetGCMode(g_gc, op);
- if (g_server_bpp == 16 && g_bpp == 32)
- {
- color = COLOR16TO32(color);
- }
- GrSetGCForeground(g_gc, color);
- GrLine(g_wnd, g_gc, startx, starty, endx, endy);
- GrSetGCMode(g_gc, GR_MODE_COPY);
- }
- else
- {
- unimpl("opcode %d in ui_line\n", opcode);
- }
-}
-
-/*****************************************************************************/
-void ui_triblt(uint8 opcode, int x, int y, int cx, int cy,
- void * src, int srcx, int srcy,
- BRUSH * brush, int bgcolor, int fgcolor)
-{
-/* not used, turned off */
-}
-
-/*****************************************************************************/
-void ui_memblt(uint8 opcode, int x, int y, int cx, int cy,
- void * src, int srcx, int srcy)
-{
- uint8 * dest;
- uint8 * source;
- uint8 * final;
- GR_WINDOW_INFO wi;
- int i, j, s, d;
- GR_WINDOW_ID pixmap;
-
- if (opcode == 12)
- {
- GrCopyArea(g_wnd, g_gc, x, y, cx, cy, (GR_DRAW_ID)src, srcx, srcy,
- GR_MODE_COPY);
- }
- else /* do opcodes ourself */
- { /* slow but its correct, ok to be slow here, these are rare */
- GrGetWindowInfo((GR_DRAW_ID)src, &wi);
- dest = xmalloc(cx * cy * g_Bpp);
- source = xmalloc(wi.width * wi.height * g_Bpp);
- final = xmalloc(cx * cy * g_Bpp);
- memset(final, 0, cx * cy * g_Bpp);
- /* dest */
- GrReadArea(g_wnd, x, y, cx, cy, (GR_PIXELVAL*)dest);
- /* source */
- GrReadArea((GR_DRAW_ID)src, 0, 0,
- wi.width, wi.height, (GR_PIXELVAL*)source);
- for (i = 0; i < cy; i++)
- {
- for (j = 0; j < cx; j++)
- {
- s = get_pixel32(source, j + srcx, i + srcy, wi.width, wi.height);
- d = get_pixel32(dest, j, i, cx ,cy);
- set_pixel32(final, j, i, cx, cy, rop(opcode, s, d));
- }
- }
- pixmap = GrNewPixmap(cx, cy, 0);
- GrArea(pixmap, g_gc_clean, 0, 0, cx, cy, final, MWPF_TRUECOLOR0888);
- GrCopyArea(g_wnd, g_gc, x, y, cx, cy, pixmap, 0, 0, GR_MODE_COPY);
- GrDestroyWindow(pixmap);
- xfree(dest);
- xfree(source);
- xfree(final);
- }
-}
-
-/*****************************************************************************/
-void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
-{
-/* not used, turned off */
-}
-
-/*****************************************************************************/
-void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
-{
-/* not used, turned off */
-}
-
-/*****************************************************************************/
-void ui_rect(int x, int y, int cx, int cy, int color)
-{
- if (g_server_bpp == 16 && g_bpp == 32)
- {
- color = COLOR16TO32(color);
- }
- GrSetGCForeground(g_gc, color);
- GrFillRect(g_wnd, g_gc, x, y, cx, cy);
-}
-
-/*****************************************************************************/
-/* using warp_coords cause clip seems to affect source in GrCopyArea */
-void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy,
- int srcx, int srcy)
-{
- if (opcode == 12)
- {
- if (warp_coords(&x, &y, &cx, &cy, &srcx, &srcy))
- {
- GrCopyArea(g_wnd, g_gc_clean, x, y, cx, cy, g_wnd, srcx, srcy,
- GR_MODE_COPY);
- }
- }
- else
- {
- unimpl("opcode %d in ui_screenblt\n", opcode);
- }
-}
-
-/******************************************************************************/
-/* can't use stipple cause tsorigin don't work, GrPoint too slow,
- GrPoints too slow but better, using a copy from the screen,
- do the pattern and copy it back */
-void ui_patblt(uint8 opcode, int x, int y, int cx, int cy,
- BRUSH * brush, int bgcolor, int fgcolor)
-{
- uint8 ipattern[8], * dest, * final;
- uint32 op;
- int i, j, s, d;
- GR_WINDOW_ID pixmap;
-
- if (g_server_bpp == 16 && g_bpp == 32)
- {
- fgcolor = COLOR16TO32(fgcolor);
- bgcolor = COLOR16TO32(bgcolor);
- }
- switch (brush->style)
- {
- case 0: /* Solid */
- if (opcode == 12 || opcode == 6)
- {
- op = g_ops[opcode];
- GrSetGCMode(g_gc, op);
- GrSetGCForeground(g_gc, fgcolor);
- GrFillRect(g_wnd, g_gc, x, y, cx, cy);
- GrSetGCMode(g_gc, GR_MODE_COPY);
- }
- else
- {
- unimpl("opcode %d in ui_patblt solid brush\n", opcode);
- }
- break;
- case 3: /* Pattern - all opcodes ok */
- for (i = 0; i != 8; i++)
- {
- ipattern[7 - i] = brush->pattern[i];
- }
- dest = xmalloc(cx * cy * g_Bpp);
- final = xmalloc(cx * cy * g_Bpp);
- memset(final, 0, cx * cy * g_Bpp);
- /* dest */
- if (opcode != 12)
- {
- GrReadArea(g_wnd, x, y, cx, cy, (GR_PIXELVAL*)dest);
- }
- for (i = 0; i < cy; i++)
- {
- for (j = 0; j < cx; j++)
- {
- if (is_pixel_on(ipattern, (x + j + brush->xorigin) % 8,
- (y + i + brush->yorigin) % 8, 8, 1))
- {
- s = fgcolor;
- }
- else
- {
- s = bgcolor;
- }
- d = get_pixel32(dest, j, i, cx ,cy);
- set_pixel32(final, j, i, cx, cy, rop(opcode, s, d));
- }
- }
- pixmap = GrNewPixmap(cx, cy, 0);
- GrArea(pixmap, g_gc_clean, 0, 0, cx, cy, final, MWPF_TRUECOLOR0888);
- GrCopyArea(g_wnd, g_gc, x, y, cx, cy, pixmap, 0, 0, GR_MODE_COPY);
- GrDestroyWindow(pixmap);
- xfree(dest);
- xfree(final);
- break;
- }
-}
-
-/*****************************************************************************/
-void ui_destblt(uint8 opcode, int x, int y, int cx, int cy)
-{
- uint32 op;
-
- if (opcode == 0) /* black */
- {
- GrSetGCForeground(g_gc, 0);
- opcode = 12;
- }
- else if (opcode == 5) /* invert */
- {
- GrSetGCForeground(g_gc, 0xffffffff);
- opcode = 6;
- }
- else if (opcode == 15) /* white */
- {
- GrSetGCForeground(g_gc, 0xffffffff);
- opcode = 12;
- }
- if (opcode == 12 || opcode == 6)
- {
- op = g_ops[opcode];
- GrSetGCMode(g_gc, op);
- GrFillRect(g_wnd, g_gc, x, y, cx, cy);
- GrSetGCMode(g_gc, GR_MODE_COPY);
- }
- else
- {
- unimpl("opcode %d in ui_destblt\n", opcode);
- }
-}
-
-/*****************************************************************************/
-void ui_paint_bitmap(int x, int y, int cx, int cy,
- int width, int height, uint8 * data)
-{
- void * b;
-
- b = ui_create_bitmap(width, height, data);
- ui_memblt(12, x, y, cx, cy, b, 0, 0);
- ui_destroy_bitmap(b);
-}
-
-/*****************************************************************************/
-void ui_move_pointer(int x, int y)
-{
- GrMoveCursor(x, y);
-}
-
-/*****************************************************************************/
-void ui_set_null_cursor(void)
-{
- GrSetWindowCursor(g_wnd, g_null_cursor);
-}
-
-/*****************************************************************************/
-void ui_set_cursor(void * cursor)
-{
- GrSetWindowCursor(g_wnd, (GR_CURSOR_ID)cursor);
-}
-
-//******************************************************************************
-static int is24on(uint8 * data, int x, int y)
-{
- uint8 r, g, b;
- int start;
-
- if (data == 0)
- {
- return 0;
- }
- start = y * 32 * 3 + x * 3;
- r = data[start];
- g = data[start + 1];
- b = data[start + 2];
- return !((r == 0) && (g == 0) && (b == 0));
-}
-
-//******************************************************************************
-static int is1on(uint8 * data, int x, int y)
-{
- int start;
- int shift;
-
- if (data == 0)
- {
- return 0;
- }
- start = (y * 32) / 8 + x / 8;
- shift = x % 8;
- return (data[start] & (0x80 >> shift)) == 0;
-}
-
-//******************************************************************************
-static void set1(uint8 * data, int x, int y)
-{
- int start;
- int shift;
-
- if (data == 0)
- {
- return;
- }
- start = (y * 32) / 8 + x / 8;
- shift = x % 8;
- data[start] = data[start] | (0x80 >> shift);
-}
-
-//******************************************************************************
-static void flipover(uint8 * data)
-{
- uint8 adata[128];
- int index;
-
- if (data == 0)
- {
- return;
- }
- memcpy(adata, data, 128);
- for (index = 0; index <= 31; index++)
- {
- data[127 - (index * 4 + 3)] = adata[index * 4];
- data[127 - (index * 4 + 2)] = adata[index * 4 + 1];
- data[127 - (index * 4 + 1)] = adata[index * 4 + 2];
- data[127 - index * 4] = adata[index * 4 + 3];
- }
-}
-
-/*****************************************************************************/
-void * ui_create_cursor(uint32 x, uint32 y,
- int width, int height,
- uint8 * andmask, uint8 * xormask)
-{
- uint8 adata[128];
- uint8 amask[128];
- GR_BITMAP * databitmap;
- GR_BITMAP * maskbitmap;
- GR_CURSOR_ID cursor;
- int i1, i2, bon, mon;
-
- if (width != 32 || height != 32)
- {
- return 0;
- }
- memset(adata, 0, 128);
- memset(amask, 0, 128);
- for (i1 = 0; i1 <= 31; i1++)
- {
- for (i2 = 0; i2 <= 31; i2++)
- {
- mon = is24on(xormask, i1, i2);
- bon = is1on(andmask, i1, i2);
- if (bon ^ mon) // xor
- {
- set1(adata, i1, i2);
- if (!mon)
- {
- set1(amask, i1, i2);
- }
- }
- if (mon)
- {
- set1(amask, i1, i2);
- }
- }
- }
- flipover(adata);
- flipover(amask);
- databitmap = ui_create_glyph(32, 32, adata);
- maskbitmap = ui_create_glyph(32, 32, amask);
- cursor = GrNewCursor(32, 32, x, y, 0xffffff, 0, databitmap, maskbitmap);
- ui_destroy_glyph(databitmap);
- ui_destroy_glyph(maskbitmap);
- return (void*)cursor;
-}
-
-/*****************************************************************************/
-void ui_destroy_cursor(void * cursor)
-{
- GrDestroyCursor((GR_CURSOR_ID)cursor);
-}
-
-/*****************************************************************************/
-uint16 ui_get_numlock_state(uint32 state)
-{
- return 0;
-}
-
-/*****************************************************************************/
-uint32 read_keyboard_state(void)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void ui_resize_window(void)
-{
-}
-
-/*****************************************************************************/
-void ui_begin_update(void)
-{
-}
-
-/*****************************************************************************/
-void ui_end_update(void)
-{
-}
-
-/*****************************************************************************/
-void ui_polygon(uint8 opcode, uint8 fillmode, POINT * point, int npoints,
- BRUSH * brush, int bgcolor, int fgcolor)
-{
-/* not used, turned off */
-}
-
-/*****************************************************************************/
-void ui_polyline(uint8 opcode, POINT * points, int npoints, PEN * pen)
-{
- int i, x, y, dx, dy;
-
- if (npoints > 0)
- {
- x = points[0].x;
- y = points[0].y;
- for (i = 1; i < npoints; i++)
- {
- dx = points[i].x;
- dy = points[i].y;
- ui_line(opcode, x, y, x + dx, y + dy, pen);
- x = x + dx;
- y = y + dy;
- }
- }
-}
-
-/*****************************************************************************/
-void ui_ellipse(uint8 opcode, uint8 fillmode,
- int x, int y, int cx, int cy,
- BRUSH * brush, int bgcolor, int fgcolor)
-{
-/* not used, turned off */
-}
-
-/*****************************************************************************/
-void generate_random(uint8 * random)
-{
- memcpy(random, "12345678901234567890123456789012", 32);
-}
-
-/*****************************************************************************/
-void save_licence(uint8 * data, int length)
-{
-}
-
-/*****************************************************************************/
-int load_licence(uint8 ** data)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void * xrealloc(void * in, int size)
-{
- if (size < 1)
- {
- size = 1;
- }
- return realloc(in, size);
-}
-
-/*****************************************************************************/
-void * xmalloc(int size)
-{
- return malloc(size);
-}
-
-/*****************************************************************************/
-void xfree(void * in)
-{
- if (in != 0)
- {
- free(in);
- }
-}
-
-/*****************************************************************************/
-char * xstrdup(const char * s)
-{
- char * mem = strdup(s);
- if (mem == NULL)
- {
- perror("strdup");
- exit(1);
- }
- return mem;
-}
-
-/*****************************************************************************/
-void warning(char * format, ...)
-{
- va_list ap;
-
- fprintf(stderr, "WARNING: ");
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- va_end(ap);
-}
-
-/*****************************************************************************/
-void unimpl(char * format, ...)
-{
- va_list ap;
-
- fprintf(stderr, "NOT IMPLEMENTED: ");
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- va_end(ap);
-}
-
-/*****************************************************************************/
-void error(char * format, ...)
-{
- va_list ap;
-
- fprintf(stderr, "ERROR: ");
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- va_end(ap);
-}
-
-/*****************************************************************************/
-int rd_pstcache_mkdir(void)
-{
- return 0;
-}
-
-/*****************************************************************************/
-int rd_open_file(char * filename)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void rd_close_file(int fd)
-{
- return;
-}
-
-/*****************************************************************************/
-int rd_read_file(int fd, void * ptr, int len)
-{
- return 0;
-}
-
-/*****************************************************************************/
-int rd_write_file(int fd, void * ptr, int len)
-{
- return 0;
-}
-
-/*****************************************************************************/
-int rd_lseek_file(int fd, int offset)
-{
- return 0;
-}
-
-/*****************************************************************************/
-int rd_lock_file(int fd, int start, int len)
-{
- return False;
-}
-
-/*****************************************************************************/
-/*static int key(int ch, int flags)
-{
- return (ch & 0xffff) | ((flags & 0xffff) << 16);
-}*/
-
-/*****************************************************************************/
-static void init_keys(void)
-{
- memset(&g_keys, 0, sizeof(g_keys));
- g_keys[0x01].ch1 = 27; /* esc */
- g_keys[0x02].ch1 = '1';
- g_keys[0x02].chs = '!';
- g_keys[0x03].ch1 = '2';
- g_keys[0x03].chs = '@';
- g_keys[0x04].ch1 = '3';
- g_keys[0x04].chs = '#';
- g_keys[0x05].ch1 = '4';
- g_keys[0x05].chs = '$';
- g_keys[0x06].ch1 = '5';
- g_keys[0x06].chs = '%';
- g_keys[0x07].ch1 = '6';
- g_keys[0x07].chs = '^';
- g_keys[0x08].ch1 = '7';
- g_keys[0x08].chs = '&';
- g_keys[0x09].ch1 = '8';
- g_keys[0x09].chs = '*';
- g_keys[0x0a].ch1 = '9';
- g_keys[0x0a].chs = '(';
- g_keys[0x0b].ch1 = '0';
- g_keys[0x0b].chs = ')';
- g_keys[0x0c].ch1 = '-';
- g_keys[0x0c].chs = '_';
- g_keys[0x0d].ch1 = '=';
- g_keys[0x0d].chs = '+';
- g_keys[0x0e].ch1 = 8; /* backspace */
- g_keys[0x0f].ch1 = 9; /* tab */
- g_keys[0x10].ch1 = 'q';
- g_keys[0x10].chs = 'Q';
- g_keys[0x11].ch1 = 'w';
- g_keys[0x11].chs = 'W';
- g_keys[0x12].ch1 = 'e';
- g_keys[0x12].chs = 'E';
- g_keys[0x13].ch1 = 'r';
- g_keys[0x13].chs = 'R';
- g_keys[0x14].ch1 = 't';
- g_keys[0x14].chs = 'T';
- g_keys[0x15].ch1 = 'y';
- g_keys[0x15].chs = 'Y';
- g_keys[0x16].ch1 = 'u';
- g_keys[0x16].chs = 'U';
- g_keys[0x17].ch1 = 'i';
- g_keys[0x17].chs = 'I';
- g_keys[0x18].ch1 = 'o';
- g_keys[0x18].chs = 'O';
- g_keys[0x19].ch1 = 'p';
- g_keys[0x19].chs = 'P';
- g_keys[0x1a].ch1 = '[';
- g_keys[0x1a].chs = '{';
- g_keys[0x1b].ch1 = ']';
- g_keys[0x1b].chs = '}';
- g_keys[0x1c].ch2 = 13; /* enter */
- g_keys[0x1d].ch1 = 63533; /* left control */
- g_keys[0x1d].ch2 = 63534; /* right control */
- g_keys[0x1e].ch1 = 'a';
- g_keys[0x1e].chs = 'A';
- g_keys[0x1f].ch1 = 's';
- g_keys[0x1f].chs = 'S';
- g_keys[0x20].ch1 = 'd';
- g_keys[0x20].chs = 'D';
- g_keys[0x21].ch1 = 'f';
- g_keys[0x21].chs = 'F';
- g_keys[0x22].ch1 = 'g';
- g_keys[0x22].chs = 'G';
- g_keys[0x23].ch1 = 'h';
- g_keys[0x23].chs = 'H';
- g_keys[0x24].ch1 = 'j';
- g_keys[0x24].chs = 'J';
- g_keys[0x25].ch1 = 'k';
- g_keys[0x25].chs = 'K';
- g_keys[0x26].ch1 = 'l';
- g_keys[0x26].chs = 'L';
- g_keys[0x27].ch1 = ';';
- g_keys[0x27].chs = ':';
- g_keys[0x28].ch1 = '\'';
- g_keys[0x28].chs = '"';
- g_keys[0x29].ch1 = '`';
- g_keys[0x29].chs = '~';
- g_keys[0x2a].ch1 = 63531; /* left shift */
- g_keys[0x2b].ch1 = '\\';
- g_keys[0x2c].ch1 = 'z';
- g_keys[0x2c].chs = 'Z';
- g_keys[0x2d].ch1 = 'x';
- g_keys[0x2d].chs = 'X';
- g_keys[0x2e].ch1 = 'c';
- g_keys[0x2e].chs = 'C';
- g_keys[0x2f].ch1 = 'v';
- g_keys[0x2f].chs = 'V';
- g_keys[0x30].ch1 = 'b';
- g_keys[0x30].chs = 'B';
- g_keys[0x31].ch1 = 'n';
- g_keys[0x31].chs = 'N';
- g_keys[0x32].ch1 = 'm';
- g_keys[0x32].chs = 'M';
- g_keys[0x33].ch1 = ',';
- g_keys[0x33].chs = '<';
- g_keys[0x34].ch1 = '.';
- g_keys[0x34].chs = '>';
- g_keys[0x35].ch1 = '/';
- g_keys[0x35].ch2 = 63509;
- g_keys[0x35].chs = '?';
- g_keys[0x36].ch1 = 63532; /* right shift */
- g_keys[0x37].ch1 = '*'; /* star on keypad */
- g_keys[0x37].ch2 = 63510; /* star on keypad */
- g_keys[0x38].ch1 = 63535; /* alt */
- g_keys[0x38].ch2 = 63536; /* alt */
- g_keys[0x39].ch1 = ' ';
- g_keys[0x3a].ch1 = 0; /* caps lock */
- g_keys[0x3b].ch1 = 63515; /* f1 */
- g_keys[0x3c].ch1 = 63516; /* f2 */
- g_keys[0x3d].ch1 = 63517; /* f3 */
- g_keys[0x3e].ch1 = 63518; /* f4 */
- g_keys[0x3f].ch1 = 63519; /* f5 */
- g_keys[0x40].ch1 = 63520; /* f6 */
- g_keys[0x41].ch1 = 63521; /* f7 */
- g_keys[0x42].ch1 = 63522; /* f8 */
- g_keys[0x43].ch1 = 63523; /* f9 */
- g_keys[0x44].ch1 = 63524; /* f10 */
- g_keys[0x45].ch1 = 0; /* num lock */
- g_keys[0x46].ch1 = 0; /* scroll lock */
- g_keys[0x47].ch1 = 63505; /* home */
- g_keys[0x47].ch2 = 63494; /* home */
- g_keys[0x48].ch1 = 63490; /* arrow up */
- g_keys[0x48].ch2 = 63506; /* arrow up */
- g_keys[0x49].ch1 = 63507; /* page up */
- g_keys[0x49].ch2 = 63496; /* page up */
- g_keys[0x4a].ch1 = '-'; /* -(minus) on keypad */
- g_keys[0x4a].ch2 = 63511; /* -(minus) on keypad */
- g_keys[0x4b].ch1 = 63502; /* arrow left */
- g_keys[0x4b].ch2 = 63488; /* arrow left */
- g_keys[0x4c].ch1 = 63503; /* middle(5 key) on keypad */
- g_keys[0x4d].ch1 = 63504; /* arrow right */
- g_keys[0x4d].ch2 = 63489; /* arrow right */
- g_keys[0x4e].ch1 = '+'; /* +(plus) on keypad */
- g_keys[0x4e].ch2 = 63512; /* +(plus) on keypad */
- g_keys[0x4f].ch1 = 63499; /* end */
- g_keys[0x4f].ch2 = 63495; /* end */
- g_keys[0x50].ch1 = 63500; /* arrow down */
- g_keys[0x50].ch2 = 63491; /* arrow down */
- g_keys[0x51].ch1 = 63501; /* page down */
- g_keys[0x51].ch2 = 63497; /* page down */
- g_keys[0x52].ch1 = 63498; /* insert */
- g_keys[0x52].ch2 = 63492; /* insert */
- g_keys[0x53].ch1 = 63508; /* delete */
- g_keys[0x53].ch2 = 63493; /* delete */
- g_keys[0x54].ch1 = 63525; /* f11 */
- g_keys[0x54].ch1 = 63527; /* f12 */
-}
-
-/*****************************************************************************/
-/* returns 0 if found key */
-static int get_sc(GR_EVENT_KEYSTROKE * event_keystroke, int * sc, int * ec)
-{
- int i;
-
- //printf("%d %d\n", event_keystroke->ch, event_keystroke->modifiers);
- *sc = 0;
- *ec = 0;
- for (i = 0; i < 256; i++)
- {
- if (event_keystroke->modifiers & 1) /* shift is down */
- {
- if (event_keystroke->ch == g_keys[i].chs)
- {
- *sc = i;
- break;
- }
- }
- if (event_keystroke->ch == g_keys[i].ch1 ||
- event_keystroke->ch == g_keys[i].ch2 ||
- event_keystroke->ch == g_keys[i].ch3)
- {
- *sc = i;
- break;
- }
- }
- if (*sc == 0)
- {
- return 1;
- }
- else
- {
- return 0;
- }
-}
-
-/*****************************************************************************/
-void static process_keystroke(GR_EVENT_KEYSTROKE * event_keystroke, int down)
-{
- int sc, ec;
-
- if (get_sc(event_keystroke, &sc, &ec) == 0)
- {
- if (down)
- {
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, sc, ec);
- }
- else
- {
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, sc, ec);
- }
- }
-}
-
-/*****************************************************************************/
-void nanox_event(GR_EVENT * ev)
-{
- GR_EVENT_MOUSE * event_mouse;
- GR_EVENT_BUTTON * event_button;
- GR_EVENT_FDINPUT * event_fdinput;
- GR_EVENT_KEYSTROKE * event_keystroke;
-
- do
- {
- if (ev->type == GR_EVENT_TYPE_FDINPUT) /* 12 */
- {
- event_fdinput = (GR_EVENT_FDINPUT *) ev;
- if (event_fdinput->fd == g_sck)
- {
- if (!rdp_loop(&g_deactivated, &g_ext_disc_reason))
- {
- fprintf(stderr, "rdp_loop in nanox_event exit codes %d %d\n",
- g_deactivated, g_ext_disc_reason);
- exit(1);
- }
- }
- }
- else if (ev->type == GR_EVENT_TYPE_BUTTON_DOWN) /* 2 */
- {
- event_button = (GR_EVENT_BUTTON *) ev;
- if (event_button->changebuttons & 4) /* left */
- {
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1,
- event_button->x, event_button->y);
- }
- else if (event_button->changebuttons & 1) /* right */
- {
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2,
- event_button->x, event_button->y);
- }
- }
- else if (ev->type == GR_EVENT_TYPE_BUTTON_UP) /* 3 */
- {
- event_button = (GR_EVENT_BUTTON *) ev;
- if (event_button->changebuttons & 4) /* left */
- {
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1,
- event_button->x, event_button->y);
- }
- else if (event_button->changebuttons & 1) /* right */
- {
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2,
- event_button->x, event_button->y);
- }
- }
- else if (ev->type == GR_EVENT_TYPE_MOUSE_MOTION) /* 6 */
- {
- event_mouse = (GR_EVENT_MOUSE *) ev;
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE,
- event_mouse->x, event_mouse->y);
- }
- else if (ev->type == GR_EVENT_TYPE_MOUSE_POSITION) /* 7 */
- {
- /* use GR_EVENT_TYPE_MOUSE_MOTION */
- }
- else if (ev->type == GR_EVENT_TYPE_KEY_DOWN) /* 8 */
- {
- event_keystroke = (GR_EVENT_KEYSTROKE *) ev;
- process_keystroke(event_keystroke, 1);
- }
- else if (ev->type == GR_EVENT_TYPE_KEY_UP) /* 9 */
- {
- event_keystroke = (GR_EVENT_KEYSTROKE *) ev;
- process_keystroke(event_keystroke, 0);
- }
- else if (ev->type == GR_EVENT_TYPE_FOCUS_IN) /* 10 */
- {
- }
- else if (ev->type == GR_EVENT_TYPE_FOCUS_OUT) /* 11 */
- {
- }
- else if (ev->type == GR_EVENT_TYPE_UPDATE) /* 13 */
- {
- }
- GrCheckNextEvent(ev);
- } while (ev->type != GR_EVENT_TYPE_NONE);
-}
-
-/*****************************************************************************/
-static void get_username_and_hostname(void)
-{
- char fullhostname[64];
- char * p;
- struct passwd * pw;
-
- STRNCPY(g_username, "unknown", sizeof(g_username));
- STRNCPY(g_hostname, "unknown", sizeof(g_hostname));
- pw = getpwuid(getuid());
- if (pw != NULL && pw->pw_name != NULL)
- {
- STRNCPY(g_username, pw->pw_name, sizeof(g_username));
- }
- if (gethostname(fullhostname, sizeof(fullhostname)) != -1)
- {
- p = strchr(fullhostname, '.');
- if (p != NULL)
- {
- *p = 0;
- }
- STRNCPY(g_hostname, fullhostname, sizeof(g_hostname));
- }
-}
-/*****************************************************************************/
-static void out_params(void)
-{
- fprintf(stderr, "rdesktop: A Remote Desktop Protocol client.\n");
- fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2005 Matt Chapman.\n");
- fprintf(stderr, "nanox uiport by Jay Sorg\n");
- fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n");
- fprintf(stderr, "Usage: nanoxrdesktop [options] server\n");
- fprintf(stderr, " -u: user name\n");
- fprintf(stderr, " -n: client hostname\n");
- fprintf(stderr, " -p: password\n");
- fprintf(stderr, " -d: domain\n");
- fprintf(stderr, " -s: shell\n");
- fprintf(stderr, " -c: working directory\n");
- fprintf(stderr, "\n");
-}
-
-/*****************************************************************************/
-static int parse_parameters(int in_argc, char ** in_argv)
-{
- int i;
-
- if (in_argc <= 1)
- {
- out_params();
- return 0;
- }
- for (i = 1; i < in_argc; i++)
- {
- strcpy(g_servername, in_argv[i]);
- if (strcmp(in_argv[i], "-h") == 0)
- {
- out_params();
- return 0;
- }
- else if (strcmp(in_argv[i], "-n") == 0)
- {
- STRNCPY(g_hostname, in_argv[i + 1], sizeof(g_hostname));
- }
- else if (strcmp(in_argv[i], "-u") == 0)
- {
- STRNCPY(g_username, in_argv[i + 1], sizeof(g_username));
- }
- else if (strcmp(in_argv[i], "-p") == 0)
- {
- STRNCPY(g_password, in_argv[i + 1], sizeof(g_password));
- g_flags |= RDP_LOGON_AUTO;
- i++;
- }
- else if (strcmp(in_argv[i], "-d") == 0)
- {
- STRNCPY(g_domain, in_argv[i + 1], sizeof(g_domain));
- i++;
- }
- else if (strcmp(in_argv[i], "-s") == 0)
- {
- STRNCPY(g_shell, in_argv[i + 1], sizeof(g_shell));
- i++;
- }
- else if (strcmp(in_argv[i], "-c") == 0)
- {
- STRNCPY(g_directory, in_argv[i + 1], sizeof(g_directory));
- i++;
- }
- }
- return 1;
-}
-
-/*****************************************************************************/
-int main(int in_argc, char ** in_argv)
-{
- get_username_and_hostname();
- /* read command line options */
- if (!parse_parameters(in_argc, in_argv))
- {
- exit(0);
- }
- /* connect to server */
- if (GrOpen() < 0)
- {
- fprintf(stderr, "Couldn't connect to Nano-X server\n");
- exit(1);
- }
- GrGetScreenInfo(&g_screen_info);
- g_bpp = g_screen_info.bpp;
- g_Bpp = (g_screen_info.bpp + 7) / 8;
- g_width = g_screen_info.vs_width;
- g_height = g_screen_info.vs_height;
- g_clip.x = 0;
- g_clip.y = 0;
- g_clip.width = g_width;
- g_clip.height = g_height;
- if (!((g_bpp == 32 && g_server_bpp == 16) ||
- (g_bpp == 16 && g_server_bpp == 16)))
- {
- fprintf(stderr, "unsupported bpp, server = %d, client = %d\n",
- g_server_bpp, g_bpp);
- GrClose();
- exit(0);
- }
- init_keys();
- /* connect to server */
- if (!rdp_connect(g_servername, g_flags, g_domain, g_password, g_shell,
- g_directory))
- {
- fprintf(stderr, "Error connecting\n");
- GrClose();
- exit(1);
- }
- /* create window */
- g_wnd = GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, g_width, g_height, 0, 0, 0);
- /* show window */
- GrMapWindow(g_wnd);
- /* create graphic context */
- g_gc = GrNewGC();
- g_gc_clean = GrNewGC();
- /* clear screen */
- GrSetGCForeground(g_gc, 0);
- GrFillRect(g_wnd, g_gc, 0, 0, g_width, g_height);
- /* create null cursor */
- g_null_cursor = (GR_CURSOR_ID)ui_create_cursor(0, 0, 32, 32, 0, 0);
- /* register callbacks, set mask, and run main loop */
- GrSelectEvents(g_wnd, -1); /* all events */
- GrRegisterInput(g_sck);
- GrMainLoop(nanox_event);
- /* free null cursor */
- ui_destroy_cursor((void*)g_null_cursor);
- /* free graphic context */
- GrDestroyGC(g_gc);
- GrDestroyGC(g_gc_clean);
- /* free window */
- GrDestroyWindow(g_wnd);
- /* close connection */
- GrClose();
- return 0;
-}
diff --git a/uiports/qtereadme.txt b/uiports/qtereadme.txt
deleted file mode 100755
index 42091eb..0000000
--- a/uiports/qtereadme.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-This is the Qt/Emb ui port
-qt should be installed in /usr/local/qt
-you may need to have LD_LIBRARY_PATH and QTDIR defined to run qtrdesktop
-tested with versions 2.3, 3.1
-
-makefile_qte can be edited to change file locations
-run make -f makefile_qte in this directory to compile it
-
-qtereadme.txt - notes, this file
-makefile_qte - makefile
-qtewin.cpp - ui lib
-qtewin.h - header
diff --git a/uiports/qtewin.cpp b/uiports/qtewin.cpp
deleted file mode 100644
index 05246ba..0000000
--- a/uiports/qtewin.cpp
+++ /dev/null
@@ -1,2555 +0,0 @@
-/* -*- c-basic-offset: 8 -*-
- rdesktop: A Remote Desktop Protocol client.
- User interface services - QT Emb System
- Copyright (C) Jay Sorg 2004-2005
-
- 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 3 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, see .
-*/
-
-//#define SHARP
-
-#ifdef SHARP
-#include
-#else
-#include
-#endif
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include // va_list va_start va_end
-#include // gethostname
-#include // getpwuid
-
-#include "../rdesktop.h"
-#include "qtewin.h"
-
-#define QT_OPTI
-
-extern int g_tcp_port_rdp;
-int g_encryption = 1;
-int g_bitmap_cache = 1;
-int g_bitmap_cache_persist_enable = 0;
-int g_bitmap_cache_precache = 1;
-int g_use_rdp5 = 1;
-int g_desktop_save = 1;
-int g_polygon_ellipse_orders = 0;
-int g_rdp5_performanceflags =
- RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG | RDP5_NO_MENUANIMATIONS;
-int g_console_session = 0;
-int g_keylayout = 0x409; /* Defaults to US keyboard layout */
-int g_keyboard_type = 0x4; /* Defaults to US keyboard layout */
-int g_keyboard_subtype = 0x0; /* Defaults to US keyboard layout */
-int g_keyboard_functionkeys = 0xc; /* Defaults to US keyboard layout */
-int g_width = 640;
-int g_height = 480;
-int g_server_bpp = 8;
-char g_hostname[16] = "";
-char g_username[100] = "";
-
-#ifdef WITH_RDPSND
-extern int g_dsp_busy;
-extern int g_dsp_fd;
-int g_rdpsnd = 0;
-static QSocketNotifier * g_SoundNotifier = 0;
-#endif
-
-/* types */
-struct QColorMap
-{
- uint32 RGBColors[256];
- uint32 NumColors;
-};
-
-struct bitmap
-{
- int w;
- int h;
- uint8 * data;
-};
-
-static int g_client_width = 640;
-static int g_client_height = 480;
-static uint32 g_flags = RDP_LOGON_NORMAL;
-static char g_server[64] = "";
-static char g_domain[16] = "";
-static char g_password[16] = "";
-static char g_shell[128] = "";
-static char g_directory[32] = "";
-static int g_fullscreen = 0;
-static int g_global_sock = 0;
-static int g_deactivated = 0;
-static uint32 g_ext_disc_reason = 0;
-
-static QSocketNotifier * g_SocketNotifier = 0;
-#ifdef SHARP
-static QPEApplication * g_App = 0;
-#else
-static QApplication * g_App = 0;
-#endif
-static QMyMainWindow * g_MW = 0;
-static QMyScrollView * g_SV = 0;
-static struct QColorMap * g_CM = 0;
-static uint8 * g_BS = 0; /* the screen data */
-static int g_clipx = 0;
-static int g_clipy = 0;
-static int g_clipcx = 0;
-static int g_clipcy = 0;
-
-/* Session Directory redirection */
-BOOL g_redirect = False;
-char g_redirect_server[64];
-char g_redirect_domain[16];
-char g_redirect_password[64];
-char g_redirect_username[64];
-char g_redirect_cookie[128];
-uint32 g_redirect_flags = 0;
-
-#define BPP ((g_server_bpp + 7) / 8)
-#define GETPIXEL8(d, x, y, w) (*(((uint8*)d) + ((y) * (w) + (x))))
-#define GETPIXEL16(d, x, y, w) (*(((uint16*)d) + ((y) * (w) + (x))))
-#define GETPIXEL32(d, x, y, w) (*(((uint32*)d) + ((y) * (w) + (x))))
-#define SETPIXEL8(d, x, y, w, v) *(((uint8*)d) + ((y) * (w) + (x))) = v
-#define SETPIXEL16(d, x, y, w, v) *(((uint16*)d) + ((y) * (w) + (x))) = v
-#define SETPIXEL32(d, x, y, w, v) *(((uint32*)d) + ((y) * (w) + (x))) = v
-
-/******************************************************************************/
-void CleanString(QString * Item)
-{
- int i;
-
- i = Item->length() - 1;
- while (i >= 0)
- {
- if (Item->at(i) == 10 || Item->at(i) == 13)
- {
- Item->remove(i, 1);
- }
- i--;
- }
-}
-
-/******************************************************************************/
-QMyDialog::QMyDialog(QWidget * parent) : QDialog(parent, "Settings", true)
-{
- int i, j;
- char * home;
- char Text[256];
- QString Line;
- QString ItemName;
- QString ItemValue;
-
- // resize dialog
- resize(230, 270);
- // main list box
- ListBox = new QListBox(this);
- ListBox->move(10, 10);
- ListBox->resize(200, 100);
- connect(ListBox, SIGNAL(selectionChanged()), this, SLOT(ListBoxChanged()));
- connect(ListBox, SIGNAL(selected(int)), this, SLOT(ListBoxSelected(int)));
- // server
- Label1 = new QLabel(this);
- Label1->setText("Server Desc");
- Label1->move(10, 120);
- Label1->resize(100, 20);
- ServerNameEdit = new QLineEdit(this);
- ServerNameEdit->move(75, 120);
- ServerNameEdit->resize(100, 20);
- // username
- Label2 = new QLabel(this);
- Label2->setText("User Name");
- Label2->move(10, 150);
- Label2->resize(100, 20);
- UserNameEdit = new QLineEdit(this);
- UserNameEdit->move(75, 150);
- UserNameEdit->resize(100, 20);
- // ip
- Label3 = new QLabel(this);
- Label3->setText("Server IP");
- Label3->move(10, 180);
- Label3->resize(100, 20);
- IPEdit = new QLineEdit(this);
- IPEdit->move(75, 180);
- IPEdit->resize(100, 20);
- // width and height
- WidthHeightBox = new QComboBox(this);
- WidthHeightBox->move(10, 210);
- WidthHeightBox->resize(100, 20);
- WidthHeightBox->insertItem("240x320");
- WidthHeightBox->insertItem("640x480");
- WidthHeightBox->insertItem("800x600");
- connect(WidthHeightBox, SIGNAL(activated(int)), this, SLOT(ComboChanged(int)));
- WidthHeightBox->setCurrentItem(1);
- WidthEdit = new QLineEdit(this);
- WidthEdit->move(110, 210);
- WidthEdit->resize(30, 20);
- WidthEdit->setText("800");
- HeightEdit = new QLineEdit(this);
- HeightEdit->move(140, 210);
- HeightEdit->resize(30, 20);
- HeightEdit->setText("600");
- // add to list button
- AddButton = new QPushButton(this);
- AddButton->move(180, 120);
- AddButton->resize(50, 20);
- AddButton->setText("Add");
- connect(AddButton, SIGNAL(clicked()), this, SLOT(AddClicked()));
- // change list item button
- EditButton = new QPushButton(this);
- EditButton->move(180, 140);
- EditButton->resize(50, 20);
- EditButton->setText("Edit");
- connect(EditButton, SIGNAL(clicked()), this, SLOT(EditClicked()));
- // save to file button
- SaveButton = new QPushButton(this);
- SaveButton->move(180, 160);
- SaveButton->resize(50, 20);
- SaveButton->setText("Save");
- connect(SaveButton, SIGNAL(clicked()), this, SLOT(SaveClicked()));
- // remove an item button
- RemoveButton = new QPushButton(this);
- RemoveButton->move(180, 180);
- RemoveButton->resize(50, 20);
- RemoveButton->setText("Remove");
- connect(RemoveButton, SIGNAL(clicked()), this, SLOT(RemoveClicked()));
- // full screen check box
- FullScreenCheckBox = new QCheckBox(this, "Full Screen");
- FullScreenCheckBox->setText("Full Screen");
- FullScreenCheckBox->move(10, 230);
- // ok button
- OKButton = new QPushButton(this);
- OKButton->setText("OK");
- OKButton->move(100, 240);
- OKButton->resize(50, 20);
- connect(OKButton, SIGNAL(clicked()), this, SLOT(OKClicked()));
- // cancel button
- CancelButton = new QPushButton(this);
- CancelButton->setText("Cancel");
- CancelButton->move(160, 240);
- CancelButton->resize(50, 20);
- connect(CancelButton, SIGNAL(clicked()), this, SLOT(CancelClicked()));
-
- for (i = 0; i < 10; i++)
- {
- ConnectionList[i] = new QMyConnectionItem;
- ConnectionList[i]->ServerName = "";
- ConnectionList[i]->UserName = "";
- ConnectionList[i]->ServerIP = "";
- ConnectionList[i]->Width = 0;
- ConnectionList[i]->Height = 0;
- ConnectionList[i]->FullScreen = 0;
- }
- home = getenv("HOME");
- if (home != NULL)
- {
- sprintf(Text, "%s/rdesktop.ini", home);
- QFile * File = new QFile(Text);
- if (File->open(IO_ReadOnly))
- {
- i = -1;
- while (!File->atEnd())
- {
- File->readLine(Line, 255);
- j = Line.find("=");
- if (j > 0)
- {
- ItemName = Line.mid(0, j);
- CleanString(&ItemName);
- ItemValue = Line.mid(j + 1);
- CleanString(&ItemValue);
- if (ItemName == "Server")
- {
- i++;
- ConnectionList[i]->ServerName = ItemValue;
- ListBox->insertItem(ItemValue);
- }
- else if (ItemName == "UserName")
- ConnectionList[i]->UserName = ItemValue;
- else if (ItemName == "Width")
- ConnectionList[i]->Width = ItemValue.toInt();
- else if (ItemName == "Height")
- ConnectionList[i]->Height = ItemValue.toInt();
- else if (ItemName == "IP")
- ConnectionList[i]->ServerIP = ItemValue;
- else if (ItemName == "FullScreen")
- ConnectionList[i]->FullScreen = (ItemValue != "0");
- }
- }
- }
- delete File;
- }
-}
-
-/******************************************************************************/
-QMyDialog::~QMyDialog()
-{
- QMyConnectionItem * Item;
- int i;
-
- for (i = 0; i < 10; i++)
- {
- Item = ConnectionList[i];
- delete Item;
- }
-}
-
-/******************************************************************************/
-void QMyDialog::ComboChanged(int index)
-{
- if (index == 0)
- {
- WidthEdit->setText("240");
- HeightEdit->setText("320");
- }
- if (index == 1)
- {
- WidthEdit->setText("640");
- HeightEdit->setText("480");
- }
- else if (index == 2)
- {
- WidthEdit->setText("800");
- HeightEdit->setText("600");
- }
-}
-
-/******************************************************************************/
-void QMyDialog::OKClicked()
-{
- ServerName = ServerNameEdit->text();
- UserName = UserNameEdit->text();
- Width = WidthEdit->text().toInt();
- Height = HeightEdit->text().toInt();
- ServerIP = IPEdit->text();
- FullScreen = FullScreenCheckBox->isChecked();
- done(1);
-}
-
-/******************************************************************************/
-void QMyDialog::CancelClicked()
-{
- done(0);
-}
-
-/******************************************************************************/
-void QMyDialog::AddClicked()
-{
- int i;
- QMyConnectionItem * Item;
-
- i = ListBox->count();
- if (i < 10)
- {
- ListBox->insertItem(ServerNameEdit->text());
- Item = ConnectionList[i];
- Item->ServerName = ServerNameEdit->text();
- Item->UserName = UserNameEdit->text();
- Item->Width = WidthEdit->text().toInt();
- Item->Height = HeightEdit->text().toInt();
- Item->ServerIP = IPEdit->text();
- Item->FullScreen = FullScreenCheckBox->isChecked();
- }
-}
-
-/******************************************************************************/
-void QMyDialog::EditClicked()
-{
- int i;
- QMyConnectionItem * Item;
-
- i = ListBox->currentItem();
- if (i >= 0)
- {
- Item = ConnectionList[i];
- Item->ServerName = ServerNameEdit->text();
- Item->UserName = UserNameEdit->text();
- Item->Width = WidthEdit->text().toInt();
- Item->Height = HeightEdit->text().toInt();
- Item->ServerIP = IPEdit->text();
- Item->FullScreen = FullScreenCheckBox->isChecked();
- ListBox->changeItem(ServerNameEdit->text(), i);
- }
-}
-
-/******************************************************************************/
-void WriteString(QFile* File, QString* Line)
-{
- File->writeBlock((const char*)(*Line), Line->length());
-}
-
-/******************************************************************************/
-void QMyDialog::SaveClicked()
-{
- int i, j;
- QMyConnectionItem * Item;
- QString Line;
- char * home;
- char Text[256];
- QFile* File;
-
- home = getenv("HOME");
- if (home != NULL)
- {
- sprintf(Text, "%s/rdesktop.ini", home);
- File = new QFile(Text);
- if (File->open(IO_Truncate | IO_ReadWrite))
- {
- i = ListBox->count();
- for (j = 0; j < i; j++)
- {
- Item = ConnectionList[j];
- Line = "Server=";
- Line += Item->ServerName;
- Line += (char)10;
- WriteString(File, &Line);
- Line = "UserName=";
- Line += Item->UserName;
- Line += (char)10;
- WriteString(File, &Line);
- Line = "Width=";
- sprintf(Text, "%d", Item->Width);
- Line += Text;
- Line += (char)10;
- WriteString(File, &Line);
- Line = "Height=";
- sprintf(Text, "%d", Item->Height);
- Line += Text;
- Line += (char)10;
- WriteString(File, &Line);
- Line = "IP=";
- Line += Item->ServerIP;
- Line += (char)10;
- WriteString(File, &Line);
- Line = "FullScreen=";
- if (Item->FullScreen)
- Line += "1";
- else
- Line += "0";
- Line += (char)10;
- WriteString(File, &Line);
- }
- }
- File->flush();
- File->close();
- delete File;
- }
-}
-
-/******************************************************************************/
-void QMyDialog::RemoveClicked()
-{
- int i, j, c;
- QMyConnectionItem * Item1;
- QMyConnectionItem * Item2;
-
- i = ListBox->currentItem();
- if (i >= 0)
- {
- c = ListBox->count();
- for (j = i; j < c - 1; j++)
- {
- Item1 = ConnectionList[i];
- Item2 = ConnectionList[i + 1];
- Item1->ServerName = Item2->ServerName;
- Item1->UserName = Item2->UserName;
- Item1->Width = Item2->Width;
- Item1->Height = Item2->Height;
- Item1->ServerIP = Item2->ServerIP;
- Item1->FullScreen = Item2->FullScreen;
- }
- ListBox->removeItem(i);
- }
-}
-
-/******************************************************************************/
-void QMyDialog::ListBoxChanged()
-{
- int i;
- QMyConnectionItem * Item;
- char Text[100];
-
- i = ListBox->currentItem();
- if (i >= 0 && i < 10)
- {
- Item = ConnectionList[i];
- ServerNameEdit->setText(Item->ServerName);
- UserNameEdit->setText(Item->UserName);
- sprintf(Text, "%d", Item->Width);
- WidthEdit->setText(Text);
- sprintf(Text, "%d", Item->Height);
- HeightEdit->setText(Text);
- IPEdit->setText(Item->ServerIP);
- FullScreenCheckBox->setChecked(Item->FullScreen != 0);
- }
-}
-
-/******************************************************************************/
-void QMyDialog::ListBoxSelected(int /*index*/)
-{
-}
-
-/******************************************************************************/
-void GetScanCode(QKeyEvent * e, int * ScanCode, int * code)
-{
- int key;
- int mod;
- int ascii;
-
- key = e->key();
- mod = e->state();
- ascii = e->ascii();
-
- *ScanCode = 0;
- *code = mod; // 8 shift, 16 control, 32 alt
-
- switch (key)
- {
- case 4096: // esc
- case 4097: // tab
- case 4099: // backspace
- case 4100: // enter
- case 4101: // enter
- case 4103: // delete
- ascii = 0;
- }
-
- if (ascii == 0)
- {
- switch (key)
- {
- case 4096: *ScanCode = 0x01; break; // esc
- case 4097: *ScanCode = 0x0f; break; // tab
- case 4099: *ScanCode = 0x0e; break; // backspace
- case 4100: *ScanCode = 0x1c; break; // enter
- case 4101: *ScanCode = 0x1c; break; // enter
- case 4112: *ScanCode = 0xc7; break; // home
- case 4113: *ScanCode = 0xcf; break; // end
- case 4102: *ScanCode = 0xd2; break; // insert
- case 4103: *ScanCode = 0xd3; break; // delete
- case 4118: *ScanCode = 0xc9; break; // page up
- case 4119: *ScanCode = 0xd1; break; // page down
- case 4117: *ScanCode = 0xd0; break; // down arrow
- case 4115: *ScanCode = 0xc8; break; // up arrow
- case 4114: *ScanCode = 0xcb; break; // left arrow
- case 4116: *ScanCode = 0xcd; break; // right arrow
- case 4128: *ScanCode = 0x2a; break; // shift
- case 4131: *ScanCode = 0x38; break; // alt
- case 4129: *ScanCode = 0x1d; break; // ctrl
- }
- if (*ScanCode != 0)
- return;
- }
-
- switch (ascii)
- {
- // first row
- case 'q': *ScanCode = 0x10; break;
- case 'Q': *ScanCode = 0x10; *code |= 8; break;
- case '1': *ScanCode = 0x02; break;
- case 'w': *ScanCode = 0x11; break;
- case 'W': *ScanCode = 0x11; *code |= 8; break;
- case '2': *ScanCode = 0x03; break;
- case 'e': *ScanCode = 0x12; break;
- case 'E': *ScanCode = 0x12; *code |= 8; break;
- case '3': *ScanCode = 0x04; break;
- case 'r': *ScanCode = 0x13; break;
- case 'R': *ScanCode = 0x13; *code |= 8; break;
- case '4': *ScanCode = 0x05; break;
- case 't': *ScanCode = 0x14; break;
- case 'T': *ScanCode = 0x14; *code |= 8; break;
- case '5': *ScanCode = 0x06; break;
- case 'y': *ScanCode = 0x15; break;
- case 'Y': *ScanCode = 0x15; *code |= 8; break;
- case '6': *ScanCode = 0x07; break;
- case 'u': *ScanCode = 0x16; break;
- case 'U': *ScanCode = 0x16; *code |= 8; break;
- case '7': *ScanCode = 0x08; break;
- case 'i': *ScanCode = 0x17; break;
- case 'I': *ScanCode = 0x17; *code |= 8; break;
- case '8': *ScanCode = 0x09; break;
- case 'o': *ScanCode = 0x18; break;
- case 'O': *ScanCode = 0x18; *code |= 8; break;
- case '9': *ScanCode = 0x0a; break;
- case 'p': *ScanCode = 0x19; break;
- case 'P': *ScanCode = 0x19; *code |= 8; break;
- case '0': *ScanCode = 0x0b; break;
- // second row
- case 'a': *ScanCode = 0x1e; break;
- case 'A': *ScanCode = 0x1e; *code |= 8; break;
- case '!': *ScanCode = 0x02; *code |= 8; break;
- case 's': *ScanCode = 0x1f; break;
- case 'S': *ScanCode = 0x1f; *code |= 8; break;
- case '@': *ScanCode = 0x03; *code |= 8; break;
- case 'd': *ScanCode = 0x20; break;
- case 'D': *ScanCode = 0x20; *code |= 8; break;
- case '#': *ScanCode = 0x04; *code |= 8; break;
- case 'f': *ScanCode = 0x21; break;
- case 'F': *ScanCode = 0x21; *code |= 8; break;
- case '$': *ScanCode = 0x05; *code |= 8; break;
- case 'g': *ScanCode = 0x22; break;
- case 'G': *ScanCode = 0x22; *code |= 8; break;
- case '%': *ScanCode = 0x06; *code |= 8; break;
- case 'h': *ScanCode = 0x23; break;
- case 'H': *ScanCode = 0x23; *code |= 8; break;
- case '_': *ScanCode = 0x0c; *code |= 8; break;
- case 'j': *ScanCode = 0x24; break;
- case 'J': *ScanCode = 0x24; *code |= 8; break;
- case '&': *ScanCode = 0x08; *code |= 8; break;
- case 'k': *ScanCode = 0x25; break;
- case 'K': *ScanCode = 0x25; *code |= 8; break;
- case '*': *ScanCode = 0x09; *code |= 8; break;
- case 'l': *ScanCode = 0x26; break;
- case 'L': *ScanCode = 0x26; *code |= 8; break;
- case '(': *ScanCode = 0x0a; *code |= 8; break;
-// case 8: *ScanCode = 0x0e; break; // backspace
- // third row
- case 'z': *ScanCode = 0x2c; break;
- case 'Z': *ScanCode = 0x2c; *code |= 8; break;
- case 'x': *ScanCode = 0x2d; break;
- case 'X': *ScanCode = 0x2d; *code |= 8; break;
- case 'c': *ScanCode = 0x2e; break;
- case 'C': *ScanCode = 0x2e; *code |= 8; break;
- case 'v': *ScanCode = 0x2f; break;
- case 'V': *ScanCode = 0x2f; *code |= 8; break;
- case 'b': *ScanCode = 0x30; break;
- case 'B': *ScanCode = 0x30; *code |= 8; break;
- case '-': *ScanCode = 0x0c; break;
- case 'n': *ScanCode = 0x31; break;
- case 'N': *ScanCode = 0x31; *code |= 8; break;
- case '+': *ScanCode = 0x0d; *code |= 8; break;
- case 'm': *ScanCode = 0x32; break;
- case 'M': *ScanCode = 0x32; *code |= 8; break;
- case '=': *ScanCode = 0x0d; break;
- case ',': *ScanCode = 0x33; break;
- case ';': *ScanCode = 0x27; break;
- case ')': *ScanCode = 0x0b; *code |= 8; break;
- // fourth row
-// case 9: *ScanCode = 0x0f; break; // tab
- case '/': *ScanCode = 0x35; break;
- case '?': *ScanCode = 0x35; *code |= 8; break;
- case ' ': *ScanCode = 0x39; break;
- case '\'': *ScanCode = 0x28; break;
- case '"': *ScanCode = 0x28; *code |= 8; break;
- case '~': *ScanCode = 0x29; *code |= 8; break;
- case '.': *ScanCode = 0x34; break;
- case ':': *ScanCode = 0x27; *code |= 8; break;
- case '<': *ScanCode = 0x33; *code |= 8; break;
-// case 13: *ScanCode = 0x1c; break; // enter
- case '>': *ScanCode = 0x34; *code |= 8; break;
- // others
-// case 27: *ScanCode = 0x01; break; // esc
- case '`': *ScanCode = 0x29; break;
- case '^': *ScanCode = 0x07; *code |= 8; break;
- case '[': *ScanCode = 0x1a; break;
- case '{': *ScanCode = 0x1a; *code |= 8; break;
- case ']': *ScanCode = 0x1b; break;
- case '}': *ScanCode = 0x1b; *code |= 8; break;
- case '\\': *ScanCode = 0x2b; break;
- case '|': *ScanCode = 0x2b; *code |= 8; break;
- // ctrl keys
- case 1: *ScanCode = 0x1e; *code |= 16; break; // a
- case 2: *ScanCode = 0x30; *code |= 16; break; // b
- }
-
- if (*ScanCode == 0 && key < 3000)
- printf("unknown key %d mod %d ascii %d\n", key, mod, ascii);
-
-}
-
-/******************************************************************************/
-QMyScrollView::QMyScrollView() : QScrollView()
-{
-}
-
-/******************************************************************************/
-QMyScrollView::~QMyScrollView()
-{
-}
-
-/******************************************************************************/
-void QMyScrollView::keyPressEvent(QKeyEvent* e)
-{
- int ScanCode, code;
- GetScanCode(e, &ScanCode, &code);
- if (ScanCode != 0)
- {
- if (code & 8) // send shift
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x2a, 0);
- if (code & 16) // send control
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x1d, 0);
- if (code & 32) // send alt
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x38, 0);
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, ScanCode, 0);
- e->accept();
- }
-}
-
-/******************************************************************************/
-void QMyScrollView::keyReleaseEvent(QKeyEvent* e)
-{
- int ScanCode, code;
- GetScanCode(e, &ScanCode, &code);
- if (ScanCode != 0)
- {
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, ScanCode, 0);
- if (code & 8) // send shift
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x2a, 0);
- if (code & 16) // send control
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x1d, 0);
- if (code & 32) // send alt
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x38, 0);
- e->accept();
- }
-}
-
-/******************************************************************************/
-void QMyScrollView::showEvent(QShowEvent* e)
-{
- QScrollView::showEvent(e);
-}
-
-/******************************************************************************/
-void QMyScrollView::show()
-{
- QScrollView::show();
-}
-
-/******************************************************************************/
-void QMyScrollView::polish()
-{
- QScrollView::polish();
-}
-
-/******************************************************************************/
-void QMyScrollView::timerEvent(QTimerEvent * e)
-{
- QMyDialog * d;
- QWidget * Desktop;
- int dw;
- int dh;
-
- QScrollView::timerEvent(e);
- killTimer(timer_id);
- d = new QMyDialog(this);
- if (d->exec() == 1) // ok clicked
- {
- g_width = d->Width;
- g_height = d->Height;
- g_client_width = g_width;
- g_client_height = g_height;
- g_fullscreen = d->FullScreen;
- sprintf(g_server, "%s", (const char*)d->ServerIP);
- sprintf(g_username, "%s", (const char*)d->UserName);
-#ifdef WITH_RDPSND
- // init sound
- if (g_rdpsnd)
- {
- rdpsnd_init();
- }
-#endif
- if (!rdp_connect(g_server, g_flags, g_domain, g_password, g_shell,
- g_directory))
- {
- delete d;
- g_SV->close();
- return;
- }
- g_BS = (uint8*)xmalloc(g_width * g_height * 4);
- memset(g_BS, 0, g_width * g_height * 4);
- g_clipx = 0;
- g_clipy = 0;
- g_clipcx = g_width;
- g_clipcy = g_height;
- g_CM = (QColorMap*)xmalloc(sizeof(struct QColorMap));
- memset(g_CM, 0, sizeof(struct QColorMap));
- g_CM->NumColors = 256;
- g_MW = new QMyMainWindow();
- g_MW->resize(g_client_width, g_client_height);
- g_MW->show();
- g_SV->addChild(g_MW);
- g_MW->setMouseTracking(true);
- g_MW->setCursor((int)10); /* Qt::BlankCursor */
- g_SocketNotifier = new QSocketNotifier(g_global_sock,
- QSocketNotifier::Read,
- g_MW);
- g_MW->connect(g_SocketNotifier, SIGNAL(activated(int)), g_MW,
- SLOT(dataReceived()));
- if (g_fullscreen)
- {
- Desktop = g_App->desktop();
- dw = Desktop->width();
- dh = Desktop->height();
- if (dw == g_client_width && dh == g_client_height)
- {
- g_MW->resize(g_client_width - 4, g_client_height - 4);
- }
- g_SV->showFullScreen();
- }
- delete d;
- }
- else // cancel clicked
- {
- delete d;
- g_SV->close();
- }
-}
-
-/******************************************************************************/
-QMyMainWindow::QMyMainWindow() : QWidget(g_SV->viewport())
-{
- PopupMenu = new QPopupMenu(this);
- PopupMenu->insertItem("Right click", 1, 0);
- PopupMenu->insertItem("Toggle fullscreen", 2, 1);
- PopupMenu->insertItem("Reset keyboard", 3, 2);
- PopupMenu->insertItem("Double click", 4, 3);
- connect(PopupMenu, SIGNAL(activated(int)), this, SLOT(MemuClicked(int)));
-}
-
-/******************************************************************************/
-QMyMainWindow::~QMyMainWindow()
-{
- delete PopupMenu;
-}
-
-/******************************************************************************/
-int rd(double in)
-{
- return (int)(in + 0.50);
-}
-
-/******************************************************************************/
-int c2sx(int cx)
-{
- double sx;
-
- sx = (double)g_client_width / (double)g_width;
- return rd(cx / sx);
-}
-
-/******************************************************************************/
-int c2sy(int cy)
-{
- double sy;
-
- sy = (double)g_client_height / (double)g_height;
- return rd(cy / sy);
-}
-
-/******************************************************************************/
-void QMyMainWindow::timerEvent(QTimerEvent * e)
-{
- QWidget::timerEvent(e);
- if (e->timerId() == timer_id)
- {
- // send mouse up
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1,
- rd(c2sx(mx)), rd(c2sy(my)));
- // if in fullscreen, take it out or the menu won't work
- if (g_fullscreen)
- {
- g_fullscreen = 0;
- g_SV->showNormal();
- g_SV->showMaximized();
- }
- else
- PopupMenu->popup(mapToGlobal(QPoint(mx, my)));
- }
- killTimer(timer_id);
-}
-
-/******************************************************************************/
-void QMyMainWindow::MemuClicked(int MenuID)
-{
- QWidget * Desktop;
- int dw;
- int dh;
-
- if (MenuID == 1) // right click
- {
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2,
- rd(c2sx(mx)), rd(c2sy(my)));
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2,
- rd(c2sx(mx)), rd(c2sy(my)));
- }
- else if (MenuID == 2) // toggle full screen
- {
- g_fullscreen = ~g_fullscreen;
- if (g_fullscreen)
- {
- Desktop = g_App->desktop();
- dw = Desktop->width();
- dh = Desktop->height();
- if (dw == g_client_width && dh == g_client_height)
- g_MW->resize(g_client_width - 4, g_client_height - 4);
- g_SV->showFullScreen();
- }
- else
- {
- g_SV->showNormal();
- g_SV->showMaximized();
- g_MW->resize(g_client_width, g_client_height);
- }
- }
- else if (MenuID == 3) // reset keyboard
- {
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x2a, 0); // shift
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x1d, 0); // control
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x38, 0); // alt
- }
- else if (MenuID == 4) // double click
- {
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1,
- rd(c2sx(mx)), rd(c2sy(my)));
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1,
- rd(c2sx(mx)), rd(c2sy(my)));
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1,
- rd(c2sx(mx)), rd(c2sy(my)));
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1,
- rd(c2sx(mx)), rd(c2sy(my)));
- }
-}
-
-/******************************************************************************/
-void QMyMainWindow::mouseMoveEvent(QMouseEvent* e)
-{
- int x, y;
-
- x = e->x();
- y = e->y();
- if (timer_id)
- {
- x = x - mx;
- y = y - my;
- if (x < -10 || x > 10 || y < -10 || y > 10)
- {
- killTimer(timer_id);
- timer_id = 0;
- }
- }
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, c2sx(e->x()),
- c2sy(e->y()));
-}
-
-/******************************************************************************/
-void QMyMainWindow::mousePressEvent(QMouseEvent* e)
-{
- timer_id = startTimer(1000);
- mx = e->x();
- my = e->y();
- if (e->button() == LeftButton)
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1,
- c2sx(e->x()), c2sy(e->y()));
- else if (e->button() == RightButton)
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2,
- c2sx(e->x()), c2sy(e->y()));
- else if (e->button() == MidButton)
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON3,
- c2sx(e->x()), c2sy(e->y()));
-}
-
-/******************************************************************************/
-void QMyMainWindow::mouseReleaseEvent(QMouseEvent* e)
-{
- killTimer(timer_id);
- timer_id = 0;
- if (e->button() == LeftButton)
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, c2sx(e->x()),
- c2sy(e->y()));
- else if (e->button() == RightButton)
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, c2sx(e->x()),
- c2sy(e->y()));
- else if (e->button() == MidButton)
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON3, c2sx(e->x()),
- c2sy(e->y()));
-}
-
-/******************************************************************************/
-void QMyMainWindow::wheelEvent(QWheelEvent* e)
-{
- if (e->delta() > 0)
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON4, c2sx(e->x()),
- c2sy(e->y()));
- else if (e->delta() < 0)
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON5, c2sx(e->x()),
- c2sy(e->y()));
-}
-
-#define NOT(x) (~x)
-
-/******************************************************************************/
-int rop(int rop, int src, int dst)
-{
- switch (rop)
- {
- case 0x0: return 0;
- case 0x1: return NOT (src | dst);
- case 0x2: return NOT (src) & dst;
- case 0x3: return NOT (src);
- case 0x4: return src & NOT (dst);
- case 0x5: return NOT (dst);
- case 0x6: return src ^ dst;
- case 0x7: return NOT (src & dst);
- case 0x8: return src & dst;
- case 0x9: return NOT (src) ^ dst;
- case 0xa: return dst;
- case 0xb: return NOT (src) | dst;
- case 0xc: return src;
- case 0xd: return src | NOT (dst);
- case 0xe: return src | dst;
- case 0xf: return NOT (0);
- }
- return dst;
-}
-
-/*****************************************************************************/
-int get_pixel(int x, int y)
-{
- if (x >= 0 && x < g_width && y >= 0 && y < g_height)
- {
- if (g_server_bpp == 8)
- return GETPIXEL8(g_BS, x, y, g_width);
- else if (g_server_bpp == 16)
- return GETPIXEL16(g_BS, x, y, g_width);
- else if (g_server_bpp == 24)
- return GETPIXEL32(g_BS, x, y, g_width);
- else
- return 0;
- }
- else
- return 0;
-}
-
-/******************************************************************************/
-void set_pixel(int x, int y, int pixel, int op = 0xc)
-{
- int p;
-
- if (x >= g_clipx && x < (g_clipx + g_clipcx) &&
- y >= g_clipy && y < (g_clipy + g_clipcy))
- {
- if (x >= 0 && x < g_width && y >= 0 && y < g_height)
- {
- if (op == 0xc)
- {
- if (g_server_bpp == 8)
- {
- SETPIXEL8(g_BS, x, y, g_width, pixel);
- }
- else if (g_server_bpp == 16)
- {
- SETPIXEL16(g_BS, x, y, g_width, pixel);
- }
- else if (g_server_bpp == 24)
- {
- SETPIXEL32(g_BS, x, y, g_width, pixel);
- }
- }
- else
- {
- if (g_server_bpp == 8)
- {
- p = GETPIXEL8(g_BS, x, y, g_width);
- p = rop(op, pixel, p);
- SETPIXEL8(g_BS, x, y, g_width, p);
- }
- else if (g_server_bpp == 16)
- {
- p = GETPIXEL16(g_BS, x, y, g_width);
- p = rop(op, pixel, p);
- SETPIXEL16(g_BS, x, y, g_width, p);
- }
- else if (g_server_bpp == 24)
- {
- p = GETPIXEL32(g_BS, x, y, g_width);
- p = rop(op, pixel, p);
- SETPIXEL32(g_BS, x, y, g_width, p);
- }
- }
- }
- }
-}
-
-/******************************************************************************/
-// adjust coordinates for clipping rect
-bool WarpCoords(int * x, int * y, int * cx, int * cy, int * srcx, int * srcy)
-{
- int dx, dy;
- QRect InRect(*x, *y, *cx, *cy);
- QRect OutRect;
- QRect CRect(g_clipx, g_clipy, g_clipcx, g_clipcy);
- OutRect = InRect.intersect(CRect);
- if (OutRect.isEmpty())
- return false;
- dx = OutRect.x() - InRect.x();
- dy = OutRect.y() - InRect.y();
- *x = OutRect.x();
- *y = OutRect.y();
- *cx = OutRect.width();
- *cy = OutRect.height();
- if (srcx != NULL)
- *srcx = *srcx + dx;
- if (srcy != NULL)
- *srcy = *srcy + dy;
- return true;
-}
-
-/******************************************************************************/
-void QMyMainWindow::paintEvent(QPaintEvent * pe)
-{
- QImage * Image;
- QPainter * Painter;
- QRect Rect;
- int i, j, w, h, l, t, pixel, r, g, b;
- uint8 * data;
- double sx, sy;
-
- Image = 0;
- data = 0;
- if (!testWFlags(WRepaintNoErase))
- setWFlags(WRepaintNoErase);
- if (g_CM != NULL || g_server_bpp > 8)
- {
- sx = (double)g_client_width / (double)g_width;
- sy = (double)g_client_height / (double)g_height;
- Rect = pe->rect();
- l = rd(Rect.left() / sx);
- t = rd(Rect.top() / sy);
- w = rd(Rect.width() / sx);
- h = rd(Rect.height() / sy);
- if (w > 0 && h > 0)
- {
- if (g_server_bpp == 8 && g_CM->NumColors > 0)
- {
- w = (w + 3) & ~3;
- data = (uint8*)xmalloc(w * h);
- for (i = 0; i < h; i++)
- for (j = 0; j < w; j++)
- data[i * w + j] = GETPIXEL8(g_BS, l + j, t + i, g_width);
- Image = new QImage(data, w, h, 8,(QRgb*)g_CM->RGBColors,
- g_CM->NumColors, QImage::IgnoreEndian);
- }
- else if (g_server_bpp == 16)
- {
- w = (w + 3) & ~3;
- data = (uint8*)xmalloc(w * h * 4);
- for (i = 0; i < h; i++)
- for (j = 0; j < w; j++)
- {
- pixel = GETPIXEL16(g_BS, l + j, t + i, g_width);
- r = ((pixel >> 8) & 0xf8) | ((pixel >> 13) & 0x7);
- g = ((pixel >> 3) & 0xfc) | ((pixel >> 9) & 0x3);
- b = ((pixel << 3) & 0xf8) | ((pixel >> 2) & 0x7);
- pixel = ((r << 16) | (g << 8) | b);
- SETPIXEL32(data, j, i, w, pixel);
- }
- Image = new QImage(data, w, h, 32, NULL,
- 0, QImage::IgnoreEndian);
- }
- else if (g_server_bpp == 24)
- {
- w = (w + 3) & ~3;
- data = (uint8*)xmalloc(w * h * 4);
- for (i = 0; i < h; i++)
- for (j = 0; j < w; j++)
- {
- pixel = GETPIXEL32(g_BS, l + j, t + i, g_width);
- r = (pixel >> 0) & 0xff;
- g = (pixel >> 8) & 0xff;
- b = (pixel >> 16) & 0xff;
- pixel = ((r << 16) | (g << 8) | b);
- SETPIXEL32(data, j, i, w, pixel);
- }
- Image = new QImage(data, w, h, 32, NULL,
- 0, QImage::IgnoreEndian);
- }
- if (Image != 0)
- {
- Painter = new QPainter(this);
- Painter->scale(sx, sy);
- Painter->drawImage(l, t, *Image, 0, 0, w, h);
- delete Painter;
- delete Image;
- }
- xfree(data);
- }
- }
-}
-
-/******************************************************************************/
-void QMyMainWindow::closeEvent(QCloseEvent * e)
-{
- e->accept();
-}
-
-/******************************************************************************/
-void QMyMainWindow::dataReceived()
-{
- if (!rdp_loop(&g_deactivated, &g_ext_disc_reason))
- g_SV->close();
-#ifdef WITH_RDPSND
- if (g_dsp_busy)
- {
- if (g_SoundNotifier == 0)
- {
- g_SoundNotifier = new QSocketNotifier(g_dsp_fd, QSocketNotifier::Write,
- g_MW);
- g_MW->connect(g_SoundNotifier, SIGNAL(activated(int)), g_MW,
- SLOT(soundSend()));
- }
- else
- {
- if (!g_SoundNotifier->isEnabled())
- g_SoundNotifier->setEnabled(true);
- }
- }
-#endif
-}
-
-/******************************************************************************/
-void QMyMainWindow::soundSend()
-{
-#ifdef WITH_RDPSND
- g_SoundNotifier->setEnabled(false);
- wave_out_play();
- if (g_dsp_busy)
- {
- g_SoundNotifier->setEnabled(true);
- }
-#endif
-}
-
-/******************************************************************************/
-void redraw(int x, int y, int cx, int cy)
-{
- double sx, sy;
-
- if (WarpCoords(&x, &y, &cx, &cy, NULL, NULL))
- {
- sx = (double)g_client_width / (double)g_width;
- sy = (double)g_client_height / (double)g_height;
- x = rd(x * sx);
- y = rd(y * sy);
- cx = rd(cx * sx);
- cy = rd(cy * sy);
- g_MW->update(x, y, cx, cy);
- }
-}
-
-/******************************************************************************/
-/* Returns 0 after user quit, 1 otherwise */
-int ui_select(int rdp_socket)
-{
- if (g_global_sock == 0)
- g_global_sock = rdp_socket;
- return 1;
-}
-
-/******************************************************************************/
-void ui_move_pointer(int /*x*/, int /*y*/)
-{
-}
-
-/******************************************************************************/
-void ui_set_null_cursor(void)
-{
-}
-
-/******************************************************************************/
-HBITMAP ui_create_bitmap(int width, int height, uint8 * data)
-{
- struct bitmap * the_bitmap;
- uint8 * bitmap_data;
- int i, j;
- int r, g, b, pixel;
-
- bitmap_data = (uint8*)xmalloc(width * height * 4);
- the_bitmap = (struct bitmap*)xmalloc(sizeof(struct bitmap));
- the_bitmap->w = width;
- the_bitmap->h = height;
- the_bitmap->data = bitmap_data;
- if (g_server_bpp == 8)
- {
- for (i = 0; i < height; i++)
- for (j = 0; j < width; j++)
- bitmap_data[i * width + j] = data[i * width + j];
- }
- else if (g_server_bpp == 16)
- {
- for (i = 0; i < height; i++)
- for (j = 0; j < width; j++)
- *(((uint16*)bitmap_data) + (i * width + j)) =
- *(((uint16*)data) + (i * width + j));
- }
- else if (g_server_bpp == 24)
- {
- for (i = 0; i < height; i++)
- for (j = 0; j < width; j++)
- {
- r = data[(i * width + j) * 3 + 0];
- g = data[(i * width + j) * 3 + 1];
- b = data[(i * width + j) * 3 + 2];
- pixel = (r << 16) | (g << 8) | b;
- SETPIXEL32(bitmap_data, j, i, width, pixel);
- }
- }
- return the_bitmap;
-}
-
-/******************************************************************************/
-void ui_paint_bitmap(int x, int y, int cx, int cy, int width,
- int height, uint8 * data)
-{
- int i, j;
- int r, g, b, pixel;
-
- if (g_server_bpp == 8)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- if (i < height)
- if (j < width)
- set_pixel(x + j, y + i, data[i * width + j]);
- }
- else if (g_server_bpp == 16)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- if (i < height)
- if (j < width)
- set_pixel(x + j, y + i, *(((uint16*)data) + (i * width + j)));
- }
- else if (g_server_bpp == 24)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- if (i < height)
- if (j < width)
- {
- r = data[(i * width + j) * 3 + 0];
- g = data[(i * width + j) * 3 + 1];
- b = data[(i * width + j) * 3 + 2];
- pixel = (r << 16) | (g << 8) | b;
- set_pixel(x + j, y + i, pixel);
- }
- }
- redraw(x, y, cx, cy);
-}
-
-/******************************************************************************/
-void ui_destroy_bitmap(HBITMAP bmp)
-{
- struct bitmap* the_bitmap;
-
- the_bitmap = (struct bitmap*)bmp;
- if (the_bitmap != NULL)
- {
- if (the_bitmap->data != NULL)
- xfree(the_bitmap->data);
- xfree(the_bitmap);
- }
-}
-
-/******************************************************************************/
-bool is_pixel_on(uint8 * data, int x, int y, int width, int bpp)
-{
- int start, shift;
-
- if (bpp == 1)
- {
- width = (width + 7) / 8;
- start = (y * width) + x / 8;
- shift = x % 8;
- return (data[start] & (0x80 >> shift)) != 0;
- }
- else if (bpp == 8)
- return data[y * width + x] != 0;
- else
- return false;
-}
-
-/******************************************************************************/
-void set_pixel_on(uint8 * data, int x, int y, int width, int bpp, uint8 pixel)
-{
- if (bpp == 8)
- data[y * width + x] = pixel;
-}
-
-/******************************************************************************/
-HGLYPH ui_create_glyph(int width, int height, uint8 * data)
-{
- int i, j;
- uint8* glyph_data;
- struct bitmap* the_glyph;
-
- glyph_data = (uint8*)xmalloc(width * height);
- the_glyph = (struct bitmap*)xmalloc(sizeof(struct bitmap));
- the_glyph->w = width;
- the_glyph->h = height;
- the_glyph->data = glyph_data;
- memset(glyph_data, 0, width * height);
- for (i = 0; i < height; i++)
- for (j = 0; j < width; j++)
- if (is_pixel_on(data, j, i, width, 1))
- set_pixel_on(glyph_data, j, i, width, 8, 255);
- return the_glyph;
-}
-
-/******************************************************************************/
-void ui_destroy_glyph(HGLYPH glyph)
-{
- struct bitmap* the_glyph;
-
- the_glyph = (struct bitmap*)glyph;
- if (the_glyph != NULL)
- {
- if (the_glyph->data != NULL)
- xfree(the_glyph->data);
- xfree(the_glyph);
- }
-}
-
-/******************************************************************************/
-HCURSOR ui_create_cursor(uint32 x, uint32 y,
- int width, int height,
- uint8 * andmask, uint8 * xormask)
-{
- return (void*)1;
-}
-
-/******************************************************************************/
-void ui_set_cursor(HCURSOR /*cursor*/)
-{
-}
-
-/*****************************************************************************/
-uint16 ui_get_numlock_state(uint32 state)
-{
- return 0;
-}
-
-/*****************************************************************************/
-unsigned int read_keyboard_state(void)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void ui_resize_window(void)
-{
-}
-
-/*****************************************************************************/
-void ui_polygon(uint8 opcode, uint8 fillmode, POINT * point, int npoints,
- BRUSH * brush, int bgcolour, int fgcolour)
-{
-}
-
-/*****************************************************************************/
-/* todo, use qt function for this (QPainter::drawPolyline) */
-void ui_polyline(uint8 opcode, POINT * points, int npoints, PEN * pen)
-{
- int i, x, y, dx, dy;
-
- if (npoints > 0)
- {
- x = points[0].x;
- y = points[0].y;
- for (i = 1; i < npoints; i++)
- {
- dx = points[i].x;
- dy = points[i].y;
- ui_line(opcode, x, y, x + dx, y + dy, pen);
- x = x + dx;
- y = y + dy;
- }
- }
-}
-
-/*****************************************************************************/
-void ui_ellipse(uint8 opcode, uint8 fillmode,
- int x, int y, int cx, int cy,
- BRUSH * brush, int bgcolour, int fgcolour)
-{
-}
-
-/******************************************************************************/
-void ui_destroy_cursor(HCURSOR /*cursor*/)
-{
-}
-
-/******************************************************************************/
-HCOLOURMAP ui_create_colourmap(COLOURMAP * colours)
-{
- int i;
- int x;
- uint8 r, g, b;
- i = 0;
- while (i < colours->ncolours && i < 256)
- {
- r = colours->colours[i].red;
- g = colours->colours[i].green;
- b = colours->colours[i].blue;
- x = (r << 16) | (g << 8) | b;
- g_CM->RGBColors[i] = x;
- i++;
- }
- g_CM->NumColors = colours->ncolours;
- return g_CM;
-}
-
-/******************************************************************************/
-void ui_set_colourmap(HCOLOURMAP map)
-{
-}
-
-/******************************************************************************/
-void ui_destroy_colourmap(HCOLOURMAP map)
-{
-}
-
-/******************************************************************************/
-void ui_begin_update(void)
-{
-}
-
-/******************************************************************************/
-void ui_end_update(void)
-{
-}
-
-/******************************************************************************/
-void ui_set_clip(int x, int y, int cx, int cy)
-{
- g_clipx = x;
- g_clipy = y;
- g_clipcx = cx;
- g_clipcy = cy;
-}
-
-/******************************************************************************/
-void ui_reset_clip(void)
-{
- g_clipx = 0;
- g_clipy = 0;
- g_clipcx = g_width;
- g_clipcy = g_height;
-}
-
-/******************************************************************************/
-void ui_bell(void)
-{
- g_App->beep();
-}
-
-/******************************************************************************/
-void ui_destblt(uint8 opcode, int x, int y, int cx, int cy)
-{
- int i, j;
-
-
- if (opcode == 0x0) /* black */
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- set_pixel(x + j, y + i, 0, 0xc);
- }
- else if (opcode == 0xf) /* white */
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- set_pixel(x + j, y + i, 0xffffff, 0xc);
- }
- else
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- set_pixel(x + j, y + i, get_pixel(x + j, y + i), opcode);
- }
- redraw(x, y, cx, cy);
-}
-
-/******************************************************************************/
-// does not repaint
-void fill_rect(int x, int y, int cx, int cy, int colour, int opcode = 0xc)
-{
- int i, j;
-
- if (x + cx > g_width)
- cx = g_width - x;
- if (y + cy > g_height)
- cy = g_height - y;
-#ifdef QT_OPTI
- if (opcode == 0xc) /* optimize */
- {
- if (WarpCoords(&x, &y, &cx, &cy, 0, 0))
- {
- if (g_server_bpp == 8)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- SETPIXEL8(g_BS, x + j, y + i, g_width, colour);
- }
- else if (g_server_bpp == 16)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- SETPIXEL16(g_BS, x + j, y + i, g_width, colour);
- }
- else if (g_server_bpp == 24)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- SETPIXEL32(g_BS, x + j, y + i, g_width, colour);
- }
- }
- }
- else
-#endif
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- set_pixel(x + j, y + i, colour, opcode);
- }
-}
-
-/******************************************************************************/
-void ui_rect(int x, int y, int cx, int cy, int colour)
-{
- fill_rect(x, y, cx, cy, colour);
- redraw(x, y, cx, cy);
-}
-
-/******************************************************************************/
-void ui_patblt(uint8 opcode, int x, int y, int cx, int cy,
- BRUSH * brush, int bgcolour, int fgcolour)
-{
- int i, j;
- uint8 ipattern[8];
-
- switch (brush->style)
- {
- case 0:
- fill_rect(x, y, cx, cy, fgcolour, opcode);
- break;
- case 3:
- for (i = 0; i < 8; i++)
- ipattern[i] = ~brush->pattern[7 - i];
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- if (is_pixel_on(ipattern, (x + j + brush->xorigin) % 8,
- (y + i + brush->yorigin) % 8, 8, 1))
- set_pixel(x + j, y + i, fgcolour, opcode);
- else
- set_pixel(x + j, y + i, bgcolour, opcode);
- break;
- }
- redraw(x, y, cx, cy);
-}
-
-/******************************************************************************/
-void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy,
- int srcx, int srcy)
-{
- int i, j, pixel;
- uint8 * temp;
-
- temp = (uint8*)xmalloc(cx * cy * 4);
-#ifdef QT_OPTI
- if (opcode == 0xc)
- {
- if (WarpCoords(&x, &y, &cx, &cy, &srcx, &srcy))
- {
- if (g_server_bpp == 8)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- {
- pixel = GETPIXEL8(g_BS, srcx + j, srcy + i, g_width);
- SETPIXEL8(temp, j, i, cx, pixel);
- }
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- {
- pixel = GETPIXEL8(temp, j, i, cx);
- SETPIXEL8(g_BS, x + j, y + i, g_width, pixel);
- }
- }
- else if (g_server_bpp == 16)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- {
- pixel = GETPIXEL16(g_BS, srcx + j, srcy + i, g_width);
- SETPIXEL16(temp, j, i, cx, pixel);
- }
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- {
- pixel = GETPIXEL16(temp, j, i, cx);
- SETPIXEL16(g_BS, x + j, y + i, g_width, pixel);
- }
- }
- else if (g_server_bpp == 24)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- {
- pixel = GETPIXEL32(g_BS, srcx + j, srcy + i, g_width);
- SETPIXEL32(temp, j, i, cx, pixel);
- }
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- {
- pixel = GETPIXEL32(temp, j, i, cx);
- SETPIXEL32(g_BS, x + j, y + i, g_width, pixel);
- }
- }
- }
- }
- else
-#endif
- {
- if (g_server_bpp == 8)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- temp[i * cx + j] = get_pixel(srcx + j, srcy + i);
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- set_pixel(x + j, y + i, temp[i * cx + j], opcode);
- }
- else if (g_server_bpp == 16)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- {
- pixel = get_pixel(srcx + j, srcy + i);
- SETPIXEL16(temp, j, i, cx, pixel);
- }
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- {
- pixel = GETPIXEL16(temp, j, i, cx);
- set_pixel(x + j, y + i, pixel, opcode);
- }
- }
- else if (g_server_bpp == 24)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- *(((uint32*)temp) + (i * cx + j)) = get_pixel(srcx + j, srcy + i);
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- set_pixel(x + j, y + i, *(((uint32*)temp) + (i * cx + j)), opcode);
- }
- }
- xfree(temp);
- redraw(x, y, cx, cy);
-}
-
-/******************************************************************************/
-void ui_memblt(uint8 opcode, int x, int y, int cx, int cy,
- HBITMAP src, int srcx, int srcy)
-{
- int i, j, p;
- struct bitmap * the_bitmap;
-
- the_bitmap = (struct bitmap*)src;
- if (the_bitmap == NULL)
- return;
-#ifdef QT_OPTI
- if (opcode == 0xc) /* optimize */
- {
- if (WarpCoords(&x, &y, &cx, &cy, &srcx, &srcy))
- {
- if (g_server_bpp == 8)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- {
- p = GETPIXEL8(the_bitmap->data, srcx + j, srcy + i, the_bitmap->w);
- SETPIXEL8(g_BS, x + j, y + i, g_width, p);
- }
- }
- else if (g_server_bpp == 16)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- {
- p = GETPIXEL16(the_bitmap->data, srcx + j, srcy + i, the_bitmap->w);
- SETPIXEL16(g_BS, x + j, y + i, g_width, p);
- }
- }
- else if (g_server_bpp == 24)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- {
- p = GETPIXEL32(the_bitmap->data, srcx + j, srcy + i, the_bitmap->w);
- SETPIXEL32(g_BS, x + j, y + i, g_width, p);
- }
- }
- }
- }
- else
-#endif
- {
- if (g_server_bpp == 8)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w)
- set_pixel(x + j, y + i,
- the_bitmap->data[(i + srcy) * the_bitmap->w + (j + srcx)],
- opcode);
- }
- else if (g_server_bpp == 16)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w)
- set_pixel(x + j, y + i,
- *(((uint16*)the_bitmap->data) + ((i + srcy) * the_bitmap->w + (j + srcx))),
- opcode);
- }
- else if (g_server_bpp == 24)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w)
- set_pixel(x + j, y + i,
- *(((uint32*)the_bitmap->data) + ((i + srcy) * the_bitmap->w + (j + srcx))),
- opcode);
- }
- }
- redraw(x, y, cx, cy);
-}
-
-/******************************************************************************/
-// not used
-void ui_triblt(uint8 opcode, int x, int y, int cx, int cy,
- HBITMAP src, int srcx, int srcy, BRUSH * brush,
- int bgcolour, int fgcolour)
-{
-}
-
-/******************************************************************************/
-/* Bresenham's line drawing algorithm */
-void ui_line(uint8 opcode, int startx, int starty, int endx,
- int endy, PEN * pen)
-{
- int dx, dy, incx, incy, dpr, dpru, p, left, top, right, bottom;
-
- if (startx > endx)
- {
- dx = startx - endx;
- incx = -1;
- left = endx;
- right = startx;
- }
- else
- {
- dx = endx - startx;
- incx = 1;
- left = startx;
- right = endx;
- }
- if (starty > endy)
- {
- dy = starty - endy;
- incy = -1;
- top = endy;
- bottom = starty;
- }
- else
- {
- dy = endy - starty;
- incy = 1;
- top = starty;
- bottom = endy;
- }
- if (dx >= dy)
- {
- dpr = dy << 1;
- dpru = dpr - (dx << 1);
- p = dpr - dx;
- for (; dx >= 0; dx--)
- {
- set_pixel(startx, starty, pen->colour, opcode);
- if (p > 0)
- {
- startx += incx;
- starty += incy;
- p += dpru;
- }
- else
- {
- startx += incx;
- p += dpr;
- }
- }
- }
- else
- {
- dpr = dx << 1;
- dpru = dpr - (dy << 1);
- p = dpr - dy;
- for (; dy >= 0; dy--)
- {
- set_pixel(startx, starty, pen->colour, opcode);
- if (p > 0)
- {
- startx += incx;
- starty += incy;
- p += dpru;
- }
- else
- {
- starty += incy;
- p += dpr;
- }
- }
- }
- redraw(left, top, (right - left) + 1, (bottom - top) + 1);
-}
-
-/******************************************************************************/
-void draw_glyph (int x, int y, HGLYPH glyph, int fgcolour)
-{
- struct bitmap *the_glyph;
- int i, j;
-
- the_glyph = (struct bitmap*)glyph;
- if (the_glyph == NULL)
- return;
- for (i = 0; i < the_glyph->h; i++)
- for (j = 0; j < the_glyph->w; j++)
- if (is_pixel_on(the_glyph->data, j, i, the_glyph->w, 8))
- set_pixel(x + j, y + i, fgcolour);
-}
-
-#define DO_GLYPH(ttext,idx) \
-{\
- glyph = cache_get_font (font, ttext[idx]);\
- if (!(flags & TEXT2_IMPLICIT_X))\
- {\
- xyoffset = ttext[++idx];\
- if ((xyoffset & 0x80))\
- {\
- if (flags & TEXT2_VERTICAL) \
- y += ttext[idx+1] | (ttext[idx+2] << 8);\
- else\
- x += ttext[idx+1] | (ttext[idx+2] << 8);\
- idx += 2;\
- }\
- else\
- {\
- if (flags & TEXT2_VERTICAL) \
- y += xyoffset;\
- else\
- x += xyoffset;\
- }\
- }\
- if (glyph != NULL)\
- {\
- draw_glyph (x + glyph->offset, y + glyph->baseline, glyph->pixmap, fgcolour);\
- if (flags & TEXT2_IMPLICIT_X)\
- x += glyph->width;\
- }\
-}
-
-/******************************************************************************/
-//*****************************************************************************
-void ui_draw_text(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, BRUSH * brush,
- int bgcolour, int fgcolour, uint8 * text, uint8 length)
-{
- FONTGLYPH * glyph;
- int i, j, xyoffset;
- DATABLOB * entry;
-
- if (boxx + boxcx > g_width)
- boxcx = g_width - boxx;
- if (boxy + boxcy > g_height)
- boxcy = g_height - boxy;
-
- if (boxcx > 1)
- fill_rect(boxx, boxy, boxcx, boxcy, bgcolour);
- else if (mixmode == MIX_OPAQUE)
- fill_rect(clipx, clipy, clipcx, clipcy, bgcolour);
-
- /* Paint text, character by character */
- for (i = 0; i < length;)
- {
- switch (text[i])
- {
- case 0xff:
- if (i + 2 < length)
- cache_put_text(text[i + 1], text, text[i + 2]);
- else
- {
- error("this shouldn't be happening\n");
- exit(1);
- }
- /* this will move pointer from start to first character after FF command */
- length -= i + 3;
- text = &(text[i + 3]);
- i = 0;
- break;
-
- case 0xfe:
- entry = cache_get_text(text[i + 1]);
- if (entry != NULL)
- {
- if ((((uint8 *) (entry->data))[1] == 0) && (!(flags & TEXT2_IMPLICIT_X)))
- {
- if (flags & TEXT2_VERTICAL)
- y += text[i + 2];
- else
- x += text[i + 2];
- }
- for (j = 0; j < entry->size; j++)
- DO_GLYPH(((uint8 *) (entry->data)), j);
- }
- if (i + 2 < length)
- i += 3;
- else
- i += 2;
- length -= i;
- /* this will move pointer from start to first character after FE command */
- text = &(text[i]);
- i = 0;
- break;
-
- default:
- DO_GLYPH(text, i);
- i++;
- break;
- }
- }
- if (boxcx > 1)
- redraw(boxx, boxy, boxcx, boxcy);
- else
- redraw(clipx, clipy, clipcx, clipcy);
-}
-
-/******************************************************************************/
-void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
-{
- uint8 * data;
- int i, j, Bpp, pixel;
-
- Bpp = 4;
- switch (g_server_bpp)
- {
- case 8: Bpp = 1; break;
- case 15: Bpp = 2; break;
- case 16: Bpp = 2; break;
- }
- data = (uint8*)xmalloc(cx * cy * Bpp);
- if (g_server_bpp == 8)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- {
- pixel = get_pixel(x + j, y + i);
- SETPIXEL8(data, j, i, cx, pixel);
- }
- }
- else if (g_server_bpp == 16)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- {
- pixel = get_pixel(x + j, y + i);
- SETPIXEL16(data, j, i, cx, pixel);
- }
- }
- else if (g_server_bpp == 24)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- *(((uint32*)data) + (i * cx + j)) = get_pixel(x + j, y + i);
- }
- offset *= Bpp;
- cache_put_desktop(offset, cx, cy, cx * Bpp, Bpp, data);
- xfree(data);
-}
-
-/******************************************************************************/
-void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
-{
- uint8 * data;
- int i, j;
- int Bpp;
-
- Bpp = 4;
- switch (g_server_bpp)
- {
- case 8: Bpp = 1; break;
- case 15: Bpp = 2; break;
- case 16: Bpp = 2; break;
- }
- offset *= Bpp;
- data = cache_get_desktop(offset, cx, cy, Bpp);
- if (g_server_bpp == 8)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- set_pixel(x + j, y + i, data[i * cx + j]);
- }
- else if (g_server_bpp == 16)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- set_pixel(x + j, y + i, *(((uint16*)data) + (i * cx + j)));
- }
- else if (g_server_bpp == 24)
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- set_pixel(x + j, y + i, *(((uint32*)data) + (i * cx + j)));
- }
- redraw(x, y, cx, cy);
-}
-
-/*****************************************************************************/
-void * xrealloc(void * in_val, int size)
-{
- if (size < 1)
- {
- size = 1;
- }
- return realloc(in_val, size);
-}
-
-/*****************************************************************************/
-void * xmalloc(int size)
-{
- return malloc(size);
-}
-
-/*****************************************************************************/
-void xfree(void * in_val)
-{
- if (in_val != NULL)
- {
- free(in_val);
- }
-}
-
-/*****************************************************************************/
-char * xstrdup(const char * s)
-{
- char * mem = strdup(s);
- if (mem == NULL)
- {
- perror("strdup");
- exit(1);
- }
- return mem;
-}
-
-/*****************************************************************************/
-void warning(char * format, ...)
-{
- va_list ap;
-
- fprintf(stderr, "WARNING: ");
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- va_end(ap);
-}
-
-/*****************************************************************************/
-void unimpl(char * format, ...)
-{
- va_list ap;
-
- fprintf(stderr, "NOT IMPLEMENTED: ");
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- va_end(ap);
-}
-
-/*****************************************************************************/
-void error(char * format, ...)
-{
- va_list ap;
-
- fprintf(stderr, "ERROR: ");
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- va_end(ap);
-}
-
-/*****************************************************************************/
-BOOL rd_pstcache_mkdir(void)
-{
- return 0;
-}
-
-/*****************************************************************************/
-int rd_open_file(char * filename)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void rd_close_file(int fd)
-{
- return;
-}
-
-/*****************************************************************************/
-int rd_read_file(int fd, void * ptr, int len)
-{
- return 0;
-}
-
-/*****************************************************************************/
-int rd_write_file(int fd, void * ptr, int len)
-{
- return 0;
-}
-
-/*****************************************************************************/
-int rd_lseek_file(int fd, int offset)
-{
- return 0;
-}
-
-/*****************************************************************************/
-BOOL rd_lock_file(int fd, int start, int len)
-{
- return False;
-}
-
-/*****************************************************************************/
-int load_licence(uint8 ** data)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void save_licence(uint8 * data, int length)
-{
-}
-
-/*****************************************************************************/
-void generate_random(uint8 * random)
-{
- QFile File("/dev/random");
- File.open(IO_ReadOnly);
- if (File.readBlock((char*)random, 32) == 32)
- {
- return;
- }
- warning("no /dev/random\n");
- memcpy(random, "12345678901234567890123456789012", 32);
-}
-
-/*****************************************************************************/
-/* produce a hex dump */
-void hexdump(uint8 * p, uint32 len)
-{
- uint8 * line = p;
- int i, thisline;
- uint32 offset = 0;
-
- while (offset < len)
- {
- printf("%04x ", offset);
- thisline = len - offset;
- if (thisline > 16)
- {
- thisline = 16;
- }
- for (i = 0; i < thisline; i++)
- {
- printf("%02x ", line[i]);
- }
- for (; i < 16; i++)
- {
- printf(" ");
- }
- for (i = 0; i < thisline; i++)
- {
- printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.');
- }
- printf("\n");
- offset += thisline;
- line += thisline;
- }
-}
-
-/*****************************************************************************/
-void get_username_and_hostname(void)
-{
- char fullhostname[64];
- char * p;
- struct passwd * pw;
-
- STRNCPY(g_username, "unknown", sizeof(g_username));
- STRNCPY(g_hostname, "unknown", sizeof(g_hostname));
- pw = getpwuid(getuid());
- if (pw != NULL && pw->pw_name != NULL)
- {
- STRNCPY(g_username, pw->pw_name, sizeof(g_username));
- }
- if (gethostname(fullhostname, sizeof(fullhostname)) != -1)
- {
- p = strchr(fullhostname, '.');
- if (p != NULL)
- {
- *p = 0;
- }
- STRNCPY(g_hostname, fullhostname, sizeof(g_hostname));
- }
-}
-
-/*****************************************************************************/
-void out_params(void)
-{
- fprintf(stderr, "qterdesktop: A Remote Desktop Protocol client.\n");
- fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2004 Matt Chapman.\n");
- fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n");
- fprintf(stderr, "Usage: qterdesktop [options] server\n");
- fprintf(stderr, " -g: desktop geometry (WxH)\n");
- fprintf(stderr, " -4: use RDP version 4\n");
- fprintf(stderr, " -5: use RDP version 5 (default)\n");
- fprintf(stderr, " -t: tcp port)\n");
- fprintf(stderr, " -a: connection colour depth\n");
- fprintf(stderr, " -u: user name\n");
- fprintf(stderr, " -d: domain\n");
- fprintf(stderr, " -s: shell\n");
- fprintf(stderr, " -c: working directory\n");
- fprintf(stderr, " -p: password (- to prompt)\n");
- fprintf(stderr, " -n: client hostname\n");
- fprintf(stderr, " -f: full screen\n");
- fprintf(stderr, " -r sound: enable sound\n");
- fprintf(stderr, "\n");
-}
-
-/*****************************************************************************/
-int parse_parameters(int in_argc, char ** in_argv)
-{
- int i;
- char * p;
-
- for (i = 1; i < in_argc; i++)
- {
- strcpy(g_server, in_argv[i]);
- if (strcmp(in_argv[i], "-h") == 0)
- {
- out_params();
- return 0;
- }
- else if (strcmp(in_argv[i], "-g") == 0)
- {
- g_width = strtol(in_argv[i + 1], &p, 10);
- if (*p == 'x')
- {
- g_height = strtol(p + 1, &p, 10);
- }
- if (*p == '-')
- {
- g_client_width = strtol(p + 1, &p, 10);
- }
- else
- {
- g_client_width = g_width;
- g_client_height = g_height;
- }
- if (*p == 'x')
- {
- g_client_height = strtol(p + 1, NULL, 10);
- }
- g_width = (g_width + 3) & ~3;
- g_height = (g_height + 3) & ~3;
- g_client_width = (g_client_width + 3) & ~3;
- g_client_height = (g_client_height + 3) & ~3;
- i++;
- }
- else if (strcmp(in_argv[i], "-4") == 0)
- {
- g_use_rdp5 = 0;
- }
- else if (strcmp(in_argv[i], "-5") == 0)
- {
- g_use_rdp5 = 1;
- }
- else if (strcmp(in_argv[i], "-a") == 0)
- {
- g_server_bpp = strtol(in_argv[i + 1], &p, 10);
- if (g_server_bpp != 8 &&
- g_server_bpp != 16 && g_server_bpp != 24)
- {
- error("invalid bpp\n");
- return 0;
- }
- i++;
- }
- else if (strcmp(in_argv[i], "-t") == 0)
- {
- g_tcp_port_rdp = strtol(in_argv[i + 1], &p, 10);
- i++;
- }
- else if (strcmp(in_argv[i], "-u") == 0)
- {
- STRNCPY(g_username, in_argv[i + 1], sizeof(g_username));
- i++;
- }
- else if (strcmp(in_argv[i], "-d") == 0)
- {
- STRNCPY(g_domain, in_argv[i + 1], sizeof(g_domain));
- i++;
- }
- else if (strcmp(in_argv[i], "-s") == 0)
- {
- STRNCPY(g_shell, in_argv[i + 1], sizeof(g_shell));
- i++;
- }
- else if (strcmp(in_argv[i], "-c") == 0)
- {
- STRNCPY(g_directory, in_argv[i + 1], sizeof(g_directory));
- i++;
- }
- else if (strcmp(in_argv[i], "-p") == 0)
- {
- STRNCPY(g_password, in_argv[i + 1], sizeof(g_password));
- g_flags |= RDP_LOGON_AUTO;
- i++;
- }
- else if (strcmp(in_argv[i], "-n") == 0)
- {
- STRNCPY(g_hostname, in_argv[i + 1], sizeof(g_hostname));
- i++;
- }
- else if (strcmp(in_argv[i], "-f") == 0)
- {
- g_fullscreen = 1;
- }
- else if (strcmp(in_argv[i], "-r") == 0)
- {
- if (strcmp(in_argv[i + 1], "sound") == 0)
- {
-#ifdef WITH_RDPSND
- g_rdpsnd = 1;
-#endif
- }
- i++;
- }
- }
- return 1;
-}
-
-/******************************************************************************/
-int param_connect(void)
-{
- QWidget * Desktop;
- int dw, dh;
-
-#ifdef WITH_RDPSND
- // init sound
- if (g_rdpsnd)
- {
- rdpsnd_init();
- }
-#endif
- if (rdp_connect(g_server, g_flags, g_domain, g_password, g_shell,
- g_directory))
- {
- g_BS = (uint8*)xmalloc(g_width * g_height * 4);
- memset(g_BS, 0, g_width * g_height * 4);
- g_clipx = 0;
- g_clipy = 0;
- g_clipcx = g_width;
- g_clipcy = g_height;
- g_CM = (QColorMap*)xmalloc(sizeof(struct QColorMap));
- memset(g_CM, 0, sizeof(struct QColorMap));
- g_CM->NumColors = 256;
- g_MW = new QMyMainWindow();
- g_MW->resize(g_client_width, g_client_height);
- g_MW->show();
- g_SV->addChild(g_MW);
- g_MW->setMouseTracking(true);
- g_SocketNotifier = new QSocketNotifier(g_global_sock,
- QSocketNotifier::Read,
- g_MW);
- g_MW->connect(g_SocketNotifier, SIGNAL(activated(int)), g_MW,
- SLOT(dataReceived()));
- if (g_fullscreen)
- {
- Desktop = g_App->desktop();
- dw = Desktop->width();
- dh = Desktop->height();
- if (dw == g_client_width && dh == g_client_height)
- {
- g_MW->resize(g_client_width - 4, g_client_height - 4);
- }
- g_SV->showFullScreen();
- }
- g_MW->setCursor((int)10); /* Qt::BlankCursor */
- g_App->exec();
- }
- return 0;
-}
-
-/******************************************************************************/
-int main(int argc, char ** argv)
-{
-#ifdef SHARP
- g_App = new QPEApplication(argc, argv);
-#else
- g_App = new QApplication(argc, argv, QApplication::GuiServer);
- //g_App = new QApplication(argc, argv);
-#endif
- g_SV = new QMyScrollView();
- g_App->setMainWidget(g_SV);
- g_SV->showMaximized();
- if (argc > 1)
- {
- get_username_and_hostname();
- if (parse_parameters(argc, argv))
- {
- param_connect();
- }
- }
- else
- {
- g_SV->timer_id = g_SV->startTimer(1000); /* one sec delay, then dialog */
- g_App->exec();
- }
- delete g_SV;
- delete g_App;
- xfree(g_CM);
- xfree(g_BS);
- return 0;
-}
diff --git a/uiports/qtewin.h b/uiports/qtewin.h
deleted file mode 100644
index 451eb0d..0000000
--- a/uiports/qtewin.h
+++ /dev/null
@@ -1,107 +0,0 @@
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-class QMyConnectionItem
-{
- public:
- QString ServerName;
- QString UserName;
- QString ServerIP;
- int Width;
- int Height;
- int FullScreen;
-};
-
-class QMyDialog: public QDialog
-{
- Q_OBJECT
- public:
- QMyDialog(QWidget*);
- ~QMyDialog();
- public:
- QListBox* ListBox;
- QPushButton* OKButton;
- QPushButton* CancelButton;
- QLabel* Label1;
- QLineEdit* ServerNameEdit;
- QLabel* Label2;
- QLineEdit* UserNameEdit;
- QLabel* Label3;
- QLineEdit* IPEdit;
- QLineEdit* WidthEdit;
- QLineEdit* HeightEdit;
- QComboBox* WidthHeightBox;
- QPushButton* AddButton;
- QPushButton* EditButton;
- QPushButton* SaveButton;
- QPushButton* RemoveButton;
- QCheckBox* FullScreenCheckBox;
- public slots:
- void ComboChanged(int);
- void OKClicked();
- void CancelClicked();
- void AddClicked();
- void EditClicked();
- void SaveClicked();
- void RemoveClicked();
- void ListBoxChanged();
- void ListBoxSelected(int);
- public:
- QString ServerName;
- QString UserName;
- QString ServerIP;
- int Width;
- int Height;
- int FullScreen;
- QMyConnectionItem* ConnectionList[10];
-};
-
-class QMyScrollView: public QScrollView
-{
- Q_OBJECT
- public:
- QMyScrollView();
- ~QMyScrollView();
- void keyPressEvent(QKeyEvent*);
- void keyReleaseEvent(QKeyEvent*);
- void showEvent(QShowEvent*);
- void show();
- void polish();
- void timerEvent(QTimerEvent*);
- public:
- int timer_id;
- int sound_timer_id;
-};
-
-class QMyMainWindow: public QWidget
-{
- Q_OBJECT
- public:
- QMyMainWindow();
- ~QMyMainWindow();
- void paintEvent(QPaintEvent*);
- void mouseMoveEvent(QMouseEvent*);
- void mousePressEvent(QMouseEvent*);
- void mouseReleaseEvent(QMouseEvent*);
- void wheelEvent(QWheelEvent*);
- void closeEvent(QCloseEvent*);
- void timerEvent(QTimerEvent*);
- public slots:
- void dataReceived();
- void soundSend();
- void MemuClicked(int);
- public:
- QPopupMenu* PopupMenu;
- int timer_id;
- int mx;
- int my;
-};
-
diff --git a/uiports/qtreadme.txt b/uiports/qtreadme.txt
deleted file mode 100755
index 93fc73d..0000000
--- a/uiports/qtreadme.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-This is the Qt/X11 ui port
-qt should be installed in /usr/local/qt
-you may need to have LD_LIBRARY_PATH defined to run qtrdesktop
-tested with versions 2.3.2, 3.1.2
-
-makefile_qt can be edited to change file locations
-run make -f makefile_qt in this directory to compile it
-
-qtreadme.txt - notes, this file
-makefile_qt - makefile
-qtwin.cpp - ui lib
-qtwin.h - header
diff --git a/uiports/qtwin.cpp b/uiports/qtwin.cpp
deleted file mode 100755
index b87fe0e..0000000
--- a/uiports/qtwin.cpp
+++ /dev/null
@@ -1,1825 +0,0 @@
-/* -*- c-basic-offset: 8 -*-
- rdesktop: A Remote Desktop Protocol client.
- User interface services - QT Window System
- Copyright (C) Jay Sorg 2004-2007
-
- 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 3 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, see .
-*/
-
-#include "rdesktop.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "qtwin.h"
-
-#include // gethostname
-#include // getpwuid
-#include // va_list va_start va_end
-
-#include
-#include
-
-/* rdesktop globals */
-extern int g_tcp_port_rdp;
-RD_BOOL g_use_rdp5 = True;
-char g_hostname[16];
-char g_username[64];
-int g_height = 600;
-int g_width = 800;
-int g_server_depth = 8;
-int g_encryption = 1;
-int g_desktop_save = 1;
-int g_polygon_ellipse_orders = 0;
-int g_bitmap_cache = 1;
-int g_bitmap_cache_persist_enable = False;
-int g_bitmap_cache_precache = True;
-int g_rdp5_performanceflags = 0;
-int g_console_session = 0;
-int g_keylayout = 0x409; /* Defaults to US keyboard layout */
-int g_keyboard_type = 0x4; /* Defaults to US keyboard layout */
-int g_keyboard_subtype = 0x0; /* Defaults to US keyboard layout */
-int g_keyboard_functionkeys = 0xc; /* Defaults to US keyboard layout */
-int g_numlock_sync = 0;
-
-/* hack globals */
-static int g_argc = 0;
-static char ** g_argv = 0;
-static int g_UpAndRunning = 0;
-static int g_sock = 0;
-static int g_deactivated = 0;
-static uint32 g_ext_disc_reason = 0;
-static char g_servername[128];
-static char g_title[128] = "";
-static int g_flags = RDP_LOGON_NORMAL;
-
-#ifdef WITH_RDPSND
-extern int g_dsp_busy;
-extern int g_dsp_fd;
-static int g_rdpsnd = 0;
-static QSocketNotifier * g_SoundNotifier = 0;
-#endif
-
-/* qt globals */
-static QSocketNotifier * g_SocketNotifier = 0;
-static QApplication * g_App = 0;
-static QMyMainWindow * g_MW = 0;
-static QMyScrollView * g_SV = 0;
-static QPixmap * g_BS = 0;
-static QPixmap * g_DS = 0;
-static QPainter * g_P1 = 0;
-static QPainter * g_P2 = 0;
-static QColor g_Color1;
-static QColor g_Color2;
-
-struct QColorMap
-{
- uint32 RGBColors[256];
- int NumColors;
-};
-static struct QColorMap * g_CM = 0;
-static QRegion * g_ClipRect;
-
-static Qt::RasterOp g_OpCodes[16] = {
- Qt::ClearROP, // BLACKNESS 0
- Qt::NorROP, // NOTSRCERASE DSon
- Qt::NotAndROP, // DSna
- Qt::NotCopyROP, // NOTSRCCOPY Sn
- Qt::AndNotROP, // SRCERASE SDna
- Qt::NotROP, // DSTINVERT Dn
- Qt::XorROP, // SRCINVERT DSx
- Qt::NandROP, // DSan
- Qt::AndROP, // SRCAND DSa
- Qt::NotXorROP, // DSxn
- Qt::NopROP, // D
- Qt::NotOrROP, // MERGEPAINT DSno
- Qt::CopyROP, // SRCCOPY S
- Qt::OrNotROP, // SDno
- Qt::OrROP, // SRCPAINT DSo
- Qt::SetROP}; // WHITENESS 1
-
-/* Session Directory redirection */
-RD_BOOL g_redirect = False;
-char g_redirect_server[64];
-char g_redirect_domain[16];
-char g_redirect_password[64];
-char g_redirect_username[64];
-char g_redirect_cookie[128];
-uint32 g_redirect_flags = 0;
-
-//*****************************************************************************
-uint32 Color15to32(uint32 InColor)
-{
- uint32 r, g, b;
-
- r = (InColor & 0x7c00) >> 10;
- r = (r * 0xff) / 0x1f;
- g = (InColor & 0x03e0) >> 5;
- g = (g * 0xff) / 0x1f;
- b = (InColor & 0x001f);
- b = (b * 0xff) / 0x1f;
- return (r << 16) | (g << 8) | b;
-}
-
-//*****************************************************************************
-uint32 Color16to32(uint32 InColor)
-{
- uint32 r, g, b;
-
- r = (InColor & 0xf800) >> 11;
- r = (r * 0xff) / 0x1f;
- g = (InColor & 0x07e0) >> 5;
- g = (g * 0xff) / 0x3f;
- b = (InColor & 0x001f);
- b = (b * 0xff) / 0x1f;
- return (r << 16) | (g << 8) | b;
-}
-
-//*****************************************************************************
-uint32 Color24to32(uint32 InColor)
-{
- return ((InColor & 0x00ff0000) >> 16) |
- ((InColor & 0x000000ff) << 16) |
- (InColor & 0x0000ff00);
-}
-
-//*****************************************************************************
-void SetColorx(QColor * Color, uint32 InColor)
-{
- switch (g_server_depth)
- {
- case 8:
- if (g_CM == NULL || InColor > 255)
- {
- Color->setRgb(0);
- return;
- }
- Color->setRgb(g_CM->RGBColors[InColor]);
- break;
- case 15:
- Color->setRgb(Color15to32(InColor));
- break;
- case 16:
- Color->setRgb(Color16to32(InColor));
- break;
- case 24:
- Color->setRgb(Color24to32(InColor));
- break;
- default:
- Color->setRgb(0);
- }
-}
-
-//*****************************************************************************
-void SetOpCode(int opcode)
-{
- if (opcode >= 0 && opcode < 16)
- {
- Qt::RasterOp op = g_OpCodes[opcode];
- if (op != Qt::CopyROP)
- {
- g_P1->setRasterOp(op);
- g_P2->setRasterOp(op);
- }
- }
-}
-
-//*****************************************************************************
-void ResetOpCode(int opcode)
-{
- if (opcode >= 0 && opcode < 16)
- {
- Qt::RasterOp op = g_OpCodes[opcode];
- if (op != Qt::CopyROP)
- {
- g_P1->setRasterOp(Qt::CopyROP);
- g_P2->setRasterOp(Qt::CopyROP);
- }
- }
-}
-
-/*****************************************************************************/
-QMyMainWindow::QMyMainWindow(): QWidget()
-{
-}
-
-/*****************************************************************************/
-QMyMainWindow::~QMyMainWindow()
-{
-}
-
-//*****************************************************************************
-void QMyMainWindow::mouseMoveEvent(QMouseEvent * e)
-{
- if (!g_UpAndRunning)
- {
- return;
- }
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, e->x(), e->y());
-}
-
-//*****************************************************************************
-void QMyMainWindow::mousePressEvent(QMouseEvent * e)
-{
- if (!g_UpAndRunning)
- {
- return;
- }
- if (e->button() == LeftButton)
- {
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1,
- e->x(), e->y());
- }
- else if (e->button() == RightButton)
- {
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2,
- e->x(), e->y());
- }
- else if (e->button() == MidButton)
- {
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON3,
- e->x(), e->y());
- }
-}
-
-//*****************************************************************************
-void QMyMainWindow::mouseReleaseEvent(QMouseEvent * e)
-{
- if (!g_UpAndRunning)
- {
- return;
- }
- if (e->button() == LeftButton)
- {
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, e->x(), e->y());
- }
- else if (e->button() == RightButton)
- {
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, e->x(), e->y());
- }
- else if (e->button() == MidButton)
- {
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON3, e->x(), e->y());
- }
-}
-
-//*****************************************************************************
-void QMyMainWindow::wheelEvent(QWheelEvent * e)
-{
- if (!g_UpAndRunning)
- {
- return;
- }
- if (e->delta() > 0)
- {
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON4, e->x(), e->y());
- }
- else if (e->delta() < 0)
- {
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON5, e->x(), e->y());
- }
-}
-
-//*****************************************************************************
-int GetScanCode(QKeyEvent* e)
-{
- int Key = e->key();
- int ScanCode = 0;
- Qt::ButtonState bs = e->state();
- if (!(bs & Qt::ShiftButton)) // shift is not down
- {
- if (Key == 42) // *
- return 0x37;
- if (Key == 43) // +
- return 0x4e;
- }
- switch (Key)
- {
- case 4100: ScanCode = 0x1c; break; // enter
- case 4101: ScanCode = 0x1c; break;
- case 4117: ScanCode = 0xd0; break; // down arrow
- case 4115: ScanCode = 0xc8; break; // up arrow
- case 4114: ScanCode = 0xcb; break; // left arrow
- case 4116: ScanCode = 0xcd; break; // right arrow
- case 4112: ScanCode = 0xc7; break; // home
- case 4113: ScanCode = 0xcf; break; // end
- case 4102: ScanCode = 0xd2; break; // insert
- case 4103: ScanCode = 0xd3; break; // delete
- case 4118: ScanCode = 0xc9; break; // page up
- case 4119: ScanCode = 0xd1; break; // page down
- case 4143: ScanCode = 0x00; break; // num lock
- case 47: ScanCode = 0x35; break; // /
- case 42: ScanCode = 0x37; break; // *
- case 45: ScanCode = 0x0c; break; // -
- case 95: ScanCode = 0x0c; break; // _
- case 43: ScanCode = 0x0d; break; // +
- case 46: ScanCode = 0x34; break; // .
- case 48: ScanCode = 0x0b; break; // 0
- case 41: ScanCode = 0x0b; break; // )
- case 49: ScanCode = 0x02; break; // 1
- case 33: ScanCode = 0x02; break; // !
- case 50: ScanCode = 0x03; break; // 2
- case 64: ScanCode = 0x03; break; // @
- case 51: ScanCode = 0x04; break; // 3
- case 35: ScanCode = 0x04; break; // #
- case 52: ScanCode = 0x05; break; // 4
- case 36: ScanCode = 0x05; break; // $
- case 53: ScanCode = 0x06; break; // 5
- case 37: ScanCode = 0x06; break; // %
- case 54: ScanCode = 0x07; break; // 6
- case 94: ScanCode = 0x07; break; // ^
- case 55: ScanCode = 0x08; break; // 7
- case 38: ScanCode = 0x08; break; // &
- case 56: ScanCode = 0x09; break; // 8
- case 57: ScanCode = 0x0a; break; // 9
- case 40: ScanCode = 0x0a; break; // (
- case 61: ScanCode = 0x0d; break; // =
- case 65: ScanCode = 0x1e; break; // a
- case 66: ScanCode = 0x30; break; // b
- case 67: ScanCode = 0x2e; break; // c
- case 68: ScanCode = 0x20; break; // d
- case 69: ScanCode = 0x12; break; // e
- case 70: ScanCode = 0x21; break; // f
- case 71: ScanCode = 0x22; break; // g
- case 72: ScanCode = 0x23; break; // h
- case 73: ScanCode = 0x17; break; // i
- case 74: ScanCode = 0x24; break; // j
- case 75: ScanCode = 0x25; break; // k
- case 76: ScanCode = 0x26; break; // l
- case 77: ScanCode = 0x32; break; // m
- case 78: ScanCode = 0x31; break; // n
- case 79: ScanCode = 0x18; break; // o
- case 80: ScanCode = 0x19; break; // p
- case 81: ScanCode = 0x10; break; // q
- case 82: ScanCode = 0x13; break; // r
- case 83: ScanCode = 0x1f; break; // s
- case 84: ScanCode = 0x14; break; // t
- case 85: ScanCode = 0x16; break; // u
- case 86: ScanCode = 0x2f; break; // v
- case 87: ScanCode = 0x11; break; // w
- case 88: ScanCode = 0x2d; break; // x
- case 89: ScanCode = 0x15; break; // y
- case 90: ScanCode = 0x2c; break; // z
- case 32: ScanCode = 0x39; break; // space
- case 44: ScanCode = 0x33; break; // ,
- case 60: ScanCode = 0x33; break; // <
- case 62: ScanCode = 0x34; break; // >
- case 63: ScanCode = 0x35; break; // ?
- case 92: ScanCode = 0x2b; break; // backslash
- case 124: ScanCode = 0x2b; break; // bar
- case 4097: ScanCode = 0x0f; break; // tab
- case 4132: ScanCode = 0x3a; break; // caps lock
- case 4096: ScanCode = 0x01; break; // esc
- case 59: ScanCode = 0x27; break; // ;
- case 58: ScanCode = 0x27; break; // :
- case 39: ScanCode = 0x28; break; // '
- case 34: ScanCode = 0x28; break; // "
- case 91: ScanCode = 0x1a; break; // [
- case 123: ScanCode = 0x1a; break; // {
- case 93: ScanCode = 0x1b; break; // ]
- case 125: ScanCode = 0x1b; break; // }
- case 4144: ScanCode = 0x3b; break; // f1
- case 4145: ScanCode = 0x3c; break; // f2
- case 4146: ScanCode = 0x3d; break; // f3
- case 4147: ScanCode = 0x3e; break; // f4
- case 4148: ScanCode = 0x3f; break; // f5
- case 4149: ScanCode = 0x40; break; // f6
- case 4150: ScanCode = 0x41; break; // f7
- case 4151: ScanCode = 0x42; break; // f8
- case 4152: ScanCode = 0x43; break; // f9
- case 4153: ScanCode = 0x44; break; // f10
- case 4154: ScanCode = 0x57; break; // f11
- case 4155: ScanCode = 0x58; break; // f12
- case 4128: ScanCode = 0x2a; break; // shift
- case 4131: ScanCode = 0x38; break; // alt
- case 4129: ScanCode = 0x1d; break; // ctrl
- case 96: ScanCode = 0x29; break; // `
- case 126: ScanCode = 0x29; break; // ~
- case 4099: ScanCode = 0x0e; break; // backspace
- }
-// if (ScanCode == 0)
-// printf("key %d scancode %d\n", Key, ScanCode);
- return ScanCode;
-}
-
-//*****************************************************************************
-void QMyMainWindow::keyPressEvent(QKeyEvent* e)
-{
- if (!g_UpAndRunning)
- return;
- int ScanCode = GetScanCode(e);
- if (ScanCode != 0)
- {
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, ScanCode, 0);
- e->accept();
- }
-}
-
-//*****************************************************************************
-void QMyMainWindow::keyReleaseEvent(QKeyEvent* e)
-{
- if (!g_UpAndRunning)
- {
- return;
- }
- int ScanCode = GetScanCode(e);
- if (ScanCode != 0)
- {
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, ScanCode, 0);
- e->accept();
- }
-}
-
-//*****************************************************************************
-void QMyMainWindow::paintEvent(QPaintEvent * pe)
-{
- QRect Rect;
-
- Rect = pe->rect();
- bitBlt(this, Rect.left(), Rect.top(), g_BS, Rect.left(), Rect.top(),
- Rect.width(), Rect.height());
-}
-
-//*****************************************************************************
-void QMyMainWindow::closeEvent(QCloseEvent * e)
-{
- e->accept();
-}
-
-//*****************************************************************************
-bool QMyMainWindow::event(QEvent * e)
-{
- return QWidget::event(e);
-}
-
-//*****************************************************************************
-void QMyMainWindow::dataReceived()
-{
- if (!rdp_loop(&g_deactivated, &g_ext_disc_reason))
- {
- g_SV->close();
- }
-#ifdef WITH_RDPSND
- if (g_dsp_busy)
- {
- if (g_SoundNotifier == 0)
- {
- g_SoundNotifier = new QSocketNotifier(g_dsp_fd, QSocketNotifier::Write,
- g_MW);
- g_MW->connect(g_SoundNotifier, SIGNAL(activated(int)), g_MW,
- SLOT(soundSend()));
- }
- else
- {
- if (!g_SoundNotifier->isEnabled())
- {
- g_SoundNotifier->setEnabled(true);
- }
- }
- }
-#endif
-}
-
-/******************************************************************************/
-void QMyMainWindow::soundSend()
-{
-#ifdef WITH_RDPSND
- g_SoundNotifier->setEnabled(false);
- wave_out_play();
- if (g_dsp_busy)
- {
- g_SoundNotifier->setEnabled(true);
- }
-#endif
-}
-
-//*****************************************************************************
-void QMyScrollView::keyPressEvent(QKeyEvent * e)
-{
- g_MW->keyPressEvent(e);
-}
-
-//*****************************************************************************
-void QMyScrollView::keyReleaseEvent(QKeyEvent * e)
-{
- g_MW->keyReleaseEvent(e);
-}
-
-
-//*****************************************************************************
-void ui_begin_update(void)
-{
- g_P1->begin(g_MW);
- g_P2->begin(g_BS);
-}
-
-//*****************************************************************************
-void ui_end_update(void)
-{
- g_P1->end();
- g_P2->end();
-}
-
-/*****************************************************************************/
-int ui_init(void)
-{
- g_App = new QApplication(g_argc, g_argv);
- return 1;
-}
-
-/*****************************************************************************/
-void ui_deinit(void)
-{
- delete g_App;
-}
-
-/*****************************************************************************/
-int ui_create_window(void)
-{
- int w, h;
- QPainter * painter;
- QWidget * desktop;
-
- g_MW = new QMyMainWindow();
- g_SV = new QMyScrollView();
- g_SV->addChild(g_MW);
- g_BS = new QPixmap(g_width, g_height);
- painter = new QPainter(g_BS);
- painter->fillRect(0, 0, g_width, g_height, QBrush(QColor("white")));
- painter->fillRect(0, 0, g_width, g_height, QBrush(QBrush::CrossPattern));
- delete painter;
- g_DS = new QPixmap(480, 480);
- g_P1 = new QPainter();
- g_P2 = new QPainter();
- g_ClipRect = new QRegion(0, 0, g_width, g_height);
- desktop = QApplication::desktop();
- w = desktop->width(); // returns screen width
- h = desktop->height(); // returns screen height
- g_MW->resize(g_width, g_height);
- if (w < g_width || h < g_height)
- {
- g_SV->resize(w, h);
- }
- else
- {
- g_SV->resize(g_width + 4, g_height + 4);
- }
- g_SV->setMaximumWidth(g_width + 4);
- g_SV->setMaximumHeight(g_height + 4);
- g_App->setMainWidget(g_SV);
- g_SV->show();
- g_MW->setMouseTracking(true);
- if (g_title[0] != 0)
- {
- g_SV->setCaption(g_title);
- }
-
-/* XGrayKey(0, 64, AnyModifie, SV->winId(), 0, GrabModeAsync, GrabModeAsync);
- XGrayKey(0, 113, AnyModifie, SV->winId(), 0, GrabModeAsync, GrabModeAsync);
- XGrayKey(0, 37, AnyModifie, SV-winId(), 0, GrabModeAsync, GrabModeAsync);
- XGrayKey(0, 109, AnyModifie, SV->winId(), 0, GrabModeAsync, GrabModeAsync);
- XGrayKey(0, 115, AnyModifie, SV->winId(), 0, GrabModeAsync, GrabModeAsync);
- XGrayKey(0, 116, AnyModifie, SV->winId(), 0, GrabModeAsync, GrabModeAsync);
- XGrayKey(0, 117, AnyModifie, SV->winId(), 0, GrabModeAsync, GrabModeAsync);
- XGrayKey(0, 62, AnyModifie, SV->winId(), 0, GrabModeAsync, GrabModeAsync);
- XGrayKey(0, 50, AnyModifie, SV->winId(), 0, GrabModeAsync, GrabModeAsync);*/
-
- return 1;
-}
-
-//*****************************************************************************
-void ui_main_loop(void)
-{
-#ifdef WITH_RDPSND
- // init sound
- if (g_rdpsnd)
- {
- rdpsnd_init(0);
- }
-#endif
- // connect
- if (!rdp_connect(g_servername, g_flags, "", "", "", ""))
- {
- return;
- }
- // start notifier
- g_SocketNotifier = new QSocketNotifier(g_sock, QSocketNotifier::Read, g_MW);
- g_MW->connect(g_SocketNotifier, SIGNAL(activated(int)),
- g_MW, SLOT(dataReceived()));
- g_UpAndRunning = 1;
- // app main loop
- g_App->exec();
-}
-
-//*****************************************************************************
-void ui_destroy_window(void)
-{
- delete g_MW;
- delete g_SV;
- delete g_BS;
- delete g_DS;
- delete g_P1;
- delete g_P2;
- delete g_ClipRect;
-}
-
-/*****************************************************************************/
-void ui_bell(void)
-{
-}
-
-/*****************************************************************************/
-int ui_select(int in_val)
-{
- if (g_sock == 0)
- {
- g_sock = in_val;
- }
- return 1;
-}
-
-/*****************************************************************************/
-void ui_destroy_cursor(void * cursor)
-{
- QCursor * Cursor;
- Cursor = (QCursor*)cursor;
- if (Cursor != NULL)
- {
- delete Cursor;
- }
-}
-
-/*****************************************************************************/
-void* ui_create_glyph(int width, int height, uint8 * data)
-{
- QBitmap * Bitmap;
- Bitmap = new QBitmap(width, height, data);
- Bitmap->setMask(*Bitmap);
- return (RD_HGLYPH)Bitmap;
-}
-
-/*****************************************************************************/
-void ui_destroy_glyph(void * glyph)
-{
- QBitmap* Bitmap;
- Bitmap = (QBitmap*)glyph;
- delete Bitmap;
-}
-
-/*****************************************************************************/
-void ui_destroy_bitmap(void * bmp)
-{
- QPixmap * Pixmap;
- Pixmap = (QPixmap*)bmp;
- delete Pixmap;
-}
-
-/*****************************************************************************/
-void ui_reset_clip(void)
-{
- g_P1->setClipRect(0, 0, g_width, g_height);
- g_P2->setClipRect(0, 0, g_width, g_height);
- delete g_ClipRect;
- g_ClipRect = new QRegion(0, 0, g_width, g_height);
-}
-
-/*****************************************************************************/
-void ui_set_clip(int x, int y, int cx, int cy)
-{
- g_P1->setClipRect(x, y, cx, cy);
- g_P2->setClipRect(x, y, cx, cy);
- delete g_ClipRect;
- g_ClipRect = new QRegion(x, y, cx, cy);
-}
-
-/*****************************************************************************/
-void * ui_create_colourmap(COLOURMAP * colours)
-{
- QColorMap* LCM;
- int i, r, g, b;
- LCM = (QColorMap*)malloc(sizeof(QColorMap));
- memset(LCM, 0, sizeof(QColorMap));
- i = 0;
- while (i < colours->ncolours && i < 256)
- {
- r = colours->colours[i].red;
- g = colours->colours[i].green;
- b = colours->colours[i].blue;
- LCM->RGBColors[i] = (r << 16) | (g << 8) | b;
- i++;
- }
- LCM->NumColors = colours->ncolours;
- return LCM;
-}
-
-//*****************************************************************************
-// todo, does this leak at end of program
-void ui_destroy_colourmap(RD_HCOLOURMAP map)
-{
- QColorMap * LCM;
- LCM = (QColorMap*)map;
- if (LCM == NULL)
- return;
- free(LCM);
-}
-
-/*****************************************************************************/
-void ui_set_colourmap(void * map)
-{
- // destroy old colormap
- ui_destroy_colourmap(g_CM);
- g_CM = (QColorMap*)map;
-}
-
-/*****************************************************************************/
-RD_HBITMAP ui_create_bitmap(int width, int height, uint8 * data)
-{
- QImage * Image = NULL;
- QPixmap * Pixmap;
- uint32 * d = NULL;
- uint16 * s;
- int i;
-
- switch (g_server_depth)
- {
- case 8:
- Image = new QImage(data, width, height, 8, (QRgb*)&g_CM->RGBColors,
- g_CM->NumColors, QImage::IgnoreEndian);
- break;
- case 15:
- d = (uint32*)malloc(width * height * 4);
- s = (uint16*)data;
- for (i = 0; i < width * height; i++)
- {
- d[i] = Color15to32(s[i]);
- }
- Image = new QImage((uint8*)d, width, height, 32, NULL,
- 0, QImage::IgnoreEndian);
- break;
- case 16:
- d = (uint32*)malloc(width * height * 4);
- s = (uint16*)data;
- for (i = 0; i < width * height; i++)
- {
- d[i] = Color16to32(s[i]);
- }
- Image = new QImage((uint8*)d, width, height, 32, NULL,
- 0, QImage::IgnoreEndian);
- break;
- case 24:
- d = (uint32*)malloc(width * height * 4);
- memset(d, 0, width * height * 4);
- for (i = 0; i < width * height; i++)
- {
- memcpy(d + i, data + i * 3, 3);
- }
- Image = new QImage((uint8*)d, width, height, 32, NULL,
- 0, QImage::IgnoreEndian);
- break;
- }
- if (Image == NULL)
- {
- return NULL;
- }
- Pixmap = new QPixmap();
- Pixmap->convertFromImage(*Image);
- delete Image;
- if (d != NULL)
- {
- free(d);
- }
- return (RD_HBITMAP)Pixmap;
-}
-
-//******************************************************************************
-// adjust coordinates for clipping rect
-int WarpCoords(int * x, int * y, int * cx, int * cy, int * srcx, int * srcy)
-{
- int dx, dy;
- QRect InRect(*x, *y, *cx, *cy);
- QRect OutRect;
- QRect CRect = g_ClipRect->boundingRect();
- OutRect = InRect.intersect(CRect);
- if (OutRect.isEmpty())
- {
- return False;
- }
- dx = OutRect.x() - InRect.x();
- dy = OutRect.y() - InRect.y();
- *x = OutRect.x();
- *y = OutRect.y();
- *cx = OutRect.width();
- *cy = OutRect.height();
- *srcx = *srcx + dx;
- *srcy = *srcy + dy;
- return True;
-}
-
-//******************************************************************************
-// needed because bitBlt don't seem to care about clipping rects
-// also has 2 dsts and src can be null
-void bitBltClip(QPaintDevice * dst1, QPaintDevice * dst2, int dx, int dy,
- QPaintDevice * src, int sx, int sy, int sw, int sh,
- Qt::RasterOp rop, bool im)
-{
- if (WarpCoords(&dx, &dy, &sw, &sh, &sx, &sy))
- {
- if (dst1 != NULL)
- {
- if (src == NULL)
- {
- bitBlt(dst1, dx, dy, dst1, sx, sy, sw, sh, rop, im);
- }
- else
- {
- bitBlt(dst1, dx, dy, src, sx, sy, sw, sh, rop, im);
- }
- }
- if (dst2 != NULL)
- {
- if (src == NULL)
- {
- bitBlt(dst2, dx, dy, dst2, sx, sy, sw, sh, rop, im);
- }
- else
- {
- bitBlt(dst2, dx, dy, src, sx, sy, sw, sh, rop, im);
- }
- }
- }
-}
-
-#define DO_GLYPH(ttext,idx) \
-{ \
- glyph = cache_get_font (font, ttext[idx]); \
- if (!(flags & TEXT2_IMPLICIT_X)) \
- { \
- xyoffset = ttext[++idx]; \
- if ((xyoffset & 0x80)) \
- { \
- if (flags & TEXT2_VERTICAL) \
- y += ttext[idx+1] | (ttext[idx+2] << 8); \
- else \
- x += ttext[idx+1] | (ttext[idx+2] << 8); \
- idx += 2; \
- } \
- else \
- { \
- if (flags & TEXT2_VERTICAL) \
- y += xyoffset; \
- else \
- x += xyoffset; \
- } \
- } \
- if (glyph != NULL) \
- { \
- g_P2->drawPixmap(x + glyph->offset, y + glyph->baseline, \
- *((QBitmap*)glyph->pixmap)); \
- if (flags & TEXT2_IMPLICIT_X) \
- x += glyph->width; \
- } \
-}
-
-//*****************************************************************************
-void ui_draw_text(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, BRUSH * brush,
- int bgcolour, int fgcolour, uint8 * text, uint8 length)
-{
- FONTGLYPH * glyph;
- int i, j, xyoffset;
- DATABLOB * entry;
-
- SetColorx(&g_Color1, fgcolour);
- SetColorx(&g_Color2, bgcolour);
- g_P2->setBackgroundColor(g_Color2);
- g_P2->setPen(g_Color1);
- if (boxcx > 1)
- {
- g_P2->fillRect(boxx, boxy, boxcx, boxcy, QBrush(g_Color2));
- }
- else if (mixmode == MIX_OPAQUE)
- {
- g_P2->fillRect(clipx, clipy, clipcx, clipcy, QBrush(g_Color2));
- }
-
- /* Paint text, character by character */
- for (i = 0; i < length;)
- {
- switch (text[i])
- {
- case 0xff:
- if (i + 2 < length)
- {
- cache_put_text(text[i + 1], text, text[i + 2]);
- }
- else
- {
- error("this shouldn't be happening\n");
- exit(1);
- }
- /* this will move pointer from start to first character after FF
- command */
- length -= i + 3;
- text = &(text[i + 3]);
- i = 0;
- break;
-
- case 0xfe:
- entry = cache_get_text(text[i + 1]);
- if (entry != NULL)
- {
- if ((((uint8 *) (entry->data))[1] == 0) &&
- (!(flags & TEXT2_IMPLICIT_X)))
- {
- if (flags & TEXT2_VERTICAL)
- {
- y += text[i + 2];
- }
- else
- {
- x += text[i + 2];
- }
- }
- for (j = 0; j < entry->size; j++)
- {
- DO_GLYPH(((uint8 *) (entry->data)), j);
- }
- }
- if (i + 2 < length)
- {
- i += 3;
- }
- else
- {
- i += 2;
- }
- length -= i;
- /* this will move pointer from start to first character after FE
- command */
- text = &(text[i]);
- i = 0;
- break;
-
- default:
- DO_GLYPH(text, i);
- i++;
- break;
- }
- }
- if (boxcx > 1)
- {
- bitBltClip(g_MW, NULL, boxx, boxy, g_BS, boxx, boxy, boxcx, boxcy,
- Qt::CopyROP, true);
- }
- else
- {
- bitBltClip(g_MW, NULL, clipx, clipy, g_BS, clipx, clipy, clipcx,
- clipcy, Qt::CopyROP, true);
- }
-}
-
-/*****************************************************************************/
-void ui_line(uint8 opcode, int startx, int starty, int endx, int endy,
- PEN * pen)
-{
- SetColorx(&g_Color1, pen->colour);
- SetOpCode(opcode);
- g_P1->setPen(g_Color1);
- g_P1->moveTo(startx, starty);
- g_P1->lineTo(endx, endy);
- g_P2->setPen(g_Color1);
- g_P2->moveTo(startx, starty);
- g_P2->lineTo(endx, endy);
- ResetOpCode(opcode);
-}
-
-/*****************************************************************************/
-// not used
-void ui_triblt(uint8 opcode, int x, int y, int cx, int cy,
- RD_HBITMAP src, int srcx, int srcy,
- BRUSH* brush, int bgcolour, int fgcolour)
-{
-}
-
-/*****************************************************************************/
-void ui_memblt(uint8 opcode, int x, int y, int cx, int cy,
- RD_HBITMAP src, int srcx, int srcy)
-{
- QPixmap* Pixmap;
- Pixmap = (QPixmap*)src;
- if (Pixmap != NULL)
- {
- SetOpCode(opcode);
- g_P1->drawPixmap(x, y, *Pixmap, srcx, srcy, cx, cy);
- g_P2->drawPixmap(x, y, *Pixmap, srcx, srcy, cx, cy);
- ResetOpCode(opcode);
- }
-}
-
-//******************************************************************************
-void CommonDeskSave(QPixmap* Pixmap1, QPixmap* Pixmap2, int Offset, int x,
- int y, int cx, int cy, int dir)
-{
- int lx;
- int ly;
- int x1;
- int y1;
- int width;
- int lcx;
- int right;
- int bottom;
- lx = Offset % 480;
- ly = Offset / 480;
- y1 = y;
- right = x + cx;
- bottom = y + cy;
- while (y1 < bottom)
- {
- x1 = x;
- lcx = cx;
- while (x1 < right)
- {
- width = 480 - lx;
- if (width > lcx)
- width = lcx;
- if (dir == 0)
- bitBlt(Pixmap1, lx, ly, Pixmap2, x1, y1, width, 1, Qt::CopyROP, true);
- else
- bitBlt(Pixmap2, x1, y1, Pixmap1, lx, ly, width, 1, Qt::CopyROP, true);
- lx = lx + width;
- if (lx >= 480)
- {
- lx = 0;
- ly++;
- if (ly >= 480)
- ly = 0;
- }
- lcx = lcx - width;
- x1 = x1 + width;
- }
- y1++;
- }
-}
-
-/*****************************************************************************/
-void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
-{
- QPixmap * Pixmap;
-
- Pixmap = new QPixmap(cx, cy);
- CommonDeskSave(g_DS, Pixmap, offset, 0, 0, cx, cy, 1);
- bitBltClip(g_MW, g_BS, x, y, Pixmap, 0, 0, cx, cy, Qt::CopyROP, true);
- delete Pixmap;
-}
-
-/*****************************************************************************/
-void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
-{
- CommonDeskSave(g_DS, g_BS, offset, x, y, cx, cy, 0);
-}
-
-/*****************************************************************************/
-void ui_rect(int x, int y, int cx, int cy, int colour)
-{
- SetColorx(&g_Color1, colour);
- g_P1->fillRect(x, y, cx, cy, QBrush(g_Color1));
- g_P2->fillRect(x, y, cx, cy, QBrush(g_Color1));
-}
-
-/*****************************************************************************/
-void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy,
- int srcx, int srcy)
-{
- SetOpCode(opcode);
- bitBltClip(g_MW, g_BS, x, y, NULL, srcx, srcy, cx, cy, Qt::CopyROP, true);
- ResetOpCode(opcode);
-}
-
-/*****************************************************************************/
-void ui_patblt(uint8 opcode, int x, int y, int cx, int cy,
- BRUSH* brush, int bgcolour, int fgcolour)
-{
- QBitmap* Bitmap;
- QBrush* Brush;
- uint8 ipattern[8], i;
- SetOpCode(opcode);
- switch (brush->style)
- {
- case 0:
- SetColorx(&g_Color1, fgcolour);
- g_P2->fillRect(x, y, cx, cy, QBrush(g_Color1));
- break;
- case 3:
- SetColorx(&g_Color1, fgcolour);
- SetColorx(&g_Color2, bgcolour);
- for (i = 0; i != 8; i++)
- {
- ipattern[7 - i] = ~brush->pattern[i];
- }
- Bitmap = new QBitmap(8, 8, ipattern);
- Brush = new QBrush(g_Color1, *Bitmap);
- g_P2->setBackgroundMode(Qt::OpaqueMode);
- g_P2->setBrushOrigin(brush->xorigin, brush->yorigin);
- g_P2->setBackgroundColor(g_Color2);
- g_P2->fillRect(x, y, cx, cy, *Brush);
- delete Brush;
- delete Bitmap;
- g_P2->setBackgroundMode(Qt::TransparentMode);
- g_P2->setBrushOrigin(0, 0);
- break;
- }
- ResetOpCode(opcode);
- bitBltClip(g_MW, NULL, x, y, g_BS, x, y, cx, cy, Qt::CopyROP, true);
-}
-
-/*****************************************************************************/
-void ui_destblt(uint8 opcode, int x, int y, int cx, int cy)
-{
- SetOpCode(opcode);
- g_P1->fillRect(x, y, cx, cy, QBrush(QColor("black")));
- g_P2->fillRect(x, y, cx, cy, QBrush(QColor("black")));
- ResetOpCode(opcode);
-}
-
-/*****************************************************************************/
-void ui_move_pointer(int x, int y)
-{
-}
-
-/*****************************************************************************/
-void ui_set_null_cursor(void)
-{
- g_MW->setCursor(10); // Qt::BlankCursor
-}
-
-/*****************************************************************************/
-void ui_paint_bitmap(int x, int y, int cx, int cy,
- int width, int height, uint8* data)
-{
- QImage * Image = NULL;
- QPixmap * Pixmap;
- uint32 * d = NULL;
- uint16 * s;
- int i;
-
- switch (g_server_depth)
- {
- case 8:
- Image = new QImage(data, width, height, 8, (QRgb*)&g_CM->RGBColors,
- g_CM->NumColors, QImage::IgnoreEndian);
- break;
- case 15:
- d = (uint32*)malloc(width * height * 4);
- s = (uint16*)data;
- for (i = 0; i < width * height; i++)
- {
- d[i] = Color15to32(s[i]);
- }
- Image = new QImage((uint8*)d, width, height, 32, NULL,
- 0, QImage::IgnoreEndian);
- break;
- case 16:
- d = (uint32*)malloc(width * height * 4);
- s = (uint16*)data;
- for (i = 0; i < width * height; i++)
- {
- d[i] = Color16to32(s[i]);
- }
- Image = new QImage((uint8*)d, width, height, 32, NULL,
- 0, QImage::IgnoreEndian);
- break;
- case 24:
- d = (uint32*)malloc(width * height * 4);
- memset(d, 0, width * height * 4);
- for (i = 0; i < width * height; i++)
- {
- memcpy(d + i, data + i * 3, 3);
- }
- Image = new QImage((uint8*)d, width, height, 32, NULL,
- 0, QImage::IgnoreEndian);
- break;
- }
- if (Image == NULL)
- {
- return;
- }
- Pixmap = new QPixmap();
- Pixmap->convertFromImage(*Image);
- g_P1->drawPixmap(x, y, *Pixmap, 0, 0, cx, cy);
- g_P2->drawPixmap(x, y, *Pixmap, 0, 0, cx, cy);
- delete Image;
- delete Pixmap;
- if (d != NULL)
- {
- free(d);
- }
-}
-
-//******************************************************************************
-int Is24On(uint8* Data, int X, int Y)
-{
- uint8 R, G, B;
- int Start;
- Start = Y * 32 * 3 + X * 3;
- R = Data[Start];
- G = Data[Start + 1];
- B = Data[Start + 2];
- return !((R == 0) && (G == 0) && (B == 0));
-}
-
-//******************************************************************************
-int Is1On(uint8* Data, int X, int Y)
-{
- int Start;
- int Shift;
- Start = (Y * 32) / 8 + X / 8;
- Shift = X % 8;
- return (Data[Start] & (0x80 >> Shift)) == 0;
-}
-
-//******************************************************************************
-void Set1(uint8* Data, int X, int Y)
-{
- int Start;
- int Shift;
- Start = (Y * 32) / 8 + X / 8;
- Shift = X % 8;
- Data[Start] = Data[Start] | (0x80 >> Shift);
-}
-
-//******************************************************************************
-void FlipOver(uint8* Data)
-{
- uint8 AData[128];
- int Index;
- memcpy(AData, Data, 128);
- for (Index = 0; Index <= 31; Index++)
- {
- Data[127 - (Index * 4 + 3)] = AData[Index * 4];
- Data[127 - (Index * 4 + 2)] = AData[Index * 4 + 1];
- Data[127 - (Index * 4 + 1)] = AData[Index * 4 + 2];
- Data[127 - Index * 4] = AData[Index * 4 + 3];
- }
-}
-
-/*****************************************************************************/
-void ui_set_cursor(RD_HCURSOR cursor)
-{
- QCursor* Cursor;
- Cursor = (QCursor*)cursor;
- if (Cursor != NULL)
- g_MW->setCursor(*Cursor);
-}
-
-/*****************************************************************************/
-RD_HCURSOR ui_create_cursor(unsigned int x, unsigned int y,
- int width, int height,
- uint8* andmask, uint8* xormask)
-{
- uint8 AData[128];
- uint8 AMask[128];
- QBitmap* DataBitmap;
- QBitmap* MaskBitmap;
- QCursor* Cursor;
- int I1, I2, BOn, MOn;
-
- if (width != 32 || height != 32)
- {
- return 0;
- }
- memset(AData, 0, 128);
- memset(AMask, 0, 128);
- for (I1 = 0; I1 <= 31; I1++)
- {
- for (I2 = 0; I2 <= 31; I2++)
- {
- MOn = Is24On(xormask, I1, I2);
- BOn = Is1On(andmask, I1, I2);
- if (BOn ^ MOn) // xor
- {
- Set1(AData, I1, I2);
- if (!MOn)
- {
- Set1(AMask, I1, I2);
- }
- }
- if (MOn)
- {
- Set1(AMask, I1, I2);
- }
- }
- }
- FlipOver(AData);
- FlipOver(AMask);
- DataBitmap = new QBitmap(32, 32, AData);
- MaskBitmap = new QBitmap(32, 32, AMask);
- Cursor = new QCursor(*DataBitmap, *MaskBitmap, x, y);
- delete DataBitmap;
- delete MaskBitmap;
- return Cursor;
-}
-
-/*****************************************************************************/
-uint16 ui_get_numlock_state(uint32 state)
-{
- return 0;
-}
-
-/*****************************************************************************/
-uint32 read_keyboard_state(void)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void ui_resize_window(void)
-{
-}
-
-/*****************************************************************************/
-void ui_polygon(uint8 opcode, uint8 fillmode, RD_POINT * point, int npoints,
- BRUSH * brush, int bgcolour, int fgcolour)
-{
-}
-
-/*****************************************************************************/
-/* todo, use qt function for this (QPainter::drawPolyline) */
-void ui_polyline(uint8 opcode, RD_POINT * points, int npoints, PEN * pen)
-{
- int i, x, y, dx, dy;
-
- if (npoints > 0)
- {
- x = points[0].x;
- y = points[0].y;
- for (i = 1; i < npoints; i++)
- {
- dx = points[i].x;
- dy = points[i].y;
- ui_line(opcode, x, y, x + dx, y + dy, pen);
- x = x + dx;
- y = y + dy;
- }
- }
-}
-
-/*****************************************************************************/
-void ui_ellipse(uint8 opcode, uint8 fillmode,
- int x, int y, int cx, int cy,
- BRUSH * brush, int bgcolour, int fgcolour)
-{
-}
-
-/*****************************************************************************/
-void generate_random(uint8 * random)
-{
- QFile File("/dev/random");
- File.open(IO_ReadOnly);
- if (File.readBlock((char*)random, 32) == 32)
- {
- return;
- }
- warning("no /dev/random\n");
- memcpy(random, "12345678901234567890123456789012", 32);
-}
-
-/*****************************************************************************/
-void save_licence(uint8 * data, int length)
-{
- char * home, * path, * tmppath;
- int fd;
-
- home = getenv("HOME");
- if (home == NULL)
- {
- return;
- }
- path = (char *) xmalloc(strlen(home) + strlen(g_hostname) +
- sizeof("/.rdesktop/licence."));
- sprintf(path, "%s/.rdesktop", home);
- if ((mkdir(path, 0700) == -1) && errno != EEXIST)
- {
- perror(path);
- return;
- }
- /* write licence to licence.hostname.new, then atomically rename to
- licence.hostname */
- sprintf(path, "%s/.rdesktop/licence.%s", home, g_hostname);
- tmppath = (char *) xmalloc(strlen(path) + sizeof(".new"));
- strcpy(tmppath, path);
- strcat(tmppath, ".new");
- fd = open(tmppath, O_WRONLY | O_CREAT | O_TRUNC, 0600);
- if (fd == -1)
- {
- perror(tmppath);
- return;
- }
- if (write(fd, data, length) != length)
- {
- perror(tmppath);
- unlink(tmppath);
- }
- else if (rename(tmppath, path) == -1)
- {
- perror(path);
- unlink(tmppath);
- }
- close(fd);
- xfree(tmppath);
- xfree(path);
-}
-
-/*****************************************************************************/
-int load_licence(uint8 ** data)
-{
- char * home, * path;
- struct stat st;
- int fd, length;
-
- home = getenv("HOME");
- if (home == NULL)
- {
- return -1;
- }
- path = (char *) xmalloc(strlen(home) + strlen(g_hostname) +
- sizeof("/.rdesktop/licence."));
- sprintf(path, "%s/.rdesktop/licence.%s", home, g_hostname);
- fd = open(path, O_RDONLY);
- if (fd == -1)
- {
- return -1;
- }
- if (fstat(fd, &st))
- {
- return -1;
- }
- *data = (uint8 *) xmalloc(st.st_size);
- length = read(fd, *data, st.st_size);
- close(fd);
- xfree(path);
- return length;
-}
-
-/*****************************************************************************/
-void* xrealloc(void * in_val, int size)
-{
- return realloc(in_val, size);
-}
-
-/*****************************************************************************/
-void* xmalloc(int size)
-{
- return malloc(size);
-}
-
-/*****************************************************************************/
-void xfree(void * in_val)
-{
- if (in_val != NULL)
- {
- free(in_val);
- }
-}
-
-/*****************************************************************************/
-char * xstrdup(const char * s)
-{
- char * mem = strdup(s);
- if (mem == NULL)
- {
- perror("strdup");
- exit(1);
- }
- return mem;
-}
-
-/*****************************************************************************/
-void warning(char * format, ...)
-{
- va_list ap;
-
- fprintf(stderr, "WARNING: ");
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- va_end(ap);
-}
-
-/*****************************************************************************/
-void unimpl(char * format, ...)
-{
- va_list ap;
-
- fprintf(stderr, "NOT IMPLEMENTED: ");
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- va_end(ap);
-}
-
-/*****************************************************************************/
-void error(char * format, ...)
-{
- va_list ap;
-
- fprintf(stderr, "ERROR: ");
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- va_end(ap);
-}
-
-/*****************************************************************************/
-void out_params(void)
-{
- fprintf(stderr, "rdesktop: A Remote Desktop Protocol client.\n");
- fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2007 Matt Chapman.\n");
- fprintf(stderr, "QT uiport by Jay Sorg\n");
- fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n");
- fprintf(stderr, "Usage: qtrdesktop [options] server\n");
- fprintf(stderr, " -g WxH: desktop geometry\n");
- fprintf(stderr, " -4: use RDP version 4\n");
- fprintf(stderr, " -5: use RDP version 5 (default)\n");
- fprintf(stderr, " -t 3389: tcp port)\n");
- fprintf(stderr, " -a 8|16|24: connection colour depth\n");
- fprintf(stderr, " -T title: window title\n");
- fprintf(stderr, " -P: use persistent bitmap caching\n");
- fprintf(stderr, " -0: attach to console\n");
- fprintf(stderr, " -z: enable rdp compression\n");
- fprintf(stderr, " -r sound: enable sound\n");
- fprintf(stderr, "\n");
-}
-
-/*****************************************************************************/
-/* produce a hex dump */
-void hexdump(uint8 * p, uint32 len)
-{
- uint8 * line = p;
- int i, thisline;
- uint32 offset = 0;
-
- while (offset < len)
- {
- printf("%04x ", offset);
- thisline = len - offset;
- if (thisline > 16)
- {
- thisline = 16;
- }
- for (i = 0; i < thisline; i++)
- {
- printf("%02x ", line[i]);
- }
- for (; i < 16; i++)
- {
- printf(" ");
- }
- for (i = 0; i < thisline; i++)
- {
- printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.');
- }
- printf("\n");
- offset += thisline;
- line += thisline;
- }
-}
-
-/*****************************************************************************/
-int rd_pstcache_mkdir(void)
-{
- char * home;
- char bmpcache_dir[256];
-
- home = getenv("HOME");
- if (home == NULL)
- {
- return False;
- }
- sprintf(bmpcache_dir, "%s/%s", home, ".rdesktop");
- if ((mkdir(bmpcache_dir, S_IRWXU) == -1) && errno != EEXIST)
- {
- perror(bmpcache_dir);
- return False;
- }
- sprintf(bmpcache_dir, "%s/%s", home, ".rdesktop/cache");
- if ((mkdir(bmpcache_dir, S_IRWXU) == -1) && errno != EEXIST)
- {
- perror(bmpcache_dir);
- return False;
- }
- return True;
-}
-
-/*****************************************************************************/
-int rd_open_file(char * filename)
-{
- char * home;
- char fn[256];
- int fd;
-
- home = getenv("HOME");
- if (home == NULL)
- {
- return -1;
- }
- sprintf(fn, "%s/.rdesktop/%s", home, filename);
- fd = open(fn, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
- if (fd == -1)
- {
- perror(fn);
- }
- return fd;
-}
-
-/*****************************************************************************/
-void rd_close_file(int fd)
-{
- close(fd);
-}
-
-/*****************************************************************************/
-int rd_read_file(int fd, void * ptr, int len)
-{
- return read(fd, ptr, len);
-}
-
-/*****************************************************************************/
-int rd_write_file(int fd, void * ptr, int len)
-{
- return write(fd, ptr, len);
-}
-
-/*****************************************************************************/
-int rd_lseek_file(int fd, int offset)
-{
- return lseek(fd, offset, SEEK_SET);
-}
-
-/*****************************************************************************/
-int rd_lock_file(int fd, int start, int len)
-{
- struct flock lock;
-
- lock.l_type = F_WRLCK;
- lock.l_whence = SEEK_SET;
- lock.l_start = start;
- lock.l_len = len;
- if (fcntl(fd, F_SETLK, &lock) == -1)
- {
- return False;
- }
- return True;
-}
-
-/*****************************************************************************/
-void get_username_and_hostname(void)
-{
- char fullhostname[64];
- char * p;
- struct passwd * pw;
-
- STRNCPY(g_username, "unknown", sizeof(g_username));
- STRNCPY(g_hostname, "unknown", sizeof(g_hostname));
- pw = getpwuid(getuid());
- if (pw != NULL && pw->pw_name != NULL)
- {
- STRNCPY(g_username, pw->pw_name, sizeof(g_username));
- }
- if (gethostname(fullhostname, sizeof(fullhostname)) != -1)
- {
- p = strchr(fullhostname, '.');
- if (p != NULL)
- {
- *p = 0;
- }
- STRNCPY(g_hostname, fullhostname, sizeof(g_hostname));
- }
-}
-
-/*****************************************************************************/
-int parse_parameters(int in_argc, char ** in_argv)
-{
- int i;
- char * p;
-
- if (in_argc <= 1)
- {
- out_params();
- return 0;
- }
- g_argc = in_argc;
- g_argv = in_argv;
- for (i = 1; i < in_argc; i++)
- {
- strcpy(g_servername, in_argv[i]);
- if (strcmp(in_argv[i], "-g") == 0)
- {
- g_width = strtol(in_argv[i + 1], &p, 10);
- if (g_width <= 0)
- {
- error("invalid geometry\n");
- return 0;
- }
- if (*p == 'x')
- {
- g_height = strtol(p + 1, NULL, 10);
- }
- if (g_height <= 0)
- {
- error("invalid geometry\n");
- return 0;
- }
- g_width = (g_width + 3) & ~3;
- }
- else if (strcmp(in_argv[i], "-T") == 0)
- {
- strcpy(g_title, in_argv[i + 1]);
- }
- else if (strcmp(in_argv[i], "-4") == 0)
- {
- g_use_rdp5 = 0;
- }
- else if (strcmp(in_argv[i], "-5") == 0)
- {
- g_use_rdp5 = 1;
- }
- else if (strcmp(in_argv[i], "-a") == 0)
- {
- g_server_depth = strtol(in_argv[i + 1], &p, 10);
- if (g_server_depth != 8 && g_server_depth != 15 &&
- g_server_depth != 16 && g_server_depth != 24)
- {
- error("invalid bpp\n");
- return 0;
- }
- }
- else if (strcmp(in_argv[i], "-t") == 0)
- {
- g_tcp_port_rdp = strtol(in_argv[i + 1], &p, 10);
- }
- else if (strcmp(in_argv[i], "-P") == 0)
- {
- g_bitmap_cache_persist_enable = 1;
- }
- else if (strcmp(in_argv[i], "-0") == 0)
- {
- g_console_session = 1;
- }
- else if (strcmp(in_argv[i], "-z") == 0)
- {
- g_flags |= (RDP_LOGON_COMPRESSION | RDP_LOGON_COMPRESSION2);
- }
- else if (strcmp(in_argv[i], "-r") == 0)
- {
- if (strcmp(in_argv[i + 1], "sound") == 0)
- {
-#ifdef WITH_RDPSND
- g_rdpsnd = 1;
-#endif
- }
- }
- }
- return 1;
-}
-
-/*****************************************************************************/
-int main(int in_argc, char** in_argv)
-{
- get_username_and_hostname();
- if (!parse_parameters(in_argc, in_argv))
- {
- return 0;
- }
- if (!ui_init())
- {
- return 1;
- }
- if (!ui_create_window())
- {
- return 1;
- }
- ui_main_loop();
- ui_destroy_window();
- ui_deinit();
- return 0;
-}
diff --git a/uiports/qtwin.h b/uiports/qtwin.h
deleted file mode 100644
index fa87187..0000000
--- a/uiports/qtwin.h
+++ /dev/null
@@ -1,32 +0,0 @@
-
-#include
-#include
-
-class QMyScrollView: public QScrollView
-{
- Q_OBJECT
- public:
- void keyPressEvent(QKeyEvent*);
- void keyReleaseEvent(QKeyEvent*);
-};
-
-class QMyMainWindow: public QWidget
-{
- Q_OBJECT
- public:
- QMyMainWindow();
- ~QMyMainWindow();
- void paintEvent(QPaintEvent*);
- void mouseMoveEvent(QMouseEvent*);
- void mousePressEvent(QMouseEvent*);
- void mouseReleaseEvent(QMouseEvent*);
- void wheelEvent(QWheelEvent*);
- void keyPressEvent(QKeyEvent*);
- void keyReleaseEvent(QKeyEvent*);
- void closeEvent(QCloseEvent*);
- bool event(QEvent*);
- public slots:
- void dataReceived();
- void soundSend();
-};
-
diff --git a/uiports/readme.txt b/uiports/readme.txt
deleted file mode 100755
index 3d24824..0000000
--- a/uiports/readme.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-This directory contains information on uiports.
-uiports are different graphics libraries using the same core
-rdesktop files.
-
-This directory is provided to include information and examples
-on how to do a new uiport. Not all ports of rdesktop can
-be included.
-
-see xxxreadme.txt for info on a blank empty uiport
-
-see qtreadme.txt for info on the Qt/X11 uiport
-
-see qtereadme.txt for info on the Qt embedded uiport
-
-see svgareadme.txt for info on the svga uiport
-
-see nanoxreadme.txt for info on the nanox uiport
diff --git a/uiports/svgareadme.txt b/uiports/svgareadme.txt
deleted file mode 100644
index 7106b82..0000000
--- a/uiports/svgareadme.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-This is the svga ui port
-send any fixes or improvements to me Jay Sorg(j@american-data.com)
-svgalib should be installed
-tested with versions 1.4.3, 1.9.x
-
-thanks to
- Donald Gordon - original work
- Peter Nikolow - misc fixes
-
-run make -f makefile_svga to compile it
-
-svgareadme.txt - notes, this file
-makefile_svga - makefile
-svgawin.c - ui lib
-
-svgalib has some support for acceleration but most drivers
-do not support it. I hope they fix this.
-The ones that do are Cirus Logic and ATI Mach 32 cards.
-If running on really slow hardware(486), use one of these cards,
-it improves performance a lot.
-
-run ./svgardesktop with no parameters to see a list of
-command line options
-
-You will need to modify the libvga.config file most likely.
-Its in /etc/vga.
-Here is what mine looks like.
-BOF
- mouse imps2
- mouse_fake_kbd_event 112 113
- mouse_accel_mult 1.5
- mouse_accel_type normal
- HorizSync 31.5 56.0
- VertRefresh 50 90
- nosigint
-EOF
-The mouse_fake_kbd_event line makes the wheel mouse work.
-
-Jay
diff --git a/uiports/svgawin.c b/uiports/svgawin.c
deleted file mode 100644
index 506a181..0000000
--- a/uiports/svgawin.c
+++ /dev/null
@@ -1,1946 +0,0 @@
-/* -*- c-basic-offset: 8 -*-
- rdesktop: A Remote Desktop Protocol client.
- User interface services - SVGA lib
- Copyright (C) Jay Sorg 2004-2007
-
- 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 3 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, see .
-*/
-
-#include "../rdesktop.h"
-
-#include
-#include
-#include
-#include
-
-#include // gethostname
-#include // getpwuid
-#include // va_list va_start va_end
-
-#include
-#include
-#include
-#include
-
-extern int g_tcp_port_rdp;
-int g_use_rdp5 = 0;
-char g_hostname[16] = "";
-char g_username[64] = "";
-int g_height = 600;
-int g_width = 800;
-int g_server_depth = 8;
-int g_encryption = 1;
-int g_desktop_save = 1;
-int g_polygon_ellipse_orders = 0;
-int g_bitmap_cache = 1;
-int g_bitmap_cache_persist_enable = False;
-int g_bitmap_cache_precache = True;
-int g_rdp5_performanceflags = 0;
-int g_console_session = 0;
-int g_keylayout = 0x409; /* Defaults to US keyboard layout */
-int g_keyboard_type = 0x4; /* Defaults to US keyboard layout */
-int g_keyboard_subtype = 0x0; /* Defaults to US keyboard layout */
-int g_keyboard_functionkeys = 0xc; /* Defaults to US keyboard layout */
-RD_BOOL g_numlock_sync = False;
-
-/* hack globals */
-int g_argc = 0;
-char** g_argv = 0;
-int UpAndRunning = 0;
-int g_sock = 0;
-int deactivated = 0;
-uint32 ext_disc_reason = 0;
-char g_servername[128] = "";
-static uint32* colmap = 0;
-static uint8* desk_save = 0;
-static int g_server_Bpp = 1;
-
-/* Keyboard LEDS */
-static int numlock;
-static int capslock;
-static int scrolllock;
-
-// this is non null if vgalib has non accel functions available
-// reading from video memory is sooo slow
-static uint8* sdata = 0;
-static int g_save_mem = 0; // for video memory use e.g. sdata == 0
-
-// video acceleration
-static int use_accel = 1;
-static int has_fill_box = 0;
-static int has_screen_copy = 0;
-static int has_put_image = 0;
-
-// clip
-int clip_startx;
-int clip_starty;
-int clip_endx;
-int clip_endy;
-
-// mouse
-uint8 mouse_under[32 * 32 * 4]; // save area under mouse
-int mousex = 0;
-int mousey = 0;
-int mouseb = 0;
-
-// mouse info
-typedef struct
-{
- uint8 andmask[32 * 32];
- uint8 xormask[32 * 32];
- int x;
- int y;
- int w;
- int h;
-} tcursor;
-
-// mouse global
-static tcursor mcursor;
-
-static int g_draw_mouse = 1;
-
-/* Session Directory redirection */
-RD_BOOL g_redirect = False;
-char g_redirect_server[64];
-char g_redirect_domain[16];
-char g_redirect_password[64];
-char g_redirect_username[64];
-char g_redirect_cookie[128];
-uint32 g_redirect_flags = 0;
-
-// bitmap
-typedef struct
-{
- int width;
- int height;
- uint8* data;
- uint8 Bpp;
-} bitmap;
-
-typedef struct
-{
- int x;
- int y;
- int cx;
- int cy;
- void* prev;
- void* next;
-} myrect;
-
-myrect* head_rect = 0;
-
-//*****************************************************************************
-// Keyboard stuff - PeterS
-static void setled(int mask, int state)
-{
- int fd;
- long int leds;
-
- if (( fd=open("/dev/console", O_NOCTTY)) != -1 )
- {
- if (ioctl (fd, KDGETLED, &leds) != -1)
- {
- leds &= 7;
- if (state)
- leds |= mask;
- else
- leds &= ~mask;
- ioctl (fd, KDSETLED, leds);
- }
- close(fd);
- }
-}
-
-
-//*****************************************************************************
-// do a raster op
-int rop(int rop, int src, int dst)
-{
- switch (rop)
- {
- case 0x0: return 0;
- case 0x1: return ~(src | dst);
- case 0x2: return (~src) & dst;
- case 0x3: return ~src;
- case 0x4: return src & (~dst);
- case 0x5: return ~(dst);
- case 0x6: return src ^ dst;
- case 0x7: return ~(src & dst);
- case 0x8: return src & dst;
- case 0x9: return ~(src) ^ dst;
- case 0xa: return dst;
- case 0xb: return (~src) | dst;
- case 0xc: return src;
- case 0xd: return src | (~dst);
- case 0xe: return src | dst;
- case 0xf: return ~0;
- }
- return dst;
-}
-
-//*****************************************************************************
-// get a screen pixel
-int get_pixel(int x, int y)
-{
- if (x >= 0 && x < g_width && y >= 0 && y < g_height)
- {
- if (sdata != 0)
- {
- if (g_server_Bpp == 1)
- return sdata[y * g_width + x];
- else if (g_server_Bpp == 2)
- return ((uint16*)sdata)[y * g_width + x];
- else
- return 0;
- }
- else
- return vga_getpixel(x, y);
- }
- else
- return 0;
-}
-
-//*****************************************************************************
-// set a screen pixel
-void set_pixel(int x, int y, int pixel, int op)
-{
- if (x >= clip_startx && x < clip_endx && y >= clip_starty && y < clip_endy)
- {
- if (x >= 0 && x < g_width && y >= 0 && y < g_height)
- {
- if (op == 0x0)
- pixel = 0;
- else if (op == 0xf)
- pixel = -1;
- else if (op != 0xc)
- pixel = rop(op, pixel, get_pixel(x, y));
- if (sdata != 0)
- {
- if (g_server_Bpp == 1)
- sdata[y * g_width + x] = pixel;
- else if (g_server_Bpp == 2)
- ((uint16*)sdata)[y * g_width + x] = pixel;
- }
- else
- {
- vga_setcolor(pixel);
- vga_drawpixel(x, y);
- }
- }
- }
-}
-
-//*****************************************************************************
-// get a pixel from a bitmap
-int get_pixel2(int x, int y, uint8* data, int width, int bpp)
-{
- if (bpp == 8)
- return data[y * width + x];
- else if (bpp == 16)
- return ((uint16*)data)[y * width + x];
- else
- return 0;
-}
-
-//*****************************************************************************
-// set a pixel in a bitmap
-void set_pixel2(int x, int y, int pixel, uint8* data, int width, int bpp)
-{
- if (bpp == 8)
- data[y * width + x] = pixel;
- else if (bpp == 16)
- ((uint16*)data)[y * width + x] = pixel;
-}
-
-//*****************************************************************************
-// get a pointer into a bitmap
-uint8* get_ptr(int x, int y, uint8* data, int width, int bpp)
-{
- if (bpp == 8)
- return data + (y * width + x);
- else if (bpp == 16)
- return data + (y * width + x) * 2;
- else
- return 0;
-}
-
-//*****************************************************************************
-// check if a certain pixel is set in a bitmap
-RD_BOOL is_pixel_on(uint8* data, int x, int y, int width, int bpp)
-{
- int start;
- int shift;
-
- if (bpp == 1)
- {
- width = (width + 7) / 8;
- start = (y * width) + x / 8;
- shift = x % 8;
- return (data[start] & (0x80 >> shift)) != 0;
- }
- else if (bpp == 8)
- {
- return data[y * width + x] != 0;
- }
- else if (bpp == 24)
- {
- return data[(y * 3) * width + (x * 3)] != 0 &&
- data[(y * 3) * width + (x * 3) + 1] != 0 &&
- data[(y * 3) * width + (x * 3) + 2] != 0;
- }
- else
- return False;
-}
-
-//*****************************************************************************
-void set_pixel_on(uint8* data, int x, int y, int width, int bpp, int pixel)
-{
- if (bpp == 8)
- {
- data[y * width + x] = pixel;
- }
-}
-
-/*****************************************************************************/
-int warp_coords(int* x, int* y, int* cx, int* cy, int* srcx, int* srcy)
-{
- int dx;
- int dy;
-// int lx = *x, ly = *y, lcx = *cx, lcy = *cy;
-
- if (clip_startx > *x)
- dx = clip_startx - *x;
- else
- dx = 0;
- if (clip_starty > *y)
- dy = clip_starty - *y;
- else
- dy = 0;
- if (*x + *cx > clip_endx)
- *cx = (*cx - ((*x + *cx) - clip_endx)) /*+ 1*/;
- if (*y + *cy > clip_endy)
- *cy = (*cy - ((*y + *cy) - clip_endy)) /*+ 1*/;
- *cx = *cx - dx;
- *cy = *cy - dy;
- if (*cx <= 0)
- return False;
- if (*cy <= 0)
- return False;
- *x = *x + dx;
- *y = *y + dy;
- if (srcx != NULL)
- *srcx = *srcx + dx;
- if (srcy != NULL)
- *srcy = *srcy + dy;
-
-// if (*x != lx || *y != ly || *cx != lcx || *cy != lcy)
-// printf("%d %d %d %d to %d %d %d %d\n", lx, ly, lcx, lcy, *x, *y, *cx, *cy);
-
- return True;
-}
-
-//*****************************************************************************
-void copy_mem(uint8* d, uint8* s, int n)
-{
- while (n & (~7))
- {
- *(d++) = *(s++);
- *(d++) = *(s++);
- *(d++) = *(s++);
- *(d++) = *(s++);
- *(d++) = *(s++);
- *(d++) = *(s++);
- *(d++) = *(s++);
- *(d++) = *(s++);
- n = n - 8;
- }
- while (n > 0)
- {
- *(d++) = *(s++);
- n--;
- }
-}
-
-//*****************************************************************************
-void copy_memb(uint8* d, uint8* s, int n)
-{
- d = (d + n) - 1;
- s = (s + n) - 1;
- while (n & (~7))
- {
- *(d--) = *(s--);
- *(d--) = *(s--);
- *(d--) = *(s--);
- *(d--) = *(s--);
- *(d--) = *(s--);
- *(d--) = *(s--);
- *(d--) = *(s--);
- *(d--) = *(s--);
- n = n - 8;
- }
- while (n > 0)
- {
- *(d--) = *(s--);
- n--;
- }
-}
-
-//*****************************************************************************
-// all in pixel except line_size is in bytes
-void accel_draw_box(int x, int y, int cx, int cy, uint8* data, int line_size)
-{
- int i;
- uint8* s;
- uint8* d;
-
- if (sdata != 0)
- {
- s = data;
- d = get_ptr(x, y, sdata, g_width, g_server_depth);
- for (i = 0; i < cy; i++)
- {
- copy_mem(d, s, cx * g_server_Bpp);
- s = s + line_size;
- d = d + g_width * g_server_Bpp;
- }
- }
- else if (has_put_image && line_size == cx * g_server_Bpp)
- {
- vga_accel(ACCEL_PUTIMAGE, x, y, cx, cy, data);
- }
- else
- {
- s = data;
- for (i = 0; i < cy; i++)
- {
- vga_drawscansegment(s, x, y + i, cx * g_server_Bpp);
- s = s + line_size;
- }
- }
-}
-
-//*****************************************************************************
-void accel_fill_rect(int x, int y, int cx, int cy, int color)
-{
- int i;
- uint8* temp;
- uint8* d;
-
- if (sdata != 0)
- {
- temp = xmalloc(cx * g_server_Bpp);
- if (g_server_Bpp == 1)
- for (i = 0; i < cx; i++)
- temp[i] = color;
- else if (g_server_Bpp == 2)
- for (i = 0; i < cx; i++)
- ((uint16*)temp)[i] = color;
- d = get_ptr(x, y, sdata, g_width, g_server_depth);
- for (i = 0; i < cy; i++)
- {
- copy_mem(d, temp, cx * g_server_Bpp);
- d = d + g_width * g_server_Bpp;
- }
- xfree(temp);
- }
- else if (has_fill_box)
- {
- vga_accel(ACCEL_SETFGCOLOR, color);
- vga_accel(ACCEL_FILLBOX, x, y, cx, cy);
- }
- else
- {
- temp = xmalloc(cx * g_server_Bpp);
- if (g_server_Bpp == 1)
- for (i = 0; i < cx; i++)
- temp[i] = color;
- else if (g_server_Bpp == 2)
- for (i = 0; i < cx; i++)
- ((uint16*)temp)[i] = color;
- for (i = 0; i < cy; i++)
- vga_drawscansegment(temp, x, y + i, cx * g_server_Bpp);
- xfree(temp);
- }
-}
-
-//*****************************************************************************
-void accel_screen_copy(int x, int y, int cx, int cy, int srcx, int srcy)
-{
- uint8* temp;
- uint8* s;
- uint8* d;
- int i;
-
- if (sdata != 0)
- {
- if (srcy < y)
- { // bottom to top
- s = get_ptr(srcx, (srcy + cy) - 1, sdata, g_width, g_server_depth);
- d = get_ptr(x, (y + cy) - 1, sdata, g_width, g_server_depth);
- for (i = 0; i < cy; i++) // copy down
- {
- copy_mem(d, s, cx * g_server_Bpp);
- s = s - g_width * g_server_Bpp;
- d = d - g_width * g_server_Bpp;
- }
- }
- else if (srcy > y || srcx > x) // copy up or left
- { // top to bottom
- s = get_ptr(srcx, srcy, sdata, g_width, g_server_depth);
- d = get_ptr(x, y, sdata, g_width, g_server_depth);
- for (i = 0; i < cy; i++)
- {
- copy_mem(d, s, cx * g_server_Bpp);
- s = s + g_width * g_server_Bpp;
- d = d + g_width * g_server_Bpp;
- }
- }
- else // copy straight right
- {
- s = get_ptr(srcx, srcy, sdata, g_width, g_server_depth);
- d = get_ptr(x, y, sdata, g_width, g_server_depth);
- for (i = 0; i < cy; i++)
- {
- copy_memb(d, s, cx * g_server_Bpp);
- s = s + g_width * g_server_Bpp;
- d = d + g_width * g_server_Bpp;
- }
- }
- }
- else if (has_screen_copy)
- {
- vga_accel(ACCEL_SCREENCOPY, srcx, srcy, x, y, cx, cy);
- }
- else
- {
- // slow
- temp = (uint8*)xmalloc(cx * cy * g_server_Bpp);
- for (i = 0; i < cy; i++)
- vga_getscansegment(get_ptr(0, i, temp, cx, g_server_depth), srcx, srcy + i, cx * g_server_Bpp);
- for (i = 0; i < cy; i++)
- vga_drawscansegment(get_ptr(0, i, temp, cx, g_server_depth), x, y + i, cx * g_server_Bpp);
- xfree(temp);
- }
-}
-
-//*****************************************************************************
-// return bool
-int contains_mouse(int x, int y, int cx, int cy)
-{
- if (mousex + 32 >= x &&
- mousey + 32 >= y &&
- mousex <= x + cx &&
- mousey <= y + cy)
- return 1;
- else
- return 0;
-}
-
-//*****************************************************************************
-void fill_rect(int x, int y, int cx, int cy, int colour, int opcode)
-{
- int i;
- int j;
-
- if (warp_coords(&x, &y, &cx, &cy, NULL, NULL))
- {
- if (opcode == 0xc)
- accel_fill_rect(x, y, cx, cy, colour);
- else if (opcode == 0xf)
- accel_fill_rect(x, y, cx, cy, -1);
- else if (opcode == 0x0)
- accel_fill_rect(x, y, cx, cy, 0);
- else
- {
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- set_pixel(x + j, y + i, colour, opcode);
- }
- }
-}
-
-//*****************************************************************************
-void get_rect(int x, int y, int cx, int cy, uint8* p)
-{
- int i;
-
- if (x < 0)
- {
- cx = cx + x;
- x = 0;
- }
- if (y < 0)
- {
- cy = cy + y;
- y = 0;
- }
- if (sdata != 0)
- {
- for (i = 0; i < cy; i++)
- {
- copy_mem(p, get_ptr(x, y + i, sdata, g_width, g_server_depth), cx * g_server_Bpp);
- p = p + cx * g_server_Bpp;
- }
- }
- else
- {
- for (i = 0; i < cy; i++)
- {
- vga_getscansegment(p, x, y + i, cx * g_server_Bpp);
- p = p + cx * g_server_Bpp;
- }
- }
-}
-
-/*****************************************************************************/
-// return true if r1 is contained by r2
-int is_contained_by(myrect* r1, myrect* r2)
-{
- if (r1->x >= r2->x &&
- r1->y >= r2->y &&
- r1->x + r1->cx <= r2->x + r2->cx &&
- r1->y + r1->cy <= r2->y + r2->cy)
- return 1;
- else
- return 0;
-}
-
-/*****************************************************************************/
-void draw_cursor_under(int ox, int oy)
-{
- int i;
- int j;
- int k;
- uint8* ptr;
- int len;
-
- if (ox < 0)
- k = -ox;
- else
- k = 0;
- j = g_width - ox;
- if (j > 32)
- j = 32;
- if (j > 0)
- {
- for (i = 0; i < 32; i++)
- {
- ptr = get_ptr(k, i, mouse_under, 32, g_server_depth);
- len = (j - k) * g_server_Bpp;
- if (ox + k >= 0 && oy + i >= 0 && ox + k < g_width && oy + i < g_height)
- vga_drawscansegment(ptr, ox + k, oy + i, len);
- }
- }
- g_draw_mouse = 1;
-}
-
-/*****************************************************************************/
-void draw_cursor(void)
-{
- int i;
- int j;
- int k;
- int pixel;
- uint8 mouse_a[32 * 32 * 4];
- uint8* ptr;
- int len;
-
- if (!g_draw_mouse)
- return;
- memset(mouse_under, 0, sizeof(mouse_under));
- for (i = 0; i < 32; i++)
- {
- for (j = 0; j < 32; j++)
- {
- pixel = get_pixel(mousex + j, mousey + i);
- set_pixel2(j, i, pixel, mouse_under, 32, g_server_depth);
- if (mcursor.andmask[i * 32 + j] == 0)
- k = 0;
- else
- k = ~0;
- pixel = rop(0x8, k, pixel);
- if (mcursor.xormask[i * 32 + j] == 0)
- k = 0;
- else
- k = ~0;
- pixel = rop(0x6, k, pixel);
- set_pixel2(j, i, pixel, mouse_a, 32, g_server_depth);
- }
- }
- if (mousex < 0)
- k = -mousex;
- else
- k = 0;
- j = g_width - mousex;
- if (j > 32)
- j = 32;
- if (j > 0)
- {
- for (i = mousey; i < mousey + 32; i++)
- if (i < g_height && i >= 0)
- {
- ptr = get_ptr(k, i - mousey, mouse_a, 32, g_server_depth);
- len = (j - k) * g_server_Bpp;
- vga_drawscansegment(ptr, mousex + k, i, len);
- }
- }
- g_draw_mouse = 0;
-}
-
-/*****************************************************************************/
-// add a rect to cache
-void cache_rect(int x, int y, int cx, int cy, int do_warp)
-{
- myrect* rect;
- myrect* walk_rect;
-
- if (sdata == 0)
- {
- draw_cursor();
- return;
- }
- if (do_warp)
- if (!warp_coords(&x, &y, &cx, &cy, NULL, NULL))
- return;
- rect = (myrect*)xmalloc(sizeof(myrect));
- rect->x = x;
- rect->y = y;
- rect->cx = cx;
- rect->cy = cy;
- rect->next = 0;
- rect->prev = 0;
- if (head_rect == 0)
- head_rect = rect;
- else
- {
- walk_rect = 0;
- do
- {
- if (walk_rect == 0)
- walk_rect = head_rect;
- else
- walk_rect = walk_rect->next;
- if (is_contained_by(rect, walk_rect))
- {
- xfree(rect);
- return;
- }
- }
- while (walk_rect->next != 0);
- walk_rect->next = rect;
- rect->prev = walk_rect;
- }
-}
-
-//*****************************************************************************
-void draw_cache_rects(void)
-{
- int i;
- myrect* rect;
- myrect* rect1;
- uint8* p;
-
- // draw all the rects
- rect = head_rect;
- while (rect != 0)
- {
- p = get_ptr(rect->x, rect->y, sdata, g_width, g_server_depth);
- for (i = 0; i < rect->cy; i++)
- {
- vga_drawscansegment(p, rect->x, rect->y + i, rect->cx * g_server_Bpp);
- p = p + g_width * g_server_Bpp;
- }
- rect1 = rect;
- rect = rect->next;
- xfree(rect1);
- }
- head_rect = 0;
-}
-
-/*****************************************************************************/
-void key_event(int scancode, int pressed)
-{
- int rdpkey;
- int ext;
-
- if (!UpAndRunning)
- return;
- rdpkey = scancode;
- ext = 0;
-
- // Keyboard LEDS
- if ((scancode == SCANCODE_CAPSLOCK) && pressed)
- {
- capslock = !capslock;
- setled(LED_CAP, capslock);
- }
- if ((scancode == SCANCODE_SCROLLLOCK) && pressed)
- {
- scrolllock = !scrolllock;
- setled(LED_SCR, scrolllock);
- }
-
- if ((scancode == SCANCODE_NUMLOCK) && pressed)
- {
- numlock = !numlock;
- setled(LED_NUM, numlock);
- }
-
- switch (scancode)
- {
- case SCANCODE_CURSORBLOCKUP: rdpkey = 0xc8; ext = KBD_FLAG_EXT; break; // up arrow
- case SCANCODE_CURSORBLOCKDOWN: rdpkey = 0xd0; ext = KBD_FLAG_EXT; break; // down arrow
- case SCANCODE_CURSORBLOCKRIGHT: rdpkey = 0xcd; ext = KBD_FLAG_EXT; break; // right arrow
- case SCANCODE_CURSORBLOCKLEFT: rdpkey = 0xcb; ext = KBD_FLAG_EXT; break; // left arrow
- case SCANCODE_PAGEDOWN: rdpkey = 0xd1; ext = KBD_FLAG_EXT; break; // page down
- case SCANCODE_PAGEUP: rdpkey = 0xc9; ext = KBD_FLAG_EXT; break; // page up
- case SCANCODE_HOME: rdpkey = 0xc7; ext = KBD_FLAG_EXT; break; // home
- case SCANCODE_END: rdpkey = 0xcf; ext = KBD_FLAG_EXT; break; // end
- case SCANCODE_INSERT: rdpkey = 0xd2; ext = KBD_FLAG_EXT; break; // insert
- case SCANCODE_REMOVE: rdpkey = 0xd3; ext = KBD_FLAG_EXT; break; // delete
- case SCANCODE_KEYPADDIVIDE: rdpkey = 0x35; break; // /
- case SCANCODE_KEYPADENTER: rdpkey = 0x1c; break; // enter
- case SCANCODE_RIGHTCONTROL: rdpkey = 0x1d; break; // right ctrl
- case SCANCODE_RIGHTALT: rdpkey = 0x38; break; // right alt
- case SCANCODE_LEFTWIN: rdpkey = 0x5b; ext = KBD_FLAG_EXT; break; // left win
- case SCANCODE_RIGHTWIN: rdpkey = 0x5c; ext = KBD_FLAG_EXT; break; // right win
- case 127: rdpkey = 0x5d; ext = KBD_FLAG_EXT; break; // menu key
- case SCANCODE_PRINTSCREEN: rdpkey = 0x37; ext = KBD_FLAG_EXT; break; // print screen
- case SCANCODE_BREAK: //rdpkey = 0; break; // break
- {
- if (pressed)
- {
- ext = KBD_FLAG_EXT;
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS | ext, 0x46, 0);
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS | ext, 0xc6, 0);
- }
- rdpkey = 0;
- }
- case SCANCODE_SCROLLLOCK: rdpkey = 0x46; break; // scroll lock
- case 112: // mouse down
- {
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON4,
- mouse_getx(), mouse_gety());
- return;
- }
- case 113: // mouse up
- {
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON5,
- mouse_getx(), mouse_gety());
- return;
- }
- }
-// printf("%d %d\n", scancode, pressed);
- if (pressed)
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS | ext, rdpkey, 0);
- else
- rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE | ext, rdpkey, 0);
-
-
-}
-
-/*****************************************************************************/
-int ui_init(void)
-{
- vga_init();
- memset(&mcursor, 0, sizeof(tcursor));
- desk_save = (uint8*)xmalloc(0x38400 * g_server_Bpp);
- return 1;
-}
-
-/*****************************************************************************/
-void ui_deinit(void)
-{
- xfree(desk_save);
-}
-
-/*****************************************************************************/
-int ui_create_window(void)
-{
- int vgamode;
- int i;
-
- vgamode = G800x600x256;
- if (g_width == 640 && g_height == 480)
- {
- if (g_server_Bpp == 1)
- vgamode = G640x480x256;
- else if (g_server_Bpp == 2)
- vgamode = G640x480x64K;
- }
- else if (g_width == 800 && g_height == 600)
- {
- if (g_server_Bpp == 1)
- vgamode = G800x600x256;
- else if (g_server_Bpp == 2)
- vgamode = G800x600x64K;
- }
- else if (g_width == 1024 && g_height == 768)
- {
- if (g_server_Bpp == 1)
- vgamode = G1024x768x256;
- else if (g_server_Bpp == 2)
- vgamode = G1024x768x64K;
- }
- else
- {
- error("Invalid width / height");
- return 0;
- }
- ui_reset_clip();
- if (!vga_hasmode(vgamode))
- {
- error("Graphics unavailable");
- return 0;
- }
- vga_setmousesupport(1);
- mouse_setposition(g_width / 2, g_height / 2);
- vga_setmode(vgamode);
- if (keyboard_init())
- {
- error("Keyboard unavailable");
- return 0;
- }
- keyboard_seteventhandler(key_event);
- if (use_accel)
- {
- i = vga_ext_set(VGA_EXT_AVAILABLE, VGA_AVAIL_ACCEL);
- if (i & ACCELFLAG_PUTIMAGE)
- has_put_image = 1;
- if (i & ACCELFLAG_SCREENCOPY)
- has_screen_copy = 1;
- if (i & ACCELFLAG_FILLBOX)
- has_fill_box = 1;
- printf("accel %d\n", i);
- }
- if (!has_screen_copy && !g_save_mem)
- sdata = xmalloc(g_width * g_height * g_server_Bpp);
- return 1;
-}
-
-/*****************************************************************************/
-void ui_destroy_window(void)
-{
- keyboard_close(); /* Don't forget this! */
- vga_setmode(TEXT);
- if (sdata != 0)
- xfree(sdata);
-}
-
-/*****************************************************************************/
-void process_mouse(void)
-{
- int ox = mousex;
- int oy = mousey;
- int ob = mouseb;
-
- if (!UpAndRunning)
- return;
- mousex = mouse_getx() - mcursor.x;
- mousey = mouse_gety() - mcursor.y;
- mouseb = mouse_getbutton();
-
- if (mouseb != ob) // button
- {
- // right button
- if (mouseb & 1)
- if (!(ob & 1))
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2,
- mousex + mcursor.x, mousey + mcursor.y);
- if (ob & 1)
- if (!(mouseb & 1))
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2,
- mousex + mcursor.x, mousey + mcursor.y);
- // middle button
- if (mouseb & 2)
- if (!(ob & 2))
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON3,
- mousex + mcursor.x, mousey + mcursor.y);
- if (ob & 2)
- if (!(mouseb & 2))
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON3,
- mousex + mcursor.x, mousey + mcursor.y);
- // left button
- if (mouseb & 4)
- if (!(ob & 4))
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1,
- mousex + mcursor.x, mousey + mcursor.y);
- if (ob & 4)
- if (!(mouseb & 4))
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1,
- mousex + mcursor.x, mousey + mcursor.y);
- }
- if (mousex != ox || mousey != oy) // movement
- {
- rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE,
- mousex + mcursor.x, mousey + mcursor.y);
- draw_cursor_under(ox, oy);
- draw_cursor();
- }
-}
-
-/*****************************************************************************/
-void process_keyboard(void)
-{
- if (!UpAndRunning)
- return;
-}
-
-/*****************************************************************************/
-RD_BOOL ui_main_loop(void)
-{
- int sel;
- fd_set rfds;
-
- if (!rdp_connect(g_servername, RDP_LOGON_NORMAL, "", "", "", ""))
- return False;
- UpAndRunning = 1;
- FD_ZERO(&rfds);
- FD_SET(g_sock, &rfds);
- sel = vga_waitevent(3, &rfds, NULL, NULL, NULL);
- while (sel >= 0)
- {
- if (sel & 1) /* mouse */
- {
- process_mouse();
- }
- else if (sel & 2) /* keyboard */
- {
- process_keyboard();
- }
- else
- {
- if (!rdp_loop(&deactivated, &ext_disc_reason))
- return True; /* ok */
- }
- FD_ZERO(&rfds);
- FD_SET(g_sock, &rfds);
- sel = vga_waitevent(3, &rfds, NULL, NULL, NULL);
- }
- return True;
-}
-
-/*****************************************************************************/
-void ui_bell(void)
-{
-}
-
-/*****************************************************************************/
-int ui_select(int in)
-{
- g_sock = in;
- return 1;
-}
-
-/*****************************************************************************/
-void* ui_create_glyph(int width, int height, uint8* data)
-{
- int i, j;
- uint8* glyph_data;
- bitmap* the_glyph;
-
- glyph_data = (uint8*)xmalloc(width * height);
- the_glyph = (bitmap*)xmalloc(sizeof(bitmap));
- the_glyph->width = width;
- the_glyph->height = height;
- the_glyph->data = glyph_data;
- memset(glyph_data, 0, width * height);
- for (i = 0; i < height; i++)
- for (j = 0; j < width; j++)
- if (is_pixel_on(data, j, i, width, 1))
- set_pixel_on(glyph_data, j, i, width, 8, 255);
- return the_glyph;
-}
-
-/*****************************************************************************/
-void ui_destroy_glyph(void* glyph)
-{
- bitmap* the_glyph;
-
- the_glyph = (bitmap*)glyph;
- if (the_glyph != NULL)
- {
- if (the_glyph->data != NULL)
- xfree(the_glyph->data);
- xfree(the_glyph);
- }
-}
-
-/*****************************************************************************/
-void ui_destroy_bitmap(void* bmp)
-{
- bitmap* b;
-
- b = (bitmap*)bmp;
- xfree(b->data);
- xfree(b);
-}
-
-/*****************************************************************************/
-void ui_reset_clip(void)
-{
- clip_startx = 0;
- clip_starty = 0;
- clip_endx = g_width;
- clip_endy = g_height;
-}
-
-/*****************************************************************************/
-void ui_set_clip(int x, int y, int cx, int cy)
-{
- clip_startx = x;
- clip_starty = y;
- clip_endx = x + cx;
- clip_endy = y + cy;
-}
-
-/*****************************************************************************/
-void* ui_create_colourmap(COLOURMAP * colours)
-{
- int i = 0;
- int n = colours->ncolours;
- COLOURENTRY* c = colours->colours;
- int* cmap = (int*)xmalloc(3 * 256 * sizeof (int));
- if (n > 256)
- n = 256;
- bzero(cmap, 256 * 3 * sizeof (int));
- for (i = 0; i < (3 * n); c++)
- {
- cmap[i++] = (c->red) >> 2;
- cmap[i++] = (c->green) >> 2;
- cmap[i++] = (c->blue) >> 2;
- }
- return cmap;
-}
-
-/*****************************************************************************/
-void ui_destroy_colourmap(RD_HCOLOURMAP map)
-{
- if (colmap == map)
- colmap = 0;
- xfree(map);
-}
-
-/*****************************************************************************/
-void ui_set_colourmap(void* map)
-{
- if (colmap != 0)
- xfree(colmap);
- vga_setpalvec(0, 256, (int*)map);
- colmap = map;
-}
-
-/*****************************************************************************/
-RD_HBITMAP ui_create_bitmap(int width, int height, uint8* data)
-{
- bitmap* b;
-
- b = (bitmap*)xmalloc(sizeof(bitmap));
- b->data = (uint8*)xmalloc(width * height * g_server_Bpp);
- b->width = width;
- b->height = height;
- b->Bpp = g_server_Bpp;
- copy_mem(b->data, data, width * height * g_server_Bpp);
- return (void*)b;
-}
-
-//*****************************************************************************
-void draw_glyph (int x, int y, RD_HGLYPH glyph, int fgcolour)
-{
- bitmap* the_glyph;
- int i, j;
-
- the_glyph = (bitmap*)glyph;
- if (the_glyph == NULL)
- return;
- for (i = 0; i < the_glyph->height; i++)
- for (j = 0; j < the_glyph->width; j++)
- if (is_pixel_on(the_glyph->data, j, i, the_glyph->width, 8))
- set_pixel(x + j, y + i, fgcolour, 0xc);
-}
-
-#define DO_GLYPH(ttext,idx) \
-{\
- glyph = cache_get_font (font, ttext[idx]);\
- if (!(flags & TEXT2_IMPLICIT_X))\
- {\
- xyoffset = ttext[++idx];\
- if ((xyoffset & 0x80))\
- {\
- if (flags & TEXT2_VERTICAL) \
- y += ttext[idx+1] | (ttext[idx+2] << 8);\
- else\
- x += ttext[idx+1] | (ttext[idx+2] << 8);\
- idx += 2;\
- }\
- else\
- {\
- if (flags & TEXT2_VERTICAL) \
- y += xyoffset;\
- else\
- x += xyoffset;\
- }\
- }\
- if (glyph != NULL)\
- {\
- draw_glyph (x + glyph->offset, y + glyph->baseline, glyph->pixmap, fgcolour);\
- if (flags & TEXT2_IMPLICIT_X)\
- x += glyph->width;\
- }\
-}
-
-/*****************************************************************************/
-void ui_draw_text(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, BRUSH * brush,
- int bgcolour, int fgcolour, uint8* text, uint8 length)
-{
- int i;
- int j;
- int xyoffset;
- DATABLOB* entry;
- FONTGLYPH* glyph;
-
- if (boxcx > 1)
- {
- if (contains_mouse(boxx, boxy, boxcx, boxcy))
- draw_cursor_under(mousex, mousey);
- fill_rect(boxx, boxy, boxcx, boxcy, bgcolour, 0xc);
- }
- else
- {
- if (contains_mouse(clipx, clipy, clipcx, clipcy))
- draw_cursor_under(mousex, mousey);
- if (mixmode == MIX_OPAQUE)
- fill_rect(clipx, clipy, clipcx, clipcy, bgcolour, 0xc);
- }
-
- /* Paint text, character by character */
- for (i = 0; i < length;)
- {
- switch (text[i])
- {
- case 0xff:
- if (i + 2 < length)
- cache_put_text(text[i + 1], text, text[i + 2]);
- else
- {
- error("this shouldn't be happening\n");
- exit(1);
- }
- /* this will move pointer from start to first character after FF command */
- length -= i + 3;
- text = &(text[i + 3]);
- i = 0;
- break;
-
- case 0xfe:
- entry = cache_get_text(text[i + 1]);
- if (entry != NULL)
- {
- if ((((uint8 *) (entry->data))[1] == 0) && (!(flags & TEXT2_IMPLICIT_X)))
- {
- if (flags & TEXT2_VERTICAL)
- y += text[i + 2];
- else
- x += text[i + 2];
- }
- for (j = 0; j < entry->size; j++)
- DO_GLYPH(((uint8 *) (entry->data)), j);
- }
- if (i + 2 < length)
- i += 3;
- else
- i += 2;
- length -= i;
- /* this will move pointer from start to first character after FE command */
- text = &(text[i]);
- i = 0;
- break;
-
- default:
- DO_GLYPH(text, i);
- i++;
- break;
- }
- }
- if (boxcx > 1)
- cache_rect(boxx, boxy, boxcx, boxcy, True);
- else
- cache_rect(clipx, clipy, clipcx, clipcy, True);
-}
-
-//*****************************************************************************
-// Bresenham's line drawing algorithm
-void ui_line(uint8 opcode, int startx, int starty, int endx,
- int endy, PEN* pen)
-{
- int dx;
- int dy;
- int incx;
- int incy;
- int dpr;
- int dpru;
- int p;
- int left;
- int top;
- int right;
- int bottom;
-
- if (startx > endx)
- {
- dx = startx - endx;
- incx = -1;
- left = endx;
- right = startx;
- }
- else
- {
- dx = endx - startx;
- incx = 1;
- left = startx;
- right = endx;
- }
- if (starty > endy)
- {
- dy = starty - endy;
- incy = -1;
- top = endy;
- bottom = starty;
- }
- else
- {
- dy = endy - starty;
- incy = 1;
- top = starty;
- bottom = endy;
- }
- if (contains_mouse(left, top, (right - left) + 1, (bottom - top) + 1))
- draw_cursor_under(mousex, mousey);
- if (dx >= dy)
- {
- dpr = dy << 1;
- dpru = dpr - (dx << 1);
- p = dpr - dx;
- for (; dx >= 0; dx--)
- {
- set_pixel(startx, starty, pen->colour, opcode);
- if (p > 0)
- {
- startx += incx;
- starty += incy;
- p += dpru;
- }
- else
- {
- startx += incx;
- p += dpr;
- }
- }
- }
- else
- {
- dpr = dx << 1;
- dpru = dpr - (dy << 1);
- p = dpr - dy;
- for (; dy >= 0; dy--)
- {
- set_pixel(startx, starty, pen->colour, opcode);
- if (p > 0)
- {
- startx += incx;
- starty += incy;
- p += dpru;
- }
- else
- {
- starty += incy;
- p += dpr;
- }
- }
- }
- cache_rect(left, top, (right - left) + 1, (bottom - top) + 1, True);
-}
-
-/*****************************************************************************/
-void ui_triblt(uint8 opcode, int x, int y, int cx, int cy,
- RD_HBITMAP src, int srcx, int srcy,
- BRUSH* brush, int bgcolour, int fgcolour)
-{
- // non used
-}
-
-/*****************************************************************************/
-void ui_memblt(uint8 opcode, int x, int y, int cx, int cy,
- RD_HBITMAP src, int srcx, int srcy)
-{
- bitmap* b;
- int i;
- int j;
- int pixel;
-
- if (warp_coords(&x, &y, &cx, &cy, &srcx, &srcy))
- {
- if (contains_mouse(x, y, cx, cy))
- draw_cursor_under(mousex, mousey);
- b = (bitmap*)src;
- if (opcode == 0xc)
- accel_draw_box(x, y, cx, cy, get_ptr(srcx, srcy, b->data, b->width, g_server_depth),
- b->width * g_server_Bpp);
- else
- {
- for (i = 0; i < cy; i++)
- {
- for (j = 0; j < cx; j++)
- {
- pixel = get_pixel2(srcx + j, srcy + i, b->data, b->width, g_server_depth);
- set_pixel(x + j, y + i, pixel, opcode);
- }
- }
- }
- cache_rect(x, y, cx, cy, False);
- }
-}
-
-/*****************************************************************************/
-void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
-{
- uint8* p;
-
- if (offset > 0x38400)
- offset = 0;
- if (offset + cx * cy > 0x38400)
- return;
- p = desk_save + offset * g_server_Bpp;
- ui_paint_bitmap(x, y, cx, cy, cx, cy, p);
-}
-
-/*****************************************************************************/
-void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
-{
- uint8* p;
-
- if (offset > 0x38400)
- offset = 0;
- if (offset + cx * cy > 0x38400)
- return;
- if (contains_mouse(x, y, cx, cy))
- draw_cursor_under(mousex, mousey);
- p = desk_save + offset * g_server_Bpp;
- get_rect(x, y, cx, cy, p);
-}
-
-/*****************************************************************************/
-void ui_rect(int x, int y, int cx, int cy, int colour)
-{
- if (warp_coords(&x, &y, &cx, &cy, NULL, NULL))
- {
- if (contains_mouse(x, y, cx, cy))
- draw_cursor_under(mousex, mousey);
- accel_fill_rect(x, y, cx, cy, colour);
- cache_rect(x, y, cx, cy, False);
- }
-}
-
-/*****************************************************************************/
-void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy,
- int srcx, int srcy)
-{
- int i;
- int j;
- uint8* temp;
-
- if (x == srcx && y == srcy)
- return;
- if (warp_coords(&x, &y, &cx, &cy, &srcx, &srcy))
- {
- if (contains_mouse(x, y, cx, cy) || contains_mouse(srcx, srcy, cx, cy))
- draw_cursor_under(mousex, mousey);
- if (opcode == 0xc) /* copy */
- accel_screen_copy(x, y, cx, cy, srcx, srcy);
- else
- {
- temp = (uint8*)xmalloc(cx * cy * g_server_Bpp);
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- set_pixel2(j, i, get_pixel(srcx + j, srcy + i), temp, cx, g_server_depth);
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- set_pixel(x + j, y + i, get_pixel2(j, i, temp, cx, g_server_depth), opcode);
- xfree(temp);
- }
- cache_rect(x, y, cx, cy, False);
- draw_cache_rects(); // draw them all so screen is not jumpy
- }
-}
-
-/*****************************************************************************/
-void ui_patblt(uint8 opcode, int x, int y, int cx, int cy,
- BRUSH * brush, int bgcolour, int fgcolour)
-{
- int i;
- int j;
- uint8 ipattern[8];
-
- if (warp_coords(&x, &y, &cx, &cy, NULL, NULL))
- {
- if (contains_mouse(x, y, cx, cy))
- draw_cursor_under(mousex, mousey);
- switch (brush->style)
- {
- case 0:
- fill_rect(x, y, cx, cy, fgcolour, opcode);
- break;
- case 3:
- for (i = 0; i < 8; i++)
- ipattern[i] = ~brush->pattern[7 - i];
- for (i = 0; i < cy; i++)
- for (j = 0; j < cx; j++)
- if (is_pixel_on(ipattern, (x + j + brush->xorigin) % 8,
- (y + i + brush->yorigin) % 8, 8, 1))
- set_pixel(x + j, y + i, fgcolour, opcode);
- else
- set_pixel(x + j, y + i, bgcolour, opcode);
- break;
- }
- cache_rect(x, y, cx, cy, False);
- }
-}
-
-/*****************************************************************************/
-void ui_destblt(uint8 opcode, int x, int y, int cx, int cy)
-{
- if (warp_coords(&x, &y, &cx, &cy, NULL, NULL))
- {
- if (contains_mouse(x, y, cx, cy))
- draw_cursor_under(mousex, mousey);
- fill_rect(x, y, cx, cy, -1, opcode);
- cache_rect(x, y, cx, cy, False);
- }
-}
-
-/*****************************************************************************/
-void ui_move_pointer(int x, int y)
-{
-}
-
-/*****************************************************************************/
-void ui_set_null_cursor(void)
-{
- draw_cursor_under(mousex, mousey);
- mousex = mousex - mcursor.x;
- mousey = mousey - mcursor.y;
- memset(&mcursor, 0, sizeof(mcursor));
- memset(mcursor.andmask, 255, sizeof(mcursor.andmask));
- memset(mcursor.xormask, 0, sizeof(mcursor.xormask));
- draw_cursor();
-}
-
-/*****************************************************************************/
-void ui_paint_bitmap(int x, int y, int cx, int cy,
- int width, int height, uint8* data)
-{
- if (warp_coords(&x, &y, &cx, &cy, NULL, NULL))
- {
- if (contains_mouse(x, y, cx, cy))
- draw_cursor_under(mousex, mousey);
- accel_draw_box(x, y, cx, cy, data, width * g_server_Bpp);
- cache_rect(x, y, cx, cy, False);
- }
-}
-
-/*****************************************************************************/
-void* ui_create_cursor(unsigned int x, unsigned int y,
- int width, int height,
- uint8* andmask, uint8* xormask)
-{
- tcursor* c;
- int i;
- int j;
-
- c = (tcursor*)xmalloc(sizeof(tcursor));
- memset(c, 0, sizeof(tcursor));
- c->w = width;
- c->h = height;
- c->x = x;
- c->y = y;
- for (i = 0; i < 32; i++)
- {
- for (j = 0; j < 32; j++)
- {
- if (is_pixel_on(andmask, j, i, 32, 1))
- set_pixel_on(c->andmask, j, 31 - i, 32, 8, 255);
- if (is_pixel_on(xormask, j, i, 32, 24))
- set_pixel_on(c->xormask, j, 31 - i, 32, 8, 255);
- }
- }
- return (void*)c;
-}
-
-/*****************************************************************************/
-void ui_destroy_cursor(void* cursor)
-{
- if (cursor != NULL)
- xfree(cursor);
-}
-
-/*****************************************************************************/
-void ui_set_cursor(void* cursor)
-{
- int x;
- int y;
- int ox;
- int oy;
-
- ox = mousex;
- oy = mousey;
- x = mousex + mcursor.x;
- y = mousey + mcursor.y;
- memcpy(&mcursor, cursor, sizeof(tcursor));
- mousex = x - mcursor.x;
- mousey = y - mcursor.y;
- draw_cursor_under(ox, oy);
- draw_cursor();
-}
-
-/*****************************************************************************/
-uint16 ui_get_numlock_state(unsigned int state)
-{
- return 0;
-}
-
-/*****************************************************************************/
-unsigned int read_keyboard_state(void)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void ui_resize_window(void)
-{
-}
-
-/*****************************************************************************/
-void ui_begin_update(void)
-{
-}
-
-/*****************************************************************************/
-void ui_end_update(void)
-{
- draw_cache_rects();
- draw_cursor();
-}
-
-/*****************************************************************************/
-void ui_polygon(uint8 opcode, uint8 fillmode, RD_POINT * point, int npoints,
- BRUSH * brush, int bgcolour, int fgcolour)
-{
-}
-
-/*****************************************************************************/
-void ui_polyline(uint8 opcode, RD_POINT * points, int npoints, PEN * pen)
-{
-}
-
-/*****************************************************************************/
-void ui_ellipse(uint8 opcode, uint8 fillmode,
- int x, int y, int cx, int cy,
- BRUSH * brush, int bgcolour, int fgcolour)
-{
-}
-
-/*****************************************************************************/
-void generate_random(uint8* random)
-{
- memcpy(random, "12345678901234567890123456789012", 32);
-}
-
-/*****************************************************************************/
-void save_licence(uint8* data, int length)
-{
-}
-
-/*****************************************************************************/
-int load_licence(uint8** data)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void* xrealloc(void* in_val, int size)
-{
- return realloc(in_val, size);
-}
-
-/*****************************************************************************/
-void* xmalloc(int size)
-{
- return malloc(size);
-}
-
-/*****************************************************************************/
-void xfree(void* in_val)
-{
- free(in_val);
-}
-
-/*****************************************************************************/
-char * xstrdup(const char * s)
-{
- char * mem = strdup(s);
- if (mem == NULL)
- {
- perror("strdup");
- exit(1);
- }
- return mem;
-}
-
-/*****************************************************************************/
-void warning(char* format, ...)
-{
- va_list ap;
-
- fprintf(stderr, "WARNING: ");
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- va_end(ap);
-}
-
-/*****************************************************************************/
-void unimpl(char* format, ...)
-{
- va_list ap;
-
- fprintf(stderr, "NOT IMPLEMENTED: ");
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- va_end(ap);
-}
-
-/*****************************************************************************/
-void error(char* format, ...)
-{
- va_list ap;
-
- fprintf(stderr, "ERROR: ");
- va_start(ap, format);
- vfprintf(stderr, format, ap);
- va_end(ap);
-}
-
-RD_BOOL rd_pstcache_mkdir(void)
-{
- return 0;
-}
-
-/*****************************************************************************/
-int rd_open_file(char *filename)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void rd_close_file(int fd)
-{
- return;
-}
-
-/*****************************************************************************/
-int rd_read_file(int fd, void *ptr, int len)
-{
- return 0;
-}
-
-/*****************************************************************************/
-int rd_write_file(int fd, void* ptr, int len)
-{
- return 0;
-}
-
-/*****************************************************************************/
-int rd_lseek_file(int fd, int offset)
-{
- return 0;
-}
-
-/*****************************************************************************/
-RD_BOOL rd_lock_file(int fd, int start, int len)
-{
- return False;
-}
-
-/*****************************************************************************/
-void get_username_and_hostname(void)
-{
- char fullhostname[64];
- char* p;
- struct passwd* pw;
-
- STRNCPY(g_username, "unknown", sizeof(g_username));
- STRNCPY(g_hostname, "unknown", sizeof(g_hostname));
- pw = getpwuid(getuid());
- if (pw != NULL && pw->pw_name != NULL)
- {
- STRNCPY(g_username, pw->pw_name, sizeof(g_username));
- }
- if (gethostname(fullhostname, sizeof(fullhostname)) != -1)
- {
- p = strchr(fullhostname, '.');
- if (p != NULL)
- *p = 0;
- STRNCPY(g_hostname, fullhostname, sizeof(g_hostname));
- }
-}
-
-/*****************************************************************************/
-void out_params(void)
-{
- fprintf(stderr, "rdesktop: A Remote Desktop Protocol client.\n");
- fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2003 Matt Chapman.\n");
- fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n");
- fprintf(stderr, "Usage: svgardesktop [options] server\n");
- fprintf(stderr, " -g: desktop geometry (WxH)\n");
- fprintf(stderr, " -4: use RDP version 4\n");
- fprintf(stderr, " -5: use RDP version 5 (default)\n");
- fprintf(stderr, " -t: tcp port\n");
- fprintf(stderr, " -u: user name\n");
- fprintf(stderr, " -n: client hostname\n");
- fprintf(stderr, " -d: disable acceleration functions\n");
- fprintf(stderr, " -a: connection colour depth\n");
- fprintf(stderr, " -l: low memory\n");
- fprintf(stderr, "\n");
-}
-
-/* produce a hex dump */
-void hexdump(uint8* p, uint32 len)
-{
- uint8* line;
- int i;
- int thisline;
- int offset;
-
- line = p;
- offset = 0;
- while (offset < len)
- {
- printf("%04x ", offset);
- thisline = len - offset;
- if (thisline > 16)
- thisline = 16;
-
- for (i = 0; i < thisline; i++)
- printf("%02x ", line[i]);
-
- for (; i < 16; i++)
- printf(" ");
-
- for (i = 0; i < thisline; i++)
- printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.');
-
- printf("\n");
- offset += thisline;
- line += thisline;
- }
-}
-
-/*****************************************************************************/
-int parse_parameters(int in_argc, char** in_argv)
-{
- int i;
- char* p;
-
- if (in_argc <= 1)
- {
- out_params();
- return 0;
- }
- g_argc = in_argc;
- g_argv = in_argv;
- for (i = 1; i < in_argc; i++)
- {
- strcpy(g_servername, in_argv[i]);
- if (strcmp(in_argv[i], "-g") == 0)
- {
- g_width = strtol(in_argv[i + 1], &p, 10);
- if (g_width <= 0)
- {
- error("invalid geometry\n");
- return 0;
- }
- if (*p == 'x')
- g_height = strtol(p + 1, NULL, 10);
- if (g_height <= 0)
- {
- error("invalid geometry\n");
- return 0;
- }
- g_width = (g_width + 3) & ~3;
- }
- else if (strcmp(in_argv[i], "-4") == 0)
- g_use_rdp5 = 0;
- else if (strcmp(in_argv[i], "-5") == 0)
- g_use_rdp5 = 1;
- else if (strcmp(in_argv[i], "-t") == 0)
- g_tcp_port_rdp = strtol(in_argv[i + 1], &p, 10);
- else if (strcmp(in_argv[i], "-h") == 0)
- {
- out_params();
- return 0;
- }
- else if (strcmp(in_argv[i], "-n") == 0)
- {
- STRNCPY(g_hostname, in_argv[i + 1], sizeof(g_hostname));
- }
- else if (strcmp(in_argv[i], "-u") == 0)
- {
- STRNCPY(g_username, in_argv[i + 1], sizeof(g_username));
- }
- else if (strcmp(in_argv[i], "-d") == 0)
- {
- use_accel = 0;
- }
- else if (strcmp(in_argv[i], "-a") == 0)
- {
- g_server_depth = strtol(in_argv[i + 1], NULL, 10);
- if (g_server_depth != 8 && g_server_depth != 16)
- {
- error("invalid server bpp\n");
- return 0;
- }
- g_server_Bpp = (g_server_depth + 7) / 8;
- }
- else if (strcmp(in_argv[i], "-l") == 0)
- g_save_mem = 1;
- }
- return 1;
-}
-
-/*****************************************************************************/
-int main(int in_argc, char** in_argv)
-{
- get_username_and_hostname();
- if (!parse_parameters(in_argc, in_argv))
- return 0;
- if (!ui_init())
- return 1;
- if (!ui_create_window())
- return 1;
- ui_main_loop();
- ui_destroy_window();
- ui_deinit();
- return 0;
-}
diff --git a/uiports/xxxwin.c b/uiports/xxxwin.c
deleted file mode 100755
index 896a76f..0000000
--- a/uiports/xxxwin.c
+++ /dev/null
@@ -1,365 +0,0 @@
-/* -*- c-basic-offset: 8 -*-
- rdesktop: A Remote Desktop Protocol client.
- User interface services - Generic
- Copyright (C) Jay Sorg 2004-2007
-
- 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 3 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, see .
-*/
-
-#include "../rdesktop.h"
-
-extern int g_tcp_port_rdp; /* in tcp.c */
-RD_BOOL g_use_rdp5 = False;
-char g_hostname[16];
-char g_username[64];
-int g_height = 600;
-int g_width = 800;
-int g_server_depth = 8;
-RD_BOOL g_encryption = True;
-RD_BOOL g_desktop_save = True;
-RD_BOOL g_polygon_ellipse_orders = False;
-RD_BOOL g_bitmap_cache = True;
-RD_BOOL g_bitmap_cache_persist_enable = False;
-RD_BOOL g_bitmap_cache_precache = True;
-uint32 g_rdp5_performanceflags = 0;
-RD_BOOL g_console_session = False;
-uint32 g_keylayout = 0x409; /* Defaults to US keyboard layout */
-int g_keyboard_type = 0x4; /* Defaults to US keyboard layout */
-int g_keyboard_subtype = 0x0; /* Defaults to US keyboard layout */
-int g_keyboard_functionkeys = 0xc; /* Defaults to US keyboard layout */
-/* Session Directory redirection */
-RD_BOOL g_redirect = False;
-RD_BOOL g_numlock_sync = False;
-char g_redirect_server[64];
-char g_redirect_domain[16];
-char g_redirect_password[64];
-char g_redirect_username[64];
-char g_redirect_cookie[128];
-uint32 g_redirect_flags = 0;
-char g_codepage[16] = "";
-
-/*****************************************************************************/
-void ui_bell(void)
-{
-}
-
-/*****************************************************************************/
-int ui_select(int in)
-{
- return 1;
-}
-
-/*****************************************************************************/
-void ui_destroy_cursor(void* cursor)
-{
-}
-
-/*****************************************************************************/
-void* ui_create_glyph(int width, int height, uint8* data)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void ui_destroy_glyph(void* glyph)
-{
-}
-
-/*****************************************************************************/
-void ui_destroy_bitmap(void* bmp)
-{
-}
-
-/*****************************************************************************/
-void ui_reset_clip(void)
-{
-}
-
-/*****************************************************************************/
-void ui_set_clip(int x, int y, int cx, int cy)
-{
-}
-
-/*****************************************************************************/
-void* ui_create_colourmap(COLOURMAP * colours)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void ui_set_colourmap(void* map)
-{
-}
-
-/*****************************************************************************/
-RD_HBITMAP ui_create_bitmap(int width, int height, uint8* data)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void ui_draw_text(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, BRUSH * brush,
- int bgcolour, int fgcolour, uint8* text, uint8 length)
-{
-}
-
-/*****************************************************************************/
-void ui_line(uint8 opcode, int startx, int starty, int endx, int endy,
- PEN * pen)
-{
-}
-
-/*****************************************************************************/
-void ui_triblt(uint8 opcode, int x, int y, int cx, int cy,
- RD_HBITMAP src, int srcx, int srcy,
- BRUSH* brush, int bgcolour, int fgcolour)
-{
-}
-
-/*****************************************************************************/
-void ui_memblt(uint8 opcode, int x, int y, int cx, int cy,
- RD_HBITMAP src, int srcx, int srcy)
-{
-}
-
-/*****************************************************************************/
-void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
-{
-}
-
-/*****************************************************************************/
-void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
-{
-}
-
-/*****************************************************************************/
-void ui_rect(int x, int y, int cx, int cy, int colour)
-{
-}
-
-/*****************************************************************************/
-void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy,
- int srcx, int srcy)
-{
-}
-
-/*****************************************************************************/
-void ui_patblt(uint8 opcode, int x, int y, int cx, int cy,
- BRUSH * brush, int bgcolour, int fgcolour)
-{
-}
-
-/*****************************************************************************/
-void ui_destblt(uint8 opcode, int x, int y, int cx, int cy)
-{
-}
-
-/*****************************************************************************/
-void ui_move_pointer(int x, int y)
-{
-}
-
-/*****************************************************************************/
-void ui_set_null_cursor(void)
-{
-}
-
-/*****************************************************************************/
-void ui_paint_bitmap(int x, int y, int cx, int cy,
- int width, int height, uint8* data)
-{
-}
-
-/*****************************************************************************/
-void ui_set_cursor(RD_HCURSOR cursor)
-{
-}
-
-/*****************************************************************************/
-RD_HCURSOR ui_create_cursor(unsigned int x, unsigned int y,
- int width, int height,
- uint8* andmask, uint8* xormask)
-{
- return 0;
-}
-
-/*****************************************************************************/
-uint16 ui_get_numlock_state(unsigned int state)
-{
- return 0;
-}
-
-/*****************************************************************************/
-unsigned int read_keyboard_state(void)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void ui_resize_window(void)
-{
-}
-
-/*****************************************************************************/
-void ui_begin_update(void)
-{
-}
-
-/*****************************************************************************/
-void ui_end_update(void)
-{
-}
-
-/*****************************************************************************/
-void ui_polygon(uint8 opcode, uint8 fillmode, RD_POINT * point, int npoints,
- BRUSH * brush, int bgcolour, int fgcolour)
-{
-}
-
-/*****************************************************************************/
-/* todo, use qt function for this (QPainter::drawPolyline) */
-void ui_polyline(uint8 opcode, RD_POINT * points, int npoints, PEN * pen)
-{
- int i, x, y, dx, dy;
- if (npoints > 0)
- {
- x = points[0].x;
- y = points[0].y;
- for (i = 1; i < npoints; i++)
- {
- dx = points[i].x;
- dy = points[i].y;
- ui_line(opcode, x, y, x + dx, y + dy, pen);
- x = x + dx;
- y = y + dy;
- }
- }
-}
-
-/*****************************************************************************/
-void ui_ellipse(uint8 opcode, uint8 fillmode,
- int x, int y, int cx, int cy,
- BRUSH * brush, int bgcolour, int fgcolour)
-{
-}
-
-/*****************************************************************************/
-void generate_random(uint8* random)
-{
-}
-
-/*****************************************************************************/
-void save_licence(uint8* data, int length)
-{
-}
-
-/*****************************************************************************/
-int load_licence(uint8** data)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void* xrealloc(void* in, int size)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void* xmalloc(int size)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void xfree(void* in)
-{
-}
-
-/*****************************************************************************/
-char * xstrdup(const char * s)
-{
- char * mem = strdup(s);
- if (mem == NULL)
- {
- perror("strdup");
- exit(1);
- }
- return mem;
-}
-/*****************************************************************************/
-void warning(char* format, ...)
-{
-}
-
-/*****************************************************************************/
-void unimpl(char* format, ...)
-{
-}
-
-/*****************************************************************************/
-void error(char* format, ...)
-{
-}
-
-/*****************************************************************************/
-RD_BOOL rd_pstcache_mkdir(void)
-{
- return 0;
-}
-
-/*****************************************************************************/
-int rd_open_file(char *filename)
-{
- return 0;
-}
-
-/*****************************************************************************/
-void rd_close_file(int fd)
-{
- return;
-}
-
-/*****************************************************************************/
-int rd_read_file(int fd, void *ptr, int len)
-{
- return 0;
-}
-
-/*****************************************************************************/
-int rd_write_file(int fd, void* ptr, int len)
-{
- return 0;
-}
-
-/*****************************************************************************/
-int rd_lseek_file(int fd, int offset)
-{
- return 0;
-}
-
-/*****************************************************************************/
-RD_BOOL rd_lock_file(int fd, int start, int len)
-{
- return False;
-}
-
-/*****************************************************************************/
-int main(int c, char** p)
-{
- return 0;
-}