#!/bin/sh

# removefile.sh
# Uninstall
#
# Created by Smith_yang on 09-2-23.
# Copyright 2009 __MyCompanyName__. All rights reserved.
killall  "SharpTouchPanel2"  || echo "No killprocess"
killall  "SharpPointerTool"  || echo "No killprocess"
kill -9 `pgrep SharpTouchPanel2`
killall "SharpTouchPanel2Driver" || echo "No killprocess"
#killall "SharpTouchPanel2SettingUtility" || echo "No killprocess"
killall "System Preferences" || echo "No killprocess"
killall "CalibrationTool" || echo "No killprocess"
killall "SharpTouchUtility" || echo "No killprocess"
#sleep 3


echo $1
echo "The uninstaller will be uninstall the SharpTouchDisplayDriver all files."
echo $2
#PERL = echo $2

#sudo chown root:wheel $2


case $1 in
	1) echo "1 time"
		$2
		#perl $PERL
        rm -f -R   /Library/PreferencePanes/SharpTouchPanel2.prefPane
        rm -f -R   /Library/PreferencePanes/TouchPanel2forBLE.prefPane
        sudo rm -f -R   /Library/PreferencePanes/TouchPanel2forBLE.prefPane
        sudo rm -f -R   /Library/PreferencePanes/SharpTouchPanel2.prefPane
		;;
	5) echo "2 times"
		rm -f -R /Library/LaunchAgents/com.newsoft.TouchPanel2.plist
        rm -f -R /Library/LaunchAgents/jp.co.sharp.displaysystem.touchPanel2.plist
		;;
	10) echo "3 times"
		rm -f -R /Library/Preferences/SharpTouchPanel2
		rm -f -R ~/Library/Preferences/SharpTouchPanel2
        rm -f -R /Applications/SharpTouchUtility.app
        sudo rm -f -R /Applications/SharpTouchUtility.app

		;;
	20) echo "4 times"
		#remove the TouchDisplayDriver.kext
		kextunload /System/Library/Extensions/TouchPanel2Driver.kext
        rm -f -R  /System/Library/Extensions/TouchPanel2Driver.kext

        kextunload /Library/Extensions/TouchPanel2Driver.kext
        rm -f -R  /Library/Extensions/TouchPanel2Driver.kext
        rm -r -f -R /private/var/root/Library/Preferences/SharpTouchPanel2

		;;

	30) echo "5 times"
		rm -rf -R /Library/Application\ Support/SharpTouchPanel2
        rm -rf /usr/local/lib/libTouchSDK.dylib
        rm -rf /usr/lib/libTouchSDK.dylib

        kextunload /Library/Extensions/SharpIWBUSBSerialDriver.kext
        rm -f -R  /Library/Extensions/SharpIWBUSBSerialDriver.kext
        kextunload /Library/Extensions/SharpIWBUSBSerialDriver.kext
        rm -f -R  /Library/Extensions/SharpIWBFTDIDriver.kext
		;;
esac

echo "SharpTouchDisplayDriver has remove the all files."
