more-rx-updates-20060504
[openafs.git] / src / WINNT / client_config / dlg_misc.cpp
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #include <winsock2.h>
11 #include <ws2tcpip.h>
12
13 extern "C" {
14 #include <afs/param.h>
15 #include <afs/stds.h>
16 }
17 #include <stdio.h>
18 #include "afs_config.h"
19
20
21 /*
22  * DEFINITIONS ________________________________________________________________
23  *
24  */
25
26 #define nLANA_MIN             0
27 #define nLANA_MAX             10
28
29 #define csecPROBE_MIN         1
30 #define csecPROBE_MAX         600
31
32 #define cTHREADS_MIN          1
33 #define cTHREADS_MAX          128
34
35 #define cDAEMONS_MIN          1
36 #define cDAEMONS_MAX          128
37
38
39 // Our dialog data
40 BOOL fFirstTime = TRUE;
41 #if undef
42 DWORD nLanAdapter;
43 #endif
44 DWORD csecProbe;
45 DWORD nThreads;
46 DWORD nDaemons;
47 TCHAR szSysName[ MAX_PATH ];
48 TCHAR szRootVolume[ MAX_PATH ];
49 TCHAR szMountDir[ MAX_PATH ];
50
51
52 /*
53  * PROTOTYPES _________________________________________________________________
54  *
55  */
56
57 void Misc_OnInitDialog (HWND hDlg);
58 void Misc_OnOK(HWND hDlg);
59 void Misc_OnCancel(HWND hDlg);
60 BOOL Misc_OnApply();
61
62
63 /*
64  * ROUTINES ___________________________________________________________________
65  *
66  */
67
68 BOOL CALLBACK Misc_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
69 {
70    switch (msg)
71       {
72       case WM_INITDIALOG:
73          Misc_OnInitDialog (hDlg);
74          break;
75
76       case WM_CTLCOLORSTATIC:
77          if ((HWND)lp == GetDlgItem (hDlg, IDC_CHUNK_SIZE))
78             {
79             if (IsWindowEnabled ((HWND)lp))
80                {
81                static HBRUSH hbrStatic = CreateSolidBrush (GetSysColor (COLOR_WINDOW));
82                SetTextColor ((HDC)wp, GetSysColor (COLOR_WINDOWTEXT));
83                SetBkColor ((HDC)wp, GetSysColor (COLOR_WINDOW));
84                return (BOOL)hbrStatic;
85                }
86             }
87          break;
88
89       case WM_COMMAND:
90          switch (LOWORD(wp))
91             {
92             case IDHELP:
93                Misc_DlgProc (hDlg, WM_HELP, 0, 0);
94                break;
95
96             case IDOK:
97                 Misc_OnOK(hDlg);
98                 break;
99                 
100             case IDCANCEL:
101                 Misc_OnCancel(hDlg);
102                 break;
103 #if undef
104                         case IDC_AUTOLANA:
105                                 if (IsDlgButtonChecked(hDlg,IDC_AUTOLANA))
106                                         nLanAdapter=-1;
107                                 else
108                                         nLanAdapter=0;
109                                 SP_SetPos (GetDlgItem (hDlg, IDC_LAN_ADAPTER),nLanAdapter);
110                                 EnableWindow(GetDlgItem(hDlg,IDC_LAN_ADAPTER),(nLanAdapter!=-1));
111 #endif
112             }
113          break;
114
115       case WM_HELP:
116          WinHelp (hDlg, g.szHelpFile, HELP_CONTEXT, IDH_AFSCONFIG_ADVANCED_MISC);
117          break;
118       }
119
120    return FALSE;
121 }
122
123
124 void Misc_OnInitDialog (HWND hDlg)
125 {
126    if (fFirstTime) {
127 #if undef
128       Config_GetLanAdapter(&g.Configuration.nLanAdapter);
129 #endif
130       Config_GetProbeInt (&g.Configuration.csecProbe);
131       Config_GetNumThreads (&g.Configuration.nThreads);
132       Config_GetNumDaemons (&g.Configuration.nDaemons);
133       Config_GetSysName (g.Configuration.szSysName);
134       Config_GetRootVolume (g.Configuration.szRootVolume);
135       Config_GetMountRoot (g.Configuration.szMountDir);
136
137 #if undef
138       nLanAdapter = g.Configuration.nLanAdapter;
139 #endif
140       csecProbe = g.Configuration.csecProbe;
141       nThreads = g.Configuration.nThreads;
142       nDaemons = g.Configuration.nDaemons;
143       lstrcpy(szSysName, g.Configuration.szSysName);
144       lstrcpy(szRootVolume, g.Configuration.szRootVolume);
145       lstrcpy(szMountDir, g.Configuration.szMountDir);
146
147       fFirstTime = FALSE;
148    }
149
150 #if undef
151    CreateSpinner (GetDlgItem (hDlg, IDC_LAN_ADAPTER), 99, FALSE, nLANA_MIN, nLanAdapter, nLANA_MAX);
152 #endif
153    CreateSpinner (GetDlgItem (hDlg, IDC_PROBE), 10, FALSE, csecPROBE_MIN, csecProbe, csecPROBE_MAX);
154    CreateSpinner (GetDlgItem (hDlg, IDC_THREADS), 10, FALSE, cTHREADS_MIN, nThreads, cTHREADS_MAX);
155    CreateSpinner (GetDlgItem (hDlg, IDC_DAEMONS), 10, FALSE, cDAEMONS_MIN, nDaemons, cDAEMONS_MAX);
156    
157    SetDlgItemText (hDlg, IDC_SYSNAME, szSysName);
158    SetDlgItemText (hDlg, IDC_ROOTVOLUME, szRootVolume);
159    SetDlgItemText (hDlg, IDC_MOUNTDIR, szMountDir);
160 #if undef
161    CheckDlgButton (hDlg, IDC_AUTOLANA, (nLanAdapter==-1));
162    EnableWindow(GetDlgItem(hDlg,IDC_LAN_ADAPTER),(nLanAdapter!=-1));
163 #endif
164 }
165
166 void Misc_OnOK (HWND hDlg)
167 {
168 #if undef
169         nLanAdapter =  (IsDlgButtonChecked(hDlg,IDC_AUTOLANA))?-1
170                 :SP_GetPos (GetDlgItem (hDlg, IDC_LAN_ADAPTER));
171 #endif
172    csecProbe = SP_GetPos (GetDlgItem (hDlg, IDC_PROBE));
173   
174    nThreads = SP_GetPos (GetDlgItem (hDlg, IDC_THREADS));
175    
176    nDaemons = SP_GetPos (GetDlgItem (hDlg, IDC_DAEMONS));
177    
178    GetDlgItemText (hDlg, IDC_SYSNAME, szSysName, sizeof(szSysName));
179    GetDlgItemText (hDlg, IDC_ROOTVOLUME, szRootVolume, sizeof(szRootVolume));
180    GetDlgItemText (hDlg, IDC_MOUNTDIR, szMountDir, sizeof(szMountDir));
181    
182    EndDialog(hDlg, IDOK);
183 }
184
185
186 BOOL Misc_OnApply()
187 {
188    if (fFirstTime)
189       return TRUE;
190
191 #if undef
192    if (nLanAdapter != g.Configuration.nLanAdapter) {
193       if (!Config_SetLanAdapter (nLanAdapter))
194          return FALSE;
195       g.Configuration.nLanAdapter = nLanAdapter;
196    }
197 #endif
198
199    if (csecProbe != g.Configuration.csecProbe) {
200       if (!Config_SetProbeInt (csecProbe))
201          return FALSE;
202       g.Configuration.csecProbe = csecProbe;
203    }
204    
205    if (nThreads != g.Configuration.nThreads) {
206       if (!Config_SetNumThreads (nThreads))
207          return FALSE;
208       g.Configuration.nThreads = nThreads;
209    }
210    
211    if (nDaemons != g.Configuration.nDaemons) {
212       if (!Config_SetNumDaemons (nDaemons))
213          return FALSE;
214       g.Configuration.nDaemons = nDaemons;
215    }
216    
217    if (lstrcmp(szSysName, g.Configuration.szSysName) != 0) {
218       if (!Config_SetSysName (szSysName))
219          return FALSE;
220       lstrcpy(g.Configuration.szSysName, szSysName);
221    }
222    
223    if (lstrcmp(szRootVolume, g.Configuration.szRootVolume) != 0) {
224       if (!Config_SetRootVolume (szRootVolume))
225          return FALSE;
226       lstrcpy(g.Configuration.szRootVolume, szRootVolume);
227    }
228    
229    if (lstrcmp(szMountDir, g.Configuration.szMountDir) != 0) {
230       if (!Config_SetMountRoot (szMountDir))
231          return FALSE;
232       lstrcpy(g.Configuration.szMountDir, szMountDir);
233    }
234
235    return TRUE;
236 }
237
238 void Misc_OnCancel(HWND hDlg)
239 {
240    fFirstTime = TRUE;
241
242    EndDialog(hDlg, IDCANCEL);
243 }
244