# Copyright (2011) Degenerated Labs
# Copyright (2011) David Francos Cuartero
#        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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

# This can also be used as skeleton for airoscript override-functions plugin.

export mark="";
export autoset=1
interfaces+=("zenity");
_source $path/plugins/xterm;

warn(){ notify-send -i "$path/../doc/airoscript-ng/airoscript-ng.png" "Airoscript notification" "${@}"; }
yesno(){ zenity --question $@; }
single_question(){ ans=`zenity --entry --text "${@}"`; }
mkmenuheader(){ return; }
mkmenuline(){ return; }
mkmenueline(){ return; }
mkmenu(){ title=$1; shift;res=();n=0;
    for i in "${@}"; do n=$(( n + 1 )); [[ "$n" == 1 ]] && ST="TRUE" || ST="FALSE"; res+=( "$ST" "$n" "$i" ); done
    choice=`zenity  --list  --text "$title" --width=350 --height=400 --radiolist  --column "Pick " --column "hidden" --column "Choose" --hide-column 2 "${res[@]}";`
    [[ $? == 1 ]] && [[ $title == "Main Menu" ]] && exit
}
selectap_wrapper(){ choice=`zenity  --list  --text "$title" --width=300 --height=500 --radiolist  --column "X" --column "hidden" --column "MAC" --column "Channel" --column "Privacy" --column "POWER" --column "LENGHT" --column "ESSID" --hide-column 2 "${res[@]}"`; }

launch_counter(){  ( for i in $( seq 1 $1 ); do a=$(( ($i * 100) / $1 )); sleep 1; echo "$a"; done ) | zenity --text "Scanning for targets" --progress --auto-close --title="Scanning for targets"; }
