<?xml version="1.0" encoding="UTF-8"?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <?define eDosStation_TargetDir=$(var.eDosStation.TargetDir)?>
  <?define syncEdosLocal_TargetDir=$(var.syncEdosLocal.TargetDir)?>
  <Product Id="*" Name="eDosStation" Language="1033" Version="1.0.3.0" Manufacturer="SCK CEN Luc Vandenbroucke" UpgradeCode="24e037ca-edbb-49d5-85d4-3a93dd7d10d8">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Comments="EPD lees software en synchronisatie tussen local en remote database" InstallPrivileges="elevated" Platform="x86" />
    <Media Id="1" EmbedCab="yes" Cabinet="cab" />
    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <Feature Id="eDosStationFeature" Title="eDosStation" Level="1">
      <ComponentGroupRef Id="eDosStation" />
      <ComponentRef Id="eDosStationShortcut" />
      <ComponentRef Id="regDesfire" />
      <ComponentRef Id="regDesfireb" />
    </Feature>
    <Feature Id="eDosSyncFeature" Title="eDosSync" Level="1">
      <ComponentGroupRef Id="eDosSync" />
      <ComponentGroupRef Id="SyncLog" />
      <ComponentRef Id="eDosSyncShortcut" />
    </Feature>
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="eDos">
          <Directory Id="eDosStationFolder" Name="eDosStation" />
          <Directory Id="eDosSyncFolder" Name="eDosSync" />
        </Directory>
      </Directory>
      <Directory Id="ProgramMenuFolder">
        <Directory Id="ApplicationProgramsFolder" Name="eDos" />
      </Directory>
      <Directory Id="LogFolder" />
    </Directory>
  </Fragment>

  <Fragment>
    <DirectoryRef Id="TARGETDIR">
      <Component Id="regDesfireb" Guid="224D6E1F-115A-4572-A3FB-73B9AB6123AB" KeyPath="yes">
        <RegistryKey Key="SOFTWARE\Microsoft\Cryptography\Calais\SmartCards\NXP Mifare DESFire (2)" Root="HKLM">
          <RegistryValue Name="ATR" Value="3BF79100FF918171FE40004120001177818040" Type="binary" />
          <RegistryValue Name="Crypto Provider" Value="$$DisableSCPnP$$" Type="string" />
        </RegistryKey>
      </Component>
      <Component Id="regDesfire" Guid="C8DCEEFC-5494-4434-87BC-829EA06347BE" KeyPath="yes">
        <RegistryKey Key="SOFTWARE\Microsoft\Cryptography\Calais\SmartCards\NXP Mifare DESFire" Root="HKLM">
          <RegistryValue Name="ATR" Value="3B8180018080" Type="binary" />
          <RegistryValue Name="Crypto Provider" Value="$$DisableSCPnP$$" Type="string" />
        </RegistryKey>
      </Component>
    </DirectoryRef>
  </Fragment>
  
  <Fragment>
    <SetDirectory Id="LogFolder" Value="[WindowsVolume]Logs" />
  </Fragment>

  <Fragment>
    
    <DirectoryRef Id="eDosStationFolder">
      <Component Id="eDosStationShortcut" Guid="85AF80D8-11AC-4B82-89F8-5764A41EF3CE">
        <Shortcut Id="eDosStationMenuShortcut" Name="eDos Station" Description="eDos Epd issuing" Target="[#eDosStation.exe]" WorkingDirectory="eDosStationFolder" />
        <RemoveFolder Id="CleanUpeDosStationShortcut" Directory="ApplicationProgramsFolder" On="uninstall" />
        <RegistryValue Root="HKLM" Key="Software\SCKCEN\eDosStation" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </DirectoryRef>
    
    <DirectoryRef Id="eDosSyncFolder">
      <Component Id="eDosSyncShortcut" Guid="ED01D079-54BA-4D1E-ACCF-6A79565C9D32">
        <Shortcut Id="eDosSyncMenuShortcut" Name="eDos sync" Description="eDos sync to/from local" Target="[#syncEdosLocal.exe]" WorkingDirectory="eDosSyncFolder" />
        <RemoveFolder Id="CleanUpeDosSyncShortCut" Directory="ApplicationProgramsFolder" On="uninstall" />
        <RegistryValue Root="HKLM" Key="Software\SCKCEN\eDosSync" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </DirectoryRef>

    <ComponentGroup Id="eDosStation" Directory="eDosStationFolder">
        <Component Id="eDosStation.exe" Guid="bf9a54fc-5185-4e37-81eb-dfbf63d2586a">
        <File Id="eDosStation.exe" Name="eDosStation.exe" Source="$(var.eDosStation_TargetDir)eDosStation.exe" />
      </Component>
      <Component Id="eDosStation.exe.config" Guid="f052d72c-32dd-4108-80b4-35773564b2cc">
        <File Id="eDosStation.exe.config" Name="eDosStation.exe.config" Source="$(var.eDosStation_TargetDir)eDosStation.exe.config" />
      </Component>
      
      <Component Id="IR_READER_MS_DLL.dll" Guid="7dc99dd1-1611-4397-84ba-ae56ed455f68">
        <File Id="IR_READER_MS_DLL.dll" Name="IR_READER_MS_DLL.dll" Source="$(var.eDosStation_TargetDir)IR_READER_MS_DLL.dll" />
      </Component>
      <Component Id="Reader2.dll" Guid="64258699-5bc6-49bf-a01c-2297206a37d4">
        <File Id="Reader2.dll" Name="Reader2.dll" Source="$(var.eDosStation_TargetDir)Reader2.dll" />
      </Component>
      
      <Component Id="Telerik.Windows.Data.dll" Guid="8d506a90-f3ff-40ac-8c5c-fc89af3fc9f3">
        <File Id="Telerik.Windows.Data.dll" Name="Telerik.Windows.Data.dll" Source="$(var.eDosStation_TargetDir)Telerik.Windows.Data.dll" />
      </Component>
      <Component Id="Telerik.Windows.Controls.dll" Guid="fe4f1f6a-cb0b-4487-a5b9-262dc004730a">
        <File Id="Telerik.Windows.Controls.dll" Name="Telerik.Windows.Controls.dll" Source="$(var.eDosStation_TargetDir)Telerik.Windows.Controls.dll" />
      </Component>
      <Component Id="Telerik.Windows.Controls.GridView.dll" Guid="e541128e-bbec-46e2-85ba-0698d2e1e42e">
        <File Id="Telerik.Windows.Controls.GridView.dll" Name="Telerik.Windows.Controls.GridView.dll" Source="$(var.eDosStation_TargetDir)Telerik.Windows.Controls.GridView.dll" />
      </Component>
      <Component Id="Telerik.Windows.Controls.Input.dll" Guid="a1ee1a08-793e-4b55-a122-b3f1726f4f78">
        <File Id="Telerik.Windows.Controls.Input.dll" Name="Telerik.Windows.Controls.Input.dll" Source="$(var.eDosStation_TargetDir)Telerik.Windows.Controls.Input.dll" />
      </Component>
      
      <Component Id="LSWDesfirePublic.dll" Guid="aac035cc-de9b-4dc6-92ae-7f0e173928c6">
        <File Id="LSWDesfirePublic.dll" Name="LSWDesfirePublic.dll" Source="$(var.eDosStation_TargetDir)LSWDesfirePublic.dll" />
      </Component>
      <Component Id="EpdBaseClr.dll" Guid="ed22005b-b3ba-4821-a598-d076ac94ea72">
        <File Id="EpdBaseClr.dll" Name="EpdBaseClr.dll" Source="$(var.eDosStation_TargetDir)EpdBaseClr.dll" />
      </Component>
    </ComponentGroup>
    
    
    
    <ComponentGroup Id="eDosSync" Directory="eDosSyncFolder">
      <Component Id="syncEdosLocal.exe.config" Guid="d1c4ba86-8a63-4b73-9179-a5eab405f8cb">
        <File Id="syncEdosLocal.exe.config" Name="syncEdosLocal.exe.config" Source="$(var.syncEdosLocal_TargetDir)syncEdosLocal.exe.config" />
      </Component>
      <Component Id="syncEdosLocal.exe" Guid="9552f9bf-c9cb-42dd-8e30-c99853613f77">
        <File Id="syncEdosLocal.exe" Name="syncEdosLocal.exe" Source="$(var.syncEdosLocal_TargetDir)syncEdosLocal.exe" />
      </Component>
      <Component Id="syncEdosLocal.pdb" Guid="5179a887-867c-4000-8fb2-c7999f23591f">
        <File Id="syncEdosLocal.pdb" Name="syncEdosLocal.pdb" Source="$(var.syncEdosLocal_TargetDir)syncEdosLocal.pdb" />
      </Component>
      <Component Id="LSWLib.dll" Guid="27679139-5900-4901-b148-751e49c9bc74">
        <File Id="LSWLib.dll" Name="LSWLib.dll" Source="$(var.syncEdosLocal_TargetDir)LSWLib.dll" />
      </Component>
      <Component Id="edossync.xml" Guid="b141fa44-2c0c-4836-8e5d-1798db6e3540">
        <File Id="edossync.xml" Name="edossync.xml" Source="$(var.syncEdosLocal_TargetDir)edossync.xml" />
      </Component>
    </ComponentGroup>
    
    <ComponentGroup Id="SyncLog">
      <Component Id="CreateLogFolder" Directory="LogFolder" Guid="EF959CF0-DC34-42A1-9031-2FE454DBED24">
        <CreateFolder>
          <util:PermissionEx User="Users" GenericAll="yes" />
        </CreateFolder>
      </Component>
    </ComponentGroup>
  </Fragment>

  <Fragment>
    <CustomAction Id="CreateScheduledTask" Return="check" Directory="eDosSyncFolder" Execute="deferred" Impersonate="no" ExeCommand="&quot;[SystemFolder]SCHTASKS.EXE&quot; /CREATE /TN &quot;EDos Sync&quot; /RU &quot;eDosStation&quot;/RP &quot;Infopla+8&quot; /XML &quot;[#edossync.xml]&quot;" />
    <CustomAction Id="DeleteScheduledTask" Return="check" Directory="eDosSyncFolder" Execute="deferred" Impersonate="no" ExeCommand="&quot;[SystemFolder]SCHTASKS.EXE&quot; /DELETE /TN &quot;EDos Sync&quot; /F" />

    <InstallExecuteSequence>
      <Custom Action="CreateScheduledTask" After='InstallFinalize'>NOT Installed</Custom>
      <Custom Action="DeleteScheduledTask" Before="RemoveFiles" >Installed</Custom>
    </InstallExecuteSequence>
    

  </Fragment>

</Wix>
