#!/bin/bash
# WineTools was initially written by Frank Hendriksen <frank@franksworld.net>
# and was extended by Joachim von Thadden <thadden@web.de>. It is not nice
# and looks like horror. But it works!
# 
# It is licensed under the GPL.
# 
# Send comments, bugreports, etc. to thadden@web.de"

# base definitions
BASEDIR="/usr/local/winetools"
BINDIR="$HOME/bin"
DIALOG="$BASEDIR/Xdialog"
WINEDIR="`echo ~/.wine`"
CONFIG="$WINEDIR/winetools.log"
SYSDIR="$HOME/winetools"
INIWAIT="600"
WAIT=$INIWAIT
CHOP="$BASEDIR/chopctrl.pl"
CDROM="`ls -l $HOME/.wine/dosdevices/ 2>/dev/null | grep \" d: -> \"| sed -e \"s/^.* d: -> \(.*\)$/\1/\"`"
[ "$SFMIRROR" = "" ] && SFMIRROR="http://mesh.dl.sourceforge.net/sourceforge"

#for Debian:
#BASEDIR="/usr/share/winetools"
#DIALOG="/usr/bin/Xdialog"

# to generate the pot template use "xgettext -L Shell -o po/wt2.pot  wt212jo findwine"
# to generate a language template for your language call "msginit" in the directory po

init()
{
  unset WINEDLLOVERRIDES
  URL=""
  installer=""
  testname=""
  script=""
  winever=""
  dlsize=""
  dload=""
}


cleantmp()
{
  rm -Rf "$SYSDIR/sys/tmp/*"
}


wineboot()
{
  waitforwineexit
  $DIALOG  --title "`eval_gettext "*** NOTICE ***"`" \
	   --no-buttons --infobox "`eval_gettext "Simulating a Windows reboot. Please wait..."`" 7 60
  $WINE wineboot
}


waitforwineexit()
{
      n=0
      wdbcount="0"
      echo "`eval_gettext "waiting for wineservers to exit..."`"
      $DIALOG  --title "`eval_gettext "*** NOTICE ***"`" \
	       --no-buttons --infobox "`eval_gettext "Waiting $WAIT seconds for wineservers to exit...\nPlease wait..."`" 7 60
#      while [ "$n" != "$WAIT" ]; do
      while [ true ]; do
        ps xwww --User $USER |grep "wineserver"|grep -v "grep wineserver" &>/dev/null
	[ "$?" != "0" ] && break
	ps xwww --User $USER |grep winedbg|grep -v "grep winedbg" &>/dev/null
	if [ "$?" = "0" ]; then
	  if [ "$wdbcount" = "3" ]; then
	    $DIALOG --title "`eval_gettext "wine status"`" \
	      --cancel-label "`eval_gettext "kill debugger"`" \
	      --ok-label "`eval_gettext "continue"`" \
	      --yesno "`eval_gettext "The wine debugger was startet. If your installation does not continue\nfor a while you should switch to the console where you started winetools\nfrom to debug or let me kill it to continue here.\nSometimes you don't have to do anything to continue."`" 9 70	#'
	    if [ "$?" !=   "0" ]; then
	      for n in `ps xwww --User $USER|grep winedbg|grep -v "grep winedbg"|sed -e "s/^\(.\+\)pts.\+$/\1/"`; do
	        kill $n
	      done
	      sleep 1s
	      for n in `ps xwww --User $USER|grep winedbg|grep -v "grep winedbg"|sed -e "s/^\(.\+\)pts.\+$/\1/"`; do
	        kill -9 $n
	      done
	    fi
            $DIALOG  --title "`eval_gettext "*** NOTICE ***"`" \
                     --no-buttons --infobox "`eval_gettext "Waiting $WAIT seconds for wineservers to exit...\nPlease wait..."`" 7 60
	  else
	    wdbcount=$(($wdbcount+1))
	  fi
	else
	  wdbcount="0"
	fi
	n=$(($n+1))
	sleep 1s
        if [ "$n" = "$WAIT" ]; then
          $DIALOG --title "`eval_gettext "wine status"`" --no-cancel \
	          --msgbox "`eval_gettext "There is still a wineserver running after $n seconds waiting.\n
On slow computers or while downloading files this need not mean\n
anything. If you think Wine hangs, you may consider killing it\n
on the console by typing \"wineserver -kill\"."`" 9 60
	  n=0
        fi
      done
      if [ "$n" = "$WAIT" ]; then
        $DIALOG --title "`eval_gettext "wine status"`" --no-cancel \
	  --msgbox "`eval_gettext "There is still a wineserver running after $n seconds waiting.\nOn slow computers or while downloading files this need not mean\nanything. If you think Wine hangs, you may consider killing it."`"  7 60
      else
        echo "`eval_gettext "all wineservers endet after $n seconds..."`"
      fi
}


#########################
### Create fake drive ###
#########################
function createdrive()
{
  WAIT=10
  waitforwineexit
  WAIT=$INIWAIT
  if [ -d ${HOME}/.wine ]; then
    $DIALOG --title "WineTools" \
        --yesno "`eval_gettext "Remove existing Wine configuration?"`" 7 60
    [ "$?" = "1" ] && return
  fi

  cdrommount="`grep -e "cdrom" -e "dvd" -e "supermount" /etc/fstab`"	#|cut -d\  -f 1|paste -s|sed -e "s/	/,/"`"
  [ "$cdrommount" = "" ] && cdrommount="/mnt/cdrom"
  $DIALOG --title "`eval_gettext "Create Fake Windows Drive"`" \
  	--inputbox "`eval_gettext "What's the mount point of the cdrom/dvd drive?\n\nYour /etc/fstab says:\n$cdrommount"`" \
	600x300 "`echo "$cdrommount"|sed -e "s/\ \+/ /g"|tr '\t' ' '|cut -d\  -f 2|head -1`" 2> /tmp/cdrom.tmp.$$	#'
  retval=$?
  if [ "$retval" = "0" ]; then
    cdrommount=`cat /tmp/cdrom.tmp.$$`
    rm -f /tmp/cdrom.tmp.$$
  else
    cdrommount=""
    return
  fi

  [ "$username" = "" ] && username="`grep \"^${LOGNAME}:\" /etc/passwd|cut -d: -f 5`"
  $DIALOG --title "`eval_gettext "Create Fake Windows Drive"`" \
  	--inputbox "`eval_gettext "What's your username?"`" \
	600x300 "$username" 2> /tmp/username.tmp.$$	#'
  retval=$?
  if [ "$retval" = "0" ]; then
    username=`cat /tmp/username.tmp.$$`
    rm -f /tmp/username.tmp.$$
  else
    username="Change preferred owner in ~/.wine/system.reg"
    return
  fi

  [ "$organization" = "" ] && organization="`cat /etc/sysconfig/organization 2>/dev/null`"
  $DIALOG --title "`eval_gettext "Create Fake Windows Drive"`" \
  	--inputbox "`eval_gettext "What's your organization?"`" \
	600x300 "$organization" 2> /tmp/organization.tmp.$$	#'
  retval=$?
  if [ "$retval" = "0" ]; then
    organization=`cat /tmp/organization.tmp.$$`
    rm -f /tmp/organization.tmp.$$
  else
    organization="Change preferred organization in ~/.wine/system.reg"
    return
  fi

  cd ~
  rm -Rf .wine
  mkdir ~/.wine
  cp "$BASEDIR/config.empty" "$WINEDIR/config"
  wineprefixcreate
  waitforwineexit
  # now we have to check whether we have a suitable configuration now
  if [ ! -e "$WINEDIR/drive_c/windows/regedit.exe" ] && [ ! -e "$WINEDIR/c/windows/regedit.exe" ] && [ ! -e "$WINEDIR/fake_windows/windows/regedit.exe" ]; then
    rm -f /tmp/links.tmp.$$
    $DIALOG --title "`eval_gettext "Create Fake Windows Drive"`" \
          --inputbox "`eval_gettext "Since your Wine installation did not create a suitable\n.wine directory on it's own, WineTools will do it for you.\nWhat's the base directory of your wine installation?\ne.g. /usr/lib/wine:"`" \
  	  400x300 "/usr/lib/wine" 2> /tmp/links.tmp.$$
    if [ "$?" = "0" ]; then
      # we have no configuration yet, so we copy one
      rm -Rf .wine
      tar -xpvzf "$BASEDIR/wineinit.tar.gz"
      cp "$BASEDIR/config.empty" "$WINEDIR/config"
      cd ~
      wine rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall 128 wine.inf
      # change filesystem links
      winelinks=`cat /tmp/links.tmp.$$`
      rm -f /tmp/links.tmp.$$
      [ "$winelinks" = "" ] && winelinks="/usr/lib/wine"
      for n in `find $WINEDIR/drive_c/windows -lname '/usr/lib/wine/*'`; do
#       linkdestold="`stat -c %N $n |cut -d -f3|cut -d -f1`"	# german
#	linkdestold="`stat -c %N $n |cut -d -f2|cut -d -f1`"	# spanish
#	linkdestold="`LANG=de_DE@euro stat -c %N "$n" |cut -d -f3|cut -d -f1`"	# german unified, hope it works
	linkdestold="`LANG=C stat -c %N "$n"|sed -e "s/^.* -> ..\?\(\/.*\)..\?$/\1/"`"
        linkdestnew="$winelinks/`basename "${linkdestold}" ".so"`"
        echo "`eval_gettext "changing link $n to ${linkdestnew}.so"`"
#       ln -sf "$linkdestnew" "$n"	# old version
	ln -sf "${linkdestnew}.so" "$n"	# unified
      done
    else
      rm -Rf .wine
      $DIALOG --title "`eval_gettext "Create Fake Windows Drive"`" \
	--no-cancel \
	--msgbox "`eval_gettext "Fake Windows drive *not* created!"`" 7 60
      return
    fi
  fi

  mv "$WINEDIR/drive_c/windows/winhlp32.exe" "$WINEDIR/drive_c/windows/winhlp32.exe.wine"
  # mv "$WINEDIR/drive_c/windows/system/regsvr32.exe" "$WINEDIR/drive_c/windows/system/regsvr32.exe.wine"
  cp $BASEDIR/scripts/dos "$BINDIR"
  cp $BASEDIR/scripts/uninstall "$BINDIR"

  # find drive C:
  DRIVEC=""
  [ -d "$WINEDIR/drive_c" ] && [ ! -h "$WINEDIR/drive_c" ] && { DRIVEC="$WINEDIR/drive_c";others="c fake_windows"; }
  [ -d "$WINEDIR/c" ] && [ ! -h "$WINEDIR/c" ] && { DRIVEC="$WINEDIR/c";others="drive_c fake_windows"; }
  [ -d "$WINEDIR/fake_windows" ] && [ ! -h "$WINEDIR/fake_windows" ] && { DRIVEC="$WINEDIR/fake_windows";others="c drive_c"; }
  [ "$DRIVEC" = "" ] && { echo "`eval_gettext "no fake drive C: found! Setting to $WINEDIR/drive_c!"`";DRIVEC="$WINEDIR/drive_c";mkdir -p "$DRIVEC"; }
  [ "$DRIVEC" = "" ] || echo "`eval_gettext "Drive C: is $DRIVEC, links will be made for $others"`"
  for n in $others; do
    ln -s "$DRIVEC" "$WINEDIR/$n"
  done
  
  # find ... to create links
  # "ProgramFiles" "CommonFilesDir" "ProgramFilesDir"
  grep "\"ProgramFiles\"=\"" $WINEDIR/system.reg | cut -d\" -f 4 | sed -e "s/c:\\\\\\\//" -e "s@\\\\\\\@/@g" > $WINEDIR/PF.tmp
  LocalizedDir=`cat "$WINEDIR/PF.tmp"`
  if [ "$LocalizedDir" != "Program Files" ]; then
    echo "linking \"$WINEDIR/c/${LocalizedDir}\" to \"$WINEDIR/c/Program Files\""
    mv "$WINEDIR/c/${LocalizedDir}/"* "$WINEDIR/c/Program Files"
    rmdir "$WINEDIR/c/${LocalizedDir}"
    ln -s "$WINEDIR/c/Program Files" "$WINEDIR/c/${LocalizedDir}"
  fi
  grep "\"CommonFilesDir\"=\"" $WINEDIR/system.reg | cut -d\" -f 4 | sed -e "s/c:\\\\\\\//" -e "s@\\\\\\\@/@g" > $WINEDIR/PF.tmp
  LocalizedDir=`cat "$WINEDIR/PF.tmp"`
  if [ "$LocalizedDir" != "Program Files/Common Files" ]; then
    echo "linking \"$WINEDIR/c/${LocalizedDir}\" to \"$WINEDIR/c/Program Files/Common Files\""
    mv "$WINEDIR/c/${LocalizedDir}/"* "$WINEDIR/c/Program Files/Common Files"
    rmdir "$WINEDIR/c/${LocalizedDir}"
    ln -s "$WINEDIR/c/Program Files/Common Files" "$WINEDIR/c/${LocalizedDir}"
  fi
  rm "$WINEDIR/PF.tmp"

  cp $BASEDIR/config.212 $WINEDIR/config
  ln -s ${cdrommount} $WINEDIR/dosdevices/d:
  ln -s /tmp ~/.wine/dosdevices/e:
  ln -s $SYSDIR ~/.wine/dosdevices/f:
  ln -s $HOME ~/.wine/dosdevices/h:
  ln -s /tmp ~/.wine/dosdevices/t:
  echo "*new* fake Windows drive = installed at `date \"+%d.%m.%Y %H:%M:%S\"`" >>$CONFIG
  touch "$WINEDIR/c/config.sys"
  touch "$WINEDIR/c/autoexec.bat"
  [ -e "$HOME/.wine/drive_c/Programme" ] || ln -s "$HOME/.wine/c/Program Files" "$HOME/.wine/drive_c/Programme"
  ln -s /tmp "$HOME/.wine/c/tmp"
  ln -s /tmp "$HOME/.wine/c/temp"

  CDROM="`ls -l $HOME/.wine/dosdevices/|grep \" d: -> \"| sed -e \"s/^.* d: -> \(.*\)$/\1/\"`"

  # replace user and organization  
  sed -e "s@Change preferred owner in ~/.wine/system.reg@$username@g" $WINEDIR/system.reg > $WINEDIR/system.reg1
  sed -e "s@Change preferred organization in ~/.wine/system.reg@$organization@g" $WINEDIR/system.reg1 > $WINEDIR/system.reg
  rm $WINEDIR/system.reg1
  
  wineboot
  
  . ${BASEDIR}/findwine

  $DIALOG --title "`eval_gettext "Create Fake Windows Drive"`" \
	--no-cancel \
	--msgbox "`eval_gettext "Fake Windows drive created in ~/.wine."`" 7 60
}


add_printcap_printers()
{
  PRINTERS="`cat /etc/printcap|grep -v \"^.*:.*:\\\\\*$\"|grep -v \"^#\"|sed -e \"s/\(.*\):\\\\\/\1/\"`"
  echo $PRINTERS
  grep -i "^\[ppd\]$" ~/.wine/config &>/dev/null
  if [ "$?" = "0" ]; then
    $DIALOG --title "`eval_gettext "Add printcap printers"`" \
	--no-cancel \
	--msgbox "`eval_gettext "You already have printers defined in your config. Please edit this manually."`" 7 80
  else
    $DIALOG --title "`eval_gettext "Add printcap printers"`" \
	--inputbox "`eval_gettext "What's the path to your ppd-file?\n
e.g. /usr/share/wine/generic.ppd"`" 300x200 "/usr/share/wine/generic.ppd" 2> /tmp/ppd.tmp.$$	#'

    retval=$?

    ppdpath=`cat /tmp/ppd.tmp.$$`
    rm -f /tmp/ppd.tmp.$$
    [ "$ppdpath" = "" ] && ppdpath="/usr/share/wine/generic.ppd"

    case $retval in
      0)
         echo -e "\n[ppd]" >> ~/.wine/config
         num=0
         for n in $PRINTERS; do
           echo "\"$n\" = \"/usr/share/wine/generic.ppd\"" >> ~/.wine/config
           num=$(($num+1))
         done
         echo -e "; [ppd] end of section\n" >> ~/.wine/config

         wineboot
         $DIALOG --title "`eval_gettext "Add printcap printers"`" \
	    --no-cancel \
	    --msgbox "`eval_gettext "$num printers added to your config."`" 7 60
	 ;;
    esac
  fi
}


