#!/bin/bash



  #	AcetoneISO2 Pro
  #	Copyright (C) 2006  Fabrizio Di Marco & Marco Di Antonio    <acetoneiso_at_gmail.com>
  #
  #  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
 


VARIN=`kdialog --icon /usr/share/pixmaps/aiso2.png --caption "Select ISO to be Mounted" --getopenfilename $HOME/ "*.iso"`

if test -z "$VARIN"
then
exit
else
echo continua
fi

VAROUT=`kdialog --icon /usr/share/pixmaps/aiso2.png --caption "Select Folder to Mount" --getexistingdirectory $HOME/ `
if test -z "$VAROUT"
then
exit
else
echo continua
fi

if test "$VAROUT" = $HOME
then
kdialog --sorry "AcetoneISO2 will not allow You to mount in $HOME for obvious reasons!"
exit
else
echo continua
fi

			if test ! -w "$VAROUT"
			then
			

  	if `kdialog --title "AcetoneISO2 warning dialog" --warningyesno "ATTENTION!\nThere is already an ISO mounted in '$VAROUT'. Do you want to Umount it so I can Mount it for You?"`
  	then
  	 kdesu -n -d -i /usr/share/pixmaps/aiso.png "umount '$VAROUT';mount -o loop -t iso9660 '$VARIN' '$VAROUT'" 
								if test -w "$VAROUT"
								then 
								kdialog --error "Sorry, AcetoneISO2 wasn't able to Mount the Image"
								else
								konqueror "$VAROUT"
								fi
							

  	else
	exit
  	fi

			else

    		        kdesu -n -d -i /usr/share/pixmaps/aiso2.png "mount -o loop -t iso9660 '$VARIN' '$VAROUT'"
					if test -w "$VAROUT"
					then 
					kdialog --error "Sorry, AcetoneISO2 wasn't able to Mount the Image"
					else
  					konqueror "$VAROUT"
					fi
					
  			
			fi