📄 tkpppoe.in
字号:
220.042 108.255 219.142 108.255 218.58 108.255 \ 218.13 107.805 217.681 106.793 218.58 104.994 \ 220.941 104.432 221.953 102.633 224.202 102.183 \ 224.764 101.621 225.214 99.822 228.474 97.461 \ 233.197 97.461 234.096 97.461 234.995 97.911 235.445 \ 98.361 236.007 99.822 236.457 102.633 236.457 \ 104.432 235.445 105.894 234.995 106.343 234.546 \ 106.793 234.546 107.805 233.646 110.616 230.835 \ 111.515 229.824 111.515 229.374 111.515 228.924 \ -fill $bg -outline {} -width 1 -tags logo $c create polygon 161.211 269.175 160.986 \ 267.826 160.649 266.927 160.199 266.477 159.3 \ 266.364 158.4 266.477 157.838 266.927 157.613 \ 267.826 157.388 269.175 157.388 278.17 157.613 \ 279.294 157.838 279.969 159.3 280.981 160.199 \ 280.643 160.649 279.969 160.986 279.294 161.211 \ 278.17 161.211 269.175 -fill $bg -outline {} -width \ 1 -tags logo $c create polygon 224.848 273.448 223.836 \ 273.448 222.825 273.56 222.15 273.673 221.588 \ 273.897 220.913 274.684 220.688 275.809 220.688 \ 278.17 220.801 279.294 221.138 279.969 221.7 280.643 \ 222.487 280.981 223.612 280.643 224.399 279.969 \ 224.736 279.294 224.848 278.17 224.848 273.448 -fill \ $bg -outline {} -width 1 -tags logo $c create polygon 253.969 269.175 253.744 \ 267.826 253.406 266.927 252.732 266.477 251.607 \ 266.364 250.708 266.477 250.146 266.927 249.696 \ 269.175 249.696 272.548 253.969 272.548 253.969 \ 269.175 -fill $bg -outline {} -width 1 -tags logo}#***********************************************************************# %PROCEDURE: LoadConnectionInfo# %ARGUMENTS:# None# %RETURNS:# Nothing# %DESCRIPTION:# Loads the connection information into the global ConnectionInfo variable#***********************************************************************proc LoadConnectionInfo {} { global ConnectionInfoFile ConnectionInfo PasswordFile set ConnectionInfo {} if {![file exists $ConnectionInfoFile]} { return } set problem [catch { set fp [open $ConnectionInfoFile "r"] while {1} { if {[gets $fp line] < 0} { break } set line [string trim $line] if {[string match "#*" $line]} { continue } if {"$line" == ""} { continue } set ConnectionInfo $line break } close $fp } err] if {$problem} { tk_dialog .err Error "[m {Error loading configuration file:}] $err" error 0 OK } # Try loading and merging passwords if the password file is readable set passwords {} if {![file readable $PasswordFile]} { return } set fp [open $PasswordFile "r"] while {1} { if {[gets $fp line] < 0} { break } set line [string trim $line] if {[string match "#*" $line]} { continue } if {"$line" == ""} { continue } set passwords $line break } close $fp # Merge passwords foreach thing $passwords { set name [value $thing ConnectionName] set password [value $thing Password] set conn [GetConnection $name] if {"$conn" != ""} { lappend conn Password $password ReplaceConnection $conn } }}#***********************************************************************# %PROCEDURE: GetConnection# %ARGUMENTS:# name -- name of connection# %RETURNS:# key/value pair listing connection configuration, or "" if not found.#***********************************************************************proc GetConnection { name } { global ConnectionInfo foreach thing $ConnectionInfo { if {[value $thing ConnectionName] == "$name"} { return $thing } } return ""}#***********************************************************************# %PROCEDURE: DeleteConnection# %ARGUMENTS:# name -- name of connection# %RETURNS:# Nothing, but deletes connection named "$name"#***********************************************************************proc DeleteConnection { name } { global ConnectionInfo ConfigDir set newInfo {} set found 0 foreach thing $ConnectionInfo { if {[value $thing ConnectionName] == "$name"} { set found 1 } else { lappend newInfo $thing } } if {!$found} { return } set ConnectionInfo $newInfo SaveConnectionInfo # Delete the config file set fname [file join $ConfigDir conf.$name] catch { file delete $fname } BuildConnectionMenu if {[GetCurrentConnection] == $name} { if {[llength $ConnectionInfo] == 0} { SwitchConnection "" } else { set name [value [lindex $ConnectionInfo 0] ConnectionName] SwitchConnection $name } }}#***********************************************************************# %PROCEDURE: ReplaceConnection# %ARGUMENTS:# conn -- new name/value pairs# %RETURNS:# Nothing, but replaces connection in ConnectionInfo. If no such# connection exists, appends new connection.#***********************************************************************proc ReplaceConnection { conn } { global ConnectionInfo set name [value $conn ConnectionName] set newInfo {} set found 0 foreach thing $ConnectionInfo { if {[value $thing ConnectionName] == "$name"} { lappend newInfo $conn set found 1 } else { lappend newInfo $thing } } if {!$found} { lappend newInfo $conn } set ConnectionInfo $newInfo}proc DeletePPPoEConnection {} { set conn [GetCurrentConnection] if {"$conn" == ""} { return } set ans [tk_dialog .confirm "[m {Confirm Deletion - RP-PPPoE}]" "[m {Are you sure you wish to delete the connection}] `$conn'?" warning 0 No Yes] if {$ans} { DeleteConnection $conn }}#***********************************************************************# %PROCEDURE: CreateMainDialog# %ARGUMENTS:# None# %RETURNS:# Nothing# %DESCRIPTION:# Creates the main window#***********************************************************************proc CreateMainDialog {} { global ConnectionInfoFile global ConnectionInfo global Admin wm title . "RP-PPPoE" wm iconname . "PPPoE" frame .f1 label .l1 -text "Connection: " menubutton .m1 -text "" -indicatoron 1 -menu .m1.menu -relief raised menu .m1.menu -tearoff 0 pack .l1 .m1 -in .f1 -side left -expand 0 -fill x canvas .c -width 40 -height 20 pack .c -in .f1 -side left -expand 0 -fill none # Draw the LED's .c create rectangle 10 1 30 8 -outline "#808080" -fill "#A0A0A0" -tags xmitrect .c create rectangle 10 10 30 18 -outline "#808080" -fill "#A0A0A0" -tags recvrect frame .buttons button .start -text "[m {Start}]" -command "StartPPPoEConnection" button .stop -text "[m {Stop}]" -command "StopPPPoEConnection" button .exit -text "[m {Exit}]" -command "exit" canvas .graph -width 1 -height 1 if {[file writable $ConnectionInfoFile]} { set Admin 1 pack .f1 -side top -expand 1 -fill both pack .buttons -side top -expand 0 -fill x button .delete -text "[m {Delete}]" -command "DeletePPPoEConnection" button .new -text "[m {New Connection...}]" -command "NewPPPoEConnection" button .props -text "[m {Properties...}]" -command "EditConnectionProps" pack .graph -in .f1 -side left -expand 1 -fill both pack .start .stop .delete .props .new .exit -in .buttons -side left -expand 0 -fill none } else { set Admin 0 pack .f1 -side top -expand 0 -fill x pack .buttons -side top -expand 1 -fill both pack .start .stop .exit -in .buttons -side left -expand 0 -fill none pack .graph -in .buttons -side left -expand 1 -fill both } LoadConnectionInfo BuildConnectionMenu # If no connections exist, pop up new connection dialog if {[llength $ConnectionInfo] == 0} { SwitchConnection "" if {$Admin} { update idletasks NewPPPoEConnection } else { tk_dialog .note [m {Note}] "[m {Note: There are no connections defined. You must run this program as root to define connections}]" warning 0 OK } } else { set con [lindex $ConnectionInfo 0] set name [value $con ConnectionName] SwitchConnection $name }}#***********************************************************************# %PROCEDURE: GetCurrentConnection# %ARGUMENTS:# None# %RETURNS:# The name of the current connection in the GUI.#***********************************************************************proc GetCurrentConnection {} { .m1 cget -text}#***********************************************************************# %PROCEDURE: value# %ARGUMENTS:# lst -- a list of key/value pairs# key -- key we're looking for# %RETURNS:# value corresponding to $key, or "" if not found.#***********************************************************************proc value { lst key } { set i
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -