Exemple #1
0
LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	LONG ptr;
	wfContext* wfc;
	int x, y, w, h;
	PAINTSTRUCT ps;
	rdpInput* input;
	BOOL processed;
	RECT windowRect;
	RECT clientRect;
	MINMAXINFO* minmax;
	SCROLLINFO si;

	processed = TRUE;
	ptr = GetWindowLongPtr(hWnd, GWLP_USERDATA);
	wfc = (wfContext*) ptr;

	if (wfc != NULL)
	{
		input = wfc->instance->input;

		switch (Msg)
		{
			case WM_MOVE:
				if (!wfc->disablewindowtracking)
				{
					int x = (int)(short) LOWORD(lParam);
					int y = (int)(short) HIWORD(lParam);
					wfc->client_x = x;
					wfc->client_y = y;
				}
				break;

			case WM_GETMINMAXINFO:
				if (wfc->instance->settings->SmartSizing)
				{
					processed = FALSE;
				}
				else
				{
					// Set maximum window size for resizing

					minmax = (MINMAXINFO*) lParam;
					wf_update_canvas_diff(wfc);

					if (!wfc->fullscreen)
					{
						// add window decoration
						minmax->ptMaxTrackSize.x = wfc->width + wfc->diff.x;
						minmax->ptMaxTrackSize.y = wfc->height + wfc->diff.y;
					}
				}
				break;

			case WM_SIZING:
				wf_sizing(wfc, lParam, wParam);
				break;
			
			case WM_SIZE:
				GetWindowRect(wfc->hwnd, &windowRect);
				
				if (!wfc->fullscreen)
				{
					wfc->client_width = LOWORD(lParam);
					wfc->client_height = HIWORD(lParam);
					wfc->client_x = windowRect.left;
					wfc->client_y = windowRect.top;
				}
				
				wf_size_scrollbars(wfc, LOWORD(lParam), HIWORD(lParam));

				// Workaround: when the window is maximized, the call to "ShowScrollBars" returns TRUE but has no effect.
				if (wParam == SIZE_MAXIMIZED && !wfc->fullscreen)
					SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, SWP_NOMOVE | SWP_FRAMECHANGED);

				break;

			case WM_EXITSIZEMOVE:
				wf_size_scrollbars(wfc, wfc->client_width, wfc->client_height);
				break;

			case WM_ERASEBKGND:
				/* Say we handled it - prevents flickering */
				return (LRESULT) 1;

			case WM_PAINT:
				hdc = BeginPaint(hWnd, &ps);

				x = ps.rcPaint.left;
				y = ps.rcPaint.top;
				w = ps.rcPaint.right - ps.rcPaint.left + 1;
				h = ps.rcPaint.bottom - ps.rcPaint.top + 1;

				wf_scale_blt(wfc, hdc, x, y, w, h, wfc->primary->hdc, x - wfc->offset_x + wfc->xCurrentScroll, y - wfc->offset_y + wfc->yCurrentScroll, SRCCOPY);

				EndPaint(hWnd, &ps);
				break;

			case WM_LBUTTONDOWN:
				wf_scale_mouse_event(wfc, input,PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
				break;

			case WM_LBUTTONUP:
				wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON1, X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
				break;

			case WM_RBUTTONDOWN:
				wf_scale_mouse_event(wfc, input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2, X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
				break;

			case WM_RBUTTONUP:
				wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON2, X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
				break;

			case WM_MOUSEMOVE:
				wf_scale_mouse_event(wfc, input, PTR_FLAGS_MOVE, X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y);
				break;

			case WM_MOUSEWHEEL:
				wf_event_process_WM_MOUSEWHEEL(wfc, hWnd, Msg, wParam, lParam);
				break;

			case WM_SETCURSOR:
				if (LOWORD(lParam) == HTCLIENT)
					SetCursor(wfc->cursor);
				else
					DefWindowProc(hWnd, Msg, wParam, lParam);
				break;

			case WM_HSCROLL:
				{
					int xDelta;     // xDelta = new_pos - current_pos  
					int xNewPos;    // new position 
					int yDelta = 0; 
 
					switch (LOWORD(wParam)) 
					{ 
						// User clicked the scroll bar shaft left of the scroll box. 
						case SB_PAGEUP: 
							xNewPos = wfc->xCurrentScroll - 50;
							break; 
 
						// User clicked the scroll bar shaft right of the scroll box. 
						case SB_PAGEDOWN: 
							xNewPos = wfc->xCurrentScroll + 50;
							break; 
 
						// User clicked the left arrow. 
						case SB_LINEUP: 
							xNewPos = wfc->xCurrentScroll - 5;
							break; 
 
						// User clicked the right arrow. 
						case SB_LINEDOWN: 
							xNewPos = wfc->xCurrentScroll + 5;
							break; 
 
						// User dragged the scroll box. 
						case SB_THUMBPOSITION: 
							xNewPos = HIWORD(wParam); 

						// user is dragging the scrollbar
						case SB_THUMBTRACK :
							xNewPos = HIWORD(wParam); 
							break; 
 
						default: 
							xNewPos = wfc->xCurrentScroll;
					} 
 
					// New position must be between 0 and the screen width. 
					xNewPos = MAX(0, xNewPos); 
					xNewPos = MIN(wfc->xMaxScroll, xNewPos);
 
					// If the current position does not change, do not scroll.
					if (xNewPos == wfc->xCurrentScroll)
						break; 
 
					// Determine the amount scrolled (in pixels). 
					xDelta = xNewPos - wfc->xCurrentScroll;
 
					// Reset the current scroll position. 
					wfc->xCurrentScroll = xNewPos;
 
					// Scroll the window. (The system repaints most of the 
					// client area when ScrollWindowEx is called; however, it is 
					// necessary to call UpdateWindow in order to repaint the 
					// rectangle of pixels that were invalidated.) 
					ScrollWindowEx(wfc->hwnd, -xDelta, -yDelta, (CONST RECT *) NULL,
						(CONST RECT *) NULL, (HRGN) NULL, (PRECT) NULL, 
						SW_INVALIDATE); 
					UpdateWindow(wfc->hwnd);
 
					// Reset the scroll bar. 
					si.cbSize = sizeof(si); 
					si.fMask  = SIF_POS; 
					si.nPos   = wfc->xCurrentScroll;
					SetScrollInfo(wfc->hwnd, SB_HORZ, &si, TRUE);
				}
				break;

				case WM_VSCROLL: 
				{ 
					int xDelta = 0; 
					int yDelta;     // yDelta = new_pos - current_pos 
					int yNewPos;    // new position 
 
					switch (LOWORD(wParam)) 
					{ 
						// User clicked the scroll bar shaft above the scroll box. 
						case SB_PAGEUP: 
							yNewPos = wfc->yCurrentScroll - 50;
							break; 
 
						// User clicked the scroll bar shaft below the scroll box. 
						case SB_PAGEDOWN: 
							yNewPos = wfc->yCurrentScroll + 50;
							break; 
 
						// User clicked the top arrow. 
						case SB_LINEUP: 
							yNewPos = wfc->yCurrentScroll - 5;
							break; 
 
						// User clicked the bottom arrow. 
						case SB_LINEDOWN: 
							yNewPos = wfc->yCurrentScroll + 5;
							break; 
 
						// User dragged the scroll box. 
						case SB_THUMBPOSITION: 
							yNewPos = HIWORD(wParam); 
							break; 
 
						// user is dragging the scrollbar
						case SB_THUMBTRACK :
							yNewPos = HIWORD(wParam); 
							break; 

						default: 
							yNewPos = wfc->yCurrentScroll;
					} 
 
					// New position must be between 0 and the screen height. 
					yNewPos = MAX(0, yNewPos); 
					yNewPos = MIN(wfc->yMaxScroll, yNewPos);
 
					// If the current position does not change, do not scroll.
					if (yNewPos == wfc->yCurrentScroll)
						break; 
 
					// Determine the amount scrolled (in pixels). 
					yDelta = yNewPos - wfc->yCurrentScroll;
 
					// Reset the current scroll position. 
					wfc->yCurrentScroll = yNewPos;
 
					// Scroll the window. (The system repaints most of the 
					// client area when ScrollWindowEx is called; however, it is 
					// necessary to call UpdateWindow in order to repaint the 
					// rectangle of pixels that were invalidated.) 
					ScrollWindowEx(wfc->hwnd, -xDelta, -yDelta, (CONST RECT *) NULL,
						(CONST RECT *) NULL, (HRGN) NULL, (PRECT) NULL, 
						SW_INVALIDATE); 
					UpdateWindow(wfc->hwnd);
 
					// Reset the scroll bar. 
					si.cbSize = sizeof(si); 
					si.fMask  = SIF_POS; 
					si.nPos   = wfc->yCurrentScroll;
					SetScrollInfo(wfc->hwnd, SB_VERT, &si, TRUE);
				}
				break; 

				case WM_SYSCOMMAND:
				{
					if (wParam == SYSCOMMAND_ID_SMARTSIZING)
					{
						HMENU hMenu = GetSystemMenu(wfc->hwnd, FALSE);
						freerdp_set_param_bool(wfc->instance->settings, FreeRDP_SmartSizing, !wfc->instance->settings->SmartSizing);
						CheckMenuItem(hMenu, SYSCOMMAND_ID_SMARTSIZING, wfc->instance->settings->SmartSizing ? MF_CHECKED : MF_UNCHECKED);

					}
					else
					{
						processed = FALSE;
					}
				}
				break;

			default:
				processed = FALSE;
				break;
		}
	}
	else
	{
		processed = FALSE;
	}

	if (processed)
		return 0;

	switch (Msg)
	{
		case WM_DESTROY:
			PostQuitMessage(WM_QUIT);
			break;

		case WM_SETCURSOR:
			if (LOWORD(lParam) == HTCLIENT)
				SetCursor(wfc->hDefaultCursor);
			else
				DefWindowProc(hWnd, Msg, wParam, lParam);
			break;

		case WM_SETFOCUS:
			DEBUG_KBD("getting focus %X", hWnd);
			g_focus_hWnd = hWnd;
			break;

		case WM_KILLFOCUS:
			if (g_focus_hWnd == hWnd && wfc && !wfc->fullscreen)
			{
				DEBUG_KBD("loosing focus %X", hWnd);
				g_focus_hWnd = NULL;
			}
			break;

		case WM_ACTIVATE:
			{
				int activate = (int)(short) LOWORD(wParam);
				if (activate != WA_INACTIVE)
				{
					g_focus_hWnd = hWnd;
				}
				else
				{
					g_focus_hWnd = NULL;
				}
			}

		default:
			return DefWindowProc(hWnd, Msg, wParam, lParam);
			break;
	}

	return 0;
}
Exemple #2
0
BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings* settings)
{
    if (~((size_t) file->Domain))
        freerdp_set_param_string(settings, FreeRDP_Domain, file->Domain);

    if (~((size_t) file->Username))
    {
        char* user = NULL;
        char* domain = NULL;

        freerdp_parse_username(file->Username, &user, &domain);
        freerdp_set_param_string(settings, FreeRDP_Username, user);

        if (domain)
            freerdp_set_param_string(settings, FreeRDP_Domain, domain);

        if (user)
            free(user);

        if (domain)
            free(domain);
    }

    if (~file->ServerPort)
        freerdp_set_param_uint32(settings, FreeRDP_ServerPort, file->ServerPort);
    if (~((size_t) file->FullAddress))
        freerdp_set_param_string(settings, FreeRDP_ServerHostname, file->FullAddress);

    if (~file->DesktopWidth)
        freerdp_set_param_uint32(settings, FreeRDP_DesktopWidth, file->DesktopWidth);
    if (~file->DesktopHeight)
        freerdp_set_param_uint32(settings, FreeRDP_DesktopHeight, file->DesktopHeight);
    if (~file->SessionBpp)
        freerdp_set_param_uint32(settings, FreeRDP_ColorDepth, file->SessionBpp);
    if (~file->ConnectToConsole)
        freerdp_set_param_uint32(settings, FreeRDP_ConsoleSession, file->ConnectToConsole);
    if (~file->AdministrativeSession)
        freerdp_set_param_uint32(settings, FreeRDP_ConsoleSession, file->AdministrativeSession);
    if (~file->NegotiateSecurityLayer)
        freerdp_set_param_uint32(settings, FreeRDP_NegotiateSecurityLayer, file->NegotiateSecurityLayer);
    if (~file->EnableCredSSPSupport)
        freerdp_set_param_uint32(settings, FreeRDP_NlaSecurity, file->EnableCredSSPSupport);
    if (~((size_t) file->AlternateShell))
        freerdp_set_param_string(settings, FreeRDP_AlternateShell, file->AlternateShell);
    if (~((size_t) file->ShellWorkingDirectory))
        freerdp_set_param_string(settings, FreeRDP_ShellWorkingDirectory, file->ShellWorkingDirectory);

    if (~file->ScreenModeId)
    {
        /**
         * Screen Mode Id:
         * http://technet.microsoft.com/en-us/library/ff393692/
         *
         * This setting corresponds to the selection in the Display
         * configuration slider on the Display tab under Options in RDC.
         *
         * Values:
         *
         * 0: The remote session will appear in a window.
         * 1: The remote session will appear full screen.
         */

        freerdp_set_param_bool(settings, FreeRDP_Fullscreen,
                               (file->ScreenModeId == 1) ? TRUE : FALSE);
    }

    if (~((size_t) file->LoadBalanceInfo))
    {
        settings->LoadBalanceInfo = (BYTE*) _strdup(file->LoadBalanceInfo);
        settings->LoadBalanceInfoLength = strlen((char*) settings->LoadBalanceInfo);
    }

    if (~file->AuthenticationLevel)
    {
        /**
         * Authentication Level:
         * http://technet.microsoft.com/en-us/library/ff393709/
         *
         * This setting corresponds to the selection in the If server authentication
         * fails drop-down list on the Advanced tab under Options in RDC.
         *
         * Values:
         *
         * 0: If server authentication fails, connect to the computer without warning (Connect and don’t warn me).
         * 1: If server authentication fails, do not establish a connection (Do not connect).
         * 2: If server authentication fails, show a warning and allow me to connect or refuse the connection (Warn me).
         * 3: No authentication requirement is specified.
         */

        freerdp_set_param_bool(settings, FreeRDP_IgnoreCertificate,
                               (file->AuthenticationLevel == 0) ? TRUE : FALSE);
    }

    if (~file->ConnectionType)
        freerdp_set_param_uint32(settings, FreeRDP_ConnectionType, file->ConnectionType);

    if (~file->AudioMode)
    {
        if (file->AudioMode == AUDIO_MODE_REDIRECT)
        {
            freerdp_set_param_bool(settings, FreeRDP_AudioPlayback, TRUE);
        }
        else if (file->AudioMode == AUDIO_MODE_PLAY_ON_SERVER)
        {
            freerdp_set_param_bool(settings, FreeRDP_RemoteConsoleAudio, TRUE);
        }
        else if (file->AudioMode == AUDIO_MODE_NONE)
        {
            freerdp_set_param_bool(settings, FreeRDP_AudioPlayback, FALSE);
            freerdp_set_param_bool(settings, FreeRDP_RemoteConsoleAudio, FALSE);
        }
    }

    if (~file->Compression)
        freerdp_set_param_bool(settings, FreeRDP_CompressionEnabled, file->Compression);

    if (~((size_t) file->GatewayHostname))
        freerdp_set_param_string(settings, FreeRDP_GatewayHostname, file->GatewayHostname);

    if (~file->GatewayUsageMethod)
    {
        freerdp_set_param_uint32(settings, FreeRDP_GatewayUsageMethod, file->GatewayUsageMethod);

        if (file->GatewayUsageMethod == TSC_PROXY_MODE_DIRECT)
            freerdp_set_param_bool(settings, FreeRDP_GatewayEnabled, TRUE);
        else if (file->GatewayUsageMethod == TSC_PROXY_MODE_DETECT)
            freerdp_set_param_bool(settings, FreeRDP_GatewayEnabled, TRUE);
        else if (file->GatewayUsageMethod == TSC_PROXY_MODE_DEFAULT)
            freerdp_set_param_bool(settings, FreeRDP_GatewayEnabled, TRUE);
        else if (file->GatewayUsageMethod == TSC_PROXY_MODE_NONE_DETECT)
            freerdp_set_param_bool(settings, FreeRDP_GatewayEnabled, FALSE);
    }

    if (~file->PromptCredentialOnce)
        freerdp_set_param_bool(settings, FreeRDP_GatewayUseSameCredentials, TRUE);

    if (~file->RemoteApplicationMode)
        freerdp_set_param_bool(settings, FreeRDP_RemoteApplicationMode, file->RemoteApplicationMode);
    if (~((size_t) file->RemoteApplicationProgram))
        freerdp_set_param_string(settings, FreeRDP_RemoteApplicationProgram, file->RemoteApplicationProgram);
    if (~((size_t) file->RemoteApplicationName))
        freerdp_set_param_string(settings, FreeRDP_RemoteApplicationName, file->RemoteApplicationName);
    if (~((size_t) file->RemoteApplicationIcon))
        freerdp_set_param_string(settings, FreeRDP_RemoteApplicationIcon, file->RemoteApplicationIcon);
    if (~((size_t) file->RemoteApplicationFile))
        freerdp_set_param_string(settings, FreeRDP_RemoteApplicationGuid, file->RemoteApplicationGuid);
    if (~((size_t) file->RemoteApplicationGuid))
        freerdp_set_param_string(settings, FreeRDP_RemoteApplicationGuid, file->RemoteApplicationGuid);
    if (~((size_t) file->RemoteApplicationCmdLine))
        freerdp_set_param_string(settings, FreeRDP_RemoteApplicationCmdLine, file->RemoteApplicationCmdLine);

    if (~file->SpanMonitors)
        freerdp_set_param_bool(settings, FreeRDP_SpanMonitors, file->SpanMonitors);
    if (~file->UseMultiMon)
        freerdp_set_param_bool(settings, FreeRDP_UseMultimon, file->UseMultiMon);

    if (~file->AllowFontSmoothing)
        freerdp_set_param_bool(settings, FreeRDP_AllowFontSmoothing, file->AllowFontSmoothing);
    if (~file->DisableWallpaper)
        freerdp_set_param_bool(settings, FreeRDP_DisableWallpaper, file->DisableWallpaper);
    if (~file->DisableFullWindowDrag)
        freerdp_set_param_bool(settings, FreeRDP_DisableFullWindowDrag, file->DisableFullWindowDrag);
    if (~file->DisableMenuAnims)
        freerdp_set_param_bool(settings, FreeRDP_DisableMenuAnims, file->DisableMenuAnims);
    if (~file->DisableThemes)
        freerdp_set_param_bool(settings, FreeRDP_DisableThemes, file->DisableThemes);
    if (~file->AllowDesktopComposition)
        freerdp_set_param_bool(settings, FreeRDP_DisableCursorShadow, file->AllowDesktopComposition);

    if (~file->BitmapCachePersistEnable)
        freerdp_set_param_bool(settings, FreeRDP_BitmapCachePersistEnabled, file->BitmapCachePersistEnable);

    if (~file->DisableRemoteAppCapsCheck)
        freerdp_set_param_bool(settings, FreeRDP_DisableRemoteAppCapsCheck, file->DisableRemoteAppCapsCheck);

    if (~file->AutoReconnectionEnabled)
        freerdp_set_param_bool(settings, FreeRDP_AutoReconnectionEnabled, file->AutoReconnectionEnabled);
    if (~file->AutoReconnectMaxRetries)
        freerdp_set_param_uint32(settings, FreeRDP_AutoReconnectMaxRetries, file->AutoReconnectMaxRetries);

    if (~file->RedirectSmartCards)
        freerdp_set_param_bool(settings, FreeRDP_RedirectSmartCards, file->RedirectSmartCards);

    if (~file->RedirectClipboard)
        freerdp_set_param_bool(settings, FreeRDP_RedirectClipboard, file->RedirectClipboard);

    if (~file->RedirectPrinters)
        freerdp_set_param_bool(settings, FreeRDP_RedirectPrinters, file->RedirectPrinters);

    if (~file->RedirectDrives)
        freerdp_set_param_bool(settings, FreeRDP_RedirectDrives, file->RedirectDrives);

    if (~file->RedirectPosDevices)
    {
        freerdp_set_param_bool(settings, FreeRDP_RedirectSerialPorts, file->RedirectComPorts);
        freerdp_set_param_bool(settings, FreeRDP_RedirectParallelPorts, file->RedirectComPorts);
    }

    if (~file->RedirectComPorts)
    {
        freerdp_set_param_bool(settings, FreeRDP_RedirectSerialPorts, file->RedirectComPorts);
        freerdp_set_param_bool(settings, FreeRDP_RedirectParallelPorts, file->RedirectComPorts);
    }

    if (~file->RedirectDirectX)
    {
        /* What is this?! */
    }

    if (~((size_t) file->DevicesToRedirect))
    {
        /**
         * Devices to redirect:
         * http://technet.microsoft.com/en-us/library/ff393728/
         *
         * This setting corresponds to the selections for Other supported Plug and Play
         * (PnP) devices under More on the Local Resources tab under Options in RDC.
         *
         * Values:
         *
         * '*':
         * 	Redirect all supported Plug and Play devices.
         *
         * 'DynamicDevices':
         * 	Redirect any supported Plug and Play devices that are connected later.
         *
         * The hardware ID for the supported Plug and Play device:
         * 	Redirect the specified supported Plug and Play device.
         *
         * Examples:
         * 	devicestoredirect:s:*
         * 	devicestoredirect:s:DynamicDevices
         * 	devicestoredirect:s:USB\VID_04A9&PID_30C1\6&4BD985D&0&2;,DynamicDevices
         *
         */

        freerdp_set_param_bool(settings, FreeRDP_RedirectDrives, TRUE);
    }

    if (~((size_t) file->DrivesToRedirect))
    {
        /*
         * Drives to redirect:
         *
         * Very similar to DevicesToRedirect, but can contain a
         * comma-separated list of drive letters to redirect.
         */

        freerdp_set_param_bool(settings, FreeRDP_RedirectDrives, TRUE);
    }

    if (file->argc > 1)
    {
        freerdp_client_parse_command_line_arguments(file->argc, file->argv, settings);
    }

    return TRUE;
}
Exemple #3
0
BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings* settings)
{
	if (~((size_t) file->Domain))
		freerdp_set_param_string(settings, FreeRDP_Domain, file->Domain);

	if (~((size_t) file->Username))
	{
		char* user;
		char* domain;

		freerdp_parse_username(file->Username, &user, &domain);
		freerdp_set_param_string(settings, FreeRDP_Username, user);

		if (domain != NULL)
			freerdp_set_param_string(settings, FreeRDP_Domain, domain);
	}

	if (~file->ServerPort)
		freerdp_set_param_uint32(settings, FreeRDP_ServerPort, file->ServerPort);
	if (~((size_t) file->FullAddress))
		freerdp_set_param_string(settings, FreeRDP_ServerHostname, file->FullAddress);

	if (~file->DesktopWidth)
		freerdp_set_param_uint32(settings, FreeRDP_DesktopWidth, file->DesktopWidth);
	if (~file->DesktopHeight)
		freerdp_set_param_uint32(settings, FreeRDP_DesktopHeight, file->DesktopHeight);
	if (~file->SessionBpp)
		freerdp_set_param_uint32(settings, FreeRDP_ColorDepth, file->SessionBpp);
	if (~file->ConnectToConsole)
		freerdp_set_param_uint32(settings, FreeRDP_ConsoleSession, file->ConnectToConsole);
	if (~file->AdministrativeSession)
		freerdp_set_param_uint32(settings, FreeRDP_ConsoleSession, file->AdministrativeSession);
	if (~file->NegotiateSecurityLayer)
		freerdp_set_param_uint32(settings, FreeRDP_NegotiateSecurityLayer, file->NegotiateSecurityLayer);
	if (~file->EnableCredSSPSupport)
		freerdp_set_param_uint32(settings, FreeRDP_NlaSecurity, file->EnableCredSSPSupport);
	if (~((size_t) file->AlternateShell))
		freerdp_set_param_string(settings, FreeRDP_AlternateShell, file->AlternateShell);
	if (~((size_t) file->ShellWorkingDirectory))
		freerdp_set_param_string(settings, FreeRDP_ShellWorkingDirectory, file->ShellWorkingDirectory);
	
	if (~((size_t) file->LoadBalanceInfo))
	{
		settings->LoadBalanceInfo = (BYTE*) _strdup(file->LoadBalanceInfo);
		settings->LoadBalanceInfoLength = strlen((char*) settings->LoadBalanceInfo);
	}

	if (~file->ConnectionType)
		freerdp_set_param_uint32(settings, FreeRDP_ConnectionType, file->ConnectionType);

	if (~file->AudioMode)
	{
		if (file->AudioMode == AUDIO_MODE_REDIRECT)
		{
			freerdp_set_param_bool(settings, FreeRDP_AudioPlayback, TRUE);
		}
		else if (file->AudioMode == AUDIO_MODE_PLAY_ON_SERVER)
		{
			freerdp_set_param_bool(settings, FreeRDP_RemoteConsoleAudio, TRUE);
		}
		else if (file->AudioMode == AUDIO_MODE_NONE)
		{
			freerdp_set_param_bool(settings, FreeRDP_AudioPlayback, FALSE);
			freerdp_set_param_bool(settings, FreeRDP_RemoteConsoleAudio, FALSE);
		}
	}

	if (~((size_t) file->GatewayHostname))
		freerdp_set_param_string(settings, FreeRDP_GatewayHostname, file->GatewayHostname);

	if (~file->GatewayUsageMethod)
	{
		freerdp_set_param_uint32(settings, FreeRDP_GatewayUsageMethod, file->GatewayUsageMethod);

		if (file->GatewayUsageMethod == TSC_PROXY_MODE_DIRECT)
			freerdp_set_param_bool(settings, FreeRDP_GatewayEnabled, TRUE);
		else if (file->GatewayUsageMethod == TSC_PROXY_MODE_NONE_DETECT)
			freerdp_set_param_bool(settings, FreeRDP_GatewayEnabled, FALSE);
	}

	if (~file->PromptCredentialOnce)
		freerdp_set_param_bool(settings, FreeRDP_GatewayUseSameCredentials, TRUE);
	
	if (~file->RemoteApplicationMode)
		freerdp_set_param_bool(settings, FreeRDP_RemoteApplicationMode, file->RemoteApplicationMode);
	if (~((size_t) file->RemoteApplicationProgram))
		freerdp_set_param_string(settings, FreeRDP_RemoteApplicationProgram, file->RemoteApplicationProgram);
	if (~((size_t) file->RemoteApplicationName))
		freerdp_set_param_string(settings, FreeRDP_RemoteApplicationName, file->RemoteApplicationName);
	if (~((size_t) file->RemoteApplicationIcon))
		freerdp_set_param_string(settings, FreeRDP_RemoteApplicationIcon, file->RemoteApplicationIcon);
	if (~((size_t) file->RemoteApplicationFile))
		freerdp_set_param_string(settings, FreeRDP_RemoteApplicationGuid, file->RemoteApplicationGuid);
	if (~((size_t) file->RemoteApplicationGuid))
		freerdp_set_param_string(settings, FreeRDP_RemoteApplicationGuid, file->RemoteApplicationGuid);
	if (~((size_t) file->RemoteApplicationCmdLine))
		freerdp_set_param_string(settings, FreeRDP_RemoteApplicationCmdLine, file->RemoteApplicationCmdLine);

	if (~file->SpanMonitors)
		freerdp_set_param_bool(settings, FreeRDP_SpanMonitors, file->SpanMonitors);
	if (~file->UseMultiMon)
		freerdp_set_param_bool(settings, FreeRDP_UseMultimon, file->UseMultiMon);

	return TRUE;
}