##################
### Fonts menu ###
##################
function fonts()
{
init
needsw  "\*new\* fake Windows drive" "--no-cancel"
needsw "dcom98.exe" "--no-cancel"
needsw "Microsoft Internet Explorer.*" "--no-cancel"

$DIALOG --title "`eval_gettext "TrueType Fonts"`" \
	--cancel-label "`eval_gettext "Main menu"`" \
	--check "`eval_gettext "Show Info"`" \
	--icon $BASEDIR/icon/font.xpm \
        --menu "`eval_gettext "
*** Microsoft's TrueType core fonts ***
These fonts are needed by many Windows programs
so you should install them. Note that you install them
for Wine, not for your whole Linux system. Use the
\"Show Info\" feature to learn more about the fonts.
"`" 400x400 0 \
        "Andale" "" \
        "Arial Black" "" \
        "Comic Sans" "" \
        "Courier New"  "" \
        "Georgia"  "" \
	"Impact"  "" \
	"Times New Roman"  "" \
	"Trebuchet"  "" \
	"Verdana"  "" \
	"Webdings"  "" 2> /tmp/menu.tmp.$$ #'
	
retval=$?

choice=`cat /tmp/menu.tmp.$$|grep -v "checked"`
checked="F"
[ "`cat /tmp/menu.tmp.$$|grep \"checked\"`" = "checked" ] && checked="T"

rm -f /tmp/menu.tmp.$$

case $retval in
0)

echo "`eval_gettext "Choice is $choice"`"
case "$choice" in
"Andale")
  URL="http://corefonts.sourceforge.net/"
  showinfo || {
    fontname="andale32.exe"
    dlsize="198384"
    fontsinstall
  }
;;
"Arial Black")
  URL="http://corefonts.sourceforge.net/"
  showinfo || {
    fontname="arialb32.exe"
    dlsize="168176"
    fontsinstall
  }
;;
"Comic Sans")
  URL="http://corefonts.sourceforge.net/"
  showinfo || {
    fontname="comic32.exe"
    dlsize="246008"
    fontsinstall
  }
;;
"Courier New")
  URL="http://corefonts.sourceforge.net/"
  showinfo || {
    fontname="courie32.exe"
    dlsize="646368"
    fontsinstall
  }
;;
"Georgia")
  URL="http://corefonts.sourceforge.net/"
  showinfo || {
    fontname="georgi32.exe"
    dlsize="392440"
    fontsinstall
  }
;;
"Impact")
  URL="http://corefonts.sourceforge.net/"
  showinfo || {
    fontname="impact32.exe"
    dlsize="173288"
    fontsinstall
  }
;;
"Times New Roman")
  URL="http://corefonts.sourceforge.net/"
  showinfo || {
    fontname="times32.exe"
    dlsize="661728"
    fontsinstall
  }
;;
"Trebuchet")
  URL="http://corefonts.sourceforge.net/"
  showinfo || {
    fontname="trebuc32.exe"
    dlsize="357200"
    fontsinstall
  }
;;
"Verdana")
  URL="http://corefonts.sourceforge.net/"
  showinfo || {
    fontname="verdan32.exe"
    dlsize="351992"
    fontsinstall
  }
;;
"Webdings")
  URL="http://corefonts.sourceforge.net/"
  showinfo || {
    fontname="webdin32.exe"
    dlsize="185072"
    fontsinstall
  }
esac
fonts
;;
1)
    mainmenu
;;
esac
}

##############################
### Fonts download/install ###
##############################
function fontsinstall()
{
cd $SYSDIR/fonts

dload="$SFMIRROR/corefonts/${fontname}"
sysname="${fontname}"
realinstall "" "--nofail"
}


#########################################
### Install system software and files ###
#########################################
function testsw()
{
    echo "$1"
    # test via registry
    $WINE regedit /e ~/.wine/installed.reg "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
    grep "\"DisplayName\"=" ~/.wine/installed.reg | sed -e "s/.*=\"\(.*\)\".*/\1/g"|sort > $HOME/.wine/installed-software
    grep "QuietDisplayName\"=" ~/.wine/installed.reg | sed -e "s/.*=\"\(.*\)\".*/\1/g"|sort > $HOME/.wine/quiet-installed-software
    rm ~/.wine/installed.reg
    grep "^$1$" ~/.wine/installed-software
    if [ "$?" = "0" ]; then
      echo "`eval_gettext "software installation verified by registry value"`"
    else
      grep "^$1$" ~/.wine/quiet-installed-software
      if [ "$?" = "0" ]; then
        echo "`eval_gettext "software installation verified by quiet registry value"`"
      else
#        # test via path
#        testfile=`winepath -u "$1"`
#        if [ -s "$testfile" ]; then
#          echo "software installation verified by path"
#        else
          # test via logfile
	  echo "`eval_gettext "software installation verified by $CONFIG"`"
	  grep "^$1 = installed at " $CONFIG
#        fi
      fi
    fi
}


function needsw()
{
  testsw "$1"
  if [ "$?" != "0" ]; then
    echo "`eval_gettext "dependency "$1" *not* fulfilled"`"
    if [ "$2" = "--no-cancel" ]; then
      boxstring="`eval_gettext "This software depends on "`\"$1\".\n`eval_gettext "Your config file states that you have not installed\n"`\"$1\"`eval_gettext " yet. In that case it could be\nthat installation or execution of the software fails."`"
      $DIALOG  --title "`eval_gettext "*** HINT ***"`"\
              --msgbox  "$boxstring" 9 60
    else
      boxstring="`eval_gettext "This software depends on "`\"$1\".\n`eval_gettext "Your config file states that you have not installed\n"`\"$1\"`eval_gettext " yet. In that case you will\nnot be able to install the desired software.\nContinue anyway?"`"
      $DIALOG  --title "`eval_gettext "*** ERROR ***"`" \
               --defaultno --yesno  "$boxstring" 12 60
    fi
    if [ "$?" = "0" ]; then
      # continue anyway
      return 0
    else
      # abort
      return 1
    fi
  else
    echo "`eval_gettext "dependency "$1" fulfilled"`"
  fi
  # continue
  return 0
}


function mustnotsw()
{
  testsw "$1"
  if [ "$?" = "0" ]; then
    $DIALOG  --title "`eval_gettext "*** ERROR ***"`"\ 
             --defaultno --yesno "`eval_gettext "Your config file states that you have already installed $1.\nIn that case the installation of your desired software will fail!\nContinue anyway?"`" 9 70
    if [ "$?" = "0" ]; then
      # continue anyway
      return 0
    else
      # abort
      return 1
    fi
  fi
  # continue
  return 0
}


function showinfo()
{
  if [ "$checked" = "T" ]; then
    [ "$URL" = "" ] && return "0"
    "$BROWSER" "$URL" &
    return "0"
  else
    return "1"
  fi
}


function sysinstallsw()
{
  cd $SYSDIR/sys
  if [ "$dlsize" != "selected" ]; then
    $DIALOG  --title "`eval_gettext "Download File"`" \
             --yesno "`eval_gettext "If you downloaded the file by yourself (e.g. in a different language)\nyou can use this one instead of the default.\nDo you want to use the default?"`" 10 60
  else
    false
  fi
  if [ "$?" = "0" ]; then
    realinstall "$1" "$2"
    failed="$?"
  else
    $DIALOG  --title "`eval_gettext "Select File"`" --fselect "~/.wine/c/" 50 70 2>/tmp/file.tmp.$$
    if [ "$?" = "0" ]; then
      sysname="`cat /tmp/file.tmp.$$`"
      dirname=`dirname "$sysname"`
      filename=`basename "$sysname"`
      rm "$WINEDIR/dosdevices/y:"
      ln -s "$dirname" "$WINEDIR/dosdevices/y:"
      sysname="y:\\$filename"
      installer="$WINE $sysname"
      dload="none"
      dlsize="selected"
      realinstall "$1" "$2"
      failed="$?"
    else
      failed="99"
    fi
    rm /tmp/file.tmp.$$
  fi
  echo "`eval_gettext "Failed: $failed"`"
  return "$failed"
}

function sysinstall()
{
  cd $SYSDIR/sys
  realinstall "$1" "$2"
}

# This function does the real work.
# $1	--noboot	inhibits boot
#	--nocheck	disables check for existing package
# $2	--nofail	disables check for failed
#
function realinstall()
{
if [ "$1" = "--nocheck" ]; then
  shift
else
  if [ "$testname" = "" ]; then
    testsw "$sysname"
  else
    testsw "$testname"
  fi
  if [ "$?" = "0" ]; then
    $DIALOG  --title "`eval_gettext "Software Exists"`"\
             --yesno "`eval_gettext "The config file says the software you want\nto install is already installed. Continue?"`" 7 60
    if [ "$?" != "0" ]; then
      return "99"
    fi
  fi
fi

if [ "$dload" = "none" ]; then
  [ "$dlsize" = "" ] && mount_cd
else
  PROGRESS="`ls -l "$sysname" |sed -e \"s/\ \+/,/g\"|cut -d\, -f5`"
  realdownload=1
  echo "$PROGRESS"

  if [ "$PROGRESS" = "$dlsize" ]; then
#    $DIALOG  --title "Download File Exists" --yesno "The required download file already exists. Do you want to use this one?" 7 60
#    if [ "$?" = "0" ]; then
      realdownload=0
#    else
#      realdownload=1
#    fi
  fi

  if [ "$realdownload" = "1" ]; then
    echo "`eval_gettext "downloading $dload to $sysname with $dlsize bytes..."`"
    PROGRESS="0"
    > $sysname
    {
      wget "$dload" -O "$sysname" 2>wget.errors &
      echo 0
      while [ "$PROGRESS" != "$dlsize" ]
      do
        PROGRESS="`ls -l "$sysname" |sed -e \"s/\ \+/,/g\"|cut -d\, -f5`"
        grep "Not Found." wget.errors &>/dev/null && PROGRESS="$dlsize"
        echo $[PROGRESS*100/dlsize] 
        sleep 1s
      done
      echo 100
    }  | $DIALOG  --title "`eval_gettext "Downloading"`" --gauge "`eval_gettext "Downloading"`" 7 60 0
    grep "Not Found." wget.errors &>/dev/null
    if [ "$?" = "0" ]; then
      echo "$sysname = download failed at `date \"+%d.%m.%Y %H:%M:%S\"`" >>$CONFIG
      ERR="`pwd`/wget.errors"
      $DIALOG --title "`eval_gettext "wine status"`" \
	      --no-cancel \
    	      --msgbox "`eval_gettext "It seems that the download has failed.\nInspect $ERR for reasons."`" 7 70
      return "1"
    fi
  fi

fi

#[ "$installer" = "" ] && installer="$WINE ./$sysname"
#echo "WINEDLLOVERRIDES=\"$WINEDLLOVERRIDES\" $installer"
#$installer
      [ -e "$HOME/.wine/dosdevices/z:" ] && mv "$HOME/.wine/dosdevices/z:" "$HOME/.wine/dosdevices/.z:"
      if [ "$installer" = "" ]; then
        {
	  echo "WINEDEBUG=\"$WINEDEBUG\" WINEDLLOVERRIDES=\"$WINEDLLOVERRIDES\" $WINE ./$sysname"
	  WINEDEBUG="$WINEDEBUG" WINEDLLOVERRIDES="$WINEDLLOVERRIDES" $WINE ./$sysname
	  echo "$?" >/tmp/wineinstall.$$.tmp
        } &
      elif [ "$installer" = "***SEARCH***" ]; then
	# check for autorun first
	if [ -e "${CDROM}/autorun.inf" ]; then
	    echo "found autorun.inf"
	    installer="$WINE D:\\`grep -i "OPEN=" "${CDROM}/autorun.inf"|sed -e "s/[Oo][Pp][Ee][Nn]=\(.*\)$/\1/"`"
	    # chop off the last character if needed
	    installer=`"$CHOP" "$installer"`	#`
	elif [ -e "${CDROM}/[Ss][Ee][Tt][Uu][Pp].[Ee][Xx][Ee]" ]; then
	    installer="$WINE D:\\setup.exe"
	elif [ -e "${CDROM}/[Ii][Nn][Ss][Tt][Aa][Ll][Ll].[Ee][Xx][Ee]" ]; then
	    installer="$WINE D:\\install.exe"
	elif [ -e "${CDROM}/[Ii][Nn][Ss][Tt].[Ee][Xx][Ee]" ]; then
	    installer="$WINE D:\\inst.exe"
	elif [ -e "${CDROM}/[Aa][Uu][Tt][Oo][Pp][Ll][Aa][Yy].[Ee][Xx][Ee]" ]; then
	    installer="$WINE D:\\autoplay.exe"
	else
	    echo "no installer found..."
            $DIALOG --title "`eval_gettext "wine status"`" \
	    	    --no-cancel \
    	            --msgbox "`eval_gettext "WineTools could not find an installer.\nTry again with manually finding it."`" 7 70
	fi
	if [ "$installer" != "***SEARCH***" ]; then
          {
	    echo "installer found as \"$installer\""
	    echo "WINEDEBUG=\"$WINEDEBUG\" WINEDLLOVERRIDES=\"$WINEDLLOVERRIDES\" $installer"
	    WINEDEBUG="$WINEDEBUG" WINEDLLOVERRIDES="$WINEDLLOVERRIDES" $installer
	    echo "$?" >/tmp/wineinstall.$$.tmp
	  } &
	fi
      else
        {
	  echo "WINEDEBUG=\"$WINEDEBUG\" WINEDLLOVERRIDES=\"$WINEDLLOVERRIDES\" $installer"
	  WINEDEBUG="$WINEDEBUG" WINEDLLOVERRIDES="$WINEDLLOVERRIDES" $installer
	  echo "$?" >/tmp/wineinstall.$$.tmp
	} &
      fi
      sleep 3s
      waitforwineexit
      failed="`cat /tmp/wineinstall.$$.tmp`"
      echo "`eval_gettext "Failed: $failed"`"
      [ "$2" = "--nofail" ] && failed="0"
      [ -e "$HOME/.wine/dosdevices/.z:" ] && mv "$HOME/.wine/dosdevices/.z:" "$HOME/.wine/dosdevices/z:"

if [ "$testname" = "" ]; then
  echo "`eval_gettext "check installation by return value..."`"
  [ "$failed" = "0" ] && echo "$sysname = installed at `date \"+%d.%m.%Y %H:%M:%S\"`" >>$CONFIG
  [ "$failed" = "1" ] && echo "$sysname = installation failed at `date \"+%d.%m.%Y %H:%M:%S\"`" >>$CONFIG
else
  echo "`eval_gettext "check installation by path or registry value..."`"
  waitforwineexit
  testsw "$testname"
  failed="$?"
  [ "$failed" = "0" ] && echo "$testname = installed at `date \"+%d.%m.%Y %H:%M:%S\"`" >>$CONFIG
  [ "$failed" = "1" ] && echo "$testname = installation failed at `date \"+%d.%m.%Y %H:%M:%S\"`" >>$CONFIG
fi

[ "$1" = "--noboot" ] || wineboot

echo "`eval_gettext "Failed: $failed"`"

if [ "$failed" != "0" ]; then
  $DIALOG --title "`eval_gettext "wine status"`" \
          --no-cancel \
          --msgbox "`eval_gettext "It seems that the installation has failed."`" 7 70
else
  if [ "$script" != "" ]; then
    for n in $script; do
      if [ -e "$BINDIR/$n" ]; then
        echo -n "`eval_gettext "There is already a script called $n in $BINDIR..."`"
        diff -q "$BASEDIR/scripts/$n" "$BINDIR/$n" &>/dev/null
	if [ "$?" != "0" ]; then
	  echo -n "`eval_gettext " and it is not the same as the one we want to copy!"`"
	  mv -f "$BINDIR/$n" "$BINDIR/$n.wt2save"
	  $DIALOG  --title "`eval_gettext "*** NOTICE ***"`"\
                   --msgbox "`eval_gettext "There is already a script called $n in\n$BINDIR. I renamed this to $n.wt2save."`" 12 60
	fi
	echo ""
      fi
      cp -a "$BASEDIR/scripts/$n" "$BINDIR"
    done
    $DIALOG  --title "`eval_gettext "*** NOTICE ***"`"\
             --msgbox "`eval_gettext "To start the installed software WineTools has copied\nthe following start scripts to your $BINDIR directory:\n\n$script"`" 12 60
  fi
fi

if [ "$dload" = "none" ]; then
  umount_cd
fi

return $failed
}

#########################
###  System Software  ###
#########################
function systemmenu()
{
init
needsw  "\*new\* fake Windows drive" "--no-cancel"
needsw "dcom98.exe" "--no-cancel"
needsw "Microsoft Internet Explorer.*" "--no-cancel"

$DIALOG --title "`eval_gettext "System Software"`" \
	--cancel-label "`eval_gettext "Main menu"`" \
	--icon $BASEDIR/icon/computer.xpm \
	--check "`eval_gettext "Show Info"`" \
        --menu "`eval_gettext "
*** Windows System Software ***
This is very basic software you normaly need for
many programs. Note that you might have to have a
valid license of Windows >98 for that. The MS-Installer
is the most important. For database applications use
the MDAC and Jet installations.
"`" 400x450 0 \
        "Windows Installer"  "" \
	"Visual Basic 5 Runtime" "" \
        "Visual Basic 6 Runtime" "" \
        "Visual C++ run-time English" "" \
        "Visual C++ run-time German" "" \
	"MDAC 2.8 and Jet 4.0 SP8 English" "" \
	"MDAC 2.8 and Jet 4.0 SP8 German" "" \
	"MSXML 4.0 Service Pack 2 English" "" \
	"MSXML 4.0 Service Pack 2 German" "" \
        "Windows Script 5.6 English"  "" \
        "Windows Script 5.6 German"  "" \
	"Common Controls 5.0" "" 2> /tmp/menu.tmp.$$

retval=$?

choice=`cat /tmp/menu.tmp.$$|grep -v "checked"`
checked="F"
[ "`cat /tmp/menu.tmp.$$|grep \"checked\"`" = "checked" ] && checked="T"
rm -f /tmp/menu.tmp.$$

case $retval in
0)

