Windows: remove trailing whitespace
[openafs.git] / src / WINNT / client_exp / auth_dlg.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 "stdafx.h"
11 #include <winsock2.h>
12 #include <ws2tcpip.h>
13
14 extern "C" {
15 #include <afs/param.h>
16 #include <afs/stds.h>
17 }
18
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"
24
25 #ifdef _DEBUG
26 #define new DEBUG_NEW
27 #undef THIS_FILE
28 static char THIS_FILE[] = __FILE__;
29 #endif
30
31 /////////////////////////////////////////////////////////////////////////////
32 // CAuthDlg dialog
33
34
35 CAuthDlg::CAuthDlg(CWnd* pParent /*=NULL*/)
36         : CDialog()
37 {
38         InitModalIndirect (TaLocale_GetDialogResource (CAuthDlg::IDD), pParent);
39
40         //{{AFX_DATA_INIT(CAuthDlg)
41         //}}AFX_DATA_INIT
42 }
43
44
45 void CAuthDlg::DoDataExchange(CDataExchange* pDX)
46 {
47         CDialog::DoDataExchange(pDX);
48         //{{AFX_DATA_MAP(CAuthDlg)
49         DDX_Control(pDX, IDC_TOKEN_LIST, m_TokenList);
50         //}}AFX_DATA_MAP
51 }
52
53
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()
61
62 /////////////////////////////////////////////////////////////////////////////
63 // CAuthDlg message handlers
64
65 BOOL CAuthDlg::OnInitDialog()
66 {
67         CDialog::OnInitDialog();
68
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 };
74
75         m_TokenList.SetTabStops(sizeof(tabs) / sizeof(int), tabs);
76
77         FillTokenList();
78
79         return TRUE;  // return TRUE unless you set the focus to a control
80                       // EXCEPTION: OCX Property Pages should return FALSE
81 }
82
83 void CAuthDlg::OnGetTokens()
84 {
85         CKlogDlg dlg;
86
87         dlg.SetCellName(GetSelectedCellName());
88
89         if (dlg.DoModal() == IDOK)
90                 FillTokenList();
91 }
92
93 void CAuthDlg::OnDiscardTokens()
94 {
95         CUnlogDlg dlg;
96
97         dlg.SetCellName(GetSelectedCellName());
98
99         if (dlg.DoModal() == IDOK)
100                 FillTokenList();
101 }
102
103 void CAuthDlg::FillTokenList()
104 {
105         m_TokenList.ResetContent();
106
107         CStringArray tokenInfo;
108         if (!GetTokenInfo(tokenInfo))
109                 return;
110
111         for (int i = 0; i < tokenInfo.GetSize(); i++)
112                 m_TokenList.AddString(tokenInfo[i]);
113 }
114
115 CString CAuthDlg::GetSelectedCellName()
116 {
117         int nIndex = m_TokenList.GetCurSel();
118         if (nIndex < 0)
119                 return "";
120
121         CString strTokenInfo;
122         m_TokenList.GetText(nIndex, strTokenInfo);
123
124         int nPos = strTokenInfo.ReverseFind('\t');
125
126         return strTokenInfo.Mid(nPos + 1);
127 }
128
129 void CAuthDlg::OnHelp()
130 {
131         ShowHelp(m_hWnd, AUTHENTICATION_HELP_ID);
132 }
133