windows-talocale-20060829
[openafs.git] / src / WINNT / afsusrmgr / options.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 extern "C" {
11 #include <afs/param.h>
12 #include <afs/stds.h>
13 }
14
15 #include "TaAfsUsrMgr.h"
16 #include "options.h"
17
18
19 /*
20  * DEFINITIONS ________________________________________________________________
21  *
22  */
23
24 #define cminREFRESH_MIN            1 // 15 minutes
25 #define cminREFRESH_DEFAULT       60 // 1 hour
26 #define cminREFRESH_MAX        10080 // 1 week
27
28
29 /*
30  * PROTOTYPES _________________________________________________________________
31  *
32  */
33
34 BOOL CALLBACK Options_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
35 void Options_OnInitDialog (HWND hDlg);
36 void Options_OnApply (HWND hDlg);
37
38
39 /*
40  * ROUTINES ___________________________________________________________________
41  *
42  */
43
44 void ShowOptionsDialog (HWND hParent)
45 {
46    LPPROPSHEET psh = PropSheet_Create (IDS_OPTIONS_TITLE, TRUE, hParent, (LPARAM)0);
47    PropSheet_AddTab (psh, 0, IDD_OPTIONS, (DLGPROC)Options_DlgProc, (LPARAM)0, TRUE, TRUE);
48    PropSheet_ShowModal (psh);
49 }
50
51
52 BOOL CALLBACK Options_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
53 {
54    if (AfsAppLib_HandleHelp (IDD_OPTIONS, hDlg, msg, wp, lp))
55       return TRUE;
56
57    switch (msg)
58       {
59       case WM_INITDIALOG:
60          Options_OnInitDialog (hDlg);
61          break;
62
63       case WM_COMMAND:
64          switch (LOWORD(wp))
65             {
66             case IDAPPLY:
67                Options_OnApply (hDlg);
68                break;
69
70             case IDC_REFRESH:
71                EnableWindow (GetDlgItem (hDlg, IDC_REFRESH_RATE), IsDlgButtonChecked (hDlg, IDC_REFRESH));
72                break;
73             }
74          break;
75       }
76
77    return FALSE;
78 }
79
80
81 void Options_OnInitDialog (HWND hDlg)
82 {
83    CheckDlgButton (hDlg, IDC_REGEXP_UNIX, !gr.fWindowsRegexp);
84    CheckDlgButton (hDlg, IDC_REGEXP_WINDOWS, gr.fWindowsRegexp);
85
86    CheckDlgButton (hDlg, IDC_WARN_BADCREDS, gr.fWarnBadCreds);
87
88    CheckDlgButton (hDlg, IDC_REFRESH, (gr.cminRefreshRate != 0));
89
90    DWORD cminShow = (gr.cminRefreshRate != 0) ? gr.cminRefreshRate : cminREFRESH_DEFAULT;
91    CreateSpinner (GetDlgItem (hDlg, IDC_REFRESH_RATE), 10, FALSE, cminREFRESH_MIN, cminShow, cminREFRESH_MAX);
92
93    EnableWindow (GetDlgItem (hDlg, IDC_REFRESH_RATE), IsDlgButtonChecked (hDlg, IDC_REFRESH));
94 }
95
96
97 void Options_OnApply (HWND hDlg)
98 {
99    gr.fWindowsRegexp = IsDlgButtonChecked (hDlg, IDC_REGEXP_WINDOWS);
100
101    gr.fWarnBadCreds = IsDlgButtonChecked (hDlg, IDC_WARN_BADCREDS);
102
103    DWORD cminRateOld = gr.cminRefreshRate;
104
105    if (!IsDlgButtonChecked (hDlg, IDC_REFRESH))
106       gr.cminRefreshRate = 0;
107    else
108       gr.cminRefreshRate = (DWORD) SP_GetPos (GetDlgItem (hDlg, IDC_REFRESH_RATE));
109
110    if ((cminRateOld != gr.cminRefreshRate) && (g.idCell))
111       {
112       StartTask (taskSET_REFRESH);
113       }
114 }
115