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
5.9 KiB

  1. // Copyright (c) 2001 Microsoft Corporation
  2. //
  3. // File: MediaInstallationUnit.cpp
  4. //
  5. // Synopsis: Defines a MediaInstallationUnit
  6. // This object has the knowledge for installing the
  7. // Streaming media service
  8. //
  9. // History: 02/06/2001 JeffJon Created
  10. #include "pch.h"
  11. #include "resource.h"
  12. #include "MediaInstallationUnit.h"
  13. // Finish page help
  14. static PCWSTR CYS_MEDIA_FINISH_PAGE_HELP = L"cys.chm::/media_server_role.htm";
  15. static PCWSTR CYS_MEDIA_MILESTONE_HELP = L"cys.chm::/media_server_role.htm#mediasrvsummary";
  16. static PCWSTR CYS_MEDIA_AFTER_FINISH_HELP = L"cys.chm::/media_server_role.htm#mediasrvcompletion";
  17. MediaInstallationUnit::MediaInstallationUnit() :
  18. InstallationUnit(
  19. IDS_MEDIA_SERVER_TYPE,
  20. IDS_MEDIA_SERVER_DESCRIPTION,
  21. IDS_MEDIA_FINISH_TITLE,
  22. IDS_MEDIA_FINISH_UNINSTALL_TITLE,
  23. IDS_MEDIA_FINISH_MESSAGE,
  24. IDS_MEDIA_INSTALL_FAILED,
  25. IDS_MEDIA_UNINSTALL_MESSAGE,
  26. IDS_MEDIA_UNINSTALL_FAILED,
  27. IDS_MEDIA_UNINSTALL_WARNING,
  28. IDS_MEDIA_UNINSTALL_CHECKBOX,
  29. CYS_MEDIA_FINISH_PAGE_HELP,
  30. CYS_MEDIA_MILESTONE_HELP,
  31. CYS_MEDIA_AFTER_FINISH_HELP,
  32. MEDIASERVER_SERVER)
  33. {
  34. LOG_CTOR(MediaInstallationUnit);
  35. }
  36. MediaInstallationUnit::~MediaInstallationUnit()
  37. {
  38. LOG_DTOR(MediaInstallationUnit);
  39. }
  40. InstallationReturnType
  41. MediaInstallationUnit::InstallService(HANDLE logfileHandle, HWND hwnd)
  42. {
  43. LOG_FUNCTION(MediaInstallationUnit::InstallService);
  44. // Log heading
  45. CYS_APPEND_LOG(String::load(IDS_LOG_MEDIA_HEADING));
  46. UpdateInstallationProgressText(hwnd, IDS_MEDIA_INSTALL_PROGRESS);
  47. String unattendFileText;
  48. String infFileText;
  49. unattendFileText += L"[Components]\n";
  50. unattendFileText += L"WMS=ON\n";
  51. unattendFileText += L"WMS_admin_mmc=ON\n";
  52. // NTRAID#NTBUG9-461170-2001/08/28-sburns
  53. // unattendFileText += L"WMS_Admin_asp=ON\n";
  54. unattendFileText += L"WMS_SERVER=ON\n";
  55. InstallationReturnType result = INSTALL_SUCCESS;
  56. bool ocmResult = InstallServiceWithOcManager(infFileText, unattendFileText);
  57. if (ocmResult &&
  58. IsServiceInstalled())
  59. {
  60. LOG(L"WMS was installed successfully");
  61. CYS_APPEND_LOG(String::load(IDS_LOG_SERVER_WMS_SUCCESS));
  62. }
  63. else
  64. {
  65. LOG(L"WMS was failed to install");
  66. CYS_APPEND_LOG(String::load(IDS_LOG_SERVER_WMS_FAILED));
  67. result = INSTALL_FAILURE;
  68. }
  69. LOG_INSTALL_RETURN(result);
  70. return result;
  71. }
  72. UnInstallReturnType
  73. MediaInstallationUnit::UnInstallService(HANDLE logfileHandle, HWND hwnd)
  74. {
  75. LOG_FUNCTION(MediaInstallationUnit::UnInstallService);
  76. UnInstallReturnType result = UNINSTALL_SUCCESS;
  77. UpdateInstallationProgressText(hwnd, IDS_MEDIA_UNINSTALL_PROGRESS);
  78. // Log heading
  79. CYS_APPEND_LOG(String::load(IDS_LOG_UNINSTALL_MEDIA_HEADING));
  80. String unattendFileText;
  81. String infFileText;
  82. unattendFileText += L"[Components]\n";
  83. unattendFileText += L"WMS=OFF\n";
  84. unattendFileText += L"WMS_admin_mmc=OFF\n";
  85. unattendFileText += L"WMS_SERVER=OFF\n";
  86. // NTRAID#NTBUG9-736557-2002/11/12-JeffJon
  87. // The uninstall of the Media Server could cause
  88. // an unexpected reboot if the Media Server MMC
  89. // is open and the user chooses not to close it
  90. // when the uninstall warns them. If the /w
  91. // switch is passed to sysocmgr.exe then it
  92. // will prompt the user before rebooting.
  93. String additionalArgs = L"/w";
  94. bool ocmResult =
  95. InstallServiceWithOcManager(
  96. infFileText,
  97. unattendFileText,
  98. additionalArgs);
  99. if (ocmResult &&
  100. !IsServiceInstalled())
  101. {
  102. LOG(L"WMS was uninstalled successfully");
  103. CYS_APPEND_LOG(String::load(IDS_LOG_UNINSTALL_SERVER_WMS_SUCCESS));
  104. }
  105. else
  106. {
  107. LOG(L"WMS was failed to uninstall");
  108. CYS_APPEND_LOG(String::load(IDS_LOG_UNINSTALL_SERVER_WMS_FAILED));
  109. result = UNINSTALL_FAILURE;
  110. }
  111. LOG_UNINSTALL_RETURN(result);
  112. return result;
  113. }
  114. bool
  115. MediaInstallationUnit::GetMilestoneText(String& message)
  116. {
  117. LOG_FUNCTION(MediaInstallationUnit::GetMilestoneText);
  118. message = String::load(IDS_MEDIA_FINISH_TEXT);
  119. LOG_BOOL(true);
  120. return true;
  121. }
  122. bool
  123. MediaInstallationUnit::GetUninstallMilestoneText(String& message)
  124. {
  125. LOG_FUNCTION(MediaInstallationUnit::GetUninstallMilestoneText);
  126. message = String::load(IDS_MEDIA_UNINSTALL_TEXT);
  127. LOG_BOOL(true);
  128. return true;
  129. }
  130. String
  131. MediaInstallationUnit::GetServiceDescription()
  132. {
  133. LOG_FUNCTION(MediaInstallationUnit::GetServiceDescription);
  134. unsigned int resourceID = static_cast<unsigned int>(-1);
  135. if (IsServiceInstalled())
  136. {
  137. resourceID = IDS_MEDIA_SERVER_DESCRIPTION_INSTALLED;
  138. }
  139. else
  140. {
  141. resourceID = descriptionID;
  142. }
  143. ASSERT(resourceID != static_cast<unsigned int>(-1));
  144. return String::load(resourceID);
  145. }
  146. void
  147. MediaInstallationUnit::ServerRoleLinkSelected(int linkIndex, HWND /*hwnd*/)
  148. {
  149. LOG_FUNCTION2(
  150. MediaInstallationUnit::ServerRoleLinkSelected,
  151. String::format(
  152. L"linkIndex = %1!d!",
  153. linkIndex));
  154. if (IsServiceInstalled())
  155. {
  156. ASSERT(linkIndex == 0);
  157. LaunchMYS();
  158. }
  159. else
  160. {
  161. ASSERT(linkIndex == 0);
  162. LOG(L"Showing configuration help");
  163. ShowHelp(CYS_MEDIA_FINISH_PAGE_HELP);
  164. }
  165. }
  166. void
  167. MediaInstallationUnit::FinishLinkSelected(int linkIndex, HWND /*hwnd*/)
  168. {
  169. LOG_FUNCTION2(
  170. MediaInstallationUnit::FinishLinkSelected,
  171. String::format(
  172. L"linkIndex = %1!d!",
  173. linkIndex));
  174. if (installing)
  175. {
  176. if (linkIndex == 0 &&
  177. IsServiceInstalled())
  178. {
  179. LOG("Showing after checklist");
  180. ShowHelp(CYS_MEDIA_AFTER_FINISH_HELP);
  181. }
  182. else
  183. {
  184. LOG(L"Showing configuration help");
  185. ShowHelp(CYS_MEDIA_FINISH_PAGE_HELP);
  186. }
  187. }
  188. else
  189. {
  190. }
  191. }