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.

303 lines
9.4 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1994 **
  4. //*********************************************************************
  5. //
  6. // MANUAL.CPP - Functions for manual options page
  7. //
  8. // HISTORY:
  9. //
  10. // 05/13/98 jeremys Created.
  11. //
  12. //*********************************************************************
  13. #include "pre.h"
  14. #include "icwextsn.h"
  15. #include "icwacct.h"
  16. extern UINT GetDlgIDFromIndex(UINT uPageIndex);
  17. extern BOOL g_bManualPath;
  18. extern BOOL g_bLanPath;
  19. const TCHAR c_szICWMan[] = TEXT("INETWIZ.EXE");
  20. const TCHAR c_szRegValICWCompleted[] = TEXT("Completed");
  21. // Run the manual wizard
  22. BOOL RunICWManProcess
  23. (
  24. void
  25. )
  26. {
  27. STARTUPINFO si;
  28. PROCESS_INFORMATION pi;
  29. MSG msg ;
  30. DWORD iWaitResult = 0;
  31. BOOL bRetVal = FALSE;
  32. memset(&pi, 0, sizeof(pi));
  33. memset(&si, 0, sizeof(si));
  34. if(CreateProcess(c_szICWMan,
  35. NULL,
  36. NULL,
  37. NULL,
  38. TRUE,
  39. 0,
  40. NULL,
  41. NULL,
  42. &si,
  43. &pi))
  44. {
  45. // wait for event or msgs. Dispatch msgs. Exit when event is signalled.
  46. while((iWaitResult=MsgWaitForMultipleObjects(1, &pi.hProcess, FALSE, INFINITE, QS_ALLINPUT))==(WAIT_OBJECT_0 + 1))
  47. {
  48. // read all of the messages in this next loop
  49. // removing each message as we read it
  50. while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  51. {
  52. // how to handle quit message?
  53. if (msg.message == WM_QUIT)
  54. {
  55. goto done;
  56. }
  57. else
  58. DispatchMessage(&msg);
  59. }
  60. }
  61. done:
  62. CloseHandle(pi.hThread);
  63. CloseHandle(pi.hProcess);
  64. }
  65. // See if ICWMAN completed, by checking the SmartStart Completed RegKey
  66. HKEY hkey;
  67. if ( RegOpenKeyEx(HKEY_CURRENT_USER,
  68. ICWSETTINGSPATH,
  69. 0,
  70. KEY_ALL_ACCESS,
  71. &hkey) == ERROR_SUCCESS)
  72. {
  73. DWORD dwType = REG_BINARY;
  74. DWORD dwValue = 0;
  75. DWORD cbValue = sizeof(DWORD);
  76. RegQueryValueEx(hkey,
  77. c_szRegValICWCompleted,
  78. NULL,
  79. &dwType,
  80. (LPBYTE) &dwValue,
  81. &cbValue);
  82. RegCloseKey(hkey);
  83. bRetVal = dwValue;
  84. }
  85. return(bRetVal);
  86. }
  87. /*******************************************************************
  88. NAME: ManualOptionsInitProc
  89. SYNOPSIS: Called when page is displayed
  90. ENTRY: hDlg - dialog window
  91. fFirstInit - TRUE if this is the first time the dialog
  92. is initialized, FALSE if this InitProc has been called
  93. before (e.g. went past this page and backed up)
  94. ********************************************************************/
  95. BOOL CALLBACK ManualOptionsInitProc
  96. (
  97. HWND hDlg,
  98. BOOL fFirstInit,
  99. UINT *puNextPage
  100. )
  101. {
  102. if (fFirstInit)
  103. {
  104. // If we are in modeless operation, then we need to
  105. // quit the wizard, and launch INETWIZ.EXE
  106. if (gpWizardState->cmnStateData.bOEMCustom)
  107. {
  108. ShowWindow(gpWizardState->cmnStateData.hWndApp,SW_HIDE);
  109. if (RunICWManProcess())
  110. {
  111. // Set the welcome state
  112. UpdateWelcomeRegSetting(TRUE);
  113. // Restore the desktop
  114. UndoDesktopChanges(g_hInstance);
  115. }
  116. gfQuitWizard = TRUE; // Quit the wizard
  117. return FALSE;
  118. }
  119. else
  120. {
  121. //BUGBUG -- SHOULD BE AUTO?
  122. // initialize radio buttons
  123. CheckDlgButton(hDlg,IDC_MANUAL_MODEM, BST_CHECKED);
  124. TCHAR* pszManualIntro = new TCHAR[MAX_MESSAGE_LEN * 3];
  125. if (pszManualIntro)
  126. {
  127. TCHAR szTemp[MAX_MESSAGE_LEN];
  128. LoadString(g_hInstance, IDS_MANUAL_INTRO1, pszManualIntro, MAX_MESSAGE_LEN * 3);
  129. LoadString(g_hInstance, IDS_MANUAL_INTRO2, szTemp, ARRAYSIZE(szTemp));
  130. lstrcat(pszManualIntro, szTemp);
  131. SetWindowText(GetDlgItem(hDlg, IDC_MANUAL_INTRO), pszManualIntro);
  132. delete pszManualIntro;
  133. }
  134. }
  135. }
  136. else
  137. {
  138. // If we are run from the Runonce with the smartreboot option, we need to
  139. // jump to the Manual wiz immediately because that was where we left the user
  140. // last time.
  141. if (g_bManualPath || g_bLanPath)
  142. {
  143. Button_SetCheck(GetDlgItem(hDlg, IDC_MANUAL_MODEM), g_bManualPath);
  144. Button_SetCheck(GetDlgItem(hDlg, IDC_MANUAL_LAN), !g_bManualPath);
  145. if (LoadInetCfgUI( hDlg,
  146. IDD_PAGE_MANUALOPTIONS,
  147. IDD_PAGE_END,
  148. IsDlgButtonChecked(hDlg, IDC_MANUAL_LAN) ? WIZ_HOST_ICW_LAN : WIZ_HOST_ICW_MPHONE))
  149. {
  150. if( DialogIDAlreadyInUse( g_uICWCONNUIFirst) )
  151. {
  152. // we're about to jump into the external apprentice, and we don't want
  153. // this page to show up in our history list
  154. *puNextPage = g_uICWCONNUIFirst;
  155. g_bAllowCancel = TRUE;
  156. if (gpINETCFGApprentice)
  157. gpINETCFGApprentice->SetStateDataFromExeToDll( &gpWizardState->cmnStateData);
  158. }
  159. }
  160. g_bManualPath = FALSE;
  161. g_bLanPath = FALSE;
  162. }
  163. }
  164. // if we've travelled through external apprentice pages,
  165. // it's easy for our current page pointer to get munged,
  166. // so reset it here for sanity's sake.
  167. gpWizardState->uCurrentPage = ORD_PAGE_MANUALOPTIONS;
  168. return TRUE;
  169. }
  170. /*******************************************************************
  171. NAME: ManualOptionsCmdProc
  172. SYNOPSIS: Called when a command is generated from page
  173. ENTRY: hDlg - dialog window
  174. wParam - wParam
  175. lParam - lParam
  176. EXIT: returns TRUE
  177. ********************************************************************/
  178. BOOL CALLBACK ManualOptionsCmdProc
  179. (
  180. HWND hDlg,
  181. WPARAM wParam,
  182. LPARAM lParam
  183. )
  184. {
  185. switch (GET_WM_COMMAND_CMD(wParam, lParam))
  186. {
  187. case BN_DBLCLK:
  188. switch (GET_WM_COMMAND_ID(wParam, lParam))
  189. {
  190. case IDC_MANUAL_MODEM:
  191. case IDC_MANUAL_LAN:
  192. {
  193. // somebody double-clicked a radio button
  194. // auto-advance to the next page
  195. PropSheet_PressButton(GetParent(hDlg), PSBTN_NEXT);
  196. break;
  197. }
  198. }
  199. break;
  200. }
  201. return TRUE;
  202. }
  203. /*******************************************************************
  204. NAME: ManualOptionsOKProc
  205. SYNOPSIS: Called when Next or Back btns pressed from page
  206. ENTRY: hDlg - dialog window
  207. fForward - TRUE if 'Next' was pressed, FALSE if 'Back'
  208. puNextPage - if 'Next' was pressed,
  209. proc can fill this in with next page to go to. This
  210. parameter is ingored if 'Back' was pressed.
  211. pfKeepHistory - page will not be kept in history if
  212. proc fills this in with FALSE.
  213. EXIT: returns TRUE to allow page to be turned, FALSE
  214. to keep the same page.
  215. ********************************************************************/
  216. BOOL CALLBACK ManualOptionsOKProc
  217. (
  218. HWND hDlg,
  219. BOOL fForward,
  220. UINT *puNextPage,
  221. BOOL *pfKeepHistory
  222. )
  223. {
  224. ASSERT(puNextPage);
  225. BOOL bRet = TRUE;
  226. if (fForward)
  227. {
  228. if( IsDlgButtonChecked(hDlg, IDC_MANUAL_MODEM) )
  229. {
  230. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_SMARTREBOOT_MANUAL;
  231. }
  232. else
  233. {
  234. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_SMARTREBOOT_LAN;
  235. }
  236. bRet = FALSE;
  237. // read radio button state
  238. *pfKeepHistory = FALSE;
  239. if (LoadInetCfgUI( hDlg,
  240. IDD_PAGE_MANUALOPTIONS,
  241. IDD_PAGE_END,
  242. IsDlgButtonChecked(hDlg, IDC_MANUAL_LAN) ? WIZ_HOST_ICW_LAN : WIZ_HOST_ICW_MPHONE))
  243. {
  244. if( DialogIDAlreadyInUse( g_uICWCONNUIFirst) )
  245. {
  246. // we're about to jump into the external apprentice, and we don't want
  247. // this page to show up in our history list
  248. bRet = TRUE;
  249. *puNextPage = g_uICWCONNUIFirst;
  250. g_bAllowCancel = TRUE;
  251. if (gpINETCFGApprentice)
  252. gpINETCFGApprentice->SetStateDataFromExeToDll( &gpWizardState->cmnStateData);
  253. }
  254. }
  255. }
  256. return bRet;
  257. }