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.

431 lines
12 KiB

  1. /*++
  2. Copyright (c) 1999 - 2000 Microsoft Corporation
  3. Module Name:
  4. userinfo.c
  5. Abstract:
  6. Functions for handling events in the "User Info" page of
  7. the fax configuration wizard
  8. Environment:
  9. Fax configuration wizard
  10. Revision History:
  11. 03/13/00 -taoyuan-
  12. Created it.
  13. mm/dd/yy -author-
  14. description
  15. --*/
  16. #include "faxcfgwz.h"
  17. // functions which will be used only in this file
  18. VOID DoInitUserInfo(HWND hDlg);
  19. BOOL DoSaveUserInfo(HWND hDlg);
  20. DWORD FillInCountryCombo(HWND hDlg);
  21. VOID
  22. DoInitUserInfo(
  23. HWND hDlg
  24. )
  25. /*++
  26. Routine Description:
  27. Initializes the User Info property sheet page with information from shared data
  28. Arguments:
  29. hDlg - Handle to the User Info property sheet page
  30. Return Value:
  31. NONE
  32. --*/
  33. #define InitUserInfoTextField(id, str) SetDlgItemText(hDlg, id, (str) ? str : TEXT(""));
  34. {
  35. LPTSTR pszAddressDetail = NULL;
  36. PFAX_PERSONAL_PROFILE pUserInfo = NULL;
  37. DEBUG_FUNCTION_NAME(TEXT("DoInitUserInfo()"));
  38. pUserInfo = &(g_wizData.userInfo);
  39. //
  40. // A numeric edit control should be LTR
  41. //
  42. SetLTREditDirection(hDlg, IDC_SENDER_FAX_NUMBER);
  43. SetLTREditDirection(hDlg, IDC_SENDER_MAILBOX);
  44. SetLTREditDirection(hDlg, IDC_SENDER_HOME_TL);
  45. SetLTREditDirection(hDlg, IDC_SENDER_OFFICE_TL);
  46. //
  47. // Fill in the edit text fields
  48. //
  49. InitUserInfoTextField(IDC_SENDER_NAME, pUserInfo->lptstrName);
  50. InitUserInfoTextField(IDC_SENDER_FAX_NUMBER, pUserInfo->lptstrFaxNumber);
  51. InitUserInfoTextField(IDC_SENDER_MAILBOX, pUserInfo->lptstrEmail);
  52. InitUserInfoTextField(IDC_SENDER_COMPANY, pUserInfo->lptstrCompany);
  53. InitUserInfoTextField(IDC_SENDER_TITLE, pUserInfo->lptstrTitle);
  54. InitUserInfoTextField(IDC_SENDER_DEPT, pUserInfo->lptstrDepartment);
  55. InitUserInfoTextField(IDC_SENDER_OFFICE_LOC, pUserInfo->lptstrOfficeLocation);
  56. InitUserInfoTextField(IDC_SENDER_HOME_TL, pUserInfo->lptstrHomePhone);
  57. InitUserInfoTextField(IDC_SENDER_OFFICE_TL, pUserInfo->lptstrOfficePhone);
  58. InitUserInfoTextField(IDC_SENDER_BILLING_CODE, pUserInfo->lptstrBillingCode);
  59. InitUserInfoTextField(IDC_ADDRESS_DETAIL, pUserInfo->lptstrStreetAddress);
  60. return;
  61. }
  62. BOOL
  63. DoSaveUserInfo(
  64. HWND hDlg
  65. )
  66. /*++
  67. Routine Description:
  68. Save the information on the User Info property sheet page to shared data
  69. Arguments:
  70. hDlg - Handle to the User Info property sheet page
  71. Return Value:
  72. TRUE -- if no error
  73. FALSE -- if error
  74. --*/
  75. #define SaveUserInfoTextField(id, str) \
  76. { \
  77. if (! GetDlgItemText(hDlg, id, szBuffer, MAX_PATH)) \
  78. { \
  79. szBuffer[0] = 0; \
  80. } \
  81. MemFree(str); \
  82. str = StringDup(szBuffer); \
  83. if(!str) \
  84. { \
  85. DebugPrintEx(DEBUG_ERR, TEXT("StringDup failed.") ); \
  86. return FALSE; \
  87. } \
  88. } \
  89. {
  90. TCHAR szBuffer[MAX_PATH];
  91. PFAX_PERSONAL_PROFILE pUserInfo = NULL;
  92. DEBUG_FUNCTION_NAME(TEXT("DoSaveUserInfo()"));
  93. pUserInfo = &(g_wizData.userInfo);
  94. //
  95. // Save the edit text fields
  96. //
  97. SaveUserInfoTextField(IDC_SENDER_NAME, pUserInfo->lptstrName);
  98. SaveUserInfoTextField(IDC_SENDER_FAX_NUMBER, pUserInfo->lptstrFaxNumber);
  99. SaveUserInfoTextField(IDC_SENDER_MAILBOX, pUserInfo->lptstrEmail);
  100. SaveUserInfoTextField(IDC_SENDER_COMPANY, pUserInfo->lptstrCompany);
  101. SaveUserInfoTextField(IDC_SENDER_TITLE, pUserInfo->lptstrTitle);
  102. SaveUserInfoTextField(IDC_SENDER_DEPT, pUserInfo->lptstrDepartment);
  103. SaveUserInfoTextField(IDC_SENDER_OFFICE_LOC, pUserInfo->lptstrOfficeLocation);
  104. SaveUserInfoTextField(IDC_SENDER_HOME_TL, pUserInfo->lptstrHomePhone);
  105. SaveUserInfoTextField(IDC_SENDER_OFFICE_TL, pUserInfo->lptstrOfficePhone);
  106. SaveUserInfoTextField(IDC_SENDER_BILLING_CODE, pUserInfo->lptstrBillingCode);
  107. SaveUserInfoTextField(IDC_ADDRESS_DETAIL, pUserInfo->lptstrStreetAddress);
  108. return TRUE;
  109. }
  110. BOOL
  111. LoadUserInfo()
  112. /*++
  113. Routine Description:
  114. Load the user information from the system.
  115. Arguments:
  116. pUserInfo - Points to the user mode memory structure
  117. Return Value:
  118. TRUE if successful, FALSE if there is an error
  119. --*/
  120. #define DuplicateString(dst, src) \
  121. { \
  122. dst = StringDup(src); \
  123. if(!dst) \
  124. { \
  125. bRes = FALSE; \
  126. DebugPrintEx(DEBUG_ERR, TEXT("StringDup failed.") ); \
  127. goto exit; \
  128. } \
  129. }
  130. {
  131. BOOL bRes = TRUE;
  132. HRESULT hr;
  133. FAX_PERSONAL_PROFILE fpp = {0};
  134. PFAX_PERSONAL_PROFILE pUserInfo = NULL;
  135. DEBUG_FUNCTION_NAME(TEXT("LoadUserInfo()"));
  136. pUserInfo = &(g_wizData.userInfo);
  137. fpp.dwSizeOfStruct = sizeof(fpp);
  138. hr = FaxGetSenderInformation(&fpp);
  139. if (FAILED(hr))
  140. {
  141. DebugPrintEx(DEBUG_ERR, TEXT("FaxGetSenderInformation error, ec = %d"), hr);
  142. return FALSE;
  143. }
  144. //
  145. // Copy the user information to shared data
  146. //
  147. pUserInfo->dwSizeOfStruct = sizeof(FAX_PERSONAL_PROFILE);
  148. DuplicateString(pUserInfo->lptstrName, fpp.lptstrName);
  149. DuplicateString(pUserInfo->lptstrFaxNumber, fpp.lptstrFaxNumber);
  150. DuplicateString(pUserInfo->lptstrEmail, fpp.lptstrEmail);
  151. DuplicateString(pUserInfo->lptstrCompany, fpp.lptstrCompany);
  152. DuplicateString(pUserInfo->lptstrTitle, fpp.lptstrTitle);
  153. DuplicateString(pUserInfo->lptstrStreetAddress, fpp.lptstrStreetAddress);
  154. DuplicateString(pUserInfo->lptstrCity, fpp.lptstrCity);
  155. DuplicateString(pUserInfo->lptstrState, fpp.lptstrState);
  156. DuplicateString(pUserInfo->lptstrZip, fpp.lptstrZip);
  157. DuplicateString(pUserInfo->lptstrCountry, fpp.lptstrCountry);
  158. DuplicateString(pUserInfo->lptstrDepartment, fpp.lptstrDepartment);
  159. DuplicateString(pUserInfo->lptstrOfficeLocation, fpp.lptstrOfficeLocation);
  160. DuplicateString(pUserInfo->lptstrHomePhone, fpp.lptstrHomePhone);
  161. DuplicateString(pUserInfo->lptstrOfficePhone, fpp.lptstrOfficePhone);
  162. DuplicateString(pUserInfo->lptstrBillingCode, fpp.lptstrBillingCode);
  163. exit:
  164. hr = FaxFreeSenderInformation(&fpp);
  165. if (FAILED(hr))
  166. {
  167. //
  168. // Memory leak.
  169. //
  170. DebugPrintEx(DEBUG_ERR, TEXT("FaxFreeSenderInformation error, ec = %d"), hr);
  171. }
  172. return bRes;
  173. }
  174. BOOL
  175. SaveUserInfo()
  176. /*++
  177. Routine Description:
  178. Save the user information to the system.
  179. Arguments:
  180. pUserInfo - Points to the user mode memory structure
  181. Return Value:
  182. TRUE if successful, FALSE if there is an error
  183. --*/
  184. {
  185. HRESULT hResult;
  186. DEBUG_FUNCTION_NAME(TEXT("SaveUserInfo()"));
  187. g_wizData.userInfo.dwSizeOfStruct = sizeof(FAX_PERSONAL_PROFILE);
  188. hResult = FaxSetSenderInformation(&(g_wizData.userInfo));
  189. return (hResult == S_OK);
  190. }
  191. VOID
  192. FreeUserInfo()
  193. /*++
  194. Routine Description:
  195. Free the user info data and release the memory.
  196. Arguments:
  197. pUserInfo - Pointer to the user info data structure
  198. Return Value:
  199. none
  200. --*/
  201. {
  202. FAX_PERSONAL_PROFILE fpp = {0};
  203. DEBUG_FUNCTION_NAME(TEXT("FreeUserInfo"));
  204. MemFree(g_wizData.userInfo.lptstrName);
  205. MemFree(g_wizData.userInfo.lptstrFaxNumber);
  206. MemFree(g_wizData.userInfo.lptstrCompany);
  207. MemFree(g_wizData.userInfo.lptstrStreetAddress);
  208. MemFree(g_wizData.userInfo.lptstrCity);
  209. MemFree(g_wizData.userInfo.lptstrState);
  210. MemFree(g_wizData.userInfo.lptstrZip);
  211. MemFree(g_wizData.userInfo.lptstrCountry);
  212. MemFree(g_wizData.userInfo.lptstrTitle);
  213. MemFree(g_wizData.userInfo.lptstrDepartment);
  214. MemFree(g_wizData.userInfo.lptstrOfficeLocation);
  215. MemFree(g_wizData.userInfo.lptstrHomePhone);
  216. MemFree(g_wizData.userInfo.lptstrOfficePhone);
  217. MemFree(g_wizData.userInfo.lptstrEmail);
  218. MemFree(g_wizData.userInfo.lptstrBillingCode);
  219. MemFree(g_wizData.userInfo.lptstrTSID);
  220. //
  221. // NULLify all pointer
  222. //
  223. g_wizData.userInfo = fpp;
  224. return;
  225. }
  226. INT_PTR CALLBACK
  227. UserInfoDlgProc (
  228. HWND hDlg,
  229. UINT uMsg,
  230. WPARAM wParam,
  231. LPARAM lParam
  232. )
  233. /*++
  234. Routine Description:
  235. Procedure for handling the "User Info" tab
  236. Arguments:
  237. hDlg - Identifies the property sheet page
  238. uMsg - Specifies the message
  239. wParam - Specifies additional message-specific information
  240. lParam - Specifies additional message-specific information
  241. Return Value:
  242. Depends on the value of message parameter
  243. --*/
  244. {
  245. switch (uMsg)
  246. {
  247. case WM_INITDIALOG :
  248. {
  249. //
  250. // Maximum length for various text fields in the dialog
  251. //
  252. static INT textLimits[] = {
  253. IDC_SENDER_NAME, MAX_USERINFO_FULLNAME,
  254. IDC_SENDER_FAX_NUMBER, MAX_USERINFO_FAX_NUMBER,
  255. IDC_SENDER_MAILBOX, MAX_USERINFO_MAILBOX,
  256. IDC_SENDER_COMPANY, MAX_USERINFO_COMPANY,
  257. IDC_SENDER_TITLE, MAX_USERINFO_TITLE,
  258. IDC_SENDER_DEPT, MAX_USERINFO_DEPT,
  259. IDC_SENDER_OFFICE_LOC, MAX_USERINFO_OFFICE,
  260. IDC_SENDER_OFFICE_TL, MAX_USERINFO_WORK_PHONE,
  261. IDC_SENDER_HOME_TL, MAX_USERINFO_HOME_PHONE,
  262. IDC_SENDER_BILLING_CODE, MAX_USERINFO_BILLING_CODE,
  263. 0,
  264. };
  265. LimitTextFields(hDlg, textLimits);
  266. //
  267. // Initialize the text fields with information from the registry
  268. //
  269. DoInitUserInfo(hDlg);
  270. return TRUE;
  271. }
  272. case WM_COMMAND:
  273. break;
  274. case WM_NOTIFY :
  275. {
  276. LPNMHDR lpnm = (LPNMHDR) lParam;
  277. switch (lpnm->code)
  278. {
  279. case PSN_SETACTIVE : // Enable the Next button
  280. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_NEXT | PSWIZB_BACK);
  281. break;
  282. case PSN_WIZBACK:
  283. {
  284. //
  285. // Handle a Back button click here
  286. //
  287. if(RemoveLastPage(hDlg))
  288. {
  289. return TRUE;
  290. }
  291. break;
  292. }
  293. case PSN_WIZNEXT :
  294. //
  295. // Handle a Next button click here
  296. //
  297. DoSaveUserInfo(hDlg);
  298. SetLastPage(IDD_WIZARD_USER_INFO);
  299. break;
  300. case PSN_RESET :
  301. {
  302. // Handle a Cancel button click, if necessary
  303. break;
  304. }
  305. default :
  306. break;
  307. }
  308. }
  309. break;
  310. default:
  311. break;
  312. }
  313. return FALSE;
  314. }