<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <?include @ODBC_SOURCE_WIX_DIR@/binaries_dir.xml ?>
  <Product Id="*" Name="@PRODUCT_NAME@" Language="1033" 
    Version="@PRODUCT_VERSION@" 
    Manufacturer="@PRODUCT_MANUFACTURER@" UpgradeCode="b43bad5d-118f-4368-8977-e60fd4dd4317">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Platform="@WIXPLATFORM@"/>

    <Condition Message="This product requires Windows 8 or newer.">
      <![CDATA[Installed OR VersionNT >= 602]]>
    </Condition>

    <MajorUpgrade DowngradeErrorMessage="A newer version of @PRODUCT_NAME@ is already installed." />
    <MediaTemplate EmbedCab="yes"/>
      <UIRef Id="WixUI_Mondo" />
      <UI>
        <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="MoveExistingDsnsToNewDriver">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
      </UI>
      <WixVariable Id="WixUILicenseRtf" Value="@ODBC_SOURCE_WIX_DIR@/license.rtf" />
      <WixVariable Id="WixUIBannerBmp" Value="@ODBC_SOURCE_WIX_DIR@/mdb-connector-odbc.png" />
      <WixVariable Id="WixUIDialogBmp" Value="@ODBC_SOURCE_WIX_DIR@/mdb-dialog-popup.png" />
      <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Make User DSN's for older Connnector versions to use this version" />

    <Feature Id="ProductFeature" Title="@PRODUCT_NAME@ @PRODUCT_VERSION@" Level="1">
      <ComponentRef Id="RegistryKeys" />
      <ComponentRef Id="Setup" />
      <ComponentRef Id="Driver" />
      <@PLUGINS_BEGIN@ComponentRef Id="CcPlugins" /@PLUGINS_END@>
      <ComponentRef Id="InstallerTools" />
      <@TLS_LIB_BEGIN@ComponentRef Id="TlsLib" /@TLS_LIB_END@>
    </Feature>
    <Feature Id="DebugFeature" Title="Debug Information" Level="2">
      <ComponentRef Id="Debug" />
    </Feature>
    <@PLUGINS_BEGIN@Feature Id="PluginsFeature" Title="Authentification Plugins" Level="2">
      <ComponentRef Id="CcPlugins" />
      <ComponentRef Id="PluginsDebug" />
    </Feature@PLUGINS_END@>
    <!--CustomAction Id="WixtUseInstlallFolder" Property="MoveExistingDsnsToNewDriver" Value="[INSTALLFOLDER]change_dsns_driver.exe -reg-direct -quiet" / -->
    <Property Id="WixQuietExec@IS64@CmdLine" Value='"[INSTALLFOLDER]change_dsns_driver.exe" --reg-direct --quiet' />
    <CustomAction Id="MoveExistingDsnsToNewDriver" BinaryKey="WixCA" DllEntry="WixQuietExec@IS64@" Impersonate="yes" />
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="@FOLDER@">
        <Directory Id="MariaDB" Name="@PRODUCT_MANUFACTURER@">
          <Directory Id="INSTALLFOLDER" Name="@PRODUCT_NAME@">
            <Directory Id="PLUGINSFOLDER" Name="$(var.plugins_subdir_name)">
            </Directory>
          </Directory>
        </Directory>
      </Directory>
    </Directory>
  </Fragment>

  <Fragment>
    <!--<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">-->
      <Component Id="RegistryKeys" Guid="@GUID_REGISTRY@" DiskId="1" Directory="INSTALLFOLDER" Win64="@IS_WIN64@">
        <RegistryKey Id="Version" Root="HKLM" Key="SOFTWARE\@PRODUCT_MANUFACTURER@\@PRODUCT_NAME@" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
            <RegistryValue Name="Version" Type="string" Value="@PRODUCT_VERSION@"/>
          </RegistryKey>
      </Component>
      <Component Id="Setup" Guid="@GUID_SETUP@" DiskId="1" Directory="INSTALLFOLDER" Win64="@IS_WIN64@">
        <File Id="mariadb_odbc_setup" Name="maodbcs.dll"  DiskId="1"  Source="$(var.binaries_dir)/maodbcs.dll" />
        <File Id="mariadb_odbc_setup_lib" Name="maodbcs.lib" DiskId="1" Source="$(var.binaries_dir)/maodbcs.lib" />
      </Component>  
      <Component Id="Driver" Guid="@GUID_DRIVER@" SharedDllRefCount="yes" Directory="INSTALLFOLDER" Win64="@IS_WIN64@">
        <File Id="mariadb_odbc_dll" Name="maodbc.dll" KeyPath="yes" DiskId="1" Source="$(var.binaries_dir)/maodbc.dll">
          <ODBCDriver Id="madb_odbc_driver" Name="MariaDB ODBC @MARIADB_ODBC_VERSION_MAJOR@.@MARIADB_ODBC_VERSION_MINOR@ Driver" SetupFile="mariadb_odbc_setup" />
        </File>
        <File Id="mariadb_odbc_lib" Name="maodbc.lib" DiskId="1" Source="$(var.binaries_dir)/maodbc.lib" />
      </Component>
    <Component Id="Debug" Guid="@GUID_DEBUG@" Directory="INSTALLFOLDER" DiskId="1" Win64="@IS_WIN64@">
      <File Id="mariadb_odbc_dll_pdb" Name="maodbc.pdb" KeyPath="yes" DiskId="1" Source="$(var.binaries_dir)/maodbc.pdb" />
      <File Id="mariadb_odbc_setup_pdb" Name="maodbcs.pdb"  DiskId="1"  Source="$(var.binaries_dir)/maodbcs.pdb" />
      <CreateFolder />
    </Component>
    <@PLUGINS_BEGIN@Component Id="CcPlugins" Guid="@GUID_PLUGINS@" Directory="PLUGINSFOLDER" DiskId="1" Win64="@IS_WIN64@">
      <File Id="caching_sha2_password.dll" Name="caching_sha2_password.dll" DiskId="1" Source="$(var.plugins_source_dir)/caching_sha2_password.dll" />
      <File Id="dialog_dll" Name="dialog.dll" KeyPath="yes" DiskId="1" Source="$(var.plugins_source_dir)/dialog.dll" />
      <File Id="mysql_clear_password_dll" Name="mysql_clear_password.dll"  DiskId="1" Source="$(var.plugins_source_dir)/mysql_clear_password.dll" />
      <File Id="sha256_password_dll" Name="sha256_password.dll" DiskId="1" Source="$(var.plugins_source_dir)/sha256_password.dll" />
      <File Id="client_ed25519_dll" Name="client_ed25519.dll" DiskId="1" Source="$(var.plugins_source_dir)/client_ed25519.dll" />
    </Component>
    <Component Id="PluginsDebug" Guid="@GUID_PLUGINS_DEBUG@" Directory="PLUGINSFOLDER" DiskId="1" Win64="@IS_WIN64@">
      <File Id="caching_sha2_password_pdb" Name="caching_sha2_password.pdb" DiskId="1" Source="$(var.plugins_source_dir)/caching_sha2_password.pdb" />
      <File Id="dialog_pdb" Name="dialog.pdb" DiskId="1" Source="$(var.plugins_source_dir)/dialog.pdb" />
      <File Id="mysql_clear_password_pdb" Name="mysql_clear_password.pdb" DiskId="1" Source="$(var.plugins_source_dir)/mysql_clear_password.pdb" />
      <File Id="sha256_password_pdb" Name="sha256_password.pdb" DiskId="1" Source="$(var.plugins_source_dir)/sha256_password.pdb" />
      <File Id="client_ed25519_pdb" Name="client_ed25519.pdb" DiskId="1" Source="$(var.plugins_source_dir)/client_ed25519.pdb" />
      <CreateFolder />
    </Component@PLUGINS_END@>
    <Component Id="InstallerTools" Guid="@GUID_INSTALLER_TOOLS@" Directory="INSTALLFOLDER" DiskId="1" Win64="@IS_WIN64@">
        <File Id="change_dsns_driver" Name="change_dsns_driver.exe"  DiskId="1"  Source="$(var.installer_tools_dir)/change_dsns_driver.exe" />
    </Component>
    <@TLS_LIB_BEGIN@Component Id="TlsLib" Guid="@GUID_TLS_LIB@" Directory="INSTALLFOLDER" DiskId="1" Win64="@IS_WIN64@">
      <File Id="TlsLibFile1" Name="libgnutls-30.dll"  DiskId="1"  Source="@LIB_GNUTLS_LOCATION@/libgnutls-30.dll" />
      <File Id="TlsLibFile2" Name="libgcc_s_seh-1.dll"  DiskId="1"  Source="@LIB_GNUTLS_LOCATION@/libgcc_s_seh-1.dll" />
      <File Id="TlsLibFile3" Name="libgmp-10.dll"  DiskId="1"  Source="@LIB_GNUTLS_LOCATION@/libgmp-10.dll" />
      <File Id="TlsLibFile4" Name="libhogweed-4.dll"  DiskId="1"  Source="@LIB_GNUTLS_LOCATION@/libhogweed-4.dll" />
      <File Id="TlsLibFile5" Name="libidn2-0.dll"  DiskId="1"  Source="@LIB_GNUTLS_LOCATION@/libidn2-0.dll" />
      <File Id="TlsLibFile6" Name="libnettle-6.dll"  DiskId="1"  Source="@LIB_GNUTLS_LOCATION@/libnettle-6.dll" />
      <File Id="TlsLibFile7" Name="libp11-kit-0.dll"  DiskId="1"  Source="@LIB_GNUTLS_LOCATION@/libp11-kit-0.dll" />
      <File Id="TlsLibFile8" Name="libwinpthread-1.dll"  DiskId="1"  Source="@LIB_GNUTLS_LOCATION@/libwinpthread-1.dll" />
      <File Id="TlsLibFile9" Name="libffi-6.dll"  DiskId="1"  Source="@LIB_GNUTLS_LOCATION@/libffi-6.dll" />
    </Component@TLS_LIB_END@>
  <!--  </ComponentGroup> -->
  </Fragment>
</Wix>
