- introduce keypath() function
[wine] / programs / winecfg / winecfg.h
1 /*
2  * WineCfg configuration management
3  *
4  * Copyright 2002 Jaco Greeff
5  * Copyright 2003 Dimitrie O. Paun
6  * Copyright 2004 Mike Hearn
7  *
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.
12  *
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.
17  *
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
21  *
22  */
23
24 #ifndef WINE_CFG_H
25 #define WINE_CFG_H
26
27 #include <stdarg.h>
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33 #include "winnls.h"
34 #include "properties.h"
35
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')
40
41 #define return_if_fail(try) \
42     if (!(try)) { \
43         WINE_ERR("check (" #try ") at %s:%d failed, returning\n", __FILE__,  __LINE__ - 1); \
44         return; \
45     }
46
47 #define WRITEME(owner) MessageBox(owner, "Write me!", "", MB_OK | MB_ICONEXCLAMATION);
48   
49
50 /* Transaction management */
51 enum transaction_action {
52     ACTION_SET,
53     ACTION_REMOVE
54 };
55
56 struct transaction {
57     char *section;
58     char *key;
59     char *newValue;
60     enum transaction_action action;
61     struct transaction *next, *prev;
62 };
63 extern struct transaction *tqhead, *tqtail;
64
65 extern int instantApply; /* non-zero means apply all changes instantly */
66
67 #define EDITING_GLOBAL 0
68 #define EDITING_APP    1
69 extern int appSettings;  /* non-zero means we are editing appdefault settings */
70
71 extern char *currentApp; /* NULL means editing global settings  */
72
73 /* returns a string of the form "AppDefaults\\appname.exe\\section", or just "section" if
74  * the user is editing the global settings.
75  *
76  * no explicit free is needed of the string returned by this function
77  */
78 char *keypath(char *section); 
79
80 /* Commits a transaction to the registry */
81 void processTransaction(struct transaction *trans);
82
83 /* Processes every pending transaction in the queue, removing them as it works from head to tail */
84 void processTransQueue();
85
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.
90  */
91 void addTransaction(const char *section, const char *key, enum transaction_action action, const char *newValue);
92
93 /* frees the transaction structure, all fields, and removes it from the queue if in it */
94 void destroyTransaction(struct transaction *trans);
95
96 /* Initializes the transaction system */
97 int initialize(void);
98 extern HKEY configKey;
99
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);
105
106 /* Graphics */
107
108 void initGraphDlg (HWND hDlg);
109 void saveGraphDlgSettings (HWND hDlg);
110 INT_PTR CALLBACK GraphDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
111
112 /* Drive management */
113 void initDriveDlg (HWND hDlg);
114 void saveDriveSettings (HWND hDlg);
115
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);
120
121 /* Audio config dialog */
122 INT_PTR CALLBACK AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
123
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() */
131
132 /* returns a string in the win32 heap  */
133 static inline char *strdupA(char *s)
134 {
135     char *r = alloc(strlen(s));
136     return strcpy(r, s);
137 }
138
139
140 #define WINE_KEY_ROOT "Software\\Wine\\Wine\\Config"
141
142 #endif