set extract(meta2) {.}
#set extract(meta) {.}
+proc ttk_toplevel {w args} {
+ variable useTile
+ eval [linsert $args 0 ::toplevel $w]
+ if {[info exists useTile] && $useTile} {
+ place [ttk::frame $w._toplevel_background] -x 0 -y 0 -relwidth 1 -relheight 1
+ }
+ return $w
+}
+
##+##########################################################################
#
# createMain -- Creates the display
return
}
- toplevel $top
+ ttk_toplevel $top
wm withdraw $top
wm title $top "SockSpy Extract"
wm transient $top .
# It uses the playback stream as its data source.
#
proc saveOutput {} {
- global state but
+ global state
+ variable NS
+ set dlg [ttk_toplevel .what -class Dialog]
+ variable $dlg ""
+ variable but both
+ wm withdraw $dlg
+ wm title $dlg "SockSpy Save"
+ wm transient $dlg .
+
+ set f [${NS}::labelframe $dlg.f -text "Select window"]
+ foreach name {server client both} {
+ set b [${NS}::radiobutton $f.$name -text $name \
+ -variable ::but -value $name]
+ grid $b -sticky ew
+ }
+ grid columnconfigure $f 0 -weight 1
+
+ ${NS}::button $dlg.ok -text OK -default active \
+ -command [list set [namespace which -variable $dlg] ok]
+ ${NS}::button $dlg.cancel -text Cancel \
+ -command [list set [namespace which -variable $dlg] cancel]
- set but -1
- set but [tk_dialog .what "SockSpy Save" "Save which window?" \
- questhead 2 server client both cancel]
+ grid $f - -sticky news -padx 2 -pady 2
+ grid $dlg.ok $dlg.cancel -sticky se
+ grid columnconfigure $dlg 0 -weight 1
+ grid rowconfigure $dlg 0 -weight 1
- if {$but == -1 || $but == 3} {
- return
+ tk::PlaceWindow $dlg widget .
+ wm deiconify $dlg
+ tkwait variable [namespace which -variable $dlg]
+ if {[set $dlg] eq "ok"} {
+ set state(msg) "Saving ..."
+ busy hold $dlg
+ update idletasks
+ performSaveOutput $dlg $but
+ busy forget $dlg
+ set state(msg) "Save completed."
}
- set file [tk_getSaveFile -parent . -initialfile $state(fname)]
+ destroy $dlg
+ unset $dlg
+}
+proc busy {state w} {
+ if {[info commands tk::busy] ne {}} {
+ tk::busy $state .
+ } else {
+ set c [expr {$state eq "hold" ? "watch" : ""}]
+ . configure -cursor $c
+ $w configure -cursor $c
+ }
+}
+proc performSaveOutput {dlg which} {
+ global state
+ set file [tk_getSaveFile -parent $dlg -initialfile $state(fname)]
if {$file == ""} return
set state(fname) $file
if {[catch {open $file w} fd]} {
- tk_messageBox -message "file $file cannot be opened" -icon error \
- -type ok
+ tk_messageBox -icon error -type ok -title "SockSpy error" \
+ -message "Cannot open file '$file'"
return
}
fconfigure $fd -translation binary
foreach {who data time} $state(playback) {
if {$who == "meta" || $who == "meta2"} continue
- if {$but == 2 || ($but == 0 && $who == "server") || \
- ($but == 1 && $who == "client")} {
+ if {$which eq "both" || $which == $who} {
if {$state(time)} {
puts $fd [timestamp $time]
}
}
}
close $fd
- bell
}
+
##+##########################################################################
#
# printable -- Replaces all unprintable characters into dots.
#
proc timestampWindow {} {
global state
+ variable NS
set state(oldTimeFormat) $state(timeFormat)
set w .tf2
destroy .tf
- toplevel .tf
+ ttk_toplevel .tf
wm title .tf "SockSpy Time Format"
+ wm transient .tf .
+ wm withdraw .tf
- set txt "Edit the format used for timestamps. "
- append txt "See Tcl's clock command documentation for a complete "
- append txt "description of acceptable formats."
+ set txt "Edit the format used for timestamps. See the Tcl clock command\n"
+ append txt "documentation for a complete description of acceptable formats."
- frame .tf.top -bd 2 -relief raised -padx 5
+ ${NS}::labelframe .tf.top ;#-bd 2 -relief raised -padx 5
- message .tf.t -aspect 500 -text $txt
- label .tf.l -text "Format: "
- entry .tf.e -textvariable state(timeFormat)
- button .tf.default -text Default -width 10 -command {tfButton default}
- button .tf.ok -text OK -width 10 -command {tfButton ok}
- button .tf.cancel -text Cancel -width 10 -command {tfButton cancel}
+ #message .tf.t -aspect 500 -text $txt
+ ${NS}::label .tf.t -text $txt
+ ${NS}::label .tf.l -text "Format: "
+ ${NS}::entry .tf.e -textvariable state(timeFormat)
+ ${NS}::button .tf.ok -text OK -default active -command {tfButton ok}
+ ${NS}::button .tf.default -text Default -underline 0 \
+ -command {tfButton default}
+ ${NS}::button .tf.cancel -text Cancel -command {tfButton cancel}
grid .tf.top -row 0 -column 0 -columnspan 4 -sticky ew -padx 10 -pady 10
grid columnconfigure .tf 0 -weight 1
- grid x .tf.default .tf.ok .tf.cancel -padx 5 -sticky ew
+ grid x .tf.ok .tf.default .tf.cancel -padx 5 -sticky ew
grid rowconfigure .tf 2 -minsize 8
grid .tf.t - -in .tf.top -row 0
grid columnconfigure .tf.top 1 -weight 1
grid columnconfigure .tf.top 2 -minsize 10
+ bind .tf <Escape> [list .tf.cancel invoke]
+ bind .tf <Return> [list .tf.ok invoke]
+ bind .tf <Alt-Key-d> [list .tf.default invoke]
+
focus .tf.e
.tf.e icursor end
.tf.e select range 0 end
+ tk::PlaceWindow .tf widget .
+ wm deiconify .tf
}
##+##########################################################################
#
}
destroy .dlg
- toplevel .dlg
+ ttk_toplevel .dlg
wm withdraw .dlg
wm title .dlg "SockSpy Setup"
wm transient .dlg .
- wm geom .dlg +176+176
+ #wm geom .dlg +176+176
+ tk::PlaceWindow .dlg widget .
${NS}::label .dlg.top
set msg "You can configure SockSpy to either forward data\n"
${NS}::entry .dlg.clvar -textvariable SP(cmdLine)
# -state readonly doesn't seem to work, sigh
- ${NS}::button .dlg.ok -text OK -width 10 -command ValidForm
- ${NS}::button .dlg.cancel -text Cancel -width 10 -command [list destroy .dlg]
+ ${NS}::button .dlg.ok -text OK -default active -command ValidForm
+ ${NS}::button .dlg.cancel -text Cancel -command [list destroy .dlg]
grid .dlg.top -row 0 -column 0 -columnspan 3 -sticky ew -padx 2 -pady 2
grid columnconfigure .dlg 0 -weight 1
grid rowconfigure .dlg.fforward 4 -minsize 10
raise .dlg
- bind .dlg.forward <Return> [bind all <Key-Tab>]
- bind .dlg.proxy <Return> [bind all <Key-Tab>]
- bind .dlg.fe1 <Return> [bind all <Key-Tab>]
- bind .dlg.fe2 <Return> [bind all <Key-Tab>]
- bind .dlg.fe3 <Return> [list .dlg.ok invoke]
- bind .dlg.pe1 <Return> [list .dlg.ok invoke]
-
+ bind .dlg <Return> [list .dlg.ok invoke]
+ bind .dlg <Escape> [list .dlg.cancel invoke]
+
GetSetup2
.dlg.pe1 icursor end
.dlg.fe2 icursor end
variable NS
set dlg .help
destroy $dlg
- toplevel $dlg -class Dialog
+ ttk_toplevel $dlg -class Dialog
wm withdraw $dlg
wm title $dlg "SockSpy Help"
wm transient $dlg .
- wm geom $dlg "+[expr {[winfo x .] + 50}]+[expr {[winfo y .] + 50}]"
+ tk::PlaceWindow $dlg widget .
set txt [text $dlg.t -relief raised -wrap word -width 70 -height 25 \
-padx 10 -pady 10 -cursor {} -yscrollcommand [list $dlg.sb set]]
# About -- simple about box
#
proc About {} {
- set m "SockSpy version $::state(version)\n"
+ set m "SockSpy version $::state(version)\n"
append m "by Tom Poindexter and Keith Vetter\n"
append m "Copyright 1998-[clock format [clock seconds] -format %Y]\n\n"
append m "A program to eavesdrop on a tcp client server conversation."