2 * Copyright 2000, International Business Machines Corporation and others.
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
11 #include <afs/param.h>
16 #include "unlog_dlg.h"
20 #include <cm_config.h>
26 static char THIS_FILE[] = __FILE__;
29 /////////////////////////////////////////////////////////////////////////////
32 CUnlogDlg::CUnlogDlg(CWnd* pParent /*=NULL*/)
35 InitModalIndirect (TaLocale_GetDialogResource (CUnlogDlg::IDD), pParent);
37 //{{AFX_DATA_INIT(CUnlogDlg)
38 m_strCellName = _T("");
42 void CUnlogDlg::DoDataExchange(CDataExchange* pDX)
44 CDialog::DoDataExchange(pDX);
45 //{{AFX_DATA_MAP(CUnlogDlg)
46 DDX_Control(pDX, IDOK, m_OK);
47 DDX_Text(pDX, IDC_CELL_NAME, m_strCellName);
51 BEGIN_MESSAGE_MAP(CUnlogDlg, CDialog)
52 //{{AFX_MSG_MAP(CUnlogDlg)
53 ON_EN_CHANGE(IDC_CELL_NAME, OnChangeCellName)
54 ON_BN_CLICKED(IDHELP, OnHelp)
58 /////////////////////////////////////////////////////////////////////////////
59 // CUnlogDlg message handlers
61 BOOL CUnlogDlg::OnInitDialog()
63 CDialog::OnInitDialog();
65 if (m_strCellName.IsEmpty()) {
66 char defaultCell[256];
67 long code = cm_GetRootCellName(defaultCell);
69 AfxMessageBox("Error determining root cell name.");
71 m_strCellName = defaultCell;
76 return TRUE; // return TRUE unless you set the focus to a control
79 int kl_Unlog(const CString& strCellName)
81 struct ktc_principal server;
83 static char xreason[100];
85 if (strCellName.IsEmpty())
86 code = ktc_ForgetAllTokens();
88 strcpy(server.cell, strCellName);
89 server.instance[0] = '\0';
90 strcpy(server.name, "afs");
91 code = ktc_ForgetToken(&server);
95 AfxMessageBox("AFS service may not have started");
97 sprintf(xreason, "Unexpected error, code %d", code);
98 AfxMessageBox(xreason);
104 void CUnlogDlg::OnChangeCellName()
108 m_OK.EnableWindow(!m_strCellName.IsEmpty());
111 void CUnlogDlg::OnOK()
113 if (kl_Unlog(m_strCellName))
119 void CUnlogDlg::OnHelp()
121 ShowHelp(m_hWnd, DISCARD_TOKENS_HELP_ID);