#!/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
 


kdialog --caption "AcetoneISO2" --msgbox "Please note that this utility will mount only true DMG image. Normal DMG data files will not be mounted because they are just data and not true Apple FS HFS\nYou can manually check if it's a Apple FS HFS image typing from a terminal ' file namefile.dmg '"

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

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 a DMG image mounted in '$VAROUT'. Do you want to Umount it so I can Mount it for You?"`
  	then
  	 kdesu -n -d -i /usr/share/pixmaps/aiso2.png "umount '$VAROUT';mount -t hfs -o loop '$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/aiso.png "mount -t hfs -o loop '$VARIN' '$VAROUT'"
					if test -w "$VAROUT"
					then 
					kdialog --error "Sorry, AcetoneISO2 wasn't able to Mount the Image"
					else
  					konqueror "$VAROUT"
					fi
					
  			
			fi