#! /bin/bash
#####################################################################################################
# SecureCopyFiles with KDialog Progressbar - v0.1
#
# Copyright (C) 2009 Markus Schulze
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
##########################################################################################################################################

# the file you've selected (%u)
FILE=${1}
# user and path of the remote pc (second parameter)
TO=${2}

dcopRef=`kdialog --title "Kopiervorgang" --progressbar "Kopiervorgang gestartet! Datei wird jetzt kopiert. Je nach Größe kann sowas dauern..." 1`
dcop $dcopRef showCancelButton true
sleep 1

if [ `dcop $dcopRef wasCancelled` == "false" ]
then	
	dcop $dcopRef setLabel "Kopiere ${FILE} ==>  $TO"
	inc=$((`dcop $dcopRef progress` + 1))
	sleep 0.5
	scp "${FILE}" $TO	
	dcop $dcopRef setProgress $inc
	dcop $dcopRef setLabel "${FILE} erfolgreich kopiert"
	dcop $dcopRef showCancelButton true
	sleep 0.75
fi

dcop $dcopRef close
