1#!/bin/sh
2#  -*- tcl -*-
3# Executing wish #\
4exec wish "$0" "$@"
5
6
7
8#############################################################################
9# Visual Tcl v1.22 Project
10#
11
12#################################
13# GLOBAL VARIABLES
14#
15global widget;
16
17#################################
18# USER DEFINED PROCEDURES
19#
20
21proc {main} {argc argv} {
22    global mode
23    set mode [lindex $argv 0]
24
25    if [catch {exec which gpg} err] {
26	.top34.fra36.ent41 insert 0 "No GnuPG for encryption found!"
27	.top34.fra36.ent41 config -show "" -state disabled
28	.top34.fra37.but39 config -command exit
29    }
30}
31
32proc direader {dir ts} {
33    global env
34
35    set return ""
36    set tarfile [open "$env(HOME)/.secpanel/.tarfiles" w]
37    foreach f  [lsort [glob -nocomplain $dir/* $dir/.*]] {
38	if {[regexp "\/\\.\\.$" $f] || [regexp "\/\\.$" $f]} {
39	    continue
40	}
41	puts $tarfile $f
42    }
43    close $tarfile
44
45    return $return
46}
47
48proc {returnpw} {} {
49    global widget env mode
50    set ts [clock clicks]
51    exec echo [.top34.fra36.ent41 get] > $env(HOME)/.secpanel/.pw_$ts
52
53    if {$mode == "de"} {
54	catch {exec gpg -q --no-verbose --passphrase-file $env(HOME)/.secpanel/.pw_$ts -d $env(HOME)/.secpanel/spdata.lck | tar tzfv -} err
55	exec echo $err > $env(HOME)/.secpanel/err
56    } elseif {$mode == "en"} {
57	direader "$env(HOME)/.secpanel" $ts
58	catch {exec tar -c -z -f - -T $env(HOME)/.secpanel/.tarfiles | gpg -q --no-verbose -c --passphrase-file pf > $env(HOME)/.secpanel/spdata.lck} err
59	exec echo $err > $env(HOME)/.secpanel/err
60    } else {
61	direader "$env(HOME)/.secpanel" $ts
62	puts "no valid operation mode..."
63	exit
64    }
65
66    file delete -force "$env(HOME)/.secpanel/.pw_$ts"
67    exit
68}
69
70proc {Window} {args} {
71global vTcl
72    set cmd [lindex $args 0]
73    set name [lindex $args 1]
74    set newname [lindex $args 2]
75    set rest [lrange $args 3 end]
76    if {$name == "" || $cmd == ""} {return}
77    if {$newname == ""} {
78        set newname $name
79    }
80    set exists [winfo exists $newname]
81    switch $cmd {
82        show {
83            if {$exists == "1" && $name != "."} {wm deiconify $name; return}
84            if {[info procs vTclWindow(pre)$name] != ""} {
85                eval "vTclWindow(pre)$name $newname $rest"
86            }
87            if {[info procs vTclWindow$name] != ""} {
88                eval "vTclWindow$name $newname $rest"
89            }
90            if {[info procs vTclWindow(post)$name] != ""} {
91                eval "vTclWindow(post)$name $newname $rest"
92            }
93        }
94        hide    { if $exists {wm withdraw $newname; return} }
95        iconify { if $exists {wm iconify $newname; return} }
96        destroy { if $exists {destroy $newname; return} }
97    }
98}
99
100proc init {argc argv} {
101
102}
103
104init $argc $argv
105
106#################################
107# VTCL GENERATED GUI PROCEDURES
108#
109
110proc vTclWindow. {base {container 0}} {
111    if {$base == ""} {
112        set base .
113    }
114    ###################
115    # CREATING WIDGETS
116    ###################
117    if {!$container} {
118    wm focusmodel $base passive
119    wm geometry $base 200x200+0+0
120    wm maxsize $base 1284 1002
121    wm minsize $base 115 1
122    wm overrideredirect $base 0
123    wm resizable $base 1 1
124    wm withdraw $base
125    wm title $base "vt"
126    }
127    ###################
128    # SETTING GEOMETRY
129    ###################
130}
131
132proc vTclWindow.top34 {base {container 0}} {
133    if {$base == ""} {
134        set base .top34
135    }
136    if {[winfo exists $base] && (!$container)} {
137        wm deiconify $base; return
138    }
139    ###################
140    # CREATING WIDGETS
141    ###################
142    if {!$container} {
143    toplevel $base -class Toplevel \
144        -borderwidth "4"
145    wm focusmodel $base passive
146    wm geometry $base 204x92+344+247
147    wm maxsize $base 1284 1002
148    wm minsize $base 115 1
149    wm overrideredirect $base 0
150    wm resizable $base 1 1
151    wm deiconify $base
152    wm title $base "SecPanel - Data Protection"
153    }
154    frame $base.fra35 \
155        -relief "groove" -height "75" -width "125"
156    label $base.fra35.lab40 \
157        -anchor "nw" -borderwidth "0" -relief "raised" \
158        -text "Enter password:"
159    frame $base.fra36 \
160        -relief "groove" -height "75" -width "125"
161    entry $base.fra36.ent41 -show "*\#*"
162    bind $base.fra36.ent41 <Key-Return> {
163        returnpw
164    }
165
166    frame $base.fra37 \
167        -borderwidth "2" -relief "groove" -height "75" -width "125"
168    button $base.fra37.but38 \
169        -relief "groove" -text "Cancel" -command exit
170    button $base.fra37.but39 \
171        -command "returnpw" -relief "groove" -text "Continue"
172    ###################
173    # SETTING GEOMETRY
174    ###################
175    grid columnconf $base 0 -weight 1
176    grid rowconf $base 0 -weight 1
177    grid $base.fra35 \
178        -in $base -column "0" -row "0" -columnspan "1" -rowspan "1" -padx "2" \
179        -pady "2" -sticky "nesw"
180    grid columnconf $base.fra35 0 -weight 1
181    grid rowconf $base.fra35 0 -weight 1
182    grid $base.fra35.lab40 \
183        -in $base.fra35 -column "0" -row "0" -columnspan "1" -rowspan "1" \
184        -sticky "nesw"
185    grid $base.fra36 \
186        -in $base -column "0" -row "1" -columnspan "1" -rowspan "1" -padx "2" \
187        -pady "2" -sticky "ew"
188    grid columnconf $base.fra36 0 -weight 1
189    grid $base.fra36.ent41 \
190        -in $base.fra36 -column "0" -row "0" -columnspan "1" -rowspan "1" \
191        -sticky "ew"
192    grid $base.fra37 \
193        -in $base -column "0" -row "2" -columnspan "1" -rowspan "1" -padx "2" \
194        -pady "2" -sticky "ew"
195    grid $base.fra37.but38 \
196        -in $base.fra37 -column "0" -row "0" -columnspan "1" -rowspan "1"
197    grid $base.fra37.but39 \
198        -in $base.fra37 -column "1" -row "0" -columnspan "1" -rowspan "1"
199}
200
201Window show .
202Window show .top34
203
204tkwait visibility .top34
205focus .top34.fra36.ent41
206grab .top34
207
208main $argc $argv
209