LINUX: afs_create infinite fetchStatus loop
[pkg-k5-afs_openafs.git] / src / WINNT / client_exp / klog_dlg.cpp
blobc090a313f7c4597e976e6e5b1c29466b80574b70
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
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 */
10 #include "stdafx.h"
11 #include <winsock2.h>
12 #include <ws2tcpip.h>
14 extern "C" {
15 #include <afsconfig.h>
16 #include <afs/param.h>
17 #include <afs/stds.h>
18 #include <roken.h>
21 #include "klog_dlg.h"
22 #include "hourglass.h"
24 extern "C" {
25 #include <afs/kautils.h>
26 #include "cm_config.h"
29 #ifdef _DEBUG
30 #define new DEBUG_NEW
31 #undef THIS_FILE
32 static char THIS_FILE[] = __FILE__;
33 #endif
35 #ifdef UNICODE
36 CStringA CStringToCStringA(const CString& str)
38 CStringA astr(str);
39 return astr;
41 #define PCCHAR(str) ((char *)(const char *)CStringToCStringA(str))
42 #else
43 #define PCCHAR(str) ((char *)(const char *)str)
44 #endif
46 /////////////////////////////////////////////////////////////////////////////
47 // CKlogDlg dialog
49 int kl_Authenticate(const CString& strCellName, const CString& strName,
50 const CString& strPassword, char **reason)
52 afs_int32 pw_exp;
54 return ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION,
55 PCCHAR(strName), "",
56 PCCHAR(strCellName),
57 PCCHAR(strPassword),
59 &pw_exp, 0, reason);
62 CKlogDlg::CKlogDlg(CWnd* pParent /*=NULL*/)
63 : CDialog()
65 InitModalIndirect (TaLocale_GetDialogResource (CKlogDlg::IDD), pParent);
67 //{{AFX_DATA_INIT(CKlogDlg)
68 m_strName = _T("");
69 m_strPassword = _T("");
70 m_strCellName = _T("");
71 //}}AFX_DATA_INIT
72 // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
75 void CKlogDlg::DoDataExchange(CDataExchange* pDX)
77 CDialog::DoDataExchange(pDX);
78 //{{AFX_DATA_MAP(CKlogDlg)
79 DDX_Control(pDX, IDOK, m_OK);
80 DDX_Text(pDX, IDC_NAME, m_strName);
81 DDX_Text(pDX, IDC_PASSWORD, m_strPassword);
82 DDX_Text(pDX, IDC_CELL_NAME, m_strCellName);
83 //}}AFX_DATA_MAP
86 BEGIN_MESSAGE_MAP(CKlogDlg, CDialog)
87 //{{AFX_MSG_MAP(CKlogDlg)
88 ON_EN_CHANGE(IDC_NAME, OnChangeName)
89 ON_EN_CHANGE(IDC_CELL_NAME, OnChangeCellName)
90 ON_EN_CHANGE(IDC_PASSWORD, OnChangePassword)
91 ON_BN_CLICKED(IDHELP, OnHelp)
92 //}}AFX_MSG_MAP
93 END_MESSAGE_MAP()
95 /////////////////////////////////////////////////////////////////////////////
96 // CKlogDlg message handlers
98 BOOL CKlogDlg::OnInitDialog()
100 CDialog::OnInitDialog();
102 if (m_strCellName.IsEmpty()) {
103 char defaultCell[256];
104 long code = cm_GetRootCellName(defaultCell);
105 if (code < 0)
106 AfxMessageBox(_T("Error determining root cell name."));
107 else
108 m_strCellName = defaultCell;
111 UpdateData(FALSE);
113 return TRUE; // return TRUE unless you set the focus to a control
116 void CKlogDlg::OnOK()
118 char *reason;
120 UpdateData();
122 HOURGLASS hg;
124 if (kl_Authenticate(m_strCellName, m_strName, m_strPassword, &reason)) {
125 CString strReason(reason);
126 AfxMessageBox(strReason);
127 return;
130 CDialog::OnOK();
133 void CKlogDlg::OnChangeName()
135 CheckEnableOk();
138 void CKlogDlg::OnChangeCellName()
140 CheckEnableOk();
143 void CKlogDlg:: CheckEnableOk()
145 UpdateData();
147 m_OK.EnableWindow(!m_strCellName.IsEmpty() && !m_strName.IsEmpty() && !m_strPassword.IsEmpty());
150 void CKlogDlg::OnChangePassword()
152 CheckEnableOk();
155 void CKlogDlg::OnHelp()
157 ShowHelp(m_hWnd, GET_TOKENS_HELP_ID);