echo "Choice is $choice"
case "$choice" in
"HTML Help Update Package")
# menu was below "Windows Script 5.6 German":
# "HTML Help Update Package" "" \
  URL="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/htmlhelp/html/vsconhh1start.asp"
  showinfo || {
    dload="http://download.microsoft.com/download/winntsrv40/Install/Q323255/NT4/EN-US/hhupd.exe"
    # was: dload="http://go.microsoft.com/fwlink/?LinkId=14498"
    dlsize="750888"
    # was: dlsize="752944"
    sysname="HHUPD.EXE"
    sysinstall
  }
;;
"MDAC 2.8 German")
# obsolete
  URL="http://www.microsoft.com/downloads/details.aspx?displaylang=de&FamilyID=6c050fe3-c795-4b7d-b037-185d0506396c"
  showinfo || {
    dload="http://download.microsoft.com/download/a/b/9/ab965707-fbab-48bc-8c33-a4cfd44255c6/MDAC_TYP.EXE"
    dlsize="5568952"
    sysname="MDAC_TYP.EXE"
    sysinstall
  }
;;
"MDAC 2.8 English")
# obsolete
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=6c050fe3-c795-4b7d-b037-185d0506396c&DisplayLang=en"
  showinfo || {
    dload="http://download.microsoft.com/download/c/d/f/cdfd58f1-3973-4c51-8851-49ae3777586f/MDAC_TYP.EXE"
    dlsize="5556616"
    sysname="MDAC_TYP.EXE"
    sysinstall
  }
;;
"Jet 4.0 SP8 German")
# obsolete
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=4335216c-8cdd-4168-a030-46f815d3f5cd&DisplayLang=de"
  showinfo || {
    needsw "MDAC_TYP.EXE"
    if [ "$?" = "0" ]; then
      dload="http://download.microsoft.com/download/1/3/3/133bff47-685e-4a59-b8ba-b129b4c850a1/Jet40SP8_9xNT.exe"
      dlsize="3877800"
      sysname="Jet40SP8_9xNT.exe"
      sysinstall
    fi
  }
;;
"Jet 4.0 SP8 English")
# obsolete
  URL="http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=4335216c-8cdd-4168-a030-46f815d3f5cd"
  showinfo || {
    needsw "MDAC_TYP.EXE"
    if [ "$?" = "0" ]; then
      dload="http://download.microsoft.com/download/4/3/9/4393c9ac-e69e-458d-9f6d-2fe191c51469/Jet40SP8_9xNT.exe"
      dlsize="3872168"
      sysname="Jet40SP8_9xNT.exe"
      sysinstall
    fi
  }
;;
"MDAC 2.8 and Jet 4.0 SP8 English")
  $DIALOG   --title "`eval_gettext "Hint"`" \
	    --no-cancel \
	    --msgbox "`eval_gettext "Note that the installer will install MDAC twice. Follow\nit, otherwise you will not have all database drivers."`" 7 60
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=6c050fe3-c795-4b7d-b037-185d0506396c&DisplayLang=en"
  showinfo || {
    dload="http://download.microsoft.com/download/c/d/f/cdfd58f1-3973-4c51-8851-49ae3777586f/MDAC_TYP.EXE"
    dlsize="5556616"
    sysname="MDAC_TYP.EXE"
    sysinstall
  }
  URL="http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=4335216c-8cdd-4168-a030-46f815d3f5cd"
  showinfo || {
    needsw "MDAC_TYP.EXE"
    if [ "$?" = "0" ]; then
      dload="http://download.microsoft.com/download/4/3/9/4393c9ac-e69e-458d-9f6d-2fe191c51469/Jet40SP8_9xNT.exe"
      dlsize="3872168"
      sysname="Jet40SP8_9xNT.exe"
      sysinstall
    fi
  }
  [ $checked = "T" ] || {
    dload="http://download.microsoft.com/download/c/d/f/cdfd58f1-3973-4c51-8851-49ae3777586f/MDAC_TYP.EXE"
    dlsize="5556616"
    sysname="MDAC_TYP.EXE"
    sysinstall "--nocheck"
  }
;;
"MDAC 2.8 and Jet 4.0 SP8 German")
  $DIALOG   --title "`eval_gettext "Hint"`" \
	    --no-cancel \
	    --msgbox "`eval_gettext "Note that the installer will install MDAC twice. Follow\nit, otherwise you will not have all database drivers."`" 7 60
  URL="http://www.microsoft.com/downloads/details.aspx?displaylang=de&FamilyID=6c050fe3-c795-4b7d-b037-185d0506396c"
  showinfo || {
    dload="http://download.microsoft.com/download/a/b/9/ab965707-fbab-48bc-8c33-a4cfd44255c6/MDAC_TYP.EXE"
    dlsize="5568952"
    sysname="MDAC_TYP.EXE"
    sysinstall
  }
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=4335216c-8cdd-4168-a030-46f815d3f5cd&DisplayLang=de"
  showinfo || {
    needsw "MDAC_TYP.EXE"
    if [ "$?" = "0" ]; then
      dload="http://download.microsoft.com/download/1/3/3/133bff47-685e-4a59-b8ba-b129b4c850a1/Jet40SP8_9xNT.exe"
      dlsize="3877800"
      sysname="Jet40SP8_9xNT.exe"
      sysinstall
    fi
  }
  [ $checked = "T" ] || {
    dload="http://download.microsoft.com/download/a/b/9/ab965707-fbab-48bc-8c33-a4cfd44255c6/MDAC_TYP.EXE"
    dlsize="5568952"
    sysname="MDAC_TYP.EXE"
    sysinstall "--nocheck"
  }
;;
"MSXML 4.0 Service Pack 2 English")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=3144b72b-b4f2-46da-b4b6-c5d7485f2b42&displaylang=en"
  showinfo || {
    needsw "MDAC_TYP.EXE"
    if [ "$?" = "0" ]; then
      dload="http://download.microsoft.com/download/9/6/5/9657c01e-107f-409c-baac-7d249561629c/msxml.msi"
      dlsize="5289984"
      sysname="msxml.msi"
      installer="$WINE msiexec /i f:\\sys\\msxml.msi"	# /qn ADDLOCAL=MSXML"
      sysinstall
    fi
  }
;;
"MSXML 4.0 Service Pack 2 German")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=3144b72b-b4f2-46da-b4b6-c5d7485f2b42&displaylang=de"
  showinfo || {
    needsw "MDAC_TYP.EXE"
    if [ "$?" = "0" ]; then
      dload="http://download.microsoft.com/download/5/f/d/5fda3c88-bd50-43cf-a845-73614e974e91/msxmlger.msi"
      dlsize="5314560"
      sysname="msxmlger.msi"
      installer="$WINE msiexec /i f:\\sys\\msxmlger.msi"	# /qn ADDLOCAL=MSXML"
      sysinstall
    fi
  }
;;
"Common Controls 5.0")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=6f94d31a-d1e0-4658-a566-93af0d8d4a1e&DisplayLang=en"
  showinfo || {
    dload="http://download.microsoft.com/download/platformsdk/Comctl32/5.80.2614.3600/W9XNT4/EN-US/50comupd.exe"
    sysname="50comupd.exe"
    dlsize="509984"
    sysinstall
  }
;;
"Visual C++ run-time German")
  URL="http://support.microsoft.com/kb/259403/de"
  showinfo || {
    dload="http://download.microsoft.com/download/vc60pro/update/2/w9xnt4/en-us/vc6redistsetup_deu.exe"
    sysname="vc6redistsetup_deu.exe"
    installer="$WINE vc6redistsetup_deu.exe /T:f:\\sys"
    dlsize="1837888"
    sysinstall
    dload="none"
    sysname="vcredist.exe"
    installer=""
    dlsize="none"
    sysinstall
    rm "$SYSDIR/sys/vcredist.exe"
  }
;;
"Visual C++ run-time English")
  URL="http://support.microsoft.com/default.aspx?scid=kb;en-us;259403"
  showinfo || {
    dload="http://download.microsoft.com/download/vc60pro/update/1/w9xnt4/en-us/vc6redistsetup_enu.exe"
    sysname="vc6redistsetup_enu.exe"
    installer="$WINE vc6redistsetup_enu.exe /T:f:\\sys"
    dlsize="1833232"
    sysinstall
    dload="none"
    sysname="vcredist.exe"
    installer=""
    dlsize="none"
    sysinstall
    rm "$SYSDIR/sys/vcredist.exe"
  }
;;
"Visual Basic 5 Runtime")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=05ae09e6-082a-4cd1-99cd-8911b6034c20&DisplayLang=en"
  showinfo || {
    dload="http://download.microsoft.com/download/vb50pro/utility/1/win98/EN-US/Msvbvm50.exe"
    sysname="Msvbm50.exe"
    dlsize="992864"
    sysinstall
  }
;;
"Visual Basic 6 Runtime")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=bf9a24f9-b5c5-48f4-8edd-cdf2d29a79d5&DisplayLang=en"
  showinfo || {
    dload="http://download.microsoft.com/download/vb60pro/Redist/sp5/WIN98Me/EN-US/vbrun60sp5.exe"
    sysname="vbrun60sp5.exe"
    dlsize="1044168"
    sysinstall
  }
;;
"Windows Installer")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=cebbacd8-c094-4255-b702-de3bb768148f&DisplayLang=en"
  showinfo || {
    $DIALOG  --title "*** WARNING ***" --defaultyes --yesno "`eval_gettext "Although it is generally a good idea to install the Windows Installer it could\nbe that some very old installer based installations will fail afterwards.\nContinue anyway?"`" 9 70
    if [ "$?" = "0" ]; then
      dload="http://download.microsoft.com/download/WindowsInstaller/Install/2.0/W9XMe/EN-US/InstMsiA.exe"
      sysname="InstMsiA.exe"
      dlsize="1709160"
      sysinstall
    fi
  }
;;
"Windows Script 5.6 English")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=0a8a18f6-249c-4a72-bfcf-fc6af26dc390&DisplayLang=en"
  showinfo || {
    dload="http://download.microsoft.com/download/winscript56/Install/5.6/W9XNT4Me/EN-US/scr56en.exe"
    sysname="scr56en.exe"
    dlsize="732768"
    sysinstall
  }
;;
"Windows Script 5.6 German")
  URL="http://www.microsoft.com/downloads/details.aspx?displaylang=de&FamilyID=0a8a18f6-249c-4a72-bfcf-fc6af26dc390"
  showinfo || {
    dload="http://download.microsoft.com/download/f/6/5/f655b268-b18b-4e36-b698-b52b766fd5e2/scr56de.exe"
    sysname="scr56de.exe"
    dlsize="695768"
    sysinstall
  }
;;
esac
systemmenu
;;

1)
    mainmenu
;;
esac
}


#########################
###     Base Setup    ###
#########################
systemsoftware()
{
init

$DIALOG --title "`eval_gettext "Base Setup"`" \
	--cancel-label "`eval_gettext "Main menu"`" \
	--icon $BASEDIR/icon/computer.xpm \
	--check "`eval_gettext "Show Info"`" \
        --menu "`eval_gettext "
This is the point where you have to start with
WineTools. Go through every point of this
menu before you continue with installations.
The last point is optional and only valuable
for very old distributions.
"`" 400x400 0 \
	"`eval_gettext "Create a fake Windows drive"`" "" \
	"TrueType Font Arial" "" \
        "DCOM98" "" \
	"Microsoft Foundation Classes 4.0" "" \
	"Internet Explorer 6.0 SP1 English" "" \
	"Internet Explorer 6.0 SP1 German" "" \
	"Internet Explorer 6.0 SP1 Brazilian" "" \
	"Internet Explorer 6.0 SP1 French" "" \
	"Internet Explorer 6.0 SP1 Norwegian" "" \
	" " "" \
	"`eval_gettext "Add printcap (non CUPS) printers"`" "" 2> /tmp/menu.tmp.$$
	
retval=$?

choice=`cat /tmp/menu.tmp.$$|grep -v "checked"`
checked="F"
[ "`cat /tmp/menu.tmp.$$|grep \"checked\"`" = "checked" ] && checked="T"
rm -f /tmp/menu.tmp.$$

case $retval in
0)

echo "`eval_gettext "Choice is $choice with checked=$checked"`"
case "$choice" in
"`eval_gettext "Create a fake Windows drive"`")
  URL="http://www.von-thadden.de/Joachim/WineTools/"
  showinfo || {
    createdrive
  }
;;
"TrueType Font Arial")
  URL="http://corefonts.sourceforge.net/"
  showinfo || {
    fontname="arial32.exe"
    dlsize="554208"
    fontsinstall
  }
;;
"DCOM98")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=08b1ac1b-7a11-43e8-b59d-0867f9bdda66&DisplayLang=en"
  showinfo || {
    dload="http://download.microsoft.com/download/d/1/3/d13cd456-f0cf-4fb2-a17f-20afc79f8a51/DCOM98.EXE"
    dlsize="1229056"
    sysname="dcom98.exe"
    export WINEDLLOVERRIDES="ole32=n"
    sysinstall
  }
;;
"Microsoft Foundation Classes 4.0")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=08b1ac1b-7a11-43e8-b59d-0867f9bdda66&DisplayLang=en"
  showinfo || {
    dload="http://www.dlldump.com/dllfiles/M/mfc40.dll"
    dlsize="924432"
    sysname="mfc40.dll"
    installer="cp mfc40.dll $WINEDIR/c/windows/system"
    sysinstall "--noboot"
  }
