<?xml version="1.0" encoding="Windows-1252" ?>
<!-- 
  Copyright (C) 2008-2009  The Tor Project, Inc.
  See LICENSE file for rights and terms.
 -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <?define ThisProductVersion="1.0.4" ?>
  <?define ThisProductVersionDisp="1.0.4.1" ?>
  <?define UpgradeCode="b45b9db8-8670-4546-8dd4-e9284ca81616" ?>
  
  <?define CurrProductGUID="22c59fc2-8c94-4151-ad82-2c90bfa7ff99" ?>
  <?define CurrExecutableGUID="cef195c5-817c-4963-a1f7-03e88c79985b" ?>
  <?define CurrRegExLibsGUID="04b3e6f5-a4f3-4cc0-adb1-765c39050865" ?>
  <?define CurrMingwLibsGUID="bd31ec38-27a3-415e-b19f-ccd61bc41d9a" ?>
  <?define CurrDocumentsGUID="ff70f640-1a87-4eed-9897-277059e55c4f" ?>
  <?define CurrConfigFileGUID="fbe1473f-de4d-4ca2-a8a4-66f3f92fff7d" ?>
  <?define CurrStartMenuGUID="0b577f55-1ca5-43b8-9df2-3834843fc80b" ?>
  <?define CurrDesktopGUID="0e7e07f2-b21b-49ea-a25e-569eae46e0ce" ?>
  <?define CurrDocsOnDesktopGUID="783fb5f6-835d-4a81-988b-d46c683ac0e2" ?>
  <?define CurrStartupGUID="60bc5fc3-74d2-4d7b-a659-8acebea93aa4" ?>
  <?define CurrLocalProgramsGUID="e0c517aa-5eb7-4909-a23f-7fccd7fddeef" ?>

  <Product Name="Polipo $(var.ThisProductVersionDisp)" Id="$(var.CurrProductGUID)"
           Version="$(var.ThisProductVersion)"
           Manufacturer="mailto: coderman at gmail.com - test package for The Tor Project, Inc."
           Language="!(loc.LCID)"
           UpgradeCode="$(var.UpgradeCode)">
    
    <Package Id="*" Keywords="Installer"
             Description="Polipo $(var.ThisProductVersionDisp) Installer"
             Manufacturer="mailto: coderman at gmail.com - test package for The Tor Project, Inc."
             InstallerVersion="200" Compressed="yes"
             InstallPrivileges="limited" />

    <Media Id="1" Cabinet="Polipo.cab" CompressionLevel="high"
           EmbedCab="yes" DiskPrompt="CD-ROM #1" />
    <Property Id="DiskPrompt" Value="Polipo $(var.ThisProductVersionDisp) Installation Volume [1]" />
    <Property Id="ALLUSERS" Secure="yes"/>
    <Property Id="ReinstallModeText">omus</Property>

    <!-- To avoid placing shortcuts all over the desktop / start menu during a
    silent installation the NOSC=1 option can be passed to omit shortcuts.
    This is useful if bundled with other applications like Vidalia that manage
    configuration and Tor related processes themselves.
      -->
    <Property Id="NOSC" Secure="yes"/>

    <!-- Associate this package with the upgrade code for this series
    to ensure that upgrade installations by Thandy or other means work
    as expected.
    The OnlyDetect option must be false to ensure that existing files
    from an older version are removed and replaced with current files.
      -->
    <Upgrade Id="$(var.UpgradeCode)">
      <UpgradeVersion
        Property="UPGRADEFOUND"
        OnlyDetect="no"
        Minimum="0.0.0"
        IncludeMinimum="yes"
        Maximum="$(var.ThisProductVersion)"
        IncludeMaximum="no"
      />
    </Upgrade>


    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="LocalAppDataFolder" Name="LocalAppData">
       <Directory Id="LocalProgramsFolder" Name="Programs">

         <!-- Until proper support for per-user installs is available we manage Programs folder.
         Note that this directory will be left in place if it is in use by any other app.
           -->
         <Component Id="LocalProgramsFolderRef" Guid="$(var.CurrLocalProgramsGUID)">
           <CreateFolder />
           <RemoveFolder Id="RemoveLocalProgramsFolder" On="uninstall" />
           <RegistryKey Root="HKCU" Key="Software\Polipo" Action="createAndRemoveOnUninstall">
             <RegistryValue Name="LocalProgramsFolderRef" Value="1" Type="integer" KeyPath="yes" />
           </RegistryKey>
         </Component>

         <Directory Id="LocalProgramsInstDir" Name="Polipo">

          <!-- Main Polipo application files -->
          <Component Id="PolipoExecutable" Guid="$(var.CurrExecutableGUID)">
            <CreateFolder/>
            <RemoveFolder Id="RemoveLocalProgramsInstDir" On="uninstall" />
            <RegistryKey Root="HKCU" Key="Software\Polipo" Action="createAndRemoveOnUninstall">
              <RegistryValue Name="Version" Value="$(var.ThisProductVersionDisp)" Type="string" KeyPath="yes" />
            </RegistryKey>
            <File Id="PolipoExe" DiskId="1"
                  Name="polipo.exe" Source="bin\polipo.exe" />
          </Component>

          <!-- MinGW-related library files -->
          <Component Id="MinGWLibrary" Guid="$(var.CurrMingwLibsGUID)">
            <RegistryKey Root="HKCU" Key="Software\Polipo" Action="createAndRemoveOnUninstall">
              <RegistryValue Name="MinGWLibrary" Value="1" Type="integer" KeyPath="yes" />
            </RegistryKey>
            <File Id="MinGWDll" DiskId="1"
                  Name="mingwm10.dll" Source="bin\mingwm10.dll" />
          </Component>

          <!-- GNU RegEx library files -->
          <Component Id="GnuRegExLibrary" Guid="$(var.CurrRegExLibsGUID)">
            <RegistryKey Root="HKCU" Key="Software\Polipo" Action="createAndRemoveOnUninstall">
              <RegistryValue Name="RegExLibrary" Value="1" Type="integer" KeyPath="yes" />
            </RegistryKey>
            <File Id="gnurxdll" DiskId="1"
                  Name="libgnurx-0.dll" Source="bin\libgnurx-0.dll" />
          </Component>

         </Directory>
        </Directory>

        <Directory Id="INSTALLDIR" Name="Polipo">
          <Component Id="PolipoConfig" Guid="$(var.CurrConfigFileGUID)">
            <CreateFolder />
            <RemoveFolder Id="RemoveINSTALLDIR" On="uninstall" />
            <RegistryKey Root="HKCU" Key="Software\Polipo" Action="createAndRemoveOnUninstall">
              <RegistryValue Name="ConfigFile" Value="1" Type="integer" KeyPath="yes" />
            </RegistryKey>
            <File
              Id="PolipoConfigFile"
              Name="config.txt"
              Source="bin\polipo.conf"
              Vital="yes"
              ReadOnly="no"
              DiskId="1"> 
              <CopyFile
                Id="PolipoSavedConfig"
                DestinationName="save-cfg.txt"
              />
            </File>
          </Component>

        </Directory>
      </Directory>

      <Directory Id="ProgramMenuFolder" Name="Programs">
        <Directory Id="ShortcutFolder" Name="Polipo">
          <Component Id="AddPolipoToStartMenu" Guid="$(var.CurrStartMenuGUID)">
            <Condition><![CDATA[NOSC <> 1]]> </Condition>
            <RegistryKey Root="HKCU" Key="Software\Polipo" Action="createAndRemoveOnUninstall">
              <RegistryValue Name="StartMenuShortcut" Value="1" Type="integer" KeyPath="yes" />
            </RegistryKey>
            <Shortcut Id="PolipoStartMenuShortcut"
                      Name="Polipo" Target="[LocalProgramsInstDir]polipo.exe"
                      Directory="ShortcutFolder" WorkingDirectory="LocalProgramsInstDir" />
            <RemoveFolder Id="RemoveShortcutFolder" On="uninstall" />
          </Component>
        </Directory>
      </Directory>

      <Directory Id="DesktopFolder" Name="Desktop">
        <Component Id="AddPolipoToDesktop" Guid="$(var.CurrDesktopGUID)">
          <Condition><![CDATA[NOSC <> 1]]> </Condition>
          <RegistryKey Root="HKCU" Key="Software\Polipo" Action="createAndRemoveOnUninstall">
            <RegistryValue Name="DesktopShortcut" Value="1" Type="integer" KeyPath="yes" />
          </RegistryKey>
          <Shortcut Id="PolipoDesktopShortcut"
                    Name="Polipo" Target="[LocalProgramsInstDir]polipo.exe"
                    Directory="DesktopFolder" WorkingDirectory="LocalProgramsInstDir" />
        </Component>
      </Directory>

      <Component Id="AddToStartupItems" Guid="$(var.CurrStartupGUID)">
        <Condition><![CDATA[NOSC <> 1]]> </Condition>
        <RegistryKey Root="HKCU"
                     Key="Software\Microsoft\Windows\CurrentVersion\Run"
                     Action="createAndRemoveOnUninstall">
          <RegistryValue Name="Polipo" Value='"[LocalProgramsInstDir]polipo.exe"' Type="string" />
        </RegistryKey>
      </Component>
    </Directory>

    <!-- Build up the feature hierarchy -->
    <Feature Id="Complete" Title="Polipo"
             Level="1" Display="expand" ConfigurableDirectory="INSTALLDIR"
             Description="Polipo is application that helps you control, monitor, and configure the Tor software.">
      <Feature Id="MainApplication" Title="Polipo $(var.ThisProductVersionDisp)"
               AllowAdvertise="no" Absent="disallow" Level="1"
               Description="Main application">
        <ComponentRef Id="LocalProgramsFolderRef" />
        <ComponentRef Id="PolipoExecutable" />
        <ComponentRef Id="MinGWLibrary" />
        <ComponentRef Id="GnuRegExLibrary" />
        <ComponentRef Id="PolipoConfig" />
      </Feature>
      <Feature Id="Shortcuts" Title="Shortcuts"
               AllowAdvertise="no" Absent="allow" Level="1"
               Description="Add a shortcut to Polipo to your Start menu or Desktop.">
        <Feature Id="StartMenuShortcuts" Title="Add to Start menu"
                 AllowAdvertise="no" Absent="allow" Level="1"
                 Description="Add Polipo to your Start menu">
          <ComponentRef Id="AddPolipoToStartMenu" />
        </Feature>
        <Feature Id="DesktopShortcuts" Title="Add to Desktop"
                 AllowAdvertise="no" Absent="allow" Level="1"
                 Description="Add Polipo to your Desktop">
          <ComponentRef Id="AddPolipoToDesktop" />
        </Feature>
        <Feature Id="RunAtStartup" Title="Run at Startup"
                 AllowAdvertise="no" Absent="allow" Level="1"
                 Description="Run Polipo automatically when your system starts">
          <ComponentRef Id="AddToStartupItems" />
        </Feature>
      </Feature>
    </Feature>

    <!-- Upgrade installation sequence. -->
    <InstallExecuteSequence>
      <RemoveExistingProducts After="InstallValidate" />
    </InstallExecuteSequence>

    <!-- Set the UI options -->
    <UIRef Id="WixUI_Custom" />
    <WixVariable Id="WixUIBannerBmp" Value="default-header.bmp" />
    <WixVariable Id="WixUIDialogBmp" Value="default-welcome.bmp" />
  </Product>
</Wix>
