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.

539 lines
17 KiB

  1. //Copyright (c) 1998 - 2001 Microsoft Corporation
  2. #include "licensetype.h"
  3. #include "fonts.h"
  4. #include "mode.h"
  5. LRW_DLG_INT CALLBACK
  6. PropModeDlgProc(
  7. IN HWND hwnd,
  8. IN UINT uMsg,
  9. IN WPARAM wParam,
  10. IN LPARAM lParam
  11. )
  12. {
  13. DWORD dwRetCode = ERROR_SUCCESS;
  14. BOOL bStatus = TRUE;
  15. switch (uMsg)
  16. {
  17. case WM_INITDIALOG:
  18. {
  19. TCHAR lpBuffer[ 512];
  20. LVFINDINFO lvFindInfo;
  21. int nItem = 0;
  22. HWND hWndComboBox = GetDlgItem(hwnd,IDC_MODEOFREG);
  23. memset(lpBuffer,0,sizeof(lpBuffer));
  24. dwRetCode = LoadString(GetInstanceHandle(), IDS_INTERNETMODE, lpBuffer, 512);
  25. ComboBox_AddString(hWndComboBox,lpBuffer);
  26. memset(lpBuffer,0,sizeof(lpBuffer));
  27. dwRetCode = LoadString(GetInstanceHandle(), IDS_WWWMODE, lpBuffer, 512);
  28. ComboBox_AddString(hWndComboBox,lpBuffer);
  29. memset(lpBuffer,0,sizeof(lpBuffer));
  30. dwRetCode = LoadString(GetInstanceHandle(), IDS_TELEPHONEMODE, lpBuffer, 512);
  31. ComboBox_AddString(hWndComboBox,lpBuffer);
  32. HWND hCountryRegion = GetDlgItem(hwnd, IDC_PHONE_COUNTRYREGION);
  33. // Set the Current Activation Method
  34. GetGlobalContext()->SetLSProp_ActivationMethod(GetGlobalContext()->GetActivationMethod());
  35. ComboBox_ResetContent(hCountryRegion);
  36. if(GetGlobalContext()->GetActivationMethod() == CONNECTION_INTERNET ||
  37. GetGlobalContext()->GetActivationMethod() == CONNECTION_DEFAULT)
  38. {
  39. ComboBox_SetCurSel(hWndComboBox, 0);
  40. EnableWindow(hCountryRegion,FALSE);
  41. EnableWindow(GetDlgItem(hwnd, IDC_COUNTRYREGION_LABEL), FALSE);
  42. }
  43. if(GetGlobalContext()->GetActivationMethod() == CONNECTION_WWW )
  44. {
  45. ComboBox_SetCurSel(hWndComboBox, 1);
  46. EnableWindow(hCountryRegion,FALSE);
  47. EnableWindow(GetDlgItem(hwnd, IDC_COUNTRYREGION_LABEL), FALSE);
  48. }
  49. if(GetGlobalContext()->GetActivationMethod() == CONNECTION_PHONE )
  50. {
  51. ComboBox_SetCurSel(hWndComboBox, 2);
  52. dwRetCode = PopulateCountryRegionComboBox(hCountryRegion);
  53. if (dwRetCode != ERROR_SUCCESS)
  54. {
  55. LRMessageBox(hwnd, dwRetCode, NULL, LRGetLastError());
  56. }
  57. nItem = ComboBox_FindStringExact(hCountryRegion, -1, GetGlobalContext()->GetContactDataObject()->sCSRPhoneRegion);
  58. ComboBox_SetCurSel(hCountryRegion, nItem);
  59. EnableWindow(hCountryRegion,TRUE);
  60. EnableWindow(GetDlgItem(hwnd, IDC_COUNTRYREGION_LABEL), TRUE);
  61. }
  62. SetDlgItemText(hwnd, IDC_LABEL_PRODUCTID, GetGlobalContext()->GetLicenseServerID());
  63. }
  64. SetConnectionMethodText(hwnd);
  65. break;
  66. case WM_COMMAND:
  67. if(HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_MODEOFREG)
  68. {
  69. LVFINDINFO lvFindInfo;
  70. int nItem = 0;
  71. HWND hWndComboBox = GetDlgItem(hwnd,IDC_MODEOFREG);
  72. HWND hCountryRegion = GetDlgItem(hwnd, IDC_PHONE_COUNTRYREGION);
  73. SetReFresh(1);
  74. dwRetCode = ComboBox_GetCurSel((HWND)lParam);
  75. ComboBox_ResetContent(hCountryRegion);
  76. //Enable Country/Region List Box in case of Telephone
  77. if(dwRetCode == 2)
  78. {
  79. GetGlobalContext()->SetLSProp_ActivationMethod(CONNECTION_PHONE);
  80. dwRetCode = PopulateCountryRegionComboBox(hCountryRegion);
  81. if (dwRetCode != ERROR_SUCCESS)
  82. {
  83. LRMessageBox(hwnd, dwRetCode, NULL, LRGetLastError());
  84. }
  85. nItem = ComboBox_FindStringExact(hCountryRegion, -1, GetGlobalContext()->GetContactDataObject()->sCSRPhoneRegion);
  86. ComboBox_SetCurSel(hCountryRegion, nItem);
  87. EnableWindow(hCountryRegion,TRUE);
  88. EnableWindow(GetDlgItem(hwnd, IDC_COUNTRYREGION_LABEL), TRUE);
  89. }
  90. else
  91. {
  92. if(dwRetCode == 0) // Internet
  93. {
  94. GetGlobalContext()->SetLSProp_ActivationMethod(CONNECTION_INTERNET);
  95. }
  96. else
  97. {
  98. GetGlobalContext()->SetLSProp_ActivationMethod(CONNECTION_WWW);
  99. }
  100. EnableWindow(hCountryRegion,FALSE);
  101. EnableWindow(GetDlgItem(hwnd, IDC_COUNTRYREGION_LABEL), FALSE);
  102. }
  103. SetConnectionMethodText(hwnd);
  104. }
  105. break;
  106. case WM_DESTROY:
  107. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  108. break;
  109. case WM_NOTIFY:
  110. {
  111. LPNMHDR pnmh = (LPNMHDR)lParam;
  112. switch( pnmh->code )
  113. {
  114. case PSN_SETACTIVE:
  115. break;
  116. case PSN_APPLY:
  117. {
  118. HWND hWndComboBox = GetDlgItem(hwnd,IDC_MODEOFREG);
  119. HWND hCountryRegion = GetDlgItem(hwnd, IDC_PHONE_COUNTRYREGION );
  120. long lReturnStatus = PSNRET_NOERROR;
  121. TCHAR szItemText[MAX_COUNTRY_NAME_LENGTH + 1];
  122. int nItem = 0;
  123. dwRetCode = ComboBox_GetCurSel(hWndComboBox);
  124. assert(dwRetCode >= 0 && dwRetCode <= 2);
  125. //Internet
  126. if(dwRetCode == 0)
  127. {
  128. GetGlobalContext()->SetActivationMethod(CONNECTION_INTERNET);
  129. }
  130. // WWW
  131. if(dwRetCode == 1)
  132. {
  133. GetGlobalContext()->SetActivationMethod(CONNECTION_WWW);
  134. }
  135. // Phone
  136. if(dwRetCode == 2)
  137. {
  138. GetGlobalContext()->SetActivationMethod(CONNECTION_PHONE);
  139. nItem = ComboBox_GetCurSel(hCountryRegion);
  140. if(nItem == -1)
  141. {
  142. LRMessageBox(hwnd, IDS_ERR_NOCOUNTRYSELECTED);
  143. lReturnStatus = PSNRET_INVALID_NOCHANGEPAGE;
  144. goto done;
  145. }
  146. ComboBox_GetLBText(hCountryRegion, nItem, szItemText);
  147. GetGlobalContext()->SetInRegistry(REG_LRWIZ_CSPHONEREGION,szItemText);
  148. TCHAR szPhoneNumber[128];
  149. GetGlobalContext()->ReadPhoneNumberFromRegistry(szItemText, szPhoneNumber, (DWORD)sizeof(szPhoneNumber));
  150. GetGlobalContext()->SetCSRNumber(szPhoneNumber);
  151. }
  152. done:
  153. if(lReturnStatus != PSNRET_NOERROR)
  154. PropSheet_SetCurSel(GetParent(hwnd),NULL,PG_NDX_PROP_MODE);
  155. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, lReturnStatus);
  156. }
  157. break;
  158. default:
  159. bStatus = FALSE;
  160. break;
  161. }
  162. }
  163. break;
  164. default:
  165. bStatus = FALSE;
  166. break;
  167. }
  168. return bStatus;
  169. }
  170. LRW_DLG_INT CALLBACK
  171. PropCustInfoADlgProc(
  172. IN HWND hwnd,
  173. IN UINT uMsg,
  174. IN WPARAM wParam,
  175. IN LPARAM lParam
  176. )
  177. {
  178. BOOL bStatus = TRUE;
  179. CString sCountryDesc;
  180. CString sCountryCode;
  181. switch (uMsg)
  182. {
  183. case WM_INITDIALOG:
  184. SendDlgItemMessage (hwnd , IDC_TXT_COMPANYNAME, EM_SETLIMITTEXT, CA_COMPANY_NAME_LEN,0);
  185. SendDlgItemMessage (hwnd , IDC_TXT_LNAME, EM_SETLIMITTEXT, CA_NAME_LEN,0);
  186. SendDlgItemMessage (hwnd , IDC_TXT_FNAME, EM_SETLIMITTEXT, CA_NAME_LEN,0);
  187. //Populate the values which were read from the Registry during Global Init
  188. SetDlgItemText(hwnd,IDC_TXT_LNAME, GetGlobalContext()->GetContactDataObject()->sContactLName);
  189. SetDlgItemText(hwnd,IDC_TXT_FNAME, GetGlobalContext()->GetContactDataObject()->sContactFName);
  190. SetDlgItemText(hwnd,IDC_TXT_COMPANYNAME, GetGlobalContext()->GetContactDataObject()->sCompanyName);
  191. //Set up the country/region combo box
  192. PopulateCountryComboBox(GetDlgItem(hwnd,IDC_COUNTRY_REGION));
  193. GetCountryDesc(GetGlobalContext()->GetContactDataObject()->sCountryCode,
  194. sCountryDesc.GetBuffer(LR_COUNTRY_DESC_LEN+1));
  195. sCountryDesc.ReleaseBuffer();
  196. ComboBox_SetCurSel(GetDlgItem(hwnd,IDC_COUNTRY_REGION),
  197. ComboBox_FindStringExact(GetDlgItem(hwnd, IDC_COUNTRY_REGION), 0, sCountryDesc));
  198. AddHyperLinkToStaticCtl(hwnd, IDC_PRIVACY);
  199. break;
  200. case WM_DESTROY:
  201. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  202. break;
  203. case WM_NOTIFY:
  204. {
  205. LPNMHDR pnmh = (LPNMHDR)lParam;
  206. switch( pnmh->code )
  207. {
  208. //Trap keystokes/clicks on the hyperlink
  209. case NM_CHAR:
  210. if( ( ( LPNMCHAR )lParam )->ch != VK_SPACE )
  211. break;
  212. // else fall through
  213. case NM_RETURN:
  214. case NM_CLICK:
  215. DisplayPrivacyHelp();
  216. break;
  217. case PSN_SETACTIVE:
  218. {
  219. TCHAR szBuf[ 255];
  220. LoadString(GetInstanceHandle(),IDS_FAXOPTION_LABEL,szBuf,sizeof(szBuf)/sizeof(TCHAR));
  221. SetDlgItemText(hwnd, IDC_LBL_FAX, szBuf);
  222. AddHyperLinkToStaticCtl(hwnd, IDC_PRIVACY);
  223. }
  224. break;
  225. case PSN_APPLY:
  226. {
  227. CString sCompanyName;
  228. CString sLastName;
  229. CString sFirstName;
  230. CString sCountryDesc;
  231. CString sCountryCode;
  232. LPTSTR lpVal = NULL;
  233. long lReturnStatus = PSNRET_NOERROR;
  234. //Read all the fields
  235. lpVal = sCompanyName.GetBuffer(CA_COMPANY_NAME_LEN+1);
  236. GetDlgItemText(hwnd,IDC_TXT_COMPANYNAME,lpVal,CA_COMPANY_NAME_LEN+1);
  237. sCompanyName.ReleaseBuffer(-1);
  238. lpVal = sLastName.GetBuffer(CA_NAME_LEN+1);
  239. GetDlgItemText(hwnd,IDC_TXT_LNAME,lpVal,CA_NAME_LEN+1);
  240. sLastName.ReleaseBuffer(-1);
  241. lpVal = sFirstName.GetBuffer(CA_NAME_LEN+1);
  242. GetDlgItemText(hwnd,IDC_TXT_FNAME,lpVal,CA_NAME_LEN+1);
  243. sFirstName.ReleaseBuffer(-1);
  244. int nCurSel = -1;
  245. nCurSel = ComboBox_GetCurSel(GetDlgItem(hwnd,IDC_COUNTRY_REGION));
  246. lpVal = sCountryDesc.GetBuffer(LR_COUNTRY_DESC_LEN+1);
  247. ComboBox_GetLBText(GetDlgItem(hwnd, IDC_COUNTRY_REGION), nCurSel, lpVal);
  248. sCountryDesc.ReleaseBuffer(-1);
  249. sFirstName.TrimLeft(); sFirstName.TrimRight();
  250. sLastName.TrimLeft(); sLastName.TrimRight();
  251. sCompanyName.TrimLeft(); sCompanyName.TrimRight();
  252. sCountryDesc.TrimLeft();sCountryDesc.TrimRight();
  253. if(sLastName.IsEmpty() || sFirstName.IsEmpty() || sCompanyName.IsEmpty())
  254. {
  255. LRMessageBox(hwnd,IDS_ERR_FIELD_EMPTY);
  256. lReturnStatus = PSNRET_INVALID_NOCHANGEPAGE;
  257. goto done;
  258. }
  259. // Check for the Invalid Characters
  260. if( !ValidateLRString(sFirstName) ||
  261. !ValidateLRString(sLastName) ||
  262. !ValidateLRString(sCountryDesc)
  263. )
  264. {
  265. LRMessageBox(hwnd,IDS_ERR_INVALID_CHAR);
  266. lReturnStatus = PSNRET_INVALID_NOCHANGEPAGE;
  267. goto done;
  268. }
  269. //Check for unselected country/region
  270. if(sCountryDesc.IsEmpty())
  271. {
  272. LRMessageBox(hwnd,IDS_ERR_FIELD_EMPTY);
  273. lReturnStatus = PSNRET_INVALID_NOCHANGEPAGE;
  274. goto done;
  275. }
  276. //Get the country code assicated with the selected country
  277. lpVal = sCountryCode.GetBuffer(LR_COUNTRY_CODE_LEN+1);
  278. if (sCountryDesc.IsEmpty())
  279. lstrcpy(lpVal, _TEXT(""));
  280. else
  281. GetCountryCode(sCountryDesc,lpVal);
  282. sCountryCode.ReleaseBuffer(-1);
  283. // Put into regsitery
  284. GetGlobalContext()->SetInRegistry(szOID_COMMON_NAME, sFirstName);
  285. GetGlobalContext()->SetInRegistry(szOID_SUR_NAME, sLastName);
  286. GetGlobalContext()->SetInRegistry(szOID_ORGANIZATION_NAME, sCompanyName);
  287. GetGlobalContext()->SetInRegistry(szOID_COUNTRY_NAME, sCountryDesc);
  288. GetGlobalContext()->SetInRegistry(szOID_DESCRIPTION, sCountryCode);
  289. done:
  290. if(lReturnStatus != PSNRET_NOERROR)
  291. PropSheet_SetCurSel(GetParent(hwnd),NULL,PG_NDX_PROP_CUSTINFO_a);
  292. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, lReturnStatus);
  293. }
  294. break;
  295. default:
  296. bStatus = FALSE;
  297. break;
  298. }
  299. }
  300. break;
  301. default:
  302. bStatus = FALSE;
  303. break;
  304. }
  305. return bStatus;
  306. }
  307. LRW_DLG_INT CALLBACK
  308. PropCustInfoBDlgProc(
  309. IN HWND hwnd,
  310. IN UINT uMsg,
  311. IN WPARAM wParam,
  312. IN LPARAM lParam
  313. )
  314. {
  315. BOOL bStatus = TRUE;
  316. switch (uMsg)
  317. {
  318. case WM_INITDIALOG:
  319. SendDlgItemMessage (hwnd , IDC_TXT_EMAIL, EM_SETLIMITTEXT, CA_EMAIL_LEN,0);
  320. SendDlgItemMessage (hwnd , IDC_TXT_ADDRESS1, EM_SETLIMITTEXT, CA_ADDRESS_LEN,0);
  321. SendDlgItemMessage (hwnd , IDC_TXT_CITY, EM_SETLIMITTEXT, CA_CITY_LEN,0);
  322. SendDlgItemMessage (hwnd , IDC_TXT_STATE, EM_SETLIMITTEXT, CA_STATE_LEN,0);
  323. SendDlgItemMessage (hwnd , IDC_TXT_ZIP, EM_SETLIMITTEXT, CA_ZIP_LEN,0);
  324. SendDlgItemMessage (hwnd , IDC_COMPANY_DIV, EM_SETLIMITTEXT, CA_ORG_UNIT_LEN,0);
  325. //Populate the values which were read from the Registry during Global Init
  326. SetDlgItemText(hwnd,IDC_TXT_EMAIL, GetGlobalContext()->GetContactDataObject()->sContactEmail);
  327. SetDlgItemText(hwnd,IDC_TXT_ADDRESS1, GetGlobalContext()->GetContactDataObject()->sContactAddress);
  328. SetDlgItemText(hwnd,IDC_TXT_CITY , GetGlobalContext()->GetContactDataObject()->sCity);
  329. SetDlgItemText(hwnd,IDC_TXT_STATE , GetGlobalContext()->GetContactDataObject()->sState);
  330. SetDlgItemText(hwnd,IDC_TXT_ZIP , GetGlobalContext()->GetContactDataObject()->sZip);
  331. SetDlgItemText(hwnd,IDC_COMPANY_DIV , GetGlobalContext()->GetContactDataObject()->sOrgUnit);
  332. AddHyperLinkToStaticCtl(hwnd, IDC_PRIVACY);
  333. break;
  334. case WM_DESTROY:
  335. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  336. break;
  337. case WM_NOTIFY:
  338. {
  339. LPNMHDR pnmh = (LPNMHDR)lParam;
  340. switch( pnmh->code )
  341. {
  342. //Trap keystokes/clicks on the hyperlink
  343. case NM_CHAR:
  344. if( ( ( LPNMCHAR )lParam )->ch != VK_SPACE )
  345. break;
  346. // else fall through
  347. case NM_RETURN:
  348. case NM_CLICK:
  349. DisplayPrivacyHelp();
  350. break;
  351. case PSN_SETACTIVE:
  352. TCHAR szBuf[ 255];
  353. AddHyperLinkToStaticCtl(hwnd, IDC_PRIVACY);
  354. break;
  355. case PSN_APPLY:
  356. {
  357. LPTSTR lpVal = NULL;
  358. CString sAddress1;
  359. CString sCity;
  360. CString sState;
  361. CString sZip;
  362. CString sOrgUnit;
  363. CString sEmail;
  364. int nCurSel = -1;
  365. long lReturnStatus = PSNRET_NOERROR;
  366. //Read all the fields
  367. lpVal = sEmail.GetBuffer(CA_EMAIL_LEN+1);
  368. GetDlgItemText(hwnd,IDC_TXT_EMAIL,lpVal,CA_EMAIL_LEN+1);
  369. sEmail.ReleaseBuffer(-1);
  370. lpVal = sAddress1.GetBuffer(CA_ADDRESS_LEN+1);
  371. GetDlgItemText(hwnd,IDC_TXT_ADDRESS1,lpVal,CA_ADDRESS_LEN+1);
  372. sAddress1.ReleaseBuffer(-1);
  373. lpVal = sCity.GetBuffer(CA_CITY_LEN+1);
  374. GetDlgItemText(hwnd,IDC_TXT_CITY,lpVal,CA_CITY_LEN+1);
  375. sCity.ReleaseBuffer(-1);
  376. lpVal = sState.GetBuffer(CA_STATE_LEN+1);
  377. GetDlgItemText(hwnd,IDC_TXT_STATE,lpVal,CA_STATE_LEN+1);
  378. sState.ReleaseBuffer(-1);
  379. lpVal = sZip.GetBuffer(CA_ZIP_LEN+1);
  380. GetDlgItemText(hwnd,IDC_TXT_ZIP,lpVal,CA_ZIP_LEN+1);
  381. sZip.ReleaseBuffer(-1);
  382. lpVal = sOrgUnit.GetBuffer(CA_ORG_UNIT_LEN+1);
  383. GetDlgItemText(hwnd,IDC_COMPANY_DIV,lpVal,CA_ORG_UNIT_LEN+1);
  384. sOrgUnit.ReleaseBuffer(-1);
  385. sAddress1.TrimLeft(); sAddress1.TrimRight();
  386. sCity.TrimLeft(); sCity.TrimRight();
  387. sState.TrimLeft(); sState.TrimRight();
  388. sZip.TrimLeft(); sZip.TrimRight();
  389. sEmail.TrimLeft(); sEmail.TrimRight();
  390. sOrgUnit.TrimLeft(); sOrgUnit.TrimRight();
  391. if(
  392. !ValidateLRString(sAddress1) ||
  393. !ValidateLRString(sCity) ||
  394. !ValidateLRString(sState) ||
  395. !ValidateLRString(sEmail) ||
  396. !ValidateLRString(sZip) ||
  397. !ValidateLRString(sOrgUnit)
  398. )
  399. {
  400. LRMessageBox(hwnd,IDS_ERR_INVALID_CHAR);
  401. lReturnStatus = PSNRET_INVALID_NOCHANGEPAGE;
  402. goto done;
  403. }
  404. GetGlobalContext()->SetInRegistry(szOID_RSA_emailAddr, (LPCTSTR) sEmail);
  405. GetGlobalContext()->SetInRegistry(szOID_LOCALITY_NAME, sCity);
  406. GetGlobalContext()->SetInRegistry(szOID_STREET_ADDRESS, sAddress1);
  407. GetGlobalContext()->SetInRegistry(szOID_POSTAL_CODE, sZip);
  408. GetGlobalContext()->SetInRegistry(szOID_STATE_OR_PROVINCE_NAME, sState);
  409. GetGlobalContext()->SetInRegistry(szOID_ORGANIZATIONAL_UNIT_NAME, sOrgUnit);
  410. done:
  411. if(lReturnStatus != PSNRET_NOERROR)
  412. PropSheet_SetCurSel(GetParent(hwnd),NULL,PG_NDX_PROP_CUSTINFO_b);
  413. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, lReturnStatus);
  414. }
  415. break;
  416. default:
  417. bStatus = FALSE;
  418. break;
  419. }
  420. }
  421. break;
  422. default:
  423. bStatus = FALSE;
  424. break;
  425. }
  426. return bStatus;
  427. }