Source code of Windows XP (NT5)
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.

426 lines
12 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: pglog.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // logging.cpp : implementation file
  11. //
  12. #include "stdafx.h"
  13. #include "acsadmin.h"
  14. #include "pglog.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CPgAccounting property page
  22. IMPLEMENT_DYNCREATE(CPgAccounting, CACSPage)
  23. CPgAccounting::CPgAccounting(CACSSubnetConfig* pConfig) : CACSPage(CPgAccounting::IDD)
  24. {
  25. ASSERT(pConfig);
  26. m_spConfig = pConfig;
  27. DataInit();
  28. }
  29. void CPgAccounting::DataInit()
  30. {
  31. //{{AFX_DATA_INIT(CPgAccounting)
  32. m_bEnableAccounting = ACS_SCADEF_ENABLERSVPMESSAGEACCOUNTING;
  33. m_strLogDir = ACS_SCADEF_RSVPACCOUNTINGFILESLOCATION;
  34. m_dwNumFiles = ACS_SCADEF_MAXNOOFACCOUNTINGFILES;
  35. m_dwLogSize = ACS_SCADEF_MAXSIZEOFRSVPACCOUNTINGFILE;
  36. //}}AFX_DATA_INIT
  37. }
  38. CPgAccounting::CPgAccounting() : CACSPage(CPgAccounting::IDD)
  39. {
  40. DataInit();
  41. }
  42. CPgAccounting::~CPgAccounting()
  43. {
  44. }
  45. void CPgAccounting::DoDataExchange(CDataExchange* pDX)
  46. {
  47. CACSPage::DoDataExchange(pDX);
  48. //{{AFX_DATA_MAP(CPgAccounting)
  49. DDX_Check(pDX, IDC_CHECK_ENABLEACCOUNTING, m_bEnableAccounting);
  50. DDX_Text(pDX, IDC_EDIT_ACC_DIRECTORY, m_strLogDir);
  51. DDV_MaxChars(pDX, m_strLogDir, ACS_SCAV_MAX_LOGFILESLOCATION);
  52. DDX_Text(pDX, IDC_EDIT_ACC_LOGFILES, m_dwNumFiles);
  53. DDV_MinMaxDWord(pDX, m_dwNumFiles, 1, DWORD_LIMIT);
  54. DDX_Text(pDX, IDC_EDIT_ACC_MAXFILESIZE, m_dwLogSize);
  55. DDV_MinMaxDWord(pDX, m_dwLogSize, 1, TOMB(DWORD_LIMIT));
  56. //}}AFX_DATA_MAP
  57. }
  58. BEGIN_MESSAGE_MAP(CPgAccounting, CACSPage)
  59. //{{AFX_MSG_MAP(CPgAccounting)
  60. ON_BN_CLICKED(IDC_CHECK_ENABLEACCOUNTING, OnCheckEnableAccounting)
  61. ON_EN_CHANGE(IDC_EDIT_ACC_DIRECTORY, OnChangeEditLogDirectory)
  62. ON_EN_CHANGE(IDC_EDIT_ACC_LOGFILES, OnChangeEditLogLogfiles)
  63. ON_EN_CHANGE(IDC_EDIT_ACC_MAXFILESIZE, OnChangeEditLogMaxfilesize)
  64. //}}AFX_MSG_MAP
  65. END_MESSAGE_MAP()
  66. /////////////////////////////////////////////////////////////////////////////
  67. // CPgAccounting message handlers
  68. BOOL CPgAccounting::OnApply()
  69. {
  70. USES_CONVERSION;
  71. // Enable Logging
  72. m_spConfig->SetFlags(ATTR_FLAG_SAVE, ACS_SCAF_ENABLERSVPMESSAGEACCOUNTING, true);
  73. m_spConfig->m_bENABLERSVPMESSAGEACCOUNTING = m_bEnableAccounting;
  74. // logging directory
  75. m_spConfig->SetFlags(ATTR_FLAG_SAVE, ACS_SCAF_RSVPACCOUNTINGFILESLOCATION, true);
  76. m_spConfig->m_strRSVPACCOUNTINGFILESLOCATION = m_strLogDir;
  77. // number of log files
  78. m_spConfig->SetFlags(ATTR_FLAG_SAVE, ACS_SCAF_MAXNOOFACCOUNTINGFILES, true);
  79. m_spConfig->m_dwMAXNOOFACCOUNTINGFILES = m_dwNumFiles;
  80. // max file size
  81. m_spConfig->SetFlags(ATTR_FLAG_SAVE, ACS_SCAF_MAXSIZEOFRSVPACCOUNTINGFILE, true);
  82. m_spConfig->m_dwMAXSIZEOFRSVPACCOUNTINGFILE = FROMMB(m_dwLogSize);
  83. DWORD dwAttrFlags = ATTR_FLAGS_NONE;
  84. dwAttrFlags |= (ACS_SCAF_ENABLERSVPMESSAGEACCOUNTING | ACS_SCAF_RSVPACCOUNTINGFILESLOCATION);
  85. dwAttrFlags |= (ACS_SCAF_MAXNOOFACCOUNTINGFILES | ACS_SCAF_MAXSIZEOFRSVPACCOUNTINGFILE);
  86. AddFlags(dwAttrFlags); // prepare flags for saving
  87. return CACSPage::OnApply();
  88. }
  89. void CPgAccounting::OnCheckEnableAccounting()
  90. {
  91. SetModified();
  92. EnableEverything();
  93. // TODO: Add your control notification handler code here
  94. }
  95. void CPgAccounting::OnChangeEditLogDirectory()
  96. {
  97. SetModified();
  98. // TODO: If this is a RICHEDIT control, the control will not
  99. // send this notification unless you override the CACSPage::OnInitDialog()
  100. // function to send the EM_SETEVENTMASK message to the control
  101. // with the ENM_CHANGE flag ORed into the lParam mask.
  102. // TODO: Add your control notification handler code here
  103. }
  104. void CPgAccounting::OnChangeEditLogLogfiles()
  105. {
  106. SetModified();
  107. // TODO: If this is a RICHEDIT control, the control will not
  108. // send this notification unless you override the CACSPage::OnInitDialog()
  109. // function to send the EM_SETEVENTMASK message to the control
  110. // with the ENM_CHANGE flag ORed into the lParam mask.
  111. // TODO: Add your control notification handler code here
  112. }
  113. void CPgAccounting::OnChangeEditLogMaxfilesize()
  114. {
  115. SetModified();
  116. // TODO: If this is a RICHEDIT control, the control will not
  117. // send this notification unless you override the CACSPage::OnInitDialog()
  118. // function to send the EM_SETEVENTMASK message to the control
  119. // with the ENM_CHANGE flag ORed into the lParam mask.
  120. // TODO: Add your control notification handler code here
  121. }
  122. BOOL CPgAccounting::OnInitDialog()
  123. {
  124. // Enable Logging
  125. if(m_spConfig->GetFlags(ATTR_FLAG_LOAD, ACS_SCAF_ENABLERSVPMESSAGEACCOUNTING))
  126. m_bEnableAccounting = (m_spConfig->m_bENABLERSVPMESSAGEACCOUNTING != 0);
  127. // logging directory
  128. if(m_spConfig->GetFlags(ATTR_FLAG_LOAD, ACS_SCAF_RSVPACCOUNTINGFILESLOCATION))
  129. m_strLogDir = m_spConfig->m_strRSVPACCOUNTINGFILESLOCATION;
  130. // number of log files
  131. if(m_spConfig->GetFlags(ATTR_FLAG_LOAD, ACS_SCAF_MAXNOOFACCOUNTINGFILES))
  132. {
  133. m_dwNumFiles = m_spConfig->m_dwMAXNOOFACCOUNTINGFILES;
  134. }
  135. // max file size
  136. if(m_spConfig->GetFlags(ATTR_FLAG_LOAD, ACS_SCAF_MAXSIZEOFRSVPACCOUNTINGFILE))
  137. {
  138. m_dwLogSize = TOMB(m_spConfig->m_dwMAXSIZEOFRSVPACCOUNTINGFILE);
  139. }
  140. CACSPage::OnInitDialog();
  141. EnableEverything();
  142. // TODO: Add extra initialization here
  143. return TRUE; // return TRUE unless you set the focus to a control
  144. // EXCEPTION: OCX Property Pages should return FALSE
  145. }
  146. void CPgAccounting::EnableEverything()
  147. {
  148. CButton* pButton = (CButton*)GetDlgItem(IDC_CHECK_ENABLEACCOUNTING);
  149. int nCheck = pButton->GetCheck();
  150. GetDlgItem(IDC_EDIT_ACC_DIRECTORY)->EnableWindow(nCheck);
  151. GetDlgItem(IDC_EDIT_ACC_LOGFILES)->EnableWindow(nCheck);
  152. GetDlgItem(IDC_EDIT_ACC_MAXFILESIZE)->EnableWindow(nCheck);
  153. }
  154. /////////////////////////////////////////////////////////////////////////////
  155. // CPgLogging property page
  156. IMPLEMENT_DYNCREATE(CPgLogging, CACSPage)
  157. CPgLogging::CPgLogging(CACSSubnetConfig* pConfig) : CACSPage(CPgLogging::IDD)
  158. {
  159. ASSERT(pConfig);
  160. m_spConfig = pConfig;
  161. DataInit();
  162. }
  163. void CPgLogging::DataInit()
  164. {
  165. //{{AFX_DATA_INIT(CPgLogging)
  166. m_bEnableLogging = ACS_SCADEF_ENABLERSVPMESSAGELOGGING;
  167. m_dwLevel = ACS_SCADEF_EVENTLOGLEVEL;
  168. m_strLogDir = ACS_SCADEF_RSVPLOGFILESLOCATION;
  169. m_dwNumFiles = ACS_SCADEF_MAXNOOFLOGFILES;
  170. m_dwLogSize = ACS_SCADEF_MAXSIZEOFRSVPLOGFILE;
  171. //}}AFX_DATA_INIT
  172. m_pLevel = NULL;
  173. }
  174. CPgLogging::CPgLogging() : CACSPage(CPgLogging::IDD)
  175. {
  176. DataInit();
  177. }
  178. CPgLogging::~CPgLogging()
  179. {
  180. delete m_pLevel;
  181. m_aLevelStrings.DeleteAll();
  182. }
  183. void CPgLogging::DoDataExchange(CDataExchange* pDX)
  184. {
  185. CACSPage::DoDataExchange(pDX);
  186. //{{AFX_DATA_MAP(CPgLogging)
  187. DDX_Check(pDX, IDC_CHECK_ENABLELOGGIN, m_bEnableLogging);
  188. DDX_CBIndex(pDX, IDC_COMBOLEVEL, m_dwLevel);
  189. DDX_Text(pDX, IDC_EDIT_LOG_DIRECTORY, m_strLogDir);
  190. DDV_MaxChars(pDX, m_strLogDir, ACS_SCAV_MAX_LOGFILESLOCATION);
  191. DDX_Text(pDX, IDC_EDIT_LOG_LOGFILES, m_dwNumFiles);
  192. DDV_MinMaxDWord(pDX, m_dwNumFiles, 1, DWORD_LIMIT);
  193. DDX_Text(pDX, IDC_EDIT_LOG_MAXFILESIZE, m_dwLogSize);
  194. DDV_MinMaxDWord(pDX, m_dwLogSize, 1, TOMB(DWORD_LIMIT));
  195. //}}AFX_DATA_MAP
  196. }
  197. BEGIN_MESSAGE_MAP(CPgLogging, CACSPage)
  198. //{{AFX_MSG_MAP(CPgLogging)
  199. ON_BN_CLICKED(IDC_CHECK_ENABLELOGGIN, OnCheckEnableloggin)
  200. ON_CBN_SELCHANGE(IDC_COMBOLEVEL, OnSelchangeCombolevel)
  201. ON_EN_CHANGE(IDC_EDIT_LOG_DIRECTORY, OnChangeEditLogDirectory)
  202. ON_EN_CHANGE(IDC_EDIT_LOG_LOGFILES, OnChangeEditLogLogfiles)
  203. ON_EN_CHANGE(IDC_EDIT_LOG_MAXFILESIZE, OnChangeEditLogMaxfilesize)
  204. //}}AFX_MSG_MAP
  205. END_MESSAGE_MAP()
  206. /////////////////////////////////////////////////////////////////////////////
  207. // CPgLogging message handlers
  208. BOOL CPgLogging::OnApply()
  209. {
  210. USES_CONVERSION;
  211. // Enable Logging
  212. m_spConfig->SetFlags(ATTR_FLAG_SAVE, ACS_SCAF_ENABLERSVPMESSAGELOGGING, true);
  213. m_spConfig->m_bENABLERSVPMESSAGELOGGING = m_bEnableLogging;
  214. // logging directory
  215. m_spConfig->SetFlags(ATTR_FLAG_SAVE, ACS_SCAF_RSVPLOGFILESLOCATION, true);
  216. m_spConfig->m_strRSVPLOGFILESLOCATION = m_strLogDir;
  217. // number of log files
  218. m_spConfig->SetFlags(ATTR_FLAG_SAVE, ACS_SCAF_MAXNOOFLOGFILES, true);
  219. m_spConfig->m_dwMAXNOOFLOGFILES = m_dwNumFiles;
  220. // max file size
  221. m_spConfig->SetFlags(ATTR_FLAG_SAVE, ACS_SCAF_MAXSIZEOFRSVPLOGFILE, true);
  222. m_spConfig->m_dwMAXSIZEOFRSVPLOGFILE = FROMMB(m_dwLogSize);
  223. // logging level
  224. m_spConfig->SetFlags(ATTR_FLAG_SAVE, ACS_SCAF_EVENTLOGLEVEL, true);
  225. m_spConfig->m_dwEVENTLOGLEVEL = m_dwLevel;
  226. DWORD dwAttrFlags = ATTR_FLAGS_NONE;
  227. dwAttrFlags |= (ACS_SCAF_ENABLERSVPMESSAGELOGGING | ACS_SCAF_RSVPLOGFILESLOCATION);
  228. dwAttrFlags |= (ACS_SCAF_MAXNOOFLOGFILES | ACS_SCAF_MAXSIZEOFRSVPLOGFILE | ACS_SCAF_EVENTLOGLEVEL);
  229. AddFlags(dwAttrFlags); // prepare flags for saving
  230. return CACSPage::OnApply();
  231. }
  232. void CPgLogging::OnCheckEnableloggin()
  233. {
  234. SetModified();
  235. EnableEverything();
  236. // TODO: Add your control notification handler code here
  237. }
  238. void CPgLogging::OnSelchangeCombolevel()
  239. {
  240. // TODO: Add your control notification handler code here
  241. SetModified();
  242. }
  243. void CPgLogging::OnChangeEditLogDirectory()
  244. {
  245. SetModified();
  246. // TODO: If this is a RICHEDIT control, the control will not
  247. // send this notification unless you override the CACSPage::OnInitDialog()
  248. // function to send the EM_SETEVENTMASK message to the control
  249. // with the ENM_CHANGE flag ORed into the lParam mask.
  250. // TODO: Add your control notification handler code here
  251. }
  252. void CPgLogging::OnChangeEditLogLogfiles()
  253. {
  254. SetModified();
  255. // TODO: If this is a RICHEDIT control, the control will not
  256. // send this notification unless you override the CACSPage::OnInitDialog()
  257. // function to send the EM_SETEVENTMASK message to the control
  258. // with the ENM_CHANGE flag ORed into the lParam mask.
  259. // TODO: Add your control notification handler code here
  260. }
  261. void CPgLogging::OnChangeEditLogMaxfilesize()
  262. {
  263. SetModified();
  264. // TODO: If this is a RICHEDIT control, the control will not
  265. // send this notification unless you override the CACSPage::OnInitDialog()
  266. // function to send the EM_SETEVENTMASK message to the control
  267. // with the ENM_CHANGE flag ORed into the lParam mask.
  268. // TODO: Add your control notification handler code here
  269. }
  270. BOOL CPgLogging::OnInitDialog()
  271. {
  272. // Enable Logging
  273. if(m_spConfig->GetFlags(ATTR_FLAG_LOAD, ACS_SCAF_ENABLERSVPMESSAGELOGGING))
  274. m_bEnableLogging = (m_spConfig->m_bENABLERSVPMESSAGELOGGING != 0);
  275. // logging directory
  276. if(m_spConfig->GetFlags(ATTR_FLAG_LOAD, ACS_SCAF_RSVPLOGFILESLOCATION))
  277. m_strLogDir = m_spConfig->m_strRSVPLOGFILESLOCATION;
  278. // number of log files
  279. if(m_spConfig->GetFlags(ATTR_FLAG_LOAD, ACS_SCAF_MAXNOOFLOGFILES))
  280. {
  281. m_dwNumFiles = m_spConfig->m_dwMAXNOOFLOGFILES;
  282. }
  283. // max file size
  284. if(m_spConfig->GetFlags(ATTR_FLAG_LOAD, ACS_SCAF_MAXSIZEOFRSVPLOGFILE))
  285. {
  286. m_dwLogSize = TOMB(m_spConfig->m_dwMAXSIZEOFRSVPLOGFILE);
  287. }
  288. // logging level
  289. if(m_spConfig->GetFlags(ATTR_FLAG_LOAD, ACS_SCAF_EVENTLOGLEVEL))
  290. {
  291. m_dwLevel = m_spConfig->m_dwEVENTLOGLEVEL;
  292. }
  293. CString* pStr = NULL;
  294. // direction
  295. // fillin the list box
  296. try{
  297. pStr = new CString();
  298. pStr->LoadString(IDS_LOGLEVEL_0);
  299. m_aLevelStrings.Add(pStr);
  300. pStr = new CString();
  301. pStr->LoadString(IDS_LOGLEVEL_1);
  302. m_aLevelStrings.Add(pStr);
  303. pStr = new CString();
  304. pStr->LoadString(IDS_LOGLEVEL_2);
  305. m_aLevelStrings.Add(pStr);
  306. /* 366523 1 I0706 rajeshm a-leeb ACS: Snap in should list 3 event levels rather than four
  307. pStr = new CString();
  308. pStr->LoadString(IDS_LOGLEVEL_3);
  309. m_aLevelStrings.Add(pStr);
  310. */
  311. m_pLevel = new CStrBox<CComboBox>(this, IDC_COMBOLEVEL, m_aLevelStrings);
  312. m_pLevel->Fill();
  313. m_pLevel->Select(m_dwLevel);
  314. }catch(CMemoryException&){};
  315. CACSPage::OnInitDialog();
  316. EnableEverything();
  317. // TODO: Add extra initialization here
  318. return TRUE; // return TRUE unless you set the focus to a control
  319. // EXCEPTION: OCX Property Pages should return FALSE
  320. }
  321. void CPgLogging::EnableEverything()
  322. {
  323. CButton* pButton = (CButton*)GetDlgItem(IDC_CHECK_ENABLELOGGIN);
  324. int nCheck = pButton->GetCheck();
  325. GetDlgItem(IDC_EDIT_LOG_DIRECTORY)->EnableWindow(nCheck);
  326. GetDlgItem(IDC_EDIT_LOG_LOGFILES)->EnableWindow(nCheck);
  327. GetDlgItem(IDC_EDIT_LOG_MAXFILESIZE)->EnableWindow(nCheck);
  328. GetDlgItem(IDC_COMBOLEVEL)->EnableWindow(TRUE);
  329. }