;;
"Internet Explorer 6.0 SP1 German"|"Internet Explorer 6.0 SP1 English"|"Internet Explorer 6.0 SP1 Brazilian"|"Internet Explorer 6.0 SP1 French"|"Internet Explorer 6.0 SP1 Norwegian")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=1e1550cb-5e5d-48f5-b02b-20b602228de6&displaylang=en"
  showinfo || {
    needsw dcom98.exe
    needsw mfc40.dll
    if [ "$?" = "0" ]; then
      #if [ -s "$WINEDIR/installed-software" ] || [ -s "$WINEDIR/quiet-installed-software" ]; then
      #    $DIALOG  --title "`eval_gettext "*** WARNING ***"`" --defaultno --yesno \
      #             "`eval_gettext "You already installed software!!!\n\nAfter the installation of IE6 your system.reg will be replaced!\nYou will loose all registry keys of installed programs (except for DCOM98)!\nThis could mean that these already installed programs have to\nbe reinstalled or repaired after the installation of IE6.\n\nContinue anyway?"`" 14 70
      #fi
      if [ "$?" = "0" ]; then
        $DIALOG  --title "`eval_gettext "*** HINT ***"`" --msgbox "`eval_gettext "This is a full automatic installation of almost all\ncomponents of IE6 and Media Player 6.4.\nYou can add additional components\nlater by using the uninstaller."`" 11 70
	# a batch for automatic installation
        cp $BASEDIR/iebatch.txt $SYSDIR/sys
	# wine ie6setup.exe /C:"ie6wzd.exe /M:0 /S:""#e"
	# let the ie setup installing just minimal components
        echo -n "using "
        if [ "$choice" = "Internet Explorer 6.0 SP1 German" ]; then
          echo -n "`eval_gettext "german"`"
          setupdir="Windows Update Setup-Dateien"
          dlsize="496888"
          dl_locale="DE"
        fi
        if [ "$choice" = "Internet Explorer 6.0 SP1 English" ]; then
          echo -n "`eval_gettext "english"`"
          setupdir="Windows Update Setup Files"
          dlsize="491768"
          dl_locale="EN-US"
        fi
        if [ "$choice" = "Internet Explorer 6.0 SP1 Brazilian" ]; then
          echo -n "`eval_gettext "brazilian portuguese"`"
          setupdir="Configurao dos Arquivos de Atualizao do Windows"
          dlsize="494328"
          dl_locale="PT-BR"
        fi
	if [ "$choice" = "Internet Explorer 6.0 SP1 French" ]; then
          echo -n "`eval_gettext "french"`"
	  setupdir="Fichiers d'installation de Windows Update"
          dlsize="496376"
	  dl_locale="FR"
	fi	
	if [ "$choice" = "Internet Explorer 6.0 SP1 Norwegian" ]; then
          echo -n "`eval_gettext "norwegian"`"
	  setupdir="Installasjonsfiler for Windows Update"
	  dlsize="491768"
	  dl_locale="NO"
	fi
        echo "`eval_gettext " setup..."`"
        dload="http://download.microsoft.com/download/ie6sp1/finrel/6_sp1/W98NT42KMeXP/${dl_locale}/ie6setup.exe"
        if [ -s "$SYSDIR/sys/${setupdir}" ] && [ ! -e "$HOME/.wine/c/windows/${setupdir}" ]; then
	  cp -a "$SYSDIR/sys/${setupdir}" "$WINEDIR/c/windows"
	  ln -s "$WINEDIR/c/windows/${setupdir}" "$WINEDIR/c/${setupdir}"
	fi
        sysname="ie6setup.exe"
        testname="Microsoft Internet Explorer.*"
        script="ie6 outlookexpress wmplayer"
	# we still need a special tuned config for IE6 installation
	#mv "$WINEDIR/config" "$WINEDIR/config.$$"
	#cp "$BASEDIR/config.ie6" "$WINEDIR/config"
        #[ "$WINEVER" != "20050111" ] && WINEDLLOVERRIDES="advpack=n, wininet=n, ole32=n"
	[ "$WINEVER" = "20050419" ] && WINEDLLOVERRIDES="riched32=\"\"" && echo "disabling riched32.dll during install of IE6"
	# we have to move regsvr out of the way during install
	mv "$WINEDIR/drive_c/windows/system/regsvr32.exe" "$WINEDIR/drive_c/windows/system/regsvr32.exe.wine"
        sysinstall "--noboot"
        failed="$?"
        echo "`eval_gettext "Failed: $failed"`"
	# now we can get our config back
        #mv -f ~/.wine/config.$$ ~/.wine/config
        if [ "$failed" = "0" ]; then
          echo "`eval_gettext "installing new registry..."`"
          waitforwineexit
	  # we have to use a tuned registry because otherwiese things like opening new windows will not work
	  # this registry is from Frank's Corner; have to ask him how he got it!
          #mv ~/.wine/system.reg ~/.wine/system.reg.preIE6install
          #cp $BASEDIR/system.reg ~/.wine/system.reg
          #wineboot
	  # at least we disable this annoying Internet Connection Wizzard and make IE6 work!
          $WINE regedit $BASEDIR/ie6.reg
          wineboot
        fi
	# and we have to move regsvr back after the install
	mv "$WINEDIR/drive_c/windows/system/regsvr32.exe" "$WINEDIR/drive_c/windows/system/regsvr32.exe.win"
	mv "$WINEDIR/drive_c/windows/system/regsvr32.exe.wine" "$WINEDIR/drive_c/windows/system/regsvr32.exe"
        sizewt="`du -s \"$SYSDIR/sys/${setupdir}\"|cut -d\	 -f1`"
        sizewine="`du -s \"$HOME/.wine/c/windows/${setupdir}\"|cut -d\	 -f1`"
        [ "$sizewt" = "" ] && sizewt=0
        [ "$sizewine" = "" ] && sizewine=0
        echo "`eval_gettext "Downloaded IE6-Files=$sizewine"`"
        echo "`eval_gettext "Winetools  IE6-Files=$sizewt"`"
        if [ $sizewt -lt $sizewine ]; then
          $DIALOG  --title "`eval_gettext "*** Copy downloaded files ***"`" --defaultno --yesno "`eval_gettext "Do you want to save the downloaded files for later?"`" 7 60
          [ "$?" = "0" ] && cp -a "$HOME/.wine/c/windows/${setupdir}" "$SYSDIR/sys"
        fi
      fi
    fi
  }
;;
"`eval_gettext "Add printcap (non CUPS) printers"`")
  URL="http://www.von-thadden.de/Joachim/WineTools/"
  showinfo || {
    grep "This file was automatically generated by cupsd" /etc/printcap &>/dev/null
    if [ "$?" = "0" ]; then
      $DIALOG  --title "`eval_gettext "*** NOTICE ***"`" --msgbox "`eval_gettext "WineTools detected that you use CUPS on your system.\nAs Wine works perfecly together with CUPS, nothing\nhas to be done for using printers in Windows programs."`" 8 60
    else
      add_printcap_printers
    fi
  }
;;
*)
  systemsoftware
;;
esac
systemsoftware
;;

1)
    mainmenu
;;
esac
}


#########################
###  Additional Soft  ###
#########################
additionalsoftware()
{
init
needsw "\*new\* fake Windows drive" "--no-cancel"
needsw "dcom98.exe" "--no-cancel"
needsw "Microsoft Internet Explorer.*" "--no-cancel"

$DIALOG --title "`eval_gettext "Additional Software"`" \
	--cancel-label "`eval_gettext "Main menu"`" \
	--check "`eval_gettext "Show Info"`" \
	--item-help \
	--icon $BASEDIR/icon/apps.xpm \
        --treeview \ "`eval_gettext "
This software is known to work with Wine.
Select one to install and press OK. If you
hover with your mouse over an item a tooltip
will be displayed. To get more informations
check \"Show Info\" and press OK.
"`" 400x450 0 \
	"1" "Office" "" "1" "`eval_gettext "."`" \
	  "Microsoft Office 95" "Microsoft Office 95" "" "2" "`eval_gettext "Alternative: OpenOffice.org"`" \
	  "Microsoft Office 97" "Microsoft Office 97" "" "2" "`eval_gettext "Alternative: OpenOffice.org"`" \
	  "Microsoft Office 2000" "Microsoft Office 2000" "" "2" "`eval_gettext "Alternative: OpenOffice.org"`" \
	  "Word Viewer 97 English" "Word Viewer 97 English" "" "2" "`eval_gettext "."`" \
	  "Word Viewer 97 German" "Word Viewer 97 German" "" "2" "`eval_gettext "."`" \
	  "Excel Viewer 97 English" "Excel Viewer 97 English" "" "2" "`eval_gettext "."`" \
	  "Excel Viewer 97 German" "Excel Viewer 97 German" "" "2" "`eval_gettext "."`" \
	  "Excel Viewer 97 French" "Excel Viewer 97 French" "" "2" "`eval_gettext "."`" \
	  "Powerpoint Viewer 97 English" "Powerpoint Viewer 97 English" "" "2" "`eval_gettext "."`" \
	  "Powerpoint Viewer 97 German" "Powerpoint Viewer 97 German" "" "2" "`eval_gettext "."`" \
	  "Powerpoint Viewer 2003 English" "Powerpoint Viewer 2003 English" "" "2" "`eval_gettext "."`" \
	  "Powerpoint Viewer 2003 German" "Powerpoint Viewer 2003 German" "" "2" "`eval_gettext "."`" \
	  "InfoRapid KnowledgeMap 2005 German" "InfoRapid KnowledgeMap 2005 German" "" "2" "`eval_gettext "a knowledge map creator in german | Alternative: freemind | License: free for non-commercial use"`" \
	  "Scribble Papers" "Scribble Papers" "" "2" "`eval_gettext "handy tool for quick notes or as memory hook | License: freeware"`" \
	"2" "Business" "" "1" "`eval_gettext "."`" \
	  "ElsterFormular 2004-2005 German" "ElsterFormular 2004-2005 German" "" "2" "`eval_gettext "german paperless tax form software | License: freeware?"`" \
	"3" "School Software" "" "1" "`eval_gettext "."`" \
	  "KLV 4 (german)" "KLV 4 (german)" "" "2" "`eval_gettext "Programm for school reports und class adminstration | License: shareware"`" \
	"3" "Science" "" "1" "`eval_gettext "."`" \
	  "BioEdit" "BioEdit" "" "2" "`eval_gettext "biological sequence alignment editor | License: freeware"`" \
	"4" "Edutainment" "" "1" "`eval_gettext "."`" \
	  "Encarta 99" "Encarta 99" "" "2" "`eval_gettext "Microsoft's multimedia encyclopedia, commercial | Alternative: www.wikipedia.org"`" \
          "PC Study Bible Basic Edition 4.2B" "PC Study Bible Basic Edition 4.2B" "" "2" "`eval_gettext "Bible Study Software and Authoring System Exchange | License: freeware"`" \
	  "OpenSong 0.9.9." "OpenSong 0.9.9." "" "2" "`eval_gettext "OpenSong is a free, open-source software application created to manage lyrics, chords, lead sheets, overheads, computer projection, and more | License: open source software"`" \
	  "InfoRapid Internet-Zeitungsleser German" "InfoRapid Internet-Zeitungsleser German" "" "2" "`eval_gettext "Internet newspaper reader | License: freeware"`" \
	"5" "Games" "" "1" "`eval_gettext "give me input and I place them here!"`" \
	  "PowBallDX" "PowBallDX" "" "2" "`eval_gettext "little breakout game | License: freeware"`" \
	"6" "Graphics" "" "1" "`eval_gettext "."`" \
	  "Adobe Photoshop 7.0" "Adobe Photoshop 7.0" "" "2" "`eval_gettext "image manipulation software, commercial | Alternative: The Gimp!"`" \
	  "Adobe Illustrator 9.0" "Adobe Illustrator 9.0" "" "2" "`eval_gettext "vector graphics software, commercial; look at www.linuxartist.org for alternatives | Alternative: OpenOffice.org's Impress or JFDraw"`" \
	  "IrfanView 3.95" "IrfanView 3.95" "" "2" "`eval_gettext "very nice multimedia viewer and basic editing software | License: freeware"`" \
	  "FontPage" "FontPage" "" "2" "`eval_gettext "litte font lister | License: freeware"`" \
	  "Typograf 4 Fontmanagement English" "Typograf 4 Fontmanagement English" "" "2" "`eval_gettext "fontmanager | License: shareware"`" \
	  "Typograf 4 Fontmanagement German" "Typograf 4 Fontmanagement German" "" "2" "`eval_gettext "fontmanager | License: shareware"`" \
	  "ArtRage 1.1" "ArtRage 1.1" "" "2" "`eval_gettext "very creative drawing program | License: freeware"`" \
	  "PhotoFiltre 6.1" "PhotoFiltre 6.1" "" "2" "`eval_gettext "complete image retouching program with many filters (>100) | License: freeware, but commercial and professional use is not authorized!"`" \
	  "Scrutico" "Scrutico" "" "2" "`eval_gettext "scan directories and extract all icons present in form of files (ICO) or of resources (EXE, DLL, ICL), in french but good understandable | License: freeware"`" \
	  "Ultimate Paint 1.91f" "Ultimate Paint 1.91f" "" "2" "`eval_gettext "nice image manipulation software with many effect filters | License: freeware"`" \
	  "Ultimate Paint LE" "Ultimate Paint LE" "" "2" "`eval_gettext "nice image manipulation software with not so many effect filters, but niftier interface | License: shareware"`" \
	  "Qimage" "Qimage" "" "2" "`eval_gettext "digital photo printing software | License: shareware"`" \
	  "NeatImage" "NeatImage" "" "2" "`eval_gettext "digital filter designed to reduce visible noise and grain in digital photographic images | License: shareware demo"`" \
	"7" "Multimedia" "" "1" "`eval_gettext "."`" \
	  "VirtualDub 1.6.1" "VirtualDub 1.6.1" "" "2" "`eval_gettext "video editing software | License: freeware"`" \
	"8" "Player" "" "1" "`eval_gettext "."`" \
	  "Acrobat Reader 6.0 English" "Acrobat Reader 6.0 English" "" "2" "`eval_gettext "PDF viewer | License: freeware | Alternative: xpdf or gv"`" \
	  "Acrobat Reader 6.0 German" "Acrobat Reader 6.0 German" "" "2" "`eval_gettext "PDF viewer | License: freeware | Alternative: xpdf or gv"`" \
	  "Acrobat Reader 5.1 English" "Acrobat Reader 5.1 English" "" "2" "`eval_gettext "PDF viewer | License: freeware | Alternative: xpdf or gv"`" \
	  "Acrobat Reader 5.1 German" "Acrobat Reader 5.1 German" "" "2" "`eval_gettext "PDF viewer | License: freeware | Alternative: xpdf or gv"`" \
	  "Macromedia Flash Player Plugin for IE6" "Macromedia Flash Player Plugin for IE6" "" "2" "`eval_gettext "."`" \
	  "Macromedia Shockwave Player Plugin for IE6" "Macromedia Shockwave Player Plugin for IE6" "" "2" "`eval_gettext "."`" \
	  "RealPlayer 10 English" "RealPlayer 10 English" "" "2" "`eval_gettext "player for RealMedia-Format | License: freeware | Alternative: HelixPlayer or XINE"`" \
	  "RealPlayer 10 German" "RealPlayer 10 German" "" "2" "`eval_gettext "player for RealMedia-Format | License: freeware | Alternative: HelixPlayer or XINE"`" \
	  "QuickTime Player 6.5.2" "QuickTime Player 6.5.2" "" "2" "`eval_gettext "player for Apples QuickTime-Format | License: freeware | Alternative: XINE"`" \
	  "QuickTime Player 5.0" "QuickTime Player 5.0" "" "2" "`eval_gettext "player for Apples QuickTime-Format | License: freeware | Alternative: XINE"`" \
	  "IRon" "IRon" "" "2" "`eval_gettext "german online radio station listener | License: freeware | Alternative: StreamTuner"`" \
	  "WinAmp 5 incl. Streamripper" "WinAmp 5 incl. Streamripper" "" "2" "`eval_gettext "multimedia player | License: freeware | Alternative: XMMS and StreamRipper"`" \
	  "WinAmp 2 incl. Streamripper" "WinAmp 2 incl. Streamripper" "" "2" "`eval_gettext "multimedia player, older interface but faster ripping | License: freeware | Alternative: XMMS and StreamRipper"`" \
	  "CoolPlayer" "CoolPlayer" "" "2" "`eval_gettext "sound player | License: open source software | Alternative: XMMS"`" \
	"9" "File Tools" "" "1" "`eval_gettext "."`" \
	  "Total Commander 6.03a" "Total Commander 6.03a" "" "2" "`eval_gettext "a good file commander | License: shareware"`" \
	  "7-Zip" "7-Zip" "" "2" "`eval_gettext "file archiver with high compression ratio | License: open source software"`" \
	  "UltimateZip" "UltimateZip" "" "2" "`eval_gettext "a program for file compression, even better than WinZip | License: freeware"`" \
	  "WinZip 9.0 English" "WinZip 9.0 English" "" "2" "`eval_gettext "a program for file compression | License: shareware"`" \
	  "WinZip 9.0 German" "WinZip 9.0 German" "" "2" "`eval_gettext "a program for file compression | License: shareware"`" \
	  "WinRAR 3.41 English" "WinRAR 3.41 English" "" "2" "`eval_gettext "a program for file compression | License: shareware"`" \
	  "WinRAR 3.41 German" "WinRAR 3.41 German" "" "2" "`eval_gettext "a program for file compression | License: shareware"`" \
	"10" "Communication" "" "1" "`eval_gettext "."`" \
	  "Google Toolbar 3 for IE6" "Google Toolbar 3 for IE6" "" "2" "`eval_gettext "Toolbar for IE6 to use Google functions | License: freeware | Alternative: Firefox with Googlebar"`" \
	  "Eudora 6.2" "Eudora 6.2" "" "2" "`eval_gettext "a mail client | License: shareware | Alternative: one of the 10 million native Linux mailer"`" \
	  "The Bat! 3.01 Professional" "The Bat! 3.01 Professional" "" "2" "`eval_gettext "a mail client | License: shareware | Alternative: one of the 10 million native Linux mailer"`" \
	  "Fort Agent Newsreader 2.0" "Fort Agent Newsreader 2.0" "" "2" "`eval_gettext "news reader | License: shareware | Alternative: Mozilla"`" \
	  "mIRC 6.16" "mIRC 6.16" "" "2" "`eval_gettext "inter relay chat program | License: freeware | Alternative: xchat"`" \
	  "Lauge 1.89 German" "Lauge 1.89 German" "" "2" "`eval_gettext "very nice eBay browser | License: freeware"`" \
	  "Awasu 2.0 Personal Edition" "Awasu 2.0 Personal Edition" "" "2" "`eval_gettext "news feed reader | License: freeware | Alterative: rssowl"`" \
	  "putty 0.56" "putty 0.56" "" "2" "`eval_gettext "telnet and secure shell client | License: freeware | Alternative: telnet and ssh"`" \
	  "DC++" "DC++" "" "2" "`eval_gettext "DC++ is an open source client for the Direct Connect protocol | License: open source software"`" \
	  "Bottler XDCC Bot Interface" "Bottler XDCC Bot Interface" "" "2" "`eval_gettext "a net news file download robot | License: open source software"`" \
	  "Miranda IM" "Miranda IM" "" "2" "`eval_gettext "multi protocol instant messenger client with more than 300 plugins | License: freeware | Alternative: gaim"`" \
	  "GrabIt 1.4.7" "GrabIt 1.4.7" "" "2" "`eval_gettext "search the usenet | License: freeware"`" \
	  "MailWasher Pro International Version" "MailWasher Pro International Version" "" "2" "`eval_gettext "deletes spam, viruses and unwanted emails right at the mail server | License: shareware"`" \
	  "X-Lite v2.0 Build 1103m English" "X-Lite v2.0 Build 1103m English" "" "2" "`eval_gettext "SIP VoIP SoftPhone | License: freeware | Alternative: kphone"`" \
	  "X-Lite v2.0 Build 1103m German" "X-Lite v2.0 Build 1103m German" "" "2" "`eval_gettext "SIP VoIP SoftPhone | License: freeware | Alternative: kphone"`" \
	  "Phoner 1.69" "Phoner 1.69" "" "2" "`eval_gettext "SIP/ISDN VoIP SoftPhone | License: freeware | Alternative: kphone"`" \
	  "Skype 1.1" "Skype 1.1" "" "2" "`eval_gettext "VoIP SoftPhone for the Skype protocoll | License: freeware | Alternative: Skype for Linux"`" \
	"11" "Database" "" "1" "`eval_gettext "."`" \
	  "PostgreSQL ODBC driver psqlODBC 8.00.0101" "PostgreSQL ODBC driver psqlODBC 8.00.0101" "" "2" "`eval_gettext "."`" \
	  "DBCrab 1.50 German with BDE 5.1.1 German" "DBCrab 1.50 German with BDE 5.1.1 German" "" "2" "`eval_gettext "little database editor with the Borland Database Engine | License: freeware, but not for commercial usage!"`" \
	  "Borland Database Engine (BDE) 5.1.1 English" "Borland Database Engine (BDE) 5.1.1 English" "" "2" "`eval_gettext "."`" \
	"12" "Tools" "" "1" "`eval_gettext "."`" \
	  "SDL Codec Pack 1.5.3" "SDL Codec Pack 1.5.3" "" "2" "`eval_gettext "some more codecs for the media player"`" \
	  "Dependency Walker" "Dependency Walker" "" "2" "`eval_gettext "shows library dependencies of executables, very handy for debugging with Wine programs | License: freeware"`" \
	  "Splash Screen Killer" "Splash Screen Killer" "" "2" "`eval_gettext "suppress splash screens that are annoying or in the way | License: freeware"`" \
	  "Xpdf 3.00" "Xpdf 3.00" "" "2" "`eval_gettext "some pdf conversion tools | License: open source software"`" \
	"13" "Misc" "" "1" "`eval_gettext "."`" \
	  "TVgenial" "TVgenial" "" "2" "`eval_gettext "german TV program guide | License: freeware | Alternative: www.tvtv.de"`" \
	2> /tmp/menu.tmp.$$

retval=$?

choice=`cat /tmp/menu.tmp.$$|grep -v "checked"`
checked="F"
[ "`cat /tmp/menu.tmp.$$|grep \"checked\"`" = "checked" ] && checked="T"
rm -f /tmp/menu.tmp.$$

case $retval in
0)

