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.

453 lines
13 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. #include "precomp.h"
  3. #include "utils.h"
  4. #include <assert.h>
  5. extern HINSTANCE g_hInstance;
  6. void MoveCaret(int nID, HWND hwnd ) ;
  7. void SetDeleteKeyStatus(int iValue) ;
  8. LRW_DLG_INT CALLBACK
  9. TelReissueProc(
  10. IN HWND hwnd,
  11. IN UINT uMsg,
  12. IN WPARAM wParam,
  13. IN LPARAM lParam
  14. )
  15. {
  16. DWORD dwNextPage = 0;
  17. BOOL bStatus = TRUE;
  18. PageInfo *pi = (PageInfo *)LRW_GETWINDOWLONG( hwnd, LRW_GWL_USERDATA );
  19. HWND hwndLSID;
  20. TCHAR * cwRegistrationID;
  21. TCHAR awBuffer[ 128];
  22. DWORD dwRetCode;
  23. TCHAR tcUserValue[ CHARS_IN_BATCH*NUMBER_OF_BATCHES + 1];
  24. switch (uMsg)
  25. {
  26. case WM_INITDIALOG:
  27. pi = (PageInfo *)((LPPROPSHEETPAGE)lParam)->lParam;
  28. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, (LRW_LONG_PTR)pi );
  29. // Now set the Limit of the data entry fields
  30. // Now set the Limit of the data entry fields
  31. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO1, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  32. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO2, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  33. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO3, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  34. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO4, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  35. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO5, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  36. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO6, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  37. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO7, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  38. assert(NUMBER_OF_BATCHES == 7);
  39. break;
  40. case WM_SHOWWINDOW:
  41. if (wParam)
  42. {
  43. SetWindowText(GetDlgItem(hwnd, IDC_CSRINFO), GetCSRNumber());
  44. cwRegistrationID = GetGlobalContext()->GetRegistrationID();
  45. hwndLSID = GetDlgItem(hwnd, IDC_MSID);
  46. swprintf(awBuffer, L"%5.5s-%5.5s-%5.5s-%5.5s-%5.5s-%5.5s-%5.5s",
  47. cwRegistrationID, cwRegistrationID + 5, cwRegistrationID + 10,
  48. cwRegistrationID + 15, cwRegistrationID + 20, cwRegistrationID + 25,
  49. cwRegistrationID + 30);
  50. SetWindowText(hwndLSID, awBuffer);
  51. }
  52. break;
  53. case WM_COMMAND:
  54. if (HIWORD(wParam) == EN_CHANGE)
  55. {
  56. MoveCaret(LOWORD(wParam), hwnd ) ;
  57. }
  58. if (HIWORD(wParam) == EN_UPDATE)
  59. {
  60. if (GetKeyState(VK_DELETE) == -128)
  61. SetDeleteKeyStatus(1) ;
  62. else
  63. SetDeleteKeyStatus(0) ;
  64. }
  65. break ;
  66. case WM_DESTROY:
  67. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  68. break;
  69. case WM_NOTIFY:
  70. {
  71. LPNMHDR pnmh = (LPNMHDR)lParam;
  72. switch( pnmh->code )
  73. {
  74. case PSN_SETACTIVE:
  75. PropSheet_SetWizButtons( GetParent( hwnd ), PSWIZB_NEXT | PSWIZB_BACK);
  76. break;
  77. case PSN_WIZNEXT:
  78. {
  79. // Let us get the Information Entered First & concatenate everything into
  80. // One String
  81. GetDlgItemText(hwnd,IDC_TXT_TELEINFO1, tcUserValue, CHARS_IN_BATCH+1);
  82. GetDlgItemText(hwnd,IDC_TXT_TELEINFO2, tcUserValue+1*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  83. GetDlgItemText(hwnd,IDC_TXT_TELEINFO3, tcUserValue+2*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  84. GetDlgItemText(hwnd,IDC_TXT_TELEINFO4, tcUserValue+3*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  85. GetDlgItemText(hwnd,IDC_TXT_TELEINFO5, tcUserValue+4*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  86. GetDlgItemText(hwnd,IDC_TXT_TELEINFO6, tcUserValue+5*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  87. GetDlgItemText(hwnd,IDC_TXT_TELEINFO7, tcUserValue+6*CHARS_IN_BATCH, CHARS_IN_BATCH+1);
  88. // OK, Now we have the Information provided by the user
  89. // Need to validate
  90. if (wcsspn(tcUserValue, BASE24_CHARACTERS) != LR_REGISTRATIONID_LEN)
  91. {
  92. // Extraneous characters in the SPK string
  93. LRMessageBox(hwnd, IDS_ERR_INVALIDLSID, 0);
  94. dwNextPage = IDD_DLG_TELREG_REISSUE;
  95. }
  96. else
  97. {
  98. dwRetCode = SetLSSPK(tcUserValue);
  99. if (dwRetCode != ERROR_SUCCESS)
  100. {
  101. LRMessageBox(hwnd, dwRetCode);
  102. dwNextPage = IDD_DLG_TELREG_REISSUE;
  103. }
  104. else
  105. {
  106. dwRetCode = ShowProgressBox(hwnd, ProcessThread, 0, 0, 0);
  107. dwNextPage = IDD_PROGRESS;
  108. LRPush(IDD_DLG_TELREG_REISSUE);
  109. }
  110. }
  111. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  112. bStatus = -1;
  113. }
  114. break;
  115. case PSN_WIZBACK:
  116. dwNextPage = LRPop();
  117. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  118. bStatus = -1;
  119. break;
  120. default:
  121. bStatus = FALSE;
  122. break;
  123. }
  124. }
  125. break;
  126. default:
  127. bStatus = FALSE;
  128. break;
  129. }
  130. return bStatus;
  131. }
  132. LRW_DLG_INT CALLBACK
  133. ConfRevokeProc(
  134. IN HWND hwnd,
  135. IN UINT uMsg,
  136. IN WPARAM wParam,
  137. IN LPARAM lParam
  138. )
  139. {
  140. DWORD dwNextPage = 0;
  141. BOOL bStatus = TRUE;
  142. PageInfo *pi = (PageInfo *)LRW_GETWINDOWLONG( hwnd, LRW_GWL_USERDATA );
  143. HWND hwndLSID;
  144. TCHAR * cwRegistrationID;
  145. TCHAR awBuffer[ 128];
  146. DWORD dwRetCode;
  147. switch (uMsg)
  148. {
  149. case WM_INITDIALOG:
  150. pi = (PageInfo *)((LPPROPSHEETPAGE)lParam)->lParam;
  151. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, (LRW_LONG_PTR)pi );
  152. SendDlgItemMessage (hwnd, IDC_REVOKE_CONFIRMATION_NUMBER, EM_SETLIMITTEXT,
  153. LR_CONFIRMATION_LEN, 0);
  154. break;
  155. case WM_SHOWWINDOW:
  156. if (wParam)
  157. {
  158. SetWindowText(GetDlgItem(hwnd, IDC_CSRINFO), GetCSRNumber());
  159. cwRegistrationID = GetGlobalContext()->GetRegistrationID();
  160. hwndLSID = GetDlgItem(hwnd, IDC_MSID2);
  161. swprintf(awBuffer, L"%5.5s-%5.5s-%5.5s-%5.5s-%5.5s-%5.5s-%5.5s",
  162. cwRegistrationID, cwRegistrationID + 5, cwRegistrationID + 10,
  163. cwRegistrationID + 15, cwRegistrationID + 20, cwRegistrationID + 25,
  164. cwRegistrationID + 30);
  165. SetWindowText(hwndLSID, awBuffer);
  166. }
  167. break;
  168. case WM_DESTROY:
  169. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  170. break;
  171. case WM_NOTIFY:
  172. {
  173. LPNMHDR pnmh = (LPNMHDR)lParam;
  174. switch( pnmh->code )
  175. {
  176. case PSN_SETACTIVE:
  177. PropSheet_SetWizButtons( GetParent( hwnd ), PSWIZB_NEXT | PSWIZB_BACK);
  178. break;
  179. case PSN_WIZNEXT:
  180. {
  181. TCHAR lpBuffer[ LR_CONFIRMATION_LEN+1];
  182. GetDlgItemText(hwnd,IDC_REVOKE_CONFIRMATION_NUMBER, lpBuffer,
  183. LR_CONFIRMATION_LEN+1);
  184. if (SetConfirmationNumber(lpBuffer) != ERROR_SUCCESS)
  185. {
  186. LRMessageBox(hwnd,IDS_ERR_INVALID_CONFIRMATION_NUMBER);
  187. dwNextPage = IDD_DLG_CONFREVOKE;
  188. }
  189. else
  190. {
  191. dwRetCode = ShowProgressBox(hwnd, ProcessThread, 0, 0, 0);
  192. dwNextPage = IDD_PROGRESS;
  193. LRPush(IDD_DLG_CONFREVOKE);
  194. }
  195. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  196. bStatus = -1;
  197. }
  198. break;
  199. case PSN_WIZBACK:
  200. dwNextPage = LRPop();
  201. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  202. bStatus = -1;
  203. break;
  204. default:
  205. bStatus = FALSE;
  206. break;
  207. }
  208. }
  209. break;
  210. default:
  211. bStatus = FALSE;
  212. break;
  213. }
  214. return bStatus;
  215. }
  216. LRW_DLG_INT CALLBACK
  217. CertLogProc(
  218. IN HWND hwnd,
  219. IN UINT uMsg,
  220. IN WPARAM wParam,
  221. IN LPARAM lParam
  222. )
  223. {
  224. DWORD dwNextPage = 0;
  225. BOOL bStatus = TRUE;
  226. PageInfo *pi = (PageInfo *)LRW_GETWINDOWLONG( hwnd, LRW_GWL_USERDATA );
  227. switch (uMsg)
  228. {
  229. case WM_INITDIALOG:
  230. pi = (PageInfo *)((LPPROPSHEETPAGE)lParam)->lParam;
  231. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, (LRW_LONG_PTR)pi );
  232. SendDlgItemMessage (hwnd , IDC_TXT_LNAME, EM_SETLIMITTEXT, CA_NAME_LEN,0);
  233. SendDlgItemMessage (hwnd , IDC_TXT_FNAME, EM_SETLIMITTEXT, CA_NAME_LEN,0);
  234. SendDlgItemMessage (hwnd , IDC_TXT_PHONE, EM_SETLIMITTEXT, CA_PHONE_LEN,0);
  235. SendDlgItemMessage (hwnd , IDC_TXT_EMAIL, EM_SETLIMITTEXT, CA_EMAIL_LEN,0);
  236. SetDlgItemText(hwnd, IDC_TXT_LNAME, GetGlobalContext()->GetContactDataObject()->sContactLName);
  237. SetDlgItemText(hwnd, IDC_TXT_FNAME, GetGlobalContext()->GetContactDataObject()->sContactFName);
  238. SetDlgItemText(hwnd, IDC_TXT_PHONE, GetGlobalContext()->GetContactDataObject()->sContactPhone);
  239. SetDlgItemText(hwnd, IDC_TXT_EMAIL, GetGlobalContext()->GetContactDataObject()->sContactEmail);
  240. break;
  241. case WM_SHOWWINDOW:
  242. //bad bad. The view should get data from
  243. //the doc and render it as it wants!
  244. if ( GetGlobalContext()->GetWizAction() == WIZACTION_UNREGISTERLS )
  245. {
  246. PopulateReasonComboBox(GetDlgItem(hwnd,IDC_COMBO_REASONS), CODE_TYPE_DEACT);
  247. // Reason code is not required here - CR23
  248. // Hack - combo is hidden and first reason code is sent over to the backend
  249. ShowWindow(GetDlgItem(hwnd,IDC_COMBO_REASONS),SW_HIDE);
  250. ShowWindow(GetDlgItem(hwnd,IDC_LBL_REASON),SW_HIDE);
  251. ComboBox_SetCurSel(GetDlgItem(hwnd, IDC_COMBO_REASONS),0);
  252. }
  253. if ( GetGlobalContext()->GetWizAction() == WIZACTION_REREGISTERLS )
  254. {
  255. PopulateReasonComboBox(GetDlgItem(hwnd,IDC_COMBO_REASONS), CODE_TYPE_REACT);
  256. // Reason codes are required in this case
  257. ShowWindow(GetDlgItem(hwnd,IDC_COMBO_REASONS),SW_SHOW);
  258. ShowWindow(GetDlgItem(hwnd,IDC_LBL_REASON),SW_SHOW);
  259. }
  260. break;
  261. case WM_DESTROY:
  262. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  263. break;
  264. case WM_NOTIFY:
  265. {
  266. LPNMHDR pnmh = (LPNMHDR)lParam;
  267. switch( pnmh->code )
  268. {
  269. case PSN_SETACTIVE:
  270. //Populate the values which were read from the Registry during Global Init
  271. //
  272. PropSheet_SetWizButtons( GetParent( hwnd ), PSWIZB_NEXT | PSWIZB_BACK);
  273. break;
  274. case PSN_WIZNEXT:
  275. {
  276. CString sLastName;
  277. CString sFirstName;
  278. CString sPhone;
  279. CString sEmail;
  280. CString sReasonDesc;
  281. CString sReasonCode;
  282. LPTSTR lpVal = NULL;
  283. DWORD dwRetCode;
  284. int nCurSel = -1;
  285. //
  286. //Read all the fields
  287. //
  288. lpVal = sLastName.GetBuffer(CA_NAME_LEN+1);
  289. GetDlgItemText(hwnd,IDC_TXT_LNAME,lpVal,CA_NAME_LEN+1);
  290. sLastName.ReleaseBuffer(-1);
  291. lpVal = sFirstName.GetBuffer(CA_NAME_LEN+1);
  292. GetDlgItemText(hwnd,IDC_TXT_FNAME,lpVal,CA_NAME_LEN+1);
  293. sFirstName.ReleaseBuffer(-1);
  294. lpVal = sPhone.GetBuffer(CA_PHONE_LEN+1);
  295. GetDlgItemText(hwnd,IDC_TXT_PHONE,lpVal,CA_PHONE_LEN+1);
  296. sPhone.ReleaseBuffer(-1);
  297. lpVal = sEmail.GetBuffer(CA_EMAIL_LEN+1);
  298. GetDlgItemText(hwnd,IDC_TXT_EMAIL,lpVal,CA_EMAIL_LEN+1);
  299. sEmail.ReleaseBuffer(-1);
  300. nCurSel = ComboBox_GetCurSel(GetDlgItem(hwnd, IDC_COMBO_REASONS));
  301. lpVal = sReasonDesc.GetBuffer(LR_REASON_DESC_LEN+1);
  302. ComboBox_GetLBText(GetDlgItem(hwnd,IDC_COMBO_REASONS), nCurSel, lpVal);
  303. sReasonDesc.ReleaseBuffer(-1);
  304. sFirstName.TrimLeft(); sFirstName.TrimRight();
  305. sLastName.TrimLeft(); sLastName.TrimRight();
  306. sPhone.TrimLeft(); sPhone.TrimRight();
  307. sEmail.TrimLeft(); sEmail.TrimRight();
  308. sReasonDesc.TrimLeft();sReasonDesc.TrimRight();
  309. if(sLastName.IsEmpty() || sFirstName.IsEmpty() || sReasonDesc.IsEmpty()) // sEmail.IsEmpty()
  310. {
  311. LRMessageBox(hwnd,IDS_ERR_FIELD_EMPTY);
  312. dwNextPage = IDD_DLG_CERTLOG_INFO;
  313. goto NextDone;
  314. }
  315. //
  316. // Check for the Invalid Characters
  317. //
  318. if( !ValidateLRString(sFirstName) ||
  319. !ValidateLRString(sLastName) ||
  320. !ValidateLRString(sPhone) ||
  321. !ValidateLRString(sEmail)
  322. )
  323. {
  324. LRMessageBox(hwnd,IDS_ERR_INVALID_CHAR);
  325. dwNextPage = IDD_DLG_CERTLOG_INFO;
  326. goto NextDone;
  327. }
  328. if(!sEmail.IsEmpty())
  329. {
  330. if(!ValidateEmailId(sEmail))
  331. {
  332. LRMessageBox(hwnd,IDS_ERR_INVALID_EMAIL);
  333. dwNextPage = IDD_DLG_CERTLOG_INFO;
  334. goto NextDone;
  335. }
  336. }
  337. lpVal = sReasonCode.GetBuffer(LR_REASON_CODE_LEN+1);
  338. if ( GetGlobalContext()->GetWizAction() == WIZACTION_UNREGISTERLS )
  339. {
  340. GetReasonCode(sReasonDesc,lpVal, CODE_TYPE_DEACT);
  341. }
  342. else if ( GetGlobalContext()->GetWizAction() == WIZACTION_REREGISTERLS )
  343. {
  344. GetReasonCode(sReasonDesc,lpVal, CODE_TYPE_REACT);
  345. }
  346. sReasonCode.ReleaseBuffer(-1);
  347. //
  348. //Finally update CAData object
  349. //
  350. GetGlobalContext()->GetContactDataObject()->sContactEmail = sEmail;
  351. GetGlobalContext()->GetContactDataObject()->sContactFName = sFirstName;
  352. GetGlobalContext()->GetContactDataObject()->sContactLName = sLastName;
  353. GetGlobalContext()->GetContactDataObject()->sContactPhone = sPhone;
  354. GetGlobalContext()->GetContactDataObject()->sReasonCode = sReasonCode;
  355. //
  356. //If no Error , go to the next page
  357. //
  358. dwRetCode = ShowProgressBox(hwnd, ProcessThread, 0, 0, 0);
  359. dwNextPage = IDD_PROGRESS;
  360. LRPush( IDD_DLG_CERTLOG_INFO );
  361. NextDone:
  362. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  363. bStatus = -1;
  364. }
  365. break;
  366. case PSN_WIZBACK:
  367. dwNextPage = LRPop();
  368. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  369. bStatus = -1;
  370. break;
  371. default:
  372. bStatus = FALSE;
  373. break;
  374. }
  375. }
  376. break;
  377. default:
  378. bStatus = FALSE;
  379. break;
  380. }
  381. return bStatus;
  382. }