<?xml version="1.0" encoding="utf-8"?>
<!-- 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. -->


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns:xse="http://schemas.microsoft.com/wix/2005/XmlSchemaExtension"
         xmlns:html="http://www.w3.org/1999/xhtml"
    targetNamespace="http://schemas.microsoft.com/wix/FirewallExtension"
              xmlns="http://schemas.microsoft.com/wix/FirewallExtension">
    <xs:annotation>
        <xs:documentation>
            The source code schema for the Windows Installer XML Toolset Firewall Extension.
        </xs:documentation>
    </xs:annotation>

    <xs:import namespace="http://schemas.microsoft.com/wix/2006/wi" />

    <xs:element name="FirewallException">
        <xs:annotation>
            <xs:documentation>
                Registers an exception for a program or a specific port and protocol in the Windows Firewall
                on Windows XP SP2, Windows Server 2003 SP1, and later. For more information about the Windows
                Firewall, see <html:a href="http://msdn.microsoft.com/en-us/library/aa364679.aspx">
                About Windows Firewall API</html:a>.
            </xs:documentation>
            <xs:appinfo>
                <xse:parent namespace="http://schemas.microsoft.com/wix/2006/wi" ref="Component" />
                <xse:parent namespace="http://schemas.microsoft.com/wix/2006/wi" ref="File" />
            </xs:appinfo>
        </xs:annotation>

        <xs:complexType>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>
                        Explicitly-listed remote addresses that this exception allows through the 
                        firewall.
                    </xs:documentation>
                </xs:annotation>
                <xs:element ref="RemoteAddress" />
            </xs:choice>

            <xs:attribute name="Id" type="xs:string" use="required">
                <xs:annotation>
                    <xs:documentation>
                        Unique ID of this firewall exception.
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>

            <xs:attribute name="Name" type="xs:string" use="required">
                <xs:annotation>
                    <xs:documentation>
                        Name of this firewall exception, visible to the user in the firewall 
                        control panel.
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>

            <xs:attribute name="Scope">
                <xs:annotation>
                    <xs:documentation>
                        The scope of this firewall exception, which indicates whether incoming
                        connections can come from any computer including those on the Internet
                        or only those on the local network subnet. To more precisely specify
                        allowed remote address, specify a custom scope using RemoteAddress 
                        child elements.
                    </xs:documentation>
                </xs:annotation>
                <xs:simpleType>
                    <xs:restriction base="xs:NMTOKEN">
                        <xs:enumeration value="any" />
                        <xs:enumeration value="localSubnet" />
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>

            <xs:attribute name="Port" type="xs:string">
                <xs:annotation>
                    <xs:documentation>
                        Port to allow through the firewall for this exception. 

                        If you use Port and also File or Program in the same 
                        FirewallException element, the exception will fail to install on 
                        Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to
                        ignore the resulting failure, but the exception will not be added.
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>

            <xs:attribute name="Protocol">
                <xs:annotation>
                    <xs:documentation>
                        IP protocol used for this firewall exception. If Port is defined, 
                        "tcp" is assumed if the protocol is not specified. 

                        If you use Protocol and also File or Program in the same 
                        FirewallException element, the exception will fail to install on 
                        Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to
                        ignore the resulting failure, but the exception will not be added.
                    </xs:documentation>
                </xs:annotation>
                <xs:simpleType>
                    <xs:restriction base="xs:NMTOKEN">
                        <xs:enumeration value="tcp" />
                        <xs:enumeration value="udp" />
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>

            <xs:attribute name="File" type="xs:string">
                <xs:annotation>
                    <xs:documentation>
                        Identifier of a file to be granted access to all incoming ports and 
                        protocols. If you use File, you cannot also use Program.

                        If you use File and also Port or Protocol in the same 
                        FirewallException element, the exception will fail to install on 
                        Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to
                        ignore the resulting failure, but the exception will not be added.
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>

            <xs:attribute name="Program" type="xs:string">
                <xs:annotation>
                    <xs:documentation>
                        Path to a target program to be granted access to all incoming ports and 
                        protocols. Note that this is a formatted field, so you can use [#fileId] 
                        syntax to refer to a file being installed. If you use Program, you cannot 
                        also use File.

                        If you use Program and also Port or Protocol in the same 
                        FirewallException element, the exception will fail to install on 
                        Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to
                        ignore the resulting failure, but the exception will not be added.
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>

            <xs:attribute name="IgnoreFailure" type="YesNoType">
                <xs:annotation>
                    <xs:documentation>
                        If "yes," failures to register this firewall exception will be silently 
                        ignored. If "no" (the default), failures will cause rollback.
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>

            <xs:attribute name="Profile">
              <xs:annotation>
                <xs:documentation>
                  Profile type for this firewall exception. Default is "all".
                </xs:documentation>
              </xs:annotation>
              <xs:simpleType>
                <xs:restriction base="xs:NMTOKEN">
                  <xs:enumeration value="domain" />
                  <xs:enumeration value="private" />
                  <xs:enumeration value="public" />
                  <xs:enumeration value="all" />
                </xs:restriction>
              </xs:simpleType>
            </xs:attribute>
            <xs:attribute name="Description" type="xs:string">
                <xs:annotation>
                    <xs:documentation>
                      Description for this firewall rule displayed in Windows Firewall manager in 
                      Windows Vista and later.
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>
        </xs:complexType>
    </xs:element>

    <xs:element name="RemoteAddress">
        <xs:annotation>
            <xs:documentation>
                A remote address to which the port or program can listen. Address formats vary 
                based on the version of Windows and Windows Firewall the program is being installed
                on. For Windows XP SP2 and Windows Server 2003 SP1, see
                <html:a href="http://msdn.microsoft.com/en-us/library/aa365270.aspx">
                    RemoteAddresses Property</html:a>.
                For Windows Vista and Windows Server 2008, see
                <html:a href="http://msdn.microsoft.com/en-us/library/aa365366.aspx">
                    RemoteAddresses Property</html:a>.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:simpleContent>
                <xs:extension base="xs:string">
                    <xs:annotation>
                        <xs:documentation>
                            A remote address.
                        </xs:documentation>
                    </xs:annotation>
                </xs:extension>
            </xs:simpleContent>
        </xs:complexType>
    </xs:element>

    <xs:simpleType name="YesNoType">
        <xs:annotation>
            <xs:documentation>Values of this type will either be "yes" or "no".</xs:documentation>
        </xs:annotation>
        <xs:restriction base='xs:NMTOKEN'>
            <xs:enumeration value="no"/>
            <xs:enumeration value="yes"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>
