- Correct return code of loadConfig().
- Make the registry key used a constant. - Made code slightly more consistant with itself. - Some style changes, expanding out variable names, whitespace, removing unnecessary variable initializers and hungarian notation etc. - Replace dialog box with a FIXME in WinMain() to warn of incompleteness. - Implement saveConfigValue(). - Hook up support for save/load of WinVer.
This commit is contained in:
parent
2b644d60d6
commit
4e1afc6de0
|
@ -62,11 +62,11 @@ IDD_X11DRVCFG DIALOG DISCARDABLE 0, 0, 260, 250
|
|||
STYLE WS_CHILD | WS_DISABLED
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
EDITTEXT IDC_SYSCOLORS,100,41,40,14,ES_AUTOHSCROLL | ES_NUMBER
|
||||
EDITTEXT IDC_SYSCOLORS,100,41,40,12,ES_AUTOHSCROLL | ES_NUMBER
|
||||
CONTROL "Use a private color map",IDC_PRIVATEMAP,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,17,62,91,10
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,15,62,91,10
|
||||
CONTROL "Favor correctness over speed",IDC_PERFECTGRAPH,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,17,76,117,10
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,15,76,117,10
|
||||
CONTROL "Use XFree DGA extension",IDC_XDGA,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,141,62,97,10
|
||||
CONTROL "Use XFree Shm extension",IDC_XSHM,"Button",
|
||||
|
@ -78,7 +78,7 @@ BEGIN
|
|||
GROUPBOX "Render Settings",IDC_STATIC,8,4,244,90
|
||||
LTEXT "The driver color and render settings are used to optimise the way in which colors and applications are displayed.",
|
||||
IDC_STATIC,15,17,228,22
|
||||
LTEXT "Allocated system colors:",IDC_STATIC,17,43,76,8
|
||||
LTEXT "Allocated system colors:",IDC_STATIC,15,43,76,8
|
||||
GROUPBOX "Wine Desktop",IDC_STATIC,8,99,244,83
|
||||
LTEXT "Wine can be setup to emulate a windows desktop, or can be run in ""Managed"" mode (default) where the default X11 windows manager/environment is resposible for placing the windows.",
|
||||
IDC_STATIC,15,112,228,28
|
||||
|
|
|
@ -27,11 +27,14 @@
|
|||
#include <commctrl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wine/debug.h>
|
||||
|
||||
#include "properties.h"
|
||||
#include "resource.h"
|
||||
#include "winecfg.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
|
||||
|
||||
WINECFG_DESC sCfg;
|
||||
|
||||
void CALLBACK
|
||||
|
@ -97,17 +100,31 @@ initGeneralDlg (HWND hDlg)
|
|||
INT_PTR CALLBACK
|
||||
GeneralDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
initGeneralDlg (hDlg);
|
||||
break;
|
||||
switch (uMsg) {
|
||||
|
||||
case WM_INITDIALOG:
|
||||
initGeneralDlg (hDlg);
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDC_WINVER: if (HIWORD(wParam) == CBN_SELCHANGE) {
|
||||
/* user changed the wine version combobox */
|
||||
int selection = SendDlgItemMessage( hDlg, IDC_WINVER, CB_GETCURSEL, 0, 0);
|
||||
const VERSION_DESC *desc = getWinVersions();
|
||||
|
||||
default:
|
||||
break;
|
||||
while (selection > 0) {
|
||||
desc++; selection--;
|
||||
}
|
||||
strcpy(sCfg.szWinVer, desc->szVersion);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -266,9 +283,11 @@ doPropertySheet (HINSTANCE hInstance, HWND hOwner)
|
|||
int WINAPI
|
||||
WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
|
||||
{
|
||||
/* Until winecfg is fully functional, warn users that it is incomplete and doesn't do anything */
|
||||
MessageBox(NULL, "The winecfg tool is not yet complete, and does not actually alter your configuration. If you want to alter the way Wine works, look in the ~/.wine/config file for more information.", "winecfg", MB_OK | MB_ICONWARNING);
|
||||
|
||||
/* Until winecfg is fully functional, warn users that it is incomplete and doesn't do anything */
|
||||
WINE_FIXME("The winecfg tool is not yet complete, and does not actually alter your configuration.\n");
|
||||
WINE_FIXME("If you want to alter the way Wine works, look in the ~/.wine/config file for more information.");
|
||||
|
||||
/*
|
||||
* Load the configuration from registry
|
||||
*/
|
||||
|
@ -279,7 +298,12 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
|
|||
* for the Wine Configuration property sheet
|
||||
*/
|
||||
InitCommonControls ();
|
||||
doPropertySheet (hInstance, NULL);
|
||||
if (doPropertySheet (hInstance, NULL) >= 0) {
|
||||
WINE_TRACE("OK\n");
|
||||
saveConfig(&sCfg);
|
||||
} else
|
||||
WINE_TRACE("Cancel\n");
|
||||
|
||||
ExitProcess (0);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -74,44 +74,53 @@ int freeConfig (WINECFG_DESC* pCfg)
|
|||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* getConfigValue: Retrieves a configuration value from the registry
|
||||
*
|
||||
* HKEY hCurrent : the registry key that the configuration is rooted at
|
||||
* char *subKey : the name of the config section
|
||||
* char *valueName : the name of the config value
|
||||
* char *retVal : pointer to the start of a buffer that has room for >= length chars
|
||||
* int length : length of the buffer pointed to by retVal
|
||||
* char *defaultResult : if the key isn't found, return this value instead
|
||||
*
|
||||
* Returns 0 upon success, non-zero otherwise
|
||||
*
|
||||
*/
|
||||
int GetConfigValueSZ (HKEY hCurrent, LPSTR subkey, LPSTR valueName, LPSTR RetVal,
|
||||
int length, LPSTR DefRes)
|
||||
int getConfigValue (HKEY hCurrent, char *subkey, char *valueName, char *retVal, int length, char *defaultResult)
|
||||
{
|
||||
CHAR *buffer=NULL;
|
||||
DWORD dataLength=0;
|
||||
HKEY hSubKey=NULL;
|
||||
DWORD res;
|
||||
CHAR *buffer;
|
||||
DWORD dataLength;
|
||||
HKEY hSubKey = NULL;
|
||||
DWORD res = 1; /* assume failure */
|
||||
|
||||
WINE_TRACE("subkey=%s, valueName=%s, defaultResult=%s\n", subkey, valueName, defaultResult);
|
||||
|
||||
if( (res=RegOpenKeyEx( hCurrent, subkey, 0, KEY_ALL_ACCESS, &hSubKey ))
|
||||
!=ERROR_SUCCESS )
|
||||
{
|
||||
if( res==ERROR_FILE_NOT_FOUND )
|
||||
{
|
||||
WINE_TRACE("Value not present - using default\n");
|
||||
strncpy( RetVal,DefRes,length);
|
||||
res=TRUE;
|
||||
WINE_TRACE("Section key not present - using default\n");
|
||||
strncpy(retVal, defaultResult, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
WINE_ERR("RegOpenKey failed on wine config key (%ld)\n", res);
|
||||
res=FALSE;
|
||||
WINE_ERR("RegOpenKey failed on wine config key (res=%ld)\n", res);
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
|
||||
res = RegQueryValueExA( hSubKey, valueName, NULL, NULL, NULL, &dataLength);
|
||||
if( res==ERROR_FILE_NOT_FOUND )
|
||||
if( res == ERROR_FILE_NOT_FOUND )
|
||||
{
|
||||
WINE_TRACE("Value not present - using default\n");
|
||||
strncpy( RetVal,DefRes,length);
|
||||
res=TRUE;
|
||||
strncpy(retVal, defaultResult, length);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if( res!=ERROR_SUCCESS )
|
||||
{
|
||||
WINE_ERR("Couldn't query value's length (%ld)\n", res );
|
||||
res=FALSE;
|
||||
WINE_ERR("Couldn't query value's length (res=%ld)\n", res );
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -119,22 +128,53 @@ int GetConfigValueSZ (HKEY hCurrent, LPSTR subkey, LPSTR valueName, LPSTR RetVal
|
|||
if( buffer==NULL )
|
||||
{
|
||||
WINE_ERR("Couldn't allocate %lu bytes for the value\n", dataLength );
|
||||
res=FALSE;
|
||||
goto end;
|
||||
}
|
||||
|
||||
RegQueryValueEx( hSubKey, valueName, NULL, NULL, (LPBYTE)buffer, &dataLength);
|
||||
strncpy( RetVal,buffer,length);
|
||||
RegQueryValueEx(hSubKey, valueName, NULL, NULL, (LPBYTE)buffer, &dataLength);
|
||||
strncpy(retVal, buffer, length);
|
||||
free(buffer);
|
||||
res = 0;
|
||||
|
||||
end:
|
||||
if( hSubKey!=NULL )
|
||||
if( hSubKey!=NULL )
|
||||
RegCloseKey( hSubKey );
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* setConfigValue : Sets a configuration key in the registry
|
||||
*
|
||||
* HKEY hCurrent : the registry key that the configuration is rooted at
|
||||
* char *subKey : the name of the config section
|
||||
* char *valueName : the name of the config value
|
||||
* char *value : the value to set the configuration key to
|
||||
*
|
||||
* Returns 0 on success, non-zero otherwise
|
||||
*
|
||||
*/
|
||||
int setConfigValue (HKEY hCurrent, char *subkey, char *valueName, const char *value) {
|
||||
DWORD res = 1;
|
||||
HKEY key = NULL;
|
||||
|
||||
WINE_TRACE("subkey=%s, valueName=%s, value=%s\n", subkey, valueName, value);
|
||||
|
||||
res = RegCreateKey(hCurrent, subkey, &key);
|
||||
if (res != ERROR_SUCCESS) goto end;
|
||||
|
||||
res = RegSetValueEx(key, valueName, 0, REG_SZ, value, strlen(value) + 1);
|
||||
if (res != ERROR_SUCCESS) goto end;
|
||||
|
||||
res = 0;
|
||||
end:
|
||||
if (key) RegCloseKey(key);
|
||||
if (res != 0) WINE_ERR("Unable to set configuration key %s in section %s to %s, res=%ld\n", valueName, subkey, value, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Name : loadConfig
|
||||
* Description: Loads and populates a configuration structure
|
||||
|
@ -152,32 +192,29 @@ int loadConfig (WINECFG_DESC* pCfg)
|
|||
HKEY hSession=NULL;
|
||||
DWORD res;
|
||||
|
||||
if( (res=RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config", 0, KEY_ALL_ACCESS, &hSession ))
|
||||
!=ERROR_SUCCESS )
|
||||
WINE_TRACE("\n");
|
||||
|
||||
res = RegCreateKey(HKEY_LOCAL_MACHINE, WINE_KEY_ROOT, &hSession);
|
||||
if (res != ERROR_SUCCESS)
|
||||
{
|
||||
if( res==ERROR_FILE_NOT_FOUND )
|
||||
WINE_ERR("Wine config key does not exist");
|
||||
else
|
||||
WINE_ERR("RegOpenKey failed on wine config key (%ld)\n", res);
|
||||
|
||||
res=FALSE;
|
||||
return 1;
|
||||
WINE_ERR("RegOpenKey failed on wine config key (%ld)\n", res);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* Windows and DOS versions */
|
||||
GetConfigValueSZ(hSession,"Version","Windows",pCfg->szWinVer,MAX_VERSION_LENGTH,"win95");
|
||||
GetConfigValueSZ(hSession,"Version","DOS",pCfg->szDOSVer,MAX_VERSION_LENGTH,"6.22");
|
||||
GetConfigValueSZ(hSession,"Tweak.Layout","WineLook",pCfg->szWinLook,MAX_VERSION_LENGTH,"win95");
|
||||
getConfigValue(hSession, "Version", "Windows", pCfg->szWinVer, MAX_VERSION_LENGTH, "win95");
|
||||
getConfigValue(hSession, "Version", "DOS", pCfg->szDOSVer, MAX_VERSION_LENGTH, "6.22");
|
||||
getConfigValue(hSession, "Tweak.Layout", "WineLook", pCfg->szWinLook, MAX_VERSION_LENGTH, "win95");
|
||||
|
||||
/* System Paths */
|
||||
GetConfigValueSZ(hSession,"Wine","Windows",pCfg->szWinDir,MAX_PATH,"c:\\Windows");
|
||||
GetConfigValueSZ(hSession,"Wine","System",pCfg->szWinSysDir,MAX_PATH,"c:\\Windows\\System");
|
||||
GetConfigValueSZ(hSession,"Wine","Temp",pCfg->szWinTmpDir,MAX_PATH,"c:\\Windows\\Temp");
|
||||
GetConfigValueSZ(hSession,"Wine","Profile",pCfg->szWinProfDir,MAX_PATH,"c:\\Windows\\Profiles\\Administrator");
|
||||
GetConfigValueSZ(hSession,"Wine","Path",pCfg->szWinPath,MAX_PATH,"c:\\Windows;c:\\Windows\\System");
|
||||
getConfigValue(hSession, "Wine", "Windows", pCfg->szWinDir, MAX_PATH, "c:\\Windows");
|
||||
getConfigValue(hSession, "Wine", "System", pCfg->szWinSysDir, MAX_PATH, "c:\\Windows\\System");
|
||||
getConfigValue(hSession, "Wine", "Temp", pCfg->szWinTmpDir, MAX_PATH, "c:\\Windows\\Temp");
|
||||
getConfigValue(hSession, "Wine", "Profile", pCfg->szWinProfDir, MAX_PATH, "c:\\Windows\\Profiles\\Administrator");
|
||||
getConfigValue(hSession, "Wine", "Path", pCfg->szWinPath, MAX_PATH, "c:\\Windows;c:\\Windows\\System");
|
||||
|
||||
/* Graphics driver */
|
||||
GetConfigValueSZ(hSession,"Wine","GraphicsDriver",pCfg->szGraphDriver,MAX_NAME_LENGTH,"x11drv");
|
||||
getConfigValue(hSession, "Wine", "GraphicsDriver", pCfg->szGraphDriver, MAX_NAME_LENGTH, "x11drv");
|
||||
|
||||
/*
|
||||
* DLL defaults for all applications is built using
|
||||
|
@ -221,9 +258,8 @@ int loadConfig (WINECFG_DESC* pCfg)
|
|||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: saveConfig
|
||||
* Description: Stores the configuration structure
|
||||
* Parameters : pCfg
|
||||
* saveConfig : Stores the configuration structure
|
||||
*
|
||||
* Returns : 0 on success, -1 otherwise
|
||||
*
|
||||
* FIXME: This is where we are to write the changes to the registry.
|
||||
|
@ -231,5 +267,20 @@ int loadConfig (WINECFG_DESC* pCfg)
|
|||
*/
|
||||
int saveConfig (const WINECFG_DESC* pCfg)
|
||||
{
|
||||
HKEY key;
|
||||
DWORD res;
|
||||
|
||||
WINE_TRACE("\n");
|
||||
|
||||
res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, WINE_KEY_ROOT, 0, KEY_ALL_ACCESS, &key);
|
||||
if (res != ERROR_SUCCESS) {
|
||||
WINE_ERR("Failed to open Wine config registry branch, res=%ld\n", res);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Windows and DOS versions */
|
||||
setConfigValue(key, "Version", "Windows", pCfg->szWinVer);
|
||||
|
||||
WINE_FIXME("We don't write out the entire configuration yet\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -51,4 +51,6 @@ int freeConfig(WINECFG_DESC *pCfg);
|
|||
int loadConfig(WINECFG_DESC *pCfg);
|
||||
int saveConfig(const WINECFG_DESC *pCfg);
|
||||
|
||||
#define WINE_KEY_ROOT "Software\\Wine\\Wine\\Config"
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue