<?xml version="1.0" encoding="windows-1252"?>
<?if $(var.Platform) = x64 ?>
  <?define ProductName = "OpenSC (64bit)" ?>
  <?define Win64YesNo="yes" ?>
  <?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
  <?define PlatformSystemFolder = "System64Folder" ?>
  <?define PlatformUpgradeCode = "{9A449570-69A2-11E0-9CC6-955B4824019B}" ?>
<?else ?>
  <?define ProductName = "OpenSC" ?>
  <?define Win64YesNo="no" ?>
  <?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
  <?define PlatformSystemFolder = "SystemFolder" ?>
  <?define PlatformUpgradeCode = "{69428F65-B96D-458D-BB87-DBB5FDB35DCE}" ?>
<?endif ?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <Product Name="$(var.ProductName)"
           Id="*"
           UpgradeCode="$(var.PlatformUpgradeCode)"
           Language="1033"
           Codepage="1252"
           Version="@OPENSC_VERSION_MAJOR@.@OPENSC_VERSION_MINOR@.@OPENSC_VERSION_FIX@.0"
           Manufacturer="OpenSC Project">
    <Package Platform="$(var.Platform)"
             Description="OpenSC Installer"
             Comments="OpenSC Project home page http://www.opensc-project.org/opensc/"
             Manufacturer="OpenSC Project"
             InstallerVersion="300"
             Languages="1033"
             Compressed="yes"
             SummaryCodepage="1252"
             InstallScope="perMachine"/>
    <!-- OpenSC is covered by LGPL. Extend the license as required with other EULA notes -->
    <WixVariable Id="WixUILicenseRtf" Value="license.rtf"/>
    <!-- Links in info -->
    <Property Id="ARPHELPLINK" Value="http://www.opensc-project.org/opensc/wiki/ReportingBugs"/>
    <Property Id="ARPURLINFOABOUT" Value="http://www.opensc-project.org/"/>
    <Property Id="ARPURLUPDATEINFO" Value="http://www.opensc-project.org/opensc/wiki/WindowsInstaller"/>

	<Icon Id="OpenSC.ico" SourceFile="OpenSC.ico" />
	<Property Id="ARPPRODUCTICON" Value="OpenSC.ico" />


    <Media Id="1" Cabinet="OpenSC.cab" EmbedCab="yes" CompressionLevel="high"/>
    <MajorUpgrade DowngradeErrorMessage="Can't downgrade." AllowSameVersionUpgrades="yes"/>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <!-- Install critical DLL-s to system folder. NB! Id-s can not contain "-" characters! -->
      <Directory Id="$(var.PlatformSystemFolder)" Name=".">
        <Component Id="opensc_pkcs11.dll" Guid="*" Win64="$(var.Win64YesNo)">
          <File Source="$(var.SOURCE_DIR)\src\pkcs11\opensc-pkcs11.dll" Vital="yes"/>
        </Component>
        <Component Id="opensc_minidriver.dll" Guid="*" Win64="$(var.Win64YesNo)">
          <File Source="$(var.SOURCE_DIR)\src\minidriver\opensc-minidriver.dll" Vital="yes"/>
        </Component>
      </Directory>
      <!-- Install tools and profiles to Program Files -->
      <Directory Id="$(var.PlatformProgramFilesFolder)" Name="PFiles">
        <Directory Id="OpenSC_Project_Dir" Name="OpenSC Project">
          <!-- Most of the stuff goes to the Program Files folder -->
          <Directory Id="PKCS11SPYINSTALLDIR" Name="PKCS11-Spy">
            <Component Id="pkcs11_spy.dll" Guid="*" Win64="$(var.Win64YesNo)">
              <File Source="$(var.SOURCE_DIR)\src\pkcs11\pkcs11-spy.dll"/>
              <RegistryKey Id="Pkcs11SpyRegs" Root="HKLM" Key="Software\[Manufacturer]\PKCS11-Spy" Action="createAndRemoveOnUninstall">
                <RegistryValue Type="string" Name="Module" Value="%SystemRoot%\system32\opensc-pkcs11.dll"/>
                <RegistryValue Type="string" Name="Output" Value="%TEMP%\pkcs11-spy.log"/>
              </RegistryKey>
            </Component>
          </Directory>
          <Directory Id="INSTALLDIR" Name="OpenSC">
            <!-- opensc.conf sample goes to installation directory -->
            <Component Id="opensc.conf" Guid="*" Win64="$(var.Win64YesNo)">
              <File Source="$(var.SOURCE_DIR)\etc\opensc.conf.win" Name="opensc.conf" KeyPath="yes"/>
              <!-- -->
              <RegistryKey Id="OpenscRegs" Root="HKLM" Key="Software\[Manufacturer]\OpenSC" Action="createAndRemoveOnUninstall">
                <RegistryValue Type="string" Name="ConfigFile" Value="[INSTALLDIR]opensc.conf"/>
                <RegistryValue Type="string" Name="ProfileDir" Value="[INSTALLDIR]profiles"/>
                <RegistryValue Type="string" Name="SmDir" Value="[INSTALLDIR]tools"/>
              </RegistryKey>
            </Component>
            <!-- Tools have their own folder -->
            <Directory Id="INSTALLDIR_TOOLS" Name="tools">
              <Component Id="opensc.dll" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\libopensc\opensc.dll" Vital="yes"/>
              </Component>
              <Component Id="smm_local.dll" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\sm\smm-local.dll" Vital="yes"/>
              </Component>
              <Component Id="opensc_explorer.exe" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\tools\opensc-explorer.exe" Vital="yes"/>
              </Component>
              <Component Id="opensc_tool.exe" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\tools\opensc-tool.exe" Vital="yes"/>
              </Component>
              <Component Id="pkcs11_tool.exe" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\tools\pkcs11-tool.exe" Vital="yes"/>
              </Component>
              <Component Id="pkcs15_init.exe" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\tools\pkcs15-init.exe" Vital="yes"/>
              </Component>
              <Component Id="pkcs15_tool.exe" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\tools\pkcs15-tool.exe" Vital="yes"/>
              </Component>
              <Component Id="pkcs15_crypt.exe" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\tools\pkcs15-crypt.exe" Vital="yes"/>
              </Component>
              <Component Id="sc_hsm_tool.exe" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\tools\sc-hsm-tool.exe" Vital="yes"/>
              </Component>
            </Directory>
            <Directory Id="INSTALLDIR_PROFILES" Name="profiles">
              <Component Id="pkcs15.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\pkcs15.profile"/>
              </Component>
              <Component Id="asepcos.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\asepcos.profile"/>
              </Component>
              <Component Id="cardos.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\cardos.profile"/>
              </Component>
              <Component Id="entersafe.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\entersafe.profile"/>
              </Component>
              <Component Id="epass2003.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\epass2003.profile"/>
              </Component>
              <Component Id="myeid.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\myeid.profile"/>
              </Component>
              <Component Id="setcos.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\setcos.profile"/>
              </Component>
              <Component Id="starcos.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\starcos.profile"/>
              </Component>
              <Component Id="westcos.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\westcos.profile"/>
              </Component>
              <Component Id="oberthur.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\oberthur.profile"/>
              </Component>
              <Component Id="authentic.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\authentic.profile"/>
              </Component>
              <Component Id="rutoken.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\rutoken.profile"/>
              </Component>
              <Component Id="rutoken_ecp.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\rutoken_ecp.profile"/>
              </Component>
              <Component Id="ias_adele_admin1.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\ias_adele_admin1.profile"/>
              </Component>
              <Component Id="ias_adele_admin2.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\ias_adele_admin2.profile"/>
              </Component>
              <Component Id="ias_adele_common.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\ias_adele_common.profile"/>
              </Component>
              <Component Id="iasecc_admin_eid.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\iasecc_admin_eid.profile"/>
              </Component>
              <Component Id="iasecc_generic_oberthur.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\iasecc_generic_oberthur.profile"/>
              </Component>
              <Component Id="iasecc_generic_pki.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\iasecc_generic_pki.profile"/>
              </Component>
              <Component Id="iasecc.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\iasecc.profile"/>
              </Component>
              <Component Id="schsm.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\sc-hsm.profile"/>
              </Component>
              <Component Id="openpgp.profile" Guid="*" Win64="$(var.Win64YesNo)">
                <File Source="$(var.SOURCE_DIR)\src\pkcs15init\openpgp.profile"/>
              </Component>
            </Directory>
          </Directory>
        </Directory>
      </Directory>
      <Directory Id="ProgramMenuFolder" Name="Programs">
        <Directory Id="ProgramMenuDir" Name="OpenSC Project">
          <Component Id="ProgramMenuDir" Guid="*">
            <util:InternetShortcut Id="OnlineDocumentationShortcut" Name="OpenSC wiki" Target="http://www.opensc-project.org/opensc/"/>
            <RemoveFolder Id="ProgramMenuDir" On="uninstall"/>
            <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
          </Component>
        </Directory>
      </Directory>
    </Directory>
    <!-- Set up the features  -->
    <Feature Id="Complete" Level="1" Title="OpenSC software suite" Display="expand">
      <Feature Id="OpenSC_core" Level="1" Title="OpenSC core library" Description="Core DLL and configuration file used by all other components." Absent="disallow">
        <ComponentRef Id="opensc.dll"/>
        <ComponentRef Id="opensc.conf"/>
        <ComponentRef Id="smm_local.dll"/>
      </Feature>
      <Feature Id="OpenSC_pkcs11" Level="1" Title="OpenSC PKCS#11 module" Description="PKCS#11 module usd by most open source and cross-platform software (like Firefox, Putty, TrueCrypt, OpenVPN etc)" TypicalDefault="install">
        <ComponentRef Id="opensc_pkcs11.dll"/>
      </Feature>
      <Feature Id="PKCS11_spy" Level="1" Title="PKCS#11 Spy module" Description="Module of the PKCS#11 spy." Absent="disallow">
        <ComponentRef Id="pkcs11_spy.dll"/>
      </Feature>
      <!-- Minidriver is only installed if selected via Custom install (level == 4) -->
      <Feature Id="OpenSC_minidriver" Level="4" Title="OpenSC minidriver (EXPERIMENTAL)" Description="OpenSC minidriver for using smart cards with native Windows CSP applications (like Internet Explorer)" AllowAdvertise="no" Absent="allow">
        <ComponentRef Id="opensc_minidriver.dll"/>
      </Feature>
      <!-- Tools and profiles are for personalization -->
      <Feature Id="OpenSC_tools" Level="1" Title="Tools and profiles" Description="Tools for debugging and personalization. Includes profiles needed for running pkcs15-init.exe">
        <!-- TODO: Not all tools and utilities are listed! -->
        <ComponentRef Id="opensc_explorer.exe"/>
        <ComponentRef Id="opensc_tool.exe"/>
        <ComponentRef Id="pkcs11_tool.exe"/>
        <ComponentRef Id="pkcs15_init.exe"/>
        <ComponentRef Id="pkcs15_tool.exe"/>
        <ComponentRef Id="pkcs15_crypt.exe"/>
        <ComponentRef Id="sc_hsm_tool.exe"/>
        <!-- TODO: Not all profiles are listed! -->
        <ComponentRef Id="pkcs15.profile"/>
        <ComponentRef Id="asepcos.profile"/>
        <ComponentRef Id="cardos.profile"/>
        <ComponentRef Id="entersafe.profile"/>
        <ComponentRef Id="epass2003.profile"/>
        <ComponentRef Id="myeid.profile"/>
        <ComponentRef Id="setcos.profile"/>
        <ComponentRef Id="starcos.profile"/>
        <ComponentRef Id="westcos.profile"/>
        <ComponentRef Id="oberthur.profile"/>
        <ComponentRef Id="authentic.profile"/>
        <ComponentRef Id="rutoken.profile"/>
        <ComponentRef Id="rutoken_ecp.profile"/>
        <ComponentRef Id="ias_adele_admin1.profile"/>
        <ComponentRef Id="ias_adele_admin2.profile"/>
        <ComponentRef Id="ias_adele_common.profile"/>
        <ComponentRef Id="iasecc_admin_eid.profile"/>
        <ComponentRef Id="iasecc_generic_oberthur.profile"/>
        <ComponentRef Id="iasecc_generic_pki.profile"/>
        <ComponentRef Id="iasecc.profile"/>
        <ComponentRef Id="schsm.profile"/>
        <ComponentRef Id="openpgp.profile"/>
      </Feature>
      <Feature Id="OpenSC_menu" Level="1" Title="Start menu entries" Description="Start menu entries: link to documentation">
        <ComponentRef Id="ProgramMenuDir"/>
      </Feature>
    </Feature>
    <UIRef Id="WixUI_Mondo"/>
    <UIRef Id="WixUI_ErrorProgressText"/>
  </Product>
</Wix>
