Source code of Windows XP (NT5)
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.

499 lines
16 KiB

  1. //Copyright (c) 1998 - 1999 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. PageInfo *pi = (PageInfo *)LRW_GETWINDOWLONG( hwnd, LRW_GWL_USERDATA );
  50. switch (uMsg)
  51. {
  52. case WM_INITDIALOG:
  53. pi = (PageInfo *)((LPPROPSHEETPAGE)lParam)->lParam;
  54. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, (LRW_LONG_PTR)pi );
  55. SendDlgItemMessage (hwnd , IDC_TXT_COMPANYNAME, EM_SETLIMITTEXT, CA_COMPANY_NAME_LEN,0);
  56. SendDlgItemMessage (hwnd , IDC_TXT_ORGUNIT , EM_SETLIMITTEXT, CA_ORG_UNIT_LEN,0);
  57. SendDlgItemMessage (hwnd , IDC_TXT_LNAME, EM_SETLIMITTEXT, CA_NAME_LEN,0);
  58. SendDlgItemMessage (hwnd , IDC_TXT_FNAME, EM_SETLIMITTEXT, CA_NAME_LEN,0);
  59. SendDlgItemMessage (hwnd , IDC_TXT_PHONE, EM_SETLIMITTEXT, CA_PHONE_LEN,0);
  60. SendDlgItemMessage (hwnd , IDC_TXT_FAX, EM_SETLIMITTEXT, CA_FAX_LEN,0);
  61. SendDlgItemMessage (hwnd , IDC_TXT_EMAIL, EM_SETLIMITTEXT, CA_EMAIL_LEN,0);
  62. //
  63. //Populate the values which were read from the Registry during Global Init
  64. //
  65. SetDlgItemText(hwnd,IDC_TXT_LNAME, GetGlobalContext()->GetContactDataObject()->sContactLName);
  66. SetDlgItemText(hwnd,IDC_TXT_FNAME, GetGlobalContext()->GetContactDataObject()->sContactFName);
  67. SetDlgItemText(hwnd,IDC_TXT_PHONE, GetGlobalContext()->GetContactDataObject()->sContactPhone);
  68. SetDlgItemText(hwnd,IDC_TXT_FAX, GetGlobalContext()->GetContactDataObject()->sContactFax);
  69. SetDlgItemText(hwnd,IDC_TXT_EMAIL, GetGlobalContext()->GetContactDataObject()->sContactEmail);
  70. SetDlgItemText(hwnd,IDC_TXT_COMPANYNAME, GetGlobalContext()->GetContactDataObject()->sCompanyName);
  71. SetDlgItemText(hwnd,IDC_TXT_ORGUNIT, GetGlobalContext()->GetContactDataObject()->sOrgUnit);
  72. break;
  73. case WM_DESTROY:
  74. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  75. break;
  76. case WM_NOTIFY:
  77. {
  78. LPNMHDR pnmh = (LPNMHDR)lParam;
  79. switch( pnmh->code )
  80. {
  81. case PSN_SETACTIVE:
  82. {
  83. //TCHAR szEmailLabel[64];
  84. //TCHAR szCapLabel[255];
  85. TCHAR szBuf[ 255];
  86. PropSheet_SetWizButtons( GetParent( hwnd ), PSWIZB_NEXT|PSWIZB_BACK );
  87. LoadString(GetInstanceHandle(),IDS_FAXOPTION_LABEL,szBuf,sizeof(szBuf)/sizeof(TCHAR));
  88. SetDlgItemText(hwnd, IDC_LBL_FAX, szBuf);
  89. if (GetGlobalContext()->GetActivationMethod() == CONNECTION_INTERNET)
  90. {
  91. LoadString(GetInstanceHandle(),IDS_EMAIL_LABEL,szBuf,sizeof(szBuf)/sizeof(TCHAR));
  92. }
  93. else
  94. {
  95. LoadString(GetInstanceHandle(),IDS_EMAILOPTION_LABEL,szBuf,sizeof(szBuf)/sizeof(TCHAR));
  96. }
  97. SetDlgItemText(hwnd, IDC_LBL_EMAIL, szBuf);
  98. /* Email is optional now.
  99. //Change the lable of Caption & Email fields if it's Online Mode
  100. if(GetLRMode() == LRMODE_CH_REQUEST )
  101. {
  102. LoadString(GetInstanceHandle(),IDS_LBL_CONTACT_ONLINE,szCapLabel,255);
  103. SetDlgItemText(hwnd,IDC_LBL_CAPTION,szCapLabel);
  104. LoadString(GetInstanceHandle(),IDS_LBL_EMAIL_ONLINE,szEmailLabel,64);
  105. SetDlgItemText(hwnd,IDC_LBL_EMAIL,szEmailLabel);
  106. }
  107. else
  108. {
  109. LoadString(GetInstanceHandle(),IDS_LBL_CONTACT_OFFLINE,szCapLabel,255);
  110. SetDlgItemText(hwnd,IDC_LBL_CAPTION,szCapLabel);
  111. LoadString(GetInstanceHandle(),IDS_LBL_EMAIL_OFFLINE,szEmailLabel,64);
  112. SetDlgItemText(hwnd,IDC_LBL_EMAIL,szEmailLabel);
  113. }
  114. */
  115. }
  116. break;
  117. case PSN_WIZNEXT:
  118. {
  119. CString sCompanyName;
  120. CString sOrgUnit;
  121. CString sLastName;
  122. CString sFirstName;
  123. CString sPhone;
  124. CString sFax;
  125. CString sEmail;
  126. LPTSTR lpVal = NULL;
  127. //Read all the fields
  128. lpVal = sCompanyName.GetBuffer(CA_COMPANY_NAME_LEN+1);
  129. GetDlgItemText(hwnd,IDC_TXT_COMPANYNAME,lpVal,CA_COMPANY_NAME_LEN+1);
  130. sCompanyName.ReleaseBuffer(-1);
  131. lpVal = sOrgUnit.GetBuffer(CA_ORG_UNIT_LEN+1);
  132. GetDlgItemText(hwnd,IDC_TXT_ORGUNIT,lpVal,CA_ORG_UNIT_LEN+1);
  133. sOrgUnit.ReleaseBuffer(-1);
  134. lpVal = sLastName.GetBuffer(CA_NAME_LEN+1);
  135. GetDlgItemText(hwnd,IDC_TXT_LNAME,lpVal,CA_NAME_LEN+1);
  136. sLastName.ReleaseBuffer(-1);
  137. lpVal = sFirstName.GetBuffer(CA_NAME_LEN+1);
  138. GetDlgItemText(hwnd,IDC_TXT_FNAME,lpVal,CA_NAME_LEN+1);
  139. sFirstName.ReleaseBuffer(-1);
  140. lpVal = sPhone.GetBuffer(CA_PHONE_LEN+1);
  141. GetDlgItemText(hwnd,IDC_TXT_PHONE,lpVal,CA_PHONE_LEN+1);
  142. sPhone.ReleaseBuffer(-1);
  143. lpVal = sFax.GetBuffer(CA_FAX_LEN+1);
  144. GetDlgItemText(hwnd,IDC_TXT_FAX,lpVal,CA_FAX_LEN+1);
  145. sFax.ReleaseBuffer(-1);
  146. lpVal = sEmail.GetBuffer(CA_EMAIL_LEN+1);
  147. GetDlgItemText(hwnd,IDC_TXT_EMAIL,lpVal,CA_EMAIL_LEN+1);
  148. sEmail.ReleaseBuffer(-1);
  149. sFirstName.TrimLeft(); sFirstName.TrimRight();
  150. sLastName.TrimLeft(); sLastName.TrimRight();
  151. sPhone.TrimLeft(); sPhone.TrimRight();
  152. sFax.TrimLeft(); sFax.TrimRight();
  153. sEmail.TrimLeft(); sEmail.TrimRight();
  154. sCompanyName.TrimLeft(); sCompanyName.TrimRight();
  155. sOrgUnit.TrimLeft(); sOrgUnit.TrimRight();
  156. if(sLastName.IsEmpty() || sFirstName.IsEmpty() || sCompanyName.IsEmpty() ||
  157. (sEmail.IsEmpty() && GetGlobalContext()->GetActivationMethod() == CONNECTION_INTERNET))
  158. {
  159. LRMessageBox(hwnd,IDS_ERR_FIELD_EMPTY);
  160. dwNextPage = IDD_CONTACTINFO1;
  161. goto NextDone;
  162. }
  163. //
  164. // Check for the Invalid Characters
  165. //
  166. if( !ValidateLRString(sFirstName) ||
  167. !ValidateLRString(sLastName) ||
  168. !ValidateLRString(sPhone) ||
  169. !ValidateLRString(sEmail)
  170. )
  171. {
  172. LRMessageBox(hwnd,IDS_ERR_INVALID_CHAR);
  173. dwNextPage = IDD_CONTACTINFO1;
  174. goto NextDone;
  175. }
  176. dwNextPage = IDD_CONTACTINFO2;
  177. //
  178. // Validate email address if not empty
  179. //
  180. if(!sEmail.IsEmpty())
  181. {
  182. if(!ValidateEmailId(sEmail))
  183. {
  184. LRMessageBox(hwnd,IDS_ERR_INVALID_EMAIL);
  185. dwNextPage = IDD_CONTACTINFO1;
  186. goto NextDone;
  187. }
  188. if (GetGlobalContext()->GetActivationMethod() == CONNECTION_INTERNET)
  189. {
  190. //Show dialog box to confirm the e-mail alias put in the dialog box
  191. if ( DialogBox ( GetInstanceHandle(),
  192. MAKEINTRESOURCE(IDD_CONFIRM_EMAIL),
  193. hwnd,
  194. ConfirmEMailDlgProc ) == IDOK )
  195. {
  196. //Check to see if e-mail aliases match
  197. //if they match - proceed else stay right here
  198. if ( GetGlobalContext()->GetContactDataObject()->sEmailAddressConf.CompareNoCase(sEmail) != 0)
  199. {
  200. LRMessageBox(hwnd,IDS_EMAIL_MISMATCH);
  201. dwNextPage = IDD_CONTACTINFO1;
  202. goto NextDone;
  203. }
  204. }
  205. else
  206. {
  207. //user hit cancel. So stay right where you are.
  208. LRMessageBox(hwnd,IDS_EMAIL_MISMATCH);
  209. dwNextPage = IDD_CONTACTINFO1;
  210. goto NextDone;
  211. }
  212. }
  213. }
  214. //
  215. //Finally update CHData object
  216. //
  217. GetGlobalContext()->GetContactDataObject()->sContactEmail = sEmail;
  218. GetGlobalContext()->GetContactDataObject()->sContactFName = sFirstName;
  219. GetGlobalContext()->GetContactDataObject()->sContactLName = sLastName;
  220. GetGlobalContext()->GetContactDataObject()->sContactPhone = sPhone;
  221. GetGlobalContext()->GetContactDataObject()->sContactFax = sFax;
  222. GetGlobalContext()->GetContactDataObject()->sCompanyName = sCompanyName;
  223. GetGlobalContext()->GetContactDataObject()->sOrgUnit = sOrgUnit;
  224. // Put into regsitery too
  225. GetGlobalContext()->SetInRegistery(szOID_RSA_emailAddr, (LPCTSTR) sEmail);
  226. GetGlobalContext()->SetInRegistery(szOID_COMMON_NAME, sFirstName);
  227. GetGlobalContext()->SetInRegistery(szOID_SUR_NAME, sLastName);
  228. GetGlobalContext()->SetInRegistery(szOID_TELEPHONE_NUMBER, sPhone);
  229. GetGlobalContext()->SetInRegistery(szOID_FACSIMILE_TELEPHONE_NUMBER, sFax);
  230. GetGlobalContext()->SetInRegistery(szOID_ORGANIZATION_NAME, sCompanyName);
  231. GetGlobalContext()->SetInRegistery(szOID_ORGANIZATIONAL_UNIT_NAME, sOrgUnit);
  232. //If no Error , go to the next page
  233. LRPush(IDD_CONTACTINFO1);
  234. NextDone:
  235. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  236. bStatus = -1;
  237. }
  238. break;
  239. case PSN_WIZBACK:
  240. dwNextPage = LRPop();
  241. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  242. bStatus = -1;
  243. break;
  244. default:
  245. bStatus = FALSE;
  246. break;
  247. }
  248. }
  249. break;
  250. default:
  251. bStatus = FALSE;
  252. break;
  253. }
  254. return bStatus;
  255. }
  256. LRW_DLG_INT CALLBACK
  257. ContactInfo2DlgProc(
  258. IN HWND hwnd,
  259. IN UINT uMsg,
  260. IN WPARAM wParam,
  261. IN LPARAM lParam
  262. )
  263. {
  264. DWORD dwNextPage = 0;
  265. BOOL bStatus = TRUE;
  266. PageInfo *pi = (PageInfo *)LRW_GETWINDOWLONG( hwnd, LRW_GWL_USERDATA );
  267. CString sCountryDesc;
  268. switch (uMsg)
  269. {
  270. case WM_INITDIALOG:
  271. pi = (PageInfo *)((LPPROPSHEETPAGE)lParam)->lParam;
  272. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, (LRW_LONG_PTR)pi );
  273. SendDlgItemMessage (hwnd , IDC_TXT_ADDRESS1, EM_SETLIMITTEXT, CA_ADDRESS_LEN,0);
  274. SendDlgItemMessage (hwnd , IDC_TXT_CITY, EM_SETLIMITTEXT, CA_CITY_LEN,0);
  275. SendDlgItemMessage (hwnd , IDC_TXT_STATE, EM_SETLIMITTEXT, CA_STATE_LEN,0);
  276. SendDlgItemMessage (hwnd , IDC_TXT_ZIP, EM_SETLIMITTEXT, CA_ZIP_LEN,0);
  277. PopulateCountryComboBox(GetDlgItem(hwnd,IDC_COMBO1));
  278. //
  279. //Populate the values which were read from the Registry during Global Init
  280. //
  281. SetDlgItemText(hwnd,IDC_TXT_ADDRESS1, GetGlobalContext()->GetContactDataObject()->sContactAddress);
  282. SetDlgItemText(hwnd,IDC_TXT_CITY , GetGlobalContext()->GetContactDataObject()->sCity);
  283. SetDlgItemText(hwnd,IDC_TXT_STATE , GetGlobalContext()->GetContactDataObject()->sState);
  284. SetDlgItemText(hwnd,IDC_TXT_ZIP , GetGlobalContext()->GetContactDataObject()->sZip);
  285. GetCountryDesc(
  286. GetGlobalContext()->GetContactDataObject()->sCountryCode,
  287. sCountryDesc.GetBuffer(LR_COUNTRY_DESC_LEN+1));
  288. sCountryDesc.ReleaseBuffer();
  289. ComboBox_SetCurSel(
  290. GetDlgItem(hwnd,IDC_COMBO1),
  291. ComboBox_FindStringExact(
  292. GetDlgItem(hwnd,IDC_COMBO1),
  293. 0,
  294. sCountryDesc));
  295. break;
  296. case WM_DESTROY:
  297. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  298. break;
  299. case WM_NOTIFY:
  300. {
  301. LPNMHDR pnmh = (LPNMHDR)lParam;
  302. switch( pnmh->code )
  303. {
  304. case PSN_SETACTIVE:
  305. PropSheet_SetWizButtons( GetParent( hwnd ), PSWIZB_NEXT | PSWIZB_BACK);
  306. break;
  307. case PSN_WIZNEXT:
  308. {
  309. CString sAddress1;
  310. CString sCity;
  311. CString sState;
  312. LPTSTR lpVal = NULL;
  313. CString sZip;
  314. CString sCountryDesc;
  315. CString sCountryCode;
  316. DWORD dwRetCode;
  317. int nCurSel = -1;
  318. //
  319. //Read all the fields
  320. //
  321. lpVal = sAddress1.GetBuffer(CA_ADDRESS_LEN+1);
  322. GetDlgItemText(hwnd,IDC_TXT_ADDRESS1,lpVal,CA_ADDRESS_LEN+1);
  323. sAddress1.ReleaseBuffer(-1);
  324. lpVal = sCity.GetBuffer(CA_CITY_LEN+1);
  325. GetDlgItemText(hwnd,IDC_TXT_CITY,lpVal,CA_CITY_LEN+1);
  326. sCity.ReleaseBuffer(-1);
  327. lpVal = sState.GetBuffer(CA_STATE_LEN+1);
  328. GetDlgItemText(hwnd,IDC_TXT_STATE,lpVal,CA_STATE_LEN+1);
  329. sState.ReleaseBuffer(-1);
  330. lpVal = sZip.GetBuffer(CA_ZIP_LEN+1);
  331. GetDlgItemText(hwnd,IDC_TXT_ZIP,lpVal,CA_ZIP_LEN+1);
  332. sZip.ReleaseBuffer(-1);
  333. nCurSel = ComboBox_GetCurSel(GetDlgItem(hwnd,IDC_COMBO1));
  334. lpVal = sCountryDesc.GetBuffer(LR_COUNTRY_DESC_LEN+1);
  335. ComboBox_GetLBText(GetDlgItem(hwnd,IDC_COMBO1), nCurSel, lpVal);
  336. sCountryDesc.ReleaseBuffer(-1);
  337. sAddress1.TrimLeft(); sAddress1.TrimRight();
  338. sCity.TrimLeft(); sCity.TrimRight();
  339. sState.TrimLeft(); sState.TrimRight();
  340. sZip.TrimLeft(); sZip.TrimRight();
  341. sCountryDesc.TrimLeft();sCountryDesc.TrimRight();
  342. if(sCountryDesc.IsEmpty())
  343. // if(sAddress1.IsEmpty() || sCity.IsEmpty() ||
  344. // sState.IsEmpty() || sZip.IsEmpty() || sCountryDesc.IsEmpty())
  345. {
  346. LRMessageBox(hwnd,IDS_ERR_FIELD_EMPTY);
  347. dwNextPage = IDD_CONTACTINFO2;
  348. goto NextDone;
  349. }
  350. if(
  351. !ValidateLRString(sAddress1) ||
  352. !ValidateLRString(sCity) ||
  353. !ValidateLRString(sState) ||
  354. !ValidateLRString(sZip) ||
  355. !ValidateLRString(sCountryDesc)
  356. )
  357. {
  358. LRMessageBox(hwnd,IDS_ERR_INVALID_CHAR);
  359. dwNextPage = IDD_CONTACTINFO2;
  360. goto NextDone;
  361. }
  362. lpVal = sCountryCode.GetBuffer(LR_COUNTRY_CODE_LEN+1);
  363. if (sCountryDesc.IsEmpty())
  364. {
  365. lstrcpy(lpVal, _TEXT(""));
  366. }
  367. else
  368. {
  369. GetCountryCode(sCountryDesc,lpVal);
  370. }
  371. sCountryCode.ReleaseBuffer(-1);
  372. //
  373. //Finally update CHData object
  374. //
  375. GetGlobalContext()->GetContactDataObject()->sCity = sCity;
  376. GetGlobalContext()->GetContactDataObject()->sCountryDesc = sCountryDesc;
  377. GetGlobalContext()->GetContactDataObject()->sCountryCode = sCountryCode;
  378. GetGlobalContext()->GetContactDataObject()->sContactAddress = sAddress1;
  379. GetGlobalContext()->GetContactDataObject()->sZip = sZip;
  380. GetGlobalContext()->GetContactDataObject()->sState = sState;
  381. GetGlobalContext()->SetInRegistery(szOID_LOCALITY_NAME, sCity);
  382. GetGlobalContext()->SetInRegistery(szOID_COUNTRY_NAME, sCountryDesc);
  383. GetGlobalContext()->SetInRegistery(szOID_DESCRIPTION, sCountryCode);
  384. GetGlobalContext()->SetInRegistery(szOID_STREET_ADDRESS, sAddress1);
  385. GetGlobalContext()->SetInRegistery(szOID_POSTAL_CODE, sZip);
  386. GetGlobalContext()->SetInRegistery(szOID_STATE_OR_PROVINCE_NAME, sState);
  387. dwRetCode = ShowProgressBox(hwnd, ProcessThread, 0, 0, 0);
  388. if (dwRetCode == ERROR_SUCCESS)
  389. {
  390. dwRetCode = LRGetLastRetCode();
  391. }
  392. if (dwRetCode != ERROR_SUCCESS)
  393. {
  394. LRMessageBox(hwnd, dwRetCode);
  395. dwNextPage = IDD_CONTACTINFO2;
  396. }
  397. else
  398. {
  399. GetGlobalContext()->ClearWizStack();
  400. LRPush(IDD_WELCOME);
  401. dwNextPage = IDD_CONTINUEREG;
  402. }
  403. NextDone:
  404. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  405. bStatus = -1;
  406. }
  407. break;
  408. case PSN_WIZBACK:
  409. dwNextPage = LRPop();
  410. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  411. bStatus = -1;
  412. break;
  413. default:
  414. bStatus = FALSE;
  415. break;
  416. }
  417. }
  418. break;
  419. default:
  420. bStatus = FALSE;
  421. break;
  422. }
  423. return bStatus;
  424. }