Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / client_exp / auth_dlg.cpp
blobc2473bacee11e8087e6b757d3dcc89418e4cba2a
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 <afs/param.h>
16 #include <afs/stds.h>
19 #include "afs_shl_ext.h"
20 #include "auth_dlg.h"
21 #include "klog_dlg.h"
22 #include "unlog_dlg.h"
23 #include "gui2fs.h"
25 #ifdef _DEBUG
26 #define new DEBUG_NEW
27 #undef THIS_FILE
28 static char THIS_FILE[] = __FILE__;
29 #endif
31 /////////////////////////////////////////////////////////////////////////////
32 // CAuthDlg dialog
35 CAuthDlg::CAuthDlg(CWnd* pParent /*=NULL*/)
36 : CDialog()
38 InitModalIndirect (TaLocale_GetDialogResource (CAuthDlg::IDD), pParent);
40 //{{AFX_DATA_INIT(CAuthDlg)
41 //}}AFX_DATA_INIT
45 void CAuthDlg::DoDataExchange(CDataExchange* pDX)
47 CDialog::DoDataExchange(pDX);
48 //{{AFX_DATA_MAP(CAuthDlg)
49 DDX_Control(pDX, IDC_TOKEN_LIST, m_TokenList);
50 //}}AFX_DATA_MAP
54 BEGIN_MESSAGE_MAP(CAuthDlg, CDialog)
55 //{{AFX_MSG_MAP(CAuthDlg)
56 ON_BN_CLICKED(ID_GET_TOKENS, OnGetTokens)
57 ON_BN_CLICKED(ID_DISCARD_TOKENS, OnDiscardTokens)
58 ON_BN_CLICKED(IDHELP, OnHelp)
59 //}}AFX_MSG_MAP
60 END_MESSAGE_MAP()
62 /////////////////////////////////////////////////////////////////////////////
63 // CAuthDlg message handlers
65 BOOL CAuthDlg::OnInitDialog()
67 CDialog::OnInitDialog();
69 // The final tab is for an extra CellName entry that is
70 // there so we can easily parse it out when someone wants
71 // to get or discard tokens. It is placed so the user can't
72 // see it. It's kind of a hack, but not too bad.
73 int tabs[] = { 93, 211, 700 };
75 m_TokenList.SetTabStops(sizeof(tabs) / sizeof(int), tabs);
77 FillTokenList();
79 return TRUE; // return TRUE unless you set the focus to a control
80 // EXCEPTION: OCX Property Pages should return FALSE
83 void CAuthDlg::OnGetTokens()
85 CKlogDlg dlg;
87 dlg.SetCellName(GetSelectedCellName());
89 if (dlg.DoModal() == IDOK)
90 FillTokenList();
93 void CAuthDlg::OnDiscardTokens()
95 CUnlogDlg dlg;
97 dlg.SetCellName(GetSelectedCellName());
99 if (dlg.DoModal() == IDOK)
100 FillTokenList();
103 void CAuthDlg::FillTokenList()
105 m_TokenList.ResetContent();
107 CStringArray tokenInfo;
108 if (!GetTokenInfo(tokenInfo))
109 return;
111 for (int i = 0; i < tokenInfo.GetSize(); i++)
112 m_TokenList.AddString(tokenInfo[i]);
115 CString CAuthDlg::GetSelectedCellName()
117 int nIndex = m_TokenList.GetCurSel();
118 if (nIndex < 0)
119 return "";
121 CString strTokenInfo;
122 m_TokenList.GetText(nIndex, strTokenInfo);
124 int nPos = strTokenInfo.ReverseFind('\t');
126 return strTokenInfo.Mid(nPos + 1);
129 void CAuthDlg::OnHelp()
131 ShowHelp(m_hWnd, AUTHENTICATION_HELP_ID);