<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified"
           elementFormDefault="qualified">
    <xs:simpleType name="ActionType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="post" />
            <xs:enumeration value="get" />
            <xs:enumeration value="upload" />
            <xs:enumeration value="login" />
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="Bool">
        <xs:restriction base="xs:string">
            <xs:enumeration value="1"/>
            <xs:enumeration value="0"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="AuthorizeType">
        <xs:restriction base="xs:byte">
            <xs:enumeration value="0" />
            <xs:enumeration value="1" />
            <xs:enumeration value="2" />
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="ServerType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="file" />
            <xs:enumeration value="get" />
            <xs:enumeration value="image" />
            <xs:enumeration value="urlshortening" />
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="ServerTypes">
        <xs:restriction>
            <xs:simpleType>
                <xs:list>
                    <xs:simpleType>
                        <xs:restriction base="xs:token">
                            <xs:enumeration value="file"/>
                            <xs:enumeration value="image"/>
                            <xs:enumeration value="urlsshortening"/>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:list>
            </xs:simpleType>
            <xs:minLength value="1"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="AssignVarsType">
        <xs:restriction base="xs:string">
            <xs:pattern value="[A-z0-9_]+:\d+(;[A-z0-9_]+:\d+)*;?"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="MinVersionType">
        <xs:restriction base="xs:string">
            <xs:pattern value="\d+\.\d+\.\d+(\.\d+)?"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="CustomHeadersType">
        <xs:restriction base="xs:string">
            <!--<xs:pattern value="[A-z0-9_]+:(;[A-z0-9_]+:.+?)*;?"/>--> <!-- TODO: write correct regexp -->
        </xs:restriction>
    </xs:simpleType>
    <xs:element name="Servers">
        <xs:complexType>
            <xs:choice maxOccurs="unbounded" minOccurs="0">
                <xs:element name="Server" maxOccurs="unbounded" minOccurs="0">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="Actions" minOccurs="0">
                                <xs:complexType mixed="true">
                                    <xs:sequence>
                                        <xs:element name="Action" maxOccurs="unbounded" minOccurs="0">
                                            <xs:complexType mixed="true">
                                                <xs:sequence>
                                                    <xs:element name="RegExp" minOccurs="0">
                                                        <xs:complexType>
                                                            <xs:simpleContent>
                                                                <xs:extension base="xs:string">
                                                                    <xs:attribute type="xs:string" name="Pattern"
                                                                                  use="required"/>
                                                                    <xs:attribute type="AssignVarsType" name="AssignVars"
                                                                                  use="optional"/>
                                                                    <xs:attribute type="xs:byte" name="Required"
                                                                                  use="optional" default="1"/>
                                                                </xs:extension>
                                                            </xs:simpleContent>
                                                        </xs:complexType>
                                                    </xs:element>
                                                </xs:sequence>
                                                <xs:attribute type="ActionType" name="Type" use="optional"/>
                                                <xs:attribute type="xs:string" name="Url" use="optional"/>
                                                <xs:attribute type="xs:string" name="PostParams" use="optional"/>
                                                <xs:attribute type="Bool" name="OnlyOnce" use="optional"/>
                                                <xs:attribute type="xs:string" name="RegExp" use="optional"/>
                                                <xs:attribute type="xs:string" name="AssignVars" use="optional"/>
                                                <xs:attribute type="xs:anyURI" name="Referer" use="optional"/>
                                                <xs:attribute type="CustomHeadersType" name="CustomHeaders" use="optional"/>
                                                <xs:attribute type="xs:string" name="Description" use="optional"/>
                                            </xs:complexType>
                                        </xs:element>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                            <xs:element name="Result">
                                <xs:complexType>
                                    <xs:simpleContent>
                                        <xs:extension base="xs:string">
                                            <xs:attribute type="xs:string" name="ImageUrlTemplate" use="optional"/>
                                            <xs:attribute type="xs:string" name="ThumbUrlTemplate" use="optional"/>
                                            <xs:attribute type="xs:string" name="DeleteUrl" use="optional"/>
                                            <xs:attribute type="xs:string" name="DownloadUrlTemplate" use="optional"/>
                                            <xs:attribute type="xs:string" name="DownloadUrl" use="optional"/>
                                            <xs:attribute type="xs:string" name="DirectUrlTemplate" use="optional"/>
                                        </xs:extension>
                                    </xs:simpleContent>
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                        <xs:attribute type="xs:string" name="Name" use="required"/>
                        <xs:attribute type="xs:positiveInteger" name="MaxFileSize" use="optional"/>
                        <xs:attribute type="Bool" name="Debug" use="optional"/>
                        <xs:attribute type="AuthorizeType" name="Authorize" use="optional"/>
                        <xs:attribute type="xs:string" name="Plugin" use="optional"/>
                        <xs:attribute type="xs:positiveInteger" name="MaxThreads" use="optional"/>
                        <xs:attribute type="Bool" name="NeedPassword" use="optional"/>
                        <xs:attribute type="Bool" name="SupportsFolders" use="optional"/>
                        <xs:attribute type="xs:anyURI" name="RegistrationUrl" use="optional"/>
                        <xs:attribute type="xs:byte" name="FileHost" use="optional"/>
                        <xs:attribute type="ServerType" name="Type" use="optional"/>
                        <xs:attribute type="ServerTypes" name="Types" use="optional"/>
                    </xs:complexType>
                </xs:element>
                <xs:element name="Server2" maxOccurs="unbounded" minOccurs="0">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="Actions" minOccurs="0">
                                <xs:complexType mixed="true">
                                    <xs:sequence>
                                        <xs:element name="Action" maxOccurs="unbounded" minOccurs="0">
                                            <xs:complexType>
                                                <xs:simpleContent>
                                                    <xs:extension base="xs:string">
                                                        <xs:attribute type="ActionType" name="Type" use="optional"/>
                                                        <xs:attribute type="xs:string" name="Url" use="required"/>
                                                        <xs:attribute type="xs:string" name="RegExp" use="optional"/>
                                                        <xs:attribute type="AssignVarsType" name="AssignVars"
                                                                      use="optional"/>
                                                        <xs:attribute type="xs:string" name="PostParams"
                                                                      use="optional"/>
                                                        <xs:attribute type="xs:anyURI" name="Referer" use="optional"/>
                                                        <xs:attribute type="CustomHeadersType" name="CustomHeaders" use="optional"/>
                                                    </xs:extension>
                                                </xs:simpleContent>
                                            </xs:complexType>
                                        </xs:element>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                            <xs:element name="Result">
                                <xs:complexType>
                                    <xs:simpleContent>
                                        <xs:extension base="xs:string">
                                            <xs:attribute type="xs:string" name="DirectUrlTemplate" use="optional"/>
                                            <xs:attribute type="xs:string" name="ImageUrlTemplate" use="optional"/>
                                            <xs:attribute type="xs:string" name="ThumbUrlTemplate" use="optional"/>
                                            <xs:attribute type="xs:string" name="ViewUrlTemplate" use="optional"/>
                                        </xs:extension>
                                    </xs:simpleContent>
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                        <xs:attribute type="xs:string" name="Name" use="required"/>
                        <xs:attribute type="xs:positiveInteger" name="MaxFileSize" use="optional"/>
                        <xs:attribute type="Bool" name="Debug" use="optional"/>
                        <xs:attribute type="AuthorizeType" name="Authorize" use="optional"/>
                        <xs:attribute type="Bool" name="SupportsFolders" use="optional"/>
                        <xs:attribute type="xs:anyURI" name="RegistrationUrl" use="optional"/>
                        <xs:attribute type="ServerType" name="Type" use="optional"/>
                        <xs:attribute type="ServerTypes" name="Types" use="optional"/>
                        <xs:attribute type="xs:string" name="FileHost" use="optional"/>
                        <xs:attribute type="xs:string" name="Plugin" use="optional"/>
                        <xs:attribute type="xs:positiveInteger" name="MaxThreads" use="optional"/>
                        <xs:attribute type="Bool" name="NeedPassword" use="optional" default="0"/>
                    </xs:complexType>
                </xs:element>
                <xs:element name="Server3" maxOccurs="unbounded" minOccurs="0">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="Actions" minOccurs="0">
                                <xs:complexType mixed="true">
                                    <xs:sequence>
                                        <xs:element name="Action" maxOccurs="unbounded" minOccurs="0">
                                            <xs:complexType mixed="true">
                                                <xs:sequence>
                                                    <xs:element name="RegExp" minOccurs="0">
                                                        <xs:complexType>
                                                            <xs:simpleContent>
                                                                <xs:extension base="xs:string">
                                                                    <xs:attribute type="xs:string" name="Pattern"
                                                                                  use="required"/>
                                                                    <xs:attribute type="AssignVarsType" name="AssignVars"
                                                                                  use="optional"/>
                                                                    <xs:attribute type="xs:byte" name="Required"
                                                                                  use="optional" default="1"/>
                                                                </xs:extension>
                                                            </xs:simpleContent>
                                                        </xs:complexType>
                                                    </xs:element>
                                                </xs:sequence>
                                                <xs:attribute type="ActionType" name="Type" use="optional"/>
                                                <xs:attribute type="xs:anyURI" name="Url" use="required"/>
                                                <xs:attribute type="Bool" name="OnlyOnce" use="optional"/>
                                                <xs:attribute type="xs:anyURI" name="Referer" use="optional"/>
                                                <xs:attribute type="xs:string" name="PostParams" use="optional"/>
                                                <xs:attribute type="xs:string" name="RegExp" use="optional"/>
                                                <xs:attribute type="AssignVarsType" name="AssignVars" use="optional"/>
                                                <xs:attribute type="CustomHeadersType" name="CustomHeaders" use="optional"/>
                                            </xs:complexType>
                                        </xs:element>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                            <xs:element name="Result">
                                <xs:complexType>
                                    <xs:simpleContent>
                                        <xs:extension base="xs:string">
                                            <xs:attribute type="xs:string" name="ImageUrlTemplate" use="optional"/>
                                            <xs:attribute type="xs:string" name="ThumbUrlTemplate" use="optional"/>
                                            <xs:attribute type="xs:string" name="ViewUrlTemplate" use="optional"/>
                                            <xs:attribute type="xs:string" name="DownloadUrlTemplate" use="optional"/>
                                        </xs:extension>
                                    </xs:simpleContent>
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                        <xs:attribute type="xs:string" name="Name" use="required"/>
                        <xs:attribute type="AuthorizeType" name="Authorize" use="optional"/>
                        <xs:attribute type="ServerType" name="Type" use="optional"/>
                        <xs:attribute type="xs:string" name="Plugin" use="optional"/>
                        <xs:attribute type="MinVersionType" name="MinVersion" use="optional"/>
                        <xs:attribute type="Bool" name="SupportsFolders" use="optional" default="0"/>
                        <xs:attribute type="Bool" name="NeedPassword" use="optional" default="0"/>
                        <xs:attribute type="Bool" name="Debug" use="optional" default="0"/>
                        <xs:attribute type="xs:positiveInteger" name="MaxThreads" use="optional"/>
                        <xs:attribute type="xs:positiveInteger" name="MaxFileSize" use="optional"/>
                        <xs:attribute type="xs:string" name="UserAgent" use="optional"/>
                        <xs:attribute type="ServerTypes" name="Types" use="optional"/>
                    </xs:complexType>
                </xs:element>
            </xs:choice>
        </xs:complexType>
    </xs:element>
</xs:schema>