2 * WineCfg configuration management
4 * Copyright 2002 Jaco Greeff
5 * Copyright 2003 Dimitrie O. Paun
6 * Copyright 2004 Mike Hearn
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #include "properties.h"
36 #define IS_OPTION_TRUE(ch) \
37 ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
38 #define IS_OPTION_FALSE(ch) \
39 ((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0')
41 #define return_if_fail(try) \
43 WINE_ERR("check (" #try ") at %s:%d failed, returning\n", __FILE__, __LINE__ - 1); \
47 #define WRITEME(owner) MessageBox(owner, "Write me!", "", MB_OK | MB_ICONEXCLAMATION);
50 /* Transaction management */
51 enum transaction_action {
60 enum transaction_action action;
61 struct transaction *next, *prev;
63 extern struct transaction *tqhead, *tqtail;
65 extern int instantApply; /* non-zero means apply all changes instantly */
67 #define EDITING_GLOBAL 0
69 extern int appSettings; /* non-zero means we are editing appdefault settings */
71 extern char *currentApp; /* NULL means editing global settings */
73 /* returns a string of the form "AppDefaults\\appname.exe\\section", or just "section" if
74 * the user is editing the global settings.
76 * no explicit free is needed of the string returned by this function
78 char *keypath(char *section);
80 /* Commits a transaction to the registry */
81 void processTransaction(struct transaction *trans);
83 /* Processes every pending transaction in the queue, removing them as it works from head to tail */
84 void processTransQueue();
86 /* Adds a transaction to the head of the queue. If we're using instant apply, this calls processTransaction
87 * action can be either:
88 * ACTION_SET -> this transaction will change a registry key, newValue is the replacement value
89 * ACTION_REMOVE -> this transaction will remove a registry key. In this case, newValue is ignored.
91 void addTransaction(const char *section, const char *key, enum transaction_action action, const char *newValue);
93 /* frees the transaction structure, all fields, and removes it from the queue if in it */
94 void destroyTransaction(struct transaction *trans);
96 /* Initializes the transaction system */
98 extern HKEY configKey;
100 /* don't use these directly! */
101 int setConfigValue (const char *subkey, const char *valueName, const char *value);
102 char *getConfigValue (const char *subkey, const char *valueName, const char *defaultResult);
103 HRESULT doesConfigValueExist (const char *subkey, const char *valueName);
104 HRESULT removeConfigValue (const char *subkey, const char *valueName);
108 void initGraphDlg (HWND hDlg);
109 void saveGraphDlgSettings (HWND hDlg);
110 INT_PTR CALLBACK GraphDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
112 /* Drive management */
113 void initDriveDlg (HWND hDlg);
114 void saveDriveSettings (HWND hDlg);
116 INT_PTR CALLBACK DriveDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
117 INT_PTR CALLBACK DriveEditDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
118 INT_PTR CALLBACK AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
119 INT_PTR CALLBACK LibrariesDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
121 /* Audio config dialog */
122 INT_PTR CALLBACK AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
124 /* some basic utilities to make win32 suck less */
125 char *getDialogItemText(HWND hDlg, WORD controlID);
126 #define disable(id) EnableWindow(GetDlgItem(dialog, id), 0);
127 #define enable(id) EnableWindow(GetDlgItem(dialog, id), 1);
128 #define alloc(size) HeapAlloc(GetProcessHeap(), 0, size);
129 #define release(ptr) HeapFree(GetProcessHeap(), 0, ptr);
130 void PRINTERROR(void); /* WINE_TRACE() the plaintext error message from GetLastError() */
132 /* returns a string in the win32 heap */
133 static inline char *strdupA(char *s)
135 char *r = alloc(strlen(s));
140 #define WINE_KEY_ROOT "Software\\Wine\\Wine\\Config"