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.

238 lines
6.3 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. FileQ.c
  6. Abstract:
  7. File queue routines for upgrade
  8. Author:
  9. Muhunthan Sivapragasam (MuhuntS) 22-Jan-1996
  10. Revision History:
  11. --*/
  12. #include "precomp.h"
  13. //
  14. // If the source disk is missing we will retry it 4 times waiting for
  15. // 3 seconds between every try
  16. //
  17. #define MISSING_MEDIA_RETRY_COUNT 4
  18. #define MISSING_MEDIA_RETRY_INTERVAL 3000
  19. typedef struct _FILE_QUEUE_CONTEXT {
  20. PVOID QueueContext;
  21. } FILE_QUEUE_CONTEXT, *PFILE_QUEUE_CONTEXT;
  22. UINT
  23. MyQueueCallback(
  24. IN PVOID QueueContext,
  25. IN UINT Notification,
  26. IN UINT_PTR Param1,
  27. IN UINT_PTR Param2
  28. )
  29. /*++
  30. Routine Description:
  31. File queue callback routine for the upgrade. We will not prompt the user
  32. for missing file. But we will retry few times before failing
  33. Arguments:
  34. QueueContext : Points to FILE_QUEUE_CONTEXT
  35. Notification : The event which is being notified
  36. Param1 : Depends on the notification
  37. Param2 : Depends on the notification
  38. Return Value:
  39. None
  40. --*/
  41. {
  42. PFILE_QUEUE_CONTEXT pFileQContext=(PFILE_QUEUE_CONTEXT)QueueContext;
  43. PSOURCE_MEDIA_W pSource;
  44. PFILEPATHS_W pFilePaths;
  45. switch (Notification) {
  46. case SPFILENOTIFY_COPYERROR:
  47. //
  48. // We know atleast pjlmon will be missing since it is copied
  49. // during textmode setup
  50. //
  51. pFilePaths = (PFILEPATHS_W) Param1;
  52. DebugMsg("Error %d copying %ws to %ws.",
  53. pFilePaths->Win32Error, pFilePaths->Source,
  54. pFilePaths->Target);
  55. return FILEOP_SKIP;
  56. case SPFILENOTIFY_NEEDMEDIA:
  57. pSource = (PSOURCE_MEDIA_W)Param1;
  58. //
  59. // Setup is going to add \i386 to the end. Tell it to look
  60. // right in the directory we give. Particularly needed for the
  61. // upgrade over the network case
  62. //
  63. if ( wcscmp(pSource->SourcePath, UpgradeData.pszSourceW) ) {
  64. wcscpy((LPWSTR)Param2, UpgradeData.pszSourceW);
  65. return FILEOP_NEWPATH;
  66. }
  67. DebugMsg("Error copying %ws from %ws.",
  68. pSource->SourceFile, pSource->SourcePath);
  69. return FILEOP_SKIP;
  70. }
  71. return SetupDefaultQueueCallbackW(pFileQContext->QueueContext,
  72. Notification,
  73. Param1,
  74. Param2);
  75. }
  76. BOOL
  77. InitFileCopyOnNT(
  78. IN HDEVINFO hDevInfo
  79. )
  80. /*++
  81. Routine Description:
  82. On NT we will call ntprint.dll via SetupDiCallClassInstaller api with the
  83. DI_NOVCP flag so that all the necessary printer driver files are queued
  84. and copied at the end.
  85. This sets the necessary queue etc before calling the class installer
  86. Arguments:
  87. hDevInfo : Handle to printer device info list.
  88. Return Value:
  89. TRUE on success. FALSE on error
  90. --*/
  91. {
  92. BOOL bRet = FALSE;
  93. HSPFILEQ CopyQueue;
  94. PFILE_QUEUE_CONTEXT pFileQContext;
  95. SP_DEVINSTALL_PARAMS_W DevInstallParams;
  96. //
  97. // Call the current device installation parameters
  98. //
  99. DevInstallParams.cbSize = sizeof(DevInstallParams);
  100. if ( !SetupDiGetDeviceInstallParamsW(hDevInfo,
  101. NULL,
  102. &DevInstallParams) )
  103. return FALSE;
  104. //
  105. // Set the parameters so that ntprint will just queue files and not commit
  106. // the file copy operations
  107. //
  108. if ( !(pFileQContext = AllocMem(sizeof(FILE_QUEUE_CONTEXT))) )
  109. goto Cleanup;
  110. pFileQContext->QueueContext = SetupInitDefaultQueueCallbackEx(
  111. INVALID_HANDLE_VALUE,
  112. INVALID_HANDLE_VALUE,
  113. 0,
  114. 0,
  115. NULL);
  116. DevInstallParams.FileQueue = SetupOpenFileQueue();
  117. DevInstallParams.InstallMsgHandlerContext = pFileQContext;
  118. DevInstallParams.InstallMsgHandler = MyQueueCallback;
  119. DevInstallParams.Flags |= DI_NOVCP;
  120. DevInstallParams.hwndParent = INVALID_HANDLE_VALUE;
  121. //
  122. // The files should be from the source dir
  123. //
  124. wcscpy(DevInstallParams.DriverPath, UpgradeData.pszSourceW);
  125. if ( DevInstallParams.FileQueue == INVALID_HANDLE_VALUE ||
  126. pFileQContext->QueueContext == NULL ||
  127. !SetupDiSetDeviceInstallParamsW(hDevInfo,
  128. NULL,
  129. &DevInstallParams) ) {
  130. if ( DevInstallParams.FileQueue != INVALID_HANDLE_VALUE )
  131. SetupCloseFileQueue(DevInstallParams.FileQueue);
  132. if ( pFileQContext->QueueContext )
  133. SetupTermDefaultQueueCallback(pFileQContext->QueueContext);
  134. } else {
  135. bRet = TRUE;
  136. }
  137. Cleanup:
  138. if ( !bRet )
  139. FreeMem(pFileQContext);
  140. return bRet;
  141. }
  142. BOOL
  143. CommitFileQueueToCopyFiles(
  144. IN HDEVINFO hDevInfo
  145. )
  146. /*++
  147. Routine Description:
  148. After calling ntprint for each printer driver to queue up the files this
  149. routine is called to commit the file queue and do the actual file copy
  150. operations
  151. Arguments:
  152. hDevInfo : Handle to printer device info list.
  153. Return Value:
  154. TRUE on success. FALSE on error
  155. --*/
  156. {
  157. BOOL bRet = FALSE;
  158. SP_DEVINSTALL_PARAMS_W DevInstallParams;
  159. PFILE_QUEUE_CONTEXT pFileQContext;
  160. DevInstallParams.cbSize = sizeof(DevInstallParams);
  161. if ( !SetupDiGetDeviceInstallParamsW(hDevInfo,
  162. NULL,
  163. &DevInstallParams) )
  164. return FALSE;
  165. pFileQContext = DevInstallParams.InstallMsgHandlerContext;
  166. bRet = SetupCommitFileQueueW(DevInstallParams.hwndParent,
  167. DevInstallParams.FileQueue,
  168. DevInstallParams.InstallMsgHandler,
  169. pFileQContext);
  170. SetupCloseFileQueue(DevInstallParams.FileQueue);
  171. SetupTermDefaultQueueCallback(pFileQContext->QueueContext);
  172. FreeMem(pFileQContext);
  173. return bRet;
  174. }