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.

298 lines
8.4 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. // Copyright (c) 2002 Microsoft Corporation. All rights reserved.
  3. // Copyright (c) 2002 OSR Open Systems Resources, Inc.
  4. //
  5. // LogSessionInformationDlg.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 "ListCtrlEx.h"
  19. #include "LogSessionDlg.h"
  20. #include "LogSessionInformationDlg.h"
  21. #include "ProviderSetupDlg.h"
  22. #include "LogDisplayOptionDlg.h"
  23. #include "LogSessionPropSht.h"
  24. #include "LogSessionOutputOptionDlg.h"
  25. #include "LogSessionAdvPropSht.h"
  26. // CLogSessionInformationDlg dialog
  27. IMPLEMENT_DYNAMIC(CLogSessionInformationDlg, CPropertyPage)
  28. CLogSessionInformationDlg::CLogSessionInformationDlg()
  29. : CPropertyPage(CLogSessionInformationDlg::IDD)
  30. {
  31. m_pLogSession = NULL;
  32. }
  33. CLogSessionInformationDlg::~CLogSessionInformationDlg()
  34. {
  35. }
  36. BOOL CLogSessionInformationDlg::OnInitDialog()
  37. {
  38. BOOL retVal;
  39. CLogSessionPropSht *pSheet = (CLogSessionPropSht *)GetParent();
  40. retVal = CPropertyPage::OnInitDialog();
  41. pSheet = (CLogSessionPropSht*) GetParent();
  42. //
  43. // Initialize settings from the parent property sheet
  44. //
  45. m_pLogSession = pSheet->m_pLogSession;
  46. m_bAppend = pSheet->m_bAppend;
  47. m_bRealTime = pSheet->m_bRealTime;
  48. m_bWriteLogFile = pSheet->m_bWriteLogFile;
  49. m_logFileNameString = pSheet->m_logFileName;
  50. m_displayNameString = pSheet->m_displayName;
  51. return retVal;
  52. }
  53. //
  54. // Enable the correct wizard buttons
  55. //
  56. BOOL CLogSessionInformationDlg::OnSetActive()
  57. {
  58. CString str;
  59. CDisplayDlg *pDisplayDlg;
  60. CLogSessionPropSht *pSheet = (CLogSessionPropSht*) GetParent();
  61. LONG numberOfEntries;
  62. BOOL retVal;
  63. retVal = CPropertyPage::OnSetActive();
  64. //
  65. // Fix the title if in Wizard mode
  66. //
  67. if(pSheet->IsWizard()) {
  68. CTabCtrl* pTab = pSheet->GetTabControl();
  69. //
  70. //If its not the active page, just set the tab item
  71. //
  72. TC_ITEM ti;
  73. ti.mask = TCIF_TEXT;
  74. ti.pszText =_T("Create New Log Session");
  75. VERIFY(pTab->SetItem(1, &ti));
  76. }
  77. //
  78. // Enable the back and finish buttons
  79. //
  80. pSheet->SetWizardButtons(PSWIZB_BACK|PSWIZB_FINISH);
  81. //
  82. // Update the display name
  83. //
  84. m_displayNameString = pSheet->m_displayName;
  85. //
  86. // set the log session name
  87. //
  88. m_logSessionName.SetWindowText(m_displayNameString);
  89. //
  90. // Disable the session name edit if using kernel logger or if the trace is active
  91. //
  92. if(m_displayNameString.Compare(KERNEL_LOGGER_NAME)) {
  93. m_logSessionName.EnableWindow(!m_pLogSession->m_bTraceActive);
  94. } else {
  95. m_logSessionName.EnableWindow(FALSE);
  96. }
  97. //
  98. // set the logfile name
  99. //
  100. m_logFileName.SetWindowText(m_logFileNameString);
  101. //
  102. // set the logfile write check
  103. //
  104. ((CButton *)GetDlgItem(IDC_WRITE_LOGFILE_CHECK))->SetCheck(m_bWriteLogFile);
  105. //
  106. // Enable log file stuff as appropriate
  107. //
  108. ((CButton *)GetDlgItem(IDC_APPEND_CHECK))->EnableWindow(!m_pLogSession->m_bTraceActive && m_bWriteLogFile);
  109. ((CEdit *)GetDlgItem(IDC_LOGFILE_EDIT))->EnableWindow(m_bWriteLogFile);
  110. ((CButton *)GetDlgItem(IDC_LOGFILE_BROWSE_BUTTON))->EnableWindow(m_bWriteLogFile);
  111. //
  112. // update the append check
  113. //
  114. ((CButton *)GetDlgItem(IDC_APPEND_CHECK))->SetCheck(m_bAppend);
  115. //
  116. // update the real time check
  117. //
  118. ((CButton *)GetDlgItem(IDC_REALTIME_CHECK))->SetCheck(m_bRealTime);
  119. return retVal;
  120. }
  121. BOOL CLogSessionInformationDlg::OnKillActive()
  122. {
  123. CLogSessionPropSht *pSheet = (CLogSessionPropSht *)GetParent();
  124. BOOL retVal= TRUE;
  125. retVal = CPropertyPage::OnKillActive();
  126. pSheet = (CLogSessionPropSht*) GetParent();
  127. //
  128. // Store all settings here so that they are correct if the user
  129. // hits the back button and comes back to us. These settings are
  130. // not propagated back to the parent property sheet yet though.
  131. //
  132. // Note: OnKillActive is not called if the user selects the finish
  133. // button.
  134. //
  135. //
  136. // store the log session name
  137. //
  138. m_logSessionName.GetWindowText(m_displayNameString);
  139. //
  140. // store the logfile name
  141. //
  142. m_logFileName.GetWindowText(m_logFileNameString);
  143. //
  144. // store the logfile write check
  145. //
  146. m_bWriteLogFile = ((CButton *)GetDlgItem(IDC_WRITE_LOGFILE_CHECK))->GetCheck();
  147. //
  148. // store the append check
  149. //
  150. m_bAppend = ((CButton *)GetDlgItem(IDC_APPEND_CHECK))->GetCheck();
  151. //
  152. // store the real time value
  153. //
  154. m_bRealTime = ((CButton *)GetDlgItem(IDC_REALTIME_CHECK))->GetCheck();
  155. return retVal;
  156. }
  157. void CLogSessionInformationDlg::DoDataExchange(CDataExchange* pDX)
  158. {
  159. CPropertyPage::DoDataExchange(pDX);
  160. DDX_Control(pDX, IDC_LOG_NAME_EDIT, m_logSessionName);
  161. DDX_Control(pDX, IDC_LOGFILE_EDIT, m_logFileName);
  162. DDX_Control(pDX, IDC_APPEND_CHECK, m_appendLogFile);
  163. DDX_Control(pDX, IDC_REALTIME_CHECK, m_realTime);
  164. }
  165. BEGIN_MESSAGE_MAP(CLogSessionInformationDlg, CPropertyPage)
  166. ON_BN_CLICKED(IDC_LOGFILE_BROWSE_BUTTON, OnBnClickedLogfileBrowseButton)
  167. ON_BN_CLICKED(IDC_WRITE_LOGFILE_CHECK, OnBnClickedWriteLogfileCheck)
  168. ON_BN_CLICKED(IDC_ADVANCED_BUTTON, OnBnClickedAdvancedButton)
  169. END_MESSAGE_MAP()
  170. // CLogSessionInformationDlg message handlers
  171. void CLogSessionInformationDlg::OnBnClickedLogfileBrowseButton()
  172. {
  173. DWORD flags;
  174. //
  175. // If appending the file must exist; Else prompt user to
  176. // create if the file doesn't exist
  177. //
  178. flags = (m_appendLogFile.GetCheck() ? OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST |
  179. OFN_HIDEREADONLY | OFN_EXPLORER |
  180. OFN_NOCHANGEDIR :
  181. OFN_CREATEPROMPT | OFN_HIDEREADONLY |
  182. OFN_EXPLORER | OFN_NOCHANGEDIR);
  183. //
  184. // Use the common controls file open dialog
  185. //
  186. CFileDialog fileDlg(TRUE,
  187. _T("etl"),_T("*.etl"),
  188. flags,
  189. _T("Log Session Files (*.etl)|*.etl|All Files (*.*)|*.*||"),
  190. this);
  191. //
  192. // Pop the dialog... Any error, just return
  193. //
  194. if( fileDlg.DoModal()!=IDOK ) {
  195. return;
  196. }
  197. //
  198. // Get the file name
  199. //
  200. if(!fileDlg.GetPathName().IsEmpty()) {
  201. //
  202. // Store the file name
  203. //
  204. ((CLogSessionPropSht *)GetParent())->m_pLogSession->m_logFileName =
  205. fileDlg.GetPathName();
  206. //
  207. // Display the file name and give it focus
  208. //
  209. m_logFileName.SetWindowText(fileDlg.GetPathName());
  210. m_logFileName.SetFocus();
  211. }
  212. }
  213. void CLogSessionInformationDlg::OnBnClickedWriteLogfileCheck()
  214. {
  215. //
  216. // Enable or disable the log file name edit box, the append
  217. // check box, and the browse button as appropriate.
  218. //
  219. if(((CButton *)GetDlgItem(IDC_WRITE_LOGFILE_CHECK))->GetCheck()) {
  220. m_logFileName.EnableWindow(TRUE);
  221. m_appendLogFile.EnableWindow(TRUE);
  222. ((CButton *)GetDlgItem(IDC_LOGFILE_BROWSE_BUTTON))->EnableWindow(TRUE);
  223. } else {
  224. m_logFileName.EnableWindow(FALSE);
  225. m_appendLogFile.EnableWindow(FALSE);
  226. ((CButton *)GetDlgItem(IDC_LOGFILE_BROWSE_BUTTON))->EnableWindow(FALSE);
  227. }
  228. }
  229. void CLogSessionInformationDlg::OnBnClickedAdvancedButton()
  230. {
  231. INT_PTR retVal;
  232. CLogSessionPropSht *pSheet = (CLogSessionPropSht *)GetParent();
  233. //
  234. // pop-up our wizard/tab dialog to show/get properties
  235. //
  236. CLogSessionAdvPropSht *pLogSessionAdvPropertySheet =
  237. new CLogSessionAdvPropSht(this, pSheet);
  238. if(NULL == pLogSessionAdvPropertySheet) {
  239. return;
  240. }
  241. retVal = pLogSessionAdvPropertySheet->DoModal();
  242. if(IDOK != retVal) {
  243. //BUGBUG -- make sure options are correct here
  244. }
  245. delete pLogSessionAdvPropertySheet;
  246. }