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.

383 lines
11 KiB

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