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.

322 lines
9.9 KiB

  1. #include "ClusterPage.h"
  2. #include "CommonUtils.h"
  3. // History:
  4. // --------
  5. //
  6. // Revised by : mhakim
  7. // Date : 02-12-01
  8. // Reason : Added passwords and remote control for nlbmgr.
  9. BEGIN_MESSAGE_MAP( ClusterPage, CPropertyPage )
  10. ON_WM_HELPINFO()
  11. ON_WM_CONTEXTMENU()
  12. END_MESSAGE_MAP()
  13. ClusterPage::ClusterPage( ClusterProperties* pClusterProperty,
  14. bool fDisablePage, UINT ID )
  15. :
  16. CPropertyPage( ID ),
  17. m_pClusterProperty( pClusterProperty ),
  18. m_fDisablePage (fDisablePage)
  19. {
  20. ZeroMemory(&m_WlbsConfig, sizeof(m_WlbsConfig));
  21. lstrcpyn(m_WlbsConfig.cl_ip_addr, pClusterProperty->cIP, CVY_MAX_CL_IP_ADDR);
  22. lstrcpyn(m_WlbsConfig.cl_net_mask, pClusterProperty->cSubnetMask, CVY_MAX_NETWORK_ADDR);
  23. lstrcpyn(m_WlbsConfig.domain_name, pClusterProperty->cFullInternetName, CVY_MAX_DOMAIN_NAME);
  24. lstrcpyn(m_WlbsConfig.cl_mac_addr, pClusterProperty->cNetworkAddress, CVY_MAX_NETWORK_ADDR);
  25. //
  26. // pClusterProperty->multicastIPAddress could be NULL
  27. //
  28. if (pClusterProperty->multicastIPAddress.length() > 0)
  29. {
  30. lstrcpyn(m_WlbsConfig.szMCastIpAddress, pClusterProperty->multicastIPAddress, CVY_MAX_CL_IP_ADDR);
  31. }
  32. m_WlbsConfig.fMcastSupport = pClusterProperty->multicastSupportEnabled;
  33. m_WlbsConfig.fIGMPSupport = pClusterProperty->igmpSupportEnabled;
  34. m_WlbsConfig.fRctEnabled = pClusterProperty->remoteControlEnabled;
  35. m_WlbsConfig.fMcastSupport = pClusterProperty->multicastSupportEnabled;
  36. m_WlbsConfig.fIpToMCastIp = pClusterProperty->clusterIPToMulticastIP;
  37. m_WlbsConfig.fConvertMac = TRUE; // Always generate the MAC address from IP
  38. lstrcpyn(m_WlbsConfig.szPassword, pClusterProperty->password, CVY_MAX_RCT_CODE + 1);
  39. // m_pCommonClusterPage = new CCommonClusterPage(AfxGetInstanceHandle(),
  40. // &m_WlbsConfig, true, NULL); // fDisablePassword = true
  41. m_pCommonClusterPage = new CCommonClusterPage(AfxGetInstanceHandle(),
  42. &m_WlbsConfig, false, NULL); // fDisablePassword = true
  43. }
  44. ClusterPage::~ClusterPage()
  45. {
  46. delete m_pCommonClusterPage;
  47. }
  48. //+----------------------------------------------------------------------------
  49. //
  50. // Function: ClusterPage::OnInitDialog
  51. //
  52. // Description: Process WM_INITDIALOG message
  53. //
  54. // Arguments: None
  55. //
  56. // Returns: BOOL -
  57. //
  58. // History: fengsun Created Header 1/4/01
  59. //
  60. //+----------------------------------------------------------------------------
  61. BOOL ClusterPage::OnInitDialog()
  62. {
  63. CPropertyPage::OnInitDialog();
  64. //
  65. // Always set that the page has changed, so we don't have to keep track of this.
  66. //
  67. SetModified(TRUE);
  68. m_pCommonClusterPage->OnInitDialog(m_hWnd);
  69. if (m_fDisablePage)
  70. {
  71. //
  72. // The page is for host property.
  73. // disable all cluster windows as we are at host level.
  74. //
  75. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_CL_IP), FALSE );
  76. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_CL_MASK), FALSE );
  77. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_RADIO_UNICAST), FALSE );
  78. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_RADIO_MULTICAST), FALSE );
  79. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK_IGMP), FALSE );
  80. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_DOMAIN), FALSE );
  81. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK_RCT), FALSE );
  82. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_PASSW), FALSE );
  83. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_PASSW2), FALSE );
  84. }
  85. else
  86. {
  87. //
  88. // The page is for cluster property
  89. //
  90. // enable all cluster windows as we are at cluster level.
  91. //
  92. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_CL_IP), TRUE );
  93. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_CL_MASK), TRUE );
  94. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_RADIO_UNICAST), TRUE );
  95. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_RADIO_MULTICAST), TRUE );
  96. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK_IGMP), TRUE );
  97. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_DOMAIN), TRUE );
  98. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK_RCT), TRUE );
  99. // enable remote control check box only if remote control is disabled.
  100. //
  101. // if remote control is enabled , enable password windows
  102. // else disable them.
  103. if (m_WlbsConfig.fRctEnabled)
  104. {
  105. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_PASSW), TRUE );
  106. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_PASSW2), TRUE );
  107. }
  108. else
  109. {
  110. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_PASSW), FALSE );
  111. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_PASSW2), FALSE );
  112. }
  113. }
  114. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_ETH), FALSE );
  115. return TRUE;
  116. }
  117. //+----------------------------------------------------------------------------
  118. //
  119. // Function: ClusterPage::OnContextMenu
  120. //
  121. // Description: Process WM_CONTEXTMENU message
  122. //
  123. // Arguments: CWnd* pWnd -
  124. // CPoint point -
  125. //
  126. // Returns: Nothing
  127. //
  128. // History: fengsun Created Header 1/4/01
  129. //
  130. //+----------------------------------------------------------------------------
  131. //+----------------------------------------------------------------------------
  132. //
  133. // Function: ClusterPage::OnCommand
  134. //
  135. // Description: Process WM_COMMAND message
  136. //
  137. // Arguments: WPARAM wParam -
  138. // LPARAM lParam -
  139. //
  140. // Returns: BOOL -
  141. //
  142. // History: fengsun Created Header 1/4/01
  143. //
  144. //+----------------------------------------------------------------------------
  145. BOOL ClusterPage::OnCommand(WPARAM wParam, LPARAM lParam)
  146. {
  147. switch (LOWORD(wParam))
  148. {
  149. case IDC_EDIT_CL_IP:
  150. return m_pCommonClusterPage->OnEditClIp(HIWORD(wParam),LOWORD(wParam), (HWND)lParam);
  151. break;
  152. case IDC_EDIT_CL_MASK:
  153. return m_pCommonClusterPage->OnEditClMask(HIWORD(wParam),LOWORD(wParam), (HWND)lParam);
  154. break;
  155. case IDC_CHECK_RCT:
  156. return m_pCommonClusterPage->OnCheckRct(HIWORD(wParam),LOWORD(wParam), (HWND)lParam);
  157. break;
  158. case IDC_BUTTON_HELP:
  159. return m_pCommonClusterPage->OnButtonHelp(HIWORD(wParam),LOWORD(wParam), (HWND)lParam);
  160. break;
  161. case IDC_RADIO_UNICAST:
  162. return m_pCommonClusterPage->OnCheckMode(HIWORD(wParam),LOWORD(wParam), (HWND)lParam);
  163. break;
  164. case IDC_RADIO_MULTICAST:
  165. return m_pCommonClusterPage->OnCheckMode(HIWORD(wParam),LOWORD(wParam), (HWND)lParam);
  166. break;
  167. case IDC_CHECK_IGMP:
  168. return m_pCommonClusterPage->OnCheckIGMP(HIWORD(wParam),LOWORD(wParam), (HWND)lParam);
  169. break;
  170. }
  171. return CPropertyPage::OnCommand(wParam, lParam);
  172. }
  173. //+----------------------------------------------------------------------------
  174. //
  175. // Function: ClusterPage::OnNotify
  176. //
  177. // Description: Process WM_NOTIFY message
  178. //
  179. // Arguments: WPARAM idCtrl -
  180. // LPARAM pnmh -
  181. // LRESULT* pResult -
  182. //
  183. // Returns: BOOL -
  184. //
  185. // History: fengsun Created Header 1/4/01
  186. //
  187. //+----------------------------------------------------------------------------
  188. BOOL ClusterPage::OnNotify(WPARAM idCtrl , LPARAM pnmh , LRESULT* pResult)
  189. {
  190. NMHDR* pNmhdr = (NMHDR*)pnmh ;
  191. switch(pNmhdr->code)
  192. {
  193. case PSN_APPLY:
  194. *pResult = m_pCommonClusterPage->OnApply(idCtrl, pNmhdr, *(BOOL*)pResult);
  195. if (*pResult == PSNRET_NOERROR)
  196. {
  197. //
  198. // Call the base class, such that OnOk can be called
  199. //
  200. return CPropertyPage::OnNotify(idCtrl, pnmh, pResult);
  201. }
  202. else
  203. {
  204. return TRUE;
  205. }
  206. case PSN_KILLACTIVE:
  207. *pResult = m_pCommonClusterPage->OnKillActive(idCtrl, pNmhdr, *(BOOL*)pResult);
  208. return TRUE;
  209. case PSN_SETACTIVE:
  210. *pResult = m_pCommonClusterPage->OnActive(idCtrl, pNmhdr, *(BOOL*)pResult);
  211. return TRUE;
  212. case PSN_RESET:
  213. *pResult = m_pCommonClusterPage->OnCancel(idCtrl, pNmhdr, *(BOOL*)pResult);
  214. return TRUE;
  215. case IPN_FIELDCHANGED:
  216. *pResult = m_pCommonClusterPage->OnIpFieldChange(idCtrl, pNmhdr, *(BOOL*)pResult);
  217. return TRUE;
  218. }
  219. return CPropertyPage::OnNotify(idCtrl, pnmh, pResult);
  220. }
  221. //+----------------------------------------------------------------------------
  222. //
  223. // Function: ClusterPage::OnOK
  224. //
  225. // Description: The property page is closed by OK
  226. //
  227. // Arguments: None
  228. //
  229. // Returns: Nothing
  230. //
  231. // History: fengsun Created Header 1/4/01
  232. //
  233. //+----------------------------------------------------------------------------
  234. void ClusterPage::OnOK()
  235. {
  236. m_pClusterProperty->cIP = m_WlbsConfig.cl_ip_addr;
  237. m_pClusterProperty->cSubnetMask = m_WlbsConfig.cl_net_mask;
  238. m_pClusterProperty->cFullInternetName = m_WlbsConfig.domain_name;
  239. m_pClusterProperty->cNetworkAddress = m_WlbsConfig.cl_mac_addr;
  240. m_pClusterProperty->multicastIPAddress = m_WlbsConfig.szMCastIpAddress;
  241. m_pClusterProperty->multicastSupportEnabled= m_WlbsConfig.fMcastSupport;
  242. m_pClusterProperty->igmpSupportEnabled = m_WlbsConfig.fIGMPSupport;
  243. m_pClusterProperty->remoteControlEnabled = m_WlbsConfig.fRctEnabled;
  244. m_pClusterProperty->multicastSupportEnabled = m_WlbsConfig.fMcastSupport;
  245. m_pClusterProperty->clusterIPToMulticastIP = m_WlbsConfig.fIpToMCastIp;
  246. m_pClusterProperty->password = m_WlbsConfig.szPassword;
  247. CPropertyPage::OnOK();
  248. }
  249. BOOL
  250. ClusterPage::OnHelpInfo (HELPINFO* helpInfo )
  251. {
  252. if( helpInfo->iContextType == HELPINFO_WINDOW )
  253. {
  254. ::WinHelp( static_cast<HWND> ( helpInfo->hItemHandle ),
  255. CVY_CTXT_HELP_FILE,
  256. HELP_WM_HELP,
  257. (ULONG_PTR ) g_aHelpIDs_IDD_CLUSTER_PAGE);
  258. }
  259. return TRUE;
  260. }
  261. void
  262. ClusterPage::OnContextMenu( CWnd* pWnd, CPoint point )
  263. {
  264. ::WinHelp( m_hWnd,
  265. CVY_CTXT_HELP_FILE,
  266. HELP_CONTEXTMENU,
  267. (ULONG_PTR ) g_aHelpIDs_IDD_CLUSTER_PAGE);
  268. }