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.

490 lines
17 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // File: wizard.h
  4. //
  5. // Contents: defines the wizard specific private types and values
  6. //
  7. //----------------------------------------------------------------------------
  8. #pragma once
  9. #include "nsbase.h"
  10. #include "netconp.h"
  11. #include "resource.h"
  12. #include <syssetup.h>
  13. #include <windns.h>
  14. HRESULT HrShouldHaveHomeNetWizard();
  15. class CWizard;
  16. typedef VOID (CALLBACK FAR * PFNPAGECLEANPROC)(CWizard *, LPARAM);
  17. typedef list<GUID *> GUID_LIST;
  18. // struct ProviderList
  19. //
  20. // Purpose: Contains the GUID for the provider instance and the id's of the
  21. // display strings to use.
  22. //
  23. typedef struct _tagProviderList
  24. {
  25. const GUID * pguidProvider;
  26. UINT nBtnIdc;
  27. } ProviderList;
  28. extern BOOL bCallRasDlgEntry;
  29. //
  30. // Class: CWizardUiContext
  31. //
  32. // Purpose: To provide a means by which the wizard providers can find out
  33. // about the context in which they will run
  34. //
  35. class CWizardUiContext : public INetConnectionWizardUiContext
  36. {
  37. public:
  38. CWizardUiContext(PINTERNAL_SETUP_DATA pData)
  39. {
  40. m_pData = pData;
  41. m_dwSetupMode = pData->SetupMode;
  42. m_cRef = 1;
  43. m_pINetCfg = NULL;
  44. m_dwUnattendedMode = 0;
  45. }
  46. ~CWizardUiContext() {ReleaseObj(m_pINetCfg);}
  47. // *** IUnknown methods ***
  48. STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj);
  49. STDMETHOD_(ULONG,AddRef)();
  50. STDMETHOD_(ULONG,Release)();
  51. // *** INetConnectionWizardUiContext methods ***
  52. STDMETHODIMP_(DWORD)GetSetupMode() {return m_dwSetupMode;}
  53. STDMETHODIMP_(DWORD)GetProductType() {return m_pData->ProductType;}
  54. STDMETHODIMP_(DWORD)GetOperationFlags() {return m_pData->OperationFlags;}
  55. STDMETHODIMP_(DWORD)GetUnattendedModeFlags() {return m_dwUnattendedMode;}
  56. STDMETHODIMP GetINetCfg(INetCfg ** ppINetCfg);
  57. VOID ChangeSetupMode(DWORD dw) {m_dwSetupMode = dw;}
  58. VOID SetUnattendedMode(DWORD dw) {m_dwUnattendedMode = dw;}
  59. VOID SetINetCfg(INetCfg * pINetCfg)
  60. {
  61. m_pINetCfg = pINetCfg;
  62. AddRefObj(m_pINetCfg);
  63. }
  64. private:
  65. PINTERNAL_SETUP_DATA m_pData;
  66. DWORD m_dwSetupMode;
  67. DWORD m_dwUnattendedMode;
  68. ULONG m_cRef;
  69. INetCfg * m_pINetCfg;
  70. };
  71. //
  72. // Class: CWizProvider
  73. //
  74. // Purpose: Manage the wizard pages provided by a single connection provider.
  75. //
  76. class CWizProvider
  77. {
  78. public:
  79. NOTHROW static HRESULT HrCreate(ProviderList *, CWizProvider **, BOOL fDeferred);
  80. ~CWizProvider();
  81. ULONG ULPageCount() {return m_ulPageCnt;}
  82. HPROPSHEETPAGE* PHPropPages() {return m_rghPages;}
  83. NOTHROW HRESULT HrAddPages(INetConnectionWizardUiContext *);
  84. NOTHROW ULONG UlGetMaxPageCount(INetConnectionWizardUiContext *);
  85. VOID DeleteHPages();
  86. VOID XFerDeleteResponsibilities() {m_fDeletePages = FALSE;}
  87. INetConnectionWizardUi* PWizardUi() {return m_pWizardUi;}
  88. UINT GetBtnIdc() {return m_nBtnIdc;}
  89. HRESULT HrSpecifyAdapterGuid(GUID *);
  90. HRESULT HrGetLanInterface(INetLanConnectionWizardUi ** ppIntr);
  91. HRESULT HrCompleteDeferredLoad();
  92. private:
  93. CWizProvider(ProviderList *, BOOL);
  94. static BOOL FAddPropSheet(HPROPSHEETPAGE, LPARAM);
  95. private:
  96. ULONG m_ulPageCnt;
  97. ULONG m_ulPageBufferLen;
  98. ULONG m_ulMaxPageCount;
  99. HPROPSHEETPAGE* m_rghPages;
  100. BOOL m_fDeletePages;
  101. BOOL m_fDeferLoad;
  102. INetConnectionWizardUi* m_pWizardUi;
  103. GUID m_guidUiObject;
  104. UINT m_nBtnIdc;
  105. };
  106. // The wizard processes adapters, the list of adapters to process is
  107. // maintained by the wizard. The adapter list will contain adapters
  108. // which have been processed as well as adapters to be processed.
  109. // the AdapterEntry structure refers to a single adapter
  110. //
  111. typedef struct _tagAdapterEntry
  112. {
  113. GUID guidAdapter;
  114. BOOL fProcessed; // TRUE if a connection has been generated
  115. // for this adapter
  116. BOOL fNew; // TRUE if the adapter is being configured
  117. // for the first time.
  118. BOOL fVirtual;
  119. BOOL fHide; // True if the adapter should not
  120. // be displayed to the user
  121. } AdapterEntry;
  122. class CAdapterList
  123. {
  124. public:
  125. CAdapterList();
  126. ~CAdapterList() {EmptyList();}
  127. VOID EmptyList();
  128. VOID HideAllAdapters();
  129. VOID UnhideNewAdapters();
  130. BOOL FAdaptersInstalled() {return m_fAdaptersInstalled;}
  131. HRESULT HrAppendEntries(AdapterEntry * pae, ULONG cae);
  132. HRESULT HrCreateTypicalConnections(CWizard * pWizard);
  133. HRESULT HrQueryUnboundAdapters(CWizard * pWizard);
  134. static HRESULT HrQueryLanAdapters(INetCfg * pnc, CAdapterList * pAL, CWizard *pWizard);
  135. AdapterEntry * PAE_Next();
  136. AdapterEntry * PAE_Prev();
  137. AdapterEntry * PAE_Current();
  138. GUID * NextAdapter();
  139. GUID * PrevAdapter();
  140. GUID * CurrentAdapter();
  141. private:
  142. AdapterEntry * m_prgAdapters;
  143. LONG m_clAdapters; // Count of adapters in the array
  144. LONG m_lBufSize; // Total available slots in the array
  145. LONG m_lIdx; // Current adapter index (or -1)
  146. BOOL m_fAdaptersInstalled; // Adapters exist on the machine
  147. // regardless of whether any need
  148. // to be processed.
  149. };
  150. typedef enum {NWPD_FORWARD, NWPD_BACKWARD} PAGEDIRECTION;
  151. //
  152. // Class: CWizard
  153. //
  154. // Purpose: Manage the wizard pages provided by all connection providers.
  155. //
  156. class CWizard
  157. {
  158. private:
  159. typedef struct _tagPageData
  160. {
  161. LPARAM ulId;
  162. HPROPSHEETPAGE hPage;
  163. LPARAM lParam;
  164. PAGEDIRECTION PageDirection;
  165. UINT PageOrigin;
  166. UINT PageOriginIDC;
  167. PFNPAGECLEANPROC pfn;
  168. } PageData;
  169. public:
  170. NOTHROW static HRESULT HrCreate(CWizard **, BOOL, PINTERNAL_SETUP_DATA, BOOL);
  171. ~CWizard();
  172. ULONG UlProviderCount() {return m_ulWizProviderCnt;}
  173. CWizProvider * PWizProviders(ULONG ulIdx)
  174. {return ((ulIdx >= m_ulWizProviderCnt) ?
  175. NULL : m_rgpWizProviders[ulIdx]);}
  176. VOID SetCurrentProvider(ULONG ulIdx);
  177. CWizProvider * GetCurrentProvider();
  178. CWizProvider * GetProviderN(ULONG ulIdx);
  179. BOOL FProviderChanged() {return m_fProviderChanged;}
  180. VOID ClearProviderChanged() { m_fProviderChanged = FALSE; }
  181. CWizardUiContext * GetUiContext() {return m_pUiContext;}
  182. VOID CacheConnection(INetConnection * pConn);
  183. INetConnection * GetCachedConnection() {return m_pConn;}
  184. VOID LoadWizProviders(ULONG, ProviderList *);
  185. HRESULT HrCreateWizProviderPages(BOOL, UINT *);
  186. VOID AppendProviderPages(HPROPSHEETPAGE *pahpsp, UINT *pcPages);
  187. HPROPSHEETPAGE GetPageHandle(LPARAM ulId);
  188. LPARAM GetPageData(LPARAM ulId);
  189. VOID SetPageData(LPARAM ulId, LPARAM lParam);
  190. LPARAM GetPageOrigin(LPARAM ulId, UINT *pOriginIDC);
  191. VOID SetPageOrigin(LPARAM ulId, UINT uiOrigin, UINT uiOriginIDC);
  192. UINT GetPageIndexFromIID(LPARAM ulId);
  193. UINT GetPageIndexFromHPage(HPROPSHEETPAGE hPage);
  194. PAGEDIRECTION GetPageDirection(LPARAM ulId);
  195. VOID SetPageDirection(LPARAM ulId, PAGEDIRECTION PageDirection);
  196. VOID RegisterPage(LPARAM, HPROPSHEETPAGE,
  197. PFNPAGECLEANPROC, LPARAM);
  198. VOID DisableUnattended() {m_dwOperationFlags &= ~SETUPOPER_BATCH;}
  199. DWORD OperationFlags() {return m_dwOperationFlags;}
  200. PINTERNAL_SETUP_DATA PSetupData() {return m_pSetupData;}
  201. VOID ChangeSetupMode(DWORD dw)
  202. {AssertH(m_pUiContext);
  203. m_pUiContext->ChangeSetupMode(dw);}
  204. VOID SetUnattendedMode(UM_MODE UMMode) {m_UMMode = UMMode;
  205. AssertH(m_pUiContext);
  206. m_pUiContext->SetUnattendedMode(UMMode);}
  207. UM_MODE GetUnattendedMode() {return m_UMMode;}
  208. INetCfg * PNetCfg() {return m_pNetCfg;}
  209. VOID SetNetCfg(INetCfg *p);
  210. VOID SetExitNoReturn() {m_fExitNoReturn = TRUE;}
  211. BOOL FExitNoReturn() {return m_fExitNoReturn;}
  212. VOID SetCoUninit(BOOL f) {m_fCoUninit = f;}
  213. BOOL FCoUninit() {return m_fCoUninit;}
  214. BOOL FDeferredProviderLoad() {return m_fDeferredProviderLoad;}
  215. DWORD GetFirstPage() {return m_dwFirstPage;}
  216. VOID SetFirstPage(DWORD dwFirstPage) {m_dwFirstPage = dwFirstPage;}
  217. BOOL FProcessLanPages() {return m_fLanPages;}
  218. CAdapterList * PAdapterQueue() {return &m_Adapters;}
  219. VOID LoadAndInsertDeferredProviderPages(HWND, UINT);
  220. // Should this be a NetConfig wide available function?
  221. inline BOOL CompareCLSID (const CLSID& x, const CLSID& y)
  222. {
  223. return( (x.Data1 == y.Data1) &&
  224. (x.Data2 == y.Data2) &&
  225. (x.Data3 == y.Data3) &&
  226. ! (memcmp(x.Data4 , y.Data4, sizeof(x.Data4))));
  227. }
  228. private:
  229. CWizard(BOOL, PINTERNAL_SETUP_DATA pData, BOOL);
  230. NOTHROW HRESULT HrAddProvider(ProviderList *);
  231. VOID DeferredLoadComplete() {m_fDeferredProviderLoad = FALSE;}
  232. private:
  233. enum {m_eMaxProviders=6}; // Represents both max providers and the
  234. // max # of guard pages we'll need
  235. enum {m_eMaxInternalPages=MAX_NET_PAGES};
  236. BOOL m_fLanPages;
  237. BOOL m_fExitNoReturn;
  238. BOOL m_fCoUninit;
  239. BOOL m_fDeferredProviderLoad;
  240. BOOL m_fProviderChanged;
  241. DWORD m_dwFirstPage;
  242. INetCfg * m_pNetCfg;
  243. CWizardUiContext * m_pUiContext;
  244. INetConnection * m_pConn;
  245. PINTERNAL_SETUP_DATA m_pSetupData;
  246. DWORD m_dwOperationFlags;
  247. UM_MODE m_UMMode;
  248. ULONG m_ulCurProvider;
  249. ULONG m_ulWizProviderCnt;
  250. CWizProvider * m_rgpWizProviders[m_eMaxProviders];
  251. ULONG m_ulPageDataCnt;
  252. ULONG m_ulPageDataMRU;
  253. PageData m_rgPageData[m_eMaxInternalPages + m_eMaxProviders];
  254. public:
  255. // This is exposed by PAdapterQueue, so there is no use pretending its
  256. // private.
  257. //
  258. CAdapterList m_Adapters;
  259. };
  260. struct InitThreadParam
  261. {
  262. HWND hwndDlg;
  263. CWizard* pWizard;
  264. };
  265. struct UpgradeData
  266. {
  267. BOOL fProcessed;
  268. HFONT hBoldFont;
  269. UINT nCurrentCap;
  270. };
  271. //**********************//
  272. //**********************//
  273. // Inline Functions //
  274. //**********************//
  275. //**********************//
  276. inline VOID CWizard::CacheConnection(INetConnection * pConn)
  277. {
  278. ReleaseObj(m_pConn);
  279. m_pConn = pConn;
  280. }
  281. inline VOID CWizard::SetNetCfg(INetCfg *p)
  282. {
  283. AssertH(NULL == m_pNetCfg);
  284. AssertH(NULL != p);
  285. m_pNetCfg = p;
  286. if (m_pUiContext)
  287. {
  288. m_pUiContext->SetINetCfg(m_pNetCfg);
  289. }
  290. }
  291. inline VOID CWizard::SetCurrentProvider(ULONG ulIdx)
  292. {
  293. AssertH(ulIdx < m_ulWizProviderCnt);
  294. if (m_ulCurProvider != ulIdx)
  295. {
  296. m_fProviderChanged = TRUE;
  297. }
  298. m_ulCurProvider = ulIdx;
  299. }
  300. inline CWizProvider * CWizard::GetCurrentProvider()
  301. {
  302. AssertH(m_ulCurProvider < m_ulWizProviderCnt);
  303. return m_rgpWizProviders[m_ulCurProvider];
  304. }
  305. inline CWizProvider * CWizard::GetProviderN(ULONG ulIdx)
  306. {
  307. AssertH(ulIdx < m_ulWizProviderCnt);
  308. return m_rgpWizProviders[ulIdx];
  309. }
  310. inline BOOL IsPostInstall(CWizard *pWizard)
  311. {
  312. AssertH(NULL != pWizard);
  313. return (pWizard->OperationFlags() & SETUPOPER_POSTSYSINSTALL);
  314. }
  315. inline BOOL IsUnattended(CWizard *pWizard)
  316. {
  317. AssertH(NULL != pWizard);
  318. return (pWizard->OperationFlags() & SETUPOPER_BATCH);
  319. }
  320. inline BOOL IsFreshInstall(CWizard *pWizard)
  321. {
  322. AssertH(NULL != pWizard);
  323. return (!(pWizard->OperationFlags() & (SETUPOPER_NTUPGRADE | SETUPOPER_POSTSYSINSTALL)));
  324. }
  325. inline BOOL IsUpgrade(CWizard *pWizard)
  326. {
  327. AssertH(NULL != pWizard);
  328. return (pWizard->OperationFlags() & SETUPOPER_NTUPGRADE);
  329. }
  330. inline DWORD ProductType(CWizard *pWizard)
  331. {
  332. AssertH(NULL != pWizard);
  333. AssertH(NULL != pWizard->PSetupData());
  334. return ((pWizard->PSetupData())->ProductType);
  335. }
  336. inline DWORD SetupMode(CWizard *pWizard)
  337. {
  338. AssertH(NULL != pWizard);
  339. AssertH(NULL != pWizard->PSetupData());
  340. return ((pWizard->PSetupData())->SetupMode);
  341. }
  342. //****************************//
  343. //****************************//
  344. // Page Specific Entry Points //
  345. //****************************//
  346. //****************************//
  347. HRESULT HrCreateMainPage(CWizard *, PINTERNAL_SETUP_DATA, BOOL, UINT *);
  348. HRESULT HrCreateConnectPage(CWizard *, PINTERNAL_SETUP_DATA, BOOL, UINT *);
  349. HRESULT HrCreateAdvancedPage(CWizard *, PINTERNAL_SETUP_DATA, BOOL, UINT *);
  350. HRESULT HrCreateISPPage(CWizard *, PINTERNAL_SETUP_DATA, BOOL, UINT *);
  351. HRESULT HrCreateInternetPage(CWizard *, PINTERNAL_SETUP_DATA, BOOL, UINT *);
  352. HRESULT HrCreateMainIntroPage(CWizard *, PINTERNAL_SETUP_DATA, BOOL, UINT *);
  353. HRESULT HrCreateExitPage(CWizard *, PINTERNAL_SETUP_DATA, BOOL, UINT *);
  354. HRESULT HrCreateFinishPage(CWizard *, PINTERNAL_SETUP_DATA, BOOL, UINT *);
  355. HRESULT HrCreateJoinPage(CWizard *, PINTERNAL_SETUP_DATA, BOOL, UINT *);
  356. HRESULT HrCreateUpgradePage(CWizard *, PINTERNAL_SETUP_DATA, BOOL, UINT *);
  357. HRESULT HrCreateWelcomePage(CWizard *, PINTERNAL_SETUP_DATA, BOOL, UINT *);
  358. HRESULT HrCreateNetDevPage(CWizard *, PINTERNAL_SETUP_DATA, BOOL, UINT *);
  359. NOTHROW HRESULT HrCreateGuardPage(CWizard *, CWizProvider *);
  360. VOID AppendMainPage(CWizard *pWizard, HPROPSHEETPAGE* pahpsp, UINT *pcPages);
  361. VOID AppendConnectPage(CWizard *pWizard, HPROPSHEETPAGE* pahpsp, UINT *pcPages);
  362. VOID AppendAdvancedPage(CWizard *pWizard, HPROPSHEETPAGE* pahpsp, UINT *pcPages);
  363. VOID AppendISPPage(CWizard *pWizard, HPROPSHEETPAGE* pahpsp, UINT *pcPages);
  364. VOID AppendInternetPage(CWizard *pWizard, HPROPSHEETPAGE* pahpsp, UINT *pcPages);
  365. VOID AppendMainIntroPage(CWizard *pWizard, HPROPSHEETPAGE* pahpsp, UINT *pcPages);
  366. VOID AppendExitPage(CWizard *pWizard, HPROPSHEETPAGE* pahpsp, UINT *pcPages);
  367. VOID AppendFinishPage(CWizard *pWizard, HPROPSHEETPAGE* pahpsp, UINT *pcPages);
  368. VOID AppendJoinPage(CWizard *pWizard, HPROPSHEETPAGE* pahpsp, UINT *pcPages);
  369. VOID AppendUpgradePage(CWizard *pWizard, HPROPSHEETPAGE* pahpsp, UINT *pcPages);
  370. VOID AppendWelcomePage(CWizard *pWizard, HPROPSHEETPAGE* pahpsp, UINT *pcPages);
  371. VOID AppendNetDevPage(CWizard *pWizard, HPROPSHEETPAGE* pahpsp, UINT *pcPages);
  372. VOID AppendGuardPage(CWizard *pWizard, CWizProvider *pWizProvider,
  373. HPROPSHEETPAGE* pahpsp, UINT *pcPages);
  374. //********************************//
  375. //********************************//
  376. // Common Wizard Related Routines //
  377. //********************************//
  378. //********************************//
  379. EXTERN_C HRESULT WINAPI HrRunWizard(HWND hwnd, BOOL fPnpAddAdapter, INetConnection ** ppConn, DWORD dwFirstPage);
  380. EXTERN_C INT WINAPI StartNCW( HWND hwndOwner, HINSTANCE hInstance, PTSTR pszParms, INT nShow );
  381. VOID NetDevRetrieveInfo(CWizard * pWizard);
  382. VOID GenerateUniqueConnectionName(REFGUID guidAdapter, tstring * pstr, CWizProvider * pWizProvider);
  383. void JoinDefaultWorkgroup(CWizard *pWizard, HWND hwndDlg);
  384. BOOL OnProcessNextAdapterPageNext(HWND hwndDlg, BOOL FOnActivate);
  385. BOOL OnProcessPrevAdapterPagePrev(HWND hwndDlg, UINT idd);
  386. HRESULT HrInitAndGetINetCfg(CWizard *pWizard);
  387. HRESULT HrCommitINetCfgChanges(HWND hwnd, CWizard * pWizard);
  388. BOOL IsSBS (VOID);
  389. BOOL IsMSClientInstalled(HWND hwnd, CWizard * pWizard);
  390. DNS_STATUS IsValidDomainName (HWND hwndDlg);
  391. HRESULT HrCreateTypicalConnections(CWizard * pWizard);
  392. VOID InstallDefaultNetworkingIfNeeded(CWizard * pWizard, DWORD dwInstallFlags);
  393. VOID SetupFonts(HWND hwnd, HFONT * pBoldFont, BOOL fLargeFont);
  394. VOID CenterWizard(HWND hwndDlg);
  395. VOID ReadAnswerFileSetupOptions(CWizard * pWizard);
  396. const UINT c_nMaxProgressRange = 100;
  397. VOID
  398. OnUpgradeUpdateProgressCap (
  399. HWND hwndDlg,
  400. CWizard* pWizard,
  401. UINT nNewCap);