echo "`eval_gettext "Choice is $choice"`"
case "$choice" in
"Splash Screen Killer")
  URL="http://www.digitallis.co.uk/pc/SplashKiller/index.html"
  showinfo || {
    mkdir "$HOME/.wine/c/Programme/SplashKiller"
    dload="http://www.digitallis.co.uk/pc/downloads/SplashKiller.zip"
    dlsize="32224"
    sysname="SplashKiller.zip"
    installer="unzip -o SplashKiller.zip -d $HOME/.wine/c/Programme/SplashKiller"
    script="splashkiller"
    sysinstall
  }
;;
"Microsoft Office 95"|"Microsoft Office 97"|"Microsoft Office 2000")
  URL="http://www.openoffice.org"
  showinfo || {
    if [ "$choice" = "Microsoft Office 2000" ]; then
      [ "$WINEVER" = "20050111" ] || needsw "SplashKiller.zip" "--no-cancel"
      $DIALOG --title "`eval_gettext "Hint"`" \
	      --no-cancel \
	      --msgbox "`eval_gettext "If you are asked for, select drive D: for installation.\nNever install Office-Tools/Office-Assistents. They\nmight shredder your setup. During the first start of\nOutlook you should not decide\nto install Symantec Fax\nbecause it does no work."`" 12 60
      script="winword msword excel msexcel msaccess powerpoint mspowerpoint outlook msoutlook outlook.executor msfinder msquery msbinder"
    fi
    if [ "$choice" = "Microsoft Office 97" ]; then
      [ "$WINEVER" = "20050111" ] || needsw "SplashKiller.zip" "--no-cancel"
      $DIALOG --title "`eval_gettext "Hint"`" \
	      --no-cancel \
	      --msgbox "`eval_gettext "During the first start of Word it complains about a broken\ninstall. Ignore it, cancel it and start it again. Also\nmsoutlook and msaccess might not work."`" 12 70
      script="winword msword excel msexcel msaccess powerpoint mspowerpoint outlook msoutlook outlook.executor msfinder msquery msbinder"
    fi
    if [ "$choice" = "Microsoft Office 95" ]; then
      [ "$WINEVER" = "20050111" ] || needsw "SplashKiller.zip" "--no-cancel"
      $DIALOG --title "`eval_gettext "Hint"`" \
	      --no-cancel \
	      --msgbox "`eval_gettext "The installer will tell you at the end that the\ninstallation failed, but it did not!"`" 9 60
      script="msword95 msexcel95 msaccess95 mspowerpoint95 msschedule95 msbinder95"
    fi
    dload="none"
    dlsize=""
    sysname="$choice"
#    installer="$WINE d:\\setup.exe"
    installer="***SEARCH***"
    if [ "$choice" = "Microsoft Office 95" ]; then
      testname="Microsoft Office.*"
    else
      testname="${choice}.*"
    fi
    sysinstallsw
    if [ "$failed" = "0" ]; then
      if [ "$choice" = "Microsoft Office 97" ]; then
        echo "creating an empty WINEDIR/drive_c/windows/system/MAPISVC.INF file"
        touch "$WINEDIR/drive_c/windows/system/MAPISVC.INF"
      fi
    fi
  }
;;
"Google Toolbar 3 for IE6")
  URL="http://toolbar.google.com/T3/index"
  showinfo || {
    dload="http://toolbar.google.com/T3/data/en/deleon/current/GoogleToolbarInstaller.exe"
    dlsize="683680"
    sysname="GoogleToolbarInstaller.exe"
    testname="Google Toolbar for Internet Explorer"
    script=""
    sysinstall
  }
;;
"Macromedia Flash Player Plugin for IE6")
  URL="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"
  showinfo || {
    $DIALOG   --title "`eval_gettext "Hint"`" \
              --no-cancel \
              --msgbox "`eval_gettext "If you install the Yahoo-Toobar the included popup blocker\nwill inhibit IE6 to open any windows. You probably want\nto disable this feature via the Yahoo-Toolbar settings."`" 9 60
    $WINE c:\\Program\ Files\\Internet\ Explorer\\IEXPLORE.EXE "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"
    wineboot
    testsw "Shockwave Flash"
    [ "$?" != "0" ] && $DIALOG --title "`eval_gettext "wine status"`" \
		               --no-cancel \
			       --msgbox "`eval_gettext "It seems that the installation has failed."`" 7 70
  }
;;
"Macromedia Shockwave Player Plugin for IE6")
  URL="http://sdc.shockwave.com/shockwave/download/download.cgi?"
  showinfo || {
    $WINE c:\\Program\ Files\\Internet\ Explorer\\IEXPLORE.EXE "http://sdc.shockwave.com/shockwave/download/download.cgi?"
    wineboot
    testsw "Macromedia Shockwave Player"
    [ "$?" != "0" ] && $DIALOG --title "`eval_gettext "wine status"`" \
		               --no-cancel \
			       --msgbox "`eval_gettext "It seems that the installation has failed."`" 7 70
  }
;;
"Word Viewer 97 English")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=0e56d944-38f6-4eb5-aca6-8bd280d5e6b1&displaylang=en"
  showinfo || {
    dload="http://www.nottinghamcity.gov.uk/downloads/wd97vwr32.exe"
    dlsize="3953640"
    sysname="wd97vwr32.exe"
    testname="Microsoft Word Viewer 97"
    script="winword wordview97"
    sysinstall
  }
;;
"Word Viewer 97 German")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=0e56d944-38f6-4eb5-aca6-8bd280d5e6b1&displaylang=de"
  showinfo || {
    dload="http://download.microsoft.com/download/word97win/wd97vwr/97/WIN98/DE/wd97vwr32.exe"
    dlsize="4364456"
    sysname="wd97vwr32.exe"
    testname="Microsoft Word Viewer 97"
    script="winword wordview97"
    sysinstall
  }
;;
"Excel Viewer 97 English")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyId=C8378BF4-996C-4569-B547-75EDBD03AAF0&displaylang=en"
  showinfo || {
    dload="http://www.nottinghamcity.gov.uk/downloads/xlViewer.exe"
    dlsize="3905464"
    sysname="xlViewer.exe"
    testname="Microsoft Excel Viewer 97"
    script="excel excelview97"
    sysinstall
  }
;;
"Excel Viewer 97 German")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyId=C8378BF4-996C-4569-B547-75EDBD03AAF0&displaylang=de"
  showinfo || {
    dload="http://download.microsoft.com/download/excel97win/xlviewer/1/WIN98/DE/xlviewer.exe"
    dlsize="3905464"
    sysname="xlViewer.exe"
    testname="Microsoft Excel Viewer 97"
    script="excel excelview97"
    sysinstall
  }
;;
"Excel Viewer 97 French")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyId=C8378BF4-996C-4569-B547-75EDBD03AAF0&displaylang=fr"
  showinfo || {
    dload="http://download.microsoft.com/download/excel97win/xlviewer/1/WIN98/FR/xlviewer.exe"
    dlsize="3959896"
    sysname="XLVIEWER.EXE"
    testname="Microsoft Excel Visionneuse 2003"
    script="excel excelview2003"
    sysinstall
  }
;;
"Powerpoint Viewer 97 English")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=7c404e8e-5513-46c4-aa4f-058a84a37df1&DisplayLang=en"
  showinfo || {
    dload="http://download.microsoft.com/download/c/2/f/c2fd9ca4-4505-453b-84b6-5839b7baffd3/PPView97.exe"
    dlsize="2855552"
    sysname="PPView97.exe"
    testname="Microsoft PowerPoint Viewer 97"
    script="powerpoint ppointview97"
    sysinstall
  }
;;
"Powerpoint Viewer 97 German")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=7c404e8e-5513-46c4-aa4f-058a84a37df1&DisplayLang=de"
  showinfo || {
    dload="http://download.microsoft.com/download/powerpoint2000/ppview97/2000/WIN98/DE/PPView97.exe"
    dlsize="2838704"
    sysname="PPView97.exe"
    testname="Microsoft PowerPoint Viewer 97"
    script="powerpoint ppointview97"
    sysinstall
  }
;;
"Powerpoint Viewer 2003 English")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=428d5727-43ab-4f24-90b7-a94784af71a4&DisplayLang=en"
  showinfo || {
    dload="http://download.microsoft.com/download/a/1/a/a1adc39b-9827-4c7a-890b-91396aed2b86/ppviewer.exe"
    dlsize="1951432"
    sysname="ppviewer.exe"
    testname="Microsoft Office PowerPoint Viewer 2003"
    script="powerpoint ppointview2003"
    sysinstall
  }
;;
"Powerpoint Viewer 2003 German")
  URL="http://www.microsoft.com/downloads/details.aspx?FamilyID=428d5727-43ab-4f24-90b7-a94784af71a4&DisplayLang=de"
  showinfo || {
    dload="http://download.microsoft.com/download/f/e/2/fe23f2ca-19b8-4d4b-8275-35ec02699c8f/ppviewer.exe"
    dlsize="1949896"
    sysname="ppviewer.exe"
    testname="Microsoft Office PowerPoint Viewer 2003"
    script="powerpoint ppointview2003"
    sysinstall
  }
;;
"ElsterFormular 2004-2005 German")
  URL="https://www.elster.de/elfo_home.php"
  showinfo || {
    needsw "MDAC_TYP.EXE"
    if [ "$?" = "0" ]; then
      needsw "Jet40SP8_9xNT.exe"
      if [ "$?" = "0" ]; then
        dload="https://a248.e.akamai.net/f/248/13616/6h/oberfinanz.download.akamai.com/13616/download/2004/ElsterFormular2004.exe"
        dlsize="13084200"
        sysname="ElsterFormular2004.exe"
        testname="ElsterFormular 2004/2005"
        script="elster04"
        sysinstall
      fi
    fi
  }
;;
"Encarta 99")
  URL="http://www.wikipedia.org"
  showinfo || {
    dload="none"
    dlsize=""
    sysname=""
#    installer="$WINE d:\\setup.exe"
    installer="***SEARCH***"
    testname="Microsoft Encarta 99.*"
    script="encarta"
    sysinstallsw
  }
;;
"Acrobat Reader 5.1 English")
  URL="http://www.adobe.com/products/acrobat/reader_archive.html#Win"
  showinfo || {
    dload="http://ardownload.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_ENU.exe"
    dlsize="8839120"
    sysname="AcroReader51_ENU.exe"
    testname="Adobe Acrobat 5.0"
    script="acro5"
    sysinstall
  }
;;
"Acrobat Reader 5.1 German")
  URL="http://www.adobe.com/products/acrobat/reader_archive.html#Win"
  showinfo || {
    dload="http://ardownload.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_DEU.exe"
    dlsize="9862808"
    sysname="AcroReader51_DEU.exe"
    testname="Adobe Acrobat 5.0"
    script="acro5"
    sysinstall
  }
;;
"Acrobat Reader 6.0 English")
  URL="http://www.adobe.com/products/acrobat/reader_archive.html#Win"
  showinfo || {
    dload="http://ardownload.adobe.com/pub/adobe/reader/win/6.x/6.0/enu/AdbeRdr60_enu_full.exe"
    dlsize="16706160"
    sysname="AdbeRdr60_enu_full.exe"
    testname="Adobe Reader 6.0.1.*"
    script="acro6"
    sysinstall
    [ "$failed" = "0" ] && $DIALOG --title "`eval_gettext "Hint"`" \
	--no-cancel \
	--msgbox "`eval_gettext "During the first start of the reader the splash screen will not\ndisappear. If this happens just type Enter and it will close."`" 7 60
  }
;;
"Acrobat Reader 6.0 German")
  URL="http://www.adobe.com/products/acrobat/reader_archive.html#Win"
  showinfo || {
    dload="http://ardownload.adobe.com/pub/adobe/reader/win/6.x/6.0/deu/AdbeRdr60_deu_full.exe"
    dlsize="18676216"
    sysname="AdbeRdr60_deu_full.exe"
    testname="Adobe Reader 6.0.1.*"
    script="acro6"
    sysinstall
    [ "$failed" = "0" ] && $DIALOG --title "`eval_gettext "Hint"`" \
	--no-cancel \
	--msgbox "`eval_gettext "During the first start of the reader the splash screen will not\ndisappear. If this happens just type Enter and it will close."`" 7 60
  }
;;
"RealPlayer 10 German")
  URL="http://www.real.com"
  showinfo || {
    dload="http://software-dl.real.com/18d888a38bdd7d6e8d16/windows/RealPlayer10-5GOLD_de.exe"
    dlsize="11732512"
    sysname="RealPlayer10-5GOLD_de.exe"
    testname="RealPlayer"
    script="rplayer10"
    sysinstall
  }
;;
"RealPlayer 10 English")
  URL="http://www.real.com"
  showinfo || {
    dload="http://software-dl.real.com/18d888a38bdd7d6e8d16/windows/RealPlayer10-5GOLD.exe"
    dlsize="10479136"
    sysname="RealPlayer10-5GOLD.exe"
    testname="RealPlayer"
    script="rplayer10"
    sysinstall
  }
;;
"SDL Codec Pack 1.5.3")
  URL="http://www.codec-download.com/modules.php?name=Downloads&d_op=viewdownload&cid=16"
  showinfo || {
    dload="http://www.codec-archiv.de/cclc/sld/SLDcodecpack1.5.3.exe"
    dlsize="4082450"
    sysname="SLDcodecpack1.5.3.exe"
    testname="SLD CODEC PACK 1.5.3"
    script=""
    sysinstall
    $DIALOG --title "`eval_gettext "Hint"`" \
	    --no-cancel \
	    --msgbox "`eval_gettext "Don't use the included Zoom Player.\nIt does not work with Wine."`" 7 60
	    #'
  }    
