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.

296 lines
7.3 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // FILE : DlgNewGroup.cpp //
  3. // //
  4. // DESCRIPTION : The CDlgNewFaxOutboundGroup class implements the //
  5. // dialog for additon of new Group. //
  6. // //
  7. // AUTHOR : yossg //
  8. // //
  9. // HISTORY : //
  10. // Jan 3 2000 yossg Create //
  11. // //
  12. // Copyright (C) 2000 Microsoft Corporation All Rights Reserved //
  13. /////////////////////////////////////////////////////////////////////////////
  14. #include "StdAfx.h"
  15. #include "dlgNewGroup.h"
  16. #include "FaxServer.h"
  17. #include "FaxServerNode.h"
  18. #include "dlgutils.h"
  19. //#include "Helper.h"
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CDlgNewFaxOutboundGroup
  22. CDlgNewFaxOutboundGroup::~CDlgNewFaxOutboundGroup()
  23. {
  24. }
  25. /*
  26. + CDlgNewFaxOutboundGroup::OnInitDialog
  27. +
  28. * Purpose:
  29. * Initiate all dialog controls.
  30. *
  31. * Arguments:
  32. * [in] uMsg : Value identifying the event.
  33. * [in] lParam : Message-specific value.
  34. * [in] wParam : Message-specific value.
  35. * [in] bHandled : bool value.
  36. *
  37. - Return:
  38. - 0 or 1
  39. */
  40. LRESULT
  41. CDlgNewFaxOutboundGroup::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  42. {
  43. DEBUG_FUNCTION_NAME( _T("CDlgNewFaxOutboundGroup::OnInitDialog"));
  44. HRESULT hRc = S_OK;
  45. //
  46. // Attach controls
  47. //
  48. m_GroupNameEdit.Attach(GetDlgItem(IDC_GROUPNAME_EDIT));
  49. //
  50. // Set length limit to area code
  51. //
  52. m_GroupNameEdit.SetLimitText(MAX_ROUTING_GROUP_NAME - 1);
  53. //
  54. // Set focus
  55. //
  56. ::SetFocus(GetDlgItem(IDC_GROUPNAME_EDIT));
  57. EnableOK(FALSE);
  58. return 1; // Let the system set the focus
  59. }
  60. /*
  61. + CDlgNewFaxOutboundGroup::OnOK
  62. +
  63. * Purpose:
  64. * Initiate all dialog controls.
  65. *
  66. * Arguments:
  67. * [in] uMsg : Value identifying the event.
  68. * [in] lParam : Message-specific value.
  69. * [in] wParam : Message-specific value.
  70. * [in] bHandled : bool value.
  71. *
  72. - Return:
  73. - 0 or 1
  74. */
  75. LRESULT
  76. CDlgNewFaxOutboundGroup::OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  77. {
  78. DEBUG_FUNCTION_NAME( _T("CDlgNewFaxOutboundGroup::OnOK"));
  79. HRESULT hRc = S_OK;
  80. DWORD ec = ERROR_SUCCESS;
  81. //
  82. // Step 0: PreApply Checks
  83. //
  84. /*
  85. if (!CheckValidtity())
  86. {
  87. EnableOK(FALSE);
  88. hRc =S_FALSE;
  89. goto Exit;
  90. }
  91. */
  92. //
  93. // Step 1: get data
  94. //
  95. if ( !m_GroupNameEdit.GetWindowText(&m_bstrGroupName))
  96. {
  97. DebugPrintEx(
  98. DEBUG_ERR,
  99. TEXT("Failed to GetWindowText(&m_bstrGroupName)"));
  100. DlgMsgBox(this, IDS_FAIL2READ_GROUPNAME);
  101. ::SetFocus(GetDlgItem(IDC_GROUPNAME_EDIT));
  102. hRc = S_FALSE;
  103. goto Exit;
  104. }
  105. //
  106. // Step 2: add group via RPC call
  107. //
  108. //
  109. // get RPC Handle
  110. //
  111. if (!m_pFaxServer->GetFaxServerHandle())
  112. {
  113. ec= GetLastError();
  114. DebugPrintEx(
  115. DEBUG_ERR,
  116. _T("Failed to GetFaxServerHandle. (ec: %ld)"),
  117. ec);
  118. goto Error;
  119. }
  120. //
  121. // Add the group
  122. //
  123. if (!FaxAddOutboundGroup (
  124. m_pFaxServer->GetFaxServerHandle(),
  125. (LPCTSTR)m_bstrGroupName))
  126. {
  127. ec = GetLastError();
  128. DebugPrintEx(
  129. DEBUG_ERR,
  130. _T("Fail to add group. (ec: %ld)"),
  131. ec);
  132. if (ERROR_DUP_NAME == ec)
  133. {
  134. DlgMsgBox(this, IDS_OUTGROUP_EXISTS);
  135. ::SetFocus(GetDlgItem(IDC_GROUPNAME_EDIT));
  136. goto Exit;
  137. }
  138. else if (IsNetworkError(ec))
  139. {
  140. DebugPrintEx(
  141. DEBUG_ERR,
  142. _T("Network Error was found. (ec: %ld)"),
  143. ec);
  144. m_pFaxServer->Disconnect();
  145. }
  146. goto Error;
  147. }
  148. //
  149. // Step 3: Close the dialog
  150. //
  151. ATLASSERT(S_OK == hRc && ERROR_SUCCESS == ec);
  152. DebugPrintEx( DEBUG_MSG,
  153. _T("The group was added successfully."));
  154. EndDialog(wID);
  155. goto Exit;
  156. Error:
  157. ATLASSERT(ERROR_SUCCESS != ec);
  158. hRc = HRESULT_FROM_WIN32(ec);
  159. PageErrorEx(IDS_FAIL_ADD_RULE, GetFaxServerErrorMsg(ec), m_hWnd);
  160. Exit:
  161. return FAILED(hRc) ? 0 : 1;
  162. }
  163. /*
  164. - CDlgNewFaxOutboundGroup::OnTextChanged
  165. -
  166. * Purpose:
  167. * Check the validity of text in side the text box.
  168. *
  169. * Arguments:
  170. *
  171. * Return:
  172. * 1
  173. */
  174. LRESULT
  175. CDlgNewFaxOutboundGroup::OnTextChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  176. {
  177. DEBUG_FUNCTION_NAME( _T("CDlgNewFaxOutboundGroup::OnTextChanged"));
  178. UINT fEnableOK;
  179. fEnableOK = ( m_GroupNameEdit.GetWindowTextLength() );
  180. EnableOK(!!fEnableOK);
  181. return 0;
  182. }
  183. /*
  184. - CDlgNewFaxOutboundGroup::EnableOK
  185. -
  186. * Purpose:
  187. * Enable (disable) apply button.
  188. *
  189. * Arguments:
  190. * [in] fEnable - the value to enable the button
  191. *
  192. * Return:
  193. * void
  194. */
  195. VOID
  196. CDlgNewFaxOutboundGroup::EnableOK(BOOL fEnable)
  197. {
  198. HWND hwndOK = GetDlgItem(IDOK);
  199. ::EnableWindow(hwndOK, fEnable);
  200. }
  201. /*
  202. - CDlgNewFaxOutboundGroup::OnCancel
  203. -
  204. * Purpose:
  205. * End dialog OnCancel.
  206. *
  207. * Arguments:
  208. *
  209. * Return:
  210. * 0
  211. */
  212. LRESULT
  213. CDlgNewFaxOutboundGroup::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  214. {
  215. DEBUG_FUNCTION_NAME( _T("CDlgNewFaxOutboundGroup::OnCancel"));
  216. EndDialog(wID);
  217. return 0;
  218. }
  219. //////////////////////////////////////////////////////////////////////////////
  220. /*++
  221. CDlgNewFaxOutboundGroup::OnHelpRequest
  222. This is called in response to the WM_HELP Notify
  223. message and to the WM_CONTEXTMENU Notify message.
  224. WM_HELP Notify message.
  225. This message is sent when the user presses F1 or <Shift>-F1
  226. over an item or when the user clicks on the ? icon and then
  227. presses the mouse over an item.
  228. WM_CONTEXTMENU Notify message.
  229. This message is sent when the user right clicks over an item
  230. and then clicks "What's this?"
  231. --*/
  232. /////////////////////////////////////////////////////////////////////////////
  233. LRESULT
  234. CDlgNewFaxOutboundGroup::OnHelpRequest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
  235. {
  236. DEBUG_FUNCTION_NAME(_T("CDlgNewFaxOutboundGroup::OnHelpRequest"));
  237. switch (uMsg)
  238. {
  239. case WM_HELP:
  240. WinContextHelp(((LPHELPINFO)lParam)->dwContextId, m_hWnd);
  241. break;
  242. case WM_CONTEXTMENU:
  243. WinContextHelp(::GetWindowContextHelpId((HWND)wParam), m_hWnd);
  244. break;
  245. }
  246. return TRUE;
  247. }
  248. /////////////////////////////////////////////////////////////////////////////