#!/bin/bash

#Copyright 2012 - 2017 CurlyMo & mkreisl <development@xbian.org>
#
#This file is part of XBian - XBMC on the Raspberry Pi.
#
#XBian 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.
#
#XBian 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 XBian. If not, see <http://www.gnu.org/licenses/>

function showUmountFormatError() {
        wrapTxtFn "$(_ xbiancopy.dialog.preperror)" $(($DEFAULTWIDTH-4))
        centerTxtFn "$WRAPPEDTXT" $(($DEFAULTWIDTH-4))
        valignTxtFn "$CENTEREDTXT"
        showInfoDlg "$ALIGNEDTXT" $HEIGHT
        return $?;
}

function showNFSerror() {
        wrapTxtFn "$(_ xbiancopy.dialog.exportwrong)" $(($DEFAULTWIDTH-4))
        centerTxtFn "$WRAPPEDTXT" $(($DEFAULTWIDTH-4))
        valignTxtFn "$CENTEREDTXT"
        showInfoDlg "$ALIGNEDTXT" $HEIGHT
        return $?;
}

function showiSCSIerror() {
        wrapTxtFn "$(printf "$(_ xbiancopy.dialog.targetwrong)" "$1")" $(($DEFAULTWIDTH-4))
        centerTxtFn "$WRAPPEDTXT" $(($DEFAULTWIDTH-4))
        valignTxtFn "$CENTEREDTXT"
        showInfoDlg "$ALIGNEDTXT" $HEIGHT
        return $1;
}

function showZFSerror() {
        wrapTxtFn "$(printf "$(_ xbiancopy.dialog.zfswrong)" "$1")" $(($DEFAULTWIDTH-4))
        centerTxtFn "$WRAPPEDTXT" $(($DEFAULTWIDTH-4))
        valignTxtFn "$CENTEREDTXT"
        showInfoDlg "$ALIGNEDTXT" $HEIGHT
        return $1
}

function showMountBooterror() {
        wrapTxtFn "$(printf "$(_ xbiancopy.dialog.mountbooterror)" "$1")" $(($DEFAULTWIDTH-4))
        centerTxtFn "$WRAPPEDTXT" $(($DEFAULTWIDTH-4))
        valignTxtFn "$CENTEREDTXT"
        showInfoDlg "$ALIGNEDTXT" $HEIGHT
        return $1
}

function showWrongBlockDev() {
        wrapTxtFn "$(_ xbiancopy.dialog.wrongblkdev)" $(($DEFAULTWIDTH-4))
        centerTxtFn "$WRAPPEDTXT" $(($DEFAULTWIDTH-4))
        valignTxtFn "$CENTEREDTXT"
        showInfoDlg "$ALIGNEDTXT" $HEIGHT
        return $?;
}

function showCopyError() {
        wrapTxtFn "$(printf "$(_ xbiancopy.dialog.copyerror)" "$1")" $(($DEFAULTWIDTH-4))
        centerTxtFn "$WRAPPEDTXT" $(($DEFAULTWIDTH-4))
        valignTxtFn "$CENTEREDTXT"
        showMsgDlg "$ALIGNEDTXT" $HEIGHT
        return $1;
}

function showCloneDone() {
        local DW=$DEFAULTWIDTH
        DEFAULTWIDTH=76
        showMsgDlg "$(printf "$(_ xbiancopy.dialog.clonedone)" "$1")" 10
        DEFAULTWIDTH=$DW
}

function showConfigDialog() {
	IFS=" ";
	DATA=($1)
	IFS=$ORIGINALIFS;

	ELEMENTS=();
	ELEMENTS+=("1,3,$(_ xbiancopy.label.source),/dev/root,31,43,200,0");
	ELEMENTS+=("2,3,$(_ xbiancopy.label.dest),/dev/sdX,31,43,200,0");

	showInputFormDlg "$(_ xbiancopy.dialog.config)" 29 82 "$(_ dialog.apply)"
} 
