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.

348 lines
10 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. #include "precomp.h"
  3. #include "utils.h"
  4. #include <assert.h>
  5. static DWORD g_dwAuthRetCode = ERROR_SUCCESS;
  6. DWORD WINAPI AuthThread(void *pData);
  7. LRW_DLG_INT CALLBACK
  8. AuthProc(
  9. IN HWND hwnd,
  10. IN UINT uMsg,
  11. IN WPARAM wParam,
  12. IN LPARAM lParam
  13. );
  14. LRW_DLG_INT CALLBACK
  15. WelcomeDlgProc(IN HWND hwnd,
  16. IN UINT uMsg,
  17. IN WPARAM wParam,
  18. IN LPARAM lParam)
  19. {
  20. DWORD dwRetCode = ERROR_SUCCESS;
  21. DWORD dwNextPage = 0;
  22. BOOL bStatus = TRUE;
  23. PageInfo *pi = (PageInfo *)LRW_GETWINDOWLONG( hwnd, LRW_GWL_USERDATA );
  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. SetControlFont( pi->hBigBoldFont, hwnd, IDC_BIGBOLDTITLE);
  30. GetGlobalContext()->ClearWizStack();
  31. break;
  32. case WM_DESTROY:
  33. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  34. break;
  35. case WM_NOTIFY:
  36. {
  37. LPNMHDR pnmh = (LPNMHDR)lParam;
  38. switch( pnmh->code )
  39. {
  40. case PSN_SETACTIVE:
  41. {
  42. TCHAR szMsg[LR_MAX_MSG_TEXT];
  43. SetDlgItemText(hwnd, IDC_PRODUCTID, GetGlobalContext()->GetLicenseServerID());
  44. if (GetGlobalContext()->GetWizAction() != WIZACTION_REGISTERLS &&
  45. GetGlobalContext()->GetWizAction() != WIZACTION_CONTINUEREGISTERLS)
  46. {
  47. SetDlgItemText(hwnd, IDC_COMPANYNAME, GetGlobalContext()->GetContactDataObject()->sCompanyName);
  48. if (GetGlobalContext()->GetContactDataObject()->sProgramName == PROGRAM_SELECT)
  49. {
  50. LoadString(GetInstanceHandle(),IDS_AGREEMENT_SELECT,szMsg,LR_MAX_MSG_TEXT);
  51. }
  52. else if (GetGlobalContext()->GetContactDataObject()->sProgramName == PROGRAM_MOLP)
  53. {
  54. LoadString(GetInstanceHandle(),IDS_AGREEMENT_MOLP,szMsg,LR_MAX_MSG_TEXT);
  55. }
  56. else
  57. {
  58. LoadString(GetInstanceHandle(),IDS_AGREEMENT_OTHER,szMsg,LR_MAX_MSG_TEXT);
  59. }
  60. SetDlgItemText(hwnd, IDC_LICENSETYPE, szMsg);
  61. if(GetGlobalContext()->GetActivationMethod() == CONNECTION_INTERNET)
  62. {
  63. LoadString(GetInstanceHandle(),IDS_INTERNETMODE,szMsg,LR_MAX_MSG_TEXT);
  64. SetDlgItemText(hwnd, IDC_ACTIVATIONMETHOD, szMsg);
  65. }
  66. if(GetGlobalContext()->GetActivationMethod() == CONNECTION_WWW)
  67. {
  68. LoadString(GetInstanceHandle(),IDS_WWWMODE,szMsg,LR_MAX_MSG_TEXT);
  69. SetDlgItemText(hwnd, IDC_ACTIVATIONMETHOD, szMsg);
  70. }
  71. if(GetGlobalContext()->GetActivationMethod() == CONNECTION_PHONE)
  72. {
  73. LoadString(GetInstanceHandle(),IDS_TELEPHONEMODE,szMsg,LR_MAX_MSG_TEXT);
  74. SetDlgItemText(hwnd, IDC_ACTIVATIONMETHOD, szMsg);
  75. }
  76. }
  77. PropSheet_SetWizButtons( GetParent( hwnd ), PSWIZB_NEXT );
  78. switch (GetGlobalContext()->GetWizAction())
  79. {
  80. case WIZACTION_DOWNLOADLKP:
  81. LoadString(GetInstanceHandle(), IDS_MSG_DOWNLOADLKP, szMsg,LR_MAX_MSG_TEXT);
  82. break;
  83. case WIZACTION_REGISTERLS:
  84. LoadString(GetInstanceHandle(), IDS_MSG_UNREGISTERED, szMsg,LR_MAX_MSG_TEXT);
  85. break;
  86. case WIZACTION_CONTINUEREGISTERLS:
  87. LoadString(GetInstanceHandle(), IDS_MSG_CONTINUEREGISTRATION, szMsg,LR_MAX_MSG_TEXT);
  88. break;
  89. case WIZACTION_REREGISTERLS:
  90. LoadString(GetInstanceHandle(), IDS_MSG_REREGISTRATION, szMsg,LR_MAX_MSG_TEXT);
  91. break;
  92. case WIZACTION_UNREGISTERLS:
  93. LoadString(GetInstanceHandle(), IDS_MSG_UNREGISTRATION, szMsg,LR_MAX_MSG_TEXT);
  94. break;
  95. case WIZACTION_DOWNLOADLASTLKP:
  96. LoadString(GetInstanceHandle(), IDS_MSG_DOWNLOADLASTLKP, szMsg,LR_MAX_MSG_TEXT);
  97. break;
  98. }
  99. SetDlgItemText(hwnd, IDC_BOLDTITLE, szMsg);
  100. }
  101. break;
  102. case PSN_WIZNEXT:
  103. if (GetGlobalContext()->GetWizAction() == WIZACTION_DOWNLOADLASTLKP)
  104. {
  105. if (GetGlobalContext()->GetActivationMethod() == CONNECTION_INTERNET)
  106. {
  107. // Solve Bug 610 BEGIN
  108. dwRetCode = ShowProgressBox(hwnd, AuthThread, 0, 0, 0);
  109. if(g_dwAuthRetCode == ERROR_SUCCESS)
  110. {
  111. //Previos code BEGIN
  112. dwRetCode = ShowProgressBox(hwnd, ProcessThread, 0, 0, 0);
  113. if (dwRetCode == ERROR_SUCCESS)
  114. {
  115. dwRetCode = LRGetLastRetCode();
  116. }
  117. if (dwRetCode != ERROR_SUCCESS)
  118. {
  119. LRMessageBox(hwnd, dwRetCode);
  120. dwNextPage = IDD_WELCOME;
  121. }
  122. else
  123. {
  124. dwNextPage = IDD_PROGRESS;
  125. }
  126. //Previous code END
  127. }
  128. else if (g_dwAuthRetCode == IDS_ERR_SPKBAD ||
  129. g_dwAuthRetCode == IDS_ERR_CERTREVOKED)
  130. {
  131. TCHAR szMsg[LR_MAX_MSG_TEXT];
  132. TCHAR szCaption[LR_MAX_MSG_CAPTION];
  133. LoadString(GetInstanceHandle(),g_dwAuthRetCode, szMsg,LR_MAX_MSG_TEXT);
  134. LoadString(GetInstanceHandle(),IDS_TITLE,szCaption,LR_MAX_MSG_CAPTION);
  135. if (MessageBox(hwnd,szMsg, szCaption, MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) == IDYES)
  136. {
  137. SetCursor(LoadCursor(NULL,IDC_WAIT));
  138. g_dwAuthRetCode = ResetLSSPK();
  139. SetCursor(LoadCursor(NULL,IDC_ARROW));
  140. if (g_dwAuthRetCode == ERROR_SUCCESS)
  141. {
  142. // Start all over again
  143. GetGlobalContext()->SetLRState(LRSTATE_NEUTRAL);
  144. GetGlobalContext()->SetLSStatus(LSERVERSTATUS_UNREGISTER);
  145. GetGlobalContext()->SetWizAction(WIZACTION_REGISTERLS);
  146. GetGlobalContext()->ClearWizStack();
  147. dwNextPage = IDD_WELCOME;
  148. }
  149. else
  150. {
  151. LRMessageBox(hwnd,g_dwAuthRetCode,LRGetLastError());
  152. dwNextPage = IDD_WELCOME;
  153. }
  154. }
  155. else
  156. {
  157. dwNextPage = IDD_WELCOME;
  158. }
  159. }
  160. else if (g_dwAuthRetCode == IDS_ERR_CERTBAD ||
  161. g_dwAuthRetCode == IDS_ERR_CERTEXPIRED)
  162. {
  163. TCHAR szMsg[LR_MAX_MSG_TEXT];
  164. TCHAR szCaption[LR_MAX_MSG_CAPTION];
  165. LoadString(GetInstanceHandle(), g_dwAuthRetCode, szMsg, LR_MAX_MSG_TEXT);
  166. LoadString(GetInstanceHandle(), IDS_TITLE, szCaption, LR_MAX_MSG_CAPTION);
  167. if (MessageBox(hwnd,szMsg, szCaption, MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) == IDYES)
  168. {
  169. // Go to Reissue Cert
  170. GetGlobalContext()->SetLRState(LRSTATE_NEUTRAL);
  171. GetGlobalContext()->SetLSStatus(LSERVERSTATUS_REGISTER_INTERNET);
  172. GetGlobalContext()->SetWizAction(WIZACTION_REREGISTERLS);
  173. dwNextPage = IDD_DLG_CERTLOG_INFO;
  174. }
  175. else
  176. {
  177. dwNextPage = IDD_WELCOME;
  178. }
  179. }
  180. else
  181. {
  182. LRMessageBox(hwnd,g_dwAuthRetCode,LRGetLastError());
  183. dwNextPage = IDD_WELCOME;
  184. }
  185. }
  186. else
  187. {
  188. dwNextPage = GetGlobalContext()->GetEntryPoint();
  189. }
  190. // Solve Bug 610 END
  191. }
  192. else if (GetGlobalContext()->GetWizAction() == WIZACTION_REGISTERLS)
  193. {
  194. dwNextPage = IDD_DLG_GETREGMODE;
  195. }
  196. else if (GetGlobalContext()->GetWizAction() == WIZACTION_DOWNLOADLKP ||
  197. GetGlobalContext()->GetWizAction() == WIZACTION_UNREGISTERLS ||
  198. GetGlobalContext()->GetWizAction() == WIZACTION_REREGISTERLS)
  199. {
  200. if (GetGlobalContext()->GetActivationMethod() == CONNECTION_INTERNET)
  201. {
  202. dwRetCode = ShowProgressBox(hwnd, AuthThread, 0, 0, 0);
  203. if(g_dwAuthRetCode == ERROR_SUCCESS)
  204. {
  205. dwNextPage = GetGlobalContext()->GetEntryPoint();
  206. }
  207. else if (g_dwAuthRetCode == IDS_ERR_SPKBAD ||
  208. g_dwAuthRetCode == IDS_ERR_CERTREVOKED)
  209. {
  210. TCHAR szMsg[LR_MAX_MSG_TEXT];
  211. TCHAR szCaption[LR_MAX_MSG_CAPTION];
  212. LoadString(GetInstanceHandle(),g_dwAuthRetCode, szMsg,LR_MAX_MSG_TEXT);
  213. LoadString(GetInstanceHandle(),IDS_TITLE,szCaption,LR_MAX_MSG_CAPTION);
  214. if (MessageBox(hwnd,szMsg, szCaption, MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) == IDYES)
  215. {
  216. SetCursor(LoadCursor(NULL,IDC_WAIT));
  217. g_dwAuthRetCode = ResetLSSPK();
  218. SetCursor(LoadCursor(NULL,IDC_ARROW));
  219. if (g_dwAuthRetCode == ERROR_SUCCESS)
  220. {
  221. // Start all over again
  222. GetGlobalContext()->SetLRState(LRSTATE_NEUTRAL);
  223. GetGlobalContext()->SetLSStatus(LSERVERSTATUS_UNREGISTER);
  224. GetGlobalContext()->SetWizAction(WIZACTION_REGISTERLS);
  225. GetGlobalContext()->ClearWizStack();
  226. dwNextPage = IDD_WELCOME;
  227. }
  228. else
  229. {
  230. LRMessageBox(hwnd,g_dwAuthRetCode,LRGetLastError());
  231. dwNextPage = IDD_WELCOME;
  232. }
  233. }
  234. else
  235. {
  236. dwNextPage = IDD_WELCOME;
  237. }
  238. }
  239. else if (g_dwAuthRetCode == IDS_ERR_CERTBAD ||
  240. g_dwAuthRetCode == IDS_ERR_CERTEXPIRED)
  241. {
  242. TCHAR szMsg[LR_MAX_MSG_TEXT];
  243. TCHAR szCaption[LR_MAX_MSG_CAPTION];
  244. LoadString(GetInstanceHandle(), g_dwAuthRetCode, szMsg, LR_MAX_MSG_TEXT);
  245. LoadString(GetInstanceHandle(), IDS_TITLE, szCaption, LR_MAX_MSG_CAPTION);
  246. if (MessageBox(hwnd,szMsg, szCaption, MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) == IDYES)
  247. {
  248. // Go to Reissue Cert
  249. GetGlobalContext()->SetLRState(LRSTATE_NEUTRAL);
  250. GetGlobalContext()->SetLSStatus(LSERVERSTATUS_REGISTER_INTERNET);
  251. GetGlobalContext()->SetWizAction(WIZACTION_REREGISTERLS);
  252. dwNextPage = IDD_DLG_CERTLOG_INFO;
  253. }
  254. else
  255. {
  256. dwNextPage = IDD_WELCOME;
  257. }
  258. }
  259. else
  260. {
  261. LRMessageBox(hwnd,g_dwAuthRetCode,LRGetLastError());
  262. dwNextPage = IDD_WELCOME;
  263. }
  264. }
  265. else
  266. {
  267. dwNextPage = GetGlobalContext()->GetEntryPoint();
  268. }
  269. }
  270. else
  271. {
  272. dwNextPage = GetGlobalContext()->GetEntryPoint();
  273. }
  274. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  275. if (dwNextPage != IDD_WELCOME)
  276. {
  277. LRPush(IDD_WELCOME);
  278. }
  279. bStatus = -1;
  280. break;
  281. default:
  282. bStatus = FALSE;
  283. break;
  284. }
  285. }
  286. break;
  287. default:
  288. bStatus = FALSE;
  289. break;
  290. }
  291. return bStatus;
  292. }
  293. DWORD WINAPI AuthThread(void *pData)
  294. {
  295. g_dwAuthRetCode = AuthenticateLS();
  296. ExitThread(0);
  297. return 0;
  298. }