rx: Remove RX_CALL_BUSY
[openafs.git] / src / WINNT / client_exp / unlog_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 <afsconfig.h>
16 #include <afs/param.h>
17 #include <roken.h>
18 #include <afs/stds.h>
19 }
20
21 #include "unlog_dlg.h"
22
23 extern "C" {
24 #include <afs/auth.h>
25 #include <cm_config.h>
26 }
27
28 #ifdef _DEBUG
29 #define new DEBUG_NEW
30 #undef THIS_FILE
31 static char THIS_FILE[] = __FILE__;
32 #endif
33
34 /////////////////////////////////////////////////////////////////////////////
35 // CUnlogDlg dialog
36
37 CUnlogDlg::CUnlogDlg(CWnd* pParent /*=NULL*/)
38         : CDialog()
39 {
40         InitModalIndirect (TaLocale_GetDialogResource (CUnlogDlg::IDD), pParent);
41
42         //{{AFX_DATA_INIT(CUnlogDlg)
43         m_strCellName = _T("");
44         //}}AFX_DATA_INIT
45 }
46
47 void CUnlogDlg::DoDataExchange(CDataExchange* pDX)
48 {
49         CDialog::DoDataExchange(pDX);
50         //{{AFX_DATA_MAP(CUnlogDlg)
51         DDX_Control(pDX, IDOK, m_OK);
52         DDX_Text(pDX, IDC_CELL_NAME, m_strCellName);
53         //}}AFX_DATA_MAP
54 }
55
56 BEGIN_MESSAGE_MAP(CUnlogDlg, CDialog)
57         //{{AFX_MSG_MAP(CUnlogDlg)
58         ON_EN_CHANGE(IDC_CELL_NAME, OnChangeCellName)
59         ON_BN_CLICKED(IDHELP, OnHelp)
60         //}}AFX_MSG_MAP
61 END_MESSAGE_MAP()
62
63 /////////////////////////////////////////////////////////////////////////////
64 // CUnlogDlg message handlers
65
66 BOOL CUnlogDlg::OnInitDialog()
67 {
68         CDialog::OnInitDialog();
69
70         if (m_strCellName.IsEmpty()) {
71                 char defaultCell[256];
72                 long code = cm_GetRootCellName(defaultCell);
73                 if (code < 0)
74                     AfxMessageBox(_T("Error determining root cell name."));
75                 else
76                         m_strCellName = defaultCell;
77         }
78
79         UpdateData(FALSE);
80
81         return TRUE;  // return TRUE  unless you set the focus to a control
82 }
83
84 int kl_Unlog(const CString& strCellName)
85 {
86         struct ktc_principal server;
87         int code;
88
89         if (strCellName.IsEmpty())
90                 code = ktc_ForgetAllTokens();
91         else {
92             CStringA astrCellName(strCellName);
93
94             strcpy(server.cell, astrCellName);
95                 server.instance[0] = '\0';
96                 strcpy(server.name, "afs");
97                 code = ktc_ForgetToken(&server);
98         }
99
100         if (code == KTC_NOCM)
101             AfxMessageBox(_T("AFS service may not have started"));
102         else if (code) {
103             CString xreason;
104
105             xreason.Format(_T("Unexpected error, code %d"), code);
106                 AfxMessageBox(xreason);
107         }
108
109         return code;
110 }
111
112 void CUnlogDlg::OnChangeCellName()
113 {
114         UpdateData();
115
116         m_OK.EnableWindow(!m_strCellName.IsEmpty());
117 }
118
119 void CUnlogDlg::OnOK()
120 {
121         if (kl_Unlog(m_strCellName))
122                 return;
123
124         CDialog::OnOK();
125 }
126
127 void CUnlogDlg::OnHelp()
128 {
129         ShowHelp(m_hWnd, DISCARD_TOKENS_HELP_ID);
130 }
131