Fixes for -Wmissing-declarations and -Wwrite-strings warnings.
[wine] / programs / winecfg / main.c
1 /*
2  * WineCfg main entry point
3  *
4  * Copyright 2002 Jaco Greeff
5  * Copyright 2003 Dimitrie O. Paun
6  * Copyright 2003 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 #include "config.h"
25
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <stdarg.h>
29 #ifdef HAVE_UNISTD_H
30 #include <unistd.h>
31 #endif
32
33 #define NONAMELESSUNION
34 #define NONAMELESSSTRUCT
35
36 #include <windef.h>
37 #include <winbase.h>
38 #include <winuser.h>
39 #include <commctrl.h>
40 #include <objbase.h>
41 #include <wine/debug.h>
42
43 #include "properties.h"
44 #include "resource.h"
45 #include "winecfg.h"
46
47 WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
48
49 static void CALLBACK
50 PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam)
51 {
52     switch (uMsg)
53     {
54         /*
55          * hWnd = NULL, lParam == dialog resource
56          */
57     case PSCB_PRECREATE:
58         break;
59
60     case PSCB_INITIALIZED:
61         break;
62
63     default:
64         break;
65     }
66 }
67
68 static INT_PTR CALLBACK
69 AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
70 {
71     switch (uMsg) {
72
73         case WM_NOTIFY:
74             if (((LPNMHDR)lParam)->code != PSN_SETACTIVE) break;
75             /* otherwise fall through, we want to refresh the page as well */
76         case WM_INITDIALOG:
77             break;
78
79         case WM_COMMAND:
80             break;
81             
82         default:
83             break;
84             
85     }
86     return FALSE;
87 }
88
89 #define NUM_PROPERTY_PAGES 6
90
91 static INT_PTR
92 doPropertySheet (HINSTANCE hInstance, HWND hOwner)
93 {
94     PROPSHEETPAGE psp[NUM_PROPERTY_PAGES];
95     PROPSHEETHEADER psh;
96     int pg = 0; /* start with page 0 */
97
98     /*
99      * Fill out the (Applications) PROPSHEETPAGE data structure 
100      * for the property sheet
101      */
102     psp[pg].dwSize = sizeof (PROPSHEETPAGE);
103     psp[pg].dwFlags = PSP_USETITLE;
104     psp[pg].hInstance = hInstance;
105     psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_APPCFG);
106     psp[pg].u2.pszIcon = NULL;
107     psp[pg].pfnDlgProc = AppDlgProc;
108     psp[pg].pszTitle = "Applications";
109     psp[pg].lParam = 0;
110     pg++;
111
112     /*
113      * Fill out the (Libraries) PROPSHEETPAGE data structure 
114      * for the property sheet
115      */
116     psp[pg].dwSize = sizeof (PROPSHEETPAGE);
117     psp[pg].dwFlags = PSP_USETITLE;
118     psp[pg].hInstance = hInstance;
119     psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_DLLCFG);
120     psp[pg].u2.pszIcon = NULL;
121     psp[pg].pfnDlgProc = LibrariesDlgProc;
122     psp[pg].pszTitle = "Libraries";
123     psp[pg].lParam = 0;
124     pg++;
125     
126     /*
127      * Fill out the (X11Drv) PROPSHEETPAGE data structure 
128      * for the property sheet
129      */
130     psp[pg].dwSize = sizeof (PROPSHEETPAGE);
131     psp[pg].dwFlags = PSP_USETITLE;
132     psp[pg].hInstance = hInstance;
133     psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_GRAPHCFG);
134     psp[pg].u2.pszIcon = NULL;
135     psp[pg].pfnDlgProc = GraphDlgProc;
136     psp[pg].pszTitle = "Graphics";
137     psp[pg].lParam = 0;
138     pg++;
139
140     psp[pg].dwSize = sizeof (PROPSHEETPAGE);
141     psp[pg].dwFlags = PSP_USETITLE;
142     psp[pg].hInstance = hInstance;
143     psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_DRIVECFG);
144     psp[pg].u2.pszIcon = NULL;
145     psp[pg].pfnDlgProc = DriveDlgProc;
146     psp[pg].pszTitle = "Drives";
147     psp[pg].lParam = 0;
148     pg++;
149
150     psp[pg].dwSize = sizeof (PROPSHEETPAGE);
151     psp[pg].dwFlags = PSP_USETITLE;
152     psp[pg].hInstance = hInstance;
153     psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_AUDIOCFG);
154     psp[pg].u2.pszIcon = NULL;
155     psp[pg].pfnDlgProc = AudioDlgProc;
156     psp[pg].pszTitle = "Audio";
157     psp[pg].lParam = 0;
158     pg++;
159
160     /*
161      * Fill out the (General) PROPSHEETPAGE data structure 
162      * for the property sheet
163      */
164     psp[pg].dwSize = sizeof (PROPSHEETPAGE);
165     psp[pg].dwFlags = PSP_USETITLE;
166     psp[pg].hInstance = hInstance;
167     psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_ABOUTCFG);
168     psp[pg].u2.pszIcon = NULL;
169     psp[pg].pfnDlgProc = AboutDlgProc;
170     psp[pg].pszTitle = "About";
171     psp[pg].lParam = 0;
172     pg++;
173
174     /*
175      * Fill out the PROPSHEETHEADER
176      */
177     psh.dwSize = sizeof (PROPSHEETHEADER);
178     psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
179     psh.hwndParent = hOwner;
180     psh.hInstance = hInstance;
181     psh.u.pszIcon = NULL;
182     psh.pszCaption = "Wine Configuration";
183     psh.nPages = NUM_PROPERTY_PAGES;
184     psh.u3.ppsp = (LPCPROPSHEETPAGE) & psp;
185     psh.pfnCallback = (PFNPROPSHEETCALLBACK) PropSheetCallback;
186     psh.u2.nStartPage = 0;
187
188     /*
189      * Display the modal property sheet
190      */
191     return PropertySheet (&psh);
192 }
193
194 /******************************************************************************
195  * Name       : ProcessCmdLine
196  * Description: Checks command line parameters for 'autodetect drives' option
197  * Parameters : lpCmdLine - the command line
198  * Returns    : TRUE - if '/D' was found. Drive autodetection was carried out.
199  *              FALSE - no '/D' option found in command line
200  * Notes      : This is a very simple implementation, which only works 
201  *              correctly if the one and only cmd line option is '/D' or
202  *              no option at all. Has to be reworked, if more options are to
203  *              be supported.
204  */
205 static BOOL
206 ProcessCmdLine(LPSTR lpCmdLine)
207 {
208     if ((lpCmdLine[0] == '/' || lpCmdLine[0] == '-') && 
209         (lpCmdLine[1] == 'D' || lpCmdLine[1] == 'd')) 
210     {
211         gui_mode = FALSE;
212         if (autodetect_drives()) {
213             apply_drive_changes();
214         }
215         return TRUE;
216     }
217
218     return FALSE;
219 }
220
221 /*****************************************************************************
222  * Name       : WinMain
223  * Description: Main windows entry point
224  * Parameters : hInstance
225  *              hPrev
226  *              szCmdLine
227  *              nShow
228  * Returns    : Program exit code
229  */
230 int WINAPI
231 WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
232 {
233     if (ProcessCmdLine(szCmdLine)) {
234         return 0;
235     }
236         
237     /* Until winecfg is fully functional, warn users that it is incomplete and doesn't do anything */
238     if (!getenv("WINECFG_NOWARN")) {
239         WINE_FIXME("The winecfg tool is not yet complete, and does not actually alter your configuration.\n");
240         WINE_FIXME("If you want to alter the way Wine works, look in the ~/.wine/config file for more information.\n");
241         MessageBoxA(NULL, "The winecfg tool is not yet complete, and does not actually alter your configuration\n\n"
242                     "If you want to alter the way Wine works, look in the ~/.wine/config file for more information.",
243                     "", MB_OK | MB_ICONEXCLAMATION);
244     }
245
246     if (initialize() != 0) {
247         WINE_ERR("initialization failed, aborting\n");
248         ExitProcess(1);
249     }
250     
251     /*
252      * The next 9 lines should be all that is needed
253      * for the Wine Configuration property sheet
254      */
255     InitCommonControls ();
256     CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
257     if (doPropertySheet (hInstance, NULL) > 0) {
258         WINE_TRACE("OK\n");
259     } else {
260         WINE_TRACE("Cancel\n");
261     }
262     CoUninitialize(); 
263     ExitProcess (0);
264
265     return 0;
266 }