#! /bin/sh
# the next line restarts using wish \
exec wish "$0" "$@"
# interface generated by SpecTcl version 1.1 from /root/vftpd/vftpd-0.1a/gui/vftpd_ipaccess.ui
#   root     is the parent window for this user interface

proc vftpd_ipaccess_ui {root args} {

	# this treats "." as a special case

	if {$root == "."} {
	    set base ""
	} else {
	    set base $root
	}
    
	label $base.label#1 \
		-text Ban

	radiobutton $base.radiobutton#1 \
		-command {set class_radiobutton 0} \
		-text host \
		-variable host_radiobutton

	radiobutton $base.radiobutton#2 \
		-command {set host_radiobutton 0} \
		-text {class C} \
		-variable class_radiobutton

	label $base.label#4 \
		-text after

	entry $base.entry#1 \
		-cursor {} \
		-textvariable hamCount \
		-width 3

	label $base.label#2 \
		-text {connection attemps}

	label $base.label#5 \
		-text {in less than}

	entry $base.entry#2 \
		-cursor {} \
		-textvariable hamTime \
		-width 3

	label $base.label#3 \
		-text seconds

	checkbutton $base.checkbutton#2 \
		-text {Add to hosts.deny} \
		-variable hostsdeny

	label $base.label#6 \
		-text Host:

	entry $base.entry#3 \
		-cursor {} \
		-textvariable host \
		-width 23

	button $base.button#1 \
		-command {vftpd_ipaccess_allow $host} \
		-text Allow \
		-width 6

	listbox $base.listbox#1 \
		-height 0 \
		-yscrollcommand "$base.scrollbar#1 set"

	scrollbar $base.scrollbar#1 \
		-command "$base.listbox#1 yview" \
		-orient v

	button $base.button#7 \
		-command {vftpd_ipaccess_deny $host} \
		-state active \
		-text Deny \
		-width 6

	button $base.button#2 \
		-command vftpd_ipaccess_remove \
		-text Remove \
		-width 6

	button $base.button#6 \
		-command {exit 0} \
		-text Cancel \
		-width 6

	button $base.button#5 \
		-text OK \
		-width 6


	# Geometry management

	grid $base.label#1 -in $root	-row 2 -column 3 
	grid $base.radiobutton#1 -in $root	-row 2 -column 4  \
		-columnspan 2 \
		-sticky w
	grid $base.radiobutton#2 -in $root	-row 3 -column 4  \
		-columnspan 2 \
		-sticky w
	grid $base.label#4 -in $root	-row 4 -column 3 
	grid $base.entry#1 -in $root	-row 4 -column 4 
	grid $base.label#2 -in $root	-row 4 -column 5  \
		-columnspan 3 \
		-sticky w
	grid $base.label#5 -in $root	-row 5 -column 2  \
		-columnspan 2 \
		-sticky e
	grid $base.entry#2 -in $root	-row 5 -column 4 
	grid $base.label#3 -in $root	-row 5 -column 5  \
		-columnspan 3 \
		-sticky w
	grid $base.checkbutton#2 -in $root	-row 6 -column 4  \
		-columnspan 4 \
		-sticky w
	grid $base.label#6 -in $root	-row 8 -column 2  \
		-sticky e
	grid $base.entry#3 -in $root	-row 8 -column 3  \
		-columnspan 5 \
		-sticky w
	grid $base.button#1 -in $root	-row 8 -column 8 
	grid $base.listbox#1 -in $root	-row 9 -column 3  \
		-columnspan 4 \
		-rowspan 6 \
		-sticky nesw
	grid $base.scrollbar#1 -in $root	-row 9 -column 7  \
		-rowspan 6 \
		-sticky nsw
	grid $base.button#7 -in $root	-row 9 -column 8 
	grid $base.button#2 -in $root	-row 11 -column 8 
	grid $base.button#6 -in $root	-row 13 -column 8 
	grid $base.button#5 -in $root	-row 14 -column 8 

	# Resize behavior management

	grid rowconfigure $root 1 -weight 0 -minsize 13
	grid rowconfigure $root 2 -weight 0 -minsize 2
	grid rowconfigure $root 3 -weight 0 -minsize 2
	grid rowconfigure $root 4 -weight 0 -minsize 30
	grid rowconfigure $root 5 -weight 0 -minsize 30
	grid rowconfigure $root 6 -weight 0 -minsize 30
	grid rowconfigure $root 7 -weight 0 -minsize 9
	grid rowconfigure $root 8 -weight 0 -minsize 30
	grid rowconfigure $root 9 -weight 0 -minsize 25
	grid rowconfigure $root 10 -weight 0 -minsize 10
	grid rowconfigure $root 11 -weight 0 -minsize 30
	grid rowconfigure $root 12 -weight 0 -minsize 67
	grid rowconfigure $root 13 -weight 0 -minsize 30
	grid rowconfigure $root 14 -weight 0 -minsize 30
	grid rowconfigure $root 15 -weight 1 -minsize 13
	grid columnconfigure $root 1 -weight 0 -minsize 13
	grid columnconfigure $root 2 -weight 0 -minsize 30
	grid columnconfigure $root 3 -weight 0 -minsize 5
	grid columnconfigure $root 4 -weight 0 -minsize 2
	grid columnconfigure $root 5 -weight 0 -minsize 2
	grid columnconfigure $root 6 -weight 0 -minsize 30
	grid columnconfigure $root 7 -weight 0 -minsize 30
	grid columnconfigure $root 8 -weight 0 -minsize 30
	grid columnconfigure $root 9 -weight 0 -minsize 13
# additional interface code
source /usr/local/sbin/vftpd_ipaccess
vftpd_ipaccess_init

global ban host_radiobutton class_radiobutton hamCount hamTime hostsdeny host

set ban host
set hamCount ""
set hamTime ""
set hostdeny 0
set host ""

if {[file exists /etc/vftpd.autoban]} then {
	source /etc/vftpd.autoban
}

if {$ban=="host"} then {
	$base.radiobutton#1 invoke

} else {
	$base.radiobutton#2 invoke 
}

global gbase
set gbase $base

$base.button#5 configure -command {vftpd_ipaccess_ok $gbase $class_radiobutton $host_radiobutton $hamCount $hamTime $hostsdeny}








# end additional interface code

}


# Allow interface to be run "stand-alone" for testing

catch {
    if [info exists embed_args] {
	# we are running in the plugin
	vftpd_ipaccess_ui .
    } else {
	# we are running in stand-alone mode
	if {$argv0 == [info script]} {
	    wm title . "vftpdaccess"
	    vftpd_ipaccess_ui .
	}
    }
}
