diff options
| author | Sam Hartman <hartmans@mit.edu> | 2011-09-28 21:02:14 +0000 |
|---|---|---|
| committer | Sam Hartman <hartmans@mit.edu> | 2011-09-28 21:02:14 +0000 |
| commit | caef99b21536d9e8c2f9c637fcf020b4e082db5d (patch) | |
| tree | b360ec8449876ea170691685cde758d9849fc8ef /src/windows/leash/LeashDebugWindow.cpp | |
| parent | 8481c14298a1886f63bec0d7cdfd800a86b4c127 (diff) | |
| download | krb5-caef99b21536d9e8c2f9c637fcf020b4e082db5d.tar.gz krb5-caef99b21536d9e8c2f9c637fcf020b4e082db5d.tar.xz krb5-caef99b21536d9e8c2f9c637fcf020b4e082db5d.zip | |
Initial import of KFW 3.2.2 Leash32 code
Signed-off-by: Alexey Melnikov <aamelnikov@gmail.com>
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25278 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/windows/leash/LeashDebugWindow.cpp')
| -rw-r--r-- | src/windows/leash/LeashDebugWindow.cpp | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/src/windows/leash/LeashDebugWindow.cpp b/src/windows/leash/LeashDebugWindow.cpp new file mode 100644 index 0000000000..6e12903aec --- /dev/null +++ b/src/windows/leash/LeashDebugWindow.cpp @@ -0,0 +1,187 @@ +// ************************************************************************************** +// File: LeashDebugWindow.cpp +// By: Arthur David Leather +// Created: 12/02/98 +// Copyright @1998 Massachusetts Institute of Technology - All rights reserved. +// Description: CPP file for LeashDebugWindow.h. Contains variables and functions +// for the Leash Debug Window +// +// History: +// +// MM/DD/YY Inits Description of Change +// 12/02/98 ADL Original +// ************************************************************************************** + + + +#include "stdafx.h" +#include "leash.h" +#include "LeashDebugWindow.h" +#include "lglobals.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CLeashDebugWindow dialog + + +CLeashDebugWindow::CLeashDebugWindow(CWnd* pParent /*=NULL*/) + : CDialog(CLeashDebugWindow::IDD, pParent) +{ + //{{AFX_DATA_INIT(CLeashDebugWindow) + //}}AFX_DATA_INIT + + m_pView = NULL; +} + +CLeashDebugWindow::CLeashDebugWindow(CFormView* pView) +{ + m_pView = pView; +} + +void CLeashDebugWindow::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CLeashDebugWindow) + DDX_Control(pDX, IDC_DEBUG_LISTBOX, m_debugListBox); + DDX_Control(pDX, IDC_LOG_FILE_LOCATION_TEXT, m_debugFile); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CLeashDebugWindow, CDialog) + //{{AFX_MSG_MAP(CLeashDebugWindow) + ON_WM_SHOWWINDOW() + ON_BN_CLICKED(IDC_COPY_TO_CLIPBOARD, OnCopyToClipboard) + ON_WM_DESTROY() + ON_WM_CLOSE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CLeashDebugWindow message handlers + + +BOOL CLeashDebugWindow::Create(const LPCSTR debugFilePath) +{ + m_debugFilePath = debugFilePath; + return CDialog::Create(CLeashDebugWindow::IDD); +} + + +void CLeashDebugWindow::OnCancel() +{ + if (m_pView != NULL) + { + CWinApp* pApp; + pApp = AfxGetApp(); + pApp->WriteProfileInt("Settings", "DebugWindow", FALSE_FLAG); + m_pView->PostMessage(WM_GOODBYE, IDCANCEL); // modeless case + pset_krb_debug(OFF); + pset_krb_ap_req_debug(OFF); + } + else + { + CDialog::OnCancel(); // modal case + } +} + +void CLeashDebugWindow::OnOK() +{ + if (m_pView != NULL) + { + // modeless case + UpdateData(TRUE); + m_pView->PostMessage(WM_GOODBYE, IDOK); + } + else + { + CDialog::OnOK(); // modal case + } +} + +BOOL CLeashDebugWindow::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // Set Debug flags + pset_krb_debug(ON); //(int)m_debugListBox.GetSafeHwnd() + pset_krb_ap_req_debug(ON); + + if (*m_debugFilePath != 0) + SetDlgItemText(IDC_LOG_FILE_LOCATION_TEXT, m_debugFilePath); + else + SetDlgItemText(IDC_LOG_FILE_LOCATION_TEXT, "Not Available"); + + if (!m_debugListBox.GetCount()) + GetDlgItem(IDC_COPY_TO_CLIPBOARD)->EnableWindow(FALSE); + + m_CopyButton = FALSE; + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CLeashDebugWindow::OnShowWindow(BOOL bShow, UINT nStatus) +{ + CDialog::OnShowWindow(bShow, nStatus); +} + +void CLeashDebugWindow::OnCopyToClipboard() +{ + if (!OpenClipboard()) + { + MessageBox("Unable to open Clipboard!", "Error", MB_OK); + return; + } + + EmptyClipboard(); + + int maxItems = m_debugListBox.GetCount(); + const int MAX_MEM = maxItems * 90; // 90 chars per line seems safe like a safe bet + + HGLOBAL hDebugText = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, MAX_MEM); + if (NULL != hDebugText) + { + CString listboxItem; + LPSTR pDebugText = (LPSTR) GlobalLock(hDebugText); + if (!pDebugText) + { + MessageBox("Unable to write to Clipboard!", "Error", MB_OK); + ASSERT(pDebugText); + return; + } + + *pDebugText = 0; + for (int xItem = 0; xItem < maxItems; xItem++) + { + m_debugListBox.GetText(xItem, listboxItem); + strcat(pDebugText, listboxItem); + strcat(pDebugText, "\r\n"); + } + + GlobalUnlock(hDebugText); + } + + if (NULL != hDebugText) + SetClipboardData(CF_TEXT, hDebugText); + + CloseClipboard(); + MessageBox("Copy to Clipboard was Successful!\r\n Paste it in your favorite editor.", + "Note", MB_OK); +} + +BOOL CLeashDebugWindow::PreTranslateMessage(MSG* pMsg) +{ + if (!m_CopyButton && m_debugListBox.GetCount()) + { + m_CopyButton = TRUE; + GetDlgItem(IDC_COPY_TO_CLIPBOARD)->EnableWindow(TRUE); + } + + return CDialog::PreTranslateMessage(pMsg); +} |
