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.

416 lines
10 KiB

  1. <HTML>
  2. <HEAD>
  3. <META NAME="GENERATOR" Content="Microsoft Developer Studio">
  4. <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
  5. <OBJECT ID=pchealth classid=CLSID:FC7D9E02-3F9E-11d3-93C0-00C04F72DAF7></OBJECT>
  6. <TITLE>Document Title</TITLE>
  7. <SCRIPT ID=Script1 SRC="/scripts/Common.js"></SCRIPT>
  8. <SCRIPT LANGUAGE=javascript>
  9. var SHT_NOTACTIVE = 0x00000000;
  10. var SHT_QUERYING = 0x00000001;
  11. var SHT_QUERIED = 0x00000002;
  12. var SHT_COPYING_DB = 0x00000003;
  13. var SHT_COPYING_FILES = 0x00000004;
  14. var SHT_INSTALLING = 0x00000005;
  15. var SHT_INSTALLED = 0x00000006;
  16. var SHT_UNINSTALLING = 0x00000007;
  17. var SHT_UNINSTALLED = 0x00000008;
  18. var SHT_ABORTING = 0x00000009;
  19. var SHT_ABORTED = 0x0000000A;
  20. var SHT_FAILED = 0x0000000B;
  21. var g_db = pchealth.Database;
  22. var g_skuMachine = null;
  23. var g_collLocal = null;
  24. var g_sku = null;
  25. var g_collRemote = null;
  26. ////////////////////////////////////////////////////////////////////////////////
  27. function BuildPage()
  28. {
  29. if(g_db.HasWritePermissions) idAdminOnly.style.display = "";
  30. g_collLocal = g_db.InstalledSKUs;
  31. UpdateCurrentSKU();
  32. UpdateAvailableSKUs();
  33. }
  34. function UpdateCurrentSKU()
  35. {
  36. var str1;
  37. var str2;
  38. var userSKU = pchealth.UserSettings.CurrentSKU;
  39. var iPos;
  40. str1 = "<SELECT onchange=\"handler_CurrentSKU();\">";
  41. iPos = 1;
  42. for(var e = new Enumerator( g_collLocal ); !e.atEnd(); e.moveNext())
  43. {
  44. var sku = e.item();
  45. str2 = GetSKUDisplayName( sku );
  46. if(sku.IsMachineHelp)
  47. {
  48. g_skuMachine = sku;
  49. idSystem.innerText = str2;
  50. }
  51. str1 += GetOption( iPos++, (sku.SKU == userSKU.SKU && sku.Language == userSKU.Language), str2 );
  52. }
  53. str1 += "</SELECT>";
  54. idCurrentSKU.innerHTML = str1;
  55. }
  56. function UpdateAvailableSKUs()
  57. {
  58. var str1;
  59. var str2;
  60. var iPos;
  61. var fADMIN = g_db.HasWritePermissions;
  62. str1 = "<TABLE>";
  63. iPos = 1;
  64. for(var e = new Enumerator( g_collLocal ); !e.atEnd(); e.moveNext())
  65. {
  66. var sku = e.item();
  67. str2 = GetSKUDisplayName( sku );
  68. str1 += "<TR id=\"" + iPos++ + "\">";
  69. //
  70. // Name
  71. //
  72. str1 += "<TD>" + str2 + "</TD>";
  73. if(fADMIN)
  74. {
  75. //
  76. // Uninstall Button
  77. //
  78. str1 += "<TD><INPUT type=\"button\" value=\"Uninstall\" onClick=\"handler_Uninstall();\"";
  79. if(sku.CanUninstall == false) str1 += " DISABLED";
  80. str1 += "></TD>";
  81. //
  82. // Dial for export.
  83. //
  84. str1 += "<TD><SELECT id=idSelect onchange=\"handler_ExportSKU();\">";
  85. str1 += GetOption( 0, (sku.Exported == false), "Don't export" );
  86. str1 += GetOption( 1, (sku.Exported == true ), "Export" );
  87. str1 += "</SELECT></TD>";
  88. }
  89. //
  90. // Location.
  91. //
  92. str1 += "<TD>Available locally: " + sku.Location + "</TD>";
  93. str1 += "</TR>";
  94. }
  95. str1 += "</TABLE>";
  96. idLocalSKUs.innerHTML = str1;
  97. }
  98. function GenerateInstallEntry( sku, iPos )
  99. {
  100. var str = "<TR id=\"" + iPos + "\">";
  101. //
  102. // Name
  103. //
  104. str += "<TD>" + GetSKUDisplayName( sku ) + "</TD>";
  105. //
  106. // Install Button
  107. //
  108. str += "<TD><INPUT type=\"button\" value=\"Install\" onClick=\"button_installSKU();\"";
  109. if(sku.CanInstall == false) str += " DISABLED";
  110. str += "></TD>";
  111. if(sku.IsInstalled)
  112. {
  113. str += "<TD>Already installed</TD>";
  114. }
  115. str += "</TR>";
  116. return str;
  117. }
  118. function UpdateRemoteSKUs()
  119. {
  120. var str = "<TABLE>";
  121. var iPos = 1;
  122. for(var e = new Enumerator( g_collRemote ); !e.atEnd(); e.moveNext())
  123. {
  124. str += GenerateInstallEntry( e.item(), iPos++ );
  125. }
  126. str += "</TABLE>";
  127. idRemoteSKUs.innerHTML = str;
  128. }
  129. function UpdateDiskSKU()
  130. {
  131. var str = "<TABLE>";
  132. str += GenerateInstallEntry( g_sku, 0 );
  133. str += "</TABLE>";
  134. idRemoteSKUs.innerHTML = str;
  135. }
  136. ////////////////////////////////////////////////////////////////////////////////
  137. function handler_CurrentSKU()
  138. {
  139. var elem = event.srcElement;
  140. var sku = GetLocalSKU( elem.value );
  141. pchealth.UserSettings.Select( sku.SKU, sku.Language );
  142. UpdateCurrentSKU();
  143. }
  144. function handler_Uninstall()
  145. {
  146. var elem = GetRow();
  147. var sku = GetLocalSKU( elem.id );
  148. sku.onStatusChange = notify;
  149. sku.Uninstall();
  150. }
  151. function handler_ExportSKU()
  152. {
  153. var elem = GetRow();
  154. var sku = GetLocalSKU( elem.id );
  155. var field = elem.all.idShare;
  156. switch(event.srcElement.value)
  157. {
  158. case "0": sku.Exported = false; field.style.display = "none"; break;
  159. case "1": sku.Exported = true ; field.style.display = "" ; break;
  160. }
  161. }
  162. ////////////////////////////////////////////////////////////////////////////////
  163. function button_installFile()
  164. {
  165. if(g_sku) return;
  166. var file = idInstallFromFile.value;
  167. if(file == "")
  168. {
  169. pchealth.MessageBox( "Please specify a directory.", "OK" );
  170. idInstallFromFile.focus();
  171. return;
  172. }
  173. idRemoteSKUs.innerHTML = "";
  174. idServerDIV.style.display = "";
  175. g_sku = g_db.ConnectToFile( file, notifyForInstall );
  176. }
  177. function button_installServer()
  178. {
  179. var server = idInstallFromServer.value;
  180. if(server == "")
  181. {
  182. pchealth.MessageBox( "Please specify a server.", "OK" );
  183. idInstallFromServer.focus();
  184. return;
  185. }
  186. idRemoteSKUs.innerHTML = "";
  187. idServerDIV.style.display = "";
  188. g_collRemote = g_db.ConnectToServer( server, notifyForServer );
  189. }
  190. function button_installSKU()
  191. {
  192. var elem = GetRow();
  193. var sku = GetRemoteSKU( elem.id );
  194. sku.onStatusChange = notify;
  195. sku.Install();
  196. }
  197. ////////////////////////////////////////////////////////////////////////////////
  198. function notifyForServer( obj, status, hr, file )
  199. {
  200. UpdateStatus( obj, status, hr, file );
  201. if(status == SHT_QUERIED)
  202. {
  203. if(g_collRemote.Count == 0)
  204. {
  205. pchealth.MessageBox( "Sorry, the specified server doesn't export any SKU", "OK" );
  206. }
  207. else
  208. {
  209. UpdateRemoteSKUs();
  210. }
  211. }
  212. }
  213. function notifyForInstall( obj, status, hr, file )
  214. {
  215. UpdateStatus( obj, status, hr, file );
  216. if(status == SHT_QUERIED)
  217. {
  218. if(obj.IsInstalled == true)
  219. {
  220. pchealth.MessageBox( "The specified SKU is already installed.", "OK" );
  221. }
  222. else if(obj.CanInstall == false)
  223. {
  224. pchealth.MessageBox( "Sorry, you cannot install the specified SKU", "OK" );
  225. }
  226. else
  227. {
  228. UpdateDiskSKU();
  229. }
  230. }
  231. }
  232. function notify( obj, status, hr, file )
  233. {
  234. UpdateStatus( obj, status, hr, file );
  235. if(status == SHT_INSTALLED ||
  236. status == SHT_UNINSTALLED )
  237. {
  238. g_sku = null;
  239. g_collLocal = g_db.InstalledSKUs;
  240. UpdateCurrentSKU();
  241. UpdateAvailableSKUs();
  242. }
  243. }
  244. function UpdateStatus( obj, status, hr, file )
  245. {
  246. switch(status)
  247. {
  248. case 0x00000000 /*SHT_NOTACTIVE */: idStatus.innerText = "" ; break;
  249. case 0x00000001 /*SHT_QUERYING */: idStatus.innerText = "Collecting information..." ; break;
  250. case 0x00000002 /*SHT_QUERIED */: idStatus.innerText = "Ready to execute." ; break;
  251. case 0x00000003 /*SHT_COPYING_DB */: idStatus.innerText = "Copying the database..." ; break;
  252. case 0x00000004 /*SHT_COPYING_FILES*/: idStatus.innerText = "Copying file: " + file ; break;
  253. case 0x00000005 /*SHT_INSTALLING */: idStatus.innerText = "Finalizing installation..." ; break;
  254. case 0x00000006 /*SHT_INSTALLED */: idStatus.innerText = "Installation complete." ; break;
  255. case 0x00000007 /*SHT_UNINSTALLING */: idStatus.innerText = "Finalizing uninstallation..."; break;
  256. case 0x00000008 /*SHT_UNINSTALLED */: idStatus.innerText = "Uninstallation complete." ; break;
  257. case 0x00000009 /*SHT_ABORTING */: idStatus.innerText = "Aborting..." ; break;
  258. case 0x0000000A /*SHT_ABORTED */: idStatus.innerText = "Aborted." ; break;
  259. case 0x0000000B /*SHT_FAILED */: idStatus.innerText = "Operation failed: " + hr ; break;
  260. }
  261. }
  262. ////////////////////////////////////////////////////////////////////////////////
  263. function GetRow()
  264. {
  265. return Common_FindParent( event.srcElement, "TR" );
  266. }
  267. function GetLocalSKU( num )
  268. {
  269. return g_collLocal.Item( num );
  270. }
  271. function GetRemoteSKU( num )
  272. {
  273. return num == 0 ? g_sku : g_collRemote.Item( num );
  274. }
  275. function GetSKUDisplayName( sku )
  276. {
  277. return sku.SKU + "/" + sku.Language;
  278. }
  279. function GetOption( iPos, fSelected, text )
  280. {
  281. var str = "<OPTION VALUE=\"" + iPos + "\"";
  282. if(fSelected) str += " SELECTED";
  283. str += ">" + text;
  284. return str;
  285. }
  286. ////////////////////////////////////////////////////////////////////////////////
  287. </SCRIPT>
  288. </HEAD>
  289. <BODY onload="BuildPage()">
  290. This system is running <SPAN ID=idSystem style="font-weight: bold"></SPAN>.<P>
  291. The currently selected set of help topics is : <SPAN ID=idCurrentSKU></SPAN><P>
  292. <DIV id=idLocalDIV>
  293. <H2>Available SKUs:</H2>
  294. <DIV id=idLocalSKUs>
  295. </DIV>
  296. </DIV><BR>
  297. <DIV id=idAdminOnly style="display:none">
  298. <HR>
  299. You can import a set of help topics from disk: <INPUT id=idInstallFromFile size=40> <INPUT type="button" value="Query" onClick="button_installFile();">
  300. <HR>
  301. You can import a set of help topics from a server: <INPUT id=idInstallFromServer size=40><INPUT type="button" value="Query" onClick="button_installServer();">
  302. <DIV id=idServerDIV style="display:none">
  303. <H2>Exported SKUs:</H2>
  304. <DIV id=idRemoteSKUs>
  305. </DIV>
  306. </DIV>
  307. <BR>
  308. </DIV>
  309. <BR>
  310. <DIV ID=idStatus style="color: blue"></DIV>
  311. </BODY>
  312. </HTML>