<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

  @W@

  <Product
      Name="Tony" 
      Id="*"
      Language="1033"
      Codepage="1252" 
      Version="@VERSION@"
      UpgradeCode="3F073027-A65B-4688-906C-5F64597C5BB1"
      Manufacturer="Queen Mary, University of London">
    
    <Package
        Id="*"
        Keywords="Installer"
        Description="Tony Installer" 
        Comments="Copyright (c) 2015 Queen Mary, University of London and others."
        Manufacturer="Queen Mary, University of London" 
        InstallerVersion="100" 
        Languages="1033" 
        Compressed="yes" 
        Platform="x64"
        SummaryCodepage="1252"/>

    <MajorUpgrade DowngradeErrorMessage="A later version of Tony is already installed. Setup will now exit."/>

    <Media Id="1" Cabinet="Tony.cab" EmbedCab="yes" DiskPrompt="CD-ROM #1"/>
    <Property Id="DiskPrompt" Value="Tony Installation [1]"/>

    <Directory Id="TARGETDIR" Name="SourceDir">

      <Directory Id="ProgramFiles64Folder" Name="PFiles64">

        <Directory Id="APPLICATIONFOLDER" Name="Tony">

          <Component Win64="yes"
              Id="MainExecutable"
              Guid="B0DA872A-E8B9-4C41-B0B0-7702A9EBBD51">

            <File
                Id="T"
                Name="Tony.exe"
                DiskId="1"
                Source="release\Tony.exe"
                KeyPath="yes">

              <Shortcut
                  Id="TStartEntry"
                  Directory="ProgramMenuDir"
                  Name="Tony"
		  Icon="winicon.ico"
		  IconIndex="0"
                  WorkingDirectory="INSTALLDIR"
                  Advertise="yes"/>
	      
              <Shortcut
                  Id="TDesktop"
                  Directory="DesktopFolder"
                  Name="Tony"
		  Icon="winicon.ico"
		  IconIndex="0"
                  WorkingDirectory="INSTALLDIR"
                  Advertise="yes"/>
            </File>

            <File
                Id="CHANGELOG"
                Name="CHANGELOG.txt"
                DiskId="1"
                Source="..\CHANGELOG"/>
            <File
                Id="COPYING"
                Name="COPYING.txt"
                DiskId="1"
                Source="..\COPYING"/>
            <File
                Id="README"
                Name="README.txt"
                DiskId="1"
                Source="..\README.md"/>
            <File
                Id="CITATION"
                Name="CITATION.txt"
                DiskId="1"
                Source="..\CITATION"/>

            <File
                Id="winicon.ico"
                Name="tony-winicon.ico"
                DiskId="1"
                Source="..\icons\tony-winicon.ico"/>
          </Component>
            
          <Component Win64="yes"
	      Id="TonyFileAssociation"
	      Guid="8ec2bed5-74fe-4f9c-af31-109fc86f16dc">
            
            <CreateFolder/>

            <ProgId 
                Id='Tony.tonfile' 
                Description='Tony project file'
                Icon="T">
              <Extension 
                  Id='tony' 
                  ContentType='application/x-tony'>
                <Verb 
                    Id='open' 
                    Command='Open' 
                    TargetFile='T' 
                    Argument='"%1"' />
              </Extension>
            </ProgId>
            
          </Component>
          
          <Component Win64="yes"
              Id="pYin"
              Guid="5C3B7285-B652-4FE5-8A1D-AC92376F8AD5">
            <File
                Id="pyinlib"
                Name="pyin.dll"
                DiskId="1"
                Source="release\pyin.dll"/>
          </Component>
          <Component Win64="yes"
              Id="CHP"
              Guid="3567639C-BFA5-46EC-BA2D-C4899508B0D0">
            <File
                Id="chplib"
                Name="chp.dll"
                DiskId="1"
                Source="release\chp.dll"/>
          </Component>

          <Component Win64="yes"
              Id="Qt5"
              Guid="7DCE15D9-DB56-4ECC-A324-A9B74E30B872">
            <File
                Id="QtCore"
                Name="Qt5Core.dll"
                DiskId="1"
                Source="release\Qt5Core.dll"
		KeyPath="yes"/>
            <File
                Id="QtGui"
                Name="Qt5Gui.dll"
                DiskId="1"
                Source="release\Qt5Gui.dll"/>
            <File
                Id="QtNetwork"
                Name="Qt5Network.dll"
                DiskId="1"
                Source="release\Qt5Network.dll"/>
            <File
                Id="QtSvg"
                Name="Qt5Svg.dll"
                DiskId="1"
                Source="release\Qt5Svg.dll"/>
            <File
                Id="QtWidgets"
                Name="Qt5Widgets.dll"
                DiskId="1"
                Source="release\Qt5Widgets.dll"/>
            <File
                Id="QtXml"
                Name="Qt5Xml.dll"
                DiskId="1"
                Source="release\Qt5Xml.dll"/>
          </Component>

          <Component Win64="yes"
                     Id="Sndfile"
                     Guid="04533516-6460-4155-A0D4-E9BA4D31E95C">
            <File
                Id="libsndfile"
                Name="libsndfile-1.dll"
                Source="..\sv-dependency-builds\win64-msvc\lib\libsndfile-1.dll"
                KeyPath="yes"/>
          </Component>

          <Component Win64="yes"
                     Id="OpenSSL"
                     Guid="e8c8341a-55af-4113-b083-5217400cf5c2">
            <File
                Id="libssl"
                Name="libssl-1_1-x64.dll"
                Source="C:\OpenSSL-v111-Win64\bin\libssl-1_1-x64.dll"
                KeyPath="yes"/>
            <File
                Id="libcrypto"
                Name="libcrypto-1_1-x64.dll"
                Source="c:\OpenSSL-v111-Win64\bin\libcrypto-1_1-x64.dll"/>
          </Component>

          <Component Win64="yes"
               Id="VCRuntime"
               Guid="251D9513-BBD2-47CF-BE78-EF79446F7683">

            <!-- Redistributables are handled by the Visual Studio
                 installer (a separate program from VS itself) and are
                 installed into C:\Program Files (x86)\Microsoft
                 Visual Studio\2019\Community\VC\Redist\MSVC\...  NB
                 this is not the same thing as the Windows SDKs, which
                 consist of build tools etc - they have their own
                 installers and get installed by default to C:\Program
                 Files (x86)\Windows Kits\... -->
               
               <File
                   Id="concrt140"
                   Name="concrt140.dll"
                   Source="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\@REDIST_VER@\x64\Microsoft.VC142.CRT\concrt140.DLL"
                   KeyPath="yes"/>
               <File
                   Id="msvcp140"
                   Name="msvcp140.dll"
                   Source="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\@REDIST_VER@\x64\Microsoft.VC142.CRT\msvcp140.DLL"/>
               <File
                   Id="vccorlib140"
                   Name="vccorlib140.dll"
                   Source="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\@REDIST_VER@\x64\Microsoft.VC142.CRT\vccorlib140.DLL"/>
               <File
                   Id="vcruntime140"
                   Name="vcruntime140.dll"
                   Source="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\@REDIST_VER@\x64\Microsoft.VC142.CRT\vcruntime140.DLL"/>
               <File
                   Id="vcruntime140_1"
                   Name="vcruntime140_1.dll"
                   Source="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\@REDIST_VER@\x64\Microsoft.VC142.CRT\vcruntime140_1.DLL"/>
          </Component>

	  <Directory Id="Platforms" Name="platforms">
            <Component Win64="yes"
                Id="Qt5PlatformPlugins"
                Guid="1FFB773E-6D6D-4C0E-832B-F0FFEA959CA5">
	      <File
                  Id="qminimal"
                  Name="qminimal.dll"
                  Source="release\qminimal.dll"/>
	      <File
                  Id="qwindows"
                  Name="qwindows.dll"
                  Source="release\qwindows.dll"/>
            </Component>
	  </Directory>

	  <Directory Id="Styles" Name="styles">
            <Component Win64="yes"
                Id="Qt5StylePlugins"
                Guid="7A676FC1-B139-432C-A7D3-F33984934B79">
	      <File
                  Id="qwindowsvistastyle"
                  Name="qwindowsvistastyle.dll"
                  Source="release\qwindowsvistastyle.dll"/>
            </Component>
	  </Directory>
        </Directory>
	
      </Directory>
      
      <Directory Id="ProgramMenuFolder" Name="Programs">
        <Directory Id="ProgramMenuDir" Name="Tony">
          <Component Id="ProgramMenuDir" Guid="56B6BB05-453C-4480-81DA-31612ED64410">
            <RemoveFolder Id="ProgramMenuDir" On="uninstall"/>
            <RegistryValue Root="HKMU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes"/>
          </Component>
        </Directory>
      </Directory>

      <Directory Id="DesktopFolder" Name="Desktop"/>

    </Directory>

    <Feature 
      Id="Complete"
      Title="Required files"
      Description="Installs the required files for running Tony."
      AllowAdvertise="no"
      Absent="disallow"
      ConfigurableDirectory="APPLICATIONFOLDER"
      Level="1">
      <ComponentRef Id="pYin"/>
      <ComponentRef Id="CHP"/>
      <ComponentRef Id="MainExecutable"/>
      <ComponentRef Id="TonyFileAssociation"/>
      <ComponentRef Id="Sndfile"/>
      <ComponentRef Id="OpenSSL"/>
      <ComponentRef Id="Qt5"/>
      <ComponentRef Id="VCRuntime"/>
      <ComponentRef Id="Qt5PlatformPlugins"/>
      <ComponentRef Id="Qt5StylePlugins"/>
      <ComponentRef Id="ProgramMenuDir"/>
    </Feature>

    <UI>
      <UIRef Id="WixUI_InstallDir" />
      <UIRef Id="WixUI_ErrorProgressText" />
    </UI>
		
    <Property Id="WIXUI_INSTALLDIR" Value="APPLICATIONFOLDER" />
    <Property Id="ApplicationFolderName" Value="Tony" />
    <Property Id="WixAppFolder" Value="WixPerMachineFolder" />
    <WixVariable Id="WixUILicenseRtf" Value="..\deploy\win64\License.rtf" />
    
    <Icon Id="winicon.ico" SourceFile="..\icons\tony-winicon.ico"/>
    <Property Id="ARPPRODUCTICON" Value="winicon.ico" />
        
    <WixVariable Id="WixUIBannerBmp" Value="..\deploy\win64\top.bmp"/>
    <WixVariable Id="WixUIDialogBmp" Value="..\deploy\win64\main.bmp"/>

  </Product>
</Wix>
