rx: Remove RX_CALL_BUSY
[openafs.git] / src / WINNT / client_config / dlg_logon.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
18 #include "afs_config.h"
19
20
21 /*
22  * DEFINITIONS ________________________________________________________________
23  *
24  */
25
26 #define nRETRY_MIN            5
27 #define nRETRY_MAX            180
28
29 static TCHAR szYes[10] = TEXT("Yes");
30 static TCHAR szNo[10] = TEXT("No");
31
32 // Our dialog data
33 static BOOL fFirstTime = TRUE;
34 static DWORD nLoginRetryInterval;
35 static BOOL fFailLoginsSilently;
36
37
38 /*
39  * PROTOTYPES _________________________________________________________________
40  *
41  */
42
43 void Logon_OnInitDialog (HWND hDlg);
44 void Logon_OnOK (HWND hDlg);
45 void Logon_OnCancel(HWND hDlg);
46 BOOL Logon_OnApply();
47
48
49 /*
50  * ROUTINES ___________________________________________________________________
51  *
52  */
53
54 BOOL CALLBACK Logon_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
55 {
56    switch (msg)
57       {
58       case WM_INITDIALOG:
59          Logon_OnInitDialog (hDlg);
60          break;
61
62       case WM_CTLCOLORSTATIC:
63          if ((HWND)lp == GetDlgItem (hDlg, IDC_CHUNK_SIZE))
64             {
65             if (IsWindowEnabled ((HWND)lp))
66                {
67                static HBRUSH hbrStatic = CreateSolidBrush (GetSysColor (COLOR_WINDOW));
68                SetTextColor ((HDC)wp, GetSysColor (COLOR_WINDOWTEXT));
69                SetBkColor ((HDC)wp, GetSysColor (COLOR_WINDOW));
70                return (BOOL)hbrStatic;
71                }
72             }
73          break;
74
75       case WM_COMMAND:
76          switch (LOWORD(wp))
77             {
78             case IDHELP:
79                Logon_DlgProc (hDlg, WM_HELP, 0, 0);
80                break;
81
82             case IDOK:
83                 Logon_OnOK(hDlg);
84                 break;
85
86             case IDCANCEL:
87                 Logon_OnCancel(hDlg);
88                 break;
89             }
90          break;
91
92       case WM_HELP:
93          WinHelp (hDlg, g.szHelpFile, HELP_CONTEXT, IDH_AFSCONFIG_ADVANCED_LOGON);
94          break;
95       }
96
97    return FALSE;
98 }
99
100
101 void Logon_OnInitDialog (HWND hDlg)
102 {
103    if (fFirstTime) {
104       Config_GetLoginRetryInterval(&g.Configuration.nLoginRetryInterval);
105       Config_GetFailLoginsSilently(&g.Configuration.fFailLoginsSilently);
106
107       nLoginRetryInterval = g.Configuration.nLoginRetryInterval;
108       fFailLoginsSilently = g.Configuration.fFailLoginsSilently;
109
110       fFirstTime = FALSE;
111    }
112
113    CreateSpinner (GetDlgItem (hDlg, IDC_LOGIN_RETRY_INTERVAL), 10, FALSE, nRETRY_MIN, nLoginRetryInterval, nRETRY_MAX);
114
115    GetString (szYes, IDS_YES);
116    GetString (szNo, IDS_NO);
117
118    HWND hCombo = GetDlgItem(hDlg, IDC_FAIL_SILENTLY);
119
120    // Always add szNo first so it has index 0 and szYes has index 1
121    CB_AddItem (hCombo, szNo, 0);
122    CB_AddItem (hCombo, szYes, 0);
123
124    CB_SetSelected (hCombo, fFailLoginsSilently);
125 }
126
127
128 void Logon_OnOK (HWND hDlg)
129 {
130    nLoginRetryInterval = SP_GetPos (GetDlgItem (hDlg, IDC_LOGIN_RETRY_INTERVAL));
131    fFailLoginsSilently = CB_GetSelected (GetDlgItem (hDlg, IDC_FAIL_SILENTLY));
132
133    EndDialog(hDlg, IDOK);
134 }
135
136
137 BOOL Logon_OnApply()
138 {
139    if (fFirstTime)
140       return TRUE;
141
142    if (nLoginRetryInterval != g.Configuration.nLoginRetryInterval) {
143       if (!Config_SetLoginRetryInterval (nLoginRetryInterval))
144          return FALSE;
145       g.Configuration.nLoginRetryInterval = nLoginRetryInterval;
146    }
147
148    if (fFailLoginsSilently != g.Configuration.fFailLoginsSilently) {
149       if (!Config_SetFailLoginsSilently (fFailLoginsSilently))
150          return FALSE;
151       g.Configuration.fFailLoginsSilently = fFailLoginsSilently;
152    }
153
154    return TRUE;
155 }
156
157
158 void Logon_OnCancel(HWND hDlg)
159 {
160    fFirstTime = TRUE;
161
162    EndDialog(hDlg, IDCANCEL);
163 }