| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 2 | |
| 3 | namespace WixToolset.Http |
| 4 | { |
| 5 | #if TODO_CONSIDER_DECOMPILER |
| 6 | using System; |
| 7 | using System.Collections; |
| 8 | using System.Diagnostics; |
| 9 | using System.Globalization; |
| 10 | using WixToolset.Data; |
| 11 | using WixToolset.Extensibility; |
| 12 | using Http = WixToolset.Extensions.Serialize.Http; |
| 13 | using Wix = WixToolset.Data.Serialize; |
| 14 | |
| 15 | /// <summary> |
| 16 | /// The decompiler for the WiX Toolset Http Extension. |
| 17 | /// </summary> |
| 18 | public sealed class HttpDecompiler : DecompilerExtension |
| 19 | { |
| 20 | /// <summary> |
| 21 | /// Creates a decompiler for Http Extension. |
| 22 | /// </summary> |
| 23 | public HttpDecompiler() |
| 24 | { |
| 25 | this.TableDefinitions = HttpExtensionData.GetExtensionTableDefinitions(); |
| 26 | } |
| 27 | |
| 28 | /// <summary> |
| 29 | /// Get the extensions library to be removed. |
| 30 | /// </summary> |
| 31 | /// <param name="tableDefinitions">Table definitions for library.</param> |
| 32 | /// <returns>Library to remove from decompiled output.</returns> |
| 33 | public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) |
| 34 | { |
| 35 | return HttpExtensionData.GetExtensionLibrary(tableDefinitions); |
| 36 | } |
| 37 | |
| 38 | /// <summary> |
| 39 | /// Decompiles an extension table. |
| 40 | /// </summary> |
| 41 | /// <param name="table">The table to decompile.</param> |
| 42 | public override void DecompileTable(Table table) |
| 43 | { |
| 44 | switch (table.Name) |
| 45 | { |
| 46 | case "WixHttpUrlReservation": |
| 47 | this.DecompileWixHttpUrlReservationTable(table); |
| 48 | break; |
| 49 | case "WixHttpUrlAce": |
| 50 | this.DecompileWixHttpUrlAceTable(table); |
| 51 | break; |
| 52 | default: |
| 53 | base.DecompileTable(table); |
| 54 | break; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | /// <summary> |
| 59 | /// Decompile the WixHttpUrlReservation table. |
| 60 | /// </summary> |
| 61 | /// <param name="table">The table to decompile.</param> |
| 62 | private void DecompileWixHttpUrlReservationTable(Table table) |
| 63 | { |
| 64 | foreach (Row row in table.Rows) |
| 65 | { |
| 66 | Http.UrlReservation urlReservation = new Http.UrlReservation(); |
| 67 | urlReservation.Id = (string)row[0]; |
| 68 | switch((int)row[1]) |
| 69 | { |
| 70 | case HttpConstants.heReplace: |
| 71 | default: |
| 72 | urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.replace; |
| 73 | break; |
| 74 | case HttpConstants.heIgnore: |
| 75 | urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.ignore; |
| 76 | break; |
| 77 | case HttpConstants.heFail: |
| 78 | urlReservation.HandleExisting = Http.UrlReservation.HandleExistingType.fail; |
| 79 | break; |
| 80 | } |
| 81 | urlReservation.Sddl = (string)row[2]; |
| 82 | urlReservation.Url = (string)row[3]; |
| 83 | |
| 84 | Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[4]); |
| 85 | if (null != component) |
| 86 | { |
| 87 | component.AddChild(urlReservation); |
| 88 | } |
| 89 | else |
| 90 | { |
| 91 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[2], "Component")); |
| 92 | } |
| 93 | this.Core.IndexElement(row, urlReservation); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | |
| 98 | /// <summary> |
| 99 | /// Decompile the WixHttpUrlAce table. |
| 100 | /// </summary> |
| 101 | /// <param name="table">The table to decompile.</param> |
| 102 | private void DecompileWixHttpUrlAceTable(Table table) |
| 103 | { |
| 104 | foreach (Row row in table.Rows) |
| 105 | { |
| 106 | Http.UrlAce urlace = new Http.UrlAce(); |
| 107 | urlace.Id = (string)row[0]; |
| 108 | urlace.SecurityPrincipal = (string)row[2]; |
| 109 | switch (Convert.ToInt32(row[3])) |
| 110 | { |
| 111 | case HttpConstants.GENERIC_ALL: |
| 112 | default: |
| 113 | urlace.Rights = Http.UrlAce.RightsType.all; |
| 114 | break; |
| 115 | case HttpConstants.GENERIC_EXECUTE: |
| 116 | urlace.Rights = Http.UrlAce.RightsType.register; |
| 117 | break; |
| 118 | case HttpConstants.GENERIC_WRITE: |
| 119 | urlace.Rights = Http.UrlAce.RightsType.@delegate; |
| 120 | break; |
| 121 | } |
| 122 | |
| 123 | string reservationId = (string)row[1]; |
| 124 | Http.UrlReservation urlReservation = (Http.UrlReservation)this.Core.GetIndexedElement("WixHttpUrlReservation", reservationId); |
| 125 | if (null != urlReservation) |
| 126 | { |
| 127 | urlReservation.AddChild(urlace); |
| 128 | } |
| 129 | else |
| 130 | { |
| 131 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, urlace.Id, "WixHttpUrlReservation_", reservationId, "WixHttpUrlReservation")); |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | #endif |
| 137 | } |