From 78cf4e67ec63512d36951ef7d8d5243824818f2e Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Thu, 8 Nov 2007 15:29:23 +0000 Subject: [PATCH] - save all settings to memory when the connect button is hit - add some slightly hackish code to get the thing working. - you should now be able to connect to Windows machines using your choice of IP address, resolution and bpp. svn path=/trunk/; revision=30274 --- .../base/applications/mstsc/connectdialog.c | 70 ++----------------- reactos/base/applications/mstsc/mstsc.rbuild | 2 +- .../applications/mstsc/mstsc_vc8_auto.vcproj | 10 +-- reactos/base/applications/mstsc/precomp.h | 58 +++++++++++++++ reactos/base/applications/mstsc/settings.c | 57 ++++++++++++++- reactos/base/applications/mstsc/win32.c | 36 ++++++++-- 6 files changed, 153 insertions(+), 80 deletions(-) diff --git a/reactos/base/applications/mstsc/connectdialog.c b/reactos/base/applications/mstsc/connectdialog.c index 4d7c23286ff..3b76fdb70eb 100644 --- a/reactos/base/applications/mstsc/connectdialog.c +++ b/reactos/base/applications/mstsc/connectdialog.c @@ -20,64 +20,8 @@ #include - #define MAX_KEY_NAME 255 -/* As slider control can't contain user data, we have to keep an - * array of RESOLUTION_INFO to have our own associated data. - */ -typedef struct _RESOLUTION_INFO -{ - DWORD dmPelsWidth; - DWORD dmPelsHeight; -} RESOLUTION_INFO, *PRESOLUTION_INFO; - -typedef struct _SETTINGS_ENTRY -{ - struct _SETTINGS_ENTRY *Blink; - struct _SETTINGS_ENTRY *Flink; - DWORD dmBitsPerPel; - DWORD dmPelsWidth; - DWORD dmPelsHeight; -} SETTINGS_ENTRY, *PSETTINGS_ENTRY; - -typedef struct _DISPLAY_DEVICE_ENTRY -{ - struct _DISPLAY_DEVICE_ENTRY *Flink; - LPWSTR DeviceDescription; - LPWSTR DeviceName; - LPWSTR DeviceKey; - LPWSTR DeviceID; - DWORD DeviceStateFlags; - PSETTINGS_ENTRY Settings; /* sorted by increasing dmPelsHeight, BPP */ - DWORD SettingsCount; - PRESOLUTION_INFO Resolutions; - DWORD ResolutionsCount; - PSETTINGS_ENTRY CurrentSettings; /* Points into Settings list */ - SETTINGS_ENTRY InitialSettings; -} DISPLAY_DEVICE_ENTRY, *PDISPLAY_DEVICE_ENTRY; - -typedef struct _INFO -{ - PRDPSETTINGS pRdpSettings; - PDISPLAY_DEVICE_ENTRY DisplayDeviceList; - PDISPLAY_DEVICE_ENTRY CurrentDisplayDevice; - HWND hSelf; - HWND hTab; - HWND hGeneralPage; - HWND hDisplayPage; - HBITMAP hHeader; - BITMAP headerbitmap; - HICON hMstscSm; - HICON hMstscLg; - HICON hLogon; - HICON hConn; - HICON hRemote; - HICON hColor; - HBITMAP hSpectrum; - BITMAP bitmap; -} INFO, *PINFO; - HINSTANCE hInst; static VOID @@ -560,15 +504,6 @@ OnResolutionChanged(PINFO pInfo, INT position) WM_SETTEXT, 0, (LPARAM)Buffer); - - /* save new settings */ - SetIntegerToSettings(pInfo->pRdpSettings, - L"desktopwidth", - pInfo->DisplayDeviceList->Resolutions[position].dmPelsWidth); - SetIntegerToSettings(pInfo->pRdpSettings, - L"desktopheight", - pInfo->DisplayDeviceList->Resolutions[position].dmPelsHeight); - } @@ -1039,6 +974,11 @@ DlgProc(HWND hDlg, { if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { + if (LOWORD(wParam) == IDOK ) + { + SaveAllSettings(pInfo); + } + if (pInfo) { HeapFree(GetProcessHeap(), diff --git a/reactos/base/applications/mstsc/mstsc.rbuild b/reactos/base/applications/mstsc/mstsc.rbuild index e0a8c09474e..58f28b16c18 100644 --- a/reactos/base/applications/mstsc/mstsc.rbuild +++ b/reactos/base/applications/mstsc/mstsc.rbuild @@ -26,8 +26,8 @@ pstcache.c rdp5.c rdp.c - rdpfile.c secure.c + settings.c ssl_calls.c tcp.c uimain.c diff --git a/reactos/base/applications/mstsc/mstsc_vc8_auto.vcproj b/reactos/base/applications/mstsc/mstsc_vc8_auto.vcproj index e28d68ab87e..1657e1650ae 100644 --- a/reactos/base/applications/mstsc/mstsc_vc8_auto.vcproj +++ b/reactos/base/applications/mstsc/mstsc_vc8_auto.vcproj @@ -48,7 +48,7 @@ BufferSecurityCheck="false" EnableFunctionLevelLinking="false" UsePrecompiledHeader="0" - WarningLevel="4" + WarningLevel="3" Detect64BitPortabilityProblems="false" DebugInformationFormat="4" CallingConvention="0" @@ -605,11 +605,11 @@ > - - #define NUM_SETTINGS 6 -LPWSTR lpSettings[NUM_SETTINGS] = +LPWSTR lpSettings[NUM_SETTINGS] = { L"screen mode id", L"desktopwidth", @@ -12,6 +12,61 @@ LPWSTR lpSettings[NUM_SETTINGS] = L"compression", }; +VOID +SaveAllSettings(PINFO pInfo) +{ + INT ret; + WCHAR szKey[MAXKEY]; + WCHAR szValue[MAXVALUE]; + + /* server */ + if (GetDlgItemText(pInfo->hGeneralPage, + IDC_SERVERCOMBO, + szValue, + MAXVALUE)) + { + SetStringToSettings(pInfo->pRdpSettings, + L"full address", + szValue); + } + + /* resolution */ + ret = SendDlgItemMessage(pInfo->hDisplayPage, + IDC_GEOSLIDER, + TBM_GETPOS, + 0, + 0); + if (ret != -1) + { + SetIntegerToSettings(pInfo->pRdpSettings, + L"desktopwidth", + pInfo->DisplayDeviceList->Resolutions[ret].dmPelsWidth); + SetIntegerToSettings(pInfo->pRdpSettings, + L"desktopheight", + pInfo->DisplayDeviceList->Resolutions[ret].dmPelsHeight); + } + + /* bpp */ + ret = SendDlgItemMessage(pInfo->hDisplayPage, + IDC_BPPCOMBO, + CB_GETCURSEL, + 0, + 0); + if (ret != CB_ERR) + { + ret = SendDlgItemMessage(pInfo->hDisplayPage, + IDC_BPPCOMBO, + CB_GETITEMDATA, + ret, + 0); + if (ret != CB_ERR) + { + SetIntegerToSettings(pInfo->pRdpSettings, + L"session bpp", + ret); + } + } +} BOOL diff --git a/reactos/base/applications/mstsc/win32.c b/reactos/base/applications/mstsc/win32.c index 10b1bd2a9df..944d3c23627 100644 --- a/reactos/base/applications/mstsc/win32.c +++ b/reactos/base/applications/mstsc/win32.c @@ -21,6 +21,10 @@ #include /* winsock2.h first */ #include +//FIXME: remove eventually +#define _UNICODE +#include + extern char g_username[]; extern char g_hostname[]; @@ -76,6 +80,21 @@ str_to_uni(TCHAR * sizex, char * size1) sizex[len] = 0; } +/*****************************************************************************/ +static void +uni_to_str(char * sizex, TCHAR * size1) +{ + int len; + int i; + + len = _tcslen(size1); + for (i = 0; i < len; i++) + { + sizex[i] = size1[i]; + } + sizex[len] = 0; +} + /*****************************************************************************/ /* returns non zero if it processed something */ static int @@ -1290,13 +1309,18 @@ wWinMain(HINSTANCE hInstance, if (OpenRDPConnectDialog(hInstance, pRdpSettings)) { - strcpy(g_servername, "192.168.40.50"); + char szValue[MAXVALUE]; + + uni_to_str(szValue, GetStringFromSettings(pRdpSettings, L"full address")); + + strcpy(g_servername, szValue); //g_port = 3389; - strcpy(g_username, "buildbot"); - strcpy(g_password, "P4ssw0rd"); - g_server_depth = 16; - g_width = 800; - g_height = 600; + strcpy(g_username, ""); + strcpy(g_password, ""); + g_server_depth = GetIntegerFromSettings(pRdpSettings, L"session bpp"); + if (g_server_depth > 16) g_server_depth = 16; /* hack, we don't support 24bpp yet */ + g_width = GetIntegerFromSettings(pRdpSettings, L"desktopwidth"); + g_height = GetIntegerFromSettings(pRdpSettings, L"desktopheight"); g_screen_width = GetSystemMetrics(SM_CXSCREEN); g_screen_height = GetSystemMetrics(SM_CYSCREEN); g_xoff = GetSystemMetrics(SM_CXEDGE) * 2;