Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

240 lines
7.5 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. // Copyright (c) 2002 Microsoft Corporation. All rights reserved.
  3. // Copyright (c) 2002 OSR Open Systems Resources, Inc.
  4. //
  5. // LogFileDlg.cpp : implementation file
  6. //////////////////////////////////////////////////////////////////////////////
  7. #include "stdafx.h"
  8. #include <tchar.h>
  9. #include <wmistr.h>
  10. #include <initguid.h>
  11. extern "C" {
  12. #include <evntrace.h>
  13. }
  14. #include <traceprt.h>
  15. #include "TraceView.h"
  16. #include "LogSession.h"
  17. #include "DisplayDlg.h"
  18. #include "LogFileDlg.h"
  19. // CLogFileDlg dialog
  20. IMPLEMENT_DYNAMIC(CLogFileDlg, CDialog)
  21. CLogFileDlg::CLogFileDlg(CWnd* pParent, CLogSession *pLogSession)
  22. : CDialog(CLogFileDlg::IDD, pParent)
  23. {
  24. ASSERT(pLogSession != NULL);
  25. m_pLogSession = pLogSession;
  26. m_pLogSession->m_bDisplayExistingLogFileOnly = TRUE;
  27. //
  28. // Initialize summary and listing file flags
  29. //
  30. m_bWriteListingFile = FALSE;
  31. m_bWriteSummaryFile = FALSE;
  32. }
  33. CLogFileDlg::~CLogFileDlg()
  34. {
  35. }
  36. BOOL CLogFileDlg::OnInitDialog()
  37. {
  38. CString str;
  39. BOOL retVal;
  40. CDisplayDlg *pDisplayDlg = NULL;
  41. retVal = CDialog::OnInitDialog();
  42. pDisplayDlg = m_pLogSession->GetDisplayWnd();
  43. //
  44. // setup the listing and summary file edit and check boxes
  45. //
  46. if(NULL == pDisplayDlg) {
  47. m_listingFileName = (LPCTSTR)m_pLogSession->GetDisplayName();
  48. m_listingFileName +=_T(".out");
  49. ((CEdit *)GetDlgItem(IDC_LISTING_EDIT))->SetWindowText(m_listingFileName);
  50. m_summaryFileName = (LPCTSTR)m_pLogSession->GetDisplayName();
  51. m_summaryFileName +=_T(".sum");
  52. ((CEdit *)GetDlgItem(IDC_SUMMARY_EDIT))->SetWindowText(m_summaryFileName);
  53. //
  54. // Disable the edit boxes
  55. //
  56. ((CEdit *)GetDlgItem(IDC_LISTING_EDIT))->EnableWindow(m_bWriteListingFile);
  57. ((CEdit *)GetDlgItem(IDC_SUMMARY_EDIT))->EnableWindow(m_bWriteSummaryFile);
  58. } else {
  59. ((CEdit *)GetDlgItem(IDC_LISTING_EDIT))->SetWindowText(pDisplayDlg->m_listingFileName);
  60. ((CEdit *)GetDlgItem(IDC_SUMMARY_EDIT))->SetWindowText(pDisplayDlg->m_summaryFileName);
  61. ((CButton *)GetDlgItem(IDC_LISTING_FILE_CHECK))->SetCheck(pDisplayDlg->m_bWriteListingFile);
  62. ((CButton *)GetDlgItem(IDC_SUMMARY_FILE_CHECK))->SetCheck(pDisplayDlg->m_bWriteSummaryFile);
  63. //
  64. // Enable or disable the edit boxes as appropriate
  65. //
  66. ((CEdit *)GetDlgItem(IDC_LISTING_EDIT))->EnableWindow(pDisplayDlg->m_bWriteListingFile && !m_pLogSession->m_bTraceActive);
  67. ((CEdit *)GetDlgItem(IDC_SUMMARY_EDIT))->EnableWindow(pDisplayDlg->m_bWriteSummaryFile && !m_pLogSession->m_bTraceActive);
  68. //
  69. // Set the summary and listing check boxes as appropriate
  70. //
  71. ((CButton *)GetDlgItem(IDC_LISTING_FILE_CHECK))->SetCheck(pDisplayDlg->m_bWriteListingFile);
  72. ((CButton *)GetDlgItem(IDC_SUMMARY_FILE_CHECK))->SetCheck(pDisplayDlg->m_bWriteSummaryFile);
  73. //
  74. // Enable the summary and listing check boxes as appropriate
  75. //
  76. ((CButton *)GetDlgItem(IDC_LISTING_FILE_CHECK))->EnableWindow(!m_pLogSession->m_bTraceActive);
  77. ((CButton *)GetDlgItem(IDC_SUMMARY_FILE_CHECK))->EnableWindow(!m_pLogSession->m_bTraceActive);
  78. }
  79. //
  80. // setup the logfile edit box
  81. //
  82. ((CEdit *)GetDlgItem(IDC_LOGFILE_EDIT))->SetWindowText(m_pLogSession->m_logFileName);
  83. return retVal;
  84. }
  85. void CLogFileDlg::DoDataExchange(CDataExchange* pDX)
  86. {
  87. CDialog::DoDataExchange(pDX);
  88. DDX_Control(pDX, IDC_LOGFILE_EDIT, m_logFileName);
  89. DDX_Control(pDX, IDC_LISTING_EDIT, m_listingFile);
  90. DDX_Control(pDX, IDC_SUMMARY_EDIT, m_summaryFile);
  91. }
  92. BEGIN_MESSAGE_MAP(CLogFileDlg, CDialog)
  93. ON_BN_CLICKED(IDC_LOGFILE_BROWSE_BUTTON, OnBnClickedLogfileBrowseButton)
  94. ON_BN_CLICKED(IDC_LISTING_FILE_CHECK, OnBnClickedListingFileCheck)
  95. ON_BN_CLICKED(IDC_SUMMARY_FILE_CHECK, OnBnClickedSummaryFileCheck)
  96. ON_BN_CLICKED(IDOK, OnBnClickedOk)
  97. END_MESSAGE_MAP()
  98. // CLogFileDlg message handlers
  99. void CLogFileDlg::OnBnClickedLogfileBrowseButton()
  100. {
  101. //
  102. // Use the common controls file open dialog
  103. //
  104. CFileDialog fileDlg(TRUE,_T("etl"),_T("*.etl"),
  105. OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST |
  106. OFN_READONLY | OFN_HIDEREADONLY |
  107. OFN_EXPLORER | OFN_NOCHANGEDIR,
  108. _T("Log Session Files (*.etl)|*.etl|All Files (*.*)|*.*||"),
  109. this);
  110. //
  111. // Pop the dialog... Any error, just return
  112. //
  113. if( fileDlg.DoModal()!=IDOK ) {
  114. return;
  115. }
  116. //
  117. // Get the file name
  118. //
  119. m_pLogSession->m_logFileName = fileDlg.GetPathName();
  120. m_logFileName.SetWindowText(m_pLogSession->m_logFileName);
  121. m_logFileName.SetFocus();
  122. }
  123. void CLogFileDlg::OnBnClickedListingFileCheck()
  124. {
  125. BOOL isChecked;
  126. isChecked = (BOOL)((CButton *)GetDlgItem(IDC_LISTING_FILE_CHECK))->GetCheck();
  127. //
  128. // enable the edit box as appropriate
  129. //
  130. ((CEdit *)GetDlgItem(IDC_LISTING_EDIT))->EnableWindow(isChecked);
  131. }
  132. void CLogFileDlg::OnBnClickedSummaryFileCheck()
  133. {
  134. BOOL isChecked;
  135. isChecked = (BOOL)((CButton *)GetDlgItem(IDC_SUMMARY_FILE_CHECK))->GetCheck();
  136. //
  137. // enable the edit box as appropriate
  138. //
  139. ((CEdit *)GetDlgItem(IDC_SUMMARY_EDIT))->EnableWindow(isChecked);
  140. }
  141. void CLogFileDlg::OnBnClickedOk()
  142. {
  143. CString str;
  144. CDisplayDlg *pDisplayDlg = NULL;
  145. pDisplayDlg = m_pLogSession->GetDisplayWnd();
  146. if(pDisplayDlg != NULL) {
  147. //
  148. // If the listing file check box is checked get the file name
  149. // and set the log session to generate the file
  150. //
  151. if(((CButton *)GetDlgItem(IDC_LISTING_FILE_CHECK))->GetCheck()) {
  152. pDisplayDlg->m_bWriteListingFile = TRUE;
  153. m_listingFile.GetWindowText(pDisplayDlg->m_listingFileName);
  154. } else {
  155. pDisplayDlg->m_bWriteListingFile = FALSE;
  156. }
  157. //
  158. // If the summary file check box is checked get the file name
  159. // and set the log session to generate the file
  160. //
  161. if(((CButton *)GetDlgItem(IDC_SUMMARY_FILE_CHECK))->GetCheck()) {
  162. pDisplayDlg->m_bWriteSummaryFile = TRUE;
  163. m_summaryFile.GetWindowText(pDisplayDlg->m_summaryFileName);
  164. } else {
  165. pDisplayDlg->m_bWriteSummaryFile = FALSE;
  166. }
  167. } else {
  168. //
  169. // If the listing file check box is checked get the file name
  170. //
  171. if(((CButton *)GetDlgItem(IDC_LISTING_FILE_CHECK))->GetCheck()) {
  172. m_bWriteListingFile = TRUE;
  173. m_listingFile.GetWindowText(m_listingFileName);
  174. } else {
  175. m_bWriteListingFile = FALSE;
  176. }
  177. //
  178. // If the summary file check box is checked get the file name
  179. //
  180. if(((CButton *)GetDlgItem(IDC_SUMMARY_FILE_CHECK))->GetCheck()) {
  181. m_bWriteSummaryFile = TRUE;
  182. m_summaryFile.GetWindowText(m_summaryFileName);
  183. } else {
  184. m_bWriteSummaryFile = FALSE;
  185. }
  186. }
  187. //
  188. // Get the logfile name, don't exit dialog if it isn't valid
  189. //
  190. m_logFileName.GetWindowText(m_pLogSession->m_logFileName);
  191. if(m_pLogSession->m_logFileName.IsEmpty()) {
  192. AfxMessageBox(_T("A Valid Log File Must Be Provided"));
  193. return;
  194. }
  195. OnOK();
  196. EndDialog(1);
  197. }