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.

233 lines
6.2 KiB

  1. // PersonalInfoPg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #define __FILE_ID__ 44
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. //
  11. // this array maps dialog control IDs to
  12. // number of string in FAX_PERSONAL_PROFILE structure
  13. //
  14. static TPersonalPageInfo s_PageInfo[] =
  15. {
  16. IDC_NAME_VALUE, PERSONAL_PROFILE_NAME,
  17. IDC_FAX_NUMBER_VALUE, PERSONAL_PROFILE_FAX_NUMBER,
  18. IDC_COMPANY_VALUE, PERSONAL_PROFILE_COMPANY,
  19. IDC_TITLE_VALUE, PERSONAL_PROFILE_TITLE,
  20. IDC_DEPARTMENT_VALUE, PERSONAL_PROFILE_DEPARTMENT,
  21. IDC_OFFICE_VALUE, PERSONAL_PROFILE_OFFICE_LOCATION,
  22. IDC_HOME_PHONE_VALUE, PERSONAL_PROFILE_HOME_PHONE,
  23. IDC_BUSINESS_PHONE_VALUE, PERSONAL_PROFILE_OFFICE_PHONE,
  24. IDC_EMAIL_VALUE, PERSONAL_PROFILE_EMAIL,
  25. IDC_BILLING_CODE_VALUE, PERSONAL_PROFILE_BILLING_CODE,
  26. IDC_ADDRESS_VALUE, PERSONAL_PROFILE_STREET_ADDRESS
  27. };
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CPersonalInfoPg property page
  30. IMPLEMENT_DYNCREATE(CPersonalInfoPg, CFaxClientPg)
  31. CPersonalInfoPg::CPersonalInfoPg(
  32. DWORD dwCaptionId, // page caption id
  33. EnumPersinalInfo ePersonalInfo, // type of Persinal Info (SENDER or RECIPIENT)
  34. CFaxMsg* pMsg, // pointer to CJob or CArchiveMsg
  35. CFolder* pFolder // folder
  36. ) :
  37. CFaxClientPg(CPersonalInfoPg::IDD, dwCaptionId),
  38. m_ePersonalInfo(ePersonalInfo),
  39. m_pPersonalProfile(NULL),
  40. m_pMsg(pMsg),
  41. m_pFolder(pFolder)
  42. {
  43. DBG_ENTER(TEXT("CPersonalInfoPg::CPersonalInfoPg"));
  44. ASSERTION(NULL != pFolder);
  45. ASSERTION(PERSON_SENDER == ePersonalInfo || PERSON_RECIPIENT == ePersonalInfo);
  46. }
  47. CPersonalInfoPg::~CPersonalInfoPg()
  48. {
  49. if(m_pPersonalProfile)
  50. {
  51. FaxFreeBuffer(m_pPersonalProfile);
  52. }
  53. }
  54. void CPersonalInfoPg::DoDataExchange(CDataExchange* pDX)
  55. {
  56. CFaxClientPg::DoDataExchange(pDX);
  57. //{{AFX_DATA_MAP(CPersonalInfoPg)
  58. // NOTE: the ClassWizard will add DDX and DDV calls here
  59. //}}AFX_DATA_MAP
  60. }
  61. BEGIN_MESSAGE_MAP(CPersonalInfoPg, CFaxClientPg)
  62. //{{AFX_MSG_MAP(CPersonalInfoPg)
  63. //}}AFX_MSG_MAP
  64. END_MESSAGE_MAP()
  65. /////////////////////////////////////////////////////////////////////////////
  66. // CPersonalInfoPg message handlers
  67. DWORD
  68. CPersonalInfoPg::Init()
  69. {
  70. DWORD dwRes = ERROR_SUCCESS;
  71. DBG_ENTER(TEXT("CPersonalInfoPg::Init"));
  72. ASSERTION(m_pFolder);
  73. //
  74. // get server handle
  75. //
  76. CServerNode *pServer = const_cast<CServerNode *>(m_pFolder->GetServer());
  77. HANDLE hFax;
  78. dwRes = pServer->GetConnectionHandle (hFax);
  79. if (ERROR_SUCCESS != dwRes)
  80. {
  81. CALL_FAIL (GENERAL_ERR, TEXT("CServerNode::GetConnectionHandle"), dwRes);
  82. return dwRes;
  83. }
  84. //
  85. // get folder type and message id
  86. //
  87. DWORDLONG dwlMessageId;
  88. FAX_ENUM_MESSAGE_FOLDER eFolder;
  89. FolderType type = m_pFolder->Type();
  90. dwlMessageId = m_pMsg->GetId();
  91. switch(type)
  92. {
  93. case FOLDER_TYPE_INCOMING:
  94. case FOLDER_TYPE_OUTBOX:
  95. eFolder = FAX_MESSAGE_FOLDER_QUEUE;
  96. break;
  97. case FOLDER_TYPE_INBOX:
  98. eFolder = FAX_MESSAGE_FOLDER_INBOX;
  99. break;
  100. case FOLDER_TYPE_SENT_ITEMS:
  101. eFolder = FAX_MESSAGE_FOLDER_SENTITEMS;
  102. break;
  103. default:
  104. ASSERTION_FAILURE
  105. return ERROR_CAN_NOT_COMPLETE;
  106. };
  107. //
  108. // get personal info
  109. //
  110. if(PERSON_RECIPIENT == m_ePersonalInfo)
  111. {
  112. //
  113. // get recipient info
  114. //
  115. START_RPC_TIME(TEXT("FaxGetRecipientInfo"));
  116. if (!FaxGetRecipientInfo(hFax, dwlMessageId, eFolder, &m_pPersonalProfile))
  117. {
  118. dwRes = GetLastError ();
  119. END_RPC_TIME(TEXT("FaxGetRecipientInfo"));
  120. pServer->SetLastRPCError (dwRes);
  121. CALL_FAIL (RPC_ERR, TEXT("FaxGetRecipientInfo"), dwRes);
  122. m_pPersonalProfile = NULL;
  123. return dwRes;
  124. }
  125. END_RPC_TIME(TEXT("FaxGetRecipientInfo"));
  126. }
  127. else // if(PERSON_SENDER == m_ePersonalInfo)
  128. {
  129. //
  130. // get sender info
  131. //
  132. START_RPC_TIME(TEXT("FaxGetSenderInfo"));
  133. if (!FaxGetSenderInfo(hFax, dwlMessageId, eFolder, &m_pPersonalProfile))
  134. {
  135. dwRes = GetLastError ();
  136. END_RPC_TIME(TEXT("FaxGetSenderInfo"));
  137. pServer->SetLastRPCError (dwRes);
  138. CALL_FAIL (RPC_ERR, TEXT("FaxGetSenderInfo"), dwRes);
  139. m_pPersonalProfile = NULL;
  140. return dwRes;
  141. }
  142. END_RPC_TIME(TEXT("FaxGetSenderInfo"));
  143. }
  144. return dwRes;
  145. }
  146. BOOL
  147. CPersonalInfoPg::OnInitDialog()
  148. {
  149. DWORD dwRes = ERROR_SUCCESS;
  150. DBG_ENTER(TEXT("CPersonalInfoPg::OnInitDialog"));
  151. CFaxClientPg::OnInitDialog();
  152. if(!m_pPersonalProfile)
  153. {
  154. return TRUE;
  155. }
  156. CItemPropSheet* pParent = (CItemPropSheet*)GetParent();
  157. //
  158. // array of strings from FAX_PERSONAL_PROFILE
  159. //
  160. TCHAR** ptchValues = ptchValues = &(m_pPersonalProfile->lptstrName);
  161. CWnd *pWnd;
  162. dwRes = ERROR_SUCCESS;
  163. DWORD dwSize = sizeof(s_PageInfo)/sizeof(s_PageInfo[0]);
  164. for(DWORD dw=0; dw < dwSize; ++dw)
  165. {
  166. //
  167. // set item value
  168. //
  169. pWnd = GetDlgItem(s_PageInfo[dw].dwValueResId);
  170. if(NULL == pWnd)
  171. {
  172. dwRes = ERROR_INVALID_HANDLE;
  173. CALL_FAIL (WINDOW_ERR, TEXT("CWnd::GetDlgItem"), dwRes);
  174. break;
  175. }
  176. pWnd->SetWindowText(ptchValues[s_PageInfo[dw].eValStrNum]);
  177. //
  178. // Place the caret back at the beginning of the text
  179. //
  180. pWnd->SendMessage (EM_SETSEL, 0, 0);
  181. }
  182. if (ERROR_SUCCESS != dwRes)
  183. {
  184. pParent->SetLastError(ERROR_INVALID_DATA);
  185. pParent->EndDialog(IDABORT);
  186. }
  187. return TRUE;
  188. }
  189. BOOL
  190. CPersonalInfoPg::OnSetActive()
  191. {
  192. BOOL bRes = CFaxClientPg::OnSetActive();
  193. GetParent()->PostMessage(WM_SET_SHEET_FOCUS, 0, 0L);
  194. return bRes;
  195. }