;;
"ArtRage 1.1")
  URL="http://www.ambientdesign.com/artrage.html"
  showinfo || {
    needsw "InstMsiA.exe"
    if [ "$?" = "0" ]; then
      dload="http://highspeed1.movedigital.com:8080/badfs/badbal?secretcode=28ef07524097fffd9052abf7937cb84a&asid=523546&path=/web/files/movedigital/temp/523546/artrage_setup.msi"
      dlsize="1628672"
      sysname="artrage_setup.msi"
      installer="$WINE msiexec /i f:\\sys\\artrage_setup.msi"
      testname="ArtRage"
      script="artrage"
      sysinstall
    fi
  }
;;
"Lauge 1.89 German")
  URL="http://www.lauge.de"
  showinfo || {
    dload="http://www.lauge.de/public/lauge189_setup.exe"
    dlsize="1290439"
    sysname="lauge189_setup.exe"
    testname="Lauge 1.89"
    script="lauge"
    sysinstall
    if [ "$failed" = "0" ]; then
      cp "$BASEDIR/lauge-prefs.ini" "$WINEDIR/c/Program Files/Lauge/prefs.ini"
    fi
  }
;;
"InfoRapid Internet-Zeitungsleser German")
  URL="http://www.inforapid.de/html/zeitungsleser.htm"
  CONTACT="info@inforapid.de"
  showinfo || {
    dload="http://www.inforapid.org/br/br.exe"
    dlsize="683318"
    sysname="br.exe"
    testname="InfoRapid Internet-Zeitungsleser"
    script="brrapid"
    sysinstall
  }
;;
"InfoRapid KnowledgeMap 2005 German")
  URL="http://www.inforapid.de/html/knowledgemap.htm"
  CONTACT="info@inforapid.de"
  showinfo || {
    dload="http://www.inforapid.org/ikm_deu/ikm_deu.exe"
    dlsize="3781893"
    sysname="ikm_deu.exe"
    testname="InfoRapid KnowledgeMap"
    script="ikmap"
    sysinstall    
    $DIALOG --title "`eval_gettext "Hint"`" \
	    --no-cancel \
	    --msgbox "`eval_gettext "For indexing PDF documents you have to install Xpdf."`" 7 60
    ln -s "$HOME/.wine/c/Programme/xpdf-3.00pl3-win32/pdftotext.exe" "$HOME/.wine/c/Programme/ikMap/"
  }
;;
"Xpdf 3.00")
  URL="http://www.foolabs.com/xpdf/"
  CONTACT="derekn@foolabs.com"
  showinfo || {
    dload="ftp://ftp.foolabs.com/pub/xpdf/xpdf-3.00pl3-win32.zip"
    dlsize="1142558"
    sysname="xpdf-3.00pl3-win32.zip"
    installer="unzip -o xpdf-3.00pl3-win32.zip -d $HOME/.wine/c/Programme/"
    script=""
    sysinstall
  }
;;
"WeatherScope 1.2.1")
# menu was:
# 	  "WeatherScope 1.2.1" "WeatherScope 1.2.1" "" "2" "`eval_gettext "Weather data browser from Oklahoma Climatological Survey (OCS) | License: freeware for non-commercial usage"`" \
  URL="http://www.ocs.ou.edu/software/"
  CONTACT="operator@mesonet.org"
  showinfo || {
    dload="http://sdg.ocs.ou.edu/builds/final/win/WeatherScope/WeatherScope-1.2.1.exe"
    dlsize="1224652"
    sysname="WeatherScope-1.2.1.exe"
    testname="WeatherScope"
    script="weatherscope"
    sysinstall
  }
;;
"PC Study Bible Basic Edition 4.2B")
  URL="http://www.biblesoftexchange.com/index.asp"
  CONTACT="custsrvc@biblesoft.com"
  showinfo || {
    dload="http://www.biblesoftexchange.com/htmldownloads/PCSBdownloads/BasicEdition42B.exe"
    dlsize="28450544"
    sysname="BasicEdition42B.exe"
    testname="PC Study Bible .*"
    script="pcstudybible"
    sysinstall
    $DIALOG --title "`eval_gettext "Hint"`" \
	    --no-cancel \
	    --msgbox "`eval_gettext "The menus are not readable. You have to guess and try a little bit."`" 7 60
  }
;;
"OpenSong 0.9.9.")
  URL="http://www.opensong.org"
  CONTACT=""
  showinfo || {
    dload="$SFMIRROR/opensong/opensong-0.9.9-setup.exe"
    dlsize="3489213"
    sysname="opensong-0.9.9-setup.exe"
    testname="OpenSong .*"
    script="opensong"
    sysinstall
  }
;;
"VirtualDub 1.6.1")
  URL="http://www.virtualdub.org"
  showinfo || {
    $DIALOG --title "`eval_gettext "Hint"`" \
	    --no-cancel \
	    --msgbox "`eval_gettext "During the first start go to Options-Preferences-Display and disable\nDirectX to prevent VD to mess up your display."`" 7 60
    mkdir "$HOME/.wine/c/Programme/VirtualDub"
    dload="$SFMIRROR/virtualdub/VirtualDub-1.6.1.zip"
    dlsize="796130"
    sysname="VirtualDub-1.6.1.zip"
    installer="unzip -o VirtualDub-1.6.1.zip -d $HOME/.wine/c/Programme/VirtualDub"
    script="virtualdub"
    sysinstall
  }
;;
"Bottler XDCC Bot Interface")
  URL="http://www.memelog.com/bottler/"
  showinfo || {
    dload="$SFMIRROR/bottler/Bottler_v3.3.1214.zip"
    dlsize="2987942"
    sysname="Bottler_v3.3.1214.zip"
    installer="unzip -o Bottler_v3.3.1214.zip -d $SYSDIR/sys/tmp"
    sysinstall
    init
    dload="none"
    dlsize="none"
    sysname="tmp/Bottler_v3.3.1214.exe"
    testname="Bottler"
    script="bottler"
    sysinstall
    cleantmp
  }
;;
"DVD Shrink 3.2")
  URL="http://www.dvdshrink.org/"
  showinfo || {
    dload="http://files.dvdr-digest.com/encode/dvdshrink32setup.zip"
    dlsize="1094021"
    sysname="dvdshrink32setup.zip"
    installer="unzip -o dvdshrink32setup.zip -d $SYSDIR/sys/tmp"
    sysinstall
    init
    dload="none"
    dlsize="none"
    sysname="tmp/dvdshrink32setup.exe"
    testname="DVD Shrink 3.2"
    script="dvdshrink"
    sysinstall
    cleantmp
  }
;;
"Total Commander 6.03a")
  URL="http://www.ghisler.com"
  showinfo || {
    dload="http://fileforum.betanews.com/sendfile/945901171/1/tcmd603a.exe"
    dlsize="1484021"
    sysname="tcmd603a.exe"
    testname="Total Commander (Remove or Repair)"
    script="wincmd totalcmd"
    sysinstall
  }
;;
"Miranda IM")
  URL="http://www.miranda-im.org"
  showinfo || {
    dload="$SFMIRROR/miranda-icq/miranda-im-v0.3.3.1.exe"
    dlsize="742686"
    sysname="miranda-im-v0.3.3.1.exe"
    testname="Miranda IM"
    script="mirandaim"
    sysinstall
  }
;;
"PowBallDX")
  URL="http://homepage.ntlworld.com/ant-man/games.html"
  showinfo || {
    dload="http://homepage.ntlworld.com/ant-man/download/powball.exe"
    dlsize="833736"
    sysname="powball.exe"
    script="powball"
    sysinstall
    if [ "$failed" = "0" ]; then
      cp "$BASEDIR/PowBallDX.cfg" "$WINEDIR/c/Program Files/PowBallDX"
      $DIALOG --title "`eval_gettext "Hint"`" \
	    --no-cancel \
	    --msgbox "`eval_gettext "After the start enter the PowBall window extremely slow, otherwise\nyou will have a second cursor lying around in your sight."`" 7 60
    fi
  }
;;
"Dependency Walker")
  URL="http://www.dependencywalker.com"
  showinfo || {
    mkdir "$HOME/.wine/c/Programme/DependencyWalker"
    dload="http://www.dependencywalker.com/depends21_x86.zip"
    dlsize="415352"
    sysname="depends21_x86.zip"
    installer="unzip -o "$sysname" -d $HOME/.wine/c/Programme/DependencyWalker"
    script="depwalker"
    sysinstall
  }
;;
"Awasu 2.0 Personal Edition")
  URL="http://www.awasu.com"
  showinfo || {
    dload="http://www.awasu.net/downloads/Awasu-PersonalEdition-v2.0.exe"
    dlsize="4356202"
    sysname="Awasu-PersonalEdition-v2.0.exe"
    script="awasu"
    sysinstall
  }
;;
"Eudora 6.2")
  URL="http://www.eudora.com"
  showinfo || {
    dload="http://www.eudora.com/download/eudora/windows/6.2/Eudora_6.2.exe"
    dlsize="9537272"
    sysname="Eudora_6.2.exe"
    testname="Eudora"
    script="eudora"
    sysinstall
  }
;;
"GrabIt 1.4.7")
  URL="http://www.shemes.com"
  showinfo || {
    dload="http://www.shemes.demon.nl/GrabIt147b.exe"
    dlsize="1117550"
    sysname="GrabIt147b.exe"
    testname="GrabIt.*"
    script="grabit"
    sysinstall
  }
;;
"The Bat! 3.01 Professional")
  URL="http://www.ritlabs.com/en/"
  showinfo || {
    needsw "InstMsiA.exe"
    if [ "$?" = "0" ]; then
      dload="http://www.ritlabs.com/download/files3/the_bat/thebat_professional.msi"
      dlsize="8776704"
      sysname="thebat_professional.msi"
      installer="$WINE msiexec /i f:\\sys\\thebat_professional.msi"
      testname="The Bat.*"
      script="thebat"
      sysinstall
    fi
  }
;;
"BioEdit")
  URL="http://www.mbio.ncsu.edu/BioEdit/bioedit.html"
  showinfo || {
    dload="http://www.mbio.ncsu.edu/BioEdit/BioEdit.zip"
    dlsize="12134795"
    sysname="BioEdit.zip"
    installer="unzip -o BioEdit.zip -d $SYSDIR/sys/tmp"
    sysinstall
    init
    dload="none"
    dlsize="none"
    sysname="tmp/SETUP.EXE"
    testname="BioEdit"
    script="bioedit"
    sysinstall
    cleantmp
  }
;;
"QuickTime Player 6.5.2")
  URL="http://www.apple.com/quicktime/products/qt/"
  showinfo || {
    $DIALOG --title "`eval_gettext "Hint"`" \
	    --yesno "`eval_gettext "Note that you might have to change the fifo-Size in the player\nsettings for uninterrupted sound. A size of 333 was good for me.\nAlso you should set Quicktime Options for Video to GDI only.\nContinue?"`" 12 60
    if [ "$?" = "0" ]; then
      dload="http://a1540.g.akamai.net/7/1540/52/20041101/qtinstall.info.apple.com/pthalo/de/win/QuickTimeFullInstaller.exe"
      dlsize="12903592"
      sysname="QuickTimeFullInstaller.exe"
      testname="QuickTime"
      script="quicktime"
      sysinstallsw
    fi
  }
;;
"QuickTime Player 5.0")
  URL="http://www.apple.com/quicktime/products/qt/"
  showinfo || {
      $DIALOG --title "`eval_gettext "Hint"`" \
	      --no-cancel \
	      --msgbox "`eval_gettext "For older QuickTime installations you need the files on a CD\nor any other medium since they are not downloadable any more..."`" 7 60
    dload="none"
    dlsize=""
#    installer="$WINE d:\\setup.exe"
    installer="***SEARCH***"
    testname="QuickTime"
    script="quicktime"
    sysinstallsw    
  }
;;
"Typograf 4 Fontmanagement German")
  URL="http://www.neuber.com/typograf/index.html"
  showinfo || {
    $DIALOG --title "`eval_gettext "Hint"`" \
	    --no-cancel \
	    --msgbox "`eval_gettext "Note that the installer will not quit with the finish button.\nYou have to quit the dialog by closing the window."`" 7 60
    waitforwineexit
    cp -a ~/.wine/config ~/.wine/config.t$$
    cat >>~/.wine/config <<EOF
[AppDefaults\\\\setup.exe\\\\x11drv]
"Managed" = "N"
"Desktop" = "1024x768"

EOF
    dload="http://www.neuber.biz/download/typo40d.exe"
    dlsize="1008304"
    sysname="typo40d.exe"
    script="typograf"
    sysinstall "" "-nofail"
    cp -a ~/.wine/config.t$$ ~/.wine/config
    rm ~/.wine/config.t$$
  }
;;
"Typograf 4 Fontmanagement English")
  URL="http://www.neuber.com/typograph/index.html"
  showinfo || {
    $DIALOG --title "`eval_gettext "Hint"`" \
	    --no-cancel \
	    --msgbox "`eval_gettext "Note that the installer will not quit with the finish button.\nYou have to quit the dialog by closing the window."`" 7 60
    waitforwineexit
    cp -a ~/.wine/config ~/.wine/config.t$$
    cat >>~/.wine/config <<EOF
[AppDefaults\\\\setup.exe\\\\x11drv]
"Managed" = "N"
"Desktop" = "1024x768"

EOF
    dload="http://www.neuber.biz/download/typo40e.exe"
    dlsize="982200"
    sysname="typo40e.exe"
    script="typograf"
    sysinstall "" "-nofail"
    cp -a ~/.wine/config.t$$ ~/.wine/config
    rm ~/.wine/config.t$$
  }
;;
"FontPage")
  URL="http://bluefive.pair.com/fontpage.htm"
  needsw "vbrun60sp5.exe" "--no-cancel"
  showinfo || {
    dload="http://users.telenet.be/david.de.groot/progs/FontPage.zip"
    dlsize="1067116"
    sysname="FontPage.zip"
    installer="unzip -o FontPage.zip -d $SYSDIR/sys/tmp"
    sysinstall
    init
    dload="none"
    dlsize="1088401"
    sysname="tmp/setup.exe"
    testname="FontPage.*"
    script="fontpage"
    sysinstall
    cleantmp
  }
;;
"UltimateZip")
  URL="http://www.ultimatezip.de/"
  showinfo || {
    $DIALOG --title "`eval_gettext "Hint"`" \
	--no-cancel \
	--msgbox "`eval_gettext "When UltimateZip is started you will find a WinZip icon\nin the system tray. Right click and quit it.\nCheck that it never starts again!"`" 9 70
    dload="http://www.swe-von-schleusen.de/uz/27us/uzsetup.exe"
    dlsize="3468862"
    sysname="uzsetup.exe"
    testname="UltimateZip.*"
    script="uzip"
    sysinstall
  }
;;
"IRon")
  URL="http://www.zeitungs.info/public/programme.iron.html"
  showinfo || {
    needsw "RealPlayer" && {
      dload="http://download.zeitungs.info/download.php?what=iron_del.exe"
      dlsize="903259"
      sysname="iron_del.exe"
      testname="IRon.*"
      script="iron"
      sysinstall
    }
  }
;;
"TVgenial")
  URL="http://www.tvgenial.com/"
  showinfo || {
      dload="http://80.237.202.68/~admin1/downloads/TVgenial330.exe"
      dlsize="2034363"
      sysname="TVgenial330.exe"
      testname="TVgenial"
      script="tvgenial"
      sysinstall
  }
;;
"Scribble Papers")
  URL="http://home.arcor.de/jhoetger/scpapers/"
  showinfo || {
      dload="http://home.arcor.de/jhoetger/scpapers/SPSetup.exe"
      dlsize="1093018"
      sysname="SPSetup.exe"
      testname="Scribble Papers.*"
      script="scpapers"
      sysinstall
  }
;;
"Qimage")
  URL="http://www.ddisoftware.com/qimage/"
  CONTACT="mchaney@ddisoftware.com"
  showinfo || {  
    dload="http://www.ddisoftware.com/qimage/q05-117.exe"
    dlsize="4381968"
    sysname="q05-117.exe"
    testname="Qimage.*"
    script="qimage"
    sysinstall
  }
;;
"NeatImage")
  URL="http://www.neatimage.com"
  CONTACT="info@neatimage.com"
  showinfo || {  
    dload="http://www.neatimage.net/files/NeatSetup.exe"
    dlsize="1384583"
    sysname="NeatSetup.exe"
    testname="Neat Image .*"
    script="neatimage"
    sysinstall
  }
;;
"KLV 4 (german)")
  needsw "MDAC_TYP.EXE" "--no-cancel"
  needsw "Jet40SP8_9xNT.exe" "--no-cancel"
  URL="http://www.klv-software.de"
  CONTACT="info@klv-software.de"
  showinfo || {  
    dload="http://www.klv-software.de/download/install.exe"
    dlsize="5075456"
    sysname="install.exe"
    script="klv4"
    sysinstall
  }
;;
"7-Zip")
  URL="http://www.7-zip.org"
  CONTACT="ipavlov@users.sourceforge.net"
  showinfo || {  
    dload="$SFMIRROR/sevenzip/7z415b.exe"
    dlsize="1137511"
    sysname="7z415b.exe"
    testname="7-Zip .*"
    script="7-zip"
    sysinstall
  }
