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.

440 lines
13 KiB

  1. //Copyright (c) 1998 - 2001 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. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO1, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  31. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO2, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  32. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO3, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  33. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO4, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  34. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO5, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  35. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO6, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  36. SendDlgItemMessage (hwnd, IDC_TXT_TELEINFO7, EM_SETLIMITTEXT, CHARS_IN_BATCH,0);
  37. assert(NUMBER_OF_BATCHES == 7);
  38. break;
  39. case WM_SHOWWINDOW:
  40. if (wParam)
  41. {
  42. SetWindowText(GetDlgItem(hwnd, IDC_CSRINFO), GetCSRNumber());
  43. cwRegistrationID = GetGlobalContext()->GetRegistrationID();
  44. hwndLSID = GetDlgItem(hwnd, IDC_MSID);
  45. swprintf(awBuffer, L"%5.5s-%5.5s-%5.5s-%5.5s-%5.5s-%5.5s-%5.5s",
  46. cwRegistrationID, cwRegistrationID + 5, cwRegistrationID + 10,
  47. cwRegistrationID + 15, cwRegistrationID + 20, cwRegistrationID + 25,
  48. cwRegistrationID + 30);
  49. SetWindowText(hwndLSID, awBuffer);
  50. }
  51. break;
  52. case WM_COMMAND:
  53. if (HIWORD(wParam) == EN_CHANGE)
  54. {
  55. MoveCaret(LOWORD(wParam), hwnd ) ;
  56. }
  57. if (HIWORD(wParam) == EN_UPDATE)
  58. {
  59. if (GetKeyState(VK_DELETE) == -128)
  60. SetDeleteKeyStatus(1) ;
  61. else
  62. SetDeleteKeyStatus(0) ;
  63. }
  64. break ;
  65. case WM_DESTROY:
  66. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  67. break;
  68. case WM_NOTIFY:
  69. {
  70. LPNMHDR pnmh = (LPNMHDR)lParam;
  71. switch( pnmh->code )
  72. {
  73. case PSN_SETACTIVE:
  74. PropSheet_SetWizButtons( GetParent( hwnd ), PSWIZB_NEXT | PSWIZB_BACK);
  75. SetWindowText(GetDlgItem(hwnd, IDC_PRODUCT_ID), GetLicenseServerID()); break;
  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,IDS_WIZARD_MESSAGE_TITLE);
  94. dwNextPage = IDD_DLG_TELREG_REISSUE;
  95. }
  96. else
  97. {
  98. dwRetCode = SetLSSPK(tcUserValue);
  99. if (dwRetCode != ERROR_SUCCESS)
  100. {
  101. LRMessageBox(hwnd, dwRetCode,IDS_WIZARD_MESSAGE_TITLE);
  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,IDS_WIZARD_MESSAGE_TITLE);
  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_EMAIL, EM_SETLIMITTEXT, CA_EMAIL_LEN,0);
  235. SetDlgItemText(hwnd, IDC_TXT_LNAME, GetGlobalContext()->GetContactDataObject()->sContactLName);
  236. SetDlgItemText(hwnd, IDC_TXT_FNAME, GetGlobalContext()->GetContactDataObject()->sContactFName);
  237. SetDlgItemText(hwnd, IDC_TXT_EMAIL, GetGlobalContext()->GetContactDataObject()->sContactEmail);
  238. break;
  239. case WM_SHOWWINDOW:
  240. //bad bad. The view should get data from
  241. //the doc and render it as it wants!
  242. if ( GetGlobalContext()->GetWizAction() == WIZACTION_UNREGISTERLS )
  243. {
  244. PopulateReasonComboBox(GetDlgItem(hwnd,IDC_COMBO_REASONS), CODE_TYPE_DEACT);
  245. // Reason code is not required here - CR23
  246. // Hack - combo is hidden and first reason code is sent over to the backend
  247. ShowWindow(GetDlgItem(hwnd,IDC_COMBO_REASONS),SW_HIDE);
  248. ShowWindow(GetDlgItem(hwnd,IDC_LBL_REASON),SW_HIDE);
  249. ComboBox_SetCurSel(GetDlgItem(hwnd, IDC_COMBO_REASONS),0);
  250. }
  251. if ( GetGlobalContext()->GetWizAction() == WIZACTION_REREGISTERLS )
  252. {
  253. PopulateReasonComboBox(GetDlgItem(hwnd,IDC_COMBO_REASONS), CODE_TYPE_REACT);
  254. // Reason codes are required in this case
  255. ShowWindow(GetDlgItem(hwnd,IDC_COMBO_REASONS),SW_SHOW);
  256. ShowWindow(GetDlgItem(hwnd,IDC_LBL_REASON),SW_SHOW);
  257. }
  258. break;
  259. case WM_DESTROY:
  260. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  261. break;
  262. case WM_NOTIFY:
  263. {
  264. LPNMHDR pnmh = (LPNMHDR)lParam;
  265. switch( pnmh->code )
  266. {
  267. case PSN_SETACTIVE:
  268. //Populate the values which were read from the Registry during Global Init
  269. //
  270. PropSheet_SetWizButtons( GetParent( hwnd ), PSWIZB_NEXT | PSWIZB_BACK);
  271. break;
  272. case PSN_WIZNEXT:
  273. {
  274. CString sLastName;
  275. CString sFirstName;
  276. CString sEmail;
  277. CString sReasonDesc;
  278. CString sReasonCode;
  279. LPTSTR lpVal = NULL;
  280. DWORD dwRetCode;
  281. lpVal = sLastName.GetBuffer(CA_NAME_LEN+1);
  282. GetDlgItemText(hwnd,IDC_TXT_LNAME,lpVal,CA_NAME_LEN+1);
  283. sLastName.ReleaseBuffer(-1);
  284. lpVal = sFirstName.GetBuffer(CA_NAME_LEN+1);
  285. GetDlgItemText(hwnd,IDC_TXT_FNAME,lpVal,CA_NAME_LEN+1);
  286. sFirstName.ReleaseBuffer(-1);
  287. lpVal = sEmail.GetBuffer(CA_EMAIL_LEN+1);
  288. GetDlgItemText(hwnd,IDC_TXT_EMAIL,lpVal,CA_EMAIL_LEN+1);
  289. sEmail.ReleaseBuffer(-1);
  290. int nCurSel = -1;
  291. nCurSel = ComboBox_GetCurSel(GetDlgItem(hwnd, IDC_COMBO_REASONS));
  292. lpVal = sReasonDesc.GetBuffer(LR_REASON_DESC_LEN+1);
  293. ComboBox_GetLBText(GetDlgItem(hwnd,IDC_COMBO_REASONS), nCurSel, lpVal);
  294. sReasonDesc.ReleaseBuffer(-1);
  295. sFirstName.TrimLeft(); sFirstName.TrimRight();
  296. sLastName.TrimLeft(); sLastName.TrimRight();
  297. sEmail.TrimLeft(); sEmail.TrimRight();
  298. sReasonDesc.TrimLeft();sReasonDesc.TrimRight();
  299. if(sLastName.IsEmpty() || sFirstName.IsEmpty() ||
  300. sReasonDesc.IsEmpty() )
  301. {
  302. LRMessageBox(hwnd,IDS_ERR_FIELD_EMPTY,IDS_WIZARD_MESSAGE_TITLE);
  303. dwNextPage = IDD_DLG_CERTLOG_INFO;
  304. goto NextDone;
  305. }
  306. // Check for the Invalid Characters
  307. if( !ValidateLRString(sFirstName) ||
  308. !ValidateLRString(sLastName) ||
  309. !ValidateLRString(sEmail)
  310. )
  311. {
  312. LRMessageBox(hwnd,IDS_ERR_INVALID_CHAR,IDS_WIZARD_MESSAGE_TITLE);
  313. dwNextPage = IDD_DLG_CERTLOG_INFO;
  314. goto NextDone;
  315. }
  316. if(!sEmail.IsEmpty())
  317. {
  318. if(!ValidateEmailId(sEmail))
  319. {
  320. LRMessageBox(hwnd,IDS_ERR_INVALID_EMAIL,IDS_WIZARD_MESSAGE_TITLE);
  321. dwNextPage = IDD_DLG_CERTLOG_INFO;
  322. goto NextDone;
  323. }
  324. }
  325. lpVal = sReasonCode.GetBuffer(LR_REASON_CODE_LEN+1);
  326. if ( GetGlobalContext()->GetWizAction() == WIZACTION_UNREGISTERLS )
  327. {
  328. GetReasonCode(sReasonDesc,lpVal, CODE_TYPE_DEACT);
  329. }
  330. else if ( GetGlobalContext()->GetWizAction() == WIZACTION_REREGISTERLS )
  331. {
  332. GetReasonCode(sReasonDesc,lpVal, CODE_TYPE_REACT);
  333. }
  334. sReasonCode.ReleaseBuffer(-1);
  335. //Finally update CAData object
  336. GetGlobalContext()->GetContactDataObject()->sContactEmail = sEmail;
  337. GetGlobalContext()->GetContactDataObject()->sContactFName = sFirstName;
  338. GetGlobalContext()->GetContactDataObject()->sContactLName = sLastName;
  339. GetGlobalContext()->GetContactDataObject()->sReasonCode = sReasonCode;
  340. //If no Error , go to the next page
  341. dwRetCode = ShowProgressBox(hwnd, ProcessThread, 0, 0, 0);
  342. dwNextPage = IDD_PROGRESS;
  343. LRPush( IDD_DLG_CERTLOG_INFO );
  344. NextDone:
  345. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  346. bStatus = -1;
  347. }
  348. break;
  349. case PSN_WIZBACK:
  350. dwNextPage = LRPop();
  351. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  352. bStatus = -1;
  353. break;
  354. default:
  355. bStatus = FALSE;
  356. break;
  357. }
  358. }
  359. break;
  360. default:
  361. bStatus = FALSE;
  362. break;
  363. }
  364. return bStatus;
  365. }