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.

738 lines
22 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. #include "precomp.h"
  3. #include "propdlgs.h"
  4. LRW_DLG_INT CALLBACK
  5. PropModeDlgProc(
  6. IN HWND hwnd,
  7. IN UINT uMsg,
  8. IN WPARAM wParam,
  9. IN LPARAM lParam
  10. )
  11. {
  12. DWORD dwRetCode = ERROR_SUCCESS;
  13. BOOL bStatus = TRUE;
  14. switch (uMsg)
  15. {
  16. case WM_INITDIALOG:
  17. {
  18. TCHAR lpBuffer[ 512];
  19. LVFINDINFO lvFindInfo;
  20. int nItem = 0;
  21. HWND hWndComboBox = GetDlgItem(hwnd,IDC_COMBO_MODE);
  22. HWND hWndListBox = GetDlgItem(hwnd, IDC_COUNTRYREGION );
  23. {
  24. LV_COLUMN lvColumn;
  25. TCHAR lpszHeader[ 128];
  26. lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  27. lvColumn.fmt = LVCFMT_LEFT;
  28. lvColumn.cx = 250;
  29. LoadString(GetInstanceHandle(), IDS_COUNTRYREGION_HEADER, lpszHeader, sizeof(lpszHeader)/sizeof(TCHAR));
  30. lvColumn.pszText = lpszHeader;
  31. ListView_InsertColumn(hWndListBox, 0, &lvColumn);
  32. lvColumn.pszText = _TEXT("");
  33. lvColumn.cx = 0;
  34. ListView_InsertColumn(hWndListBox, 1, &lvColumn);
  35. }
  36. memset(lpBuffer,0,sizeof(lpBuffer));
  37. dwRetCode = LoadString(GetInstanceHandle(), IDS_INTERNETMODE, lpBuffer, 512);
  38. ComboBox_AddString(hWndComboBox,lpBuffer);
  39. memset(lpBuffer,0,sizeof(lpBuffer));
  40. dwRetCode = LoadString(GetInstanceHandle(), IDS_WWWMODE, lpBuffer, 512);
  41. ComboBox_AddString(hWndComboBox,lpBuffer);
  42. memset(lpBuffer,0,sizeof(lpBuffer));
  43. dwRetCode = LoadString(GetInstanceHandle(), IDS_TELEPHONEMODE, lpBuffer, 512);
  44. ComboBox_AddString(hWndComboBox,lpBuffer);
  45. //
  46. // Set the Current Activation Method
  47. //
  48. GetGlobalContext()->SetLSProp_ActivationMethod(GetGlobalContext()->GetActivationMethod());
  49. ListView_DeleteAllItems(GetDlgItem(hwnd, IDC_COUNTRYREGION));
  50. if(GetGlobalContext()->GetActivationMethod() == CONNECTION_INTERNET ||
  51. GetGlobalContext()->GetActivationMethod() == CONNECTION_DEFAULT)
  52. {
  53. ComboBox_SetCurSel(hWndComboBox, 0);
  54. EnableWindow(GetDlgItem(hwnd,IDC_LBL_COUNTRYREGION),FALSE);
  55. EnableWindow(GetDlgItem(hwnd, IDC_COUNTRYREGION),FALSE);
  56. }
  57. if(GetGlobalContext()->GetActivationMethod() == CONNECTION_WWW )
  58. {
  59. ComboBox_SetCurSel(hWndComboBox, 1);
  60. EnableWindow(GetDlgItem(hwnd,IDC_LBL_COUNTRYREGION),FALSE);
  61. EnableWindow(GetDlgItem(hwnd, IDC_COUNTRYREGION),FALSE);
  62. }
  63. if(GetGlobalContext()->GetActivationMethod() == CONNECTION_PHONE )
  64. {
  65. ComboBox_SetCurSel(hWndComboBox, 2);
  66. EnableWindow(GetDlgItem(hwnd,IDC_LBL_COUNTRYREGION),TRUE);
  67. EnableWindow(hWndListBox,TRUE);
  68. dwRetCode = PopulateCountryRegionComboBox(hWndListBox);
  69. if (dwRetCode != ERROR_SUCCESS)
  70. {
  71. LRMessageBox(hwnd, dwRetCode, LRGetLastError());
  72. }
  73. memset(&lvFindInfo,0,sizeof(lvFindInfo));
  74. lvFindInfo.flags = LVFI_STRING;
  75. lvFindInfo.psz = GetGlobalContext()->GetContactDataObject()->sCSRPhoneRegion;
  76. nItem = ListView_FindItem(hWndListBox,-1,&lvFindInfo);
  77. ListView_SetItemState(hWndListBox,nItem,LVIS_SELECTED,LVIS_SELECTED);
  78. ListView_SetSelectionMark(hWndListBox,nItem);
  79. ListView_SetSelectionMark(hWndListBox,nItem);
  80. }
  81. }
  82. break;
  83. case WM_COMMAND:
  84. if(HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_COMBO_MODE)
  85. {
  86. LVFINDINFO lvFindInfo;
  87. int nItem = 0;
  88. HWND hWndListBox = GetDlgItem(hwnd, IDC_COUNTRYREGION );
  89. HWND hWndComboBox = GetDlgItem(hwnd,IDC_COMBO_MODE);
  90. SetReFresh(1);
  91. dwRetCode = ComboBox_GetCurSel((HWND)lParam);
  92. ListView_DeleteAllItems(hWndListBox);
  93. //Enable Country/Region List Box in case of Telephone
  94. if(dwRetCode == 2)
  95. {
  96. EnableWindow(GetDlgItem(hwnd,IDC_LBL_COUNTRYREGION),TRUE);
  97. EnableWindow(hWndListBox,TRUE);
  98. GetGlobalContext()->SetLSProp_ActivationMethod(CONNECTION_PHONE);
  99. dwRetCode = PopulateCountryRegionComboBox(hWndListBox);
  100. if (dwRetCode != ERROR_SUCCESS)
  101. {
  102. LRMessageBox(hwnd, dwRetCode, LRGetLastError());
  103. }
  104. memset(&lvFindInfo,0,sizeof(lvFindInfo));
  105. lvFindInfo.flags = LVFI_STRING;
  106. lvFindInfo.psz = GetGlobalContext()->GetContactDataObject()->sCSRPhoneRegion;
  107. nItem = ListView_FindItem(hWndListBox,-1,&lvFindInfo);
  108. ListView_SetItemState(hWndListBox,nItem,LVIS_SELECTED,LVIS_SELECTED);
  109. ListView_SetSelectionMark(hWndListBox,nItem);
  110. ListView_SetSelectionMark(hWndListBox,nItem);
  111. }
  112. else
  113. {
  114. if(dwRetCode == 0) // Internet
  115. {
  116. GetGlobalContext()->SetLSProp_ActivationMethod(CONNECTION_INTERNET);
  117. }
  118. else
  119. {
  120. GetGlobalContext()->SetLSProp_ActivationMethod(CONNECTION_WWW);
  121. }
  122. EnableWindow(GetDlgItem(hwnd,IDC_LBL_COUNTRYREGION),FALSE);
  123. EnableWindow(hWndListBox,FALSE);
  124. }
  125. }
  126. break;
  127. case WM_DESTROY:
  128. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  129. break;
  130. case WM_NOTIFY:
  131. {
  132. LPNMHDR pnmh = (LPNMHDR)lParam;
  133. switch( pnmh->code )
  134. {
  135. case PSN_SETACTIVE:
  136. break;
  137. case PSN_APPLY:
  138. {
  139. HWND hWndComboBox = GetDlgItem(hwnd,IDC_COMBO_MODE);
  140. HWND hWndListBox = GetDlgItem(hwnd, IDC_COUNTRYREGION );
  141. long lReturnStatus = PSNRET_NOERROR;
  142. TCHAR szItemText[255];
  143. int nItem = 0;
  144. dwRetCode = ComboBox_GetCurSel(hWndComboBox);
  145. assert(dwRetCode >= 0 && dwRetCode <= 2);
  146. //Internet
  147. if(dwRetCode == 0)
  148. {
  149. GetGlobalContext()->SetActivationMethod(CONNECTION_INTERNET);
  150. }
  151. // WWW
  152. if(dwRetCode == 1)
  153. {
  154. GetGlobalContext()->SetActivationMethod(CONNECTION_WWW);
  155. }
  156. // Phone
  157. if(dwRetCode == 2)
  158. {
  159. TCHAR lpVal[ 128];
  160. GetGlobalContext()->SetActivationMethod(CONNECTION_PHONE);
  161. nItem = ListView_GetSelectionMark(hWndListBox);
  162. if(nItem == -1)
  163. {
  164. LRMessageBox(hwnd, IDS_ERR_NOCOUNTRYSELECTED, 0);
  165. lReturnStatus = PSNRET_INVALID_NOCHANGEPAGE;
  166. goto done;
  167. }
  168. ListView_GetItemText(hWndListBox,nItem,0,szItemText,sizeof(szItemText)/sizeof(TCHAR));
  169. GetGlobalContext()->SetInRegistery(REG_LRWIZ_CSPHONEREGION,szItemText);
  170. LVITEM lvItem;
  171. lvItem.mask = LVIF_TEXT;
  172. lvItem.iItem = nItem;
  173. lvItem.iSubItem = 1;
  174. lvItem.pszText = lpVal;
  175. lvItem.cchTextMax = 128;
  176. ListView_GetItem(hWndListBox, &lvItem);
  177. GetGlobalContext()->SetCSRNumber(lpVal);
  178. }
  179. done:
  180. if(lReturnStatus != PSNRET_NOERROR)
  181. PropSheet_SetCurSel(GetParent(hwnd),NULL,PG_NDX_PROP_MODE);
  182. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, lReturnStatus);
  183. }
  184. break;
  185. default:
  186. bStatus = FALSE;
  187. break;
  188. }
  189. }
  190. break;
  191. default:
  192. bStatus = FALSE;
  193. break;
  194. }
  195. return bStatus;
  196. }
  197. LRW_DLG_INT CALLBACK
  198. PropProgramDlgProc(
  199. IN HWND hwnd,
  200. IN UINT uMsg,
  201. IN WPARAM wParam,
  202. IN LPARAM lParam
  203. )
  204. {
  205. BOOL bStatus = TRUE;
  206. static BOOL bIsFirstTime = TRUE ; //Ignore the first click in the radio buttons (solve Bug #439)
  207. static int iSelectedOption = IDC_RD_REG_SELECT;
  208. switch (uMsg)
  209. {
  210. case WM_INITDIALOG:
  211. {
  212. TCHAR szBuffer[ 1024];
  213. bIsFirstTime = TRUE ;
  214. if(GetGlobalContext()->GetContactDataObject()->sProgramName == PROGRAM_SELECT)
  215. {
  216. SendDlgItemMessage(hwnd,IDC_RD_REG_SELECT,BM_SETCHECK,(WPARAM)BST_CHECKED,(LPARAM)0);
  217. LoadString(GetInstanceHandle(), IDS_SELECT_DESCRIPTION,
  218. szBuffer, sizeof(szBuffer)/sizeof(TCHAR));
  219. SendDlgItemMessage(hwnd, IDC_DESCRIPTION,
  220. WM_SETTEXT,(WPARAM)0,
  221. (LPARAM)(LPCTSTR)szBuffer);
  222. SetFocus(GetDlgItem(hwnd, IDC_RD_REG_SELECT));
  223. iSelectedOption = IDC_RD_REG_SELECT;
  224. }
  225. else if(GetGlobalContext()->GetContactDataObject()->sProgramName == PROGRAM_MOLP)
  226. {
  227. SendDlgItemMessage(hwnd,IDC_RD_REG_MOLP,BM_SETCHECK,(WPARAM)BST_CHECKED,(LPARAM)0);
  228. LoadString(GetInstanceHandle(), IDS_OPEN_DESCRIPTION,
  229. szBuffer, sizeof(szBuffer)/sizeof(TCHAR));
  230. SendDlgItemMessage(hwnd, IDC_DESCRIPTION,
  231. WM_SETTEXT,(WPARAM)0,
  232. (LPARAM)(LPCTSTR)szBuffer);
  233. SetFocus(GetDlgItem(hwnd, IDC_RD_REG_MOLP));
  234. iSelectedOption = IDC_RD_REG_MOLP;
  235. }
  236. else if(GetGlobalContext()->GetContactDataObject()->sProgramName == PROGRAM_RETAIL)
  237. {
  238. SendDlgItemMessage(hwnd,IDC_RD_REG_OTHER,BM_SETCHECK,(WPARAM)BST_CHECKED,(LPARAM)0);
  239. LoadString(GetInstanceHandle(), IDS_OTHER_DESCRIPTION,
  240. szBuffer, sizeof(szBuffer)/sizeof(TCHAR));
  241. SendDlgItemMessage(hwnd, IDC_DESCRIPTION,
  242. WM_SETTEXT,(WPARAM)0,
  243. (LPARAM)(LPCTSTR)szBuffer);
  244. SetFocus(GetDlgItem(hwnd, IDC_RD_REG_OTHER));
  245. iSelectedOption = IDC_RD_REG_OTHER;
  246. }
  247. else //By default Check the first RADIO button.
  248. {
  249. SendDlgItemMessage(hwnd,IDC_RD_REG_SELECT,BM_SETCHECK,(WPARAM)BST_CHECKED,(LPARAM)0);
  250. LoadString(GetInstanceHandle(), IDS_SELECT_DESCRIPTION,
  251. szBuffer, sizeof(szBuffer)/sizeof(TCHAR));
  252. SendDlgItemMessage(hwnd, IDC_DESCRIPTION,
  253. WM_SETTEXT,(WPARAM)0,
  254. (LPARAM)(LPCTSTR)szBuffer);
  255. SetFocus(GetDlgItem(hwnd, IDC_RD_REG_SELECT));
  256. iSelectedOption = IDC_RD_REG_SELECT;
  257. }
  258. }
  259. break;
  260. case WM_DESTROY:
  261. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  262. break;
  263. case WM_COMMAND:
  264. if (HIWORD(wParam) == BN_CLICKED)
  265. {
  266. TCHAR szBuffer[ 1024];
  267. switch ( LOWORD(wParam) ) //from which control
  268. {
  269. case IDC_RD_REG_SELECT:
  270. if (bIsFirstTime == TRUE){ //Ignore the first click (solve Bug #439)
  271. SetFocus(GetDlgItem(hwnd, iSelectedOption));
  272. }
  273. else
  274. {
  275. LoadString(GetInstanceHandle(), IDS_SELECT_DESCRIPTION, szBuffer, sizeof(szBuffer)/sizeof(TCHAR));
  276. SendDlgItemMessage(hwnd, IDC_DESCRIPTION, WM_SETTEXT,(WPARAM)0, (LPARAM)(LPCTSTR)szBuffer);
  277. }
  278. break;
  279. case IDC_RD_REG_MOLP:
  280. LoadString(GetInstanceHandle(), IDS_OPEN_DESCRIPTION, szBuffer, sizeof(szBuffer)/sizeof(TCHAR));
  281. SendDlgItemMessage(hwnd, IDC_DESCRIPTION, WM_SETTEXT,(WPARAM)0, (LPARAM)(LPCTSTR)szBuffer);
  282. break;
  283. case IDC_RD_REG_OTHER:
  284. LoadString(GetInstanceHandle(), IDS_OTHER_DESCRIPTION, szBuffer, sizeof(szBuffer)/sizeof(TCHAR));
  285. SendDlgItemMessage(hwnd, IDC_DESCRIPTION, WM_SETTEXT,(WPARAM)0, (LPARAM)(LPCTSTR)szBuffer);
  286. break;
  287. }
  288. bIsFirstTime = FALSE ;
  289. }
  290. break;
  291. case WM_NOTIFY:
  292. {
  293. LPNMHDR pnmh = (LPNMHDR)lParam;
  294. switch( pnmh->code )
  295. {
  296. case PSN_SETACTIVE:
  297. break;
  298. case PSN_APPLY:
  299. {
  300. if(SendDlgItemMessage(hwnd,IDC_RD_REG_SELECT,BM_GETCHECK,(WPARAM)0,(LPARAM)0) == BST_CHECKED)
  301. {
  302. GetGlobalContext()->SetInRegistery(szOID_BUSINESS_CATEGORY,PROGRAM_SELECT);
  303. //GetGlobalContext()->SetEncodedInRegistry(szOID_BUSINESS_CATEGORY,PROGRAM_SELECT);
  304. }
  305. else if (SendDlgItemMessage(hwnd,IDC_RD_REG_MOLP,BM_GETCHECK,(WPARAM)0,(LPARAM)0) == BST_CHECKED)
  306. {
  307. GetGlobalContext()->SetInRegistery(szOID_BUSINESS_CATEGORY,PROGRAM_MOLP);
  308. }
  309. else
  310. {
  311. GetGlobalContext()->SetInRegistery(szOID_BUSINESS_CATEGORY,PROGRAM_RETAIL);
  312. }
  313. }
  314. break;
  315. default:
  316. bStatus = FALSE;
  317. break;
  318. }
  319. }
  320. break;
  321. default:
  322. bStatus = FALSE;
  323. break;
  324. }
  325. return bStatus;
  326. }
  327. LRW_DLG_INT CALLBACK
  328. PropCustInfoADlgProc(
  329. IN HWND hwnd,
  330. IN UINT uMsg,
  331. IN WPARAM wParam,
  332. IN LPARAM lParam
  333. )
  334. {
  335. BOOL bStatus = TRUE;
  336. switch (uMsg)
  337. {
  338. case WM_INITDIALOG:
  339. SendDlgItemMessage (hwnd , IDC_TXT_COMPANYNAME, EM_SETLIMITTEXT, CA_COMPANY_NAME_LEN,0);
  340. SendDlgItemMessage (hwnd , IDC_TXT_ORGUNIT , EM_SETLIMITTEXT, CA_ORG_UNIT_LEN,0);
  341. SendDlgItemMessage (hwnd , IDC_TXT_LNAME, EM_SETLIMITTEXT, CA_NAME_LEN,0);
  342. SendDlgItemMessage (hwnd , IDC_TXT_FNAME, EM_SETLIMITTEXT, CA_NAME_LEN,0);
  343. SendDlgItemMessage (hwnd , IDC_TXT_PHONE, EM_SETLIMITTEXT, CA_PHONE_LEN,0);
  344. SendDlgItemMessage (hwnd , IDC_TXT_EMAIL, EM_SETLIMITTEXT, CA_EMAIL_LEN,0);
  345. SendDlgItemMessage (hwnd , IDC_TXT_FAX, EM_SETLIMITTEXT, CA_FAX_LEN,0);
  346. //
  347. //Populate the values which were read from the Registry during Global Init
  348. //
  349. //
  350. //Populate the values which were read from the Registry during Global Init
  351. //
  352. SetDlgItemText(hwnd,IDC_TXT_LNAME, GetGlobalContext()->GetContactDataObject()->sContactLName);
  353. SetDlgItemText(hwnd,IDC_TXT_FNAME, GetGlobalContext()->GetContactDataObject()->sContactFName);
  354. SetDlgItemText(hwnd,IDC_TXT_PHONE, GetGlobalContext()->GetContactDataObject()->sContactPhone);
  355. SetDlgItemText(hwnd,IDC_TXT_FAX, GetGlobalContext()->GetContactDataObject()->sContactFax);
  356. SetDlgItemText(hwnd,IDC_TXT_EMAIL, GetGlobalContext()->GetContactDataObject()->sContactEmail);
  357. SetDlgItemText(hwnd,IDC_TXT_COMPANYNAME, GetGlobalContext()->GetContactDataObject()->sCompanyName);
  358. SetDlgItemText(hwnd,IDC_TXT_ORGUNIT, GetGlobalContext()->GetContactDataObject()->sOrgUnit);
  359. break;
  360. case WM_DESTROY:
  361. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  362. break;
  363. case WM_NOTIFY:
  364. {
  365. LPNMHDR pnmh = (LPNMHDR)lParam;
  366. switch( pnmh->code )
  367. {
  368. case PSN_SETACTIVE:
  369. {
  370. TCHAR szBuf[ 255];
  371. LoadString(GetInstanceHandle(),IDS_FAXOPTION_LABEL,szBuf,sizeof(szBuf)/sizeof(TCHAR));
  372. SetDlgItemText(hwnd, IDC_LBL_FAX, szBuf);
  373. if (GetGlobalContext()->GetLSProp_ActivationMethod() == CONNECTION_INTERNET)
  374. {
  375. LoadString(GetInstanceHandle(),IDS_EMAIL_LABEL,szBuf,sizeof(szBuf)/sizeof(TCHAR));
  376. }
  377. else
  378. {
  379. LoadString(GetInstanceHandle(),IDS_EMAILOPTION_LABEL,szBuf,sizeof(szBuf)/sizeof(TCHAR));
  380. }
  381. SetDlgItemText(hwnd, IDC_LBL_EMAIL, szBuf);
  382. }
  383. break;
  384. case PSN_APPLY:
  385. {
  386. CString sCompanyName;
  387. CString sOrgUnit;
  388. CString sLastName;
  389. CString sFirstName;
  390. CString sPhone;
  391. CString sFax;
  392. CString sEmail;
  393. LPTSTR lpVal = NULL;
  394. long lReturnStatus = PSNRET_NOERROR;
  395. //Read all the fields
  396. lpVal = sCompanyName.GetBuffer(CA_COMPANY_NAME_LEN+1);
  397. GetDlgItemText(hwnd,IDC_TXT_COMPANYNAME,lpVal,CA_COMPANY_NAME_LEN+1);
  398. sCompanyName.ReleaseBuffer(-1);
  399. lpVal = sOrgUnit.GetBuffer(CA_ORG_UNIT_LEN+1);
  400. GetDlgItemText(hwnd,IDC_TXT_ORGUNIT,lpVal,CA_ORG_UNIT_LEN+1);
  401. sOrgUnit.ReleaseBuffer(-1);
  402. lpVal = sLastName.GetBuffer(CA_NAME_LEN+1);
  403. GetDlgItemText(hwnd,IDC_TXT_LNAME,lpVal,CA_NAME_LEN+1);
  404. sLastName.ReleaseBuffer(-1);
  405. lpVal = sFirstName.GetBuffer(CA_NAME_LEN+1);
  406. GetDlgItemText(hwnd,IDC_TXT_FNAME,lpVal,CA_NAME_LEN+1);
  407. sFirstName.ReleaseBuffer(-1);
  408. lpVal = sPhone.GetBuffer(CA_PHONE_LEN+1);
  409. GetDlgItemText(hwnd,IDC_TXT_PHONE,lpVal,CA_PHONE_LEN+1);
  410. sPhone.ReleaseBuffer(-1);
  411. lpVal = sFax.GetBuffer(CA_FAX_LEN+1);
  412. GetDlgItemText(hwnd,IDC_TXT_FAX,lpVal,CA_FAX_LEN+1);
  413. sFax.ReleaseBuffer(-1);
  414. lpVal = sEmail.GetBuffer(CA_EMAIL_LEN+1);
  415. GetDlgItemText(hwnd,IDC_TXT_EMAIL,lpVal,CA_EMAIL_LEN+1);
  416. sEmail.ReleaseBuffer(-1);
  417. sFirstName.TrimLeft(); sFirstName.TrimRight();
  418. sLastName.TrimLeft(); sLastName.TrimRight();
  419. sPhone.TrimLeft(); sPhone.TrimRight();
  420. sFax.TrimLeft(); sFax.TrimRight();
  421. sEmail.TrimLeft(); sEmail.TrimRight();
  422. sCompanyName.TrimLeft(); sCompanyName.TrimRight();
  423. sOrgUnit.TrimLeft(); sOrgUnit.TrimRight();
  424. if(sLastName.IsEmpty() || sFirstName.IsEmpty() || sCompanyName.IsEmpty() ||
  425. (sEmail.IsEmpty() && GetGlobalContext()->GetLSProp_ActivationMethod() == CONNECTION_INTERNET))
  426. {
  427. LRMessageBox(hwnd,IDS_ERR_FIELD_EMPTY);
  428. lReturnStatus = PSNRET_INVALID_NOCHANGEPAGE;
  429. goto done;
  430. }
  431. //
  432. // Check for the Invalid Characters
  433. //
  434. if( !ValidateLRString(sFirstName) ||
  435. !ValidateLRString(sLastName) ||
  436. !ValidateLRString(sPhone) ||
  437. !ValidateLRString(sEmail) ||
  438. !ValidateLRString(sFax)
  439. )
  440. {
  441. LRMessageBox(hwnd,IDS_ERR_INVALID_CHAR);
  442. lReturnStatus = PSNRET_INVALID_NOCHANGEPAGE;
  443. goto done;
  444. }
  445. //
  446. // Validate email address if not empty
  447. //
  448. if(!sEmail.IsEmpty())
  449. {
  450. if(!ValidateEmailId(sEmail))
  451. {
  452. LRMessageBox(hwnd,IDS_ERR_INVALID_EMAIL);
  453. lReturnStatus = PSNRET_INVALID_NOCHANGEPAGE;
  454. goto done;
  455. }
  456. }
  457. // Put into regsitery too
  458. GetGlobalContext()->SetInRegistery(szOID_RSA_emailAddr, (LPCTSTR) sEmail);
  459. GetGlobalContext()->SetInRegistery(szOID_COMMON_NAME, sFirstName);
  460. GetGlobalContext()->SetInRegistery(szOID_SUR_NAME, sLastName);
  461. GetGlobalContext()->SetInRegistery(szOID_TELEPHONE_NUMBER, sPhone);
  462. GetGlobalContext()->SetInRegistery(szOID_FACSIMILE_TELEPHONE_NUMBER, sFax);
  463. GetGlobalContext()->SetInRegistery(szOID_ORGANIZATION_NAME, sCompanyName);
  464. GetGlobalContext()->SetInRegistery(szOID_ORGANIZATIONAL_UNIT_NAME, sOrgUnit);
  465. done:
  466. if(lReturnStatus != PSNRET_NOERROR)
  467. PropSheet_SetCurSel(GetParent(hwnd),NULL,PG_NDX_PROP_CUSTINFO_a);
  468. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, lReturnStatus);
  469. }
  470. break;
  471. default:
  472. bStatus = FALSE;
  473. break;
  474. }
  475. }
  476. break;
  477. default:
  478. bStatus = FALSE;
  479. break;
  480. }
  481. return bStatus;
  482. }
  483. LRW_DLG_INT CALLBACK
  484. PropCustInfoBDlgProc(
  485. IN HWND hwnd,
  486. IN UINT uMsg,
  487. IN WPARAM wParam,
  488. IN LPARAM lParam
  489. )
  490. {
  491. BOOL bStatus = TRUE;
  492. CString sCountryDesc;
  493. switch (uMsg)
  494. {
  495. case WM_INITDIALOG:
  496. SendDlgItemMessage (hwnd , IDC_TXT_ADDRESS1, EM_SETLIMITTEXT, CA_ADDRESS_LEN,0);
  497. SendDlgItemMessage (hwnd , IDC_TXT_CITY, EM_SETLIMITTEXT, CA_CITY_LEN,0);
  498. SendDlgItemMessage (hwnd , IDC_TXT_STATE, EM_SETLIMITTEXT, CA_STATE_LEN,0);
  499. SendDlgItemMessage (hwnd , IDC_TXT_ZIP, EM_SETLIMITTEXT, CA_ZIP_LEN,0);
  500. PopulateCountryComboBox(GetDlgItem(hwnd,IDC_COMBO1));
  501. //
  502. //Populate the values which were read from the Registry during Global Init
  503. //
  504. SetDlgItemText(hwnd,IDC_TXT_ADDRESS1, GetGlobalContext()->GetContactDataObject()->sContactAddress);
  505. SetDlgItemText(hwnd,IDC_TXT_CITY , GetGlobalContext()->GetContactDataObject()->sCity);
  506. SetDlgItemText(hwnd,IDC_TXT_STATE , GetGlobalContext()->GetContactDataObject()->sState);
  507. SetDlgItemText(hwnd,IDC_TXT_ZIP , GetGlobalContext()->GetContactDataObject()->sZip);
  508. GetCountryDesc(
  509. GetGlobalContext()->GetContactDataObject()->sCountryCode,
  510. sCountryDesc.GetBuffer(LR_COUNTRY_DESC_LEN+1));
  511. sCountryDesc.ReleaseBuffer();
  512. ComboBox_SetCurSel(
  513. GetDlgItem(hwnd,IDC_COMBO1),
  514. ComboBox_FindStringExact(
  515. GetDlgItem(hwnd,IDC_COMBO1),
  516. 0,
  517. (LPCTSTR)sCountryDesc));
  518. break;
  519. case WM_DESTROY:
  520. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  521. break;
  522. case WM_NOTIFY:
  523. {
  524. LPNMHDR pnmh = (LPNMHDR)lParam;
  525. switch( pnmh->code )
  526. {
  527. case PSN_SETACTIVE:
  528. break;
  529. case PSN_APPLY:
  530. {
  531. LPTSTR lpVal = NULL;
  532. CString sAddress1;
  533. CString sCity;
  534. CString sState;
  535. CString sZip;
  536. CString sCountryDesc;
  537. CString sCountryCode;
  538. int nCurSel = -1;
  539. long lReturnStatus = PSNRET_NOERROR;
  540. //
  541. //Read all the fields
  542. //
  543. lpVal = sAddress1.GetBuffer(CA_ADDRESS_LEN+1);
  544. GetDlgItemText(hwnd,IDC_TXT_ADDRESS1,lpVal,CA_ADDRESS_LEN+1);
  545. sAddress1.ReleaseBuffer(-1);
  546. lpVal = sCity.GetBuffer(CA_CITY_LEN+1);
  547. GetDlgItemText(hwnd,IDC_TXT_CITY,lpVal,CA_CITY_LEN+1);
  548. sCity.ReleaseBuffer(-1);
  549. lpVal = sState.GetBuffer(CA_STATE_LEN+1);
  550. GetDlgItemText(hwnd,IDC_TXT_STATE,lpVal,CA_STATE_LEN+1);
  551. sState.ReleaseBuffer(-1);
  552. lpVal = sZip.GetBuffer(CA_ZIP_LEN+1);
  553. GetDlgItemText(hwnd,IDC_TXT_ZIP,lpVal,CA_ZIP_LEN+1);
  554. sZip.ReleaseBuffer(-1);
  555. nCurSel = ComboBox_GetCurSel(GetDlgItem(hwnd,IDC_COMBO1));
  556. lpVal = sCountryDesc.GetBuffer(LR_COUNTRY_DESC_LEN+1);
  557. ComboBox_GetLBText(GetDlgItem(hwnd,IDC_COMBO1), nCurSel, lpVal);
  558. sCountryDesc.ReleaseBuffer(-1);
  559. sAddress1.TrimLeft(); sAddress1.TrimRight();
  560. sCity.TrimLeft(); sCity.TrimRight();
  561. sState.TrimLeft(); sState.TrimRight();
  562. sZip.TrimLeft(); sZip.TrimRight();
  563. sCountryDesc.TrimLeft();sCountryDesc.TrimRight();
  564. if(
  565. !ValidateLRString(sAddress1) ||
  566. !ValidateLRString(sCity) ||
  567. !ValidateLRString(sState) ||
  568. !ValidateLRString(sZip) ||
  569. !ValidateLRString(sCountryDesc)
  570. )
  571. {
  572. LRMessageBox(hwnd,IDS_ERR_INVALID_CHAR);
  573. lReturnStatus = PSNRET_INVALID_NOCHANGEPAGE;
  574. goto done;
  575. }
  576. if (sCountryDesc.IsEmpty())
  577. {
  578. LRMessageBox(hwnd,IDS_ERR_FIELD_EMPTY);
  579. lReturnStatus = PSNRET_INVALID_NOCHANGEPAGE;
  580. goto done;
  581. }
  582. lpVal = sCountryCode.GetBuffer(LR_COUNTRY_CODE_LEN+1);
  583. GetCountryCode(sCountryDesc,lpVal);
  584. sCountryCode.ReleaseBuffer(-1);
  585. GetGlobalContext()->SetInRegistery(szOID_LOCALITY_NAME, sCity);
  586. GetGlobalContext()->SetInRegistery(szOID_COUNTRY_NAME, sCountryDesc);
  587. GetGlobalContext()->SetInRegistery(szOID_DESCRIPTION, sCountryCode);
  588. GetGlobalContext()->SetInRegistery(szOID_STREET_ADDRESS, sAddress1);
  589. GetGlobalContext()->SetInRegistery(szOID_POSTAL_CODE, sZip);
  590. GetGlobalContext()->SetInRegistery(szOID_STATE_OR_PROVINCE_NAME, sState);
  591. done:
  592. if(lReturnStatus != PSNRET_NOERROR)
  593. PropSheet_SetCurSel(GetParent(hwnd),NULL,PG_NDX_PROP_CUSTINFO_b);
  594. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, lReturnStatus);
  595. }
  596. break;
  597. default:
  598. bStatus = FALSE;
  599. break;
  600. }
  601. }
  602. break;
  603. default:
  604. bStatus = FALSE;
  605. break;
  606. }
  607. return bStatus;
  608. }