;;
"MailWasher Pro International Version")
  URL="http://www.firetrust.com/products/pro/"
  CONTACT="matthew.miller@firetrust.com"
  showinfo || {  
    dload="http://home.xtra.co.nz/hosts/nickbolton/mailwasherpro/mwp_419_international.exe"
    dlsize="5163606"
    sysname="mwp_419_international.exe"
    testname="MailWasher Pro.*"
    script="mailwasher"
    sysinstall
  }
;;
"X-Lite v2.0 Build 1103m English")
  URL="http://www.xten.com/"
  CONTACT="corporate@xten.com"
  showinfo || {  
    dload="http://builds.xten.net/download-public.php?download=1135"
    dlsize="1769495"
    sysname="X_lite-Xten-Win32-1103m-14262.exe"
    testname="X-Lite 2.0 .*"
    script="x-lite"
    sysinstall
  }
;;
"X-Lite v2.0 Build 1103m German")
  URL="http://www.globalipphones.com/_Pages/IndexFrameset/Frameset.aspx"
  CONTACT="corporate@xten.com"
  showinfo || {  
    dload="http://www.globalipphones.com/_Pages/IndexFrameset/ContentFrame.aspx?gotoDownload=yes&un=gipp&vers=lite&lang=ger"
    dlsize="2846154"
    sysname="X-Lite_ger1103m.exe"
    testname="X-Lite"
    script="x-lite"
    sysinstall
  }
;;
"Phoner 1.69")
  URL="http://www.phoner.de/index_en.htm"
  CONTACT="info@phoner.de"
  showinfo || {  
    dload="http://www.phoner.de/PhonerSetup.exe"
    dlsize="1678769"
    sysname="PhonerSetup.exe"
    testname="Phoner 1.69"
    script="phoner"
    sysinstall
  }
;;
"Skype 1.1")
  URL="http://www.skype.com/"
  CONTACT="info@skype.com"
  showinfo || {  
    dload="http://www.skype.com/go/getskype"
    dlsize="5909216"
    sysname="SkypeSetup.exe"
    testname="Skype .*"
    script="skype-win"
    sysinstall
  }
;;
"Scrutico")
  URL="http://photofiltre.free.fr/frames_en.htm"
  CONTACT="photofiltre@free.fr"
  showinfo || {
      dload="http://photofiltre.free.fr/utils/Scrutico.zip"
      dlsize="544210"
      sysname="Scrutico.zip"
      installer="unzip -o Scrutico.zip -d $WINEDIR/c/Programme/Scrutico"
      script="scrutico"
      sysinstall
  }
;;
"PhotoFiltre 6.1")
  URL="http://photofiltre.free.fr/frames_en.htm"
  CONTACT="photofiltre@free.fr"
  showinfo || {
      dload="http://photofiltre.free.fr/utils/pf-setup-en.exe"
      dlsize="1585705"
      sysname="pf-setup-en.exe"
      testname="PhotoFiltre"
      script="photofiltre"
      sysinstall
      $DIALOG --title "`eval_gettext "Info"`" \
	      --yesno "`eval_gettext "Installing plugins now. This could take a while..."`" 9 70
      if [ "$?" = "0" ]; then
	cd "$SYSDIR/sys"
        wget -r -np "http://plugins.photofiltre.free.fr/plugins/"
        unzip -o "$SYSDIR/sys/plugins.photofiltre.free.fr/plugins/*.zip" -d "$WINEDIR/c/Programme/PhotoFiltre/Plugins"
	instfilter="`for n in \"$SYSDIR/sys/plugins.photofiltre.free.fr/plugins\"/*.zip; do basename \"$n\" \".zip\"; done | paste -s`"
        $DIALOG --title "`eval_gettext "Info"`" --wrap \
	        --msgbox "`eval_gettext "The following filters have been found and installed:\n$instfilter"`" 15 80
      fi
      $DIALOG --title "`eval_gettext "Info"`" \
	      --yesno "`eval_gettext "Installing selections, masks, patterns, and thumbnails now.\nThis could take a while, too..."`" 9 70
      if [ "$?" = "0" ]; then
	cd "$SYSDIR/sys"
        wget -r -np "http://photofiltre.free.fr/suppl/"
        unzip -o "$SYSDIR/sys/photofiltre.free.fr/suppl/pfs_*.zip" -d "$WINEDIR/c/Programme/PhotoFiltre/Selections"
	instfilter="`for n in \"$SYSDIR/sys/photofiltre.free.fr/suppl\"/pfs_*.zip; do basename \"$n\" \".zip\"; done | paste -s`"
        $DIALOG --title "`eval_gettext "Info"`" --wrap \
	        --msgbox "`eval_gettext "The following selections have been found and installed:\n$instfilter"`" 15 80
        unzip -o "$SYSDIR/sys/photofiltre.free.fr/suppl/pm_*.zip" -d "$WINEDIR/c/Programme/PhotoFiltre/Masks"
	instfilter="`for n in \"$SYSDIR/sys/photofiltre.free.fr/suppl\"/pm_*.zip; do basename \"$n\" \".zip\"; done | paste -s`"
        $DIALOG --title "`eval_gettext "Info"`" --wrap \
	        --msgbox "`eval_gettext "The following masks have been found and installed:\n$instfilter"`" 15 80
        unzip -o "$SYSDIR/sys/photofiltre.free.fr/suppl/mo_*.zip" -d "$WINEDIR/c/Programme/PhotoFiltre/Patterns"
	instfilter="`for n in \"$SYSDIR/sys/photofiltre.free.fr/suppl\"/mo_*.zip; do basename \"$n\" \".zip\"; done | paste -s`"
        $DIALOG --title "`eval_gettext "Info"`" --wrap \
	        --msgbox "`eval_gettext "The following patterns have been found and installed:\n$instfilter"`" 15 80
        unzip -o "$SYSDIR/sys/photofiltre.free.fr/suppl/th_*.zip" -d "$WINEDIR/c/Programme/PhotoFiltre/Vignette"
	instfilter="`for n in \"$SYSDIR/sys/photofiltre.free.fr/suppl\"/th_*.zip; do basename \"$n\" \".zip\"; done | paste -s`"
        $DIALOG --title "`eval_gettext "Info"`" --wrap \
	        --msgbox "`eval_gettext "The following thumbnails have been found and installed:\n$instfilter"`" 15 80
      fi
  }
;;
"WinAmp 5 incl. Streamripper")
  URL="http://www.winamp.com/"
  showinfo || {
#    $DIALOG --title "`eval_gettext "Hint"`" \
#	--no-cancel \
#	--msgbox "When WinAmp is started you will find an icon\nin the system tray. Right click and quit it.\nCheck that it never starts again!" 9 70
      dload="http://download.nullsoft.com/winamp/client/winamp508d_full_emusic-7plus.exe"
      dlsize="4654144"
      sysname="winamp508d_full_emusic-7plus.exe"
      testname="Winamp.*"
      script="winamp"
      sysinstall
      init
      dload="$SFMIRROR/streamripper/srwa5-1.61.3.exe"
      dlsize="856682"
      sysname="srwa5-1.61.3.exe"
      sysinstall
  }
;;
"WinAmp 2 incl. Streamripper")
  URL="http://www.winamp.com/"
  showinfo || {
#    $DIALOG --title "`eval_gettext "Hint"`" \
#	--no-cancel \
#	--msgbox "When WinAmp is started you will find an icon\nin the system tray. Right click and quit it.\nCheck that it never starts again!" 9 70
      dload="http://download.nullsoft.com/winamp/client/winamp291_full.exe"
      dlsize="2320949"
      sysname="winamp291_full.exe"
      testname="Winamp.*"
      script="winamp"
      sysinstall
      init
      dload="$SFMIRROR/streamripper/srwa5-1.61.3.exe"
      dlsize="856682"
      sysname="srwa5-1.61.3.exe"
      sysinstall
  }
;;
"CoolPlayer")
  URL="http://coolplayer.sourceforge.net/"
  showinfo || {
    $DIALOG --title "`eval_gettext "Hint"`" \
	--no-cancel \
	--msgbox "If playback is broken change Options - Output to \"Cooler Wave mapper\"." 6 70
      dload="$SFMIRROR/coolplayer/CoolPlayer215_Bin.zip"
      dlsize="325247"
      sysname="CoolPlayer215_Bin.zip"
      mkdir "$WINEDIR/c/Programme/CoolPlayer"
      installer="unzip -o CoolPlayer215_Bin.zip -d $WINEDIR/c/Programme/CoolPlayer"
      script="coolplayer"
      sysinstall
  }
;;
"Ultimate Paint LE")
  URL="http://www.ultimatepaint.com/"
  showinfo || {
    mustnotsw "Ultimate Paint 1.*" && {
      dload="http://www.ultimatepaint.com/up.zip"
      dlsize="1783250"
      sysname="up.zip"
      installer="unzip -o up.zip -d $SYSDIR/sys/tmp"
      sysinstall
      init
      dload="none"
      dlsize="1808049"
      sysname="tmp/setup.exe"
      testname="Ultimate Paint 2.*"
      script="upaint"
      sysinstall
      init
      dload="http://www.ultimatepaint.com/deutsch286.zip"
      dlsize="450784"
      sysname="deutsch286.zip"
      installer="unzip -o deutsch286.zip -d $WINEDIR/c/Programme/UP"
      sysinstall
      init
      dload="http://www.ultimatepaint.com/magyar286.zip"
      dlsize="488736"
      sysname="magyar286.zip"
      installer="unzip -o magyar286.zip -d $WINEDIR/c/Programme/UP"
      sysinstall
      $DIALOG --title "`eval_gettext "*** NOTE ***"`" \
              --msgbox "`eval_gettext "Ultimate Paint may start with a zoom factor for new pictures\nthat produces an \"Out of Memory\" error but the program still works.\nGo to options-settings and set the zoom factor to 1-10."`" 12 60
      cleantmp
    }
  }
;;
"Ultimate Paint 1.91f")
  URL="http://www.megaluxltd.com/eng/index.html"
  showinfo || {
    mustnotsw "Ultimate Paint 2.*" && {
      dload="http://www.computerbild.de/programme/ultimatepaint.exe"
      dlsize="1993846"
      sysname="ultimatepaint.exe"
      testname="Ultimate Paint 1.*"
      script="upaint"
      sysinstall
      init
      dload="http://www.ultimatepaint.com/deutsch286.zip"
      dlsize="450784"
      sysname="deutsch286.zip"
      installer="unzip -o deutsch286.zip -d $WINEDIR/c/Programme/UP"
      sysinstall
      init
      dload="http://www.ultimatepaint.com/magyar286.zip"
      dlsize="488736"
      sysname="magyar286.zip"
      installer="unzip -o magyar286.zip -d $WINEDIR/c/Programme/UP"
      sysinstall
#      $DIALOG --title "`eval_gettext "*** NOTE ***"`" \
#              --msgbox "Ultimate Paint may start with a zoom factor for new pictures\nthat produces an \"Out of Memory\" error but the program still works.\nGo to options-settings and set the zoom factor to 1-10." 12 60
      cleantmp
    }
  }
;;
"Fort Agent Newsreader 2.0")
  URL="http://www.forteinc.com/agent/index.php"
  showinfo || {
    dload="ftp://ftp3.forteinc.com/pub/agent/english/agentenu200-652.exe"
    dlsize="3818184"
    sysname="agentenu200-652.exe"
    testname="Fort Agent"
    script="agentnr"
    sysinstall
  }
;;
"DBCrab 1.50 German with BDE 5.1.1 German")
  URL="http://www.dbcrab.de"
  CONTACT="feedback@dbcrab.de"
  showinfo || {
    dload="http://www.dbcrab.de/zip/dbcrab150.zip"
    dlsize="5418434"
    sysname="dbcrab150.zip"
    installer="unzip -o dbcrab150.zip -d $SYSDIR/sys/tmp"
    sysinstall
    init
    dload="none"
    dlsize="45312"
    sysname="tmp/SETUP.EXE"
    testname="DBCrab"
    script="dbcrab"
    sysinstall
    $WINE regedit "$BASEDIR/bde.reg"
    cleantmp
  }
;;
"Borland Database Engine (BDE) 5.1.1 English")
  URL="http://info.borland.com/devsupport/bde/"
  showinfo || {
    needsw "DBCrab"
    if [ "$?" = "0" ]; then
      for n in BDEADMIN.CNT BDEADMIN.EXE BDEADMIN.HLP BDEADMIN.TOC; do
        rm "$WINEDIR/c/Program Files/Common Files/Borland Shared/BDE/$n"
      done
      $WINE regedit "$BASEDIR/bde.reg"
      dload="ftp://ftpc.borland.com/pub/bde/devsupport/updates/bde511en.exe"
      dlsize="11895034"
      sysname="bde511en.exe"
      script="bdeadmin"
      sysinstall
      $WINE regedit "$BASEDIR/bde.reg"
    fi
  }
;;
"Borland Database Engine (BDE) 5.1.1 German")
  URL="http://info.borland.com/devsupport/bde/"
  showinfo || {
    dload="ftp://ftpc.borland.com/pub/bde/devsupport/updates/bde511ge.exe"
    dlsize="12039880"
    sysname="bde511ge.exe"
    testname="bde511.*exe"
    script="bdeadmin"
    sysinstall
  }
;;
"PostgreSQL ODBC driver psqlODBC 8.00.0101")
#"PostgreSQL ODBC driver psqlODBC 7.03.0200")
  URL="http://gborg.postgresql.org/project/psqlodbc/projdisplay.php"
  showinfo || {
#    dload="ftp://ftp.postgresql.org/pub/odbc/versions/full/psqlodbc-07_03_0200.zip"
#    dlsize="3781611"
#    sysname="psqlodbc-07_03_0200.zip"
    dload="ftp://ftp.postgresql.org/pub/odbc/versions/msi/psqlodbc-08_00_0101.zip"
    dlsize="194187"
    sysname="psqlodbc-08_00_0101.zip"
    installer="unzip -o $sysname -d $SYSDIR/sys/tmp"
    sysinstall
    init
    dload="none"
    dlsize="267776"
    sysname="tmp\\psqlodbc.msi"
    installer="$WINE msiexec /i f:\\sys\\${sysname}"
    testname="psqlODBC"
    script=""
    sysinstall    
    cleantmp
  }
;;
"mIRC 6.16")
  URL="http://www.mirc.com"
  showinfo || {
    dload="ftp://ftp.freenet.de/pub/mirc.com/mirc616.exe"
    dlsize="1302528"
    sysname="mirc616.exe"
    testname="mIRC"
    script="mirc"
    sysinstall
  }
;;
"IrfanView 3.95")
  URL="http://www.irfanview.com"
  showinfo || {
    needsw "vcredist.exe"
    if [ "$?" = "0" ]; then
      dload="http://fileforum.betanews.com/sendfile/967963863/1/iview395.exe"
      dlsize="877056"
      sysname="iview395.exe"
      testname="IrfanView.*"
      script="iview"
      sysinstall
      if [ "$failed" = "0" ]; then
        $DIALOG --title "IrfanView" \
	      --no-cancel \
	      --msgbox "Installing the Plugins now..." 7 60
        dload="http://fileforum.betanews.com/sendfile/1099412658/1/irfanview_plugins_395.exe"
        dlsize="4692992"
        sysname="irfanview_plugins_395.exe"
        testname=""
        script=""
        sysinstall
      fi
    fi
  }
;;
"putty 0.56")
  URL="http://www.chiark.greenend.org.uk/~sgtatham/putty/"
  showinfo || {
    dload="http://the.earth.li/~sgtatham/putty/latest/x86/putty-0.56-installer.exe"
    dlsize="1221389"
    sysname="putty-0.56-installer.exe"
    testname="PuTTY version .*"
    script="putty puttygent puttygen"
    sysinstall
  }
;;
"DC++")
  URL="http://dcplusplus.sourceforge.net"
  showinfo || {
    dload="$SFMIRROR/dcplusplus/DCPlusPlus-0.668.exe"
    dlsize="2452326"
    sysname="DCPlusPlus-0.668.exe"
    testname="DC++ .*"
    script="dc++"
    sysinstall
    if [ "$failed" = "0" ]; then
      $DIALOG --title "`eval_gettext "Hint"`" \
	    --no-cancel \
	    --msgbox "`eval_gettext "After first start disable the\n'progress bars for transfer'\nat advanced options."`" 9 60
    
    fi
  }
;;
"Adobe Photoshop 7.0")
  URL="http://www.gimp.org"
  showinfo || {
    dload="none"
    dlsize=""
    sysname="$choice"
    installer="***SEARCH***"
#    installer="$WINE d:\\setup.exe"
    testname="$choice"
    script="photoshop imageready"
    sysinstallsw
  }
;;
"Adobe Illustrator 9.0")
  URL="http://www.linuxartist.org"
  showinfo || {
    dload="none"
    dlsize=""
    sysname="$choice"
    installer="***SEARCH***"
#    installer="$WINE d:\\autoplay.exe"
    testname="$choice"
    script="illustrator"
    sysinstallsw
  }
;;
"WinZip 9.0 German")
  URL="http://www.winzip.com"
  showinfo || {
    $DIALOG --title "`eval_gettext "Hint"`" \
	--no-cancel \
	--msgbox "`eval_gettext "If the WinZip installer starts WinZip after completion of the installation quit it.\nAnd in the system tray you will also find a WinZip icon. Richt click and quit also.\nCheck that it never starts again!"`" 9 70
    dload="http://download.winzip.com/german/wz90gev.exe"
    dlsize="2609152"
    sysname="wz90gev.exe"
    testname="WinZip"
    scipt="winzip"
    sysinstall
  }
;;
"WinZip 9.0 English")
  URL="http://www.winzip.com"
  showinfo || {
    $DIALOG --title "`eval_gettext "Hint"`" \
	--no-cancel \
	--msgbox "`eval_gettext "If the WinZip installer starts WinZip after completion of the installation quit it.\nAnd in the system tray you will also find a WinZip icon. Richt click and quit also.\nCheck that it never starts again!"`" 9 70
    dload="http://download.winzip.com/winzip90.exe"
    dlsize="2417824"
    sysname="winzip90.exe"
    testname="WinZip"
    scipt="winzip"
    sysinstall
  }
;;
"WinRAR 3.41 German")
  URL="http://www.winrar-rog.de"
  showinfo || {
    dload="http://www.rarlab.com/rar/wrar341d.exe"
    dlsize="1144977"
    sysname="wrar341d.exe"
    testname="WinRAR .*"
    scipt="winrar"
    sysinstall
  }    
;;
"WinRAR 3.41 English")
  URL="http://www.rarlab.com"
  showinfo || {
    dload="http://www.rarlab.com/rar/wrar341.exe"
    dlsize="1164112"
    sysname="wrar341d.exe"
    testname="WinRAR .*"
    scipt="winrar"
    sysinstall
  }    
;;
*)
  additionalsoftware
;;
esac
additionalsoftware
;;

1)
    mainmenu
;;
esac
}

#################
### Main menu ###
#################

function mainmenu()
{
init
$DIALOG --title "WineTools 2.1.2" \
	--cancel-label "`eval_gettext "exit"`" \
	--item-help \
	--icon $BASEDIR/icon/wt.xpm \
        --menu ""  400x500 0  \
        "`eval_gettext "Base setup"`" "" "`eval_gettext "Start here with WineTools!"`" \
        "`eval_gettext "Install Windows system software"`" "" "`eval_gettext "Important additional software."`" \
        "`eval_gettext "Install Microsoft TrueType core fonts"`" "" "`eval_gettext "Fonts many applications rely on."`" \
        "`eval_gettext "Install tested software"`" "" "`eval_gettext "Software know to work with Wine."`" \
	" " "" "" \
	"`eval_gettext "Control Center"`" "" "`eval_gettext "The Windows Control Center."`" \
	"`eval_gettext "Registry Editor"`" "" "`eval_gettext "Comfortably edit the registry."`" \
	"`eval_gettext "Show installed Software"`" "" "" \
	"`eval_gettext "Uninstaller"`" "" "`eval_gettext "Uninstall Windows software."`" \
	"`eval_gettext "Simulate a Windows reboot"`" "" "" \
	"`eval_gettext "Show active Wine processes"`" "" "" \
	"`eval_gettext "Kill all Wine processes"`" "" "" \
	" " "" "" \
	"`eval_gettext "Save your Wine directory"`" "" "`eval_gettext "Backup an actual installation."`" \
	"`eval_gettext "Restore your Wine directory"`" "" "`eval_gettext "Restore an old installation."`" \
	"`eval_gettext "Edit the Wine configuration file"`" "" "`eval_gettext "Manually edit the config. Be careful! This can break your setup."`" \
	" " "" "" \
	"`eval_gettext "Read Intro again"`" "" "" \
	"`eval_gettext "About"`" "" "" 2> /tmp/menu.tmp.$$

retval=$?

choice=`cat /tmp/menu.tmp.$$|grep -v "checked"`
checked="F"
[ "`cat /tmp/menu.tmp.$$|grep \"checked\"`" = "checked" ] && checked="T"
rm -f /tmp/menu.tmp.$$

case $retval in
0)
echo "`eval_gettext "Choice is $choice"`"
case "$choice" in
"`eval_gettext "Read Intro again"`")
  about
  readme
  mainmenu
