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("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;
86 static char xreason[100];
88 if (strCellName.IsEmpty())
89 code = ktc_ForgetAllTokens();
91 strcpy(server.cell, strCellName);
92 server.instance[0] = '\0';
93 strcpy(server.name, "afs");
94 code = ktc_ForgetToken(&server);
98 AfxMessageBox("AFS service may not have started");
100 sprintf(xreason, "Unexpected error, code %d", code);
101 AfxMessageBox(xreason);
107 void CUnlogDlg::OnChangeCellName()
111 m_OK.EnableWindow(!m_strCellName.IsEmpty());
114 void CUnlogDlg::OnOK()
116 if (kl_Unlog(m_strCellName))
122 void CUnlogDlg::OnHelp()
124 ShowHelp(m_hWnd, DISCARD_TOKENS_HELP_ID);