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.

428 lines
14 KiB

  1. //Copyright (c) 1998 - 2001 Microsoft Corporation
  2. #include "precomp.h"
  3. LRW_DLG_INT CALLBACK ConfirmEMailDlgProc(IN HWND hwndDlg, // handle to dialog box
  4. IN UINT uMsg, // message
  5. IN WPARAM wParam, // first message parameter
  6. IN LPARAM lParam // second message parameter
  7. )
  8. {
  9. BOOL bRetCode = FALSE;
  10. LPTSTR lpVal = NULL;
  11. CString sEmailConf;
  12. switch ( uMsg )
  13. {
  14. case WM_INITDIALOG:
  15. bRetCode = TRUE;
  16. break;
  17. case WM_COMMAND:
  18. switch ( LOWORD(wParam) ) //from which control
  19. {
  20. case IDOK:
  21. //Get the ITem text and store it in the global structure
  22. lpVal = sEmailConf.GetBuffer(CA_EMAIL_LEN+1);
  23. GetDlgItemText(hwndDlg,IDC_TXT_CONF_EMAIL,lpVal,CA_EMAIL_LEN+1);
  24. sEmailConf.ReleaseBuffer(-1);
  25. sEmailConf.TrimLeft(); sEmailConf.TrimRight();
  26. GetGlobalContext()->GetContactDataObject()->sEmailAddressConf = sEmailConf;
  27. EndDialog(hwndDlg, IDOK);
  28. bRetCode = TRUE;
  29. break;
  30. default:
  31. break;
  32. }
  33. break;
  34. default:
  35. break;
  36. }
  37. return bRetCode;
  38. }
  39. LRW_DLG_INT CALLBACK
  40. ContactInfo1DlgProc(
  41. IN HWND hwnd,
  42. IN UINT uMsg,
  43. IN WPARAM wParam,
  44. IN LPARAM lParam
  45. )
  46. {
  47. DWORD dwNextPage = 0;
  48. BOOL bStatus = TRUE;
  49. CString sCountryDesc;
  50. CString sProgramName;
  51. switch (uMsg)
  52. {
  53. case WM_INITDIALOG:
  54. SendDlgItemMessage (hwnd , IDC_TXT_COMPANYNAME, EM_SETLIMITTEXT, CA_COMPANY_NAME_LEN,0);
  55. SendDlgItemMessage (hwnd , IDC_TXT_LNAME, EM_SETLIMITTEXT, CA_NAME_LEN,0);
  56. SendDlgItemMessage (hwnd , IDC_TXT_FNAME, EM_SETLIMITTEXT, CA_NAME_LEN,0);
  57. //Populate the values which were read from the Registry during Global Init
  58. SetDlgItemText(hwnd,IDC_TXT_LNAME, GetGlobalContext()->GetContactDataObject()->sContactLName);
  59. SetDlgItemText(hwnd,IDC_TXT_FNAME, GetGlobalContext()->GetContactDataObject()->sContactFName);
  60. SetDlgItemText(hwnd,IDC_TXT_COMPANYNAME, GetGlobalContext()->GetContactDataObject()->sCompanyName);
  61. //Set up the country/region combo box
  62. PopulateCountryComboBox(GetDlgItem(hwnd,IDC_COUNTRY_REGION));
  63. GetCountryDesc(GetGlobalContext()->GetContactDataObject()->sCountryCode,
  64. sCountryDesc.GetBuffer(LR_COUNTRY_DESC_LEN+1));
  65. sCountryDesc.ReleaseBuffer();
  66. ComboBox_SetCurSel(GetDlgItem(hwnd,IDC_COUNTRY_REGION),
  67. ComboBox_FindStringExact(GetDlgItem(hwnd, IDC_COUNTRY_REGION), 0, sCountryDesc));
  68. AddHyperLinkToStaticCtl(hwnd, IDC_PRIVACY);
  69. break;
  70. case WM_DESTROY:
  71. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  72. break;
  73. case WM_NOTIFY:
  74. {
  75. LPNMHDR pnmh = (LPNMHDR)lParam;
  76. switch( pnmh->code )
  77. {
  78. //Trap keystokes/clicks on the hyperlink
  79. case NM_CHAR:
  80. if( ( ( LPNMCHAR )lParam )->ch != VK_SPACE )
  81. break;
  82. // else fall through
  83. case NM_RETURN:
  84. case NM_CLICK:
  85. DisplayPrivacyHelp();
  86. break;
  87. case PSN_SETACTIVE:
  88. {
  89. PropSheet_SetWizButtons( GetParent( hwnd ), PSWIZB_NEXT|PSWIZB_BACK );
  90. AddHyperLinkToStaticCtl(hwnd, IDC_PRIVACY);
  91. }
  92. break;
  93. case PSN_WIZNEXT:
  94. {
  95. CString sCompanyName;
  96. CString sLastName;
  97. CString sFirstName;
  98. CString sCountryDesc;
  99. CString sCountryCode;
  100. LPTSTR lpVal = NULL;
  101. //Read all the fields
  102. lpVal = sCompanyName.GetBuffer(CA_COMPANY_NAME_LEN+1);
  103. GetDlgItemText(hwnd,IDC_TXT_COMPANYNAME,lpVal,CA_COMPANY_NAME_LEN+1);
  104. sCompanyName.ReleaseBuffer(-1);
  105. lpVal = sLastName.GetBuffer(CA_NAME_LEN+1);
  106. GetDlgItemText(hwnd,IDC_TXT_LNAME,lpVal,CA_NAME_LEN+1);
  107. sLastName.ReleaseBuffer(-1);
  108. lpVal = sFirstName.GetBuffer(CA_NAME_LEN+1);
  109. GetDlgItemText(hwnd,IDC_TXT_FNAME,lpVal,CA_NAME_LEN+1);
  110. sFirstName.ReleaseBuffer(-1);
  111. int nCurSel = -1;
  112. nCurSel = ComboBox_GetCurSel(GetDlgItem(hwnd,IDC_COUNTRY_REGION));
  113. lpVal = sCountryDesc.GetBuffer(LR_COUNTRY_DESC_LEN+1);
  114. ComboBox_GetLBText(GetDlgItem(hwnd, IDC_COUNTRY_REGION), nCurSel, lpVal);
  115. sCountryDesc.ReleaseBuffer(-1);
  116. sFirstName.TrimLeft(); sFirstName.TrimRight();
  117. sLastName.TrimLeft(); sLastName.TrimRight();
  118. sCompanyName.TrimLeft(); sCompanyName.TrimRight();
  119. sCountryDesc.TrimLeft();sCountryDesc.TrimRight();
  120. if(sLastName.IsEmpty() || sFirstName.IsEmpty() || sCompanyName.IsEmpty())
  121. {
  122. LRMessageBox(hwnd,IDS_ERR_FIELD_EMPTY,IDS_WIZARD_MESSAGE_TITLE);
  123. dwNextPage = IDD_CONTACTINFO1;
  124. goto NextDone;
  125. }
  126. // Check for the Invalid Characters
  127. if( !ValidateLRString(sFirstName) ||
  128. !ValidateLRString(sLastName) ||
  129. !ValidateLRString(sCountryDesc)
  130. )
  131. {
  132. LRMessageBox(hwnd,IDS_ERR_INVALID_CHAR,IDS_WIZARD_MESSAGE_TITLE);
  133. dwNextPage = IDD_CONTACTINFO1;
  134. goto NextDone;
  135. }
  136. dwNextPage = IDD_CONTACTINFO2;
  137. //Check for unselected country/region
  138. if(sCountryDesc.IsEmpty())
  139. {
  140. LRMessageBox(hwnd,IDS_ERR_FIELD_EMPTY,IDS_WIZARD_MESSAGE_TITLE);
  141. dwNextPage = IDD_CONTACTINFO1;
  142. goto NextDone;
  143. }
  144. //Get the country code assicated with the selected country
  145. lpVal = sCountryCode.GetBuffer(LR_COUNTRY_CODE_LEN+1);
  146. if (sCountryDesc.IsEmpty())
  147. lstrcpy(lpVal, _TEXT(""));
  148. else
  149. GetCountryCode(sCountryDesc,lpVal);
  150. sCountryCode.ReleaseBuffer(-1);
  151. //Finally update CHData object
  152. GetGlobalContext()->GetContactDataObject()->sContactFName = sFirstName;
  153. GetGlobalContext()->GetContactDataObject()->sContactLName = sLastName;
  154. GetGlobalContext()->GetContactDataObject()->sCompanyName = sCompanyName;
  155. GetGlobalContext()->GetContactDataObject()->sCountryDesc = sCountryDesc;
  156. GetGlobalContext()->GetContactDataObject()->sCountryCode = sCountryCode;
  157. //
  158. // IMPORTANT:
  159. // The activation wizard flow used to ask for license type.
  160. // It doesn't anymore but to minimize changes we pre-select a program
  161. // type. The user gets to change it when they run the CAL wizard
  162. //
  163. //
  164. sProgramName = PROGRAM_LICENSE_PAK;
  165. GetGlobalContext()->GetContactDataObject()->sProgramName = sProgramName;
  166. GetGlobalContext()->SetInRegistry(szOID_BUSINESS_CATEGORY,
  167. GetGlobalContext()->GetContactDataObject()->sProgramName);
  168. // Put into regsitery too
  169. GetGlobalContext()->SetInRegistry(szOID_COMMON_NAME, sFirstName);
  170. GetGlobalContext()->SetInRegistry(szOID_SUR_NAME, sLastName);
  171. GetGlobalContext()->SetInRegistry(szOID_ORGANIZATION_NAME, sCompanyName);
  172. GetGlobalContext()->SetInRegistry(szOID_COUNTRY_NAME, sCountryDesc);
  173. GetGlobalContext()->SetInRegistry(szOID_DESCRIPTION, sCountryCode);
  174. //If no Error , go to the next page
  175. LRPush(IDD_CONTACTINFO1);
  176. NextDone:
  177. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  178. bStatus = -1;
  179. }
  180. break;
  181. case PSN_WIZBACK:
  182. dwNextPage = LRPop();
  183. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  184. bStatus = -1;
  185. break;
  186. default:
  187. bStatus = FALSE;
  188. break;
  189. }
  190. }
  191. break;
  192. default:
  193. bStatus = FALSE;
  194. break;
  195. }
  196. return bStatus;
  197. }
  198. LRW_DLG_INT CALLBACK
  199. ContactInfo2DlgProc(
  200. IN HWND hwnd,
  201. IN UINT uMsg,
  202. IN WPARAM wParam,
  203. IN LPARAM lParam
  204. )
  205. {
  206. DWORD dwNextPage = 0;
  207. BOOL bStatus = TRUE;
  208. //CString sCountryDesc;
  209. switch (uMsg)
  210. {
  211. case WM_INITDIALOG:
  212. SendDlgItemMessage (hwnd , IDC_TXT_EMAIL, EM_SETLIMITTEXT, CA_EMAIL_LEN,0);
  213. SendDlgItemMessage (hwnd , IDC_TXT_ADDRESS1, EM_SETLIMITTEXT, CA_ADDRESS_LEN,0);
  214. SendDlgItemMessage (hwnd , IDC_TXT_CITY, EM_SETLIMITTEXT, CA_CITY_LEN,0);
  215. SendDlgItemMessage (hwnd , IDC_TXT_STATE, EM_SETLIMITTEXT, CA_STATE_LEN,0);
  216. SendDlgItemMessage (hwnd , IDC_TXT_ZIP, EM_SETLIMITTEXT, CA_ZIP_LEN,0);
  217. SendDlgItemMessage (hwnd , IDC_COMPANY_DIV, EM_SETLIMITTEXT, CA_ORG_UNIT_LEN,0);
  218. //Populate the values which were read from the Registry during Global Init
  219. SetDlgItemText(hwnd,IDC_TXT_EMAIL, GetGlobalContext()->GetContactDataObject()->sContactEmail);
  220. SetDlgItemText(hwnd,IDC_TXT_ADDRESS1, GetGlobalContext()->GetContactDataObject()->sContactAddress);
  221. SetDlgItemText(hwnd,IDC_TXT_CITY , GetGlobalContext()->GetContactDataObject()->sCity);
  222. SetDlgItemText(hwnd,IDC_TXT_STATE , GetGlobalContext()->GetContactDataObject()->sState);
  223. SetDlgItemText(hwnd,IDC_TXT_ZIP , GetGlobalContext()->GetContactDataObject()->sZip);
  224. SetDlgItemText(hwnd,IDC_COMPANY_DIV , GetGlobalContext()->GetContactDataObject()->sOrgUnit);
  225. AddHyperLinkToStaticCtl(hwnd, IDC_PRIVACY);
  226. break;
  227. case WM_DESTROY:
  228. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  229. break;
  230. case WM_NOTIFY:
  231. {
  232. LPNMHDR pnmh = (LPNMHDR)lParam;
  233. switch( pnmh->code )
  234. {
  235. //Trap keystokes/clicks on the hyperlink
  236. case NM_CHAR:
  237. if( ( ( LPNMCHAR )lParam )->ch != VK_SPACE )
  238. break;
  239. // else fall through
  240. case NM_RETURN:
  241. case NM_CLICK:
  242. DisplayPrivacyHelp();
  243. break;
  244. case PSN_SETACTIVE:
  245. PropSheet_SetWizButtons( GetParent( hwnd ), PSWIZB_NEXT | PSWIZB_BACK);
  246. AddHyperLinkToStaticCtl(hwnd, IDC_PRIVACY);
  247. break;
  248. case PSN_WIZNEXT:
  249. {
  250. CString sEmail;
  251. CString sAddress1;
  252. CString sCity;
  253. CString sState;
  254. LPTSTR lpVal = NULL;
  255. CString sZip;
  256. CString sOrgUnit;
  257. DWORD dwRetCode;
  258. int nCurSel = -1;
  259. //Read all the fields
  260. lpVal = sEmail.GetBuffer(CA_EMAIL_LEN+1);
  261. GetDlgItemText(hwnd,IDC_TXT_EMAIL,lpVal,CA_EMAIL_LEN+1);
  262. sEmail.ReleaseBuffer(-1);
  263. lpVal = sAddress1.GetBuffer(CA_ADDRESS_LEN+1);
  264. GetDlgItemText(hwnd,IDC_TXT_ADDRESS1,lpVal,CA_ADDRESS_LEN+1);
  265. sAddress1.ReleaseBuffer(-1);
  266. lpVal = sCity.GetBuffer(CA_CITY_LEN+1);
  267. GetDlgItemText(hwnd,IDC_TXT_CITY,lpVal,CA_CITY_LEN+1);
  268. sCity.ReleaseBuffer(-1);
  269. lpVal = sState.GetBuffer(CA_STATE_LEN+1);
  270. GetDlgItemText(hwnd,IDC_TXT_STATE,lpVal,CA_STATE_LEN+1);
  271. sState.ReleaseBuffer(-1);
  272. lpVal = sZip.GetBuffer(CA_ZIP_LEN+1);
  273. GetDlgItemText(hwnd,IDC_TXT_ZIP,lpVal,CA_ZIP_LEN+1);
  274. sZip.ReleaseBuffer(-1);
  275. lpVal = sOrgUnit.GetBuffer(CA_ORG_UNIT_LEN+1);
  276. GetDlgItemText(hwnd,IDC_COMPANY_DIV,lpVal,CA_ORG_UNIT_LEN+1);
  277. sOrgUnit.ReleaseBuffer(-1);
  278. sEmail.TrimLeft(); sEmail.TrimRight();
  279. sAddress1.TrimLeft(); sAddress1.TrimRight();
  280. sCity.TrimLeft(); sCity.TrimRight();
  281. sState.TrimLeft(); sState.TrimRight();
  282. sZip.TrimLeft(); sZip.TrimRight();
  283. sOrgUnit.TrimLeft(); sOrgUnit.TrimRight();
  284. if(
  285. !ValidateLRString(sAddress1) ||
  286. !ValidateLRString(sCity) ||
  287. !ValidateLRString(sState) ||
  288. !ValidateLRString(sZip) ||
  289. !ValidateLRString(sOrgUnit) ||
  290. !ValidateLRString(sEmail)
  291. )
  292. {
  293. LRMessageBox(hwnd,IDS_ERR_INVALID_CHAR);
  294. dwNextPage = IDD_CONTACTINFO2;
  295. goto NextDone;
  296. }
  297. // Validate email address if not empty
  298. if(!sEmail.IsEmpty())
  299. {
  300. if(!ValidateEmailId(sEmail))
  301. {
  302. LRMessageBox(hwnd,IDS_ERR_INVALID_EMAIL,IDS_WIZARD_MESSAGE_TITLE);
  303. dwNextPage = IDD_CONTACTINFO2;
  304. goto NextDone;
  305. }
  306. }
  307. //Finally update CHData object
  308. GetGlobalContext()->GetContactDataObject()->sContactEmail = sEmail;
  309. GetGlobalContext()->GetContactDataObject()->sCity = sCity;
  310. GetGlobalContext()->GetContactDataObject()->sContactAddress = sAddress1;
  311. GetGlobalContext()->GetContactDataObject()->sZip = sZip;
  312. GetGlobalContext()->GetContactDataObject()->sState = sState;
  313. GetGlobalContext()->GetContactDataObject()->sOrgUnit = sOrgUnit;
  314. GetGlobalContext()->SetInRegistry(szOID_RSA_emailAddr, (LPCTSTR) sEmail);
  315. GetGlobalContext()->SetInRegistry(szOID_LOCALITY_NAME, sCity);
  316. GetGlobalContext()->SetInRegistry(szOID_STREET_ADDRESS, sAddress1);
  317. GetGlobalContext()->SetInRegistry(szOID_POSTAL_CODE, sZip);
  318. GetGlobalContext()->SetInRegistry(szOID_STATE_OR_PROVINCE_NAME, sState);
  319. GetGlobalContext()->SetInRegistry(szOID_ORGANIZATIONAL_UNIT_NAME, sOrgUnit);
  320. dwRetCode = ShowProgressBox(hwnd, ProcessThread, 0, 0, 0);
  321. if (dwRetCode != ERROR_SUCCESS)
  322. {
  323. LRMessageBox(hwnd, dwRetCode,IDS_WIZARD_MESSAGE_TITLE);
  324. dwNextPage = IDD_CONTACTINFO2;
  325. }
  326. else
  327. {
  328. LRPush(IDD_WELCOME_CLIENT_LICENSING);
  329. dwNextPage = IDD_PROGRESS;
  330. }
  331. NextDone:
  332. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  333. bStatus = -1;
  334. }
  335. break;
  336. case PSN_WIZBACK:
  337. dwNextPage = LRPop();
  338. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  339. bStatus = -1;
  340. break;
  341. default:
  342. bStatus = FALSE;
  343. break;
  344. }
  345. }
  346. break;
  347. default:
  348. bStatus = FALSE;
  349. break;
  350. }
  351. return bStatus;
  352. }