;;
"`eval_gettext "Base setup"`")
  systemsoftware
;;
"`eval_gettext "Install Windows system software"`")
  systemmenu
;;
"`eval_gettext "Install Microsoft TrueType core fonts"`")
  fonts
;;
"`eval_gettext "Install tested software"`")
  additionalsoftware
;;
"`eval_gettext "Control Center"`")
  $WINE control
  mainmenu
;;
"`eval_gettext "Registry Editor"`")
  $WINE regedit
  mainmenu
;;
"`eval_gettext "Uninstaller"`")
  $WINE uninstaller
  wineboot
  mainmenu
;;
"`eval_gettext "Simulate a Windows reboot"`")
  wineboot
  mainmenu
;;
"`eval_gettext "Show active Wine processes"`")
  ps axwww|grep wine|grep -v "grep wine" >/tmp/psoutput.tmp.$$
  $DIALOG --tailbox /tmp/psoutput.tmp.$$ 60 80
  rm /tmp/psoutput.tmp.$$
  mainmenu
;;
"`eval_gettext "Show installed Software"`")
  testsw "testsw"
  echo -e "`eval_gettext " *** Installed software via registry *** "`" >/tmp/psoutput.tmp.$$
  cat $HOME/.wine/installed-software >>/tmp/psoutput.tmp.$$
  echo -e "`eval_gettext "\n\n *** Quiet installed software via registry *** "`" >>/tmp/psoutput.tmp.$$
  cat $HOME/.wine/quiet-installed-software >>/tmp/psoutput.tmp.$$
  echo -e "`eval_gettext "\n\n *** Hidden installed software via $CONFIG *** "`" >>/tmp/psoutput.tmp.$$
  grep " = installed at " "$CONFIG" >>/tmp/psoutput.tmp.$$
  echo -e "`eval_gettext "\n\n *** Failed software installations via $CONFIG *** "`" >>/tmp/psoutput.tmp.$$
  grep " = installation failed at " "$CONFIG" >>/tmp/psoutput.tmp.$$
  $DIALOG --no-cancel --tailbox /tmp/psoutput.tmp.$$ 60 80
  rm /tmp/psoutput.tmp.$$
  mainmenu
;;

"`eval_gettext "Kill all Wine processes"`")
  $DIALOG  --defaultno --title "`eval_gettext "Kill"`" --yesno "`eval_gettext "Are you shure you want to kill *all* Wine processes???"`" 7 60
  $DIALOG  --title "`eval_gettext "*** NOTICE ***"`" --no-buttons --infobox "`eval_gettext "Please wait..."`" 7 60
  [ "$?" = "0" ] && wineserver -kill
  mainmenu
;;
"`eval_gettext "Save your Wine directory"`")
  cd ~
  $DIALOG --title "`eval_gettext "Create Fake Windows Drive"`" \
          --inputbox "`eval_gettext "Give a description for the file.\nIt will be called wine-<Description>.tar.gz:"`" 300x200 2> /tmp/description.tmp.$$
  if [ "$?" = "0" ]; then
    realtar="1"
    if [ -e "wine-`cat /tmp/description.tmp.$$`.tar.gz" ]; then
      $DIALOG  --title "`eval_gettext "tar File Exists"`" --yesno "`eval_gettext "The file already exists. Do you want to overwrite?"`" 7 60
      if [ "$?" = "0" ]; then
        realtar="1"
      else
        realtar="0"
      fi
    fi
    if [ "$realtar" = "1" ]; then
      (tar -cpvzf "wine-`cat /tmp/description.tmp.$$`.tar.gz" .wine; echo -e "`eval_gettext "===============================\ndone. You can close the window now!"`")  &>/tmp/taroutput.tmp.$$ &
      $DIALOG --tailbox /tmp/taroutput.tmp.$$ 60 80
    fi
  fi
  rm /tmp/taroutput.tmp.$$
  mainmenu
;;
"`eval_gettext "Restore your Wine directory"`")
  cd ~
  $DIALOG --title "`eval_gettext "Create Fake Windows Drive"`" \
          --inputbox "`eval_gettext "Give the description for the saved file.\nThe file will be called wine-<Description>.tar.gz:"`" 300x200 2> /tmp/description.tmp.$$
  if [ "$?" = "0" ]; then
    realtar="1"
    if [ -e "wine-`cat /tmp/description.tmp.$$`.tar.gz" ]; then
      if [ -e ".wine" ]; then
        $DIALOG  --title "`eval_gettext ".wine exists"`" --defaultno --yesno "`eval_gettext "The .wine directory already exists. Do you want to delete it?"`" 7 60
        if [ "$?" = "0" ]; then
          rm -Rf .wine
	  if [ "$?" = "0" ]; then
            realtar="1"
	  else
            $DIALOG  --title "`eval_gettext "*** ERROR ***"`"\ --msgbox "`eval_gettext "There was a error deleting the .wine directory. We can not continue."`" 7 60
            realtar="0"
	  fi
        else
          $DIALOG  --title "`eval_gettext "*** NOTICE ***"`" --msgbox "`eval_gettext "We can not continue!"`" 7 60
          realtar="0"
        fi
      fi
    else
      $DIALOG  --title "`eval_gettext "*** ERROR ***"`"\ --msgbox "`eval_gettext "The tar file does not exist! We can not continue."`" 7 60
      realtar="0"
    fi
    if [ "$realtar" = "1" ]; then
      (tar -xpvzf "wine-`cat /tmp/description.tmp.$$`.tar.gz"; echo -e "`eval_gettext "===============================\ndone. You can close the window now!"`")  &>/tmp/taroutput.tmp.$$ &
      $DIALOG --tailbox /tmp/taroutput.tmp.$$ 60 80
    fi
  fi
  rm /tmp/taroutput.tmp.$$
  mainmenu
;;
"`eval_gettext "Edit the Wine configuration file"`")
  editconfig
;;
"`eval_gettext "About"`")
  about
  mainmenu
;;
*)
  mainmenu
;;
esac
;;

1)
    clear
;;
esac
}

###################
### Edit config ###
###################
function editconfig_new()
{
cp ~/.wine/config ~/.wine/config.bak
winecfg
$DIALOG  --defaultno --title "`eval_gettext "Save Wine config"`" --yesno "`eval_gettext "Do you want to save your changes?"`" 7 60
case $? in
  0)
    mainmenu 
    ;;
  1)
    cp ~/.wine/config.bak ~/.wine/config
    mainmenu
    ;;
esac

rm -f /tmp/xedit$$
}

function editconfig()
{
cp ~/.wine/config ~/.wine/config.edit.$$
$DIALOG --title "`eval_gettext "Edit Wine config"`" --fixed-font "" \
	--ok-label "`eval_gettext "Save"`" \
	--editbox ~/.wine/config.edit.$$ 0 0 2> ~/.wine/config.edited.$$
choice="$?"
echo "`eval_gettext "Return value is $choice"`"
case "$choice" in
  0)
    echo "`eval_gettext "saved new config"`"
    mv -f ~/.wine/config.edited.$$ ~/.wine/config
    rm ~/.wine/config.edit.$$
    mainmenu
    ;;
  *)
    echo "`eval_gettext "aborted editing new config"`"
    rm ~/.wine/config.edit.$$ ~/.wine/config.edited.$$
    mainmenu
    ;;
esac

rm -f /tmp/xedit$$
}



#############
### About ###
#############
function about()
{
$DIALOG --title "`eval_gettext "About WineTools"`" \
	--msgbox \
"`eval_gettext "WineTools was initially written by Frank Hendriksen <frank@franksworld.net>
and was extended and is maintained by Joachim von Thadden <thadden@web.de>.

It is licensed under the GPL.

Send comments, bugreports, etc. to thadden@web.de. Don't blame me for the
code. It's a horrible hack but it works.

Note:	This software comes with absolutely no warranty.
	You will not get any support or help for WineTools, Wine, software
	installations, Linux or Microsoft Windows from the author. If you need
	help, ask the mailing lists at http://www.winehq.org/site/forums. If you
	want support, buy the commercial versions of wine: CodeWeavers
	CrossOver Office (http://www.codeweavers.com) for Desktop
	Applications or	TransGamings Cedega (formerly known as WineX)
	(http://www.transgaming.com) for playing games."`" 25 80

}


function readme()
{
    if [ -e "${BASEDIR}/doc/README.${WINEVER}" ]; then
      cat ${BASEDIR}/doc/README.first ${BASEDIR}/doc/README.${WINEVER} > /tmp/README.wine.$$
    else
      cat ${BASEDIR}/doc/README.first ${BASEDIR}/doc/README.nover > /tmp/README.wine.$$
    fi
    $DIALOG --title "`eval_gettext "Intro"`" --fixed-font "" \
	--no-cancel \
	--textbox /tmp/README.wine.$$ 35 60
    rm /tmp/README.wine.$$
}


####################
### Main Program ###
####################

. ${BASEDIR}/findwine --noexit

# take an old winetools.log to the new format
grep "^\*new\* fake Windows drive created at" "$CONFIG" &>/dev/null
if [ "$?" = "0" ]; then
  sed -e "s/\*new\* fake Windows drive created at/\*new\* fake Windows drive = installed at/" "$CONFIG" > "$CONFIG.new"
  mv -f "$CONFIG.new" "$CONFIG"
  echo "$CONFIG changed to new version"
fi

# take an old config to the new form
if [ -e "$WINEDIR/config" ]; then
  CONFVERUSER="`grep \"^;; Version .*jo$\" $WINEDIR/config`"
  CONFVERWT="`grep \"^;; Version .*jo$\" $BASEDIR/config.212`"
  if [ "$CONFVERUSER" != "$CONFVERWT" ]; then
    $DIALOG  --title "`eval_gettext "*** NOTICE ***"`" --yesno "`eval_gettext "Your config is not the one that comes with recent WineTools.\nYou should copy WineTools \"config.212\" to \".wine/config\".\nShall I do that for you?"`" 9 60
    if [ "$?" = "0" ]; then
      mv "$WINEDIR/config" "$WINEDIR/config.`date +backup_%Y-%m-%d`"
      cp "$BASEDIR/config.212" "$WINEDIR/config"
      $DIALOG  --title "`eval_gettext "*** NOTICE ***"`" --msgbox "Your original config has been saved as\n\"$WINEDIR/config.`date +backup_%Y-%m-%d`\"" 7 70
    fi
  fi
fi

# find a browser
for n in dillo firefox mozilla konqueror; do
  BROWSER="`which $n 2>/dev/null`"
  [ "$BROWSER" = "" ] || break
done

echo "`eval_gettext "Browser is $BROWSER."`"

[ ! -d $SYSDIR ] && mkdir $SYSDIR

[ ! -d $SYSDIR/fonts ] && mkdir $SYSDIR/fonts

[ ! -d $SYSDIR/sys ] && mkdir -p $SYSDIR/sys/tmp

[ ! -d $SYSDIR/sys/tmp ] && mkdir $SYSDIR/sys/tmp

#[ ! -d $SYSDIR/user ] && mkdir $SYSDIR/user

[ ! -d "${BINDIR}" ] && mkdir "${BINDIR}"

[ -e "$WINEDIR/dosdevices/f:" ] && rm "$WINEDIR/dosdevices/f:" && ln -s "$SYSDIR" "$WINEDIR/dosdevices/f:"

echo "WINEVER is \"$WINEVER\"."
if [ "$WINEVER" -lt "20040914" ] || [ "$WINEVER" -gt "20050111" ]; then
  $DIALOG  --title "`eval_gettext "*** NOTICE ***"`" --msgbox "`eval_gettext "WineTools is tested with Wine versions\n20040914, 20041019, 20041201, 20050111.\nYou use a different version so the results are unpredictable."`" 9 60
else
  echo "`eval_gettext "Version of Wine is OK."`"
fi

if [ "$WINEVER" = "20050111" ] || [ "$WINEVER" = "20041201" ]; then
  $DIALOG  --title "`eval_gettext "*** NOTICE ***"`" --msgbox "`eval_gettext \
"There is only experimental support for Wine versions 20041201 and 20050111
in WineTools. Recent tests showed that some programs you can install with
WineTools do not work properly with these Wine versions. You should consider
installing the 20041019 release which showed the best results with WineTools
until now."`" 15 70
fi

echo "`eval_gettext "Calls to wine are executed as "`" "\"$WINE\"."
echo "`eval_gettext "Config is $CONFIG."`"
echo "`eval_gettext "CDROM is $CDROM."`"

about
readme
mainmenu
