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.

242 lines
7.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: I S D N W I Z . C P P
  7. //
  8. // Contents: Wizard pages and helper functions for the ISDN Wizard
  9. //
  10. // Notes:
  11. //
  12. // Author: jeffspr 15 Jun 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include <ncxbase.h>
  18. #include "isdncfg.h"
  19. #include "resource.h"
  20. #include "isdnshts.h"
  21. #include "isdncfg.h"
  22. #include "isdnwiz.h"
  23. #include "ncsetup.h"
  24. //+---------------------------------------------------------------------------
  25. //
  26. // Function: AddWizardPage
  27. //
  28. // Purpose: Adds a wizard page to the hardware wizard's new device
  29. // wizard structure
  30. //
  31. // Arguments:
  32. // ppsp [in] PropSheetPage structure of page to add
  33. // pndwd [inout] New device wizard structure to add pages to
  34. //
  35. // Returns: None
  36. //
  37. // Author: BillBe 24 Apr 1998
  38. //
  39. // Notes:
  40. //
  41. void inline
  42. AddWizardPage(PROPSHEETPAGE* ppsp, PSP_NEWDEVICEWIZARD_DATA pndwd)
  43. {
  44. // Don't add pages to the new deice wizard if there is no more room
  45. //
  46. if (pndwd->NumDynamicPages < MAX_INSTALLWIZARD_DYNAPAGES)
  47. {
  48. // Add the handle to the array
  49. pndwd->DynamicPages[pndwd->NumDynamicPages] =
  50. CreatePropertySheetPage(ppsp);
  51. // If we were successful, increment the count of pages
  52. //
  53. if (pndwd->DynamicPages[pndwd->NumDynamicPages])
  54. {
  55. pndwd->NumDynamicPages++;
  56. }
  57. }
  58. }
  59. //+---------------------------------------------------------------------------
  60. //
  61. // Function: FillInIsdnWizardPropertyPage
  62. //
  63. // Purpose: Fills in the given PROPSHEETPAGE structure
  64. //
  65. // Arguments:
  66. // psp [] PropSheetPage structure to fill
  67. // iDlgID [] DialogID to use.
  68. // pszTitle [] Title of the prop sheet page
  69. // pfnDlgProc [] Dialog Proc to use.
  70. // pPageData [] Pointer to structure for the individual page proc
  71. //
  72. // Returns: None
  73. //
  74. // Author: jeffspr 15 Jun 1997
  75. //
  76. // Notes:
  77. //
  78. VOID FillInIsdnWizardPropertyPage( HINSTANCE hInst,
  79. PROPSHEETPAGE * psp,
  80. INT iDlgID,
  81. PCWSTR pszTitle,
  82. DLGPROC pfnDlgProc,
  83. PCWSTR pszHeaderTitle,
  84. PCWSTR pszHeaderSubTitle,
  85. LPVOID pPageData)
  86. {
  87. // Initialize all of the psp parameters, including the ones that
  88. // we're not going to use.
  89. psp->dwSize = sizeof(PROPSHEETPAGE);
  90. psp->dwFlags = PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE |
  91. PSP_USETITLE;
  92. psp->hInstance = hInst;
  93. psp->pszTemplate = MAKEINTRESOURCE(iDlgID);
  94. psp->pszIcon = NULL;
  95. psp->pfnDlgProc = pfnDlgProc;
  96. psp->pszTitle = (PWSTR) pszTitle;
  97. psp->lParam = (LPARAM) pPageData;
  98. psp->pszHeaderTitle = (PWSTR) pszHeaderTitle;
  99. psp->pszHeaderSubTitle = (PWSTR) pszHeaderSubTitle;
  100. // Unused data
  101. //
  102. psp->pfnCallback = NULL;
  103. psp->pcRefParent = NULL;
  104. }
  105. struct WIZ_PAGE_INFO
  106. {
  107. UINT uiResId;
  108. UINT idsPageTitle;
  109. UINT idsPageDesc;
  110. DLGPROC pfnDlgProc;
  111. };
  112. static const WIZ_PAGE_INFO c_aPages[] =
  113. {
  114. {IDW_ISDN_SWITCH_TYPE,
  115. IDS_ISDN_SWITCH_TYPE_TITLE,
  116. IDS_ISDN_SWITCH_TYPE_SUBTITLE,
  117. IsdnSwitchTypeProc},
  118. {IDW_ISDN_SPIDS,
  119. IDS_ISDN_SPIDS_TITLE,
  120. IDS_ISDN_SPIDS_SUBTITLE,
  121. IsdnInfoPageProc},
  122. {IDW_ISDN_JAPAN,
  123. IDS_ISDN_JAPAN_TITLE,
  124. IDS_ISDN_JAPAN_SUBTITLE,
  125. IsdnInfoPageProc},
  126. {IDW_ISDN_EAZ,
  127. IDS_ISDN_EAZ_TITLE,
  128. IDS_ISDN_EAZ_SUBTITLE,
  129. IsdnInfoPageProc},
  130. {IDW_ISDN_MSN,
  131. IDS_ISDN_MSN_TITLE,
  132. IDS_ISDN_MSN_SUBTITLE,
  133. IsdnInfoPageProc},
  134. };
  135. static const INT c_cPages = celems(c_aPages);
  136. //+---------------------------------------------------------------------------
  137. //
  138. // Function: HrCreateIsdnWizardPages
  139. //
  140. // Purpose: Creates the various pages for the ISDN wizard
  141. //
  142. // Arguments:
  143. // hwndParent [in] Parent window
  144. // pisdnci [in] Configuration information as read from the
  145. // registry
  146. //
  147. // Returns: S_OK if success, Win32 error code otherwise
  148. //
  149. // Author: danielwe 11 Mar 1998
  150. //
  151. // Notes:
  152. //
  153. HRESULT HrAddIsdnWizardPagesToDevice(HDEVINFO hdi, PSP_DEVINFO_DATA pdeid,
  154. PISDN_CONFIG_INFO pisdnci)
  155. {
  156. HRESULT hr = S_OK;
  157. PROPSHEETPAGE psp = {0};
  158. HINSTANCE hInst = _Module.GetResourceInstance();
  159. INT iPage;
  160. AssertSz(pisdnci, "HrCreateIsdnWizardPages - the CONFIG_INFO struct is"
  161. " NULL");
  162. AssertSz(pisdnci->dwWanEndpoints, "No WanEndpoints? What does this adapter"
  163. " DO, anyway?");
  164. AssertSz(pisdnci->dwNumDChannels, "No D Channels. No Shoes. No Service");
  165. AssertSz(pisdnci->dwSwitchTypes, "Switch types was NULL. We need a list"
  166. ", eh?");
  167. SP_NEWDEVICEWIZARD_DATA ndwd;
  168. hr = HrSetupDiGetFixedSizeClassInstallParams(hdi, pdeid,
  169. reinterpret_cast<PSP_CLASSINSTALL_HEADER>(&ndwd), sizeof(ndwd));
  170. if (SUCCEEDED(hr))
  171. {
  172. PWSTR pszTitle = NULL;
  173. PWSTR pszDesc = NULL;
  174. hr = HrSetupDiGetDeviceName(hdi, pdeid, &pszDesc);
  175. if (SUCCEEDED(hr))
  176. {
  177. DwFormatStringWithLocalAlloc(SzLoadIds(IDS_ISDN_WIZARD_TITLE),
  178. &pszTitle, pszDesc);
  179. for (iPage = 0; iPage < c_cPages; iPage++)
  180. {
  181. PAGE_DATA * pPageData;
  182. pPageData = new PAGE_DATA;
  183. if (pPageData == NULL)
  184. {
  185. return(ERROR_NOT_ENOUGH_MEMORY);
  186. }
  187. pPageData->pisdnci = pisdnci;
  188. pPageData->idd = c_aPages[iPage].uiResId;
  189. // Fill in the propsheet page data
  190. //
  191. FillInIsdnWizardPropertyPage(hInst, &psp,
  192. c_aPages[iPage].uiResId,
  193. pszTitle,
  194. c_aPages[iPage].pfnDlgProc,
  195. SzLoadIds(c_aPages[iPage].idsPageTitle),
  196. SzLoadIds(c_aPages[iPage].idsPageDesc),
  197. pPageData);
  198. // The last page gets the job of cleaning up
  199. if ((c_cPages - 1) == iPage)
  200. {
  201. psp.dwFlags |= PSP_USECALLBACK;
  202. psp.pfnCallback = DestroyWizardData;
  203. }
  204. AddWizardPage(&psp, &ndwd);
  205. }
  206. LocalFree(pszTitle);
  207. MemFree(pszDesc);
  208. }
  209. hr = HrSetupDiSetClassInstallParams(hdi, pdeid,
  210. reinterpret_cast<PSP_CLASSINSTALL_HEADER>(&ndwd),
  211. sizeof(ndwd));
  212. }
  213. TraceError("HrAddIsdnWizardPagesToDevice", hr);
  214. return hr;
  215. }