From b1d5617ed46a3e036ddda9dfafbe8b19046d5bfb Mon Sep 17 00:00:00 2001 From: jsorg71 Date: Thu, 11 Jan 2007 07:21:05 +0000 Subject: [PATCH] remove uirdesktop --- uirdesktop/channels.c | 181 ------ uirdesktop/constants.h | 436 --------------- uirdesktop/dfb.c | 894 ------------------------------ uirdesktop/fb.c | 1202 ---------------------------------------- uirdesktop/iso.c | 231 -------- 5 files changed, 2944 deletions(-) delete mode 100644 uirdesktop/channels.c delete mode 100755 uirdesktop/constants.h delete mode 100644 uirdesktop/dfb.c delete mode 100644 uirdesktop/fb.c delete mode 100644 uirdesktop/iso.c diff --git a/uirdesktop/channels.c b/uirdesktop/channels.c deleted file mode 100644 index 389cce2e..00000000 --- a/uirdesktop/channels.c +++ /dev/null @@ -1,181 +0,0 @@ -/* -*- c-basic-offset: 8 -*- - rdesktop: A Remote Desktop Protocol client. - Protocol services - Virtual channels - Copyright (C) Erik Forsberg 2003 - Copyright (C) Matthew Chapman 2003-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 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "rdesktop.h" - -#define MAX_CHANNELS 6 -#define CHANNEL_CHUNK_LENGTH 1600 -#define CHANNEL_FLAG_FIRST 0x01 -#define CHANNEL_FLAG_LAST 0x02 -#define CHANNEL_FLAG_SHOW_PROTOCOL 0x10 - -extern BOOL g_use_rdp5; -extern BOOL g_encryption; - -VCHANNEL g_channels[MAX_CHANNELS]; -unsigned int g_num_channels; - -/* FIXME: We should use the information in TAG_SRV_CHANNELS to map RDP5 - channels to MCS channels. - - The format of TAG_SRV_CHANNELS seems to be - - global_channel_no (uint16le) - number_of_other_channels (uint16le) - ..followed by uint16les for the other channels. -*/ - -VCHANNEL * -channel_register(char *name, uint32 flags, void (*callback) (STREAM)) -{ - VCHANNEL *channel; - - if (!g_use_rdp5) - return NULL; - - if (g_num_channels >= MAX_CHANNELS) - { - error("Channel table full, increase MAX_CHANNELS\n"); - return NULL; - } - - channel = &g_channels[g_num_channels]; - channel->mcs_id = MCS_GLOBAL_CHANNEL + 1 + g_num_channels; - strncpy(channel->name, name, 8); - channel->flags = flags; - channel->process = callback; - g_num_channels++; - return channel; -} - -STREAM -channel_init(VCHANNEL * channel, uint32 length) -{ - STREAM s; - - s = sec_init(g_encryption ? SEC_ENCRYPT : 0, length + 8); - s_push_layer(s, channel_hdr, 8); - return s; -} - -void -channel_send(STREAM s, VCHANNEL * channel) -{ - uint32 length, flags; - uint32 thislength, remaining; - uint8 *data; - - /* first fragment sent in-place */ - s_pop_layer(s, channel_hdr); - length = s->end - s->p - 8; - - DEBUG_CHANNEL(("channel_send, length = %d\n", length)); - - thislength = MIN(length, CHANNEL_CHUNK_LENGTH); -/* Note: In the original clipboard implementation, this number was - 1592, not 1600. However, I don't remember the reason and 1600 seems - to work so.. This applies only to *this* length, not the length of - continuation or ending packets. */ - remaining = length - thislength; - flags = (remaining == 0) ? CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST : CHANNEL_FLAG_FIRST; - if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL) - flags |= CHANNEL_FLAG_SHOW_PROTOCOL; - - out_uint32_le(s, length); - out_uint32_le(s, flags); - data = s->end = s->p + thislength; - DEBUG_CHANNEL(("Sending %d bytes with FLAG_FIRST\n", thislength)); - sec_send_to_channel(s, g_encryption ? SEC_ENCRYPT : 0, channel->mcs_id); - - /* subsequent segments copied (otherwise would have to generate headers backwards) */ - while (remaining > 0) - { - thislength = MIN(remaining, CHANNEL_CHUNK_LENGTH); - remaining -= thislength; - flags = (remaining == 0) ? CHANNEL_FLAG_LAST : 0; - if (channel->flags & CHANNEL_OPTION_SHOW_PROTOCOL) - flags |= CHANNEL_FLAG_SHOW_PROTOCOL; - - DEBUG_CHANNEL(("Sending %d bytes with flags %d\n", thislength, flags)); - - s = sec_init(g_encryption ? SEC_ENCRYPT : 0, thislength + 8); - out_uint32_le(s, length); - out_uint32_le(s, flags); - out_uint8p(s, data, thislength); - s_mark_end(s); - sec_send_to_channel(s, g_encryption ? SEC_ENCRYPT : 0, channel->mcs_id); - - data += thislength; - } -} - -void -channel_process(STREAM s, uint16 mcs_channel) -{ - uint32 length, flags; - uint32 thislength; - VCHANNEL *channel = NULL; - unsigned int i; - STREAM in; - - for (i = 0; i < g_num_channels; i++) - { - channel = &g_channels[i]; - if (channel->mcs_id == mcs_channel) - break; - } - - if (i >= g_num_channels) - return; - - in_uint32_le(s, length); - in_uint32_le(s, flags); - if ((flags & CHANNEL_FLAG_FIRST) && (flags & CHANNEL_FLAG_LAST)) - { - /* single fragment - pass straight up */ - channel->process(s); - } - else - { - /* add fragment to defragmentation buffer */ - in = &channel->in; - if (flags & CHANNEL_FLAG_FIRST) - { - if (length > in->size) - { - in->data = (uint8 *) xrealloc(in->data, length); - in->size = length; - } - in->p = in->data; - } - - thislength = MIN(s->end - s->p, in->data + in->size - in->p); - memcpy(in->p, s->p, thislength); - in->p += thislength; - - if (flags & CHANNEL_FLAG_LAST) - { - in->end = in->p; - in->p = in->data; - channel->process(in); - } - } -} diff --git a/uirdesktop/constants.h b/uirdesktop/constants.h deleted file mode 100755 index a11b4f46..00000000 --- a/uirdesktop/constants.h +++ /dev/null @@ -1,436 +0,0 @@ -/* - rdesktop: A Remote Desktop Protocol client. - Miscellaneous protocol constants - Copyright (C) Matthew Chapman 1999-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 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -/* TCP port for Remote Desktop Protocol */ -#define TCP_PORT_RDP 3389 - -#define DEFAULT_CODEPAGE "UTF-8" -#define WINDOWS_CODEPAGE "UTF-16LE" - -/* ISO PDU codes */ -enum ISO_PDU_CODE -{ - ISO_PDU_CR = 0xE0, /* Connection Request */ - ISO_PDU_CC = 0xD0, /* Connection Confirm */ - ISO_PDU_DR = 0x80, /* Disconnect Request */ - ISO_PDU_DT = 0xF0, /* Data */ - ISO_PDU_ER = 0x70 /* Error */ -}; - -/* MCS PDU codes */ -enum MCS_PDU_TYPE -{ - MCS_EDRQ = 1, /* Erect Domain Request */ - MCS_DPUM = 8, /* Disconnect Provider Ultimatum */ - MCS_AURQ = 10, /* Attach User Request */ - MCS_AUCF = 11, /* Attach User Confirm */ - MCS_CJRQ = 14, /* Channel Join Request */ - MCS_CJCF = 15, /* Channel Join Confirm */ - MCS_SDRQ = 25, /* Send Data Request */ - MCS_SDIN = 26 /* Send Data Indication */ -}; - -#define MCS_CONNECT_INITIAL 0x7f65 -#define MCS_CONNECT_RESPONSE 0x7f66 - -#define BER_TAG_BOOLEAN 1 -#define BER_TAG_INTEGER 2 -#define BER_TAG_OCTET_STRING 4 -#define BER_TAG_RESULT 10 -#define MCS_TAG_DOMAIN_PARAMS 0x30 - -#define MCS_GLOBAL_CHANNEL 1003 -#define MCS_USERCHANNEL_BASE 1001 - -/* RDP secure transport constants */ -#define SEC_RANDOM_SIZE 32 -#define SEC_MODULUS_SIZE 64 -#define SEC_MAX_MODULUS_SIZE 256 -#define SEC_PADDING_SIZE 8 -#define SEC_EXPONENT_SIZE 4 - -#define SEC_CLIENT_RANDOM 0x0001 -#define SEC_ENCRYPT 0x0008 -#define SEC_LOGON_INFO 0x0040 -#define SEC_LICENCE_NEG 0x0080 -#define SEC_REDIRECT_ENCRYPT 0x0C00 - -#define SEC_TAG_SRV_INFO 0x0c01 -#define SEC_TAG_SRV_CRYPT 0x0c02 -#define SEC_TAG_SRV_CHANNELS 0x0c03 - -#define SEC_TAG_CLI_INFO 0xc001 -#define SEC_TAG_CLI_CRYPT 0xc002 -#define SEC_TAG_CLI_CHANNELS 0xc003 -#define SEC_TAG_CLI_4 0xc004 - -#define SEC_TAG_PUBKEY 0x0006 -#define SEC_TAG_KEYSIG 0x0008 - -#define SEC_RSA_MAGIC 0x31415352 /* RSA1 */ - -/* RDP licensing constants */ -#define LICENCE_TOKEN_SIZE 10 -#define LICENCE_HWID_SIZE 20 -#define LICENCE_SIGNATURE_SIZE 16 - -#define LICENCE_TAG_DEMAND 0x01 -#define LICENCE_TAG_AUTHREQ 0x02 -#define LICENCE_TAG_ISSUE 0x03 -#define LICENCE_TAG_REISSUE 0x04 -#define LICENCE_TAG_PRESENT 0x12 -#define LICENCE_TAG_REQUEST 0x13 -#define LICENCE_TAG_AUTHRESP 0x15 -#define LICENCE_TAG_RESULT 0xff - -#define LICENCE_TAG_USER 0x000f -#define LICENCE_TAG_HOST 0x0010 - -/* RDP PDU codes */ -enum RDP_PDU_TYPE -{ - RDP_PDU_DEMAND_ACTIVE = 1, - RDP_PDU_CONFIRM_ACTIVE = 3, - RDP_PDU_REDIRECT = 4, /* MS Server 2003 Session Redirect */ - RDP_PDU_DEACTIVATE = 6, - RDP_PDU_DATA = 7 -}; - -enum RDP_DATA_PDU_TYPE -{ - RDP_DATA_PDU_UPDATE = 2, - RDP_DATA_PDU_CONTROL = 20, - RDP_DATA_PDU_POINTER = 27, - RDP_DATA_PDU_INPUT = 28, - RDP_DATA_PDU_SYNCHRONISE = 31, - RDP_DATA_PDU_BELL = 34, - RDP_DATA_PDU_CLIENT_WINDOW_STATUS = 35, - RDP_DATA_PDU_LOGON = 38, - RDP_DATA_PDU_FONT2 = 39, - RDP_DATA_PDU_KEYBOARD_INDICATORS = 41, - RDP_DATA_PDU_DISCONNECT = 47 -}; - -enum RDP_CONTROL_PDU_TYPE -{ - RDP_CTL_REQUEST_CONTROL = 1, - RDP_CTL_GRANT_CONTROL = 2, - RDP_CTL_DETACH = 3, - RDP_CTL_COOPERATE = 4 -}; - -enum RDP_UPDATE_PDU_TYPE -{ - RDP_UPDATE_ORDERS = 0, - RDP_UPDATE_BITMAP = 1, - RDP_UPDATE_PALETTE = 2, - RDP_UPDATE_SYNCHRONIZE = 3 -}; - -enum RDP_POINTER_PDU_TYPE -{ - RDP_POINTER_SYSTEM = 1, - RDP_POINTER_MOVE = 3, - RDP_POINTER_COLOR = 6, - RDP_POINTER_CACHED = 7 -}; - -enum RDP_SYSTEM_POINTER_TYPE -{ - RDP_NULL_POINTER = 0, - RDP_DEFAULT_POINTER = 0x7F00 -}; - -enum RDP_INPUT_DEVICE -{ - RDP_INPUT_SYNCHRONIZE = 0, - RDP_INPUT_CODEPOINT = 1, - RDP_INPUT_VIRTKEY = 2, - RDP_INPUT_SCANCODE = 4, - RDP_INPUT_MOUSE = 0x8001 -}; - -/* Device flags */ -#define KBD_FLAG_RIGHT 0x0001 -#define KBD_FLAG_EXT 0x0100 -#define KBD_FLAG_QUIET 0x1000 -#define KBD_FLAG_DOWN 0x4000 -#define KBD_FLAG_UP 0x8000 - -/* These are for synchronization; not for keystrokes */ -#define KBD_FLAG_SCROLL 0x0001 -#define KBD_FLAG_NUMLOCK 0x0002 -#define KBD_FLAG_CAPITAL 0x0004 - -/* See T.128 */ -#define RDP_KEYPRESS 0 -#define RDP_KEYRELEASE (KBD_FLAG_DOWN | KBD_FLAG_UP) - -#define MOUSE_FLAG_MOVE 0x0800 -#define MOUSE_FLAG_BUTTON1 0x1000 -#define MOUSE_FLAG_BUTTON2 0x2000 -#define MOUSE_FLAG_BUTTON3 0x4000 -#define MOUSE_FLAG_BUTTON4 0x0280 -#define MOUSE_FLAG_BUTTON5 0x0380 -#define MOUSE_FLAG_DOWN 0x8000 - -/* Raster operation masks */ -#define ROP2_S(rop3) ((uint8) (rop3 & 0xf)) -#define ROP2_P(rop3) ((uint8) ((rop3 & 0x3) | ((rop3 & 0x30) >> 2))) -#define ROP_MINUS_1(rop) ((uint8) (rop - 1)) - -#define ROP2_COPY 0xc -#define ROP2_XOR 0x6 -#define ROP2_AND 0x8 -#define ROP2_NXOR 0x9 -#define ROP2_OR 0xe - -#define MIX_TRANSPARENT 0 -#define MIX_OPAQUE 1 - -#define TEXT2_VERTICAL 0x04 -#define TEXT2_IMPLICIT_X 0x20 - -#define ALTERNATE 1 -#define WINDING 2 - -/* RDP bitmap cache (version 2) constants */ -#define BMPCACHE2_C0_CELLS 0x78 -#define BMPCACHE2_C1_CELLS 0x78 -#define BMPCACHE2_C2_CELLS 0x150 -#define BMPCACHE2_NUM_PSTCELLS 0x9f6 - -#define PDU_FLAG_FIRST 0x01 -#define PDU_FLAG_LAST 0x02 - -/* RDP capabilities */ -#define RDP_CAPSET_GENERAL 1 /* Maps to generalCapabilitySet in T.128 page 138 */ -#define RDP_CAPLEN_GENERAL 0x18 -#define OS_MAJOR_TYPE_UNIX 4 -#define OS_MINOR_TYPE_XSERVER 7 - -#define RDP_CAPSET_BITMAP 2 -#define RDP_CAPLEN_BITMAP 0x1C - -#define RDP_CAPSET_ORDER 3 -#define RDP_CAPLEN_ORDER 0x58 -#define ORDER_CAP_NEGOTIATE 2 -#define ORDER_CAP_NOSUPPORT 4 - -#define RDP_CAPSET_BMPCACHE 4 -#define RDP_CAPLEN_BMPCACHE 0x28 - -#define RDP_CAPSET_CONTROL 5 -#define RDP_CAPLEN_CONTROL 0x0C - -#define RDP_CAPSET_ACTIVATE 7 -#define RDP_CAPLEN_ACTIVATE 0x0C - -#define RDP_CAPSET_POINTER 8 -#define RDP_CAPLEN_POINTER 0x08 - -#define RDP_CAPSET_SHARE 9 -#define RDP_CAPLEN_SHARE 0x08 - -#define RDP_CAPSET_COLCACHE 10 -#define RDP_CAPLEN_COLCACHE 0x08 - -#define RDP_CAPSET_BMPCACHE2 19 -#define RDP_CAPLEN_BMPCACHE2 0x28 -#define BMPCACHE2_FLAG_PERSIST ((uint32)1<<31) - -#define RDP_SOURCE "MSTSC" - -/* Logon flags */ -#define RDP_LOGON_AUTO 0x0008 -#define RDP_LOGON_NORMAL 0x0033 -#define RDP_LOGON_COMPRESSION 0x0080 /* mppc compression with 8kB histroy buffer */ -#define RDP_LOGON_BLOB 0x0100 -#define RDP_LOGON_COMPRESSION2 0x0200 /* rdp5 mppc compression with 64kB history buffer */ -#define RDP_LOGON_LEAVE_AUDIO 0x2000 - -#define RDP5_DISABLE_NOTHING 0x00 -#define RDP5_NO_WALLPAPER 0x01 -#define RDP5_NO_FULLWINDOWDRAG 0x02 -#define RDP5_NO_MENUANIMATIONS 0x04 -#define RDP5_NO_THEMING 0x08 -#define RDP5_NO_CURSOR_SHADOW 0x20 -#define RDP5_NO_CURSORSETTINGS 0x40 /* disables cursor blinking */ - -/* compression types */ -#define RDP_MPPC_BIG 0x01 -#define RDP_MPPC_COMPRESSED 0x20 -#define RDP_MPPC_RESET 0x40 -#define RDP_MPPC_FLUSH 0x80 -#define RDP_MPPC_DICT_SIZE 65536 - -#define RDP5_COMPRESSED 0x80 - -/* Keymap flags */ -#define MapRightShiftMask (1<<0) -#define MapLeftShiftMask (1<<1) -#define MapShiftMask (MapRightShiftMask | MapLeftShiftMask) - -#define MapRightAltMask (1<<2) -#define MapLeftAltMask (1<<3) -#define MapAltGrMask MapRightAltMask - -#define MapRightCtrlMask (1<<4) -#define MapLeftCtrlMask (1<<5) -#define MapCtrlMask (MapRightCtrlMask | MapLeftCtrlMask) - -#define MapRightWinMask (1<<6) -#define MapLeftWinMask (1<<7) -#define MapWinMask (MapRightWinMask | MapLeftWinMask) - -#define MapNumLockMask (1<<8) -#define MapCapsLockMask (1<<9) - -#define MapLocalStateMask (1<<10) - -#define MapInhibitMask (1<<11) - -#define MASK_ADD_BITS(var, mask) (var |= mask) -#define MASK_REMOVE_BITS(var, mask) (var &= ~mask) -#define MASK_HAS_BITS(var, mask) ((var & mask)>0) -#define MASK_CHANGE_BIT(var, mask, active) (var = ((var & ~mask) | (active ? mask : 0))) - -/* Clipboard constants, "borrowed" from GCC system headers in - the w32 cross compiler */ - -#ifndef CF_TEXT -#define CF_TEXT 1 -#define CF_BITMAP 2 -#define CF_METAFILEPICT 3 -#define CF_SYLK 4 -#define CF_DIF 5 -#define CF_TIFF 6 -#define CF_OEMTEXT 7 -#define CF_DIB 8 -#define CF_PALETTE 9 -#define CF_PENDATA 10 -#define CF_RIFF 11 -#define CF_WAVE 12 -#define CF_UNICODETEXT 13 -#define CF_ENHMETAFILE 14 -#define CF_HDROP 15 -#define CF_LOCALE 16 -#define CF_MAX 17 -#define CF_OWNERDISPLAY 128 -#define CF_DSPTEXT 129 -#define CF_DSPBITMAP 130 -#define CF_DSPMETAFILEPICT 131 -#define CF_DSPENHMETAFILE 142 -#define CF_PRIVATEFIRST 512 -#define CF_PRIVATELAST 767 -#define CF_GDIOBJFIRST 768 -#define CF_GDIOBJLAST 1023 -#endif - -/* Sound format constants */ -#define WAVE_FORMAT_PCM 1 -#define WAVE_FORMAT_ADPCM 2 -#define WAVE_FORMAT_ALAW 6 -#define WAVE_FORMAT_MULAW 7 - -/* Virtual channel options */ -#define CHANNEL_OPTION_INITIALIZED 0x80000000 -#define CHANNEL_OPTION_ENCRYPT_RDP 0x40000000 -#define CHANNEL_OPTION_COMPRESS_RDP 0x00800000 -#define CHANNEL_OPTION_SHOW_PROTOCOL 0x00200000 - -/* NT status codes for RDPDR */ -#undef STATUS_SUCCESS -#define STATUS_SUCCESS 0x00000000 -#undef STATUS_NOT_IMPLEMENTED -#define STATUS_NOT_IMPLEMENTED 0x00000001 -#undef STATUS_PENDING -#define STATUS_PENDING 0x00000103 - -#ifndef STATUS_NO_MORE_FILES -#define STATUS_NO_MORE_FILES 0x80000006 -#define STATUS_DEVICE_PAPER_EMPTY 0x8000000e -#define STATUS_DEVICE_POWERED_OFF 0x8000000f -#define STATUS_DEVICE_OFF_LINE 0x80000010 -#define STATUS_DEVICE_BUSY 0x80000011 -#endif - -#ifndef STATUS_INVALID_HANDLE -#define STATUS_INVALID_HANDLE 0xc0000008 -#define STATUS_INVALID_PARAMETER 0xc000000d -#define STATUS_NO_SUCH_FILE 0xc000000f -#define STATUS_INVALID_DEVICE_REQUEST 0xc0000010 -#define STATUS_ACCESS_DENIED 0xc0000022 -#define STATUS_OBJECT_NAME_COLLISION 0xc0000035 -#define STATUS_DISK_FULL 0xc000007f -#define STATUS_FILE_IS_A_DIRECTORY 0xc00000ba -#define STATUS_NOT_SUPPORTED 0xc00000bb -#define STATUS_TIMEOUT 0xc0000102 -#define STATUS_NOTIFY_ENUM_DIR 0xc000010c -#define STATUS_CANCELLED 0xc0000120 -#endif - -/* RDPDR constants */ -#define RDPDR_MAX_DEVICES 0x10 -#define DEVICE_TYPE_SERIAL 0x01 -#define DEVICE_TYPE_PARALLEL 0x02 -#define DEVICE_TYPE_PRINTER 0x04 -#define DEVICE_TYPE_DISK 0x08 -#define DEVICE_TYPE_SCARD 0x20 - -#define FILE_DIRECTORY_FILE 0x00000001 -#define FILE_NON_DIRECTORY_FILE 0x00000040 -#define FILE_COMPLETE_IF_OPLOCKED 0x00000100 -#define FILE_DELETE_ON_CLOSE 0x00001000 -#define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000 - -/* RDP5 disconnect PDU */ -#define exDiscReasonNoInfo 0x0000 -#define exDiscReasonAPIInitiatedDisconnect 0x0001 -#define exDiscReasonAPIInitiatedLogoff 0x0002 -#define exDiscReasonServerIdleTimeout 0x0003 -#define exDiscReasonServerLogonTimeout 0x0004 -#define exDiscReasonReplacedByOtherConnection 0x0005 -#define exDiscReasonOutOfMemory 0x0006 -#define exDiscReasonServerDeniedConnection 0x0007 -#define exDiscReasonServerDeniedConnectionFips 0x0008 -#define exDiscReasonLicenseInternal 0x0100 -#define exDiscReasonLicenseNoLicenseServer 0x0101 -#define exDiscReasonLicenseNoLicense 0x0102 -#define exDiscReasonLicenseErrClientMsg 0x0103 -#define exDiscReasonLicenseHwidDoesntMatchLicense 0x0104 -#define exDiscReasonLicenseErrClientLicense 0x0105 -#define exDiscReasonLicenseCantFinishProtocol 0x0106 -#define exDiscReasonLicenseClientEndedProtocol 0x0107 -#define exDiscReasonLicenseErrClientEncryption 0x0108 -#define exDiscReasonLicenseCantUpgradeLicense 0x0109 -#define exDiscReasonLicenseNoRemoteConnections 0x010a - -/* SeamlessRDP constants */ -#define SEAMLESSRDP_NOTYETMAPPED -1 -#define SEAMLESSRDP_NORMAL 0 -#define SEAMLESSRDP_MINIMIZED 1 -#define SEAMLESSRDP_MAXIMIZED 2 -#define SEAMLESSRDP_POSITION_TIMER 200000 - -#define SEAMLESSRDP_CREATE_MODAL 0x0001 - -#define SEAMLESSRDP_HELLO_RECONNECT 0x0001 -#define SEAMLESSRDP_HELLO_HIDDEN 0x0002 diff --git a/uirdesktop/dfb.c b/uirdesktop/dfb.c deleted file mode 100644 index b49da378..00000000 --- a/uirdesktop/dfb.c +++ /dev/null @@ -1,894 +0,0 @@ -/* -*- c-basic-offset: 8 -*- - rdesktop: A Remote Desktop Protocol client. - directfb calls - Copyright (C) Jay Sorg 2006 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -//#define USE_FLIPPING -#define USE_ORDERS - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "uimain.h" -#include "bsops.h" - -extern char g_username[]; -extern char g_hostname[]; -extern char g_servername[]; -extern char g_password[]; -extern char g_shell[]; -extern char g_directory[]; -extern char g_domain[]; -extern int g_width; -extern int g_height; -extern int g_tcp_sck; -extern int g_server_depth; -extern int g_tcp_port_rdp; /* in tcp.c */ -extern int g_bytes_in; -extern int pal_entries[]; - -extern char * g_bs; - -static DFBRegion g_reg; - -static pthread_mutex_t g_mutex1 = PTHREAD_MUTEX_INITIALIZER; - -/* direct frame buffer stuff */ -static IDirectFB * g_dfb = 0; -static IDirectFBSurface * g_primary = 0; -static IDirectFBEventBuffer * g_event = 0; -static DFBRectangle g_rect = {0, 0, 0, 0}; - -struct cursor -{ - unsigned char andmask[32 * 32]; - unsigned char xormask[32 * 32]; - int x; - int y; - int w; - int h; -}; -static struct cursor g_mcursor; /* current mouse */ -static int g_mouse_x = 0; -static int g_mouse_y = 0; - -static IDirectFBSurface * g_s = 0; - -static int g_wfpx = 0; /* wait for pixel stuff */ -static int g_wfpy = 0; -static int g_wfpv = 0; -static int g_show_wfp = 0; -static int g_no_draw = 0; /* this means don't draw the screen but draw on - backingstore */ - -/* for transparent colour */ -static int g_use_trans = 0; -static int g_trans_colour = 0; - -//static IDirectFBDataBuffer * g_buffer = 0; -//static IDirectFBImageProvider * g_provider = 0; - -void (* master_callback)(int msg, int param1, int param2) = 0; - -/*****************************************************************************/ -void -mi_error(char * msg) -{ - printf(msg); -} - -/*****************************************************************************/ -void -mi_warning(char * msg) -{ - printf(msg); -} - -/*****************************************************************************/ -int -mi_read_keyboard_state(void) -{ - return 0; -} - -/*****************************************************************************/ -/* returns non zero if ok */ -int -mi_create_window(void) -{ - if (!g_no_draw) - { - g_primary->SetColor(g_primary, 0, 0, 0, 0xff); - g_primary->FillRectangle(g_primary, 0, 0, g_width, g_height); - } - return 1; -} - -/*****************************************************************************/ -void -mi_update_screen(void) -{ - int r; - int g; - int b; - - if (g_no_draw) - { - return; - } - if (g_rect.w > 0 && g_rect.h > 0) - { -#ifdef USE_ORDERS_NOT - DFBRegion reg; - reg.x1 = 0; - reg.y1 = 0; - reg.x2 = g_width; - reg.y2 = g_height; - g_primary->SetClip(g_primary, ®); -#endif -#ifdef USE_FLIPPING - g_primary->Blit(g_primary, g_primary, 0, 0, 0); - g_primary->Blit(g_primary, g_s, &g_rect, g_rect.x, g_rect.y); - g_primary->Flip(g_primary, 0, 0); -#else - g_primary->Blit(g_primary, g_s, &g_rect, g_rect.x, g_rect.y); - if (g_use_trans) - { - r = (g_trans_colour >> 16) & 0xff; - g = (g_trans_colour >> 8) & 0xff; - b = g_trans_colour & 0xff; - g_primary->SetDrawingFlags(g_primary, DSDRAW_DST_COLORKEY); - g_primary->SetDstColorKey(g_primary, r, g, b); - g_primary->SetColor(g_primary, r, g, b, 0); - g_primary->FillRectangle(g_primary, g_rect.x, g_rect.y, g_rect.w, g_rect.h); - g_primary->SetDrawingFlags(g_primary, DSDRAW_NOFX); - } -#endif -#ifdef USE_ORDERS_NOT - g_primary->SetClip(g_primary, &g_reg); -#endif - } - g_rect.x = 0; - g_rect.y = 0; - g_rect.w = 0; - g_rect.h = 0; -} - -/*****************************************************************************/ -void process_event(DFBEvent * event) -{ - DFBInputEvent * input_event; - int mouse_x; - int mouse_y; - - mouse_x = g_mouse_x + g_mcursor.x; - mouse_y = g_mouse_y + g_mcursor.y; - if (event->clazz == DFEC_INPUT) - { - input_event = (DFBInputEvent *) event; - if (input_event->type == DIET_AXISMOTION) - { - if (input_event->flags & DIEF_AXISABS) - { - if (input_event->axis == DIAI_X) - { - mouse_x = input_event->axisabs; - } - else if (input_event->axis == DIAI_Y) - { - mouse_y = input_event->axisabs; - } - } - if (input_event->flags & DIEF_AXISREL) - { - if (input_event->axis == DIAI_X) - { - mouse_x += input_event->axisrel; - } - else if (input_event->axis == DIAI_Y) - { - mouse_y += input_event->axisrel; - } - } - mouse_x = UI_MAX(mouse_x, 0); - mouse_x = UI_MIN(mouse_x, g_width - 1); - mouse_y = UI_MAX(mouse_y, 0); - mouse_y = UI_MIN(mouse_y, g_height - 1); - ui_mouse_move(mouse_x, mouse_y); - } - else if (input_event->type == DIET_BUTTONPRESS) - { - if (input_event->button == DIBI_LEFT) - { - ui_mouse_button(1, mouse_x, mouse_y, 1); - //rdp_send_input(0, RDP_INPUT_MOUSE, - // MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, - // mouse_x, mouse_y); - } - else if (input_event->button == DIBI_RIGHT) - { - //mi_update_screen(); - ui_mouse_button(2, mouse_x, mouse_y, 1); -// invalidate(0, 0, g_width, g_height); - //rdp_send_input(0, RDP_INPUT_MOUSE, - // MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2, - // mouse_x, mouse_y); - } - else if (input_event->button == DIBI_MIDDLE) - { - ui_mouse_button(3, mouse_x, mouse_y, 1); - } - } - else if (input_event->type == DIET_BUTTONRELEASE) - { - if (input_event->button == DIBI_LEFT) - { - ui_mouse_button(1, mouse_x, mouse_y, 0); - //rdp_send_input(0, RDP_INPUT_MOUSE, - // MOUSE_FLAG_BUTTON1, - // mouse_x, mouse_y); - } - else if (input_event->button == DIBI_RIGHT) - { - ui_mouse_button(2, mouse_x, mouse_y, 0); - //rdp_send_input(0, RDP_INPUT_MOUSE, - // MOUSE_FLAG_BUTTON2, - // mouse_x, mouse_y); - } - else if (input_event->button == DIBI_MIDDLE) - { - ui_mouse_button(3, mouse_x, mouse_y, 0); - } - } - else if (input_event->type == DIET_KEYPRESS) - { - //printf("hi1 %d\n", input_event->key_id); - return; - } - else if (input_event->type == DIET_KEYRELEASE) - { - //printf("hi2 %d\n", input_event->key_id); - return; - } - } - g_mouse_x = mouse_x - g_mcursor.x; - g_mouse_y = mouse_y - g_mcursor.y; -// printf("%d %d\n", g_mouse_x, g_mouse_y); - g_primary->SetColor(g_primary, 0, 0, 0, 0xff); - g_primary->FillRectangle(g_primary, g_mouse_x, g_mouse_y, 5, 5); -// draw_mouse(); -} - -/*****************************************************************************/ -int -mi_main_loop(void) -{ - fd_set rfds; - int rv; - int fd; - DFBEvent event[10]; - struct timeval tv; - - fd = g_tcp_sck; - FD_ZERO(&rfds); - FD_SET(g_tcp_sck, &rfds); - tv.tv_sec = 0; - tv.tv_usec = 0; - rv = select(fd + 1, &rfds, 0, 0, &tv); - while (rv > -1) - { - if (g_event->HasEvent(g_event) == DFB_OK) - { - if (g_event->GetEvent(g_event, &event[0]) == 0) - { - process_event(&event[0]); - } - } - if (rv > 0) - { - if (FD_ISSET(g_tcp_sck, &rfds)) - { - if (!ui_read_wire()) - { - return 0; - } - } - } - else - { - //usleep(1000000 / 60); - usleep(0); - } - FD_ZERO(&rfds); - FD_SET(g_tcp_sck, &rfds); - tv.tv_sec = 0; - tv.tv_usec = 0; - rv = select(fd + 1, &rfds, 0, 0, &tv); - } - return 0; -} - -/*****************************************************************************/ -void -mi_add_to(int x, int y, int cx, int cy) -{ - int right; - int bottom; - - if (g_rect.h == 0 && g_rect.w == 0) - { - g_rect.x = x; - g_rect.y = y; - g_rect.w = cx; - g_rect.h = cy; - } - else - { - right = g_rect.x + g_rect.w; - bottom = g_rect.y + g_rect.h; - if (x + cx > right) - { - right = x + cx; - } - if (y + cy > bottom) - { - bottom = y + cy; - } - if (x < g_rect.x) - { - g_rect.x = x; - } - if (y < g_rect.y) - { - g_rect.y = y; - } - g_rect.w = right - g_rect.x; - g_rect.h = bottom - g_rect.y; - } -} - -/*****************************************************************************/ -void -mi_invalidate(int x, int y, int cx, int cy) -{ - mi_add_to(x, y, cx, cy); - mi_update_screen(); -} - -/*****************************************************************************/ -void * -update_thread(void * arg) -{ - struct timeval ltime; - struct timeval ntime; - int nsecs; - - gettimeofday(<ime, 0); - while (g_bs != 0) - { - gettimeofday(&ntime, 0); - nsecs = (ntime.tv_sec - ltime.tv_sec) * 1000000 + (ntime.tv_usec - ltime.tv_usec); - nsecs = (1000000 / 12) - nsecs; - if (nsecs < 0) - { - nsecs = 0; - } - usleep(nsecs); - gettimeofday(<ime, 0); - pthread_mutex_lock(&g_mutex1); - mi_update_screen(); - pthread_mutex_unlock(&g_mutex1); - } - return 0; -} - -/*****************************************************************************/ -/* return boolean */ -int -mi_create_bs(void) -{ - //pthread_t thread; - DFBSurfaceDescription dsc; - - g_bs = malloc(g_width * g_height * 4); - dsc.flags = DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT | - DSDESC_PREALLOCATED | DSDESC_PIXELFORMAT; - dsc.caps = DSCAPS_SYSTEMONLY; - dsc.width = g_width; - dsc.height = g_height; - dsc.pixelformat = DSPF_AiRGB; - dsc.preallocated[0].data = g_bs; - dsc.preallocated[0].pitch = g_width * 4; - if (g_dfb->CreateSurface(g_dfb, &dsc, &g_s) == 0) - { - //pthread_create(&thread, 0, update_thread, 0); - //pthread_detach(thread); - } - else - { - g_s = 0; - free(g_bs); - g_bs = 0; - return 0; - } - return 1; -} - -/*****************************************************************************/ -void -mi_begin_update(void) -{ - pthread_mutex_lock(&g_mutex1); -} - -/*****************************************************************************/ -void -mi_end_update(void) -{ - pthread_mutex_unlock(&g_mutex1); - if (g_show_wfp) - { - printf("pixel at %d %d is %d\n", g_wfpx, g_wfpy, bs_get_pixel(g_wfpx, g_wfpy)); - } - if (g_no_draw) - { - if (g_wfpv == bs_get_pixel(g_wfpx, g_wfpy)) - { - g_no_draw = 0; - mi_invalidate(0, 0, g_width, g_height); - } - } - -} - -/*****************************************************************************/ -void -mi_fill_rect(int x, int y, int cx, int cy, int colour) -{ - if (g_no_draw) - { - return; - } -#ifdef USE_ORDERS - int red; - int green; - int blue; - - mi_update_screen(); - red = (colour & 0xff0000) >> 16; - green = (colour & 0xff00) >> 8; - blue = colour & 0xff; - if (g_use_trans && g_trans_colour == colour) - { - g_primary->SetColor(g_primary, red, green, blue, 0); - } - else - { - g_primary->SetColor(g_primary, red, green, blue, 0xff); - } - g_primary->FillRectangle(g_primary, x, y, cx, cy); -#else - mi_add_to(x, y, cx, cy); -#endif -} - -/*****************************************************************************/ -void -mi_line(int x1, int y1, int x2, int y2, int colour) -{ - if (g_no_draw) - { - return; - } -#ifdef USE_ORDERS_TOO_SLOW - int red; - int green; - int blue; - - mi_update_screen(); - red = (colour >> 16) & 0xff; - green = (colour >> 8) & 0xff; - blue = colour & 0xff; - if (g_use_trans && g_trans_colour == colour) - { - g_primary->SetColor(g_primary, red, green, blue, 0); - } - else - { - g_primary->SetColor(g_primary, red, green, blue, 0xff); - } - g_primary->DrawLine(g_primary, x1, y1, x2, y2); -#else - int x; - int y; - int cx; - int cy; - - x = UI_MIN(x1, x2); - y = UI_MIN(y1, y2); - cx = (UI_MAX(x1, x2) + 1) - x; - cy = (UI_MAX(y1, y2) + 1) - y; - mi_add_to(x, y, cx, cy); -#endif -} - -/*****************************************************************************/ -void -mi_screen_copy(int x, int y, int cx, int cy, int srcx, int srcy) -{ - if (g_no_draw) - { - return; - } -#ifdef USE_ORDERS - DFBRectangle rect; - DFBSurfaceDescription dsc; - IDirectFBSurface * surface; - - mi_update_screen(); - //if (srcy < y) - { - dsc.flags = DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT; - dsc.caps = DSCAPS_VIDEOONLY; - dsc.width = cx; - dsc.height = cy; - if (g_dfb->CreateSurface(g_dfb, &dsc, &surface) == 0) - { - rect.x = srcx; - rect.y = srcy; - rect.w = cx; - rect.h = cy; - surface->Blit(surface, g_primary, &rect, 0, 0); - g_primary->Blit(g_primary, surface, 0, x, y); - surface->Release(surface); - } - } - //else - //{ - // rect.x = srcx; - // rect.y = srcy; - // rect.w = cx; - // rect.h = cy; - // g_primary->Blit(g_primary, g_primary, &rect, x, y); - //} -#else - mi_add_to(x, y, cx, cy); -#endif -} - -/*****************************************************************************/ -void -mi_set_clip(int x, int y, int cx, int cy) -{ -#ifdef USE_ORDERS - g_reg.x1 = x; - g_reg.y1 = y; - g_reg.x2 = (x + cx) - 1; - g_reg.y2 = (y + cy) - 1; - g_primary->SetClip(g_primary, &g_reg); -#endif -} - -/*****************************************************************************/ -void -mi_reset_clip(void) -{ -#ifdef USE_ORDERS -// this dosen't work, directb bug? -// g_primary->SetClip(g_primary, 0); - g_reg.x1 = 0; - g_reg.y1 = 0; - g_reg.x2 = g_width; - g_reg.y2 = g_height; - g_primary->SetClip(g_primary, &g_reg); -#endif -} - -/*****************************************************************************/ -void * -mi_create_cursor(unsigned int x, unsigned int y, - int width, int height, - unsigned char * andmask, unsigned char * xormask) -{ - return (void *) 1; -} - -/*****************************************************************************/ -void -mi_destroy_cursor(void * cursor) -{ -} - -/*****************************************************************************/ -void -mi_set_cursor(void * cursor) -{ -} - -/*****************************************************************************/ -void -mi_set_null_cursor(void) -{ -} - -/*****************************************************************************/ -void -mi_logon(void) -{ - if (master_callback != 0) - { - master_callback(1, 0, 0); - } -} - -/*****************************************************************************/ -static void -out_params(void) -{ - fprintf(stderr, "rdesktop: A Remote Desktop Protocol client.\n"); - fprintf(stderr, "Version 1.4.1. Copyright (C) 1999-2006 Matt Chapman.\n"); - fprintf(stderr, "direct framebuffer uiport by Jay Sorg\n"); - fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n"); - fprintf(stderr, "Usage: dfbrdesktop [options] server\n"); - fprintf(stderr, " -u: user name\n"); - fprintf(stderr, " -n: client hostname\n"); - fprintf(stderr, " -s: shell\n"); - fprintf(stderr, " -p: password\n"); - fprintf(stderr, " -d: domain\n"); - fprintf(stderr, " -c: working directory\n"); - fprintf(stderr, " -a: colour depth\n"); - fprintf(stderr, " -wfp x y pixel: skip screen updates till x, y pixel is \ -this colour\n"); - fprintf(stderr, " -trans pixel: transparent colour\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], "-u") == 0) - { - strcpy(g_username, in_argv[i + 1]); - } - else if (strcmp(in_argv[i], "-n") == 0) - { - strcpy(g_hostname, in_argv[i + 1]); - } - else if (strcmp(in_argv[i], "-s") == 0) - { - strcpy(g_shell, in_argv[i + 1]); - } - else if (strcmp(in_argv[i], "-p") == 0) - { - strcpy(g_password, in_argv[i + 1]); - } - else if (strcmp(in_argv[i], "-d") == 0) - { - strcpy(g_domain, in_argv[i + 1]); - } - else if (strcmp(in_argv[i], "-c") == 0) - { - strcpy(g_directory, in_argv[i + 1]); - } - else if (strcmp(in_argv[i], "-a") == 0) - { - g_server_depth = atoi(in_argv[i + 1]); - } - else if (strcmp(in_argv[i], "-wfp") == 0) - { - g_wfpx = atoi(in_argv[i + 1]); - g_wfpy = atoi(in_argv[i + 2]); - g_wfpv = atoi(in_argv[i + 3]); - if (g_wfpv == 0) - { - g_show_wfp = 1; - } - else - { - g_no_draw = 1; - } - } - else if (strcmp(in_argv[i], "-trans") == 0) - { - g_use_trans = 1; - g_trans_colour = atoi(in_argv[i + 1]); - } - } - return 1; -} - -/*****************************************************************************/ -int -main(int argc, char ** argv) -{ - int rv; - DFBSurfaceDescription dsc; - DFBResult err; - - strcpy(g_hostname, "test"); - g_server_depth = 24; - if (!parse_parameters(argc, argv)) - { - return 0; - } - err = DirectFBInit(&argc, &argv); - if (err == 0) - { - err = DirectFBCreate(&g_dfb); - } - if (err == 0) - { - err = g_dfb->SetCooperativeLevel(g_dfb, DFSCL_FULLSCREEN); - } - if (err == 0) - { - dsc.flags = DSDESC_CAPS; -#ifdef USE_FLIPPING - dsc.caps = DSCAPS_PRIMARY | DSCAPS_DOUBLE | DSCAPS_FLIPPING; -#else - dsc.caps = DSCAPS_PRIMARY; -#endif - err = g_dfb->CreateSurface(g_dfb, &dsc, &g_primary); - } - if (err == 0) - { - g_dfb->CreateInputEventBuffer(g_dfb, DICAPS_AXES | DICAPS_BUTTONS | - DICAPS_KEYS, 0, &g_event); - } - if (err == 0) - { - err = g_primary->GetSize(g_primary, &g_width, &g_height); - } - if (err != 0) - { - printf("error in main\n"); - return 1; - } - rv = ui_main(); - g_s->Release(g_s); - g_primary->Release(g_primary); - g_dfb->Release(g_dfb); - return rv; -} - -/*****************************************************************************/ -/* returns non zero ok */ -int -librdesktop_init(long obj1, long obj2, long obj3, int in_argc, char ** in_argv) -{ - strcpy(g_hostname, "test"); - g_dfb = (IDirectFB *) obj1; - g_primary = (IDirectFBSurface *) obj2; - g_primary->GetSize(g_primary, &g_width, &g_height); - g_server_depth = 24; - if (!parse_parameters(in_argc, in_argv)) - { - return 0; - } - return 1; -} - -/*****************************************************************************/ -/* returns non zero ok */ -int -librdesktop_connect(void) -{ - return ui_lib_main(); -} - -/*****************************************************************************/ -/* returns non zero ok */ -int -librdesktop_check_wire(void) -{ - fd_set rfds; - int rv; - int fd; - struct timeval tv; - - fd = g_tcp_sck; - FD_ZERO(&rfds); - FD_SET(g_tcp_sck, &rfds); - tv.tv_sec = 0; - tv.tv_usec = 0; - rv = select(fd + 1, &rfds, 0, 0, &tv); - if (rv > -1) - { - if (rv > 0) - { - if (FD_ISSET(g_tcp_sck, &rfds)) - { - if (!ui_read_wire()) - { - return 0; - } - } - } - } - return 1; -} - -/*****************************************************************************/ -int -librdesktop_mouse_move(int x, int y) -{ - ui_mouse_move(x, y); - return 0; -} - -/*****************************************************************************/ -int -librdesktop_mouse_button(int button, int x, int y, int down) -{ - ui_mouse_button(button, x, y, down); - return 0; -} - -/*****************************************************************************/ -int -librdesktop_key_down(int key, int ext) -{ - ui_key_down(key, ext); - return 0; -} - -/*****************************************************************************/ -int -librdesktop_key_up(int key, int ext) -{ - ui_key_up(key, ext); - return 0; -} - -/*****************************************************************************/ -int -librdesktop_quit(void) -{ - return 1; -} - -/*****************************************************************************/ -int -librdesktop_set_callback(void (* callback)(int, int, int)) -{ - master_callback = callback; - return 0; -} diff --git a/uirdesktop/fb.c b/uirdesktop/fb.c deleted file mode 100644 index f45b1b14..00000000 --- a/uirdesktop/fb.c +++ /dev/null @@ -1,1202 +0,0 @@ -/* -*- c-basic-offset: 8 -*- - rdesktop: A Remote Desktop Protocol client. - fb calls - Copyright (C) Jay Sorg 2006 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "uimain.h" -#include "bsops.h" - -extern char g_username[]; -extern char g_hostname[]; -extern char g_servername[]; -extern char g_password[]; -extern char g_shell[]; -extern char g_directory[]; -extern char g_domain[]; -extern int g_width; -extern int g_height; -extern int g_tcp_sck; -extern int g_server_depth; -extern int g_tcp_port_rdp; /* in tcp.c */ -extern int g_bytes_in; -extern int pal_entries[]; - -extern int g_bs_bpp; -extern int g_bs_Bpp; -extern char * g_bs; - - -static int g_bpp = 8; -static int g_Bpp = 1; - -/* keys */ -struct key -{ - int scancode; - int rdpcode; - int ext; -}; -static struct key g_keys[256]; -static char g_keyfile[64] = "./default.key"; - -struct cursor -{ - unsigned char andmask[32 * 32]; - unsigned char xormask[32 * 32]; - int x; - int y; - int w; - int h; -}; -static struct cursor g_mcursor; /* current mouse */ -static int g_mouse_x = 0; -static int g_mouse_y = 0; -static int g_mouse_buttons = 0; /* mouse button states */ -static int g_mousefd = 0; /* mouse fd */ -static int g_mouse_state = 0; /* used when reading mouse device */ - -static int g_uts = 0; /* updates to skip */ -static int g_alt_down = 0; /* used to disable control alt delete */ -static int g_control_down = 0; -static int g_shift_down = 0; -static int g_disable_cad = 0; /* disable control alt delete */ - /* and ctrl shift esc */ -static int g_wfpx = 0; /* wait for pixel stuff */ -static int g_wfpy = 0; -static int g_wfpv = 0; -static int g_show_wfp = 0; -static int g_no_draw = 0; /* this means don't draw the screen but draw on - backingstore */ -/* for transparent colour */ -static int g_use_trans = 0; -static int g_trans_colour = 0; - - -/* clip */ -static int g_clip_left = 0; -static int g_clip_top = 0; -static int g_clip_right = 0; -static int g_clip_bottom = 0; - -static int g_kbfd = 0; /* keyboard fd */ - -static int g_fbfd = 0; /* framebuffer fd */ -static char * g_sdata = 0; -static struct fb_var_screeninfo g_vinfo; -static struct fb_fix_screeninfo g_finfo; - -static short g_saved_red[256]; /* original hw palette */ -static short g_saved_green[256]; -static short g_saved_blue[256]; - -struct my_rect -{ - int x; - int y; - int w; - int h; -}; -static struct my_rect g_rect = {0, 0, 0, 0}; - -/*****************************************************************************/ -void -mi_error(char * msg) -{ - printf(msg); -} - -/*****************************************************************************/ -void -mi_warning(char * msg) -{ - printf(msg); -} - -/*****************************************************************************/ -int -mi_read_keyboard_state(void) -{ - return 0; -} - -/*****************************************************************************/ -/* returns non zero if ok */ -int -mi_create_window(void) -{ - return 1; -} - -/*****************************************************************************/ -void -mi_update_screen(void) -{ - int i; - int j; - int endi; - int endj; - int x; - int y; - int pixel; - int r; - int g; - int b; - - if (g_no_draw) - { - return; - } - endi = UI_MIN(g_rect.y + g_rect.h, g_clip_bottom); - endj = UI_MIN(g_rect.x + g_rect.w, g_clip_right); - x = UI_MAX(g_rect.x, g_clip_left); - y = UI_MAX(g_rect.y, g_clip_top); - //printf("hi %d %d %d %d\n", x, y, endi, endj); - if (g_bpp == 16 && g_bs_bpp == 32) - { - for (i = y; i < endi; i++) - { - for (j = x; j < endj; j++) - { - pixel = ((unsigned int *) g_bs)[i * g_width + j]; - SPLIT_COLOUR32(pixel, b, g, r); - MAKE_COLOUR16(pixel, r, g, b); - ((unsigned short *) g_sdata)[i * g_width + j] = pixel; - } - } - } - g_rect.x = 0; - g_rect.y = 0; - g_rect.w = 0; - g_rect.h = 0; - //printf("bye\n"); -} - -/*****************************************************************************/ -static void -process_keyboard(void) -{ - char buf[128]; - unsigned char ch; - int count; - int index; - int keyup; - int rdpkey; - int ext; - - ext = 0; - index = 0; - count = read(g_kbfd, buf, 128); - while (index < count) - { - ch = (unsigned char)buf[index]; - //printf("%2.2x\n", ch); - keyup = ch & 0x80; - rdpkey = ch & 0x7f; - ext = g_keys[rdpkey].ext ? 0x100 : 0; - rdpkey = g_keys[rdpkey].rdpcode; - if (rdpkey == 0x1d) /* control */ - { - g_control_down = !keyup; - } - if (rdpkey == 0x38) /* alt */ - { - g_alt_down = !keyup; - } - if (rdpkey == 0x2a || rdpkey == 0x36) /* shift */ - { - g_shift_down = !keyup; - } - if (g_disable_cad) /* diable control alt delete and control shift escape */ - { - if (rdpkey == 0x53 && g_alt_down && g_control_down) /* delete */ - { - rdpkey = 0; - } - if (rdpkey == 0x01 && g_shift_down && g_control_down) /* escape */ - { - rdpkey = 0; - } - } - if (rdpkey > 0 && g_mouse_buttons == 0) - { - if (!keyup) - { - ui_key_down(rdpkey, ext); - } - else - { - ui_key_up(rdpkey, ext); - } - } - index++; - } -} - -/*****************************************************************************/ -static int -process_mouse(void) -{ - char d[128]; - int c; - int i; - int b; - int old_x; - int old_y; - int old_but1; - int old_but2; - int mouse_x; /* hot spot */ - int mouse_y; /* hot spot */ - - mouse_x = g_mouse_x + g_mcursor.x; - mouse_y = g_mouse_y + g_mcursor.y; - old_x = mouse_x; - old_y = mouse_y; - old_but1 = g_mouse_buttons & 1; - old_but2 = g_mouse_buttons & 2; - c = read(g_mousefd, &d, 128); - for (i = 0; i < c; i++) - { - b = (unsigned char)d[i]; - switch (g_mouse_state) - { - case 0: - if (b & 0x08) /* PS2_CTRL_BYTE */ - { - g_mouse_buttons = b & (1 | 2); - g_mouse_state = 1; - } - break; - case 1: /* x */ - if (b > 127) - { - b -= 256; - } - mouse_x += b; - if (mouse_x < 0) - { - mouse_x = 0; - } - else if (mouse_x >= g_width) - { - mouse_x = g_width - 1; - } - g_mouse_state = 2; - break; - case 2: /* y */ - if (b > 127) - { - b -= 256; - } - mouse_y += -b; - if (mouse_y < 0) - { - mouse_y = 0; - } - else if (mouse_y >= g_height) - { - mouse_y = g_height - 1; - } - g_mouse_state = 0; - break; - } - } - if (old_x != mouse_x || old_y != mouse_y) /* mouse pos changed */ - { - ui_mouse_move(mouse_x, mouse_y); - } - if (old_but1 != (g_mouse_buttons & 1)) /* left button changed */ - { - if (g_mouse_buttons & 1) - { - ui_mouse_button(1, mouse_x, mouse_y, 1); - } - else - { - ui_mouse_button(1, mouse_x, mouse_y, 0); - } - } - if (old_but2 != (g_mouse_buttons & 2)) /* right button changed */ - { - if (g_mouse_buttons & 2) - { - ui_mouse_button(2, mouse_x, mouse_y, 1); - } - else - { - ui_mouse_button(2, mouse_x, mouse_y, 0); - } - } - //undraw_mouse(); - g_mouse_x = mouse_x - g_mcursor.x; - g_mouse_y = mouse_y - g_mcursor.y; - //draw_mouse(); - return 0; -} - -/*****************************************************************************/ -int -mi_main_loop(void) -{ - fd_set rfds; -// fd_set wfds; - int rv; - int fd; - struct timeval tv; - - fd = UI_MAX(g_tcp_sck, UI_MAX(g_mousefd, g_kbfd)); - FD_ZERO(&rfds); - FD_SET(g_tcp_sck, &rfds); - FD_SET(g_mousefd, &rfds); - FD_SET(g_kbfd, &rfds); - tv.tv_sec = 0; - tv.tv_usec = 0; - rv = select(fd + 1, &rfds, 0, 0, &tv); - while (rv > -1) - { - if (rv == 0) - { - usleep(0); - } - if (FD_ISSET(g_kbfd, &rfds)) - { - process_keyboard(); - } - if (FD_ISSET(g_mousefd, &rfds)) - { - process_mouse(); - } - if (FD_ISSET(g_tcp_sck, &rfds)) - { - if (!ui_read_wire()) - { - return 0; - } - } - fd = UI_MAX(g_tcp_sck, UI_MAX(g_mousefd, g_kbfd)); - FD_ZERO(&rfds); - FD_SET(g_tcp_sck, &rfds); - FD_SET(g_mousefd, &rfds); - FD_SET(g_kbfd, &rfds); -#ifdef WITH_RDPSND -// if (g_rdpsnd && g_dsp_busy) -// { -// fd = MAX(fd, g_dsp_fd); -// FD_ZERO(&wfds); -// FD_SET(g_dsp_fd, &wfds); -// rv = select(fd + 1, &rfds, &wfds, 0, 0); -// if (rv > 0 && FD_ISSET(g_dsp_fd, &wfds)) -// { -// wave_out_play(); -// } -// } -// else -// { -// rv = select(fd + 1, &rfds, 0, 0, 0); -// } -#else - tv.tv_sec = 0; - tv.tv_usec = 0; - rv = select(fd + 1, &rfds, 0, 0, &tv); -#endif - } - return 0; -} - -/*****************************************************************************/ -void -mi_add_to(int x, int y, int cx, int cy) -{ - int right; - int bottom; - - if (g_rect.h == 0 && g_rect.w == 0) - { - g_rect.x = x; - g_rect.y = y; - g_rect.w = cx; - g_rect.h = cy; - } - else - { - right = g_rect.x + g_rect.w; - bottom = g_rect.y + g_rect.h; - if (x + cx > right) - { - right = x + cx; - } - if (y + cy > bottom) - { - bottom = y + cy; - } - if (x < g_rect.x) - { - g_rect.x = x; - } - if (y < g_rect.y) - { - g_rect.y = y; - } - g_rect.w = right - g_rect.x; - g_rect.h = bottom - g_rect.y; - } -} - -/*****************************************************************************/ -void -mi_invalidate(int x, int y, int cx, int cy) -{ - mi_add_to(x, y, cx, cy); - mi_update_screen(); -} - -/*****************************************************************************/ -/* return boolean */ -int -mi_create_bs(void) -{ - return 1; -} - -/*****************************************************************************/ -void -mi_begin_update(void) -{ -} - -/*****************************************************************************/ -void -mi_end_update(void) -{ - int pixel; - - if (g_show_wfp) - { - printf(" %d\r\n", bs_get_pixel(g_wfpx, g_wfpy)); - } - if (g_no_draw) - { - pixel = bs_get_pixel(g_wfpx, g_wfpy); - if ((pixel & 0xffffff) == (g_wfpv & 0xffffff)) - { - g_no_draw = 0; - mi_invalidate(0, 0, g_width, g_height); - } - } -} - -/*****************************************************************************/ -void -mi_fill_rect(int x, int y, int cx, int cy, int colour) -{ - if (g_no_draw) - { - return; - } - mi_add_to(x, y, cx, cy); - mi_update_screen(); -} - -/*****************************************************************************/ -void -mi_line(int x1, int y1, int x2, int y2, int colour) -{ - if (g_no_draw) - { - return; - } - int x; - int y; - int cx; - int cy; - - x = UI_MIN(x1, x2); - y = UI_MIN(y1, y2); - cx = (UI_MAX(x1, x2) + 1) - x; - cy = (UI_MAX(y1, y2) + 1) - y; - mi_add_to(x, y, cx, cy); - mi_update_screen(); -} - -/*****************************************************************************/ -void -mi_screen_copy(int x, int y, int cx, int cy, int srcx, int srcy) -{ - if (g_no_draw) - { - return; - } - mi_add_to(x, y, cx, cy); - mi_update_screen(); -} - -/*****************************************************************************/ -void -mi_set_clip(int x, int y, int cx, int cy) -{ - g_clip_left = x; - g_clip_top = y; - g_clip_right = x + cx; - g_clip_bottom = y + cy; - g_clip_left = UI_MAX(g_clip_left, 0); - g_clip_top = UI_MAX(g_clip_top, 0); - g_clip_right = UI_MIN(g_clip_right, g_width); - g_clip_bottom = UI_MIN(g_clip_bottom, g_height); -} - -/*****************************************************************************/ -void -mi_reset_clip(void) -{ - g_clip_left = 0; - g_clip_top = 0; - g_clip_right = g_width; - g_clip_bottom = g_height; -} - -/*****************************************************************************/ -void * -mi_create_cursor(unsigned int x, unsigned int y, - int width, int height, - unsigned char * andmask, unsigned char * xormask) -{ - struct cursor * c; - int i; - int j; - - c = (struct cursor *) malloc(sizeof(struct cursor)); - memset(c, 0, sizeof(struct cursor)); - 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 (bs_is_pixel_on(andmask, j, i, 32, 1)) - { - bs_set_pixel_on(c->andmask, j, 31 - i, 32, 8, 255); - } - if (bs_is_pixel_on(xormask, j, i, 32, 1)) - { - bs_set_pixel_on(c->xormask, j, 31 - i, 32, 8, 255); - } - } - } - return c; -} - -/*****************************************************************************/ -void -mi_destroy_cursor(void * cursor) -{ - struct cursor * c; - - c = (struct cursor *) cursor; - free(c); -} - -/*****************************************************************************/ -void -mi_set_cursor(void * cursor) -{ -} - -/*****************************************************************************/ -void -mi_set_null_cursor(void) -{ -} - -/*****************************************************************************/ -static void -out_params(void) -{ - fprintf(stderr, "rdesktop: A Remote Desktop Protocol client.\n"); - fprintf(stderr, "Version 1.4.1. Copyright (C) 1999-2006 Matt Chapman.\n"); - fprintf(stderr, "direct framebuffer uiport by Jay Sorg\n"); - fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n"); - fprintf(stderr, "Usage: dfbrdesktop [options] server\n"); - fprintf(stderr, " -u: user name\n"); - fprintf(stderr, " -n: client hostname\n"); - fprintf(stderr, " -s: shell\n"); - fprintf(stderr, " -p: password\n"); - fprintf(stderr, " -d: domain\n"); - fprintf(stderr, " -c: working directory\n"); - fprintf(stderr, " -a: colour depth\n"); - fprintf(stderr, " -wfp x y pixel: skip screen updates till x, y pixel is \ -this colour\n"); - fprintf(stderr, " -trans pixel: transparent colour\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], "-u") == 0) - { - strcpy(g_username, in_argv[i + 1]); - } - else if (strcmp(in_argv[i], "-n") == 0) - { - strcpy(g_hostname, in_argv[i + 1]); - } - else if (strcmp(in_argv[i], "-s") == 0) - { - strcpy(g_shell, in_argv[i + 1]); - } - else if (strcmp(in_argv[i], "-p") == 0) - { - strcpy(g_password, in_argv[i + 1]); - } - else if (strcmp(in_argv[i], "-d") == 0) - { - strcpy(g_domain, in_argv[i + 1]); - } - else if (strcmp(in_argv[i], "-c") == 0) - { - strcpy(g_directory, in_argv[i + 1]); - } - else if (strcmp(in_argv[i], "-a") == 0) - { - g_server_depth = atoi(in_argv[i + 1]); - } - else if (strcmp(in_argv[i], "-wfp") == 0) - { - g_wfpx = atoi(in_argv[i + 1]); - g_wfpy = atoi(in_argv[i + 2]); - g_wfpv = atoi(in_argv[i + 3]); - if (g_wfpv == 0) - { - g_show_wfp = 1; - } - else - { - g_no_draw = 1; - } - } - else if (strcmp(in_argv[i], "-trans") == 0) - { - g_use_trans = 1; - g_trans_colour = atoi(in_argv[i + 1]); - } - } - return 1; -} - -/*****************************************************************************/ -static void -get_username_and_hostname(void) -{ - char fullhostname[64]; - char * p; - struct passwd * pw; - - strncpy(g_username, "unknown", 255); - strncpy(g_hostname, "unknown", 255); - pw = getpwuid(getuid()); - if (pw != 0) - { - if (pw->pw_name != 0) - { - strncpy(g_username, pw->pw_name, 255); - } - } - if (gethostname(fullhostname, sizeof(fullhostname)) != -1) - { - p = strchr(fullhostname, '.'); - if (p != 0) - { - *p = 0; - } - strncpy(g_hostname, fullhostname, 255); - } -} - -/*****************************************************************************/ -static void -save_palette(void) -{ - struct fb_cmap cmap; - - cmap.start = 0; - if (g_bpp == 15) - { - cmap.len = 16; - } - else - { - cmap.len = 256; - } - cmap.red = (unsigned short *) g_saved_red; - cmap.green = (unsigned short *) g_saved_green; - cmap.blue = (unsigned short *) g_saved_blue; - cmap.transp = 0; - ioctl(g_fbfd, FBIOGETCMAP, &cmap); -} - -/*****************************************************************************/ -static void -restore_palette(void) -{ - struct fb_cmap cmap; - - cmap.start = 0; - if (g_bpp == 15) - { - cmap.len = 16; - } - else - { - cmap.len = 256; - } - cmap.red = (unsigned short *) g_saved_red; - cmap.green = (unsigned short *) g_saved_green; - cmap.blue = (unsigned short *) g_saved_blue; - cmap.transp = 0; - ioctl(g_fbfd, FBIOPUTCMAP, &cmap); -} - -/*****************************************************************************/ -static void -set_directcolor_palette(void) -{ - short r[256]; - int i; - struct fb_cmap cmap; - - if (g_bpp == 15) - { - for (i = 0; i < 32; i++) - { - r[i] = i << 11; - } - cmap.len = 32; - } - else - { - for (i = 0; i < 256; i++) - { - r[i] = i << 8; - } - cmap.len = 256; - } - cmap.start = 0; - cmap.red = (unsigned short *) r; - cmap.green = (unsigned short *) r; - cmap.blue = (unsigned short *) r; - cmap.transp = 0; - ioctl(g_fbfd, FBIOPUTCMAP, &cmap); -} - -/*****************************************************************************/ -static int -htoi(char * val) -{ - int rv; - - rv = 0; - switch (val[0]) - { - case '1': rv = 16; break; - case '2': rv = 16 * 2; break; - case '3': rv = 16 * 3; break; - case '4': rv = 16 * 4; break; - case '5': rv = 16 * 5; break; - case '6': rv = 16 * 6; break; - case '7': rv = 16 * 7; break; - case '8': rv = 16 * 8; break; - case '9': rv = 16 * 9; break; - case 'a': rv = 16 * 10; break; - case 'b': rv = 16 * 11; break; - case 'c': rv = 16 * 12; break; - case 'd': rv = 16 * 13; break; - case 'e': rv = 16 * 14; break; - case 'f': rv = 16 * 15; break; - } - switch (val[1]) - { - case '1': rv += 1; break; - case '2': rv += 2; break; - case '3': rv += 3; break; - case '4': rv += 4; break; - case '5': rv += 5; break; - case '6': rv += 6; break; - case '7': rv += 7; break; - case '8': rv += 8; break; - case '9': rv += 9; break; - case 'a': rv += 10; break; - case 'b': rv += 11; break; - case 'c': rv += 12; break; - case 'd': rv += 13; break; - case 'e': rv += 14; break; - case 'f': rv += 15; break; - } - return rv; -} - - -/*****************************************************************************/ -static int -load_keys(void) -{ - int fd; - int len; - int index; - int i1; - int comment; - int val1; - int val2; - int val3; - char all_lines[8192]; - char line[256]; - char val[4]; - - memset(g_keys, 0, sizeof(g_keys)); - fd = open(g_keyfile, O_RDWR); - if (fd > 0) - { - i1 = 0; - line[0] = 0; - comment = 0; - len = read(fd, all_lines, 8192); - for (index = 0; index < len ; index++) - { - if (all_lines[index] == '#') - { - comment = 1; - } - else if (all_lines[index] == 13 || all_lines[index] == 10) - { - if (strlen(line) > 7) - { - val[0] = line[0]; - val[1] = line[1]; - val[2] = 0; - val1 = htoi(val); - val[0] = line[3]; - val[1] = line[4]; - val[2] = 0; - val2 = htoi(val); - val[0] = line[6]; - val[1] = line[7]; - val[2] = 0; - val3 = htoi(val); - g_keys[val1].scancode = val1; - g_keys[val1].rdpcode = val2; - g_keys[val1].ext = val3; - } - line[0] = 0; - i1 = 0; - comment = 0; - } - else if (!comment) - { - line[i1] = all_lines[index]; - i1++; - line[i1] = 0; - } - } - close(fd); - } - return 0; -} - -/*****************************************************************************/ -int -main(int in_argc, char ** in_argv) -{ - int rv; - int screensize; - struct termios new_termios; - - rv = 0; - g_server_depth = 24; - memset(&g_mcursor, 0, sizeof(struct cursor)); - get_username_and_hostname(); - /* read command line options */ - if (!parse_parameters(in_argc, in_argv)) - { - exit(0); - } - /* Open the file for reading and writing */ - g_fbfd = open("/dev/fb0", O_RDWR); - if (g_fbfd == -1) - { - printf("Error: cannot open framebuffer device.\n"); - exit(101); - } - printf("The framebuffer device was opened successfully.\n"); - /* Get fixed screen information */ - if (ioctl(g_fbfd, FBIOGET_FSCREENINFO, &g_finfo)) - { - printf("Error reading fixed information.\n"); - exit(102); - } - /* Get variable screen information */ - if (ioctl(g_fbfd, FBIOGET_VSCREENINFO, &g_vinfo)) - { - printf("Error reading variable information.\n"); - exit(103); - } - g_bpp = g_vinfo.bits_per_pixel; - g_Bpp = (g_bpp + 7) / 8; - g_width = g_vinfo.xres; - g_height = g_vinfo.yres; - g_clip_right = g_width; - g_clip_bottom = g_height; - printf("%dx%d, %dbpp\n", g_vinfo.xres, g_vinfo.yres, g_vinfo.bits_per_pixel); - /* Figure out the size of the screen in bytes */ - screensize = g_vinfo.xres * g_vinfo.yres * g_Bpp; - /* Map the device to memory */ - g_sdata = (char *) mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, - g_fbfd, 0); - g_bs = malloc(screensize); - if ((int) g_sdata == -1) - { - printf("Error: failed to map framebuffer device to memory.\n"); - exit(104); - } - printf("The framebuffer device was mapped to memory successfully.\n"); - /* open mouse */ - g_mousefd = open("/dev/mouse", O_RDWR); - if (g_mousefd == -1) - { - g_mousefd = open("/dev/psaux", O_RDWR); - } - if (g_mousefd == -1) - { - printf("Error: failed to open /dev/mouse or /dev/psaux\n"); - exit(105); - } - g_kbfd = open("/dev/tty0", O_RDWR); - if (g_kbfd == -1) - { - printf("Error: failed to open /dev/tty0\n"); - exit(106); - } - /* check fb type */ - if (g_finfo.visual != FB_VISUAL_DIRECTCOLOR && - g_finfo.visual != FB_VISUAL_TRUECOLOR) - { - printf("unsupports fb\n"); - exit(107); - } - if (g_finfo.visual == FB_VISUAL_DIRECTCOLOR) - { - /* save hardware palette */ - save_palette(); - /* set palette to match truecolor */ - set_directcolor_palette(); - } - /* clear the screen */ - mi_fill_rect(0, 0, g_width, g_height, 0); - /* connect */ -#ifdef WITH_RDPSND - /* init sound */ -// if (g_rdpsnd) -// { -// rdpsnd_init(); -// } -#endif -#if 0 - /* setup keyboard */ - ioctl(g_kbfd, KDGKBMODE, &g_org_kbmode); /* save this */ - tcgetattr(g_kbfd, &org_termios); /* save this */ - new_termios = org_termios; - new_termios.c_lflag &= ~(ICANON | ECHO | ISIG); - new_termios.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON); - new_termios.c_cc[VMIN] = 0; - new_termios.c_cc[VTIME] = 0; - tcsetattr(g_kbfd, TCSAFLUSH, &new_termios); - ioctl(g_kbfd, KDSKBMODE, K_MEDIUMRAW); -#endif - load_keys(); - /* do it all here */ - rv = ui_main(); - /* clear the screen when done */ - mi_fill_rect(0, 0, g_width, g_height, 0); - /* restore some stuff */ - if (g_finfo.visual == FB_VISUAL_DIRECTCOLOR) - { - restore_palette(); - } - munmap(g_sdata, screensize); - close(g_fbfd); - close(g_mousefd); -#if 0 - ioctl(g_kbfd, KDSKBMODE, g_org_kbmode); - tcsetattr(g_kbfd, TCSANOW, &org_termios); -#endif - close(g_kbfd); - free(g_bs); - return rv; -} - -/*****************************************************************************/ -/* returns non zero ok */ -int -librdesktop_init(long obj1, long obj2, long obj3, int in_argc, char ** in_argv) -{ - int screensize; - struct termios new_termios; - - g_server_depth = 24; - memset(&g_mcursor, 0, sizeof(struct cursor)); - get_username_and_hostname(); - /* read command line options */ - if (!parse_parameters(in_argc, in_argv)) - { - return 0; - } - /* Open the file for reading and writing */ - //g_fbfd = open("/dev/fb0", O_RDWR); - g_fbfd = obj1; - /* Get fixed screen information */ - if (ioctl(g_fbfd, FBIOGET_FSCREENINFO, &g_finfo)) - { - printf("Error reading fixed information.\n"); - return 1; - } - /* Get variable screen information */ - if (ioctl(g_fbfd, FBIOGET_VSCREENINFO, &g_vinfo)) - { - printf("Error reading variable information.\n"); - return 1; - } - g_bpp = g_vinfo.bits_per_pixel; - g_Bpp = (g_bpp + 7) / 8; - g_width = g_vinfo.xres; - g_height = g_vinfo.yres; - g_clip_right = g_width; - g_clip_bottom = g_height; - printf("%dx%d, %dbpp\n", g_vinfo.xres, g_vinfo.yres, g_vinfo.bits_per_pixel); - /* Figure out the size of the screen in bytes */ - screensize = g_vinfo.xres * g_vinfo.yres * 4; - g_sdata = (char*)obj2; - g_bs = malloc(screensize); - return 0; -} - -/*****************************************************************************/ -/* returns non zero ok */ -int -librdesktop_connect(void) -{ - return ui_lib_main(); -} - -/*****************************************************************************/ -/* returns non zero ok */ -int -librdesktop_check_wire(void) -{ - fd_set rfds; - int rv; - int fd; - struct timeval tv; - - fd = g_tcp_sck; - FD_ZERO(&rfds); - FD_SET(g_tcp_sck, &rfds); - tv.tv_sec = 0; - tv.tv_usec = 0; - rv = select(fd + 1, &rfds, 0, 0, &tv); - if (rv > -1) - { - if (rv > 0) - { - if (FD_ISSET(g_tcp_sck, &rfds)) - { - if (!ui_read_wire()) - { - return 0; - } - } - } - } - return 1; -} - -/*****************************************************************************/ -int -librdesktop_mouse_move(int x, int y) -{ - ui_mouse_move(x, y); - return 0; -} - -/*****************************************************************************/ -int -librdesktop_mouse_button(int button, int x, int y, int down) -{ - ui_mouse_button(button, x, y, down); - return 0; -} - -/*****************************************************************************/ -int -librdesktop_key_down(int key, int ext) -{ - ui_key_down(key, ext); - return 0; -} - -/*****************************************************************************/ -int -librdesktop_key_up(int key, int ext) -{ - ui_key_up(key, ext); - return 0; -} - -/*****************************************************************************/ -int -librdesktop_quit(void) -{ - return 1; -} diff --git a/uirdesktop/iso.c b/uirdesktop/iso.c deleted file mode 100644 index 163946df..00000000 --- a/uirdesktop/iso.c +++ /dev/null @@ -1,231 +0,0 @@ -/* -*- c-basic-offset: 8 -*- - rdesktop: A Remote Desktop Protocol client. - Protocol services - ISO layer - Copyright (C) Matthew Chapman 1999-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 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "rdesktop.h" - -/* Send a self-contained ISO PDU */ -static void -iso_send_msg(uint8 code) -{ - STREAM s; - - s = tcp_init(11); - - out_uint8(s, 3); /* version */ - out_uint8(s, 0); /* reserved */ - out_uint16_be(s, 11); /* length */ - - out_uint8(s, 6); /* hdrlen */ - out_uint8(s, code); - out_uint16(s, 0); /* dst_ref */ - out_uint16(s, 0); /* src_ref */ - out_uint8(s, 0); /* class */ - - s_mark_end(s); - tcp_send(s); -} - -static void -iso_send_connection_request(char *username) -{ - STREAM s; - int length = 30 + strlen(username); - - s = tcp_init(length); - - out_uint8(s, 3); /* version */ - out_uint8(s, 0); /* reserved */ - out_uint16_be(s, length); /* length */ - - out_uint8(s, length - 5); /* hdrlen */ - out_uint8(s, ISO_PDU_CR); - out_uint16(s, 0); /* dst_ref */ - out_uint16(s, 0); /* src_ref */ - out_uint8(s, 0); /* class */ - - out_uint8p(s, "Cookie: mstshash=", strlen("Cookie: mstshash=")); - out_uint8p(s, username, strlen(username)); - - out_uint8(s, 0x0d); /* Unknown */ - out_uint8(s, 0x0a); /* Unknown */ - - s_mark_end(s); - tcp_send(s); -} - -/* Receive a message on the ISO layer, return code */ -static STREAM -iso_recv_msg(uint8 * code, uint8 * rdpver) -{ - STREAM s; - uint16 length; - uint8 version; - - s = tcp_recv(NULL, 4); - if (s == NULL) - return NULL; - in_uint8(s, version); - if (rdpver != NULL) - *rdpver = version; - if (version == 3) - { - in_uint8s(s, 1); /* pad */ - in_uint16_be(s, length); - } - else - { - in_uint8(s, length); - if (length & 0x80) - { - length &= ~0x80; - next_be(s, length); - } - } - s = tcp_recv(s, length - 4); - if (s == NULL) - return NULL; - if (version != 3) - return s; - in_uint8s(s, 1); /* hdrlen */ - in_uint8(s, *code); - if (*code == ISO_PDU_DT) - { - in_uint8s(s, 1); /* eot */ - return s; - } - in_uint8s(s, 5); /* dst_ref, src_ref, class */ - return s; -} - -/* Initialise ISO transport data packet */ -STREAM -iso_init(int length) -{ - STREAM s; - - s = tcp_init(length + 7); - s_push_layer(s, iso_hdr, 7); - - return s; -} - -/* Send an ISO data PDU */ -void -iso_send(STREAM s) -{ - uint16 length; - - s_pop_layer(s, iso_hdr); - length = s->end - s->p; - - out_uint8(s, 3); /* version */ - out_uint8(s, 0); /* reserved */ - out_uint16_be(s, length); - - out_uint8(s, 2); /* hdrlen */ - out_uint8(s, ISO_PDU_DT); /* code */ - out_uint8(s, 0x80); /* eot */ - - tcp_send(s); -} - -/* Receive ISO transport data packet */ -STREAM -iso_recv(uint8 * rdpver) -{ - STREAM s; - uint8 code = 0; - - s = iso_recv_msg(&code, rdpver); - if (s == NULL) - return NULL; - if (rdpver != NULL) - if (*rdpver != 3) - return s; - if (code != ISO_PDU_DT) - { - error("expected DT, got 0x%x\n", code); - return NULL; - } - return s; -} - -/* Establish a connection up to the ISO layer */ -BOOL -iso_connect(char *server, char *username) -{ - uint8 code = 0; - - if (!tcp_connect(server)) - return False; - - iso_send_connection_request(username); - - if (iso_recv_msg(&code, NULL) == NULL) - return False; - - if (code != ISO_PDU_CC) - { - error("expected CC, got 0x%x\n", code); - tcp_disconnect(); - return False; - } - - return True; -} - -/* Establish a reconnection up to the ISO layer */ -BOOL -iso_reconnect(char *server) -{ - uint8 code = 0; - - if (!tcp_connect(server)) - return False; - - iso_send_msg(ISO_PDU_CR); - - if (iso_recv_msg(&code, NULL) == NULL) - return False; - - if (code != ISO_PDU_CC) - { - error("expected CC, got 0x%x\n", code); - tcp_disconnect(); - return False; - } - - return True; -} - -/* Disconnect from the ISO layer */ -void -iso_disconnect(void) -{ - iso_send_msg(ISO_PDU_DR); - tcp_disconnect(); -} - -/* reset the state to support reconnecting */ -void -iso_reset_state(void) -{ - tcp_reset_state(); -}