home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 September - Disc 1 / PCNET_CD_2006_09.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / sbin / xeznet.tcl < prev    next >
Encoding:
Text File  |  1999-08-29  |  25.6 KB  |  837 lines

  1.  
  2. #!/bin/sh
  3. # \
  4. exec wish "$0" "$@"
  5.  
  6. #       xeznet - Tcl/Tk interface for 'eznet'
  7. #       xeznet,v 1.8 1999/02/19 00:55:48 migh Exp
  8. #
  9.  
  10. option add *borderWidth         1
  11. option add *Label*anchor        w
  12. option add *Label*foreground    DarkBlue
  13.  
  14. bind Entry <FocusIn>    {%W configure -background gray95; show_help %W}
  15. bind Entry <FocusOut>   {%W configure -background gray85}
  16.  
  17. set upd_rate 60                 ;# status update rate (see menu settings)
  18. set nquick 0                    ;# number of quick updates for service up/down
  19.  
  20. set rc_file     ~/.xeznet_rc
  21.  
  22. #
  23. #       Return a list of selected service names
  24. #
  25. proc get_sel { } {
  26.         msg ""
  27.         set svcs {}
  28.         foreach ix [.lbox.list curselection] {
  29.                 set line [.lbox.list get $ix]
  30.                 set svc [string trim \
  31.                                 [string range $line 1 \
  32.                                         [string wordend $line 1]]]
  33.                 if {$svc == ""} {
  34.                         continue
  35.                 }
  36.                 lappend svcs $svc
  37.         }
  38.         if {[llength $svcs] == 0} {
  39.                 msg "Select a service, then click the button."
  40.         }
  41.         return $svcs
  42. }
  43.  
  44. #
  45. #       Make a new action window for each selected service name
  46. #
  47. proc do_sel {action} {
  48.         if {$action == "add"} {
  49.                 msg ""
  50.                 svc_window add new
  51.         } {
  52.                 foreach svc [get_sel] {
  53.                         svc_window $action $svc
  54.                 }
  55.         }
  56.         return
  57. }
  58.  
  59. #
  60. #       Bring the selected service(s) up or down
  61. #       TODO: we sometimes exit when we bring down a service
  62. #
  63. proc do_updn {dir} {
  64.         set svcs [get_sel]
  65.         foreach svc $svcs {
  66.                 msg "Bringing $dir $svc."
  67.                 catch {exec eznet $dir $svc >/dev/null &}
  68.         }
  69.         if {[llength $svcs] > 0} {
  70.                 global nquick
  71.                 set nquick 12
  72.                 svc_status
  73.         }
  74.         return
  75. }
  76.  
  77. #
  78. #       Refresh the current service status
  79. #
  80. proc svc_status {{repeat 0}} {
  81.         set fid 0
  82.         if {[catch {open "|eznet status" r} fid] == 0} {
  83.                 set sel [lindex [.lbox.list curselection] 0]
  84.                 .lbox.list delete 0 end
  85.                 while {[gets $fid line] > 0} {
  86.                         set p [string first ":" $line]
  87.                         set svc  [string range $line 0 [expr {$p - 1}]]
  88.                         set stat [string range $line [expr {$p + 1}] end]
  89.                         .lbox.list insert end [format " %-10s %s" $svc $stat]
  90.                 }
  91.                 catch {close $fid}
  92.                 if {$sel != ""} {
  93.                         .lbox.list selection set $sel
  94.                         .lbox.list activate $sel
  95.                         .lbox.list see $sel
  96.                 }
  97.         } {
  98.                 msg "Unable to get status from 'eznet'."
  99.         }
  100.  
  101.         # do we repeat?  how soon?
  102.         set dt 0
  103.         global nquick
  104.         if {$nquick > 0} {
  105.                 set dt 5000
  106.                 incr nquick -1
  107.         } elseif {$repeat > 0} {
  108.                 global upd_rate
  109.                 set dt [expr {$upd_rate * 1000}]
  110.         }
  111.         if {$dt > 0} {
  112.                 after $dt svc_status 1
  113.         }
  114.         return
  115. }
  116.  
  117. #
  118. #       Handle the "OK" button on the service information window
  119. #
  120. proc do_svc_ok {w action} {
  121.         set svc [$w.service.e get]
  122.         if {$action == "delete"} {
  123.                 msg "Deleted $svc"
  124.                 catch {exec eznet delete $svc >/dev/null}
  125.         } elseif {$action != "show"} {
  126.                 set cmd "eznet $action $svc"
  127.                 set args ""
  128.                 global all_entries
  129.                 foreach x $all_entries {
  130.                         set val [$w.$x.e get]
  131.                         # TODO: How do we clear an entry???
  132.                         if {$val != ""} {
  133.                                 if {$x == "password" && [string index $val 0] == "*"} {
  134.                                         continue
  135.                                 } {
  136.                                         append args " \"$x=$val\""
  137.                                 }
  138.                         }
  139.                 }
  140.                 if {$args != ""} {
  141.                         msg "$cmd ..."
  142.                         catch {eval exec $cmd $args >/dev/null}
  143.                 }
  144.         }
  145.         destroy $w
  146.         update idletasks
  147.         if {$action != "show"} {
  148.                 svc_status
  149.         }
  150.         return
  151. }
  152.  
  153. array set entry_help {
  154.         phone           "Phone number for modem to dial"
  155.         user            "User login name"
  156.         password        "Login password"
  157.         tty             "Serial port for the modem"
  158.         baud            "Baud rate for the serial port"
  159.         service         "Name of the ISP"
  160.         chat            "`no' to ignore `login:' prompts, etc."
  161.         autostart       "`no' to not start pppd if no `login:'"
  162.         pppversion      "Version of pppd in use"
  163.         debug           "`yes' to turn on pppd debugging"
  164.         expectN         "Extra expect string"
  165.         replyN          "Reply to issue after expect string"
  166.         initN           "Extra modem initialization string"
  167.         diald           "Name of diald executable"
  168.         pppd            "Name of pppd executable"
  169.         local           "Local IP address for diald slip link"
  170.         remote          "Remote IP address for diald slip link"
  171.         idle            "Number of seconds for idle timeout"
  172.         persist         "`yes' for a permanent connection"
  173.         defaultroute    "`no' to not create a default route"
  174.         pppoptN         "Extra parameters to pppd"
  175.         routeN          "Add this route when pppd comes up"
  176.         ip              "Network accessed by this service"
  177.         netmask         "Netmask for the ip network"
  178.         dialtimeout     "Time allowed for modem connect"
  179.         chattimeout     "Time allowed for chat dialog"
  180. }
  181.  
  182. proc show_help {w} {
  183.         global entry_help
  184.         set parts [split $w .]
  185.         set pw  [lindex $parts 1]
  186.         set ent [lindex $parts 2]
  187.         if {[winfo exists .$pw.help]} {
  188.                 regsub {[0-9]} $ent N ent
  189.                 if {![info exists entry_help($ent)]} {
  190.                         set entry_help($ent) "(unknown)"
  191.                 }
  192.                 .$pw.help configure -text "$ent - $entry_help($ent)"
  193.         }
  194.         return
  195. }
  196.  
  197. array set win_txt {
  198.         add     "Create Service" 
  199.         show    "Show Service for $svc" 
  200.         edit    "Edit Service for $svc" 
  201.         delete  "Delete Service for $svc ?"
  202. }
  203.  
  204. set win_id 0
  205.  
  206. #
  207. #       Split all the available entries/settings into subsets for display
  208. #
  209. set basic_entries {
  210.         service phone user password tty baud
  211. }
  212.  
  213. set modem_entries {
  214.         chat
  215.         diald dialtimeout chattimeout idle
  216.         init0 init1 init2 init3 init4
  217. }
  218.  
  219. set chat_entries {
  220.         expect0 reply0 
  221.         expect1 reply1 
  222.         expect2 reply2 
  223.         expect3 reply3 
  224.         expect4 reply4 
  225. }
  226.  
  227. set ppp_entries {
  228.         pppd pppversion 
  229.         pppopt0 pppopt1 pppopt2 pppopt3 pppopt4
  230.         autostart debug 
  231. }
  232.  
  233. set ip_entries {
  234.         local remote ip netmask persist
  235. }
  236.  
  237. set route_entries {
  238.         defaultroute
  239.         route0 route1 route2 route3 route4
  240. }
  241.  
  242. set all_entries [concat $basic_entries $modem_entries $chat_entries\
  243.                         $ppp_entries $ip_entries $route_entries]
  244.  
  245. #
  246. #       List of frame names and titles
  247. #       (names should match above entry lists)
  248. #
  249. set frame_list {
  250.         {basic  "Basic Settings"}
  251.         {modem  "Modem Settings"}
  252.         {chat   "Chat Dialog Settings"}
  253.         {ppp    "PPP Settings"}
  254.         {ip     "IP Settings"}
  255.         {route  "Route Settings"}
  256. }
  257.  
  258. #
  259. #       Unpack the current selection frame; pack a new one
  260. #
  261. proc newframe {w opt} {
  262.         # unpack the old frame (find it by name "f_xyz")
  263.         foreach slave [pack slaves $w] {
  264.                 if {[string first "f_" $slave] > 0} {
  265.                         pack forget $slave
  266.                 }
  267.         }
  268.         # new text on menu button
  269.         global frame_defs
  270.         $w.fs configure -text $frame_defs($opt)
  271.  
  272.         # pack the new frame
  273.         pack $w.f_$opt -side top -fill both -expand yes
  274.         
  275.         # select first entry (to update the help-text, if there)
  276.         global ${opt}_entries
  277.         set x [lindex [set ${opt}_entries] 0]
  278.         $w.$x.e select range 0 end
  279.         focus $w.$x.e
  280. }
  281.  
  282. #
  283. #       Make a service-information window
  284. #
  285. proc svc_window {action svc} {
  286.         global win_id win_txt
  287.  
  288.         # make a new window
  289.         set w .w[incr win_id]
  290.         toplevel $w
  291.         wm title $w [subst $win_txt($action)]
  292.         # TODO: wm iconbitmap $w ... ?
  293.  
  294.         # make a menu button to choose among the frames
  295.         menubutton $w.fs -indicatoron 1 -menu $w.fs.menu -anchor w \
  296.                 -text "Basic Settings" -relief raised
  297.         menu $w.fs.menu -tearoff 0
  298.  
  299.         # make some frames to hold subsets of entries
  300.         global frame_list frame_defs
  301.         foreach x $frame_list {
  302.                 foreach {base label} $x { }
  303.  
  304.                 # save name-label association for later
  305.                 # add menu button to the menu
  306.                 set frame_defs($base) $label
  307.                 $w.fs.menu add radiobutton -label $label -indicatoron 0 \
  308.                         -command "newframe $w $base"
  309.  
  310.                 # make the frame and fill it with its labelled entries
  311.                 global ${base}_entries
  312.                 frame $w.f_$base
  313.                 foreach x [set ${base}_entries] {
  314.                         labent $w $x
  315.                         pack $w.$x -in $w.f_$base -side top -fill x
  316.                 }
  317.         }
  318.  
  319.         # make the bottom button row
  320.         buttons $w.b left \
  321.                 [list OK        "do_svc_ok $w $action"] \
  322.                 [list Cancel    "destroy $w"]
  323.  
  324.         # put the frame-selector on top, button-row on bottom, frame inbetween
  325.         pack $w.fs      -side top       -fill x
  326.         pack $w.b       -side bottom    -fill x
  327.         pack $w.f_basic -side top       -fill both -expand yes
  328.  
  329.         # make the 'OK' button look special on the delete-window
  330.         if {$action == "delete"} {
  331.                 $w.b.b1 configure -activeforeground Red -fg Red -text Delete
  332.         }
  333.  
  334.         # for editable windows, add a prompt-line for help messages
  335.         if {$action == "add" || $action == "edit"} {
  336.                 label $w.help -text "" -fg Black -relief sunken -padx 1m \
  337.                         -font Helvetica
  338.                 pack $w.help -side bottom -fill x
  339.         }
  340.  
  341.         if {$action == "add"} {
  342.                 $w.service.e insert 0 service-name
  343.                 $w.service.e select range 0 end
  344.                 focus $w.service.e
  345.         } {
  346.                 update
  347.                 if {[catch {open "|eznet list $svc" r} fid] == 0} {
  348.                         while {[gets $fid buf] > 0} {
  349.                                 set p [string first "=" $buf]
  350.                                 incr p -1
  351.                                 set var [string trim [string range $buf 0 $p]]
  352.                                 incr p 2
  353.                                 set val [string trim [string range $buf $p end]]
  354.                                 if {[winfo exists $w.$var.e]} {
  355.                                         $w.$var.e insert 0 $val
  356.                                 }
  357.                                 # TODO: else report missing values?
  358.                         }
  359.                         catch {close $fid}
  360.                 }
  361.         }
  362.  
  363.         # make the 'show' and 'delete' windows read-only
  364.         if {$action == "show" || $action == "delete"} {
  365.                 global all_entries
  366.                 foreach x $all_entries {
  367.                         $w.$x.e configure -state disabled
  368.                 }
  369.                 if {$action == "show"} {
  370.                         bind $w <Return> [list $w.b.b1 invoke]
  371.                 }
  372.         }
  373.         return
  374. }
  375.  
  376. #
  377. #       Put messages or errors in the message line
  378. #
  379. proc err {msg} {
  380.         .msg configure -text "Error! $msg"
  381.         return
  382. }
  383.  
  384. proc msg {msg} {
  385.         .msg configure -text $msg
  386.         return
  387. }
  388.  
  389. # proc ask_yn {msg} {
  390. #       return [tk_messageBox -title Question -message $msg \
  391. #               -icon question -type yesno]
  392. # }
  393.  
  394. ###
  395. ### Some GUI-creation helper routines...
  396. ###
  397.  
  398. #
  399. #       Make a menubar with menus
  400. #
  401. proc menu_bar {w args} {
  402.         if {[winfo exists $w] == 0} {
  403.                 frame $w -relief raised -borderwidth 2
  404.         }
  405.         set mnum 0              ;# menu counter
  406.         set inum 0              ;# item counter
  407.  
  408.         foreach arg $args {
  409.                 foreach {type name var val v2} $arg { }
  410.                 if {$inum == 0 && [string match "menu*" $type] == 0} {
  411.                         err "menu_bar: need menu to hold $type/$name menu-item"
  412.                         return
  413.                 }
  414.                 switch $type {
  415.                 menu {
  416.                         set mbase $w.m[incr mnum]
  417.                         set new $mbase.menu
  418.                         menubutton $mbase -text $name -menu $new
  419.                         menu $new -disabledforeground DarkBlue
  420.                         set inum 1
  421.                 }
  422.                 sep {
  423.                         $new add sep
  424.                 }
  425.                 label {
  426.                         $new add command -label $name -state disabled
  427.                         incr inum       
  428.                 }
  429.                 cmd {
  430.                         $new add command -label $name -command $var
  431.                         incr inum
  432.                 }
  433.                 radio {
  434.                         global $var
  435.                         $new add radiobutton -label $name \
  436.                                 -variable $var -value $val
  437.                         incr inum
  438.                 }
  439.                 check {
  440.                         global $var
  441.                         $new add checkbutton -label $name \
  442.                                 -variable $var -offvalue $val -onvalue $v2
  443.                         incr inum
  444.                 }
  445.                 end {
  446.                         # pack this menu on the given side
  447.                         pack $mbase -side $name -padx 1m
  448.                         set inum 0
  449.                 }
  450.                 default {
  451.                         err "menu_bar: unknown type '$type' for '$name'"
  452.                         return
  453.                 }
  454.                 }
  455.         }
  456.         return
  457. }
  458.  
  459. #
  460. #       Make a button row from names and commands
  461. #
  462. proc buttons {w dir args} {
  463.         if {[winfo exists $w] == 0} {
  464.                 frame $w
  465.         }
  466.         set i 0
  467.         set btns ""
  468.         foreach arg $args {
  469.                 foreach {name cmd} $arg { }
  470.                 set btn $w.b[incr i]
  471.                 append btns " $btn"
  472.                 button $btn -text $name -command $cmd -width 4
  473.         }
  474.         eval pack $btns -side $dir -fill x -expand yes
  475.         return
  476. }
  477.  
  478. #
  479. #       Make a labeled entry
  480. #
  481. proc labent {w x} {
  482.         if {[winfo exists $w.$x] == 0} {
  483.                 frame $w.$x
  484.         }
  485.         label $w.$x.l -text $x -anchor e -width 10 -padx 3m
  486.         entry $w.$x.e -width 25
  487.         pack  $w.$x.l -side left -fill x
  488.         pack  $w.$x.e -side left -fill x -expand yes
  489.         return
  490. }
  491.  
  492. #
  493. #       Make a listbox/scrollbar pair, connect them
  494. #
  495. proc list_box {w title action} {
  496.         if {[winfo exists $w] == 0} {
  497.                 frame $w
  498.         }
  499.         label $w.hdr -text $title -font fixed -anchor w
  500.         scrollbar $w.sb -command "$w.list yview"
  501.         listbox $w.list -yscroll "$w.sb set" \
  502.                 -font fixed -setgrid 1 -height 5
  503.  
  504.         pack $w.hdr  -side top   -fill x
  505.         pack $w.sb   -side right -fill y
  506.         pack $w.list -side left  -fill both -expand yes
  507.         if {$action != ""} {
  508.                 bind $w.list    <Double-1>      $action
  509.                 bind $w.list    <Return>        $action
  510.         }
  511.         bind $w.list    <Control-p>     {tkListboxUpDown %W -1}
  512.         bind $w.list    <Control-n>     {tkListboxUpDown %W  1}
  513.         bind $w.list    <k>             {tkListboxUpDown %W -1}
  514.         bind $w.list    <j>             {tkListboxUpDown %W  1}
  515.         return
  516. }
  517.  
  518. #
  519. #       Make a text-box/scrollbar pair, connect them
  520. #
  521. proc text_box {w {title ""}} {
  522.         if {[winfo exists $w] == 0} {
  523.                 frame $w
  524.         }
  525.         if {$title != ""} {
  526.                 label $w.hdr -text $title -font fixed
  527.                 pack $w.hdr -side top -fill x
  528.         }
  529.         scrollbar $w.sb -command "$w.text yview"
  530.         text $w.text -yscroll "$w.sb set" -setgrid 1
  531. #               -font fixed 
  532.  
  533.         pack $w.sb -side right -fill y
  534.         pack $w.text -side left -fill both -expand yes
  535.  
  536.         $w.text insert end "Please wait..."
  537.         return
  538. }
  539.  
  540. #
  541. #       Given some text, fill a text-box
  542. #
  543. proc fill_textbox {tb ro txt} {
  544.         set t $tb.text
  545.         $t configure -state normal
  546.         $t delete 1.0 end
  547.         $t mark set insert 0.0
  548.         $t insert end $txt
  549.  
  550.         if {$ro == "ro"} {
  551.                 $t configure -state disabled
  552.                 $t mark set curs 0.0
  553.         } {
  554.                 $t mark set insert 0.0
  555.         }
  556.         return
  557. }
  558.  
  559. #
  560. #       Make a simple text window
  561. #
  562. proc simple_text {w title} {
  563.         if {[winfo exists $w] == 0} {
  564.                 toplevel $w
  565.                 # TODO: wm iconbitmap .   ...
  566.                 if {$title != ""} {
  567.                         wm title $w $title
  568.                 }
  569.                 text_box $w.tbox
  570.                 buttons $w.b left [list Done "destroy $w"]
  571.                 pack $w.tbox -side top -fill both -expand yes
  572.                 pack $w.b -side bottom -fill x
  573.                 bind $w <Return> "destroy $w"
  574.                 focus $w.tbox.text
  575.         } {
  576.                 wm deiconify $w
  577.         }
  578.         return
  579. }
  580.  
  581. ###
  582. ### End of GUI helpers
  583. ###
  584.  
  585. #
  586. #       Save our current settings
  587. #
  588. proc save_settings { } {
  589.         global rc_file
  590.         if {[catch {open $rc_file w} fid] == 0} {
  591.                 puts $fid "wm geometry . [wm geometry .]"
  592.                 set sel [lindex [.lbox.list curselection] 0]
  593.                 if {$sel != ""} {
  594.                         puts $fid "set lbsel $sel"
  595.                 } {
  596.                         puts $fid "set lbsel -1"
  597.                 }
  598.                 catch {close $fid}
  599.         }
  600. }
  601.  
  602. #
  603. #       Are we 'root'?
  604. #
  605. proc as_root { } {
  606.         global env
  607.         set rt 0
  608.         if {[info exists env(TESTING_XEZNET)]} {
  609.                 set rt 1
  610.         } elseif {[catch {open "|id" r} fid] == 0} {
  611.                 set id [read $fid]
  612.                 catch {close $fid}
  613.                 if {[string first "(root)" $id] > 0} {
  614.                         set rt 1
  615.                 }
  616.         }
  617.         return $rt
  618. }
  619.  
  620. #
  621. #       Make a new window, fill it with 'eznet log'
  622. #
  623. proc see_log { } {
  624.         simple_text .w_log "Log file from eznet"
  625.         update
  626.         if {[catch {open "|eznet log" r} fid] == 0} {
  627.                 set txt [read $fid]
  628.                 catch {close $fid}
  629.         } {
  630.                 set txt "Problems running 'eznet log'!"
  631.         }
  632.         fill_textbox .w_log.tbox ro $txt
  633.         return
  634. }
  635.  
  636. set eznet_icon {
  637. #define eznet_width 32
  638. #define eznet_height 32
  639. static unsigned char eznet_bits[] = {
  640.    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  641.    0x00, 0x00, 0x00, 0x00, 0xf8, 0x3f, 0xfe, 0x1f, 0xf8, 0x3f, 0xfe, 0x1f,
  642.    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  643.    0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x1c,
  644.    0x18, 0x00, 0x00, 0x0e, 0x18, 0x00, 0x00, 0x07, 0x18, 0x00, 0x80, 0x03,
  645.    0x18, 0x1f, 0xc0, 0x01, 0x18, 0x1f, 0xe0, 0x00, 0x18, 0x00, 0x70, 0x00,
  646.    0x18, 0x00, 0x38, 0x00, 0x18, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x0e, 0x00,
  647.    0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
  648.    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x3f, 0xfe, 0x3f,
  649.    0xf8, 0x3f, 0xfe, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  650.    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  651. }
  652.  
  653. #
  654. #       Work-around a Tcl/Tk "feature":
  655. #       - bitmaps work OK on buttons, but are not accepted by the 'wm' command
  656. #
  657. proc wm_set_icon {w icon} {
  658.         set iconFile /tmp/.eznet_icon.[pid]
  659.         if {[catch {open $iconFile w} fid] == 0} {
  660.                 puts $fid $icon
  661.                 close $fid
  662.                 wm iconbitmap $w @$iconFile
  663.                 catch {file delete $iconFile}
  664.         }
  665.         return
  666. }
  667.  
  668. #
  669. #       Make the main control and status panel
  670. #
  671. proc make_ui { } {
  672.         global upd_rate eznet_icon
  673.         wm title        . "EZNET Interface"
  674.         wm iconname     . "xeznet"
  675.         wm command      . "xeznet"
  676.         wm_set_icon     . $eznet_icon
  677.  
  678.         menu_bar .mbar                                          \
  679.                 {menu   File}                                   \
  680.                 {cmd    "See log..."    see_log}                \
  681.                 {cmd    Save            save_settings}          \
  682.                 {sep}                                           \
  683.                 {cmd    Quit            exit}                   \
  684.                 {end    left}                                   \
  685.                 \
  686.                 {menu   Update}                                 \
  687.                 {cmd    Now             svc_status}             \
  688.                 {radio  "10 sec"        upd_rate        10}     \
  689.                 {radio  "30 sec"        upd_rate        30}     \
  690.                 {radio  " 1 min"        upd_rate        60}     \
  691.                 {radio  " 5 min"        upd_rate        300}    \
  692.                 {end    left}                                   \
  693.                 \
  694.                 {menu   Help}                                   \
  695.                 {cmd    About           do_about}               \
  696.                 {cmd    Usage           do_use}                 \
  697.                 {end    right}
  698.  
  699.         list_box .lbox " Service     Status" {do_sel show}
  700.         bind . <Any-Enter> {focus .lbox.list}
  701.  
  702.         buttons .cmd left                       \
  703.                 {Show   {do_sel show}}          \
  704.                 {Edit   {do_sel edit}}          \
  705.                 {Add    {do_sel add}}           \
  706.                 {Delete {do_sel delete}}        \
  707.                 {Up     {do_updn up}}           \
  708.                 {Down   {do_updn down}}         \
  709.                 {Quit   exit}
  710.  
  711.         # if not root, pull off Edit/Add/Delete buttons
  712.         if {[as_root] == 0} {
  713.                 destroy .cmd.b2
  714.                 destroy .cmd.b3
  715.                 destroy .cmd.b4
  716.         }
  717.  
  718.         label .msg -text ""
  719.  
  720.         pack .mbar      -side top       -fill x 
  721.         pack .lbox      -side top       -fill both      -expand yes
  722.         pack .cmd .msg  -side bottom    -fill x 
  723.         return
  724. }
  725.  
  726. proc do_about { } {
  727.         simple_text .w_about "About xeznet"
  728.         .w_about.tbox.text configure -height 9
  729.         fill_textbox .w_about.tbox ro {
  730. xeznet is a graphical front-end for the 'eznet' command.
  731. This is version 1.8 made on 1999/02/19 00:55:48.
  732.  
  733. Mike Hall <mghall@enteract.com> is the author of 'xeznet'.
  734.  
  735. D. Richard Hipp" <drh@acm.org> is the author of 'eznet',
  736. and provided essential suggestions to improve 'xeznet'.
  737. }
  738.         return
  739. }
  740.  
  741. proc do_use { } {
  742.         simple_text .w_usage "How to use 'xeznet'"
  743.         fill_textbox .w_usage.tbox ro {
  744. OPERATION:
  745. ----------
  746.  
  747. NOTE: The Edit, Add, and Delete buttons will appear only for the 'root' user!
  748.  
  749. To create a new service, you must be 'root': 
  750.         Click on the Add button.
  751.         A new window will appear; fill in the forms.
  752.         Click on the OK button to have 'eznet' create the new service.
  753.  
  754. To edit or delete an existing service, you must be 'root':
  755.         Select an entry, then click on the Edit (or Delete) button.
  756.         A new window will appear, showing you the service.
  757.         Click on the OK button to post your edits to 'eznet'
  758.         (or click on the Delete button to delete the service).
  759.  
  760. To show the settings for a service:
  761.         Method 1: select an entry, then click on the Show button.
  762.         Method 2: select an entry, then press the Return key
  763.         Method 3: double-click on an entry
  764.  
  765.         A new window will appear, showing you the service parameters.
  766.         Click on the OK button to close the window.
  767.  
  768. To bring a service up or down:
  769.         Select the service, then click on the Up or Down button.
  770.         The listbox will track the progress of the connection.
  771.  
  772.  
  773. SERVICE INFORMATION WINDOW:
  774. -------------------------------
  775. There are several sections in the service popup window:
  776.         - Selection menu, to select groups of settings
  777.         - List of entries, to examine or change 'eznet' settings
  778.         - Optional setting description, to explain the meaning of a setting
  779.         - OK and Cancel buttons, to accept the settings or cancel
  780.  
  781. One of several groups of entries can be selected from the menu:
  782.         Basic Settings
  783.         Modem Settings
  784.         Chat Dialog Settings
  785.         PPP Settings
  786.         IP Settings
  787.         Route Settings
  788.  
  789.  
  790. MENUS:
  791. ------
  792. File / 
  793.         See log ...     Show the 'eznet' log file.
  794.         Save            Save the current position, size, and service.
  795.         Quit            Exit the 'xeznet' program.
  796.  
  797. Update /
  798.         Now             Update the status panel immediately.
  799.         10 sec          Update the status panel every 10 seconds.
  800.         30 sec          ..    ..    30 seconds
  801.          1 min          ..    ..    minute
  802.          5 min          ..    ..    5 minutes
  803.  
  804.         Note: when bringing a service up or down,
  805.         the status is automatically updated every 5 seconds for one minute.
  806.  
  807. Help /
  808.         About           Pops up a small version panel.
  809.         Usage           Brings up this text panel.
  810.         return
  811. }
  812.  
  813. #
  814. #       Make the interface, start status updates
  815. #
  816. make_ui
  817.  
  818. # no entries to highlight; read in the RC file for position/settings
  819. set lbsel -1
  820. if {[file exists $rc_file]} {
  821.         source $rc_file
  822. }
  823.  
  824. # draw the interface
  825. update
  826.  
  827. # start the updates (fill the listbox)
  828. svc_status 1
  829.  
  830. # highlight an entry if one was saved last time
  831. if {$lbsel >= 0} {
  832.         .lbox.list selection set $lbsel
  833.         .lbox.list activate $lbsel
  834. }
  835.