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.

179 lines
4.6 KiB

  1. #include "stdafx.h"
  2. #include "RoutingMethodProp.h"
  3. #include "RoutingMethodConfig.h"
  4. #include <faxutil.h>
  5. #include <faxreg.h>
  6. #include <faxres.h>
  7. #include <EmailConfigPage.h>
  8. #include <Util.h>
  9. HRESULT
  10. CEmailConfigPage::Init(
  11. LPCTSTR lpctstrServerName,
  12. DWORD dwDeviceId
  13. )
  14. {
  15. DEBUG_FUNCTION_NAME(TEXT("CEmailConfigPage::Init"));
  16. DWORD ec = ERROR_SUCCESS;
  17. m_bstrServerName = lpctstrServerName;
  18. m_dwDeviceId = dwDeviceId;
  19. if (!m_bstrServerName)
  20. {
  21. DebugPrintEx(
  22. DEBUG_ERR,
  23. TEXT("Out of memory while copying server name (ec: %ld)")
  24. );
  25. ec = ERROR_NOT_ENOUGH_MEMORY;
  26. DisplayRpcErrorMessage(ERROR_NOT_ENOUGH_MEMORY, IDS_EMAIL_TITLE, m_hWnd);
  27. goto exit;
  28. }
  29. if (!FaxConnectFaxServer(lpctstrServerName, &m_hFax))
  30. {
  31. ec = GetLastError();
  32. DebugPrintEx(
  33. DEBUG_ERR,
  34. TEXT("FaxConnectFaxServer failed (ec: %ld)"),
  35. ec);
  36. DisplayRpcErrorMessage(ec, IDS_EMAIL_TITLE, m_hWnd);
  37. goto exit;
  38. }
  39. //
  40. // Retrieve the data
  41. //
  42. ec = ReadExtStringData (
  43. m_hFax,
  44. m_dwDeviceId,
  45. REGVAL_RM_EMAIL_GUID,
  46. m_bstrMailTo,
  47. TEXT(""),
  48. IDS_EMAIL_TITLE,
  49. m_hWnd);
  50. exit:
  51. if ((ERROR_SUCCESS != ec) && m_hFax)
  52. {
  53. if (!FaxClose(m_hFax))
  54. {
  55. DebugPrintEx(
  56. DEBUG_ERR,
  57. TEXT("FaxClose() failed on fax handle (0x%08X : %s). (ec: %ld)"),
  58. m_hFax,
  59. m_bstrServerName,
  60. GetLastError());
  61. }
  62. m_hFax = NULL;
  63. }
  64. return HRESULT_FROM_WIN32(ec);
  65. } // CEmailConfigPage::Init
  66. LRESULT CEmailConfigPage::OnInitDialog(
  67. UINT uiMsg,
  68. WPARAM wParam,
  69. LPARAM lParam,
  70. BOOL& fHandled
  71. )
  72. {
  73. DEBUG_FUNCTION_NAME( _T("CEmailConfigPage::OnInitDialog"));
  74. //
  75. // An edit control should be LTR
  76. //
  77. SetLTREditDirection (m_hWnd,IDC_EDIT_MAILTO);
  78. //
  79. // Attach and set values to the controls
  80. //
  81. m_edtMailTo.Attach (GetDlgItem (IDC_EDIT_MAILTO));
  82. m_edtMailTo.SetWindowText (m_bstrMailTo);
  83. m_fIsDialogInitiated = TRUE;
  84. return 1;
  85. }
  86. BOOL
  87. CEmailConfigPage::OnApply()
  88. {
  89. DEBUG_FUNCTION_NAME(TEXT("CEmailConfigPage::OnApply"));
  90. if (!m_fIsDirty)
  91. {
  92. return TRUE;
  93. }
  94. //
  95. // Collect data from the controls
  96. //
  97. m_edtMailTo.GetWindowText (m_bstrMailTo.m_str);
  98. //
  99. // Check data validity
  100. //
  101. if (!m_bstrMailTo.Length())
  102. {
  103. DisplayErrorMessage (IDS_EMAIL_TITLE, IDS_EMAIL_ADDR_INVALID, FALSE, m_hWnd);
  104. return FALSE;
  105. }
  106. //
  107. // Validation passed. Now write the data using RPC
  108. //
  109. if (ERROR_SUCCESS != WriteExtData (m_hFax,
  110. m_dwDeviceId,
  111. REGVAL_RM_EMAIL_GUID,
  112. (LPBYTE)(LPCWSTR)m_bstrMailTo,
  113. sizeof (WCHAR) * (1 + m_bstrMailTo.Length()),
  114. IDS_EMAIL_TITLE,
  115. m_hWnd))
  116. {
  117. return FALSE;
  118. }
  119. //Success
  120. m_fIsDirty = FALSE;
  121. return TRUE;
  122. } // CEmailConfigPage::OnApply
  123. //////////////////////////////////////////////////////////////////////////////
  124. /*++
  125. CEmailConfigPage::OnHelpRequest
  126. This is called in response to the WM_HELP Notify
  127. message and to the WM_CONTEXTMENU Notify message.
  128. WM_HELP Notify message.
  129. This message is sent when the user presses F1 or <Shift>-F1
  130. over an item or when the user clicks on the ? icon and then
  131. presses the mouse over an item.
  132. WM_CONTEXTMENU Notify message.
  133. This message is sent when the user right clicks over an item
  134. and then clicks "What's this?"
  135. --*/
  136. /////////////////////////////////////////////////////////////////////////////
  137. LRESULT
  138. CEmailConfigPage::OnHelpRequest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
  139. {
  140. DEBUG_FUNCTION_NAME(_T("CEmailConfigPage::OnHelpRequest"));
  141. switch (uMsg)
  142. {
  143. case WM_HELP:
  144. WinContextHelp(((LPHELPINFO)lParam)->dwContextId, m_hWnd);
  145. break;
  146. case WM_CONTEXTMENU:
  147. WinContextHelp(::GetWindowContextHelpId((HWND)wParam), m_hWnd);
  148. break;
  149. }
  150. return TRUE;
  151. }