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.

496 lines
10 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name :
  4. compinst.cxx
  5. Abstract:
  6. Base classes that are used to define the different
  7. instalations
  8. Author:
  9. Christopher Achille (cachille)
  10. Project:
  11. Internet Services Setup
  12. Revision History:
  13. April 2002: Created
  14. --*/
  15. #include "stdafx.h"
  16. #include "compinst.hxx"
  17. #include "webcomp.hxx"
  18. #include "ftpcomp.hxx"
  19. #include "complus.hxx"
  20. #include "wwwcmpts.hxx"
  21. #include "comncomp.hxx"
  22. // Constructor
  23. //
  24. // Initialize the Component List to NULL
  25. CComponentList::CComponentList()
  26. {
  27. DWORD i;
  28. for ( i = 0; i < COMPONENTS_MAXNUMBER; i++ )
  29. {
  30. // Initialize all to NULL
  31. m_pComponentList[i] = NULL;
  32. }
  33. m_dwNumberofComponents = 0;
  34. }
  35. // Destructor
  36. //
  37. // Cleanup all the classes we created
  38. CComponentList::~CComponentList()
  39. {
  40. DWORD i;
  41. for ( i = 0; i < COMPONENTS_MAXNUMBER; i++ )
  42. {
  43. if ( m_pComponentList[i] )
  44. {
  45. delete m_pComponentList[i];
  46. m_pComponentList[i] = NULL;
  47. }
  48. }
  49. }
  50. // FindComponent
  51. //
  52. // Find a particular component based on its name
  53. //
  54. CInstallComponent *
  55. CComponentList::FindComponent(LPCTSTR szComponentName)
  56. {
  57. DWORD i;
  58. for ( i = 0; i < GetNumberofComponents(); i++ )
  59. {
  60. if ( _tcsicmp( m_pComponentList[i]->GetName(), szComponentName ) == 0 )
  61. {
  62. return m_pComponentList[i];
  63. }
  64. }
  65. // Could not find
  66. return NULL;
  67. }
  68. // GetNumberofComponents
  69. //
  70. // Return the number of components that we have
  71. //
  72. DWORD
  73. CComponentList::GetNumberofComponents()
  74. {
  75. return m_dwNumberofComponents;
  76. }
  77. // Initialize
  78. //
  79. // Initialize the components that we have to install
  80. //
  81. BOOL
  82. CComponentList::Initialize()
  83. {
  84. DWORD dwCurrent;
  85. DWORD dwComponents = 0;
  86. BOOL bRet = TRUE;
  87. // Make sure we have not been called before, and we have no components
  88. ASSERT( GetNumberofComponents() == 0 );
  89. // Create the classes
  90. m_pComponentList[ dwComponents++ ] = new (CWebServiceInstallComponent);
  91. m_pComponentList[ dwComponents++ ] = new (CFtpServiceInstallComponent);
  92. m_pComponentList[ dwComponents++ ] = new (CCOMPlusInstallComponent);
  93. m_pComponentList[ dwComponents++ ] = new (CDTCInstallComponent);
  94. m_pComponentList[ dwComponents++ ] = new (CWWWASPInstallComponent);
  95. m_pComponentList[ dwComponents++ ] = new (CWWWIDCInstallComponent);
  96. m_pComponentList[ dwComponents++ ] = new (CWWWSSIInstallComponent);
  97. m_pComponentList[ dwComponents++ ] = new (CWWWWebDavInstallComponent);
  98. m_pComponentList[ dwComponents++ ] = new (CCommonInstallComponent);
  99. // Make sure that we have not gone past the array
  100. ASSERT( dwComponents < COMPONENTS_MAXNUMBER );
  101. // Check to make sure all classes were allocated.
  102. // Initialize in order of dependencies, ie. keeping scripts_vdir before web service
  103. for ( dwCurrent = 0; dwCurrent < dwComponents; dwCurrent++ )
  104. {
  105. if ( m_pComponentList[ dwCurrent ] == NULL )
  106. {
  107. // FAILED to allocate one of the classes
  108. bRet = FALSE;
  109. break;
  110. }
  111. }
  112. if ( !bRet )
  113. {
  114. // Failed, so lets cleanup
  115. for ( dwCurrent = 0; dwCurrent < dwComponents; dwCurrent++ )
  116. {
  117. if ( m_pComponentList[ dwCurrent ] )
  118. {
  119. delete m_pComponentList[ dwCurrent ];
  120. m_pComponentList[ dwCurrent ] = NULL;
  121. }
  122. }
  123. }
  124. else
  125. {
  126. m_dwNumberofComponents = dwComponents;
  127. }
  128. return bRet;
  129. }
  130. // PreInstall
  131. //
  132. // Call the PreInstall function for the appropriate component
  133. //
  134. BOOL
  135. CComponentList::PreInstall(LPCTSTR szComponentName)
  136. {
  137. CInstallComponent *pComponent = FindComponent( szComponentName );
  138. BOOL bRet = TRUE;
  139. if ( pComponent &&
  140. !( pComponent->PreInstall() )
  141. )
  142. {
  143. iisDebugOut((LOG_TYPE_ERROR, _T("PreInstall of Component '%s' FAILED\n"), szComponentName ));
  144. bRet = FALSE;
  145. }
  146. return bRet;
  147. }
  148. // Install
  149. //
  150. // Call the Install function for the appropriate component
  151. //
  152. BOOL
  153. CComponentList::Install(LPCTSTR szComponentName)
  154. {
  155. CInstallComponent *pComponent = FindComponent( szComponentName );
  156. BOOL bRet = TRUE;
  157. if ( pComponent &&
  158. !( pComponent->Install() )
  159. )
  160. {
  161. iisDebugOut((LOG_TYPE_ERROR, _T("Install of Component '%s' FAILED\n"), szComponentName ));
  162. bRet = FALSE;
  163. }
  164. return bRet;
  165. }
  166. // PostInstall
  167. //
  168. // Call the PostInstall function for the appropriate component
  169. //
  170. BOOL
  171. CComponentList::PostInstall(LPCTSTR szComponentName)
  172. {
  173. CInstallComponent *pComponent = FindComponent( szComponentName );
  174. BOOL bRet = TRUE;
  175. if ( pComponent &&
  176. !( pComponent->PostInstall() )
  177. )
  178. {
  179. iisDebugOut((LOG_TYPE_ERROR, _T("PostInstall of Component '%s' FAILED\n"), szComponentName ));
  180. bRet = FALSE;
  181. }
  182. return bRet;
  183. }
  184. // PreUnInstall
  185. //
  186. // Call the PreUnInstall function for the appropriate component
  187. //
  188. BOOL
  189. CComponentList::PreUnInstall(LPCTSTR szComponentName)
  190. {
  191. CInstallComponent *pComponent = FindComponent( szComponentName );
  192. BOOL bRet = TRUE;
  193. if ( pComponent &&
  194. !( pComponent->PreUnInstall() )
  195. )
  196. {
  197. iisDebugOut((LOG_TYPE_ERROR, _T("PreUnInstall of Component '%s' FAILED\n"), szComponentName ));
  198. bRet = FALSE;
  199. }
  200. return bRet;
  201. }
  202. // UnInstall
  203. //
  204. // Call the UnInstall function for the appropriate component
  205. //
  206. BOOL
  207. CComponentList::UnInstall(LPCTSTR szComponentName)
  208. {
  209. CInstallComponent *pComponent = FindComponent( szComponentName );
  210. BOOL bRet = TRUE;
  211. if ( pComponent &&
  212. !( pComponent->UnInstall() )
  213. )
  214. {
  215. iisDebugOut((LOG_TYPE_ERROR, _T("UnInstall of Component '%s' FAILED\n"), szComponentName ));
  216. bRet = FALSE;
  217. }
  218. return bRet;
  219. }
  220. // PostUnInstall
  221. //
  222. // Call the PostUnInstall function for the appropriate component
  223. //
  224. BOOL
  225. CComponentList::PostUnInstall(LPCTSTR szComponentName)
  226. {
  227. CInstallComponent *pComponent = FindComponent( szComponentName );
  228. BOOL bRet = TRUE;
  229. if ( pComponent &&
  230. !( pComponent->PostUnInstall() )
  231. )
  232. {
  233. iisDebugOut((LOG_TYPE_ERROR, _T("PostUnInstall of Component '%s' FAILED\n"), szComponentName ));
  234. bRet = FALSE;
  235. }
  236. return bRet;
  237. }
  238. // IsInstalled
  239. //
  240. // Is the component already installed or not
  241. //
  242. // Parameters:
  243. // szComponentName [in] - The name of the component to check
  244. // pbIsInstalled [out] - TRUE == it is installed
  245. // FALSE == it is not installed
  246. //
  247. // Return Values
  248. // TRUE - We do know if it was installed
  249. // FALSE - We don't know if it was installed
  250. //
  251. BOOL
  252. CComponentList::IsInstalled( LPCTSTR szComponentName, LPBOOL pbIsInstalled )
  253. {
  254. CInstallComponent *pComponent = FindComponent( szComponentName );
  255. BOOL bRet = FALSE;
  256. if ( pComponent )
  257. {
  258. bRet = pComponent->IsInstalled( pbIsInstalled );
  259. }
  260. return bRet;
  261. }
  262. // GetFriendlyName
  263. //
  264. // Call the GetFriendlyName function for the appropriate component
  265. //
  266. BOOL
  267. CComponentList::GetFriendlyName( LPCTSTR szComponentName, TSTR *pstrFriendlyName )
  268. {
  269. CInstallComponent *pComponent = FindComponent( szComponentName );
  270. BOOL bRet = FALSE;
  271. if ( pComponent )
  272. {
  273. bRet = pComponent->GetFriendlyName( pstrFriendlyName );
  274. }
  275. return bRet;
  276. }
  277. // GetSmallIcon
  278. //
  279. // Retrieve the small icon for the OCM component
  280. //
  281. BOOL
  282. CComponentList::GetSmallIcon( LPCTSTR szComponentName, HBITMAP *phIcon )
  283. {
  284. CInstallComponent *pComponent = FindComponent( szComponentName );
  285. BOOL bRet = FALSE;
  286. ASSERT( phIcon );
  287. if ( pComponent )
  288. {
  289. bRet = pComponent->GetSmallIcon( phIcon );
  290. }
  291. return bRet;
  292. }
  293. // Initialize
  294. //
  295. // Initialize the component for install.
  296. // The default function is to do nothing
  297. //
  298. BOOL
  299. CInstallComponent::Initialize()
  300. {
  301. return TRUE;
  302. }
  303. // PreInstall
  304. //
  305. // PreInstall work for component. This should theoretically be nothing, we should
  306. // do everything in the Install Part
  307. //
  308. BOOL
  309. CInstallComponent::PreInstall()
  310. {
  311. return TRUE;
  312. }
  313. // Install
  314. //
  315. // This does all the meat of the install work. Everything should be done inside of
  316. // here.
  317. //
  318. BOOL
  319. CInstallComponent::Install()
  320. {
  321. return TRUE;
  322. }
  323. // PostInstall
  324. //
  325. // This does any post install work. In a theoretical world this would not be needed,
  326. // but sometimes things need to be done after everything else
  327. //
  328. BOOL
  329. CInstallComponent::PostInstall()
  330. {
  331. return TRUE;
  332. }
  333. // PreUninstall
  334. //
  335. // Anything that needs to be done before any uninstalation occurs.
  336. //
  337. BOOL
  338. CInstallComponent::PreUnInstall()
  339. {
  340. return TRUE;
  341. }
  342. // Uninstall
  343. //
  344. // The core of the work to be done for uninstall.
  345. //
  346. BOOL
  347. CInstallComponent::UnInstall()
  348. {
  349. return TRUE;
  350. }
  351. // PostUnInstall
  352. //
  353. // Anything that needs to be done after all the other uninstall stuff is done.
  354. //
  355. BOOL
  356. CInstallComponent::PostUnInstall()
  357. {
  358. return TRUE;
  359. }
  360. // IsInstalled
  361. //
  362. // Is the component already installed or not
  363. //
  364. // Parameters:
  365. // pbIsInstalled [out] - TRUE == it is installed
  366. // FALSE == it is not installed
  367. //
  368. // Return Values
  369. // TRUE - We do know if it was installed
  370. // FALSE - We don't know if it was installed
  371. BOOL
  372. CInstallComponent::IsInstalled( LPBOOL pbIsInstalled )
  373. {
  374. // By default, we don't know if it is installed
  375. return FALSE;
  376. }
  377. // GetFriendlyName
  378. //
  379. // Get the friendly name for the application
  380. //
  381. // This willr eturn false if it does not know if,
  382. // or true if it does
  383. BOOL
  384. CInstallComponent::GetFriendlyName( TSTR *pstrFriendlyName )
  385. {
  386. return FALSE;
  387. }
  388. // GetSmallIcon
  389. //
  390. // Retrieve the Small Icon for this OCM component
  391. //
  392. // Parameters:
  393. // phIcon - The icon retrieved
  394. //
  395. // Return Values:
  396. // TRUE - Retrieve Successfully
  397. // FALSE - No we do not know what the icon looks like,
  398. // or we failed to retrieve it
  399. BOOL
  400. CInstallComponent::GetSmallIcon( HBITMAP *phIcon )
  401. {
  402. // By default, there is no icon
  403. return FALSE;
  404. }
  405. // IsUpgrade
  406. //
  407. // Is this an upgrade or a fresh install
  408. //
  409. // Return Values:
  410. // TRUE - Upgrade
  411. // FALSE - Fresh Install
  412. //
  413. BOOL
  414. CInstallComponent::IsUpgrade()
  415. {
  416. return g_pTheApp->IsUpgrade();
  417. }
  418. // GetUpdateVersion
  419. //
  420. // Is this is an upgrade, this is the version we are upgrading from
  421. //
  422. DWORD
  423. CInstallComponent::GetUpgradeVersion()
  424. {
  425. return g_pTheApp->GetUpgradeVersion();
  426. }