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
15 #include <afs/param.h>
19 #include "unlog_dlg.h"
23 #include <cm_config.h>
29 static char THIS_FILE[] = __FILE__;
32 /////////////////////////////////////////////////////////////////////////////
35 CUnlogDlg::CUnlogDlg(CWnd* pParent /*=NULL*/)
38 InitModalIndirect (TaLocale_GetDialogResource (CUnlogDlg::IDD), pParent);
40 //{{AFX_DATA_INIT(CUnlogDlg)
41 m_strCellName = _T("");
45 void CUnlogDlg::DoDataExchange(CDataExchange* pDX)
47 CDialog::DoDataExchange(pDX);
48 //{{AFX_DATA_MAP(CUnlogDlg)
49 DDX_Control(pDX, IDOK, m_OK);
50 DDX_Text(pDX, IDC_CELL_NAME, m_strCellName);
54 BEGIN_MESSAGE_MAP(CUnlogDlg, CDialog)
55 //{{AFX_MSG_MAP(CUnlogDlg)
56 ON_EN_CHANGE(IDC_CELL_NAME, OnChangeCellName)
57 ON_BN_CLICKED(IDHELP, OnHelp)
61 /////////////////////////////////////////////////////////////////////////////
62 // CUnlogDlg message handlers
64 BOOL CUnlogDlg::OnInitDialog()
66 CDialog::OnInitDialog();
68 if (m_strCellName.IsEmpty()) {
69 char defaultCell[256];
70 long code = cm_GetRootCellName(defaultCell);
72 AfxMessageBox(_T("Error determining root cell name."));
74 m_strCellName = defaultCell;
79 return TRUE; // return TRUE unless you set the focus to a control
82 int kl_Unlog(const CString& strCellName)
84 struct ktc_principal server;
87 if (strCellName.IsEmpty())
88 code = ktc_ForgetAllTokens();
90 CStringA astrCellName(strCellName);
92 strcpy(server.cell, astrCellName);
93 server.instance[0] = '\0';
94 strcpy(server.name, "afs");
95 code = ktc_ForgetToken(&server);
99 AfxMessageBox(_T("AFS service may not have started"));
103 xreason.Format(_T("Unexpected error, code %d"), code);
104 AfxMessageBox(xreason);
110 void CUnlogDlg::OnChangeCellName()
114 m_OK.EnableWindow(!m_strCellName.IsEmpty());
117 void CUnlogDlg::OnOK()
119 if (kl_Unlog(m_strCellName))
125 void CUnlogDlg::OnHelp()
127 ShowHelp(m_hWnd, DISCARD_TOKENS_HELP_ID);