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.

232 lines
6.6 KiB

  1. /*++
  2. Copyright (C) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. enabldlg.cpp
  5. Abstract:
  6. Implementation of the provider status dialog box.
  7. --*/
  8. #include "stdafx.h"
  9. #include "provprop.h"
  10. #include "smcfgmsg.h"
  11. #include "smlogcfg.h"
  12. #include "enabldlg.h"
  13. #include "smcfghlp.h"
  14. #include "smtprov.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. static ULONG
  21. s_aulHelpIds[] =
  22. {
  23. IDC_PACT_CHECK_SHOW_ENABLED, IDH_PACT_CHECK_SHOW_ENABLED,
  24. IDC_PACT_PROVIDERS_LIST, IDH_PACT_PROVIDERS_LIST,
  25. 0,0
  26. };
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CActiveProviderDlg dialog
  29. CActiveProviderDlg::CActiveProviderDlg(CWnd* pParent /*=NULL*/)
  30. : CDialog(CActiveProviderDlg::IDD, pParent),
  31. m_pProvidersPage( NULL ),
  32. m_iListViewWidth(0)
  33. {
  34. //{{AFX_DATA_INIT(CActiveProviderDlg)
  35. //}}AFX_DATA_INIT
  36. }
  37. void CActiveProviderDlg::DoDataExchange(CDataExchange* pDX)
  38. {
  39. CDialog::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CActiveProviderDlg)
  41. DDX_Control(pDX, IDC_PACT_PROVIDERS_LIST, m_Providers);
  42. DDX_Check(pDX, IDC_PACT_CHECK_SHOW_ENABLED, m_bShowEnabledOnly);
  43. //}}AFX_DATA_MAP
  44. }
  45. BEGIN_MESSAGE_MAP(CActiveProviderDlg, CDialog)
  46. //{{AFX_MSG_MAP(CActiveProviderDlg)
  47. ON_BN_CLICKED(IDC_PACT_CHECK_SHOW_ENABLED, OnCheckShowEnabled)
  48. ON_WM_HELPINFO()
  49. ON_WM_CONTEXTMENU()
  50. //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CActiveProviderDlg message handlers
  54. BOOL
  55. CActiveProviderDlg::OnInitDialog()
  56. {
  57. RECT rect;
  58. m_bShowEnabledOnly = FALSE;
  59. CDialog::OnInitDialog(); // Calls UpdateDate ( FALSE ) to init the checkbox value.
  60. // Get the width of the list view control, then delete the default column.
  61. m_Providers.GetClientRect(&rect);
  62. m_iListViewWidth = rect.right;
  63. UpdateList();
  64. return TRUE; // return TRUE unless you set the focus to a control
  65. // EXCEPTION: OCX Property Pages should return FALSE
  66. }
  67. void
  68. CActiveProviderDlg::OnCheckShowEnabled()
  69. {
  70. // ::SendMessage(m_Providers.m_hWnd, WM_SETREDRAW, TRUE, 0);
  71. UpdateData(TRUE);
  72. UpdateList();
  73. }
  74. BOOL
  75. CActiveProviderDlg::OnHelpInfo(HELPINFO* pHelpInfo)
  76. {
  77. ASSERT( NULL != m_pProvidersPage );
  78. if ( pHelpInfo->iCtrlId >= IDC_PACT_FIRST_HELP_CTRL_ID
  79. || pHelpInfo->iCtrlId == IDCANCEL )
  80. {
  81. InvokeWinHelp(WM_HELP, NULL, (LPARAM)pHelpInfo, m_pProvidersPage->GetContextHelpFilePath(), s_aulHelpIds);
  82. }
  83. return TRUE;
  84. }
  85. void
  86. CActiveProviderDlg::OnContextMenu(CWnd* pWnd, CPoint /* point */)
  87. {
  88. ASSERT( NULL != m_pProvidersPage );
  89. InvokeWinHelp(WM_CONTEXTMENU, (WPARAM)( pWnd->m_hWnd), NULL, m_pProvidersPage->GetContextHelpFilePath(), s_aulHelpIds);
  90. return;
  91. }
  92. // Helper functions
  93. void CActiveProviderDlg::UpdateList()
  94. {
  95. LVCOLUMN lvCol;
  96. LVITEM lvItem;
  97. INT iGenIndex;
  98. INT iAllIndex;
  99. INT iEnabledIndex;
  100. INT iCount;
  101. CString arrstrHeader[2];
  102. CString strEnabled;
  103. INT iColWidth[2];
  104. CString strItemText;
  105. ResourceStateManager rsm;
  106. (arrstrHeader[0]).LoadString( IDS_PROV_NAME );
  107. (arrstrHeader[1]).LoadString( IDS_PROV_STATUS );
  108. strEnabled.LoadString(IDS_PROV_ENABLED);
  109. m_Providers.DeleteAllItems();
  110. m_Providers.DeleteColumn(1); // Note - Column 1 might not exist.
  111. m_Providers.DeleteColumn(0);
  112. lvCol.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH | LVCF_FMT;
  113. lvCol.fmt = LVCFMT_LEFT;
  114. if ( m_bShowEnabledOnly ) {
  115. iColWidth[0] = m_iListViewWidth;
  116. iColWidth[1] = 0;
  117. } else {
  118. iColWidth[0] = (m_iListViewWidth * 75) / 100;
  119. iColWidth[1] = (m_iListViewWidth * 25) / 100;
  120. }
  121. if ( m_bShowEnabledOnly ) {
  122. lvCol.iSubItem = 0;
  123. lvCol.pszText = arrstrHeader[0].GetBufferSetLength( arrstrHeader[0].GetLength());
  124. lvCol.cx = iColWidth[0];
  125. m_Providers.InsertColumn(0,&lvCol);
  126. } else {
  127. INT iColIndex;
  128. for (iColIndex = 0 ; iColIndex < 2 ;iColIndex++ ){
  129. lvCol.iSubItem = 0;
  130. lvCol.pszText = arrstrHeader[iColIndex].GetBufferSetLength( arrstrHeader[iColIndex].GetLength());
  131. lvCol.cx = iColWidth[iColIndex];
  132. m_Providers.InsertColumn(iColIndex,&lvCol);
  133. }
  134. }
  135. iEnabledIndex = 0;
  136. iAllIndex = 0;
  137. // Add Kernel provider separately.
  138. if(m_bShowEnabledOnly) {
  139. if ( m_pProvidersPage->GetKernelProviderEnabled() ) {
  140. m_Providers.InsertItem(iEnabledIndex,(LPCWSTR)(m_pProvidersPage->GetKernelProviderDescription()));
  141. }
  142. } else {
  143. lvItem.mask = LVIF_TEXT;
  144. lvItem.iItem = 0;
  145. lvItem.iSubItem = 0;
  146. m_Providers.InsertItem(iAllIndex++,(LPCWSTR)(m_pProvidersPage->GetKernelProviderDescription()));
  147. // Show status
  148. if ( m_pProvidersPage->GetKernelProviderEnabled() ) {
  149. lvItem.pszText = strEnabled.GetBufferSetLength( strEnabled.GetLength() );
  150. lvItem.iSubItem = 1;
  151. m_Providers.SetItem(&lvItem);
  152. }
  153. }
  154. // Add general providers
  155. m_pProvidersPage->GetGenProviderCount( iCount );
  156. for ( iGenIndex = 0; iGenIndex < iCount ; iGenIndex++ ){
  157. lvItem.mask = LVIF_TEXT;
  158. lvItem.iItem = iAllIndex;
  159. lvItem.iSubItem = 0;
  160. if ( m_pProvidersPage->IsActiveProvider(iGenIndex) ) {
  161. CString strProviderName;
  162. if(m_bShowEnabledOnly){
  163. if ( m_pProvidersPage->IsEnabledProvider(iGenIndex) ){
  164. m_pProvidersPage->GetProviderDescription ( iGenIndex, strProviderName );
  165. m_Providers.InsertItem (iEnabledIndex++,strProviderName );
  166. }
  167. } else {
  168. m_pProvidersPage->GetProviderDescription ( iGenIndex, strProviderName );
  169. m_Providers.InsertItem (iAllIndex,strProviderName );
  170. // Show status
  171. if ( m_pProvidersPage->IsEnabledProvider(iGenIndex) ){
  172. lvItem.pszText = strEnabled.GetBufferSetLength( strEnabled.GetLength() );
  173. lvItem.iSubItem = 1;
  174. m_Providers.SetItem(&lvItem);
  175. }
  176. }
  177. }
  178. }
  179. }
  180. void
  181. CActiveProviderDlg::SetProvidersPage( CProvidersProperty* pPage )
  182. {
  183. // The providers page is not always the parent, so store a separate pointer
  184. m_pProvidersPage = pPage;
  185. }