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 <afsconfig.h>
16 #include <afs/param.h>
21 #include "unlog_dlg.h"
25 #include <cm_config.h>
31 static char THIS_FILE[] = __FILE__;
34 /////////////////////////////////////////////////////////////////////////////
37 CUnlogDlg::CUnlogDlg(CWnd* pParent /*=NULL*/)
40 InitModalIndirect (TaLocale_GetDialogResource (CUnlogDlg::IDD), pParent);
42 //{{AFX_DATA_INIT(CUnlogDlg)
43 m_strCellName = _T("");
47 void CUnlogDlg::DoDataExchange(CDataExchange* pDX)
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);
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)
63 /////////////////////////////////////////////////////////////////////////////
64 // CUnlogDlg message handlers
66 BOOL CUnlogDlg::OnInitDialog()
68 CDialog::OnInitDialog();
70 if (m_strCellName.IsEmpty()) {
71 char defaultCell[256];
72 long code = cm_GetRootCellName(defaultCell);
74 AfxMessageBox(_T("Error determining root cell name."));
76 m_strCellName = defaultCell;
81 return TRUE; // return TRUE unless you set the focus to a control
84 int kl_Unlog(const CString& strCellName)
86 struct ktc_principal server;
89 if (strCellName.IsEmpty())
90 code = ktc_ForgetAllTokens();
92 CStringA astrCellName(strCellName);
94 strcpy(server.cell, astrCellName);
95 server.instance[0] = '\0';
96 strcpy(server.name, "afs");
97 code = ktc_ForgetToken(&server);
100 if (code == KTC_NOCM)
101 AfxMessageBox(_T("AFS service may not have started"));
105 xreason.Format(_T("Unexpected error, code %d"), code);
106 AfxMessageBox(xreason);
112 void CUnlogDlg::OnChangeCellName()
116 m_OK.EnableWindow(!m_strCellName.IsEmpty());
119 void CUnlogDlg::OnOK()
121 if (kl_Unlog(m_strCellName))
127 void CUnlogDlg::OnHelp()
129 ShowHelp(m_hWnd, DISCARD_TOKENS_HELP_ID);