#
# Copyright (C) by Stefano Falsetto
# e-mail contact ....: mailto:stefko5@inwind.it
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#
# Config plugin for dagrab
#

cat_variables_dagrab () {
    cat <<EOF
# Complete path for dagrab
dagrab_DECODER="$dagrab_DECODER"

# Handled format file in output
OUTPUT_FORMATS_dagrab=( $OUTPUT_FORMATS_dagrab )

# Parameters to output files in various formats
dagrab_TO_wav="$dagrab_TO_wav"
dagrab_TOFMT="$dagrab_TO_wav"

# Options to dagrab
DAGRAB_OPT="$DAGRAB_OPT"

EOF
}

###############
# MAIN
###############

if [ $(expr "$SUPPORTED_FORMATS" : ".*CDA.*") -ne ${#SUPPORTED_FORMATS} ]; then
  begin_check dagrab
  find_prg dagrab
  dagrab_DECODER=$FOUND_PRG
  if [ -z "$dagrab_DECODER" ]; then
    missing dagrab "http://vertigo.fme.vutbr.cz/~stibor/dagrab.html"
  else
    EXTENSIONS="CDA"
    OUTPUT_FORMATS_dagrab="wav"
    dagrab_TO_wav="wav"
    dagrab_TOFMT=$dagrab_TO_wav
    AUDIO_PLUGINS="$AUDIO_PLUGINS dagrab"
    PARAMETERS="cdda:.*"
    PLUGINS_WITH_PARAMETERS="$PLUGINS_WITH_PARAMETERS dagrab"
    SUPPORTED_FORMATS="$SUPPORTED_FORMATS $EXTENSIONS"
    QueryVersion $($dagrab_DECODER --help|head -n1|cut -d' ' -f2) dagrab "S0.493"
    echo
    quest "Do you want to use jitter correction (-J option)" "jitter correction on" "jitter correction off" 1
    if [ $? -eq 1 ]; then
      DAGRAB_OPT="-J"
    fi
  fi  
  
  end_check
fi
