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.

425 lines
11 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. static WIZCONNECTION g_enumPrevMethod = CONNECTION_DEFAULT;
  7. DWORD WINAPI PingThread(void *pData)
  8. {
  9. g_dwAuthRetCode = PingCH();
  10. ExitThread(0);
  11. return 0;
  12. }
  13. LRW_DLG_INT CALLBACK
  14. GetModeDlgProc(IN HWND hwnd,
  15. IN UINT uMsg,
  16. IN WPARAM wParam,
  17. IN LPARAM lParam)
  18. {
  19. DWORD dwRetCode = ERROR_SUCCESS;
  20. DWORD dwNextPage = 0;
  21. BOOL bStatus = TRUE;
  22. HWND hwndComboBox;
  23. TCHAR lpBuffer[ 512];
  24. PageInfo *pi = (PageInfo *)LRW_GETWINDOWLONG( hwnd, LRW_GWL_USERDATA );
  25. switch (uMsg)
  26. {
  27. case WM_INITDIALOG:
  28. pi = (PageInfo *)((LPPROPSHEETPAGE)lParam)->lParam;
  29. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, (LRW_LONG_PTR)pi );
  30. hwndComboBox = GetDlgItem(hwnd,IDC_MODEOFREG);
  31. assert(hwndComboBox != NULL); // Somebody has messed with the Res. Files.
  32. // Let user choose the mode of registration with Internet being default
  33. memset(lpBuffer,0,sizeof(lpBuffer));
  34. dwRetCode = LoadString(GetInstanceHandle(), IDS_INTERNETMODE, lpBuffer, sizeof(lpBuffer)/sizeof(TCHAR));
  35. assert(dwRetCode != 0);
  36. ComboBox_AddString(hwndComboBox,lpBuffer);
  37. memset(lpBuffer,0,sizeof(lpBuffer));
  38. dwRetCode = LoadString(GetInstanceHandle(), IDS_WWWMODE, lpBuffer, sizeof(lpBuffer)/sizeof(TCHAR));
  39. assert(dwRetCode != 0);
  40. ComboBox_AddString(hwndComboBox,lpBuffer);
  41. memset(lpBuffer,0,sizeof(lpBuffer));
  42. dwRetCode = LoadString(GetInstanceHandle(), IDS_TELEPHONEMODE, lpBuffer, sizeof(lpBuffer)/sizeof(TCHAR));
  43. assert(dwRetCode != 0);
  44. ComboBox_AddString(hwndComboBox,lpBuffer);
  45. if(GetGlobalContext()->GetActivationMethod() == CONNECTION_INTERNET ||
  46. GetGlobalContext()->GetActivationMethod() == CONNECTION_DEFAULT) //Partially fix bug # 577
  47. {
  48. ComboBox_SetCurSel(hwndComboBox, 0);
  49. memset(lpBuffer,0,sizeof(lpBuffer));
  50. LoadString(GetInstanceHandle(),IDS_INTERNET_DESC,lpBuffer,sizeof(lpBuffer)/sizeof(TCHAR));
  51. SetDlgItemText(hwnd,IDC_TXT_DESC,lpBuffer);
  52. }
  53. if(GetGlobalContext()->GetActivationMethod() == CONNECTION_WWW )
  54. {
  55. ComboBox_SetCurSel(hwndComboBox, 1);
  56. memset(lpBuffer,0,sizeof(lpBuffer));
  57. LoadString(GetInstanceHandle(),IDS_WWW_DESC,lpBuffer,sizeof(lpBuffer)/sizeof(TCHAR));
  58. SetDlgItemText(hwnd,IDC_TXT_DESC,lpBuffer);
  59. }
  60. if(GetGlobalContext()->GetActivationMethod() == CONNECTION_PHONE )
  61. {
  62. ComboBox_SetCurSel(hwndComboBox, 2);
  63. memset(lpBuffer,0,sizeof(lpBuffer));
  64. LoadString(GetInstanceHandle(),IDS_TELEPHONE_DESC,lpBuffer,sizeof(lpBuffer)/sizeof(TCHAR));
  65. SetDlgItemText(hwnd,IDC_TXT_DESC,lpBuffer);
  66. }
  67. break;
  68. case WM_DESTROY:
  69. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  70. break;
  71. case WM_COMMAND:
  72. if(HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_MODEOFREG)
  73. {
  74. dwRetCode = ComboBox_GetCurSel((HWND)lParam);
  75. if(dwRetCode == 0)
  76. {
  77. memset(lpBuffer,0,sizeof(lpBuffer));
  78. LoadString(GetInstanceHandle(),IDS_INTERNET_DESC,lpBuffer,sizeof(lpBuffer)/sizeof(TCHAR));
  79. SetDlgItemText(hwnd,IDC_TXT_DESC,lpBuffer);
  80. }
  81. if(dwRetCode == 2)
  82. {
  83. memset(lpBuffer,0,sizeof(lpBuffer));
  84. LoadString(GetInstanceHandle(),IDS_TELEPHONE_DESC,lpBuffer,sizeof(lpBuffer)/sizeof(TCHAR));
  85. SetDlgItemText(hwnd,IDC_TXT_DESC,lpBuffer);
  86. }
  87. if(dwRetCode == 1)
  88. {
  89. memset(lpBuffer,0,sizeof(lpBuffer));
  90. LoadString(GetInstanceHandle(),IDS_WWW_DESC,lpBuffer,sizeof(lpBuffer)/sizeof(TCHAR));
  91. SetDlgItemText(hwnd,IDC_TXT_DESC,lpBuffer);
  92. }
  93. }
  94. break;
  95. case WM_NOTIFY:
  96. {
  97. LPNMHDR pnmh = (LPNMHDR)lParam;
  98. hwndComboBox = GetDlgItem(hwnd,IDC_MODEOFREG);
  99. assert(hwndComboBox != NULL); // Somebody has messed with the Res. Files.
  100. switch( pnmh->code )
  101. {
  102. case PSN_SETACTIVE:
  103. PropSheet_SetWizButtons( GetParent( hwnd ), PSWIZB_NEXT|PSWIZB_BACK );
  104. break;
  105. case PSN_WIZNEXT:
  106. // What did the user choose ??
  107. dwRetCode = ComboBox_GetCurSel(hwndComboBox);
  108. assert(dwRetCode >= 0 && dwRetCode <= 2);
  109. switch(dwRetCode)
  110. {
  111. case 0:
  112. // Only applicable for Registration, so the Ping Goes Thru'
  113. dwRetCode = ShowProgressBox(hwnd, PingThread, 0, 0, 0);
  114. if(g_dwAuthRetCode == ERROR_SUCCESS)
  115. {
  116. GetGlobalContext()->SetActivationMethod(CONNECTION_INTERNET);
  117. dwNextPage = GetGlobalContext()->GetEntryPoint();
  118. }
  119. else
  120. {
  121. LRMessageBox(hwnd,g_dwAuthRetCode,LRGetLastError());
  122. dwNextPage = IDD_DLG_GETREGMODE;
  123. }
  124. break;
  125. case 1:
  126. GetGlobalContext()->SetActivationMethod(CONNECTION_WWW);
  127. dwNextPage = IDD_DLG_WWWREG;
  128. break;
  129. case 2:
  130. GetGlobalContext()->SetActivationMethod(CONNECTION_PHONE);
  131. //Check if the Required Registry key is ok or not
  132. dwRetCode = GetGlobalContext()->CheckRegistryForPhoneNumbers();
  133. if(dwRetCode != ERROR_SUCCESS)
  134. {
  135. LRMessageBox(hwnd,dwRetCode,LRGetLastError());
  136. dwNextPage = IDD_DLG_GETREGMODE;
  137. }
  138. else
  139. dwNextPage = IDD_DLG_COUNTRYREGION;
  140. break;
  141. default:
  142. GetGlobalContext()->SetActivationMethod(CONNECTION_DEFAULT);
  143. dwNextPage = IDD_DLG_GETREGMODE;
  144. break;
  145. }
  146. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  147. bStatus = -1;
  148. if (dwNextPage != IDD_DLG_GETREGMODE)
  149. {
  150. LRPush(IDD_DLG_GETREGMODE);
  151. }
  152. break;
  153. case PSN_WIZBACK:
  154. dwNextPage = LRPop();
  155. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  156. bStatus = -1;
  157. break;
  158. default:
  159. bStatus = FALSE;
  160. break;
  161. }
  162. }
  163. break;
  164. default:
  165. bStatus = FALSE;
  166. break;
  167. }
  168. return bStatus;
  169. }
  170. LRW_DLG_INT CALLBACK
  171. CountryRegionProc(
  172. IN HWND hwnd,
  173. IN UINT uMsg,
  174. IN WPARAM wParam,
  175. IN LPARAM lParam
  176. )
  177. {
  178. DWORD dwRetCode = ERROR_SUCCESS;
  179. DWORD dwNextPage = 0;
  180. BOOL bStatus = TRUE;
  181. HWND hWndCSR = GetDlgItem(hwnd, IDC_COUNTRYREGION );
  182. LVFINDINFO lvFindInfo;
  183. int nItem = 0;
  184. HWND hWndListBox = 0 ;
  185. PageInfo *pi = (PageInfo *)LRW_GETWINDOWLONG( hwnd, LRW_GWL_USERDATA );
  186. switch (uMsg)
  187. {
  188. case WM_INITDIALOG:
  189. pi = (PageInfo *)((LPPROPSHEETPAGE)lParam)->lParam;
  190. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, (LRW_LONG_PTR)pi );
  191. hWndListBox = GetDlgItem(hwnd, IDC_COUNTRYREGION );
  192. //Setup columns in list view
  193. {
  194. LV_COLUMN lvColumn;
  195. TCHAR lpszHeader[ 128];
  196. lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  197. lvColumn.fmt = LVCFMT_LEFT;
  198. lvColumn.cx = 250;
  199. LoadString(GetInstanceHandle(), IDS_COUNTRYREGION_HEADER, lpszHeader, sizeof(lpszHeader)/sizeof(TCHAR));
  200. lvColumn.pszText = lpszHeader;
  201. ListView_InsertColumn(hWndCSR, 0, &lvColumn);
  202. lvColumn.pszText = _TEXT("");
  203. lvColumn.cx = 0;
  204. ListView_InsertColumn(hWndCSR, 1, &lvColumn);
  205. }
  206. g_enumPrevMethod = GetGlobalContext()->GetActivationMethod();
  207. if (GetGlobalContext()->GetActivationMethod() == CONNECTION_PHONE)
  208. {
  209. dwRetCode = PopulateCountryRegionComboBox(hWndCSR);
  210. //fix bug 575 BEGIN
  211. memset(&lvFindInfo,0,sizeof(lvFindInfo));
  212. lvFindInfo.flags = LVFI_STRING;
  213. lvFindInfo.psz = GetGlobalContext()->GetContactDataObject()->sCSRPhoneRegion;
  214. nItem = ListView_FindItem(hWndListBox,-1,&lvFindInfo);
  215. ListView_SetItemState(hWndListBox,nItem,LVIS_SELECTED,LVIS_SELECTED);
  216. ListView_SetSelectionMark(hWndListBox,nItem);
  217. ListView_SetSelectionMark(hWndListBox,nItem);
  218. //fix bug 575 END
  219. }
  220. break;
  221. case WM_DESTROY:
  222. LRW_SETWINDOWLONG( hwnd, LRW_GWL_USERDATA, NULL );
  223. break;
  224. case WM_NOTIFY:
  225. {
  226. LPNMHDR pnmh = (LPNMHDR)lParam;
  227. switch( pnmh->code )
  228. {
  229. case PSN_SETACTIVE:
  230. //
  231. // If the PrevMethod and The Current method don't match
  232. // then Country/Region list box must be reloaded
  233. //
  234. hWndListBox = GetDlgItem(hwnd, IDC_COUNTRYREGION );
  235. if( GetGlobalContext()->GetActivationMethod() != g_enumPrevMethod )
  236. {
  237. if (GetGlobalContext()->GetActivationMethod() == CONNECTION_PHONE)
  238. {
  239. dwRetCode = PopulateCountryRegionComboBox(hWndCSR);
  240. }
  241. g_enumPrevMethod = GetGlobalContext()->GetActivationMethod();
  242. }
  243. nItem = ListView_GetSelectionMark(hWndCSR);
  244. //Select the previous selected country
  245. if (nItem ==-1 && GetGlobalContext()->GetActivationMethod() == CONNECTION_PHONE)
  246. {
  247. dwRetCode = PopulateCountryRegionComboBox(hWndCSR);
  248. //fix bug 575 BEGIN
  249. memset(&lvFindInfo,0,sizeof(lvFindInfo));
  250. lvFindInfo.flags = LVFI_STRING;
  251. lvFindInfo.psz = GetGlobalContext()->GetContactDataObject()->sCSRPhoneRegion;
  252. nItem = ListView_FindItem(hWndListBox,-1,&lvFindInfo);
  253. ListView_SetItemState(hWndListBox,nItem,LVIS_SELECTED,LVIS_SELECTED);
  254. ListView_SetSelectionMark(hWndListBox,nItem);
  255. ListView_SetSelectionMark(hWndListBox,nItem);
  256. //fix bug 575 END
  257. }
  258. PropSheet_SetWizButtons( GetParent( hwnd ), PSWIZB_NEXT|PSWIZB_BACK );
  259. break;
  260. case PSN_WIZNEXT:
  261. // What did the user choose ??
  262. {
  263. TCHAR lpVal[ 128];
  264. int nItem = ListView_GetSelectionMark(hWndCSR);
  265. if (nItem != -1)
  266. {
  267. LVITEM lvItem;
  268. lvItem.mask = LVIF_TEXT;
  269. lvItem.iItem = nItem;
  270. lvItem.iSubItem = 1;
  271. lvItem.pszText = lpVal;
  272. lvItem.cchTextMax = 128;
  273. ListView_GetItem(hWndCSR, &lvItem);
  274. if (GetGlobalContext()->GetActivationMethod() == CONNECTION_PHONE)
  275. {
  276. GetGlobalContext()->SetCSRNumber(lpVal);
  277. }
  278. }
  279. else
  280. {
  281. LRMessageBox(hwnd, IDS_ERR_NOCOUNTRYSELECTED, 0);
  282. dwNextPage = IDD_DLG_COUNTRYREGION;
  283. bStatus = -1;
  284. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  285. break;
  286. }
  287. }
  288. if (GetGlobalContext()->GetActivationMethod() == CONNECTION_PHONE)
  289. {
  290. dwNextPage = GetGlobalContext()->GetEntryPoint();
  291. }
  292. else
  293. {
  294. dwNextPage = IDD_LICENSETYPE;
  295. }
  296. /*
  297. dwNextPage = IDD_DLG_COUNTRYREGION;
  298. switch( GetGlobalContext()->GetWizAction() )
  299. {
  300. case WIZACTION_REGISTERLS:
  301. case WIZACTION_CONTINUEREGISTERLS:
  302. dwNextPage = IDD_DLG_TELREG;
  303. break;
  304. case WIZACTION_REREGISTERLS:
  305. break;
  306. case WIZACTION_UNREGISTERLS:
  307. break;
  308. case WIZACTION_DOWNLOADLKP:
  309. break;
  310. }
  311. */ bStatus = -1;
  312. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  313. if (dwNextPage != IDD_DLG_COUNTRYREGION)
  314. {
  315. LRPush(IDD_DLG_COUNTRYREGION);
  316. }
  317. break;
  318. case PSN_WIZBACK:
  319. dwNextPage = LRPop();
  320. LRW_SETWINDOWLONG(hwnd, LRW_DWL_MSGRESULT, dwNextPage);
  321. bStatus = -1;
  322. break;
  323. default:
  324. bStatus = FALSE;
  325. break;
  326. }
  327. }
  328. break;
  329. default:
  330. bStatus = FALSE;
  331. break;
  332. }
  333. return bStatus;
  334. }