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.

274 lines
8.4 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. class.c
  5. Abstract:
  6. This file implements the modem co-class
  7. installer for fax.
  8. Environment:
  9. WIN32 User Mode
  10. Author:
  11. Wesley Witt (wesw) 31-Jul-1997
  12. --*/
  13. #include "wizard.h"
  14. #pragma hdrstop
  15. #if DBG
  16. typedef struct _DIF_DEBUG {
  17. DWORD DifValue;
  18. LPTSTR DifString;
  19. } DIF_DEBUG, *PDIF_DEBUG;
  20. DIF_DEBUG DifDebug[] =
  21. {
  22. { 0, TEXT("") }, // 0x00000000
  23. { DIF_SELECTDEVICE, TEXT("DIF_SELECTDEVICE") }, // 0x00000001
  24. { DIF_INSTALLDEVICE, TEXT("DIF_INSTALLDEVICE") }, // 0x00000002
  25. { DIF_ASSIGNRESOURCES, TEXT("DIF_ASSIGNRESOURCES") }, // 0x00000003
  26. { DIF_PROPERTIES, TEXT("DIF_PROPERTIES") }, // 0x00000004
  27. { DIF_REMOVE, TEXT("DIF_REMOVE") }, // 0x00000005
  28. { DIF_FIRSTTIMESETUP, TEXT("DIF_FIRSTTIMESETUP") }, // 0x00000006
  29. { DIF_FOUNDDEVICE, TEXT("DIF_FOUNDDEVICE") }, // 0x00000007
  30. { DIF_SELECTCLASSDRIVERS, TEXT("DIF_SELECTCLASSDRIVERS") }, // 0x00000008
  31. { DIF_VALIDATECLASSDRIVERS, TEXT("DIF_VALIDATECLASSDRIVERS") }, // 0x00000009
  32. { DIF_INSTALLCLASSDRIVERS, TEXT("DIF_INSTALLCLASSDRIVERS") }, // 0x0000000A
  33. { DIF_CALCDISKSPACE, TEXT("DIF_CALCDISKSPACE") }, // 0x0000000B
  34. { DIF_DESTROYPRIVATEDATA, TEXT("DIF_DESTROYPRIVATEDATA") }, // 0x0000000C
  35. { DIF_VALIDATEDRIVER, TEXT("DIF_VALIDATEDRIVER") }, // 0x0000000D
  36. { DIF_MOVEDEVICE, TEXT("DIF_MOVEDEVICE") }, // 0x0000000E
  37. { DIF_DETECT, TEXT("DIF_DETECT") }, // 0x0000000F
  38. { DIF_INSTALLWIZARD, TEXT("DIF_INSTALLWIZARD") }, // 0x00000010
  39. { DIF_DESTROYWIZARDDATA, TEXT("DIF_DESTROYWIZARDDATA") }, // 0x00000011
  40. { DIF_PROPERTYCHANGE, TEXT("DIF_PROPERTYCHANGE") }, // 0x00000012
  41. { DIF_ENABLECLASS, TEXT("DIF_ENABLECLASS") }, // 0x00000013
  42. { DIF_DETECTVERIFY, TEXT("DIF_DETECTVERIFY") }, // 0x00000014
  43. { DIF_INSTALLDEVICEFILES, TEXT("DIF_INSTALLDEVICEFILES") }, // 0x00000015
  44. { DIF_UNREMOVE, TEXT("DIF_UNREMOVE") }, // 0x00000016
  45. { DIF_SELECTBESTCOMPATDRV, TEXT("DIF_SELECTBESTCOMPATDRV") }, // 0x00000017
  46. { DIF_ALLOW_INSTALL, TEXT("DIF_ALLOW_INSTALL") }, // 0x00000018
  47. { DIF_REGISTERDEVICE, TEXT("DIF_REGISTERDEVICE") }, // 0x00000019
  48. { 0, TEXT("") }, // 0x0000001A
  49. { 0, TEXT("") }, // 0x0000001B
  50. { 0, TEXT("") }, // 0x0000001C
  51. { 0, TEXT("") }, // 0x0000001D
  52. { 0, TEXT("") }, // 0x0000001E
  53. { 0, TEXT("") }, // 0x0000001F
  54. { DIF_INSTALLINTERFACES, TEXT("DIF_INSTALLINTERFACES") }, // 0x00000020
  55. { DIF_DETECTCANCEL, TEXT("DIF_DETECTCANCEL") }, // 0x00000021
  56. { DIF_REGISTER_COINSTALLERS, TEXT("DIF_REGISTER_COINSTALLERS") }, // 0x00000022
  57. { 0, TEXT("") } // 0x00000023
  58. };
  59. #endif
  60. LRESULT
  61. FaxModemDlgProc(
  62. HWND hwnd,
  63. UINT message,
  64. WPARAM wParam,
  65. LPARAM lParam
  66. )
  67. {
  68. switch( message ) {
  69. case WM_INITDIALOG:
  70. break;
  71. case WM_COMMAND:
  72. switch( wParam ) {
  73. case IDCANCEL:
  74. EndDialog( hwnd, IDCANCEL );
  75. return TRUE;
  76. case IDOK:
  77. EndDialog( hwnd, IDOK );
  78. return TRUE;
  79. }
  80. break;
  81. }
  82. return FALSE;
  83. }
  84. DWORD
  85. CALLBACK
  86. FaxModemCoClassInstaller(
  87. IN DI_FUNCTION InstallFunction,
  88. IN HDEVINFO DeviceInfoSet,
  89. IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
  90. IN OUT PCOINSTALLER_CONTEXT_DATA Context
  91. )
  92. {
  93. DWORD rVal = NO_ERROR;
  94. HKEY hKey = INVALID_HANDLE_VALUE;
  95. LPTSTR FriendlyName = NULL;
  96. LPTSTR ModemAttachedTo = NULL;
  97. HANDLE hFile = NULL;
  98. TCHAR ComPortName[32];
  99. #if 0
  100. int DlgErr;
  101. #endif
  102. DebugPrint(( TEXT("FaxModemCoClassInstaller: processing %s request"), DifDebug[InstallFunction].DifString ));
  103. if (InstallFunction == DIF_FIRSTTIMESETUP) {
  104. NtGuiMode = TRUE;
  105. return 0;
  106. }
  107. if (InstallFunction == DIF_INSTALLDEVICE) {
  108. if (!Context->PostProcessing) {
  109. DebugPrint(( TEXT("FaxModemCoClassInstaller: pre-installation, waiting for post-installation call") ));
  110. return ERROR_DI_POSTPROCESSING_REQUIRED;
  111. }
  112. if (Context->InstallResult != NO_ERROR) {
  113. DebugPrint(( TEXT("FaxModemCoClassInstaller: previous error causing installation failure, 0x%08x"), Context->InstallResult ));
  114. return Context->InstallResult;
  115. }
  116. //
  117. // get the modem information
  118. //
  119. hKey = SetupDiOpenDevRegKey(
  120. DeviceInfoSet,
  121. DeviceInfoData,
  122. DICS_FLAG_GLOBAL,
  123. 0,
  124. DIREG_DRV,
  125. KEY_READ
  126. );
  127. if (hKey == INVALID_HANDLE_VALUE) {
  128. DebugPrint(( TEXT("FaxModemCoClassInstaller: SetupDiOpenDevRegKey failed") ));
  129. rVal = ERROR_GEN_FAILURE;
  130. goto fax_install_exit;
  131. }
  132. FriendlyName = GetRegistryString( hKey, TEXT("FriendlyName"), EMPTY_STRING );
  133. ModemAttachedTo = GetRegistryString( hKey, TEXT("AttachedTo"), EMPTY_STRING );
  134. RegCloseKey( hKey );
  135. //
  136. // open the com port that the modem is attached to
  137. //
  138. _stprintf( ComPortName, TEXT("\\\\.\\%s"), ModemAttachedTo );
  139. hFile = CreateFile(
  140. ComPortName,
  141. GENERIC_READ | GENERIC_WRITE,
  142. 0,
  143. NULL,
  144. OPEN_EXISTING,
  145. 0,
  146. NULL
  147. );
  148. if (hFile == INVALID_HANDLE_VALUE) {
  149. DebugPrint((
  150. TEXT("FaxModemCoClassInstaller: could not open the com port for modem [%s][%s], ec=%d"),
  151. FriendlyName,
  152. ModemAttachedTo,
  153. GetLastError()
  154. ));
  155. rVal = ERROR_GEN_FAILURE;
  156. goto fax_install_exit;
  157. }
  158. //
  159. // get the fax class for the modem, zero is data only
  160. //
  161. if (GetModemClass( hFile ) == 0) {
  162. DebugPrint((
  163. TEXT("FaxModemCoClassInstaller: modem is NOT a fax modem [%s][%s]"),
  164. FriendlyName,
  165. ModemAttachedTo
  166. ));
  167. CloseHandle( hFile );
  168. rVal = ERROR_GEN_FAILURE;
  169. goto fax_install_exit;
  170. }
  171. CloseHandle( hFile );
  172. //
  173. // the modem is a valid fax modem
  174. // ask the user if they want fax services
  175. //
  176. #if 0
  177. if (!NtGuiMode) {
  178. DlgErr = DialogBoxParam(
  179. FaxWizModuleHandle,
  180. MAKEINTRESOURCE(IDD_FAX_MODEM_INSTALL),
  181. NULL,
  182. FaxModemDlgProc,
  183. (LPARAM) 0
  184. );
  185. if (DlgErr == -1 || DlgErr == 0) {
  186. //
  187. // the user does not want fax services
  188. //
  189. DebugPrint((
  190. TEXT("FaxModemCoClassInstaller: user does not want fax service for modem [%s][%s]"),
  191. FriendlyName,
  192. ModemAttachedTo
  193. ));
  194. goto fax_install_exit;
  195. }
  196. }
  197. #endif
  198. if (!NtGuiMode) {
  199. //
  200. // create a fax printer
  201. //
  202. if (!CreateServerFaxPrinter( NULL, FAX_PRINTER_NAME )) {
  203. DebugPrint(( TEXT("CreateServerFaxPrinter() failed") ));
  204. }
  205. //
  206. // start the fax service
  207. //
  208. StartFaxService();
  209. //
  210. // create the program groups
  211. //
  212. CreateGroupItems( FALSE, NULL );
  213. }
  214. fax_install_exit:
  215. MemFree( FriendlyName );
  216. MemFree( ModemAttachedTo );
  217. return rVal;
  218. }
  219. return NO_ERROR;
  220. }